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 //_________________________________________________________________________
19 // Class for trigger analysis.
20 // Digits are grouped in TRU's (Trigger Units). A TRU consists of 384
21 // cells ordered fNTRUPhi x fNTRUEta. The algorithm searches all possible 2x2
22 // and nxn (n is a multiple of 2) cell combinations per each TRU, adding the
23 // digits amplitude and finding the maximum. If found, look if it is isolated.
24 // Maxima are transformed in ADC time samples. Each time bin is compared to the trigger
25 // threshold until it is larger and then, triggers are set. Thresholds need to be fixed.
26 // Thresholds need to be fixed. Last 2 modules are half size in Phi, I considered
27 // that the number of TRU is maintained for the last modules but decision not taken.
28 // If different, then this must be changed.
31 // //Inside the event loop
32 // AliEMCALTrigger *tr = new AliEMCALTrigger();//Init Trigger
33 // tr->SetL0Threshold(100); //Arbitrary threshold values
34 // tr->SetL1JetLowPtThreshold(1000);
35 // tr->SetL1JetMediumPtThreshold(10000);
36 // tr->SetL1JetHighPtThreshold(20000);
38 // tr->Trigger(); //Execute Trigger
39 // tr->Print(""); //Print results
41 //*-- Author: Gustavo Conesa & Yves Schutz (IFIC, CERN)
42 //////////////////////////////////////////////////////////////////////////////
45 // --- ROOT system ---
47 // --- ALIROOT system ---
49 #include "AliRunLoader.h"
50 #include "AliTriggerInput.h"
52 #include "AliEMCALLoader.h"
53 #include "AliEMCALDigit.h"
54 #include "AliEMCALTrigger.h"
55 #include "AliEMCALGeometry.h"
56 #include "AliEMCALRawUtils.h"
58 ClassImp(AliEMCALTrigger)
60 //______________________________________________________________________
61 AliEMCALTrigger::AliEMCALTrigger()
62 : AliTriggerDetector(), fGeom(0),
63 f2x2MaxAmp(-1), f2x2CellPhi(-1), f2x2CellEta(-1),
65 fnxnMaxAmp(-1), fnxnCellPhi(-1), fnxnCellEta(-1),
67 fADCValuesHighnxn(0),fADCValuesLownxn(0),
68 fADCValuesHigh2x2(0),fADCValuesLow2x2(0),
70 fL0Threshold(100),fL1JetLowPtThreshold(200),
71 fL1JetMediumPtThreshold(500), fL1JetHighPtThreshold(1000),
72 fPatchSize(1), fIsolPatchSize(1),
73 f2x2AmpOutOfPatch(-1), fnxnAmpOutOfPatch(-1),
74 f2x2AmpOutOfPatchThres(100000), fnxnAmpOutOfPatchThres(100000),
75 fIs2x2Isol(kFALSE), fIsnxnIsol(kFALSE),
76 fSimulation(kTRUE), fIsolateInSuperModule(kTRUE)
79 fADCValuesHighnxn = 0x0; //new Int_t[fTimeBins];
80 fADCValuesLownxn = 0x0; //new Int_t[fTimeBins];
81 fADCValuesHigh2x2 = 0x0; //new Int_t[fTimeBins];
82 fADCValuesLow2x2 = 0x0; //new Int_t[fTimeBins];
92 //____________________________________________________________________________
93 AliEMCALTrigger::AliEMCALTrigger(const AliEMCALTrigger & trig)
94 : AliTriggerDetector(trig),
96 f2x2MaxAmp(trig.f2x2MaxAmp),
97 f2x2CellPhi(trig.f2x2CellPhi),
98 f2x2CellEta(trig.f2x2CellEta),
100 fnxnMaxAmp(trig.fnxnMaxAmp),
101 fnxnCellPhi(trig.fnxnCellPhi),
102 fnxnCellEta(trig.fnxnCellEta),
104 fADCValuesHighnxn(trig.fADCValuesHighnxn),
105 fADCValuesLownxn(trig.fADCValuesLownxn),
106 fADCValuesHigh2x2(trig.fADCValuesHigh2x2),
107 fADCValuesLow2x2(trig.fADCValuesLow2x2),
108 fDigitsList(trig.fDigitsList),
109 fL0Threshold(trig.fL0Threshold),
110 fL1JetLowPtThreshold(trig.fL1JetLowPtThreshold),
111 fL1JetMediumPtThreshold(trig.fL1JetMediumPtThreshold),
112 fL1JetHighPtThreshold(trig.fL1JetHighPtThreshold),
113 fPatchSize(trig.fPatchSize),
114 fIsolPatchSize(trig.fIsolPatchSize),
115 f2x2AmpOutOfPatch(trig.f2x2AmpOutOfPatch),
116 fnxnAmpOutOfPatch(trig.fnxnAmpOutOfPatch),
117 f2x2AmpOutOfPatchThres(trig.f2x2AmpOutOfPatchThres),
118 fnxnAmpOutOfPatchThres(trig.fnxnAmpOutOfPatchThres),
119 fIs2x2Isol(trig.fIs2x2Isol),
120 fIsnxnIsol(trig.fIsnxnIsol),
121 fSimulation(trig.fSimulation),
122 fIsolateInSuperModule(trig.fIsolateInSuperModule)
127 AliEMCALTrigger::~AliEMCALTrigger() {
128 delete [] fADCValuesHighnxn;
129 delete [] fADCValuesLownxn;
130 delete [] fADCValuesHigh2x2;
131 delete [] fADCValuesLow2x2;
134 //----------------------------------------------------------------------
135 void AliEMCALTrigger::CreateInputs()
139 // Do not create inputs again!!
140 if( fInputs.GetEntriesFast() > 0 ) return;
142 fInputs.AddLast( new AliTriggerInput( "EMCAL_L0", "EMCAL L0", 0x02 ) );
143 fInputs.AddLast( new AliTriggerInput( "EMCAL_JetHPt_L1","EMCAL Jet High Pt L1", 0x04 ) );
144 fInputs.AddLast( new AliTriggerInput( "EMCAL_JetMPt_L1","EMCAL Jet Medium Pt L1", 0x08 ) );
145 fInputs.AddLast( new AliTriggerInput( "EMCAL_JetLPt_L1","EMCAL Jet Low Pt L1", 0x016 ) );
149 //____________________________________________________________________________
150 Bool_t AliEMCALTrigger::IsPatchIsolated(Int_t iPatchType, const TClonesArray * ampmatrixes, const Int_t iSM, const Int_t mtru, const Float_t maxamp, const Int_t maxphi, const Int_t maxeta) {
152 //Calculate if the maximum patch found is isolated, find amplitude around maximum (2x2 or nxn) patch,
153 //inside isolation patch . iPatchType = 0 means calculation for 2x2 patch,
154 //iPatchType = 1 means calculation for nxn patch.
155 //In the next table there is an example of the different options of patch size and isolation patch size:
156 // Patch Size (fPatchSize)
158 // fIsolPatchSize 2x2 (not overlap) 4x4 (overlapped) 6x6(overlapped) ...
166 //Get matrix of TRU or Module with maximum amplitude patch.
167 Int_t itru = mtru + iSM * fGeom->GetNTRU(); //number of tru, min 0 max 8*5.
168 TMatrixD * ampmatrix = 0x0;
172 if(fIsolateInSuperModule){
173 ampmatrix = dynamic_cast<TMatrixD *>(ampmatrixes->At(iSM)) ;
174 rowborder = fGeom->GetNPhi()*2;
175 colborder = fGeom->GetNZ()*2;
176 AliDebug(2,"Isolate trigger in Module");
179 ampmatrix = dynamic_cast<TMatrixD *>(ampmatrixes->At(itru)) ;
180 rowborder = fGeom->GetNCellsInTRUPhi();
181 colborder = fGeom->GetNCellsInTRUEta();
182 AliDebug(2,"Isolate trigger in TRU");
186 Int_t isolcells = fIsolPatchSize*(1+iPatchType);
187 Int_t ipatchcells = 2*(1+fPatchSize*iPatchType);
188 Int_t minrow = maxphi - isolcells;
189 Int_t mincol = maxeta - isolcells;
190 Int_t maxrow = maxphi + isolcells + ipatchcells;
191 Int_t maxcol = maxeta + isolcells + ipatchcells;
197 if (maxrow > rowborder)
199 if (maxcol > colborder)
202 AliDebug(2,Form("Number of added Isol Cells %d, Patch Size %d",isolcells, ipatchcells));
203 AliDebug(2,Form("Patch: minrow %d, maxrow %d, mincol %d, maxcol %d",minrow,maxrow,mincol,maxcol));
205 //Add amplitudes in all isolation patch
206 for(Int_t irow = minrow ; irow < maxrow; irow ++)
207 for(Int_t icol = mincol ; icol < maxcol ; icol ++)
208 amp += (*ampmatrix)(irow,icol);
210 AliDebug(2,Form("Type %d, Maximum amplitude %f, patch+isol square %f",iPatchType, maxamp, amp));
213 AliError(Form("Bad sum: Type %d, Maximum amplitude %f, patch+isol square %f",iPatchType, maxamp, amp));
217 amp-=maxamp; //Calculate energy in isolation patch that do not comes from maximum patch.
219 AliDebug(2, Form("Maximum amplitude %f, Out of patch %f",maxamp, amp));
221 //Fill isolation amplitude data member and say if patch is isolated.
222 if(iPatchType == 0){ //2x2 case
223 f2x2AmpOutOfPatch = amp;
224 if(amp < f2x2AmpOutOfPatchThres)
227 else if(iPatchType == 1){ //nxn case
228 fnxnAmpOutOfPatch = amp;
229 if(amp < fnxnAmpOutOfPatchThres)
237 //____________________________________________________________________________
238 void AliEMCALTrigger::MakeSlidingCell(const TClonesArray * amptrus, const TClonesArray * timeRtrus, const Int_t isupermod,TMatrixD &max2, TMatrixD &maxn){
240 //Sums energy of all possible 2x2 (L0) and nxn (L1) cells per each TRU.
241 //Fast signal in the experiment is given by 2x2 cells,
242 //for this reason we loop inside the TRU cells by 2.
244 //Declare and initialize variables
245 Int_t nCellsPhi = fGeom->GetNCellsInTRUPhi();
247 nCellsPhi = nCellsPhi / 2 ; //Half size SM. Not Final.
248 // 12(tow)*2(cell)/1 TRU, cells in Phi in one TRU
249 Int_t nCellsEta = fGeom->GetNCellsInTRUEta();
250 Int_t nTRU = fGeom->GetNTRU();
251 // 24(mod)*2(tower)/3 TRU, cells in Eta in one TRU
252 //Int_t nTRU = geom->GeNTRU();//3 TRU per super module
256 for(Int_t i = 0; i < 4; i++){
257 for(Int_t j = 0; j < nTRU; j++){
263 //Create matrix that will contain 2x2 amplitude sums
264 //used to calculate the nxn sums
265 TMatrixD tru2x2(nCellsPhi/2,nCellsEta/2) ;
266 for(Int_t i = 0; i < nCellsPhi/2; i++)
267 for(Int_t j = 0; j < nCellsEta/2; j++)
270 //Loop over all TRUS in a supermodule
271 for(Int_t itru = 0 + isupermod * nTRU ; itru < (isupermod+1)*nTRU ; itru++) {
272 TMatrixD * amptru = dynamic_cast<TMatrixD *>(amptrus->At(itru)) ;
273 TMatrixD * timeRtru = dynamic_cast<TMatrixD *>(timeRtrus->At(itru)) ;
274 Int_t mtru = itru-isupermod*nTRU ; //Number of TRU in Supermodule
276 //Sliding 2x2, add 2x2 amplitudes (NOT OVERLAP)
277 for(Int_t irow = 0 ; irow < nCellsPhi; irow += 2){
278 for(Int_t icol = 0 ; icol < nCellsEta ; icol += 2){
279 amp2 = (*amptru)(irow,icol)+(*amptru)(irow+1,icol)+
280 (*amptru)(irow,icol+1)+(*amptru)(irow+1,icol+1);
282 //Fill matrix with added 2x2 cells for use in nxn sums
283 tru2x2(irow/2,icol/2) = amp2 ;
284 //Select 2x2 maximum sums to select L0
285 if(amp2 > ampmax2(0,mtru)){
286 ampmax2(0,mtru) = amp2 ;
287 ampmax2(1,mtru) = irow;
288 ampmax2(2,mtru) = icol;
293 //Find most recent time in the selected 2x2 cell
294 ampmax2(3,mtru) = 1 ;
295 Int_t row2 = static_cast <Int_t> (ampmax2(1,mtru));
296 Int_t col2 = static_cast <Int_t> (ampmax2(2,mtru));
297 for(Int_t i = 0; i<2; i++){
298 for(Int_t j = 0; j<2; j++){
299 if((*amptru)(row2+i,col2+j) > 0 && (*timeRtru)(row2+i,col2+j)> 0){
300 if((*timeRtru)(row2+i,col2+j) < ampmax2(3,mtru) )
301 ampmax2(3,mtru) = (*timeRtru)(row2+i,col2+j);
306 //Sliding nxn, add nxn amplitudes (OVERLAP)
308 for(Int_t irow = 0 ; irow < nCellsPhi/2; irow++){
309 for(Int_t icol = 0 ; icol < nCellsEta/2 ; icol++){
311 if( (irow+fPatchSize) < nCellsPhi/2 && (icol+fPatchSize) < nCellsEta/2){//Avoid exit the TRU
312 for(Int_t i = 0 ; i <= fPatchSize ; i++)
313 for(Int_t j = 0 ; j <= fPatchSize ; j++)
314 ampn += tru2x2(irow+i,icol+j);
315 //Select nxn maximum sums to select L1
316 if(ampn > ampmaxn(0,mtru)){
317 ampmaxn(0,mtru) = ampn ;
318 ampmaxn(1,mtru) = irow*2;
319 ampmaxn(2,mtru) = icol*2;
325 //Find most recent time in selected nxn cell
326 ampmaxn(3,mtru) = 1 ;
327 Int_t rown = static_cast <Int_t> (ampmaxn(1,mtru));
328 Int_t coln = static_cast <Int_t> (ampmaxn(2,mtru));
329 for(Int_t i = 0; i<4*fPatchSize; i++){
330 for(Int_t j = 0; j<4*fPatchSize; j++){
331 if( (rown+i) < nCellsPhi && (coln+j) < nCellsEta){//Avoid exit the TRU
332 if((*amptru)(rown+i,coln+j) > 0 && (*timeRtru)(rown+i,coln+j)> 0){
333 if((*timeRtru)(rown+i,coln+j) < ampmaxn(3,mtru) )
334 ampmaxn(3,mtru) = (*timeRtru)(rown+i,coln+j);
341 ampmaxn(0,mtru) = ampmax2(0,mtru);
342 ampmaxn(1,mtru) = ampmax2(1,mtru);
343 ampmaxn(2,mtru) = ampmax2(2,mtru);
344 ampmaxn(3,mtru) = ampmax2(3,mtru);
349 //____________________________________________________________________________
350 void AliEMCALTrigger::Print(const Option_t * opt) const
353 //Prints main parameters
357 AliTriggerInput* in = 0x0 ;
359 printf( " Maximum Amplitude after Sliding Cell, \n") ;
360 printf( " -2x2 cells sum (not overlapped): %10.2f, in Super Module %d\n",
362 printf( " -2x2 from row %d to row %d and from column %d to column %d\n", f2x2CellPhi, f2x2CellPhi+2, f2x2CellEta, f2x2CellEta+2) ;
363 printf( " -2x2 Isolation Patch %d x %d, Amplitude out of 2x2 patch is %f, threshold %f, Isolated? %d \n",
364 2*fIsolPatchSize+2, 2*fIsolPatchSize+2, f2x2AmpOutOfPatch, f2x2AmpOutOfPatchThres,static_cast<Int_t> (fIs2x2Isol)) ;
366 printf( " Patch Size, n x n: %d x %d cells\n",2*(fPatchSize+1), 2*(fPatchSize+1));
367 printf( " -nxn cells sum (overlapped) : %10.2f, in Super Module %d\n",
369 printf( " -nxn from row %d to row %d and from column %d to column %d\n", fnxnCellPhi, fnxnCellPhi+4*fPatchSize, fnxnCellEta, fnxnCellEta+4*fPatchSize) ;
370 printf( " -nxn Isolation Patch %d x %d, Amplitude out of nxn patch is %f, threshold %f, Isolated? %d \n",
371 4*fIsolPatchSize+2*(fPatchSize+1),4*fIsolPatchSize+2*(fPatchSize+1) , fnxnAmpOutOfPatch, fnxnAmpOutOfPatchThres,static_cast<Int_t> (fIsnxnIsol) ) ;
374 printf( " Isolate in SuperModule? %d\n",
375 fIsolateInSuperModule) ;
377 printf( " Threshold for LO %10.2f\n",
379 in = (AliTriggerInput*)fInputs.FindObject( "EMCAL_L0" );
381 printf( " *** EMCAL LO is set ***\n") ;
383 printf( " Jet Low Pt Threshold for L1 %10.2f\n",
384 fL1JetLowPtThreshold) ;
385 in = (AliTriggerInput*)fInputs.FindObject( "EMCAL_JetLPt_L1" );
387 printf( " *** EMCAL Jet Low Pt for L1 is set ***\n") ;
389 printf( " Jet Medium Pt Threshold for L1 %10.2f\n",
390 fL1JetMediumPtThreshold) ;
391 in = (AliTriggerInput*) fInputs.FindObject( "EMCAL_JetMPt_L1" );
393 printf( " *** EMCAL Jet Medium Pt for L1 is set ***\n") ;
395 printf( " Jet High Pt Threshold for L1 %10.2f\n",
396 fL1JetHighPtThreshold) ;
397 in = (AliTriggerInput*) fInputs.FindObject( "EMCAL_JetHPt_L1" );
399 printf( " *** EMCAL Jet High Pt for L1 is set ***\n") ;
403 //____________________________________________________________________________
404 void AliEMCALTrigger::SetTriggers(const TClonesArray * ampmatrix,const Int_t iSM,
405 const TMatrixD &max2,
406 const TMatrixD &maxn)
409 //Checks the 2x2 and nxn maximum amplitude per each TRU and
410 //compares with the different L0 and L1 triggers thresholds
411 Float_t max2[] = {-1,-1,-1,-1} ;
412 Float_t maxn[] = {-1,-1,-1,-1} ;
416 Int_t nTRU = fGeom->GetNTRU();
418 //Find maximum summed amplitude of all the TRU
420 for(Int_t i = 0 ; i < nTRU ; i++){
421 if(max2[0] < ampmax2(0,i) ){
422 max2[0] = ampmax2(0,i) ; // 2x2 summed max amplitude
423 max2[1] = ampmax2(1,i) ; // corresponding phi position in TRU
424 max2[2] = ampmax2(2,i) ; // corresponding eta position in TRU
425 max2[3] = ampmax2(3,i) ; // corresponding most recent time
428 if(maxn[0] < ampmaxn(0,i) ){
429 maxn[0] = ampmaxn(0,i) ; // nxn summed max amplitude
430 maxn[1] = ampmaxn(1,i) ; // corresponding phi position in TRU
431 maxn[2] = ampmaxn(2,i) ; // corresponding eta position in TRU
432 maxn[3] = ampmaxn(3,i) ; // corresponding most recent time
437 //--------Set max amplitude if larger than in other Super Modules------------
438 Float_t maxtimeR2 = -1 ;
439 Float_t maxtimeRn = -1 ;
440 static AliEMCALRawUtils rawUtil;
441 Int_t nTimeBins = rawUtil.GetRawFormatTimeBins() ;
443 //Set max of 2x2 amplitudes and select L0 trigger
444 if(max2[0] > f2x2MaxAmp ){
445 f2x2MaxAmp = max2[0] ;
447 maxtimeR2 = max2[3] ;
448 fGeom->GetCellPhiEtaIndexInSModuleFromTRUIndex(mtru2,
449 static_cast<Int_t>(max2[1]),
450 static_cast<Int_t>(max2[2]),
451 f2x2CellPhi,f2x2CellEta) ;
454 if(fIsolateInSuperModule)
455 fIs2x2Isol = IsPatchIsolated(0, ampmatrix, iSM, mtru2, f2x2MaxAmp, f2x2CellPhi,f2x2CellEta) ;
457 fIs2x2Isol = IsPatchIsolated(0, ampmatrix, iSM, mtru2, f2x2MaxAmp, static_cast<Int_t>(max2[1]), static_cast<Int_t>(max2[2])) ;
459 //Transform digit amplitude in Raw Samples
460 if (fADCValuesLow2x2 == 0) {
461 fADCValuesLow2x2 = new Int_t[nTimeBins];
462 fADCValuesHigh2x2 = new Int_t[nTimeBins];
464 rawUtil.RawSampledResponse(maxtimeR2, f2x2MaxAmp, fADCValuesHigh2x2, fADCValuesLow2x2) ;
466 //Set Trigger Inputs, compare ADC time bins until threshold is attained
468 for(Int_t i = 0 ; i < nTimeBins ; i++){
469 if(fADCValuesHigh2x2[i] >= fL0Threshold || fADCValuesLow2x2[i] >= fL0Threshold){
470 SetInput("EMCAL_L0") ;
476 //------------Set max of nxn amplitudes and select L1 trigger---------
477 if(maxn[0] > fnxnMaxAmp ){
478 fnxnMaxAmp = maxn[0] ;
480 maxtimeRn = maxn[3] ;
481 fGeom->GetCellPhiEtaIndexInSModuleFromTRUIndex(mtrun,
482 static_cast<Int_t>(maxn[1]),
483 static_cast<Int_t>(maxn[2]),
484 fnxnCellPhi,fnxnCellEta) ;
487 if(fIsolateInSuperModule)
488 fIsnxnIsol = IsPatchIsolated(1, ampmatrix, iSM, mtrun, fnxnMaxAmp, fnxnCellPhi, fnxnCellEta) ;
490 fIsnxnIsol = IsPatchIsolated(1, ampmatrix, iSM, mtrun, fnxnMaxAmp, static_cast<Int_t>(maxn[1]), static_cast<Int_t>(maxn[2])) ;
492 //Transform digit amplitude in Raw Samples
493 if (fADCValuesLownxn == 0) {
494 fADCValuesHighnxn = new Int_t[nTimeBins];
495 fADCValuesLownxn = new Int_t[nTimeBins];
497 rawUtil.RawSampledResponse(maxtimeRn, fnxnMaxAmp, fADCValuesHighnxn, fADCValuesLownxn) ;
499 //Set Trigger Inputs, compare ADC time bins until threshold is attained
501 for(Int_t i = 0 ; i < nTimeBins ; i++){
502 if(fADCValuesHighnxn[i] >= fL1JetLowPtThreshold || fADCValuesLownxn[i] >= fL1JetLowPtThreshold){
503 SetInput("EMCAL_JetLPt_L1") ;
509 for(Int_t i = 0 ; i < nTimeBins ; i++){
510 if(fADCValuesHighnxn[i] >= fL1JetMediumPtThreshold || fADCValuesLownxn[i] >= fL1JetMediumPtThreshold){
511 SetInput("EMCAL_JetMPt_L1") ;
517 for(Int_t i = 0 ; i < nTimeBins ; i++){
518 if(fADCValuesHighnxn[i] >= fL1JetHighPtThreshold || fADCValuesLownxn[i] >= fL1JetHighPtThreshold){
519 SetInput("EMCAL_JetHPt_L1") ;
526 //____________________________________________________________________________
527 void AliEMCALTrigger::FillTRU(const TClonesArray * digits, TClonesArray * ampmatrix, TClonesArray * ampmatrixsmod, TClonesArray * timeRmatrix) {
529 // Orders digits ampitudes list in fNTRU TRUs (384 cells) per supermodule.
530 // Each TRU is a TMatrixD, and they are kept in TClonesArrays. The number of
531 // TRU in phi is fNTRUPhi, and the number of TRU in eta is fNTRUEta.
532 // Last 2 modules are half size in Phi, I considered that the number of TRU
533 // is maintained for the last modules but decision not taken. If different,
534 // then this must be changed. Also fill a matrix with all amplitudes in supermodule for isolation studies.
536 //Initilize and declare variables
537 //List of TRU matrices initialized to 0.
538 Int_t nPhi = fGeom->GetNPhi();
539 Int_t nZ = fGeom->GetNZ();
540 Int_t nTRU = fGeom->GetNTRU();
541 Int_t nTRUPhi = fGeom->GetNTRUPhi();
542 Int_t nCellsPhi = fGeom->GetNCellsInTRUPhi();
543 Int_t nCellsPhi2 = fGeom->GetNCellsInTRUPhi();
544 Int_t nCellsEta = fGeom->GetNCellsInTRUEta();
556 //List of TRU matrices initialized to 0.
557 Int_t nSup = fGeom->GetNumberOfSuperModules();
558 for(Int_t k = 0; k < nTRU*nSup; k++){
559 TMatrixD amptrus(nCellsPhi,nCellsEta) ;
560 TMatrixD timeRtrus(nCellsPhi,nCellsEta) ;
561 // Do we need to initialise? I think TMatrixD does it by itself...
562 for(Int_t i = 0; i < nCellsPhi; i++){
563 for(Int_t j = 0; j < nCellsEta; j++){
565 timeRtrus(i,j) = 0.0;
568 new((*ampmatrix)[k]) TMatrixD(amptrus) ;
569 new((*timeRmatrix)[k]) TMatrixD(timeRtrus) ;
572 //List of Modules matrices initialized to 0.
573 for(Int_t k = 0; k < nSup ; k++){
574 TMatrixD ampsmods( nPhi*2, nZ*2) ;
575 for(Int_t i = 0; i < nPhi*2; i++){
576 for(Int_t j = 0; j < nZ*2; j++){
580 new((*ampmatrixsmod)[k]) TMatrixD(ampsmods) ;
583 AliEMCALDigit * dig ;
585 //Digits loop to fill TRU matrices with amplitudes.
586 for(Int_t idig = 0 ; idig < digits->GetEntriesFast() ; idig++){
588 dig = dynamic_cast<AliEMCALDigit *>(digits->At(idig)) ;
589 amp = dig->GetAmp() ; // Energy of the digit (arbitrary units)
590 id = dig->GetId() ; // Id label of the cell
591 timeR = dig->GetTimeR() ; // Earliest time of the digit
593 //Get eta and phi cell position in supermodule
594 Bool_t bCell = fGeom->GetCellIndex(id, iSupMod, nModule, nIphi, nIeta) ;
596 Error("FillTRU","Wrong cell id number") ;
598 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
600 //Check to which TRU in the supermodule belongs the cell.
601 //Supermodules are divided in a TRU matrix of dimension
602 //(fNTRUPhi,fNTRUEta).
603 //Each TRU is a cell matrix of dimension (nCellsPhi,nCellsEta)
605 //First calculate the row and column in the supermodule
606 //of the TRU to which the cell belongs.
607 Int_t col = ieta/nCellsEta;
608 Int_t row = iphi/nCellsPhi;
610 row = iphi/nCellsPhi2;
611 //Calculate label number of the TRU
612 Int_t itru = row + col*nTRUPhi + iSupMod*nTRU ;
614 //Fill TRU matrix with cell values
615 TMatrixD * amptrus = dynamic_cast<TMatrixD *>(ampmatrix->At(itru)) ;
616 TMatrixD * timeRtrus = dynamic_cast<TMatrixD *>(timeRmatrix->At(itru)) ;
618 //Calculate row and column of the cell inside the TRU with number itru
619 Int_t irow = iphi - row * nCellsPhi;
621 irow = iphi - row * nCellsPhi2;
622 Int_t icol = ieta - col * nCellsEta;
624 (*amptrus)(irow,icol) = amp ;
625 (*timeRtrus)(irow,icol) = timeR ;
627 //####################SUPERMODULE MATRIX ##################
628 TMatrixD * ampsmods = dynamic_cast<TMatrixD *>(ampmatrixsmod->At(iSupMod)) ;
629 (*ampsmods)(iphi,ieta) = amp ;
633 //____________________________________________________________________________
634 void AliEMCALTrigger::Trigger()
636 //Main Method to select triggers.
637 AliRunLoader *runLoader = AliRunLoader::GetRunLoader();
638 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>
639 (runLoader->GetDetectorLoader("EMCAL"));
641 //Load EMCAL Geometry
642 if (runLoader->GetAliRun() && runLoader->GetAliRun()->GetDetector("EMCAL"))
643 fGeom = dynamic_cast<AliEMCAL*>(runLoader->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
645 fGeom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaulGeometryName());
648 AliFatal("Did not get geometry from EMCALLoader");
651 Int_t nSuperModules = fGeom->GetNumberOfSuperModules() ; //12 SM in EMCAL
652 Int_t nTRU = fGeom->GetNTRU(); //3 TRU per super module
654 //Intialize data members each time the trigger is called in event loop
655 f2x2MaxAmp = -1; f2x2CellPhi = -1; f2x2CellEta = -1;
656 fnxnMaxAmp = -1; fnxnCellPhi = -1; fnxnCellEta = -1;
658 //Take the digits list if simulation
660 runLoader->LoadDigits("EMCAL");
661 fDigitsList = emcalLoader->Digits() ;
664 AliFatal("Digits not found !") ;
666 //Take the digits list
669 TClonesArray * amptrus = new TClonesArray("TMatrixD",1000);
670 TClonesArray * ampsmods = new TClonesArray("TMatrixD",1000);
671 TClonesArray * timeRtrus = new TClonesArray("TMatrixD",1000);
673 FillTRU(fDigitsList, amptrus, ampsmods, timeRtrus) ;
675 //Do Cell Sliding and select Trigger
676 //Initialize varible that will contain maximum amplitudes and
677 //its corresponding cell position in eta and phi, and time.
678 TMatrixD ampmax2(4,nTRU) ;
679 TMatrixD ampmaxn(4,nTRU) ;
681 for(Int_t iSM = 0 ; iSM < nSuperModules ; iSM++) {
682 //Do 2x2 and nxn sums, select maximums.
683 MakeSlidingCell(amptrus, timeRtrus, iSM, ampmax2, ampmaxn);
686 if(fIsolateInSuperModule)
687 SetTriggers(ampsmods,iSM,ampmax2,ampmaxn) ;
688 if(!fIsolateInSuperModule)
689 SetTriggers(amptrus,iSM,ampmax2,ampmaxn) ;
693 delete amptrus; amptrus = 0;
695 delete ampsmods; ampsmods = 0;
697 delete timeRtrus; timeRtrus = 0;