]>
Commit | Line | Data |
---|---|---|
25354ff4 | 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 | /* $Id$ */ | |
59264fa6 | 16 | /* $Log $ */ |
25354ff4 | 17 | |
18 | //_________________________________________________________________________ | |
25354ff4 | 19 | // Class for trigger analysis. |
59264fa6 | 20 | // Digits are grouped in TRU's (Trigger Units). A TRU consist of 16x28 |
21 | // crystals ordered fNTRUPhi x fNTRUZ. The algorithm searches all possible | |
0b2ec9f7 | 22 | // 2x2 and nxn (n multiple of 4) crystal combinations per each TRU, adding the |
23 | // digits amplitude and finding the maximum. Maxima are transformed in ADC | |
24 | // time samples. Each time bin is compared to the trigger threshold until it is larger | |
59264fa6 | 25 | // and then, triggers are set. Thresholds need to be fixed. |
bb38a8fc | 26 | // Usage: |
27 | // | |
28 | // //Inside the event loop | |
29 | // AliEMCALTrigger *tr = new AliEMCALTrigger();//Init Trigger | |
59264fa6 | 30 | // tr->SetL0Threshold(100); |
bb38a8fc | 31 | // tr->SetL1JetLowPtThreshold(1000); |
bb38a8fc | 32 | // tr->SetL1JetHighPtThreshold(20000); |
33 | // tr->Trigger(); //Execute Trigger | |
34 | // tr->Print(""); //Print result, with "deb" option all data members | |
35 | // //are printed | |
36 | // | |
25354ff4 | 37 | //*-- Author: Gustavo Conesa & Yves Schutz (IFIC, CERN) |
38 | ////////////////////////////////////////////////////////////////////////////// | |
39 | ||
40 | ||
41 | // --- ROOT system --- | |
59264fa6 | 42 | //#include "TMatrixD.h" |
25354ff4 | 43 | |
44 | // --- ALIROOT system --- | |
59264fa6 | 45 | #include "AliPHOS.h" |
25354ff4 | 46 | #include "AliPHOSTrigger.h" |
47 | #include "AliPHOSGeometry.h" | |
48 | #include "AliPHOSGetter.h" | |
431a9211 | 49 | #include "AliPHOSPulseGenerator.h" |
b165f59d | 50 | #include "AliTriggerInput.h" |
59264fa6 | 51 | //#include "AliLog.h" |
25354ff4 | 52 | |
53 | ClassImp(AliPHOSTrigger) | |
54 | ||
b165f59d | 55 | //______________________________________________________________________ |
56 | AliPHOSTrigger::AliPHOSTrigger() | |
59264fa6 | 57 | : AliTriggerDetector(), |
3663622c | 58 | f2x2MaxAmp(-1), f2x2CrystalPhi(-1), f2x2CrystalEta(-1), f2x2SM(0), |
0b2ec9f7 | 59 | fnxnMaxAmp(-1), fnxnCrystalPhi(-1), fnxnCrystalEta(-1), fnxnSM(0), |
60 | fADCValuesHighnxn(0), fADCValuesLownxn(0), | |
3663622c | 61 | fADCValuesHigh2x2(0), fADCValuesLow2x2(0), fDigitsList(0), |
59264fa6 | 62 | fL0Threshold(50), fL1JetLowPtThreshold(200), fL1JetHighPtThreshold(500), |
0b2ec9f7 | 63 | fNTRU(8), fNTRUZ(2), fNTRUPhi(4), fPatchSize(1), fSimulation(kTRUE) |
25354ff4 | 64 | { |
b165f59d | 65 | //ctor |
0b2ec9f7 | 66 | fADCValuesHighnxn = 0x0; //new Int_t[fTimeBins]; |
67 | fADCValuesLownxn = 0x0; //new Int_t[fTimeBins]; | |
59264fa6 | 68 | fADCValuesHigh2x2 = 0x0; //new Int_t[fTimeBins]; |
69 | fADCValuesLow2x2 = 0x0; //new Int_t[fTimeBins]; | |
70 | ||
59264fa6 | 71 | SetName("PHOS"); |
72 | CreateInputs(); | |
73 | ||
74 | //Print("") ; | |
25354ff4 | 75 | } |
76 | ||
77 | //____________________________________________________________________________ | |
3663622c | 78 | AliPHOSTrigger::AliPHOSTrigger(const AliPHOSTrigger & trig) : |
79 | AliTriggerDetector(trig), | |
80 | f2x2MaxAmp(trig.f2x2MaxAmp), | |
81 | f2x2CrystalPhi(trig.f2x2CrystalPhi), | |
82 | f2x2CrystalEta(trig.f2x2CrystalEta), | |
83 | f2x2SM(trig.f2x2SM), | |
0b2ec9f7 | 84 | fnxnMaxAmp(trig.fnxnMaxAmp), |
85 | fnxnCrystalPhi(trig.fnxnCrystalPhi), | |
86 | fnxnCrystalEta(trig.fnxnCrystalEta), | |
87 | fnxnSM(trig.fnxnSM), | |
88 | fADCValuesHighnxn(trig.fADCValuesHighnxn), | |
89 | fADCValuesLownxn(trig.fADCValuesLownxn), | |
3663622c | 90 | fADCValuesHigh2x2(trig.fADCValuesHigh2x2), |
91 | fADCValuesLow2x2(trig.fADCValuesLow2x2), | |
92 | fDigitsList(trig.fDigitsList), | |
93 | fL0Threshold(trig.fL0Threshold), | |
94 | fL1JetLowPtThreshold(trig.fL1JetLowPtThreshold), | |
95 | fL1JetHighPtThreshold(trig.fL1JetHighPtThreshold), | |
96 | fNTRU(trig.fNTRU), | |
97 | fNTRUZ(trig.fNTRUZ), | |
98 | fNTRUPhi(trig.fNTRUPhi), | |
0b2ec9f7 | 99 | fPatchSize(trig.fPatchSize), fSimulation(trig.fSimulation) |
25354ff4 | 100 | { |
25354ff4 | 101 | // cpy ctor |
25354ff4 | 102 | } |
103 | ||
59264fa6 | 104 | //_________________________________________________________________________ |
3663622c | 105 | AliPHOSTrigger & AliPHOSTrigger::operator = (const AliPHOSTrigger &) |
106 | { | |
107 | Fatal("operator =", "no implemented"); | |
108 | return *this; | |
109 | } | |
110 | ||
b165f59d | 111 | void AliPHOSTrigger::CreateInputs() |
112 | { | |
113 | // inputs | |
114 | ||
115 | // Do not create inputs again!! | |
116 | if( fInputs.GetEntriesFast() > 0 ) return; | |
117 | ||
59264fa6 | 118 | fInputs.AddLast( new AliTriggerInput( "PHOS_L0", "PHOS L0", 0x02 ) ); |
119 | fInputs.AddLast( new AliTriggerInput( "PHOS_JetHPt_L1","PHOS Jet High Pt L1", 0x04 ) ); | |
120 | fInputs.AddLast( new AliTriggerInput( "PHOS_JetLPt_L1","PHOS Jet Low Pt L1", 0x08 ) ); | |
b165f59d | 121 | |
122 | } | |
123 | ||
25354ff4 | 124 | //____________________________________________________________________________ |
59264fa6 | 125 | void AliPHOSTrigger::FillTRU(const TClonesArray * digits, const AliPHOSGeometry * geom, TClonesArray * ampmatrix, TClonesArray * timeRmatrix) const { |
25354ff4 | 126 | |
59264fa6 | 127 | //Orders digits ampitudes list and times in fNTRU TRUs (28x16 crystals) |
128 | //per module. Each TRU is a TMatrixD, and they are kept in TClonesArrays. | |
129 | //In a module, the number of TRU in phi is fNTRUPhi, and the number of | |
130 | //TRU in eta is fNTRUZ. | |
25354ff4 | 131 | |
bb38a8fc | 132 | //Check data members |
133 | ||
134 | if(fNTRUZ*fNTRUPhi != fNTRU) | |
135 | Error("FillTRU"," Wrong number of TRUS per Z or Phi"); | |
25354ff4 | 136 | |
59264fa6 | 137 | //Initilize and declare variables |
138 | Int_t nModules = geom->GetNModules(); | |
139 | Int_t nCrystalsPhi = geom->GetNPhi()/fNTRUPhi ;// 64/4=16 | |
140 | Int_t nCrystalsZ = geom->GetNZ()/fNTRUZ ;// 56/2=28 | |
141 | Int_t relid[4] ; | |
142 | Float_t amp = -1; | |
143 | Float_t timeR = -1; | |
144 | Int_t id = -1; | |
25354ff4 | 145 | |
59264fa6 | 146 | //List of TRU matrices initialized to 0. |
2ff6837e | 147 | for(Int_t k = 0; k < fNTRU*nModules ; k++){ |
59264fa6 | 148 | TMatrixD * amptrus = new TMatrixD(nCrystalsPhi,nCrystalsZ) ; |
149 | TMatrixD * timeRtrus = new TMatrixD(nCrystalsPhi,nCrystalsZ) ; | |
150 | for(Int_t i = 0; i < nCrystalsPhi; i++){ | |
151 | for(Int_t j = 0; j < nCrystalsZ; j++){ | |
152 | (*amptrus)(i,j) = 0.0; | |
153 | (*timeRtrus)(i,j) = 0.0; | |
154 | } | |
155 | } | |
156 | new((*ampmatrix)[k]) TMatrixD(*amptrus) ; | |
157 | new((*timeRmatrix)[k]) TMatrixD(*timeRtrus) ; | |
25354ff4 | 158 | } |
159 | ||
160 | AliPHOSDigit * dig ; | |
59264fa6 | 161 | |
bb38a8fc | 162 | //Digits loop to fill TRU matrices with amplitudes. |
163 | ||
25354ff4 | 164 | for(Int_t idig = 0 ; idig < digits->GetEntriesFast() ; idig++){ |
165 | ||
59264fa6 | 166 | dig = static_cast<AliPHOSDigit *>(digits->At(idig)) ; |
0b2ec9f7 | 167 | amp = dig->GetEnergy() ; // Energy of the digit |
59264fa6 | 168 | id = dig->GetId() ; // Id label of the cell |
169 | timeR = dig->GetTimeR() ; // Earliest time of the digit | |
170 | geom->AbsToRelNumbering(id, relid) ; | |
bb38a8fc | 171 | //Transform digit number into 4 numbers |
25354ff4 | 172 | //relid[0] = module |
173 | //relid[1] = EMC (0) or CPV (-1) | |
174 | //relid[2] = row <= 64 (fNPhi) | |
175 | //relid[3] = column <= 56 (fNZ) | |
176 | ||
bb38a8fc | 177 | if(relid[1] == 0){//Not CPV, Only EMC digits |
178 | ||
59264fa6 | 179 | //Check to which TRU in the supermodule belongs the crystal. |
bb38a8fc | 180 | //Supermodules are divided in a TRU matrix of dimension |
181 | //(fNTRUPhi,fNTRUZ). | |
59264fa6 | 182 | //Each TRU is a crystal matrix of dimension (nCrystalsPhi,nCrystalsZ) |
25354ff4 | 183 | |
bb38a8fc | 184 | //First calculate the row and column in the supermodule |
59264fa6 | 185 | //of the TRU to which the crystal belongs. |
bb38a8fc | 186 | Int_t col = (relid[3]-1)/nCrystalsZ+1; |
59264fa6 | 187 | Int_t row = (relid[2]-1)/nCrystalsPhi+1; |
188 | ||
189 | //Calculate label number of the TRU | |
190 | Int_t itru = (row-1) + (col-1)*fNTRUPhi + (relid[0]-1)*fNTRU ; | |
2ff6837e | 191 | |
59264fa6 | 192 | //Fill TRU matrix with crystal values |
193 | TMatrixD * amptrus = dynamic_cast<TMatrixD *>(ampmatrix->At(itru)) ; | |
194 | TMatrixD * timeRtrus = dynamic_cast<TMatrixD *>(timeRmatrix->At(itru)) ; | |
2ff6837e | 195 | |
59264fa6 | 196 | //Calculate row and column of the crystal inside the TRU with number itru |
197 | Int_t irow = (relid[2]-1) - (row-1) * nCrystalsPhi; | |
198 | Int_t icol = (relid[3]-1) - (col-1) * nCrystalsZ; | |
199 | ||
200 | (*amptrus)(irow,icol) = amp ; | |
201 | (*timeRtrus)(irow,icol) = timeR ; | |
25354ff4 | 202 | } |
203 | } | |
25354ff4 | 204 | } |
205 | ||
59264fa6 | 206 | //______________________________________________________________________ |
207 | void AliPHOSTrigger::GetCrystalPhiEtaIndexInModuleFromTRUIndex(const Int_t itru,const Int_t iphitru,const Int_t ietatru,Int_t &iphiMod,Int_t &ietaMod,const AliPHOSGeometry* geom) const | |
208 | { | |
209 | // This method transforms the (eta,phi) index of a crystals in a | |
210 | // TRU matrix into Super Module (eta,phi) index. | |
211 | ||
212 | // Calculate in which row and column in which the TRU are | |
213 | // ordered in the SM | |
214 | Int_t col = itru/ fNTRUPhi + 1; | |
215 | Int_t row = itru - (col-1)*fNTRUPhi + 1; | |
216 | ||
217 | //Calculate the (eta,phi) index in SM | |
218 | Int_t nCrystalsPhi = geom->GetNPhi()/fNTRUPhi; | |
219 | Int_t nCrystalsZ = geom->GetNZ()/fNTRUZ; | |
220 | ||
221 | iphiMod = nCrystalsPhi*(row-1) + iphitru + 1 ; | |
222 | ietaMod = nCrystalsZ*(col-1) + ietatru + 1 ; | |
223 | ||
224 | } | |
25354ff4 | 225 | //____________________________________________________________________________ |
0b2ec9f7 | 226 | void AliPHOSTrigger::MakeSlidingCell(const TClonesArray * amptrus, const TClonesArray * timeRtrus, const Int_t imod, TMatrixD *ampmax2, TMatrixD *ampmaxn, const AliPHOSGeometry *geom){ |
227 | //Sums energy of all possible 2x2 (L0) and nxn (L1) crystals per each TRU. | |
59264fa6 | 228 | //Fast signal in the experiment is given by 2x2 crystals, |
229 | //for this reason we loop inside the TRU crystals by 2. | |
25354ff4 | 230 | |
59264fa6 | 231 | //Declare and initialize varibles |
232 | Int_t nCrystalsPhi = geom->GetNPhi()/fNTRUPhi ;// 64/4=16 | |
233 | Int_t nCrystalsZ = geom->GetNZ()/fNTRUZ ;// 56/2=28 | |
234 | Float_t amp2 = 0 ; | |
0b2ec9f7 | 235 | Float_t ampn = 0 ; |
236 | for(Int_t i = 0; i < 4; i++){ | |
59264fa6 | 237 | for(Int_t j = 0; j < fNTRU; j++){ |
238 | (*ampmax2)(i,j) = -1; | |
0b2ec9f7 | 239 | (*ampmaxn)(i,j) = -1; |
59264fa6 | 240 | } |
241 | } | |
25354ff4 | 242 | |
59264fa6 | 243 | //Create matrix that will contain 2x2 amplitude sums |
0b2ec9f7 | 244 | //used to calculate the nxn sums |
59264fa6 | 245 | TMatrixD * tru2x2 = new TMatrixD(nCrystalsPhi/2,nCrystalsZ/2) ; |
59264fa6 | 246 | for(Int_t i = 0; i < nCrystalsPhi/2; i++) |
247 | for(Int_t j = 0; j < nCrystalsZ/2; j++) | |
248 | (*tru2x2)(i,j) = 0.0; | |
249 | ||
25354ff4 | 250 | //Loop over all TRUS in a module |
59264fa6 | 251 | for(Int_t itru = 0 + (imod - 1) * fNTRU ; itru < imod*fNTRU ; itru++){ |
252 | TMatrixD * amptru = dynamic_cast<TMatrixD *>(amptrus->At(itru)) ; | |
253 | TMatrixD * timeRtru = dynamic_cast<TMatrixD *>(timeRtrus->At(itru)) ; | |
254 | Int_t mtru = itru-(imod-1)*fNTRU ; //Number of TRU in Module | |
255 | ||
256 | //Sliding 2x2, add 2x2 amplitudes (NOT OVERLAP) | |
2ff6837e | 257 | for(Int_t irow = 0 ; irow < nCrystalsPhi; irow += 2){ |
258 | for(Int_t icol = 0 ; icol < nCrystalsZ ; icol += 2){ | |
59264fa6 | 259 | amp2 = (*amptru)(irow,icol)+(*amptru)(irow+1,icol)+ |
260 | (*amptru)(irow,icol+1)+(*amptru)(irow+1,icol+1); | |
0b2ec9f7 | 261 | |
262 | //Fill new matrix with added 2x2 crystals for use in nxn sums | |
59264fa6 | 263 | (*tru2x2)(irow/2,icol/2) = amp2 ; |
264 | //Select 2x2 maximum sums to select L0 | |
265 | if(amp2 > (*ampmax2)(0,mtru)){ | |
266 | (*ampmax2)(0,mtru) = amp2 ; | |
267 | (*ampmax2)(1,mtru) = irow; | |
268 | (*ampmax2)(2,mtru) = icol; | |
25354ff4 | 269 | } |
25354ff4 | 270 | } |
271 | } | |
2ff6837e | 272 | |
59264fa6 | 273 | //Find most recent time in the selected 2x2 cell |
274 | (*ampmax2)(3,mtru) = 1 ; | |
275 | Int_t row2 = static_cast <Int_t> ((*ampmax2)(1,mtru)); | |
276 | Int_t col2 = static_cast <Int_t> ((*ampmax2)(2,mtru)); | |
277 | for(Int_t i = 0; i<2; i++){ | |
278 | for(Int_t j = 0; j<2; j++){ | |
279 | if((*amptru)(row2+i,col2+j) > 0 && (*timeRtru)(row2+i,col2+j)> 0){ | |
280 | if((*timeRtru)(row2+i,col2+j) < (*ampmax2)(3,mtru) ) | |
281 | (*ampmax2)(3,mtru) = (*timeRtru)(row2+i,col2+j); | |
282 | } | |
283 | } | |
284 | } | |
2ff6837e | 285 | |
0b2ec9f7 | 286 | //Sliding nxn, add nxn amplitudes (OVERLAP) |
287 | if(fPatchSize > 0){ | |
288 | for(Int_t irow = 0 ; irow < nCrystalsPhi/2; irow++){ | |
289 | for(Int_t icol = 0 ; icol < nCrystalsZ/2 ; icol++){ | |
290 | ampn = 0; | |
291 | if( (irow+fPatchSize) < nCrystalsPhi/2 && (icol+fPatchSize) < nCrystalsZ/2){//Avoid exit the TRU | |
292 | for(Int_t i = 0 ; i <= fPatchSize ; i++) | |
293 | for(Int_t j = 0 ; j <= fPatchSize ; j++) | |
294 | ampn += (*tru2x2)(irow+i,icol+j); | |
295 | //Select nxn maximum sums to select L1 | |
296 | if(ampn > (*ampmaxn)(0,mtru)){ | |
297 | (*ampmaxn)(0,mtru) = ampn ; | |
298 | (*ampmaxn)(1,mtru) = irow*2; | |
299 | (*ampmaxn)(2,mtru) = icol*2; | |
300 | } | |
59264fa6 | 301 | } |
302 | } | |
303 | } | |
0b2ec9f7 | 304 | |
305 | //Find most recent time in selected nxn cell | |
306 | (*ampmaxn)(3,mtru) = 1 ; | |
307 | Int_t rown = static_cast <Int_t> ((*ampmaxn)(1,mtru)); | |
308 | Int_t coln = static_cast <Int_t> ((*ampmaxn)(2,mtru)); | |
309 | for(Int_t i = 0; i<4*fPatchSize; i++){ | |
310 | for(Int_t j = 0; j<4*fPatchSize; j++){ | |
311 | if( (rown+i) < nCrystalsPhi && (coln+j) < nCrystalsZ/2){//Avoid exit the TRU | |
312 | if((*amptru)(rown+i,coln+j) > 0 && (*timeRtru)(rown+i,coln+j)> 0){ | |
313 | if((*timeRtru)(rown+i,coln+j) < (*ampmaxn)(3,mtru) ) | |
314 | (*ampmaxn)(3,mtru) = (*timeRtru)(rown+i,coln+j); | |
315 | } | |
316 | } | |
59264fa6 | 317 | } |
318 | } | |
319 | } | |
0b2ec9f7 | 320 | else { |
321 | (*ampmaxn)(0,mtru) = (*ampmax2)(0,mtru); | |
322 | (*ampmaxn)(1,mtru) = (*ampmax2)(1,mtru); | |
323 | (*ampmaxn)(2,mtru) = (*ampmax2)(2,mtru); | |
324 | (*ampmaxn)(3,mtru) = (*ampmax2)(3,mtru); | |
325 | } | |
25354ff4 | 326 | } |
25354ff4 | 327 | } |
25354ff4 | 328 | //____________________________________________________________________________ |
329 | void AliPHOSTrigger::Print(const Option_t * opt) const | |
330 | { | |
331 | ||
332 | //Prints main parameters | |
333 | ||
334 | if(! opt) | |
335 | return; | |
b165f59d | 336 | AliTriggerInput* in = 0x0 ; |
25354ff4 | 337 | |
59264fa6 | 338 | printf( " Maximum Amplitude after Sliding Crystal, \n") ; |
339 | printf( " -2x2 crystals sum (not overlapped): %10.2f, in Super Module %d\n", | |
340 | f2x2MaxAmp,f2x2SM) ; | |
341 | printf( " -2x2 from row %d to row %d and from column %d to column %d\n", f2x2CrystalPhi, f2x2CrystalPhi+2, f2x2CrystalEta, f2x2CrystalEta+2) ; | |
0b2ec9f7 | 342 | |
343 | if(fPatchSize > 0){ | |
344 | printf( " Patch Size, n x n: %d x %d cells\n",4*fPatchSize, 4*fPatchSize); | |
345 | printf( " -nxn crystals sum (overlapped) : %10.2f, in Super Module %d\n", | |
346 | fnxnMaxAmp,fnxnSM) ; | |
347 | printf( " -nxn from row %d to row %d and from column %d to column %d\n", fnxnCrystalPhi, fnxnCrystalPhi+4, fnxnCrystalEta, fnxnCrystalEta+4) ; | |
348 | } | |
59264fa6 | 349 | printf( " Threshold for LO %10.1f\n", |
350 | fL0Threshold) ; | |
351 | ||
352 | printf( " Threshold for LO %10.2f\n", fL0Threshold) ; | |
353 | in = (AliTriggerInput*)fInputs.FindObject( "PHOS_L0" ); | |
b165f59d | 354 | if(in->GetValue()) |
59264fa6 | 355 | printf( " *** PHOS LO is set ***\n") ; |
356 | ||
357 | printf( " Jet Low Pt Threshold for L1 %10.2f\n", fL1JetLowPtThreshold) ; | |
358 | in = (AliTriggerInput*)fInputs.FindObject( "PHOS_JetLPt_L1" ); | |
66f9b73c | 359 | if(in->GetValue()) |
59264fa6 | 360 | printf( " *** PHOS Jet Low Pt for L1 is set ***\n") ; |
66f9b73c | 361 | |
59264fa6 | 362 | printf( " Jet High Pt Threshold for L1 %10.2f\n", fL1JetHighPtThreshold) ; |
363 | in = (AliTriggerInput*) fInputs.FindObject( "PHOS_JetHPt_L1" ); | |
b165f59d | 364 | if(in->GetValue()) |
59264fa6 | 365 | printf( " *** PHOS Jet High Pt for L1 is set ***\n") ; |
366 | ||
367 | } | |
b165f59d | 368 | |
59264fa6 | 369 | //____________________________________________________________________________ |
0b2ec9f7 | 370 | void AliPHOSTrigger::SetTriggers(const Int_t iMod, const TMatrixD * ampmax2, const TMatrixD * ampmaxn, const AliPHOSGeometry *geom) |
59264fa6 | 371 | { |
0b2ec9f7 | 372 | //Checks the 2x2 and nxn maximum amplitude per each TRU and compares |
59264fa6 | 373 | //with the different L0 and L1 triggers thresholds |
374 | ||
375 | //Initialize variables | |
376 | Float_t max2[] = {-1,-1,-1,-1} ; | |
0b2ec9f7 | 377 | Float_t maxn[] = {-1,-1,-1,-1} ; |
59264fa6 | 378 | Int_t itru2 = -1 ; |
0b2ec9f7 | 379 | Int_t itrun = -1 ; |
59264fa6 | 380 | |
381 | ||
382 | //Find maximum summed amplitude of all the TRU | |
383 | //in a Module | |
384 | for(Int_t i = 0 ; i < fNTRU ; i++){ | |
385 | if(max2[0] < (*ampmax2)(0,i) ){ | |
386 | max2[0] = (*ampmax2)(0,i) ; // 2x2 summed max amplitude | |
387 | max2[1] = (*ampmax2)(1,i) ; // corresponding phi position in TRU | |
388 | max2[2] = (*ampmax2)(2,i) ; // corresponding eta position in TRU | |
389 | max2[3] = (*ampmax2)(3,i) ; // corresponding most recent time | |
390 | itru2 = i ; // TRU number | |
391 | } | |
0b2ec9f7 | 392 | if(maxn[0] < (*ampmaxn)(0,i) ){ |
393 | maxn[0] = (*ampmaxn)(0,i) ; // nxn summed max amplitude | |
394 | maxn[1] = (*ampmaxn)(1,i) ; // corresponding phi position in TRU | |
395 | maxn[2] = (*ampmaxn)(2,i) ; // corresponding eta position in TRU | |
396 | maxn[3] = (*ampmaxn)(3,i) ; // corresponding most recent time | |
397 | itrun = i ; // TRU number | |
59264fa6 | 398 | } |
399 | } | |
400 | ||
401 | //Set max amplitude if larger than in other Modules | |
402 | Float_t maxtimeR2 = -1 ; | |
0b2ec9f7 | 403 | Float_t maxtimeRn = -1 ; |
431a9211 | 404 | // Create a shaper pulse object |
405 | AliPHOSPulseGenerator *pulse = new AliPHOSPulseGenerator(); | |
406 | Int_t nTimeBins = pulse->GetRawFormatTimeBins() ; | |
59264fa6 | 407 | |
408 | //Set max 2x2 amplitude and select L0 trigger | |
409 | if(max2[0] > f2x2MaxAmp ){ | |
410 | f2x2MaxAmp = max2[0] ; | |
411 | f2x2SM = iMod ; | |
412 | maxtimeR2 = max2[3] ; | |
431a9211 | 413 | GetCrystalPhiEtaIndexInModuleFromTRUIndex(itru2, |
414 | static_cast<Int_t>(max2[1]), | |
415 | static_cast<Int_t>(max2[2]), | |
416 | f2x2CrystalPhi,f2x2CrystalEta,geom) ; | |
59264fa6 | 417 | |
418 | //Transform digit amplitude in Raw Samples | |
419 | fADCValuesLow2x2 = new Int_t[nTimeBins]; | |
420 | fADCValuesHigh2x2 = new Int_t[nTimeBins]; | |
421 | ||
431a9211 | 422 | pulse->SetAmplitude(f2x2MaxAmp); |
423 | pulse->SetTZero(maxtimeR2); | |
424 | pulse->MakeSamples(); | |
425 | pulse->GetSamples(fADCValuesHigh2x2, fADCValuesLow2x2) ; | |
59264fa6 | 426 | |
427 | //Set Trigger Inputs, compare ADC time bins until threshold is attained | |
428 | //Set L0 | |
429 | for(Int_t i = 0 ; i < nTimeBins ; i++){ | |
431a9211 | 430 | if(fADCValuesHigh2x2[i] >= fL0Threshold || fADCValuesLow2x2[i] >= fL0Threshold) { |
59264fa6 | 431 | SetInput("PHOS_L0") ; |
432 | break; | |
433 | } | |
434 | } | |
59264fa6 | 435 | } |
436 | ||
0b2ec9f7 | 437 | //Set max nxn amplitude and select L1 triggers |
438 | if(maxn[0] > fnxnMaxAmp ){ | |
439 | fnxnMaxAmp = maxn[0] ; | |
440 | fnxnSM = iMod ; | |
441 | maxtimeRn = maxn[3] ; | |
431a9211 | 442 | GetCrystalPhiEtaIndexInModuleFromTRUIndex(itrun, |
443 | static_cast<Int_t>(maxn[1]), | |
444 | static_cast<Int_t>(maxn[2]), | |
445 | fnxnCrystalPhi,fnxnCrystalEta,geom) ; | |
59264fa6 | 446 | |
447 | //Transform digit amplitude in Raw Samples | |
0b2ec9f7 | 448 | fADCValuesHighnxn = new Int_t[nTimeBins]; |
449 | fADCValuesLownxn = new Int_t[nTimeBins]; | |
431a9211 | 450 | |
451 | pulse->SetAmplitude(maxtimeRn); | |
452 | pulse->SetTZero(fnxnMaxAmp); | |
453 | pulse->MakeSamples(); | |
454 | pulse->GetSamples(fADCValuesHighnxn, fADCValuesLownxn) ; | |
59264fa6 | 455 | |
456 | //Set Trigger Inputs, compare ADC time bins until threshold is attained | |
457 | //SetL1 Low | |
458 | for(Int_t i = 0 ; i < nTimeBins ; i++){ | |
0b2ec9f7 | 459 | if(fADCValuesHighnxn[i] >= fL1JetLowPtThreshold || fADCValuesLownxn[i] >= fL1JetLowPtThreshold){ |
59264fa6 | 460 | SetInput("PHOS_JetLPt_L1") ; |
461 | break; | |
462 | } | |
463 | } | |
464 | //SetL1 High | |
465 | for(Int_t i = 0 ; i < nTimeBins ; i++){ | |
0b2ec9f7 | 466 | if(fADCValuesHighnxn[i] >= fL1JetHighPtThreshold || fADCValuesLownxn[i] >= fL1JetHighPtThreshold){ |
59264fa6 | 467 | SetInput("PHOS_JetHPt_L1") ; |
468 | break; | |
469 | } | |
470 | } | |
59264fa6 | 471 | } |
25354ff4 | 472 | } |
473 | ||
474 | //____________________________________________________________________________ | |
59264fa6 | 475 | void AliPHOSTrigger::Trigger() |
25354ff4 | 476 | { |
477 | ||
59264fa6 | 478 | //Main Method to select triggers. |
479 | AliRunLoader *rl = gAlice->GetRunLoader(); | |
480 | //Getter | |
481 | AliPHOSGetter * gime = AliPHOSGetter::Instance( rl->GetFileName() ) ; | |
482 | //AliPHOSGetter * gime = AliPHOSGetter::Instance() ; | |
25354ff4 | 483 | |
59264fa6 | 484 | //Get Geometry |
485 | const AliPHOSGeometry * geom = AliPHOSGetter::Instance()->PHOSGeometry() ; | |
486 | ||
487 | //Define parameters | |
488 | Int_t nModules = geom->GetNModules(); | |
489 | ||
490 | //Intialize data members each time the trigger is called in event loop | |
491 | f2x2MaxAmp = -1; f2x2CrystalPhi = -1; f2x2CrystalEta = -1; | |
0b2ec9f7 | 492 | fnxnMaxAmp = -1; fnxnCrystalPhi = -1; fnxnCrystalEta = -1; |
59264fa6 | 493 | |
494 | //Take the digits list if simulation | |
495 | if(fSimulation) | |
496 | fDigitsList = gime->Digits() ; | |
497 | ||
498 | if(!fDigitsList) | |
499 | AliFatal("Digits not found !") ; | |
66f9b73c | 500 | |
59264fa6 | 501 | //Fill TRU Matrix |
502 | TClonesArray * amptrus = new TClonesArray("TMatrixD",1000); | |
503 | TClonesArray * timeRtrus = new TClonesArray("TMatrixD",1000); | |
504 | FillTRU(fDigitsList,geom,amptrus, timeRtrus) ; | |
505 | ||
506 | //Do Crystal Sliding and select Trigger | |
507 | //Initialize varible that will contain maximum amplitudes and | |
508 | //its corresponding cell position in eta and phi, and time. | |
509 | TMatrixD * ampmax2 = new TMatrixD(4,fNTRU) ; | |
0b2ec9f7 | 510 | TMatrixD * ampmaxn = new TMatrixD(4,fNTRU) ; |
59264fa6 | 511 | |
512 | for(Int_t imod = 1 ; imod <= nModules ; imod++) { | |
0b2ec9f7 | 513 | //Do 2x2 and nxn sums, select maximums. |
514 | MakeSlidingCell(amptrus, timeRtrus, imod, ampmax2, ampmaxn, geom); | |
59264fa6 | 515 | //Set the trigger |
0b2ec9f7 | 516 | SetTriggers(imod,ampmax2,ampmaxn, geom) ; |
59264fa6 | 517 | } |
25354ff4 | 518 | } |