Line data Source code
1 : /**************************************************************************
2 : * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 : * *
4 : * Author: The ALICE Off-line Project. *
5 : * Contributors are mentioned in the code where appropriate. *
6 : * *
7 : * Permission to use, copy, modify and distribute this software and its *
8 : * documentation strictly for non-commercial purposes is hereby granted *
9 : * without fee, provided that the above copyright notice appears in all *
10 : * copies and that both the copyright notice and this permission notice *
11 : * appear in the supporting documentation. The authors make no claims *
12 : * about the suitability of this software for any purpose. It is *
13 : * provided "as is" without express or implied warranty. *
14 : **************************************************************************/
15 :
16 : /*
17 :
18 :
19 :
20 :
21 : Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
22 : */
23 :
24 : #include "AliESDCaloTrigger.h"
25 : #include "AliLog.h"
26 :
27 : #include "TArrayI.h"
28 : #include "Riostream.h"
29 : #include <cstdlib>
30 :
31 172 : ClassImp(AliESDCaloTrigger)
32 :
33 : //_______________
34 36 : AliESDCaloTrigger::AliESDCaloTrigger() : AliVCaloTrigger(),
35 36 : fNEntries(0),
36 36 : fCurrent(-1),
37 36 : fColumn(0x0),
38 36 : fRow(0x0),
39 36 : fAmplitude(0x0),
40 36 : fTime(0x0),
41 36 : fNL0Times(0x0),
42 108 : fL0Times(new TArrayI()),
43 36 : fL1TimeSum(0x0),
44 36 : fTriggerBits(0x0),
45 36 : fL1Threshold(),
46 36 : fL1V0(),
47 36 : fL1FrameMask(0),
48 36 : fL1DCALThreshold(),
49 36 : fL1SubRegion(0x0),
50 36 : fL1DCALFrameMask(0),
51 36 : fMedian(),
52 36 : fTriggerBitWord(0),
53 36 : fL1DCALV0()
54 180 : {
55 : //
56 360 : for (int i = 0; i < 4; i++) {fL1Threshold[i] = fL1DCALThreshold[i] = 0;}
57 36 : fL1V0[0] = fL1V0[1] = 0;
58 36 : fL1DCALV0[0] = fL1DCALV0[1] = 0;
59 36 : fMedian[0] = fMedian[1] = 0;
60 72 : }
61 :
62 : //_______________
63 0 : AliESDCaloTrigger::AliESDCaloTrigger(const AliESDCaloTrigger& src) : AliVCaloTrigger(src),
64 0 : fNEntries(0),
65 0 : fCurrent(-1),
66 0 : fColumn(0x0),
67 0 : fRow(0x0),
68 0 : fAmplitude(0x0),
69 0 : fTime(0x0),
70 0 : fNL0Times(0x0),
71 0 : fL0Times(new TArrayI()),
72 0 : fL1TimeSum(0x0),
73 0 : fL1Threshold(),
74 0 : fL1V0(),
75 0 : fL1FrameMask(0),
76 0 : fL1DCALThreshold(),
77 0 : fL1SubRegion(0x0),
78 0 : fL1DCALFrameMask(0),
79 0 : fMedian(),
80 0 : fTriggerBitWord(0),
81 0 : fL1DCALV0()
82 0 : {
83 : //
84 0 : src.Copy(*this);
85 0 : }
86 :
87 : //_______________
88 : AliESDCaloTrigger::~AliESDCaloTrigger()
89 120 : {
90 : //
91 21 : if (fNEntries) DeAllocate();
92 :
93 60 : delete fL0Times; fL0Times = 0x0;
94 60 : }
95 :
96 : //_______________
97 : void AliESDCaloTrigger::DeAllocate()
98 : {
99 : //
100 210 : delete [] fColumn; fColumn = 0x0;
101 143 : delete [] fRow; fRow = 0x0;
102 143 : delete [] fAmplitude; fAmplitude = 0x0;
103 143 : delete [] fTime; fTime = 0x0;
104 143 : delete [] fNL0Times; fNL0Times = 0x0;
105 143 : delete [] fL1TimeSum; fL1TimeSum = 0x0;
106 143 : delete [] fL1SubRegion; fL1SubRegion = 0x0;
107 143 : delete [] fTriggerBits; fTriggerBits = 0x0;
108 :
109 67 : fNEntries = 0;
110 67 : fCurrent = -1;
111 :
112 67 : fL0Times->Reset();
113 67 : }
114 :
115 : //_______________
116 : AliESDCaloTrigger& AliESDCaloTrigger::operator=(const AliESDCaloTrigger& src)
117 : {
118 : //
119 0 : if (this != &src) src.Copy(*this);
120 :
121 0 : return *this;
122 : }
123 :
124 : //_______________
125 : void AliESDCaloTrigger::Copy(TObject &obj) const
126 : {
127 : //
128 8 : AliVCaloTrigger::Copy(obj);
129 :
130 4 : AliESDCaloTrigger& dest = static_cast<AliESDCaloTrigger&>(obj);
131 :
132 4 : if (dest.fNEntries) dest.DeAllocate();
133 :
134 4 : dest.Allocate(fNEntries);
135 :
136 8 : for (Int_t i = 0; i < fNEntries; i++)
137 : {
138 0 : Int_t times[10];
139 0 : for (Int_t j = 0; j < 10; j++) times[j] = fL0Times->At(10 * i + j);
140 :
141 0 : dest.Add(fColumn[i], fRow[i], fAmplitude[i], fTime[i], times, fNL0Times[i], fL1TimeSum[i], fL1SubRegion[i], fTriggerBits[i]);
142 0 : }
143 :
144 40 : for (int i = 0; i < 4; i++) dest.SetL1Threshold(i, fL1Threshold[i]);
145 40 : for (int i = 0; i < 4; i++) dest.SetL1Threshold(1, i, fL1DCALThreshold[i]);
146 :
147 4 : dest.SetL1V0(fL1V0);
148 4 : dest.SetL1V0(1, fL1DCALV0);
149 4 : dest.SetL1FrameMask(fL1FrameMask);
150 4 : dest.SetL1FrameMask(1, fL1DCALFrameMask);
151 4 : }
152 :
153 : //_______________
154 : void AliESDCaloTrigger::Allocate(Int_t size)
155 : {
156 : //
157 32 : if (!size) return;
158 :
159 4 : fNEntries = size;
160 :
161 4 : fColumn = new Int_t[fNEntries];
162 4 : fRow = new Int_t[fNEntries];
163 4 : fAmplitude = new Float_t[fNEntries];
164 4 : fTime = new Float_t[fNEntries];
165 4 : fNL0Times = new Int_t[fNEntries];
166 4 : fL1TimeSum = new Int_t[fNEntries];
167 4 : fL1SubRegion = new Int_t[fNEntries];
168 4 : fTriggerBits = new Int_t[fNEntries];
169 :
170 292 : for (Int_t i = 0; i < fNEntries; i++)
171 : {
172 142 : fColumn[i] = 0;
173 142 : fRow[i] = 0;
174 142 : fAmplitude[i] = 0;
175 142 : fTime[i] = 0;
176 142 : fNL0Times[i] = 0;
177 142 : fL1TimeSum[i] = 0;
178 142 : fL1SubRegion[i] = 0;
179 142 : fTriggerBits[i] = 0;
180 : }
181 :
182 4 : fL0Times->Set(fNEntries * 10);
183 20 : }
184 :
185 : //_______________
186 : Bool_t AliESDCaloTrigger::Add(Int_t col, Int_t row, Float_t amp, Float_t time, Int_t trgtimes[], Int_t ntrgtimes, Int_t trgts, Int_t trgbits)
187 : {
188 : //
189 284 : fCurrent++;
190 :
191 142 : fColumn[fCurrent] = col;
192 142 : fRow[fCurrent] = row;
193 142 : fAmplitude[fCurrent] = amp;
194 142 : fTime[fCurrent] = time;
195 142 : fNL0Times[fCurrent] = ntrgtimes;
196 142 : fL1TimeSum[fCurrent] = trgts;
197 142 : fTriggerBits[fCurrent] = trgbits;
198 :
199 142 : if (ntrgtimes > 9)
200 : {
201 0 : AliError("Should not have more than 10 L0 times");
202 0 : return kFALSE;
203 : }
204 :
205 336 : for (Int_t i = 0; i < fNL0Times[fCurrent]; i++) fL0Times->AddAt(trgtimes[i], 10 * fCurrent + i);
206 :
207 142 : return kTRUE;
208 142 : }
209 :
210 : //_______________
211 : Bool_t AliESDCaloTrigger::Add(Int_t col, Int_t row, Float_t amp, Float_t time, Int_t trgtimes[], Int_t ntrgtimes, Int_t trgts, Int_t subra, Int_t trgbits)
212 : {
213 : //
214 284 : Add(col, row, amp, time, trgtimes, ntrgtimes, trgts, trgbits);
215 142 : fL1SubRegion[fCurrent] = subra;
216 :
217 142 : return kTRUE;
218 : }
219 :
220 : //_______________
221 : Bool_t AliESDCaloTrigger::Next()
222 : {
223 : //
224 474 : if (fCurrent >= fNEntries - 1 || !fNEntries) return kFALSE;
225 :
226 142 : fCurrent++;
227 :
228 142 : return kTRUE;
229 158 : }
230 :
231 : //_______________
232 : void AliESDCaloTrigger::GetPosition(Int_t& col, Int_t& row) const
233 : {
234 : //
235 284 : if (fCurrent == -1) return;
236 :
237 426 : col = fColumn?fColumn[fCurrent]:0;
238 426 : row = fRow?fRow[fCurrent]:0;
239 284 : }
240 :
241 : //_______________
242 : void AliESDCaloTrigger::GetAmplitude(Float_t& amp) const
243 : {
244 : //
245 284 : if (fCurrent == -1) return;
246 :
247 426 : amp = fAmplitude?fAmplitude[fCurrent]:0;
248 284 : }
249 :
250 : //_______________
251 : void AliESDCaloTrigger::GetTime(Float_t& time) const
252 : {
253 : //
254 284 : if (fCurrent == -1) return;
255 :
256 426 : time = fTime?fTime[fCurrent]:0;
257 284 : }
258 :
259 : //_______________
260 : void AliESDCaloTrigger::GetL1TimeSum(Int_t& amp) const
261 : {
262 : //
263 284 : if (fCurrent == -1) return;
264 :
265 426 : amp = fL1TimeSum?fL1TimeSum[fCurrent]:0;
266 284 : }
267 :
268 : //_______________
269 : Int_t AliESDCaloTrigger::GetL1TimeSum() const
270 : {
271 : //
272 0 : if (fCurrent == -1) return -1;
273 :
274 0 : return ((fL1TimeSum)?fL1TimeSum[fCurrent]:0);
275 0 : }
276 :
277 : //_______________
278 : void AliESDCaloTrigger::GetL1SubRegion(Int_t& sb) const
279 : {
280 : //
281 0 : if (fCurrent == -1) return;
282 :
283 0 : sb = fL1SubRegion?fL1SubRegion[fCurrent]:0;
284 0 : }
285 :
286 : //_______________
287 : Int_t AliESDCaloTrigger::GetL1SubRegion() const
288 : {
289 : //
290 0 : if (fCurrent == -1) return -1;
291 :
292 0 : return ((fL1SubRegion)?fL1SubRegion[fCurrent]:0);
293 0 : }
294 :
295 : //_______________
296 : void AliESDCaloTrigger::GetNL0Times(Int_t& ntimes) const
297 : {
298 : //
299 284 : if (fCurrent == -1) return;
300 :
301 426 : ntimes = fNL0Times?fNL0Times[fCurrent]:0;
302 284 : }
303 :
304 : //_______________
305 : void AliESDCaloTrigger::GetTriggerBits(Int_t& bits) const
306 : {
307 : //
308 284 : if (fCurrent == -1) return;
309 :
310 426 : bits = fTriggerBits?fTriggerBits[fCurrent]:0;
311 284 : }
312 :
313 : //_______________
314 : void AliESDCaloTrigger::GetL0Times(Int_t times[]) const
315 : {
316 : //
317 284 : if (fCurrent == -1) return;
318 :
319 284 : if (fNL0Times && fL0Times) {
320 336 : for (Int_t i = 0; i < fNL0Times[fCurrent]; i++) times[i] = fL0Times->At(10 * fCurrent + i);
321 142 : }
322 142 : }
323 :
324 : //_______________
325 : void AliESDCaloTrigger::Print(const Option_t* /*opt*/) const
326 : {
327 : //
328 0 : if (fCurrent == -1) return;
329 0 : if (!fColumn) return;
330 0 : if (!fRow) return;
331 0 : if (!fAmplitude) return;
332 0 : if (!fTime) return;
333 0 : if (!fNL0Times) return;
334 0 : if (!fL0Times) return;
335 0 : if (!fL1TimeSum) return;
336 0 : if (!fTriggerBits) return;
337 :
338 0 : printf("============\n");
339 0 : printf("--L0:\n");
340 0 : printf("\tPOSITION (X: %2d Y: %2d) / FITTED F-ALTRO (AMP: %4f TIME: %3f)\n",
341 0 : fColumn[fCurrent], fRow[fCurrent], fAmplitude[fCurrent], fTime[fCurrent]);
342 0 : printf("\t%d L0 TIMES (", fNL0Times[fCurrent]);
343 0 : for (Int_t i = 0; i < fNL0Times[fCurrent]; i++) printf("%2d ",fL0Times->At(10 * fCurrent + i));
344 0 : printf(")\n");
345 0 : printf("--L1:\n");
346 0 : printf("\tTIME SUM: %4d\n", fL1TimeSum[fCurrent]);
347 0 : printf("\tHIGH THRESHOLDS (GAMMA: %4d, JET: %4d)\n", fL1Threshold[0], fL1Threshold[1]);
348 0 : printf("\tLOW THRESHOLDS (GAMMA: %4d, JET: %4d)\n", fL1Threshold[2], fL1Threshold[3]);
349 0 : printf("--TRIGGER BITS: 0x%x\n", fTriggerBits[fCurrent]);
350 0 : }
|