1 | // class ChipGtuData |
---|
2 | // describe the digital data coming out of the Front End Chip |
---|
3 | // (counters, internal memories, logical signals) |
---|
4 | // used by the MacroCell |
---|
5 | // M. Pallavicini - created 19/11/01 |
---|
6 | |
---|
7 | #include <iostream> |
---|
8 | #include "utils.hh" |
---|
9 | #include "ChipGtuData.hh" |
---|
10 | #include "FrontEndChip.hh" |
---|
11 | #include "Etypes.hh" |
---|
12 | |
---|
13 | ClassImp(ChipGtuData) |
---|
14 | |
---|
15 | |
---|
16 | //______________________________________________________________________________ |
---|
17 | ChipGtuData::ChipGtuData(FrontEndChip* fe, Int_t g) : pFrontEnd( fe ), fGtu(g) { |
---|
18 | // |
---|
19 | // Constructor |
---|
20 | // |
---|
21 | fThresh = 0; |
---|
22 | Reset(); |
---|
23 | } |
---|
24 | |
---|
25 | //______________________________________________________________________________ |
---|
26 | ChipGtuData::ChipGtuData() { |
---|
27 | // |
---|
28 | // Empty private ctor |
---|
29 | // |
---|
30 | |
---|
31 | pFrontEnd = 0; |
---|
32 | fGtu = 0; |
---|
33 | fThresh = 0; |
---|
34 | fEmpty = kTRUE; |
---|
35 | fTime = -kHuge; |
---|
36 | fRow = -1; |
---|
37 | fCol = -1; |
---|
38 | fDynode = 0; |
---|
39 | |
---|
40 | } |
---|
41 | |
---|
42 | //______________________________________________________________________________ |
---|
43 | ChipGtuData::~ChipGtuData() { |
---|
44 | // |
---|
45 | // Destructor |
---|
46 | // |
---|
47 | } |
---|
48 | |
---|
49 | //______________________________________________________________________________ |
---|
50 | Int_t ChipGtuData::GetTotalCounts() { |
---|
51 | // |
---|
52 | // Returns the total number of detected counts |
---|
53 | // |
---|
54 | Int_t tot=0; |
---|
55 | for(Int_t index=0; index < FrontEnd()->Channels(); index++) { |
---|
56 | tot += GetCounter(index); |
---|
57 | } |
---|
58 | return tot; |
---|
59 | } |
---|
60 | |
---|
61 | //______________________________________________________________________________ |
---|
62 | Int_t ChipGtuData::GetTotalPureSignal() { |
---|
63 | // |
---|
64 | // Returns the total number of detected signal counts |
---|
65 | // |
---|
66 | Int_t tot=0; |
---|
67 | for(Int_t index=0; index < FrontEnd()->Channels(); index++) { |
---|
68 | tot += GetPureSignal(index); |
---|
69 | } |
---|
70 | return tot; |
---|
71 | } |
---|
72 | |
---|
73 | //______________________________________________________________________________ |
---|
74 | Int_t ChipGtuData::GetNumActivePixels() { |
---|
75 | // |
---|
76 | // Returns the number of pixels with at least one hit |
---|
77 | // |
---|
78 | |
---|
79 | Int_t tot=0; |
---|
80 | for(Int_t index=0; index < FrontEnd()->Channels(); index++) { |
---|
81 | if ( GetCounter(index) > 0 ) |
---|
82 | tot++; |
---|
83 | } |
---|
84 | return tot; |
---|
85 | } |
---|
86 | |
---|
87 | //______________________________________________________________________________ |
---|
88 | void ChipGtuData::Reset() { |
---|
89 | // |
---|
90 | // Reset data (counters, memory) |
---|
91 | // |
---|
92 | |
---|
93 | fCounts.clear(); |
---|
94 | fPureSignal.clear(); |
---|
95 | fCharge.clear(); |
---|
96 | fPureSignal.resize( FrontEnd()->Channels() ); |
---|
97 | fCounts.resize( FrontEnd()->Channels() ); |
---|
98 | fCharge.resize( FrontEnd()->Channels() ); |
---|
99 | |
---|
100 | for(Int_t index=0; index < FrontEnd()->Channels(); index++) { |
---|
101 | fCounts[index] = 0; |
---|
102 | fCharge[index] = 0; |
---|
103 | } |
---|
104 | |
---|
105 | fRowList.clear(); |
---|
106 | fColList.clear(); |
---|
107 | fRowList.resize( FrontEnd()->NumSide() ); |
---|
108 | fColList.resize( FrontEnd()->NumSide() ); |
---|
109 | |
---|
110 | for(Int_t index=0; index < FrontEnd()->NumSide(); index++) { |
---|
111 | fRowList[index] = -1; |
---|
112 | fColList[index] = -1.; |
---|
113 | } |
---|
114 | |
---|
115 | fTime = kHuge; |
---|
116 | fRow = fCol = 0; |
---|
117 | fDynode=0.; |
---|
118 | SetEmpty(); |
---|
119 | } |
---|
120 | |
---|
121 | //______________________________________________________________________________ |
---|
122 | void ChipGtuData::SetRowCol( Int_t r, Int_t c, Double_t t ) { |
---|
123 | // |
---|
124 | // Set the logical signals for rows and columns |
---|
125 | // remember the time at which they go on |
---|
126 | // if already set, do not change the time |
---|
127 | // negative time means NOT activated in this GTU |
---|
128 | // |
---|
129 | |
---|
130 | if ( fRowList[r] < 0. ) { |
---|
131 | fRowList[r] = t; |
---|
132 | } |
---|
133 | |
---|
134 | if ( fColList[c] < 0. ) { |
---|
135 | fColList[c] = t; |
---|
136 | } |
---|
137 | |
---|
138 | if ( t < fTime ) { |
---|
139 | fTime = t; |
---|
140 | fRow = r; |
---|
141 | fCol = c; |
---|
142 | } |
---|
143 | |
---|
144 | SetEmpty( kFALSE ); |
---|
145 | } |
---|
146 | |
---|
147 | //______________________________________________________________________________ |
---|
148 | Bool_t ChipGtuData::GetXYLogic(Int_t& x, Int_t& y, Double_t& t) { |
---|
149 | // |
---|
150 | // Returns coordinates and time of the first XY logic hic |
---|
151 | // returns false if no active counter in this gtu |
---|
152 | // |
---|
153 | |
---|
154 | if ( IsEmpty() ) |
---|
155 | return kFALSE; |
---|
156 | x = fRow; |
---|
157 | y = fCol; |
---|
158 | t = fTime; |
---|
159 | return kTRUE; |
---|
160 | } |
---|
161 | |
---|
162 | //______________________________________________________________________________ |
---|
163 | void ChipGtuData::AddCharge(Int_t ch, Double_t crg, Int_t g) { |
---|
164 | // |
---|
165 | // Analog front end function |
---|
166 | // add charge for a channel |
---|
167 | // |
---|
168 | |
---|
169 | if ( Gtu() != g ) { |
---|
170 | Msg(EsafMsg::Warning) << "GTU=" << Gtu() << " " << g << MsgDispatch; |
---|
171 | FatalError("GTU Id mismatch in ChipGtuData::AddCharge"); |
---|
172 | } |
---|
173 | fCharge[ch] = crg; |
---|
174 | } |
---|
175 | |
---|
176 | //______________________________________________________________________________ |
---|
177 | void ChipGtuData::AddDynodeCharge(Double_t crg, Int_t g) { |
---|
178 | // |
---|
179 | // Add dynode charge for the whole chip in gtu |
---|
180 | // |
---|
181 | |
---|
182 | if ( Gtu() != g ) { |
---|
183 | Msg(EsafMsg::Warning) << "GTU=" << Gtu() << " " << g << MsgDispatch; |
---|
184 | FatalError("GTU Id mismatch in ChipGtuData::AddDynodeCharge"); |
---|
185 | } |
---|
186 | fDynode = crg; |
---|
187 | } |
---|