]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/ESD/AliESDCaloTrigger.cxx
New base class
[u/mrichter/AliRoot.git] / STEER / ESD / AliESDCaloTrigger.cxx
CommitLineData
d5ebf00e 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
042d5330 16/*
17
d5ebf00e 18
042d5330 19
20
21Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
22*/
d5ebf00e 23
24#include "AliESDCaloTrigger.h"
042d5330 25#include "AliLog.h"
26
27#include "TArrayI.h"
28#include "Riostream.h"
29#include <cstdlib>
d5ebf00e 30
31ClassImp(AliESDCaloTrigger)
32
042d5330 33//_______________
35799643 34AliESDCaloTrigger::AliESDCaloTrigger() : AliVCaloTrigger(),
042d5330 35fNEntries(0),
36fCurrent(-1),
37fColumn(0x0),
38fRow(0x0),
39fAmplitude(0x0),
40fTime(0x0),
41fNL0Times(0x0),
42fL0Times(new TArrayI()),
a61738e1 43fL1TimeSum(0x0),
da6062af 44fTriggerBits(0x0),
45fL1Threshold(),
46fL1V0(),
47fL1FrameMask(0)
d5ebf00e 48{
042d5330 49 //
63c22917 50 for (int i = 0; i < 4; i++) fL1Threshold[i] = 0;
da6062af 51 fL1V0[0] = fL1V0[1] = 0;
d5ebf00e 52}
53
042d5330 54//_______________
35799643 55AliESDCaloTrigger::AliESDCaloTrigger(const AliESDCaloTrigger& src) : AliVCaloTrigger(src),
042d5330 56fNEntries(0),
57fCurrent(-1),
58fColumn(0x0),
59fRow(0x0),
60fAmplitude(0x0),
61fTime(0x0),
62fNL0Times(0x0),
63fL0Times(new TArrayI()),
a61738e1 64fL1TimeSum(0x0),
da6062af 65fTriggerBits(0x0),
66fL1Threshold(),
67fL1V0(),
68fL1FrameMask(0)
d5ebf00e 69{
042d5330 70 //
71 src.Copy(*this);
d5ebf00e 72}
73
042d5330 74//_______________
d5ebf00e 75AliESDCaloTrigger::~AliESDCaloTrigger()
76{
042d5330 77 //
78 if (fNEntries) DeAllocate();
79
80 delete fL0Times; fL0Times = 0x0;
d5ebf00e 81}
82
042d5330 83//_______________
84void AliESDCaloTrigger::DeAllocate()
d5ebf00e 85{
042d5330 86 //
a61738e1 87 delete [] fColumn; fColumn = 0x0;
88 delete [] fRow; fRow = 0x0;
89 delete [] fAmplitude; fAmplitude = 0x0;
90 delete [] fTime; fTime = 0x0;
91 delete [] fNL0Times; fNL0Times = 0x0;
92 delete [] fL1TimeSum; fL1TimeSum = 0x0;
93 delete [] fTriggerBits; fTriggerBits = 0x0;
042d5330 94
95 fNEntries = 0;
96 fCurrent = -1;
732a24fe 97
042d5330 98 fL0Times->Reset();
d5ebf00e 99}
100
042d5330 101//_______________
102AliESDCaloTrigger& AliESDCaloTrigger::operator=(const AliESDCaloTrigger& src)
103{
104 //
105 if (this != &src) src.Copy(*this);
106
107 return *this;
108}
732a24fe 109
042d5330 110//_______________
111void AliESDCaloTrigger::Copy(TObject &obj) const
112{
113 //
35799643 114 AliVCaloTrigger::Copy(obj);
042d5330 115
116 AliESDCaloTrigger& dest = static_cast<AliESDCaloTrigger&>(obj);
732a24fe 117
042d5330 118 if (dest.fNEntries) dest.DeAllocate();
119
120 dest.Allocate(fNEntries);
121
122 for (Int_t i = 0; i < fNEntries; i++)
123 {
124 Int_t times[10];
125 for (Int_t j = 0; j < 10; j++) times[j] = fL0Times->At(10 * i + j);
126
a61738e1 127 dest.Add(fColumn[i], fRow[i], fAmplitude[i], fTime[i], times, fNL0Times[i], fL1TimeSum[i], fTriggerBits[i]);
128 }
da6062af 129
63c22917 130 for (int i = 0; i < 4; i++) dest.SetL1Threshold(i, fL1Threshold[i]);
131
da6062af 132 dest.SetL1V0(fL1V0);
133 dest.SetL1FrameMask(fL1FrameMask);
732a24fe 134}
135
042d5330 136//_______________
137void AliESDCaloTrigger::Allocate(Int_t size)
138{
139 //
140 if (!size) return;
141
142 fNEntries = size;
143
144 fColumn = new Int_t[fNEntries];
145 fRow = new Int_t[fNEntries];
146 fAmplitude = new Float_t[fNEntries];
147 fTime = new Float_t[fNEntries];
148 fNL0Times = new Int_t[fNEntries];
042d5330 149 fL1TimeSum = new Int_t[fNEntries];
a61738e1 150 fTriggerBits = new Int_t[fNEntries];
042d5330 151
152 for (Int_t i = 0; i < fNEntries; i++)
153 {
a61738e1 154 fColumn[i] = 0;
155 fRow[i] = 0;
156 fAmplitude[i] = 0;
157 fTime[i] = 0;
158 fNL0Times[i] = 0;
159 fL1TimeSum[i] = 0;
160 fTriggerBits[i] = 0;
042d5330 161 }
162
163 fL0Times->Set(fNEntries * 10);
164}
732a24fe 165
042d5330 166//_______________
a61738e1 167Bool_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)
d5ebf00e 168{
042d5330 169 //
170 fCurrent++;
171
a61738e1 172 fColumn[fCurrent] = col;
173 fRow[fCurrent] = row;
174 fAmplitude[fCurrent] = amp;
175 fTime[fCurrent] = time;
176 fNL0Times[fCurrent] = ntrgtimes;
177 fL1TimeSum[fCurrent] = trgts;
178 fTriggerBits[fCurrent] = trgbits;
179
042d5330 180 if (ntrgtimes > 9)
181 {
182 AliError("Should not have more than 10 L0 times");
183 return kFALSE;
184 }
185
186 for (Int_t i = 0; i < fNL0Times[fCurrent]; i++) fL0Times->AddAt(trgtimes[i], 10 * fCurrent + i);
187
188 return kTRUE;
d5ebf00e 189}
190
042d5330 191//_______________
192Bool_t AliESDCaloTrigger::Next()
193{
194 //
195 if (fCurrent >= fNEntries - 1 || !fNEntries) return kFALSE;
196
197 fCurrent++;
198
199 return kTRUE;
200}
201
202//_______________
203void AliESDCaloTrigger::GetPosition(Int_t& col, Int_t& row) const
204{
205 //
206 if (fCurrent == -1) return;
207
c7d569c0 208 col = fColumn?fColumn[fCurrent]:0;
209 row = fRow?fRow[fCurrent]:0;
042d5330 210}
211
212//_______________
213void AliESDCaloTrigger::GetAmplitude(Float_t& amp) const
214{
215 //
216 if (fCurrent == -1) return;
217
c7d569c0 218 amp = fAmplitude?fAmplitude[fCurrent]:0;
042d5330 219}
220
221//_______________
222void AliESDCaloTrigger::GetTime(Float_t& time) const
223{
224 //
225 if (fCurrent == -1) return;
226
c7d569c0 227 time = fTime?fTime[fCurrent]:0;
042d5330 228}
229
230//_______________
231void AliESDCaloTrigger::GetL1TimeSum(Int_t& amp) const
232{
233 //
234 if (fCurrent == -1) return;
235
c7d569c0 236 amp = fL1TimeSum?fL1TimeSum[fCurrent]:0;
042d5330 237}
238
239//_______________
240void AliESDCaloTrigger::GetNL0Times(Int_t& ntimes) const
241{
242 //
243 if (fCurrent == -1) return;
244
c7d569c0 245 ntimes = fNL0Times?fNL0Times[fCurrent]:0;
042d5330 246}
247
248//_______________
a61738e1 249void AliESDCaloTrigger::GetTriggerBits(Int_t& bits) const
042d5330 250{
251 //
252 if (fCurrent == -1) return;
253
c7d569c0 254 bits = fTriggerBits?fTriggerBits[fCurrent]:0;
042d5330 255}
256
257//_______________
258void AliESDCaloTrigger::GetL0Times(Int_t times[]) const
259{
260 //
261 if (fCurrent == -1) return;
c7d569c0 262
263 if (fNL0Times && fL0Times) {
264 for (Int_t i = 0; i < fNL0Times[fCurrent]; i++) times[i] = fL0Times->At(10 * fCurrent + i);
265 }
042d5330 266}
267
268//_______________
269void AliESDCaloTrigger::Print(const Option_t* /*opt*/) const
270{
271 //
272 if (fCurrent == -1) return;
c7d569c0 273 if (!fColumn) return;
274 if (!fRow) return;
275 if (!fAmplitude) return;
276 if (!fTime) return;
277 if (!fNL0Times) return;
278 if (!fL0Times) return;
279 if (!fL1TimeSum) return;
280 if (!fTriggerBits) return;
d5ebf00e 281
042d5330 282 printf("============\n");
283 printf("--L0:\n");
284 printf("\tPOSITION (X: %2d Y: %2d) / FITTED F-ALTRO (AMP: %4f TIME: %3f)\n",
285 fColumn[fCurrent], fRow[fCurrent], fAmplitude[fCurrent], fTime[fCurrent]);
286 printf("\t%d L0 TIMES (", fNL0Times[fCurrent]);
287 for (Int_t i = 0; i < fNL0Times[fCurrent]; i++) printf("%2d ",fL0Times->At(10 * fCurrent + i));
288 printf(")\n");
289 printf("--L1:\n");
290 printf("\tTIME SUM: %4d\n", fL1TimeSum[fCurrent]);
63c22917 291 printf("\tHIGH THRESHOLDS (GAMMA: %4d, JET: %4d)\n", fL1Threshold[0], fL1Threshold[1]);
292 printf("\tLOW THRESHOLDS (GAMMA: %4d, JET: %4d)\n", fL1Threshold[2], fL1Threshold[3]);
a61738e1 293 printf("--TRIGGER BITS: 0x%x\n", fTriggerBits[fCurrent]);
042d5330 294}