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