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(),
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 fNTRU(3), fNTRUEta(3), fNTRUPhi(1),
73 fNCellsPhi(24), fNCellsEta(16),
74 fPatchSize(1), fIsolPatchSize(1),
75 f2x2AmpOutOfPatch(-1), fnxnAmpOutOfPatch(-1),
76 f2x2AmpOutOfPatchThres(100000), fnxnAmpOutOfPatchThres(100000),
77 fIs2x2Isol(kFALSE), fIsnxnIsol(kFALSE),
78 fSimulation(kTRUE), fIsolateInSuperModule(kTRUE)
81 fADCValuesHighnxn = 0x0; //new Int_t[fTimeBins];
82 fADCValuesLownxn = 0x0; //new Int_t[fTimeBins];
83 fADCValuesHigh2x2 = 0x0; //new Int_t[fTimeBins];
84 fADCValuesLow2x2 = 0x0; //new Int_t[fTimeBins];
94 //____________________________________________________________________________
95 AliEMCALTrigger::AliEMCALTrigger(const AliEMCALTrigger & trig)
96 : AliTriggerDetector(trig),
97 f2x2MaxAmp(trig.f2x2MaxAmp),
98 f2x2CellPhi(trig.f2x2CellPhi),
99 f2x2CellEta(trig.f2x2CellEta),
101 fnxnMaxAmp(trig.fnxnMaxAmp),
102 fnxnCellPhi(trig.fnxnCellPhi),
103 fnxnCellEta(trig.fnxnCellEta),
105 fADCValuesHighnxn(trig.fADCValuesHighnxn),
106 fADCValuesLownxn(trig.fADCValuesLownxn),
107 fADCValuesHigh2x2(trig.fADCValuesHigh2x2),
108 fADCValuesLow2x2(trig.fADCValuesLow2x2),
109 fDigitsList(trig.fDigitsList),
110 fL0Threshold(trig.fL0Threshold),
111 fL1JetLowPtThreshold(trig.fL1JetLowPtThreshold),
112 fL1JetMediumPtThreshold(trig.fL1JetMediumPtThreshold),
113 fL1JetHighPtThreshold(trig.fL1JetHighPtThreshold),
114 fNTRU(trig.fNTRU), fNTRUEta(trig.fNTRUEta), fNTRUPhi(trig.fNTRUPhi),
115 fNCellsPhi(trig.fNCellsPhi), fNCellsEta(trig.fNCellsEta),
116 fPatchSize(trig.fPatchSize),
117 fIsolPatchSize(trig.fIsolPatchSize),
118 f2x2AmpOutOfPatch(trig.f2x2AmpOutOfPatch),
119 fnxnAmpOutOfPatch(trig.fnxnAmpOutOfPatch),
120 f2x2AmpOutOfPatchThres(trig.f2x2AmpOutOfPatchThres),
121 fnxnAmpOutOfPatchThres(trig.fnxnAmpOutOfPatchThres),
122 fIs2x2Isol(trig.fIs2x2Isol),
123 fIsnxnIsol(trig.fIsnxnIsol),
124 fSimulation(trig.fSimulation),
125 fIsolateInSuperModule(trig.fIsolateInSuperModule)
130 AliEMCALTrigger::~AliEMCALTrigger() {
131 delete [] fADCValuesHighnxn;
132 delete [] fADCValuesLownxn;
133 delete [] fADCValuesHigh2x2;
134 delete [] fADCValuesLow2x2;
137 //----------------------------------------------------------------------
138 void AliEMCALTrigger::CreateInputs()
142 // Do not create inputs again!!
143 if( fInputs.GetEntriesFast() > 0 ) return;
145 fInputs.AddLast( new AliTriggerInput( "EMCAL_L0", "EMCAL L0", 0x02 ) );
146 fInputs.AddLast( new AliTriggerInput( "EMCAL_JetHPt_L1","EMCAL Jet High Pt L1", 0x04 ) );
147 fInputs.AddLast( new AliTriggerInput( "EMCAL_JetMPt_L1","EMCAL Jet Medium Pt L1", 0x08 ) );
148 fInputs.AddLast( new AliTriggerInput( "EMCAL_JetLPt_L1","EMCAL Jet Low Pt L1", 0x016 ) );
152 //____________________________________________________________________________
153 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) {
155 //Calculate if the maximum patch found is isolated, find amplitude around maximum (2x2 or nxn) patch,
156 //inside isolation patch . iPatchType = 0 means calculation for 2x2 patch,
157 //iPatchType = 1 means calculation for nxn patch.
158 //In the next table there is an example of the different options of patch size and isolation patch size:
159 // Patch Size (fPatchSize)
161 // fIsolPatchSize 2x2 (not overlap) 4x4 (overlapped) 6x6(overlapped) ...
169 //Get matrix of TRU or Module with maximum amplitude patch.
170 Int_t itru = mtru+iSM*fNTRU ; //number of tru, min 0 max 8*5.
171 TMatrixD * ampmatrix = 0x0;
175 if(fIsolateInSuperModule){
176 ampmatrix = dynamic_cast<TMatrixD *>(ampmatrixes->At(iSM)) ;
177 rowborder = fNCellsPhi*fNTRUPhi;
178 colborder = fNCellsEta*fNTRUEta;
179 AliDebug(2,"Isolate trigger in Module");
182 ampmatrix = dynamic_cast<TMatrixD *>(ampmatrixes->At(itru)) ;
183 rowborder = fNCellsPhi;
184 colborder = fNCellsEta;
185 AliDebug(2,"Isolate trigger in TRU");
189 Int_t isolcells = fIsolPatchSize*(1+iPatchType);
190 Int_t ipatchcells = 2*(1+fPatchSize*iPatchType);
191 Int_t minrow = maxphi - isolcells;
192 Int_t mincol = maxeta - isolcells;
193 Int_t maxrow = maxphi + isolcells + ipatchcells;
194 Int_t maxcol = maxeta + isolcells + ipatchcells;
196 AliDebug(2,Form("Number of added Isol Cells %d, Patch Size %d",isolcells, ipatchcells));
197 AliDebug(2,Form("Patch: minrow %d, maxrow %d, mincol %d, maxcol %d",minrow,maxrow,mincol,maxcol));
199 if(minrow < 0 || mincol < 0 || maxrow > rowborder || maxcol > colborder){
200 AliDebug(1,Form("Out of Module/TRU range, cannot isolate patch"));
204 //Add amplitudes in all isolation patch
205 for(Int_t irow = minrow ; irow < maxrow; irow ++)
206 for(Int_t icol = mincol ; icol < maxcol ; icol ++)
207 amp += (*ampmatrix)(irow,icol);
209 AliDebug(2,Form("Type %d, Maximum amplitude %f, patch+isol square %f",iPatchType, maxamp, amp));
212 AliError(Form("Bad sum: Type %d, Maximum amplitude %f, patch+isol square %f",iPatchType, maxamp, amp));
216 amp-=maxamp; //Calculate energy in isolation patch that do not comes from maximum patch.
218 AliDebug(2, Form("Maximum amplitude %f, Out of patch %f",maxamp, amp));
220 //Fill isolation amplitude data member and say if patch is isolated.
221 if(iPatchType == 0){ //2x2 case
222 f2x2AmpOutOfPatch = amp;
223 if(amp < f2x2AmpOutOfPatchThres)
226 else if(iPatchType == 1){ //nxn case
227 fnxnAmpOutOfPatch = amp;
228 if(amp < fnxnAmpOutOfPatchThres)
236 //____________________________________________________________________________
237 void AliEMCALTrigger::MakeSlidingCell(const TClonesArray * amptrus, const TClonesArray * timeRtrus, const Int_t isupermod,TMatrixD &max2, TMatrixD &maxn){
239 //Sums energy of all possible 2x2 (L0) and nxn (L1) cells per each TRU.
240 //Fast signal in the experiment is given by 2x2 cells,
241 //for this reason we loop inside the TRU cells by 2.
243 //Declare and initialize variables
244 Int_t nCellsPhi = fNCellsPhi;//geom->GetNPhi()*2/geom->GetNTRUPhi() ;
246 nCellsPhi = nCellsPhi / 2 ; //Half size SM. Not Final.
247 // 12(tow)*2(cell)/1 TRU, cells in Phi in one TRU
248 Int_t nCellsEta = fNCellsEta ;//geom->GetNEta()*2/geom->GetNTRUEta() ;
249 // 24(mod)*2(tower)/3 TRU, cells in Eta in one TRU
250 //Int_t nTRU = geom->GeNTRU();//3 TRU per super module
254 for(Int_t i = 0; i < 4; i++){
255 for(Int_t j = 0; j < fNTRU; j++){
261 //Create matrix that will contain 2x2 amplitude sums
262 //used to calculate the nxn sums
263 TMatrixD tru2x2(nCellsPhi/2,nCellsEta/2) ;
264 for(Int_t i = 0; i < nCellsPhi/2; i++)
265 for(Int_t j = 0; j < nCellsEta/2; j++)
268 //Loop over all TRUS in a supermodule
269 for(Int_t itru = 0 + isupermod * fNTRU ; itru < (isupermod+1)*fNTRU ; itru++) {
270 TMatrixD * amptru = dynamic_cast<TMatrixD *>(amptrus->At(itru)) ;
271 TMatrixD * timeRtru = dynamic_cast<TMatrixD *>(timeRtrus->At(itru)) ;
272 Int_t mtru = itru-isupermod*fNTRU ; //Number of TRU in Supermodule
274 //Sliding 2x2, add 2x2 amplitudes (NOT OVERLAP)
275 for(Int_t irow = 0 ; irow < nCellsPhi; irow += 2){
276 for(Int_t icol = 0 ; icol < nCellsEta ; icol += 2){
277 amp2 = (*amptru)(irow,icol)+(*amptru)(irow+1,icol)+
278 (*amptru)(irow,icol+1)+(*amptru)(irow+1,icol+1);
280 //Fill matrix with added 2x2 cells for use in nxn sums
281 tru2x2(irow/2,icol/2) = amp2 ;
282 //Select 2x2 maximum sums to select L0
283 if(amp2 > ampmax2(0,mtru)){
284 ampmax2(0,mtru) = amp2 ;
285 ampmax2(1,mtru) = irow;
286 ampmax2(2,mtru) = icol;
291 //Find most recent time in the selected 2x2 cell
292 ampmax2(3,mtru) = 1 ;
293 Int_t row2 = static_cast <Int_t> (ampmax2(1,mtru));
294 Int_t col2 = static_cast <Int_t> (ampmax2(2,mtru));
295 for(Int_t i = 0; i<2; i++){
296 for(Int_t j = 0; j<2; j++){
297 if((*amptru)(row2+i,col2+j) > 0 && (*timeRtru)(row2+i,col2+j)> 0){
298 if((*timeRtru)(row2+i,col2+j) < ampmax2(3,mtru) )
299 ampmax2(3,mtru) = (*timeRtru)(row2+i,col2+j);
304 //Sliding nxn, add nxn amplitudes (OVERLAP)
306 for(Int_t irow = 0 ; irow < nCellsPhi/2; irow++){
307 for(Int_t icol = 0 ; icol < nCellsEta/2 ; icol++){
309 if( (irow+fPatchSize) < nCellsPhi/2 && (icol+fPatchSize) < nCellsEta/2){//Avoid exit the TRU
310 for(Int_t i = 0 ; i <= fPatchSize ; i++)
311 for(Int_t j = 0 ; j <= fPatchSize ; j++)
312 ampn += tru2x2(irow+i,icol+j);
313 //Select nxn maximum sums to select L1
314 if(ampn > ampmaxn(0,mtru)){
315 ampmaxn(0,mtru) = ampn ;
316 ampmaxn(1,mtru) = irow*2;
317 ampmaxn(2,mtru) = icol*2;
323 //Find most recent time in selected nxn cell
324 ampmaxn(3,mtru) = 1 ;
325 Int_t rown = static_cast <Int_t> (ampmaxn(1,mtru));
326 Int_t coln = static_cast <Int_t> (ampmaxn(2,mtru));
327 for(Int_t i = 0; i<4*fPatchSize; i++){
328 for(Int_t j = 0; j<4*fPatchSize; j++){
329 if( (rown+i) < nCellsPhi && (coln+j) < nCellsEta/2){//Avoid exit the TRU
330 if((*amptru)(rown+i,coln+j) > 0 && (*timeRtru)(rown+i,coln+j)> 0){
331 if((*timeRtru)(rown+i,coln+j) < ampmaxn(3,mtru) )
332 ampmaxn(3,mtru) = (*timeRtru)(rown+i,coln+j);
339 ampmaxn(0,mtru) = ampmax2(0,mtru);
340 ampmaxn(1,mtru) = ampmax2(1,mtru);
341 ampmaxn(2,mtru) = ampmax2(2,mtru);
342 ampmaxn(3,mtru) = ampmax2(3,mtru);
347 //____________________________________________________________________________
348 void AliEMCALTrigger::Print(const Option_t * opt) const
351 //Prints main parameters
355 AliTriggerInput* in = 0x0 ;
357 printf( " Maximum Amplitude after Sliding Cell, \n") ;
358 printf( " -2x2 cells sum (not overlapped): %10.2f, in Super Module %d\n",
360 printf( " -2x2 from row %d to row %d and from column %d to column %d\n", f2x2CellPhi, f2x2CellPhi+2, f2x2CellEta, f2x2CellEta+2) ;
361 printf( " -2x2 Isolation Patch %d x %d, Amplitude out of 2x2 patch is %f, threshold %f, Isolated? %d \n",
362 2*fIsolPatchSize+2, 2*fIsolPatchSize+2, f2x2AmpOutOfPatch, f2x2AmpOutOfPatchThres,static_cast<Int_t> (fIs2x2Isol)) ;
364 printf( " Patch Size, n x n: %d x %d cells\n",2*(fPatchSize+1), 2*(fPatchSize+1));
365 printf( " -nxn cells sum (overlapped) : %10.2f, in Super Module %d\n",
367 printf( " -nxn from row %d to row %d and from column %d to column %d\n", fnxnCellPhi, fnxnCellPhi+4*fPatchSize, fnxnCellEta, fnxnCellEta+4*fPatchSize) ;
368 printf( " -nxn Isolation Patch %d x %d, Amplitude out of nxn patch is %f, threshold %f, Isolated? %d \n",
369 4*fIsolPatchSize+2*(fPatchSize+1),4*fIsolPatchSize+2*(fPatchSize+1) , fnxnAmpOutOfPatch, fnxnAmpOutOfPatchThres,static_cast<Int_t> (fIsnxnIsol) ) ;
372 printf( " Isolate in SuperModule? %d\n",
373 fIsolateInSuperModule) ;
375 printf( " Threshold for LO %10.2f\n",
377 in = (AliTriggerInput*)fInputs.FindObject( "EMCAL_L0" );
379 printf( " *** EMCAL LO is set ***\n") ;
381 printf( " Jet Low Pt Threshold for L1 %10.2f\n",
382 fL1JetLowPtThreshold) ;
383 in = (AliTriggerInput*)fInputs.FindObject( "EMCAL_JetLPt_L1" );
385 printf( " *** EMCAL Jet Low Pt for L1 is set ***\n") ;
387 printf( " Jet Medium Pt Threshold for L1 %10.2f\n",
388 fL1JetMediumPtThreshold) ;
389 in = (AliTriggerInput*) fInputs.FindObject( "EMCAL_JetMPt_L1" );
391 printf( " *** EMCAL Jet Medium Pt for L1 is set ***\n") ;
393 printf( " Jet High Pt Threshold for L1 %10.2f\n",
394 fL1JetHighPtThreshold) ;
395 in = (AliTriggerInput*) fInputs.FindObject( "EMCAL_JetHPt_L1" );
397 printf( " *** EMCAL Jet High Pt for L1 is set ***\n") ;
401 //____________________________________________________________________________
402 void AliEMCALTrigger::SetTriggers(const TClonesArray * ampmatrix,const Int_t iSM,
403 const TMatrixD &max2,
404 const TMatrixD &maxn, const AliEMCALGeometry *geom)
407 //Checks the 2x2 and nxn maximum amplitude per each TRU and
408 //compares with the different L0 and L1 triggers thresholds
409 Float_t max2[] = {-1,-1,-1,-1} ;
410 Float_t maxn[] = {-1,-1,-1,-1} ;
414 //Find maximum summed amplitude of all the TRU
416 for(Int_t i = 0 ; i < fNTRU ; i++){
417 if(max2[0] < ampmax2(0,i) ){
418 max2[0] = ampmax2(0,i) ; // 2x2 summed max amplitude
419 max2[1] = ampmax2(1,i) ; // corresponding phi position in TRU
420 max2[2] = ampmax2(2,i) ; // corresponding eta position in TRU
421 max2[3] = ampmax2(3,i) ; // corresponding most recent time
424 if(maxn[0] < ampmaxn(0,i) ){
425 maxn[0] = ampmaxn(0,i) ; // nxn summed max amplitude
426 maxn[1] = ampmaxn(1,i) ; // corresponding phi position in TRU
427 maxn[2] = ampmaxn(2,i) ; // corresponding eta position in TRU
428 maxn[3] = ampmaxn(3,i) ; // corresponding most recent time
433 //--------Set max amplitude if larger than in other Super Modules------------
434 Float_t maxtimeR2 = -1 ;
435 Float_t maxtimeRn = -1 ;
436 static AliEMCALRawUtils rawUtil;
437 Int_t nTimeBins = rawUtil.GetRawFormatTimeBins() ;
439 //Set max of 2x2 amplitudes and select L0 trigger
440 if(max2[0] > f2x2MaxAmp ){
441 f2x2MaxAmp = max2[0] ;
443 maxtimeR2 = max2[3] ;
444 geom->GetCellPhiEtaIndexInSModuleFromTRUIndex(mtru2,
445 static_cast<Int_t>(max2[1]),
446 static_cast<Int_t>(max2[2]),
447 f2x2CellPhi,f2x2CellEta) ;
450 if(fIsolateInSuperModule)
451 fIs2x2Isol = IsPatchIsolated(0, ampmatrix, iSM, mtru2, f2x2MaxAmp, f2x2CellPhi,f2x2CellEta) ;
453 fIs2x2Isol = IsPatchIsolated(0, ampmatrix, iSM, mtru2, f2x2MaxAmp, static_cast<Int_t>(max2[1]), static_cast<Int_t>(max2[2])) ;
455 //Transform digit amplitude in Raw Samples
456 if (fADCValuesLow2x2 == 0) {
457 fADCValuesLow2x2 = new Int_t[nTimeBins];
458 fADCValuesHigh2x2 = new Int_t[nTimeBins];
460 rawUtil.RawSampledResponse(maxtimeR2, f2x2MaxAmp, fADCValuesHigh2x2, fADCValuesLow2x2) ;
462 //Set Trigger Inputs, compare ADC time bins until threshold is attained
464 for(Int_t i = 0 ; i < nTimeBins ; i++){
465 if(fADCValuesHigh2x2[i] >= fL0Threshold || fADCValuesLow2x2[i] >= fL0Threshold){
466 SetInput("EMCAL_L0") ;
472 //------------Set max of nxn amplitudes and select L1 trigger---------
473 if(maxn[0] > fnxnMaxAmp ){
474 fnxnMaxAmp = maxn[0] ;
476 maxtimeRn = maxn[3] ;
477 geom->GetCellPhiEtaIndexInSModuleFromTRUIndex(mtrun,
478 static_cast<Int_t>(maxn[1]),
479 static_cast<Int_t>(maxn[2]),
480 fnxnCellPhi,fnxnCellEta) ;
483 if(fIsolateInSuperModule)
484 fIsnxnIsol = IsPatchIsolated(1, ampmatrix, iSM, mtrun, fnxnMaxAmp, fnxnCellPhi, fnxnCellEta) ;
486 fIsnxnIsol = IsPatchIsolated(1, ampmatrix, iSM, mtrun, fnxnMaxAmp, static_cast<Int_t>(maxn[1]), static_cast<Int_t>(maxn[2])) ;
488 //Transform digit amplitude in Raw Samples
489 if (fADCValuesLownxn == 0) {
490 fADCValuesHighnxn = new Int_t[nTimeBins];
491 fADCValuesLownxn = new Int_t[nTimeBins];
493 rawUtil.RawSampledResponse(maxtimeRn, fnxnMaxAmp, fADCValuesHighnxn, fADCValuesLownxn) ;
495 //Set Trigger Inputs, compare ADC time bins until threshold is attained
497 for(Int_t i = 0 ; i < nTimeBins ; i++){
498 if(fADCValuesHighnxn[i] >= fL1JetLowPtThreshold || fADCValuesLownxn[i] >= fL1JetLowPtThreshold){
499 SetInput("EMCAL_JetLPt_L1") ;
505 for(Int_t i = 0 ; i < nTimeBins ; i++){
506 if(fADCValuesHighnxn[i] >= fL1JetMediumPtThreshold || fADCValuesLownxn[i] >= fL1JetMediumPtThreshold){
507 SetInput("EMCAL_JetMPt_L1") ;
513 for(Int_t i = 0 ; i < nTimeBins ; i++){
514 if(fADCValuesHighnxn[i] >= fL1JetHighPtThreshold || fADCValuesLownxn[i] >= fL1JetHighPtThreshold){
515 SetInput("EMCAL_JetHPt_L1") ;
522 //____________________________________________________________________________
523 void AliEMCALTrigger::FillTRU(const AliEMCALGeometry *geom, const TClonesArray * digits, TClonesArray * ampmatrix, TClonesArray * ampmatrixsmod, TClonesArray * timeRmatrix) {
525 // Orders digits ampitudes list in fNTRU TRUs (384 cells) per supermodule.
526 // Each TRU is a TMatrixD, and they are kept in TClonesArrays. The number of
527 // TRU in phi is fNTRUPhi, and the number of TRU in eta is fNTRUEta.
528 // Last 2 modules are half size in Phi, I considered that the number of TRU
529 // is maintained for the last modules but decision not taken. If different,
530 // then this must be changed. Also fill a matrix with all amplitudes in supermodule for isolation studies.
534 if(fNTRUEta*fNTRUPhi != fNTRU)
535 Error("FillTRU"," Wrong number of TRUS per Eta or Phi");
537 //Initilize and declare variables
538 //List of TRU matrices initialized to 0.
539 Int_t nPhi = geom->GetNPhi();
540 Int_t nZ = geom->GetNZ();
541 Int_t nCellsPhi = nPhi*2/fNTRUPhi;
542 Int_t nCellsPhi2 = nPhi/fNTRUPhi; //HalfSize modules
543 Int_t nCellsEta = nZ*2/fNTRUEta;
555 //List of TRU matrices initialized to 0.
556 Int_t nSup = geom->GetNumberOfSuperModules();
557 for(Int_t k = 0; k < fNTRU*nSup; k++){
558 TMatrixD amptrus(nCellsPhi,nCellsEta) ;
559 TMatrixD timeRtrus(nCellsPhi,nCellsEta) ;
560 // Do we need to initialise? I think TMatrixD does it by itself...
561 for(Int_t i = 0; i < nCellsPhi; i++){
562 for(Int_t j = 0; j < nCellsEta; j++){
564 timeRtrus(i,j) = 0.0;
567 new((*ampmatrix)[k]) TMatrixD(amptrus) ;
568 new((*timeRmatrix)[k]) TMatrixD(timeRtrus) ;
571 //List of Modules matrices initialized to 0.
572 for(Int_t k = 0; k < nSup ; k++){
573 TMatrixD ampsmods( nPhi*2, nZ*2) ;
574 for(Int_t i = 0; i < nPhi*2; i++){
575 for(Int_t j = 0; j < nZ*2; j++){
579 new((*ampmatrixsmod)[k]) TMatrixD(ampsmods) ;
582 AliEMCALDigit * dig ;
584 //Digits loop to fill TRU matrices with amplitudes.
585 for(Int_t idig = 0 ; idig < digits->GetEntriesFast() ; idig++){
587 dig = dynamic_cast<AliEMCALDigit *>(digits->At(idig)) ;
588 amp = dig->GetAmp() ; // Energy of the digit (arbitrary units)
589 id = dig->GetId() ; // Id label of the cell
590 timeR = dig->GetTimeR() ; // Earliest time of the digit
592 //Get eta and phi cell position in supermodule
593 Bool_t bCell = geom->GetCellIndex(id, iSupMod, nModule, nIphi, nIeta) ;
595 Error("FillTRU","Wrong cell id number") ;
597 geom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
599 //Check to which TRU in the supermodule belongs the cell.
600 //Supermodules are divided in a TRU matrix of dimension
601 //(fNTRUPhi,fNTRUEta).
602 //Each TRU is a cell matrix of dimension (nCellsPhi,nCellsEta)
604 //First calculate the row and column in the supermodule
605 //of the TRU to which the cell belongs.
606 Int_t col = ieta/nCellsEta;
607 Int_t row = iphi/nCellsPhi;
609 row = iphi/nCellsPhi2;
610 //Calculate label number of the TRU
611 Int_t itru = row + col*fNTRUPhi + iSupMod*fNTRU ;
613 //Fill TRU matrix with cell values
614 TMatrixD * amptrus = dynamic_cast<TMatrixD *>(ampmatrix->At(itru)) ;
615 TMatrixD * timeRtrus = dynamic_cast<TMatrixD *>(timeRmatrix->At(itru)) ;
617 //Calculate row and column of the cell inside the TRU with number itru
618 Int_t irow = iphi - row * nCellsPhi;
620 irow = iphi - row * nCellsPhi2;
621 Int_t icol = ieta - col * nCellsEta;
623 (*amptrus)(irow,icol) = amp ;
624 (*timeRtrus)(irow,icol) = timeR ;
626 //####################SUPERMODULE MATRIX ##################
627 TMatrixD * ampsmods = dynamic_cast<TMatrixD *>(ampmatrixsmod->At(iSupMod)) ;
628 (*ampsmods)(iphi,ieta) = amp ;
632 //____________________________________________________________________________
633 void AliEMCALTrigger::Trigger()
635 //Main Method to select triggers.
636 AliRunLoader *runLoader = AliRunLoader::GetRunLoader();
637 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>
638 (runLoader->GetDetectorLoader("EMCAL"));
640 //Load EMCAL Geometry
641 AliEMCALGeometry * geom = 0;
642 if (runLoader->GetAliRun() && runLoader->GetAliRun()->GetDetector("EMCAL"))
643 geom = dynamic_cast<AliEMCAL*>(runLoader->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
645 geom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaulGeometryName());
648 AliFatal("Did not get geometry from EMCALLoader");
651 Int_t nSuperModules = geom->GetNumberOfSuperModules() ; //12 SM in EMCAL
652 fNTRU = geom->GetNTRU(); //3 TRU per super module
653 fNTRUEta = geom->GetNTRUEta(); //3 TRU in eta per super module
654 fNTRUPhi = geom->GetNTRUPhi(); //1 TRU in phi per super module
655 fNCellsPhi = geom->GetNPhi()*2/geom->GetNTRUPhi() ;
656 fNCellsEta = geom->GetNEta()*2/geom->GetNTRUEta() ;
658 //Intialize data members each time the trigger is called in event loop
659 f2x2MaxAmp = -1; f2x2CellPhi = -1; f2x2CellEta = -1;
660 fnxnMaxAmp = -1; fnxnCellPhi = -1; fnxnCellEta = -1;
662 //Take the digits list if simulation
664 runLoader->LoadDigits("EMCAL");
665 fDigitsList = emcalLoader->Digits() ;
668 AliFatal("Digits not found !") ;
670 //Take the digits list
673 TClonesArray * amptrus = new TClonesArray("TMatrixD",1000);
674 TClonesArray * ampsmods = new TClonesArray("TMatrixD",1000);
675 TClonesArray * timeRtrus = new TClonesArray("TMatrixD",1000);
677 FillTRU(geom,fDigitsList, amptrus, ampsmods, timeRtrus) ;
679 //Do Cell Sliding and select Trigger
680 //Initialize varible that will contain maximum amplitudes and
681 //its corresponding cell position in eta and phi, and time.
682 TMatrixD ampmax2(4,fNTRU) ;
683 TMatrixD ampmaxn(4,fNTRU) ;
685 for(Int_t iSM = 0 ; iSM < nSuperModules ; iSM++) {
686 //Do 2x2 and nxn sums, select maximums.
687 MakeSlidingCell(amptrus, timeRtrus, iSM, ampmax2, ampmaxn);
690 if(fIsolateInSuperModule)
691 SetTriggers(ampsmods,iSM,ampmax2,ampmaxn,geom) ;
692 if(!fIsolateInSuperModule)
693 SetTriggers(amptrus,iSM,ampmax2,ampmaxn,geom) ;
697 delete amptrus; amptrus = 0;
699 delete ampsmods; ampsmods = 0;
701 delete timeRtrus; timeRtrus = 0;