1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 //_________________________________________________________________________
18 // Class for trigger analysis.
19 // Digits are grouped in TRU's (Trigger Units). A TRU consist of 16x28
20 // crystals ordered fNTRUPhi x fNTRUZ. The algorithm searches all possible
21 // 2x2 and nxn (n multiple of 2) crystal combinations per each TRU, adding the
22 // digits amplitude and finding the maximum. If found, look if it is isolated.
23 // Maxima are transformed in ADC time samples. Each time bin is compared to the trigger
24 // threshold until it is larger and then, triggers are set. Thresholds need to be fixed.
27 // //Inside the event loop
28 // AliPHOSTrigger *tr = new AliPHOSTrigger();//Init Trigger
29 // tr->SetL0Threshold(100);
30 // tr->SetL1JetLowPtThreshold(1000);
31 // tr->SetL1JetMediumPtThreshold(10000);
32 // tr->SetL1JetHighPtThreshold(20000);
34 // tr->Trigger(); //Execute Trigger
35 // tr->Print(""); //Print data members after calculation.
38 //*-- Author: Gustavo Conesa & Yves Schutz (IFIC, CERN)
39 //////////////////////////////////////////////////////////////////////////////
42 // --- ROOT system ---
44 // --- ALIROOT system ---
46 #include "AliPHOSTrigger.h"
47 #include "AliPHOSGeometry.h"
48 #include "AliPHOSGetter.h"
49 #include "AliPHOSPulseGenerator.h"
50 #include "AliTriggerInput.h"
53 ClassImp(AliPHOSTrigger)
55 //______________________________________________________________________
56 AliPHOSTrigger::AliPHOSTrigger()
57 : AliTriggerDetector(),
58 f2x2MaxAmp(-1), f2x2CrystalPhi(-1), f2x2CrystalEta(-1), f2x2SM(0),
59 fnxnMaxAmp(-1), fnxnCrystalPhi(-1), fnxnCrystalEta(-1), fnxnSM(0),
60 fADCValuesHighnxn(0), fADCValuesLownxn(0),
61 fADCValuesHigh2x2(0), fADCValuesLow2x2(0), fDigitsList(0),
62 fL0Threshold(50), fL1JetLowPtThreshold(200), fL1JetMediumPtThreshold(500),
63 fL1JetHighPtThreshold(1000),
64 fNTRU(8), fNTRUZ(2), fNTRUPhi(4),
67 fPatchSize(1), fIsolPatchSize(1),
68 f2x2AmpOutOfPatch(-1), fnxnAmpOutOfPatch(-1),
69 f2x2AmpOutOfPatchThres(2), fnxnAmpOutOfPatchThres(2), //2 GeV out of patch
70 fIs2x2Isol(kFALSE), fIsnxnIsol(kFALSE),
71 fSimulation(kTRUE), fIsolateInModule(kTRUE)
74 fADCValuesHighnxn = 0x0; //new Int_t[fTimeBins];
75 fADCValuesLownxn = 0x0; //new Int_t[fTimeBins];
76 fADCValuesHigh2x2 = 0x0; //new Int_t[fTimeBins];
77 fADCValuesLow2x2 = 0x0; //new Int_t[fTimeBins];
85 //____________________________________________________________________________
86 AliPHOSTrigger::AliPHOSTrigger(const AliPHOSTrigger & trig) :
87 AliTriggerDetector(trig),
88 f2x2MaxAmp(trig.f2x2MaxAmp),
89 f2x2CrystalPhi(trig.f2x2CrystalPhi),
90 f2x2CrystalEta(trig.f2x2CrystalEta),
92 fnxnMaxAmp(trig.fnxnMaxAmp),
93 fnxnCrystalPhi(trig.fnxnCrystalPhi),
94 fnxnCrystalEta(trig.fnxnCrystalEta),
96 fADCValuesHighnxn(trig.fADCValuesHighnxn),
97 fADCValuesLownxn(trig.fADCValuesLownxn),
98 fADCValuesHigh2x2(trig.fADCValuesHigh2x2),
99 fADCValuesLow2x2(trig.fADCValuesLow2x2),
100 fDigitsList(trig.fDigitsList),
101 fL0Threshold(trig.fL0Threshold),
102 fL1JetLowPtThreshold(trig.fL1JetLowPtThreshold),
103 fL1JetMediumPtThreshold(trig.fL1JetMediumPtThreshold),
104 fL1JetHighPtThreshold(trig.fL1JetHighPtThreshold),
107 fNTRUPhi(trig.fNTRUPhi),
108 fNCrystalsPhi(trig.fNCrystalsPhi),
109 fNCrystalsZ(trig. fNCrystalsZ),
110 fPatchSize(trig.fPatchSize),
111 fIsolPatchSize(trig.fIsolPatchSize),
112 f2x2AmpOutOfPatch(trig.f2x2AmpOutOfPatch),
113 fnxnAmpOutOfPatch(trig.fnxnAmpOutOfPatch),
114 f2x2AmpOutOfPatchThres(trig.f2x2AmpOutOfPatchThres),
115 fnxnAmpOutOfPatchThres(trig.fnxnAmpOutOfPatchThres),
116 fIs2x2Isol(trig.fIs2x2Isol),
117 fIsnxnIsol(trig.fIsnxnIsol),
118 fSimulation(trig.fSimulation),
119 fIsolateInModule(trig.fIsolateInModule)
124 //_________________________________________________________________________
125 AliPHOSTrigger & AliPHOSTrigger::operator = (const AliPHOSTrigger &)
127 Fatal("operator =", "no implemented");
131 void AliPHOSTrigger::CreateInputs()
135 // Do not create inputs again!!
136 if( fInputs.GetEntriesFast() > 0 ) return;
138 fInputs.AddLast( new AliTriggerInput( "PHOS_L0", "PHOS L0", 0x02 ) );
139 fInputs.AddLast( new AliTriggerInput( "PHOS_JetHPt_L1","PHOS Jet High Pt L1", 0x04 ) );
140 fInputs.AddLast( new AliTriggerInput( "PHOS_JetMPt_L1","PHOS Jet Medium Pt L1", 0x08 ) );
141 fInputs.AddLast( new AliTriggerInput( "PHOS_JetLPt_L1","PHOS Jet Low Pt L1", 0x016 ) );
145 //____________________________________________________________________________
146 void AliPHOSTrigger::FillTRU(const TClonesArray * digits, const AliPHOSGeometry * geom, TClonesArray * ampmatrixtru, TClonesArray * ampmatrixmod, TClonesArray * timeRmatrixtru) const {
148 //Orders digits ampitudes list and times in fNTRU TRUs (28x16 crystals)
149 //per module. Each TRU is a TMatrixD, and they are kept in TClonesArrays.
150 //In a module, the number of TRU in phi is fNTRUPhi, and the number of
151 //TRU in eta is fNTRUZ. Also fill a matrix with all amplitudes in module for isolation studies.
155 if(fNTRUZ*fNTRUPhi != fNTRU)
156 Error("FillTRU"," Wrong number of TRUS per Z or Phi");
158 //Initilize and declare variables
159 Int_t nModules = geom->GetNModules();
165 //List of TRU matrices initialized to 0.
166 for(Int_t k = 0; k < fNTRU*nModules ; k++){
167 TMatrixD amptrus(fNCrystalsPhi,fNCrystalsZ) ;
168 TMatrixD timeRtrus(fNCrystalsPhi,fNCrystalsZ) ;
169 for(Int_t i = 0; i < fNCrystalsPhi; i++){
170 for(Int_t j = 0; j < fNCrystalsZ; j++){
172 timeRtrus(i,j) = 0.0;
175 new((*ampmatrixtru)[k]) TMatrixD(amptrus) ;
176 new((*timeRmatrixtru)[k]) TMatrixD(timeRtrus) ;
179 //List of Modules matrices initialized to 0.
180 Int_t nmodphi = geom->GetNPhi();
181 Int_t nmodz = geom->GetNZ();
183 for(Int_t k = 0; k < nModules ; k++){
184 TMatrixD ampmods(nmodphi,nmodz) ;
185 for(Int_t i = 0; i < nmodphi; i++){
186 for(Int_t j = 0; j < nmodz; j++){
190 new((*ampmatrixmod)[k]) TMatrixD(ampmods) ;
195 //Digits loop to fill TRU matrices with amplitudes.
196 for(Int_t idig = 0 ; idig < digits->GetEntriesFast() ; idig++){
198 dig = static_cast<AliPHOSDigit *>(digits->At(idig)) ;
199 amp = dig->GetEnergy() ; // Energy of the digit
200 id = dig->GetId() ; // Id label of the cell
201 timeR = dig->GetTimeR() ; // Earliest time of the digit
202 geom->AbsToRelNumbering(id, relid) ;
203 //Transform digit number into 4 numbers
205 //relid[1] = EMC (0) or CPV (-1)
206 //relid[2] = row <= 64 (fNPhi)
207 //relid[3] = column <= 56 (fNZ)
209 if(relid[1] == 0){//Not CPV, Only EMC digits
210 //############# TRU ###################
211 //Check to which TRU in the supermodule belongs the crystal.
212 //Supermodules are divided in a TRU matrix of dimension
214 //Each TRU is a crystal matrix of dimension (fNCrystalsPhi,fNCrystalsZ)
216 //First calculate the row and column in the supermodule
217 //of the TRU to which the crystal belongs.
218 Int_t col = (relid[3]-1)/fNCrystalsZ+1;
219 Int_t row = (relid[2]-1)/fNCrystalsPhi+1;
221 //Calculate label number of the TRU
222 Int_t itru = (row-1) + (col-1)*fNTRUPhi + (relid[0]-1)*fNTRU ;
224 //Fill TRU matrix with crystal values
225 TMatrixD * amptrus = dynamic_cast<TMatrixD *>(ampmatrixtru->At(itru)) ;
226 TMatrixD * timeRtrus = dynamic_cast<TMatrixD *>(timeRmatrixtru->At(itru)) ;
228 //Calculate row and column of the crystal inside the TRU with number itru
229 Int_t irow = (relid[2]-1) - (row-1) * fNCrystalsPhi;
230 Int_t icol = (relid[3]-1) - (col-1) * fNCrystalsZ;
232 (*amptrus)(irow,icol) = amp ;
233 (*timeRtrus)(irow,icol) = timeR ;
235 //####################MODULE MATRIX ##################
236 TMatrixD * ampmods = dynamic_cast<TMatrixD *>(ampmatrixmod->At(relid[0]-1)) ;
237 (*ampmods)(relid[2]-1,relid[3]-1) = amp ;
242 //______________________________________________________________________
243 void AliPHOSTrigger::GetCrystalPhiEtaIndexInModuleFromTRUIndex(const Int_t itru,const Int_t iphitru,const Int_t ietatru,Int_t &iphiMod,Int_t &ietaMod) const
245 // This method transforms the (eta,phi) index of a crystals in a
246 // TRU matrix into Super Module (eta,phi) index.
248 // Calculate in which row and column in which the TRU are
250 Int_t col = itru/ fNTRUPhi + 1;
251 Int_t row = itru - (col-1)*fNTRUPhi + 1;
253 //Calculate the (eta,phi) index in SM
255 iphiMod = fNCrystalsPhi*(row-1) + iphitru + 1 ;
256 ietaMod = fNCrystalsZ*(col-1) + ietatru + 1 ;
260 //____________________________________________________________________________
261 Bool_t AliPHOSTrigger::IsPatchIsolated(Int_t iPatchType, const TClonesArray * ampmatrixes, const Int_t imod, const Int_t mtru, const Float_t maxamp, const Int_t maxphi, const Int_t maxeta) {
263 //Calculate if the maximum patch found is isolated, find amplitude around maximum (2x2 or nxn) patch,
264 //inside isolation patch . iPatchType = 0 means calculation for 2x2 patch,
265 //iPatchType = 1 means calculation for nxn patch.
266 //In the next table there is an example of the different options of patch size and isolation patch size:
267 // Patch Size (fPatchSize)
269 // fIsolPatchSize 2x2 (not overlap) 4x4 (overlapped) 6x6(overlapped) ...
277 //Get matrix of TRU or Module with maximum amplitude patch.
278 Int_t itru = mtru+imod*fNTRU ; //number of tru, min 0 max 8*5.
279 TMatrixD * ampmatrix = 0x0;
283 if(fIsolateInModule){
284 ampmatrix = dynamic_cast<TMatrixD *>(ampmatrixes->At(imod)) ;
285 rowborder = fNCrystalsPhi*fNTRUPhi;
286 colborder = fNCrystalsZ*fNTRUZ;
287 AliDebug(2,"Isolate trigger in Module");
290 ampmatrix = dynamic_cast<TMatrixD *>(ampmatrixes->At(itru)) ;
291 rowborder = fNCrystalsPhi;
292 colborder = fNCrystalsZ;
293 AliDebug(2,"Isolate trigger in TRU");
297 Int_t isolcells = fIsolPatchSize*(1+iPatchType);
298 Int_t ipatchcells = 2*(1+fPatchSize*iPatchType);
299 Int_t minrow = maxphi - isolcells;
300 Int_t mincol = maxeta - isolcells;
301 Int_t maxrow = maxphi + isolcells + ipatchcells;
302 Int_t maxcol = maxeta + isolcells + ipatchcells;
304 AliDebug(2,Form("Number of added Isol Cells %d, Patch Size %d",isolcells, ipatchcells));
305 AliDebug(2,Form("Patch: minrow %d, maxrow %d, mincol %d, maxcol %d",minrow,maxrow,mincol,maxcol));
307 if(minrow < 0 || mincol < 0 || maxrow > rowborder || maxcol > colborder){
308 AliDebug(1,Form("Out of Module/TRU range, cannot isolate patch"));
312 //Add amplitudes in all isolation patch
313 for(Int_t irow = minrow ; irow < maxrow; irow ++)
314 for(Int_t icol = mincol ; icol < maxcol ; icol ++)
315 amp += (*ampmatrix)(irow,icol);
317 AliDebug(2,Form("Type %d, Maximum amplitude %f, patch+isol square %f",iPatchType, maxamp, amp));
319 if(TMath::Nint(amp*1E5) < TMath::Nint(maxamp*1E5)){
320 AliError(Form("Bad sum: Type %d, Maximum amplitude %f, patch+isol square %f",iPatchType, maxamp, amp));
324 amp-=maxamp; //Calculate energy in isolation patch that do not comes from maximum patch.
326 AliDebug(2, Form("Maximum amplitude %f, Out of patch %f",maxamp, amp));
328 //Fill isolation amplitude data member and say if patch is isolated.
329 if(iPatchType == 0){ //2x2 case
330 f2x2AmpOutOfPatch = amp;
331 if(amp < f2x2AmpOutOfPatchThres)
334 else if(iPatchType == 1){ //nxn case
335 fnxnAmpOutOfPatch = amp;
336 if(amp < fnxnAmpOutOfPatchThres)
345 //____________________________________________________________________________
346 void AliPHOSTrigger::MakeSlidingCell(const TClonesArray * amptrus, const TClonesArray * timeRtrus, const Int_t imod, TMatrixD &max2, TMatrixD &maxn){
347 //Sums energy of all possible 2x2 (L0) and nxn (L1) crystals per each TRU.
348 //Fast signal in the experiment is given by 2x2 crystals,
349 //for this reason we loop inside the TRU crystals by 2.
351 //Declare and initialize varibles
354 for(Int_t i = 0; i < 4; i++){
355 for(Int_t j = 0; j < fNTRU; j++){
361 //Create matrix that will contain 2x2 amplitude sums
362 //used to calculate the nxn sums
363 TMatrixD tru2x2(fNCrystalsPhi/2,fNCrystalsZ/2) ;
364 for(Int_t i = 0; i < fNCrystalsPhi/2; i++)
365 for(Int_t j = 0; j < fNCrystalsZ/2; j++)
368 //Loop over all TRUS in a module
369 for(Int_t itru = 0 + imod * fNTRU ; itru < (imod+1)*fNTRU ; itru++){
370 TMatrixD * amptru = dynamic_cast<TMatrixD *>(amptrus->At(itru)) ;
371 TMatrixD * timeRtru = dynamic_cast<TMatrixD *>(timeRtrus->At(itru)) ;
372 Int_t mtru = itru-imod*fNTRU ; //Number of TRU in Module
374 //Sliding 2x2, add 2x2 amplitudes (NOT OVERLAP)
375 for(Int_t irow = 0 ; irow < fNCrystalsPhi; irow += 2){
376 for(Int_t icol = 0 ; icol < fNCrystalsZ ; icol += 2){
377 amp2 = (*amptru)(irow,icol)+(*amptru)(irow+1,icol)+
378 (*amptru)(irow,icol+1)+(*amptru)(irow+1,icol+1);
379 //Fill new matrix with added 2x2 crystals for use in nxn sums
380 tru2x2(irow/2,icol/2) = amp2 ;
381 //Select 2x2 maximum sums to select L0
382 if(amp2 > ampmax2(0,mtru)){
383 ampmax2(0,mtru) = amp2 ;
384 ampmax2(1,mtru) = irow;
385 ampmax2(2,mtru) = icol;
390 //Find most recent time in the selected 2x2 cell
391 ampmax2(3,mtru) = 1 ;
392 Int_t row2 = static_cast <Int_t> (ampmax2(1,mtru));
393 Int_t col2 = static_cast <Int_t> (ampmax2(2,mtru));
394 for(Int_t i = 0; i<2; i++){
395 for(Int_t j = 0; j<2; j++){
396 if((*amptru)(row2+i,col2+j) > 0 && (*timeRtru)(row2+i,col2+j)> 0){
397 if((*timeRtru)(row2+i,col2+j) < ampmax2(3,mtru) )
398 ampmax2(3,mtru) = (*timeRtru)(row2+i,col2+j);
403 //Sliding nxn, add nxn amplitudes (OVERLAP)
405 for(Int_t irow = 0 ; irow < fNCrystalsPhi/2; irow++){
406 for(Int_t icol = 0 ; icol < fNCrystalsZ/2 ; icol++){
408 if( (irow+fPatchSize) < fNCrystalsPhi/2 && (icol+fPatchSize) < fNCrystalsZ/2){//Avoid exit the TRU
409 for(Int_t i = 0 ; i <= fPatchSize ; i++)
410 for(Int_t j = 0 ; j <= fPatchSize ; j++)
411 ampn += tru2x2(irow+i,icol+j);
412 //Select nxn maximum sums to select L1
413 if(ampn > ampmaxn(0,mtru)){
414 ampmaxn(0,mtru) = ampn ;
415 ampmaxn(1,mtru) = irow*2;
416 ampmaxn(2,mtru) = icol*2;
422 //Find most recent time in selected nxn cell
423 ampmaxn(3,mtru) = 1 ;
424 Int_t rown = static_cast <Int_t> (ampmaxn(1,mtru));
425 Int_t coln = static_cast <Int_t> (ampmaxn(2,mtru));
426 for(Int_t i = 0; i<4*fPatchSize; i++){
427 for(Int_t j = 0; j<4*fPatchSize; j++){
428 if( (rown+i) < fNCrystalsPhi && (coln+j) < fNCrystalsZ/2){//Avoid exit the TRU
429 if((*amptru)(rown+i,coln+j) > 0 && (*timeRtru)(rown+i,coln+j)> 0){
430 if((*timeRtru)(rown+i,coln+j) < ampmaxn(3,mtru) )
431 ampmaxn(3,mtru) = (*timeRtru)(rown+i,coln+j);
438 ampmaxn(0,mtru) = ampmax2(0,mtru);
439 ampmaxn(1,mtru) = ampmax2(1,mtru);
440 ampmaxn(2,mtru) = ampmax2(2,mtru);
441 ampmaxn(3,mtru) = ampmax2(3,mtru);
447 //____________________________________________________________________________
448 void AliPHOSTrigger::Print(const Option_t * opt) const
451 //Prints main parameters
455 AliTriggerInput* in = 0x0 ;
457 printf( " Maximum Amplitude after Sliding Crystal, \n") ;
458 printf( " -2x2 crystals sum (not overlapped): %10.2f, in Super Module %d\n",
460 printf( " -2x2 from row %d to row %d and from column %d to column %d\n", f2x2CrystalPhi, f2x2CrystalPhi+2, f2x2CrystalEta, f2x2CrystalEta+2) ;
461 printf( " -2x2 Isolation Patch %d x %d, Amplitude out of 2x2 patch is %f, threshold %f, Isolated? %d \n",
462 2*fIsolPatchSize+2, 2*fIsolPatchSize+2, f2x2AmpOutOfPatch, f2x2AmpOutOfPatchThres,static_cast<Int_t> (fIs2x2Isol)) ;
464 printf( " Patch Size, n x n: %d x %d cells\n",2*(fPatchSize+1), 2*(fPatchSize+1));
465 printf( " -nxn crystals sum (overlapped) : %10.2f, in Super Module %d\n",
467 printf( " -nxn from row %d to row %d and from column %d to column %d\n", fnxnCrystalPhi, fnxnCrystalPhi+4*fPatchSize, fnxnCrystalEta, fnxnCrystalEta+4*fPatchSize) ;
468 printf( " -nxn Isolation Patch %d x %d, Amplitude out of nxn patch is %f, threshold %f, Isolated? %d \n",
469 4*fIsolPatchSize+2*(fPatchSize+1),4*fIsolPatchSize+2*(fPatchSize+1) , fnxnAmpOutOfPatch, fnxnAmpOutOfPatchThres,static_cast<Int_t> (fIsnxnIsol) ) ;
472 printf( " Isolate in Module? %d\n",
475 printf( " Threshold for LO %10.1f\n",
478 printf( " Threshold for LO %10.2f\n", fL0Threshold) ;
479 in = (AliTriggerInput*)fInputs.FindObject( "PHOS_L0" );
481 printf( " *** PHOS LO is set ***\n") ;
483 printf( " Jet Low Pt Threshold for L1 %10.2f\n", fL1JetLowPtThreshold) ;
484 in = (AliTriggerInput*)fInputs.FindObject( "PHOS_JetLPt_L1" );
486 printf( " *** PHOS Jet Low Pt for L1 is set ***\n") ;
488 printf( " Jet Medium Pt Threshold for L1 %10.2f\n", fL1JetMediumPtThreshold) ;
489 in = (AliTriggerInput*)fInputs.FindObject( "PHOS_JetMPt_L1" );
491 printf( " *** PHOS Jet Medium Pt for L1 is set ***\n") ;
493 printf( " Jet High Pt Threshold for L1 %10.2f\n", fL1JetHighPtThreshold) ;
494 in = (AliTriggerInput*) fInputs.FindObject( "PHOS_JetHPt_L1" );
496 printf( " *** PHOS Jet High Pt for L1 is set ***\n") ;
500 //____________________________________________________________________________
501 void AliPHOSTrigger::SetTriggers(const TClonesArray * ampmatrix, const Int_t iMod, const TMatrixD & ampmax2, const TMatrixD & ampmaxn)
503 //Checks the 2x2 and nxn maximum amplitude per each TRU and compares
504 //with the different L0 and L1 triggers thresholds. It finds if maximum amplitudes are isolated.
506 //Initialize variables
507 Float_t max2[] = {-1,-1,-1,-1} ;
508 Float_t maxn[] = {-1,-1,-1,-1} ;
513 //Find maximum summed amplitude of all the TRU
515 for(Int_t i = 0 ; i < fNTRU ; i++){
516 if(max2[0] < ampmax2(0,i) ){
517 max2[0] = ampmax2(0,i) ; // 2x2 summed max amplitude
518 max2[1] = ampmax2(1,i) ; // corresponding phi position in TRU
519 max2[2] = ampmax2(2,i) ; // corresponding eta position in TRU
520 max2[3] = ampmax2(3,i) ; // corresponding most recent time
521 mtru2 = i ; // TRU number in module
523 if(maxn[0] < ampmaxn(0,i) ){
524 maxn[0] = ampmaxn(0,i) ; // nxn summed max amplitude
525 maxn[1] = ampmaxn(1,i) ; // corresponding phi position in TRU
526 maxn[2] = ampmaxn(2,i) ; // corresponding eta position in TRU
527 maxn[3] = ampmaxn(3,i) ; // corresponding most recent time
528 mtrun = i ; // TRU number in module
532 //Set max amplitude if larger than in other Modules
533 Float_t maxtimeR2 = -1 ;
534 Float_t maxtimeRn = -1 ;
535 // Create a shaper pulse object
536 AliPHOSPulseGenerator pulse ;
537 Int_t nTimeBins = pulse.GetRawFormatTimeBins() ;
539 //Set max 2x2 amplitude and select L0 trigger
540 if(max2[0] > f2x2MaxAmp ){
541 f2x2MaxAmp = max2[0] ;
543 maxtimeR2 = max2[3] ;
544 GetCrystalPhiEtaIndexInModuleFromTRUIndex(mtru2,
545 static_cast<Int_t>(max2[1]),
546 static_cast<Int_t>(max2[2]),
547 f2x2CrystalPhi,f2x2CrystalEta) ;
551 fIs2x2Isol = IsPatchIsolated(0, ampmatrix, iMod, mtru2, f2x2MaxAmp, f2x2CrystalPhi,f2x2CrystalEta) ;
553 fIs2x2Isol = IsPatchIsolated(0, ampmatrix, iMod, mtru2, f2x2MaxAmp, static_cast<Int_t>(max2[1]), static_cast<Int_t>(max2[2])) ;
555 //Transform digit amplitude in Raw Samples
556 if (fADCValuesLow2x2 == 0) {
557 fADCValuesLow2x2 = new Int_t[nTimeBins];
558 fADCValuesHigh2x2 = new Int_t[nTimeBins];
561 pulse.SetAmplitude(f2x2MaxAmp);
562 pulse.SetTZero(maxtimeR2);
564 pulse.GetSamples(fADCValuesHigh2x2, fADCValuesLow2x2) ;
566 //Set Trigger Inputs, compare ADC time bins until threshold is attained
568 for(Int_t i = 0 ; i < nTimeBins ; i++){
569 if(fADCValuesHigh2x2[i] >= fL0Threshold || fADCValuesLow2x2[i] >= fL0Threshold) {
570 SetInput("PHOS_L0") ;
576 //Set max nxn amplitude and select L1 triggers
577 if(maxn[0] > fnxnMaxAmp && fPatchSize > 0){
578 fnxnMaxAmp = maxn[0] ;
580 maxtimeRn = maxn[3] ;
581 GetCrystalPhiEtaIndexInModuleFromTRUIndex(mtrun,
582 static_cast<Int_t>(maxn[1]),
583 static_cast<Int_t>(maxn[2]),
584 fnxnCrystalPhi,fnxnCrystalEta) ;
588 fIsnxnIsol = IsPatchIsolated(1, ampmatrix, iMod, mtrun, fnxnMaxAmp, fnxnCrystalPhi, fnxnCrystalEta) ;
590 fIsnxnIsol = IsPatchIsolated(1, ampmatrix, iMod, mtrun, fnxnMaxAmp, static_cast<Int_t>(maxn[1]), static_cast<Int_t>(maxn[2])) ;
592 //Transform digit amplitude in Raw Samples
593 if (fADCValuesHighnxn == 0) {
594 fADCValuesHighnxn = new Int_t[nTimeBins];
595 fADCValuesLownxn = new Int_t[nTimeBins];
598 pulse.SetAmplitude(maxtimeRn);
599 pulse.SetTZero(fnxnMaxAmp);
601 pulse.GetSamples(fADCValuesHighnxn, fADCValuesLownxn) ;
603 //Set Trigger Inputs, compare ADC time bins until threshold is attained
605 for(Int_t i = 0 ; i < nTimeBins ; i++){
606 if(fADCValuesHighnxn[i] >= fL1JetLowPtThreshold || fADCValuesLownxn[i] >= fL1JetLowPtThreshold){
607 SetInput("PHOS_JetLPt_L1") ;
612 for(Int_t i = 0 ; i < nTimeBins ; i++){
613 if(fADCValuesHighnxn[i] >= fL1JetMediumPtThreshold || fADCValuesLownxn[i] >= fL1JetMediumPtThreshold){
614 SetInput("PHOS_JetMPt_L1") ;
619 for(Int_t i = 0 ; i < nTimeBins ; i++){
620 if(fADCValuesHighnxn[i] >= fL1JetHighPtThreshold || fADCValuesLownxn[i] >= fL1JetHighPtThreshold){
621 SetInput("PHOS_JetHPt_L1") ;
628 //____________________________________________________________________________
629 void AliPHOSTrigger::Trigger()
632 //Main Method to select triggers.
634 AliRunLoader * rl = AliRunLoader::GetRunLoader();
635 TString fileName = rl->GetFileName() ;
636 DoIt(fileName.Data()) ;
639 //____________________________________________________________________________
640 void AliPHOSTrigger::Trigger(const char * fileName)
643 //Main Method to select triggers.
649 //____________________________________________________________________________
650 void AliPHOSTrigger::DoIt(const char * fileName)
652 // does the trigger job
654 AliPHOSGetter * gime = AliPHOSGetter::Instance( fileName ) ;
657 const AliPHOSGeometry * geom = AliPHOSGetter::Instance()->PHOSGeometry() ;
660 Int_t nModules = geom->GetNModules();
661 fNCrystalsPhi = geom->GetNPhi()/fNTRUPhi ;// 64/4=16
662 fNCrystalsZ = geom->GetNZ()/fNTRUZ ;// 56/2=28
664 //Intialize data members each time the trigger is called in event loop
665 f2x2MaxAmp = -1; f2x2CrystalPhi = -1; f2x2CrystalEta = -1;
666 fnxnMaxAmp = -1; fnxnCrystalPhi = -1; fnxnCrystalEta = -1;
668 //Take the digits list if simulation
670 fDigitsList = gime->Digits() ;
673 AliFatal("Digits not found !") ;
676 TClonesArray * amptrus = new TClonesArray("TMatrixD",1000);
677 TClonesArray * ampmods = new TClonesArray("TMatrixD",1000);
678 TClonesArray * timeRtrus = new TClonesArray("TMatrixD",1000);
679 FillTRU(fDigitsList,geom,amptrus, ampmods,timeRtrus) ;
681 //Do Crystal Sliding and select Trigger
682 //Initialize varible that will contain maximum amplitudes and
683 //its corresponding cell position in eta and phi, and time.
684 TMatrixD ampmax2(4,fNTRU) ;
685 TMatrixD ampmaxn(4,fNTRU) ;
687 for(Int_t imod = 0 ; imod < nModules ; imod++) {
689 //Do 2x2 and nxn sums, select maximums.
690 MakeSlidingCell(amptrus, timeRtrus, imod, ampmax2, ampmaxn);
693 SetTriggers(ampmods,imod,ampmax2,ampmaxn) ;
694 if(!fIsolateInModule)
695 SetTriggers(amptrus,imod,ampmax2,ampmaxn) ;
699 delete amptrus; amptrus=0;
701 delete ampmods; ampmods=0;
703 delete timeRtrus; timeRtrus=0;