]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALTrigger.cxx
Correction for actual vertex position implemented
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALTrigger.cxx
CommitLineData
f0377b23 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$ */
f0377b23 16
17//_________________________________________________________________________
18//
19// Class for trigger analysis.
0964c2e9 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.
0b2ec9f7 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.
f0377b23 29// Usage:
30//
31// //Inside the event loop
32// AliEMCALTrigger *tr = new AliEMCALTrigger();//Init Trigger
0b2ec9f7 33// tr->SetL0Threshold(100); //Arbitrary threshold values
f0377b23 34// tr->SetL1JetLowPtThreshold(1000);
35// tr->SetL1JetMediumPtThreshold(10000);
36// tr->SetL1JetHighPtThreshold(20000);
0964c2e9 37// ...
f0377b23 38// tr->Trigger(); //Execute Trigger
39// tr->Print(""); //Print results
40//
41//*-- Author: Gustavo Conesa & Yves Schutz (IFIC, CERN)
42//////////////////////////////////////////////////////////////////////////////
43
44
45// --- ROOT system ---
f0377b23 46
47// --- ALIROOT system ---
f0377b23 48#include "AliRun.h"
49#include "AliRunLoader.h"
50#include "AliTriggerInput.h"
51#include "AliEMCAL.h"
52#include "AliEMCALLoader.h"
53#include "AliEMCALDigit.h"
54#include "AliEMCALTrigger.h"
55#include "AliEMCALGeometry.h"
133abe1f 56#include "AliEMCALRawUtils.h"
f0377b23 57
58ClassImp(AliEMCALTrigger)
59
60//______________________________________________________________________
61AliEMCALTrigger::AliEMCALTrigger()
62 : AliTriggerDetector(),
59264fa6 63 f2x2MaxAmp(-1), f2x2CellPhi(-1), f2x2CellEta(-1),
18a21c7c 64 f2x2SM(0),
0b2ec9f7 65 fnxnMaxAmp(-1), fnxnCellPhi(-1), fnxnCellEta(-1),
66 fnxnSM(0),
0964c2e9 67 fADCValuesHighnxn(0),fADCValuesLownxn(0),
68 fADCValuesHigh2x2(0),fADCValuesLow2x2(0),
69 fDigitsList(0),
18a21c7c 70 fL0Threshold(100),fL1JetLowPtThreshold(200),
71 fL1JetMediumPtThreshold(500), fL1JetHighPtThreshold(1000),
0964c2e9 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)
f0377b23 79{
59264fa6 80 //ctor
0964c2e9 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];
59264fa6 85
59264fa6 86 SetName("EMCAL");
87 CreateInputs();
f0377b23 88
59264fa6 89 //Print("") ;
f0377b23 90}
91
92
93
94//____________________________________________________________________________
95AliEMCALTrigger::AliEMCALTrigger(const AliEMCALTrigger & trig)
18a21c7c 96 : AliTriggerDetector(trig),
97 f2x2MaxAmp(trig.f2x2MaxAmp),
98 f2x2CellPhi(trig.f2x2CellPhi),
99 f2x2CellEta(trig.f2x2CellEta),
100 f2x2SM(trig.f2x2SM),
0b2ec9f7 101 fnxnMaxAmp(trig.fnxnMaxAmp),
102 fnxnCellPhi(trig.fnxnCellPhi),
103 fnxnCellEta(trig.fnxnCellEta),
104 fnxnSM(trig.fnxnSM),
105 fADCValuesHighnxn(trig.fADCValuesHighnxn),
106 fADCValuesLownxn(trig.fADCValuesLownxn),
18a21c7c 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),
0964c2e9 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)
f0377b23 126{
f0377b23 127 // cpy ctor
f0377b23 128}
129
130//----------------------------------------------------------------------
131void AliEMCALTrigger::CreateInputs()
132{
133 // inputs
134
135 // Do not create inputs again!!
136 if( fInputs.GetEntriesFast() > 0 ) return;
137
59264fa6 138 fInputs.AddLast( new AliTriggerInput( "EMCAL_L0", "EMCAL L0", 0x02 ) );
139 fInputs.AddLast( new AliTriggerInput( "EMCAL_JetHPt_L1","EMCAL Jet High Pt L1", 0x04 ) );
140 fInputs.AddLast( new AliTriggerInput( "EMCAL_JetMPt_L1","EMCAL Jet Medium Pt L1", 0x08 ) );
141 fInputs.AddLast( new AliTriggerInput( "EMCAL_JetLPt_L1","EMCAL Jet Low Pt L1", 0x016 ) );
f0377b23 142
143}
144
145//____________________________________________________________________________
0964c2e9 146Bool_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) {
147
148 //Calculate if the maximum patch found is isolated, find amplitude around maximum (2x2 or nxn) patch,
149 //inside isolation patch . iPatchType = 0 means calculation for 2x2 patch,
150 //iPatchType = 1 means calculation for nxn patch.
151 //In the next table there is an example of the different options of patch size and isolation patch size:
152 // Patch Size (fPatchSize)
153 // 0 1 2
154 // fIsolPatchSize 2x2 (not overlap) 4x4 (overlapped) 6x6(overlapped) ...
155 // 1 4x4 8x8 10x10
156 // 2 6x6 12x12 14x14
157 // 3 8x8 16x16 18x18
158
159 Bool_t b = kFALSE;
160 Float_t amp = 0;
161
162 //Get matrix of TRU or Module with maximum amplitude patch.
163 Int_t itru = mtru+iSM*fNTRU ; //number of tru, min 0 max 8*5.
164 TMatrixD * ampmatrix = 0x0;
165 Int_t colborder = 0;
166 Int_t rowborder = 0;
167
168 if(fIsolateInSuperModule){
169 ampmatrix = dynamic_cast<TMatrixD *>(ampmatrixes->At(iSM)) ;
170 rowborder = fNCellsPhi*fNTRUPhi;
171 colborder = fNCellsEta*fNTRUEta;
172 AliDebug(2,"Isolate trigger in Module");
173 }
174 else{
175 ampmatrix = dynamic_cast<TMatrixD *>(ampmatrixes->At(itru)) ;
176 rowborder = fNCellsPhi;
177 colborder = fNCellsEta;
178 AliDebug(2,"Isolate trigger in TRU");
179 }
180
181 //Define patch cells
182 Int_t isolcells = fIsolPatchSize*(1+iPatchType);
183 Int_t ipatchcells = 2*(1+fPatchSize*iPatchType);
184 Int_t minrow = maxphi - isolcells;
185 Int_t mincol = maxeta - isolcells;
186 Int_t maxrow = maxphi + isolcells + ipatchcells;
187 Int_t maxcol = maxeta + isolcells + ipatchcells;
188
189 AliDebug(2,Form("Number of added Isol Cells %d, Patch Size %d",isolcells, ipatchcells));
190 AliDebug(2,Form("Patch: minrow %d, maxrow %d, mincol %d, maxcol %d",minrow,maxrow,mincol,maxcol));
191
192 if(minrow < 0 || mincol < 0 || maxrow > rowborder || maxcol > colborder){
193 AliDebug(1,Form("Out of Module/TRU range, cannot isolate patch"));
194 return kFALSE;
195 }
196
197 //Add amplitudes in all isolation patch
198 for(Int_t irow = minrow ; irow < maxrow; irow ++)
199 for(Int_t icol = mincol ; icol < maxcol ; icol ++)
200 amp += (*ampmatrix)(irow,icol);
201
202 AliDebug(2,Form("Type %d, Maximum amplitude %f, patch+isol square %f",iPatchType, maxamp, amp));
203
204 if(amp < maxamp){
205 AliError(Form("Bad sum: Type %d, Maximum amplitude %f, patch+isol square %f",iPatchType, maxamp, amp));
206 return kFALSE;
207 }
208 else
209 amp-=maxamp; //Calculate energy in isolation patch that do not comes from maximum patch.
210
211 AliDebug(2, Form("Maximum amplitude %f, Out of patch %f",maxamp, amp));
212
213 //Fill isolation amplitude data member and say if patch is isolated.
214 if(iPatchType == 0){ //2x2 case
215 f2x2AmpOutOfPatch = amp;
216 if(amp < f2x2AmpOutOfPatchThres)
217 b=kTRUE;
218 }
219 else if(iPatchType == 1){ //nxn case
220 fnxnAmpOutOfPatch = amp;
221 if(amp < fnxnAmpOutOfPatchThres)
222 b=kTRUE;
223 }
224
225 return b;
226
227}
228
229//____________________________________________________________________________
230void AliEMCALTrigger::MakeSlidingCell(const TClonesArray * amptrus, const TClonesArray * timeRtrus, const Int_t isupermod,TMatrixD *ampmax2, TMatrixD *ampmaxn){
f0377b23 231
0b2ec9f7 232 //Sums energy of all possible 2x2 (L0) and nxn (L1) cells per each TRU.
59264fa6 233 //Fast signal in the experiment is given by 2x2 cells,
234 //for this reason we loop inside the TRU cells by 2.
33d0b833 235
59264fa6 236 //Declare and initialize variables
0964c2e9 237 Int_t nCellsPhi = fNCellsPhi;//geom->GetNPhi()*2/geom->GetNTRUPhi() ;
33d0b833 238 if(isupermod > 9)
59264fa6 239 nCellsPhi = nCellsPhi / 2 ; //Half size SM. Not Final.
f0377b23 240 // 12(tow)*2(cell)/1 TRU, cells in Phi in one TRU
0964c2e9 241 Int_t nCellsEta = fNCellsEta ;//geom->GetNEta()*2/geom->GetNTRUEta() ;
f0377b23 242 // 24(mod)*2(tower)/3 TRU, cells in Eta in one TRU
0964c2e9 243 //Int_t nTRU = geom->GeNTRU();//3 TRU per super module
f0377b23 244
59264fa6 245 Float_t amp2 = 0 ;
0b2ec9f7 246 Float_t ampn = 0 ;
33d0b833 247 for(Int_t i = 0; i < 4; i++){
0964c2e9 248 for(Int_t j = 0; j < fNTRU; j++){
59264fa6 249 (*ampmax2)(i,j) = -1;
0b2ec9f7 250 (*ampmaxn)(i,j) = -1;
59264fa6 251 }
252 }
f0377b23 253
59264fa6 254 //Create matrix that will contain 2x2 amplitude sums
0b2ec9f7 255 //used to calculate the nxn sums
59264fa6 256 TMatrixD * tru2x2 = new TMatrixD(nCellsPhi/2,nCellsEta/2) ;
257 for(Int_t i = 0; i < nCellsPhi/2; i++)
258 for(Int_t j = 0; j < nCellsEta/2; j++)
259 (*tru2x2)(i,j) = -1;
260
261 //Loop over all TRUS in a supermodule
0964c2e9 262 for(Int_t itru = 0 + isupermod * fNTRU ; itru < (isupermod+1)*fNTRU ; itru++) {
59264fa6 263 TMatrixD * amptru = dynamic_cast<TMatrixD *>(amptrus->At(itru)) ;
264 TMatrixD * timeRtru = dynamic_cast<TMatrixD *>(timeRtrus->At(itru)) ;
0964c2e9 265 Int_t mtru = itru-isupermod*fNTRU ; //Number of TRU in Supermodule
33d0b833 266
59264fa6 267 //Sliding 2x2, add 2x2 amplitudes (NOT OVERLAP)
268 for(Int_t irow = 0 ; irow < nCellsPhi; irow += 2){
269 for(Int_t icol = 0 ; icol < nCellsEta ; icol += 2){
270 amp2 = (*amptru)(irow,icol)+(*amptru)(irow+1,icol)+
271 (*amptru)(irow,icol+1)+(*amptru)(irow+1,icol+1);
33d0b833 272
0964c2e9 273 //Fill matrix with added 2x2 cells for use in nxn sums
59264fa6 274 (*tru2x2)(irow/2,icol/2) = amp2 ;
275 //Select 2x2 maximum sums to select L0
276 if(amp2 > (*ampmax2)(0,mtru)){
277 (*ampmax2)(0,mtru) = amp2 ;
278 (*ampmax2)(1,mtru) = irow;
279 (*ampmax2)(2,mtru) = icol;
280 }
281 }
282 }
283
284 //Find most recent time in the selected 2x2 cell
285 (*ampmax2)(3,mtru) = 1 ;
286 Int_t row2 = static_cast <Int_t> ((*ampmax2)(1,mtru));
287 Int_t col2 = static_cast <Int_t> ((*ampmax2)(2,mtru));
288 for(Int_t i = 0; i<2; i++){
289 for(Int_t j = 0; j<2; j++){
290 if((*amptru)(row2+i,col2+j) > 0 && (*timeRtru)(row2+i,col2+j)> 0){
291 if((*timeRtru)(row2+i,col2+j) < (*ampmax2)(3,mtru) )
292 (*ampmax2)(3,mtru) = (*timeRtru)(row2+i,col2+j);
293 }
294 }
295 }
0b2ec9f7 296
297 //Sliding nxn, add nxn amplitudes (OVERLAP)
298 if(fPatchSize > 0){
299 for(Int_t irow = 0 ; irow < nCellsPhi/2; irow++){
300 for(Int_t icol = 0 ; icol < nCellsEta/2 ; icol++){
301 ampn = 0;
302 if( (irow+fPatchSize) < nCellsPhi/2 && (icol+fPatchSize) < nCellsEta/2){//Avoid exit the TRU
303 for(Int_t i = 0 ; i <= fPatchSize ; i++)
304 for(Int_t j = 0 ; j <= fPatchSize ; j++)
305 ampn += (*tru2x2)(irow+i,icol+j);
306 //Select nxn maximum sums to select L1
307 if(ampn > (*ampmaxn)(0,mtru)){
308 (*ampmaxn)(0,mtru) = ampn ;
309 (*ampmaxn)(1,mtru) = irow*2;
310 (*ampmaxn)(2,mtru) = icol*2;
311 }
59264fa6 312 }
313 }
314 }
0b2ec9f7 315
316 //Find most recent time in selected nxn cell
317 (*ampmaxn)(3,mtru) = 1 ;
318 Int_t rown = static_cast <Int_t> ((*ampmaxn)(1,mtru));
319 Int_t coln = static_cast <Int_t> ((*ampmaxn)(2,mtru));
320 for(Int_t i = 0; i<4*fPatchSize; i++){
321 for(Int_t j = 0; j<4*fPatchSize; j++){
322 if( (rown+i) < nCellsPhi && (coln+j) < nCellsEta/2){//Avoid exit the TRU
323 if((*amptru)(rown+i,coln+j) > 0 && (*timeRtru)(rown+i,coln+j)> 0){
324 if((*timeRtru)(rown+i,coln+j) < (*ampmaxn)(3,mtru) )
325 (*ampmaxn)(3,mtru) = (*timeRtru)(rown+i,coln+j);
326 }
327 }
59264fa6 328 }
329 }
330 }
0b2ec9f7 331 else {
332 (*ampmaxn)(0,mtru) = (*ampmax2)(0,mtru);
333 (*ampmaxn)(1,mtru) = (*ampmax2)(1,mtru);
334 (*ampmaxn)(2,mtru) = (*ampmax2)(2,mtru);
335 (*ampmaxn)(3,mtru) = (*ampmax2)(3,mtru);
336 }
f0377b23 337 }
f0377b23 338}
339
340//____________________________________________________________________________
341void AliEMCALTrigger::Print(const Option_t * opt) const
342{
343
344 //Prints main parameters
345
346 if(! opt)
347 return;
348 AliTriggerInput* in = 0x0 ;
59264fa6 349
350 printf( " Maximum Amplitude after Sliding Cell, \n") ;
351 printf( " -2x2 cells sum (not overlapped): %10.2f, in Super Module %d\n",
352 f2x2MaxAmp,f2x2SM) ;
0b2ec9f7 353 printf( " -2x2 from row %d to row %d and from column %d to column %d\n", f2x2CellPhi, f2x2CellPhi+2, f2x2CellEta, f2x2CellEta+2) ;
0964c2e9 354 printf( " -2x2 Isolation Patch %d x %d, Amplitude out of 2x2 patch is %f, threshold %f, Isolated? %d \n",
355 2*fIsolPatchSize+2, 2*fIsolPatchSize+2, f2x2AmpOutOfPatch, f2x2AmpOutOfPatchThres,static_cast<Int_t> (fIs2x2Isol)) ;
0b2ec9f7 356 if(fPatchSize > 0){
0964c2e9 357 printf( " Patch Size, n x n: %d x %d cells\n",2*(fPatchSize+1), 2*(fPatchSize+1));
0b2ec9f7 358 printf( " -nxn cells sum (overlapped) : %10.2f, in Super Module %d\n",
359 fnxnMaxAmp,fnxnSM) ;
360 printf( " -nxn from row %d to row %d and from column %d to column %d\n", fnxnCellPhi, fnxnCellPhi+4*fPatchSize, fnxnCellEta, fnxnCellEta+4*fPatchSize) ;
0964c2e9 361 printf( " -nxn Isolation Patch %d x %d, Amplitude out of nxn patch is %f, threshold %f, Isolated? %d \n",
362 4*fIsolPatchSize+2*(fPatchSize+1),4*fIsolPatchSize+2*(fPatchSize+1) , fnxnAmpOutOfPatch, fnxnAmpOutOfPatchThres,static_cast<Int_t> (fIsnxnIsol) ) ;
0b2ec9f7 363 }
0964c2e9 364
365 printf( " Isolate in SuperModule? %d\n",
366 fIsolateInSuperModule) ;
367
59264fa6 368 printf( " Threshold for LO %10.2f\n",
369 fL0Threshold) ;
370 in = (AliTriggerInput*)fInputs.FindObject( "EMCAL_L0" );
f0377b23 371 if(in->GetValue())
59264fa6 372 printf( " *** EMCAL LO is set ***\n") ;
f0377b23 373
59264fa6 374 printf( " Jet Low Pt Threshold for L1 %10.2f\n",
375 fL1JetLowPtThreshold) ;
376 in = (AliTriggerInput*)fInputs.FindObject( "EMCAL_JetLPt_L1" );
f0377b23 377 if(in->GetValue())
59264fa6 378 printf( " *** EMCAL Jet Low Pt for L1 is set ***\n") ;
f0377b23 379
59264fa6 380 printf( " Jet Medium Pt Threshold for L1 %10.2f\n",
381 fL1JetMediumPtThreshold) ;
382 in = (AliTriggerInput*) fInputs.FindObject( "EMCAL_JetMPt_L1" );
f0377b23 383 if(in->GetValue())
59264fa6 384 printf( " *** EMCAL Jet Medium Pt for L1 is set ***\n") ;
f0377b23 385
59264fa6 386 printf( " Jet High Pt Threshold for L1 %10.2f\n",
387 fL1JetHighPtThreshold) ;
388 in = (AliTriggerInput*) fInputs.FindObject( "EMCAL_JetHPt_L1" );
f0377b23 389 if(in->GetValue())
59264fa6 390 printf( " *** EMCAL Jet High Pt for L1 is set ***\n") ;
f0377b23 391
392}
393
394//____________________________________________________________________________
0964c2e9 395void AliEMCALTrigger::SetTriggers(const TClonesArray * ampmatrix,const Int_t iSM,
396 const TMatrixD *ampmax2,
397 const TMatrixD *ampmaxn, const AliEMCALGeometry *geom)
f0377b23 398{
399
0b2ec9f7 400 //Checks the 2x2 and nxn maximum amplitude per each TRU and
59264fa6 401 //compares with the different L0 and L1 triggers thresholds
402 Float_t max2[] = {-1,-1,-1,-1} ;
0b2ec9f7 403 Float_t maxn[] = {-1,-1,-1,-1} ;
0964c2e9 404 Int_t mtru2 = -1 ;
405 Int_t mtrun = -1 ;
f0377b23 406
59264fa6 407 //Find maximum summed amplitude of all the TRU
408 //in a Super Module
0964c2e9 409 for(Int_t i = 0 ; i < fNTRU ; i++){
59264fa6 410 if(max2[0] < (*ampmax2)(0,i) ){
411 max2[0] = (*ampmax2)(0,i) ; // 2x2 summed max amplitude
412 max2[1] = (*ampmax2)(1,i) ; // corresponding phi position in TRU
413 max2[2] = (*ampmax2)(2,i) ; // corresponding eta position in TRU
414 max2[3] = (*ampmax2)(3,i) ; // corresponding most recent time
0964c2e9 415 mtru2 = i ;
59264fa6 416 }
0b2ec9f7 417 if(maxn[0] < (*ampmaxn)(0,i) ){
418 maxn[0] = (*ampmaxn)(0,i) ; // nxn summed max amplitude
419 maxn[1] = (*ampmaxn)(1,i) ; // corresponding phi position in TRU
420 maxn[2] = (*ampmaxn)(2,i) ; // corresponding eta position in TRU
421 maxn[3] = (*ampmaxn)(3,i) ; // corresponding most recent time
0964c2e9 422 mtrun = i ;
59264fa6 423 }
424 }
425
426 //--------Set max amplitude if larger than in other Super Modules------------
427 Float_t maxtimeR2 = -1 ;
0b2ec9f7 428 Float_t maxtimeRn = -1 ;
133abe1f 429 static AliEMCALRawUtils rawUtil;
430 Int_t nTimeBins = rawUtil.GetRawFormatTimeBins() ;
59264fa6 431
432 //Set max of 2x2 amplitudes and select L0 trigger
433 if(max2[0] > f2x2MaxAmp ){
434 f2x2MaxAmp = max2[0] ;
435 f2x2SM = iSM ;
436 maxtimeR2 = max2[3] ;
0964c2e9 437 geom->GetCellPhiEtaIndexInSModuleFromTRUIndex(mtru2,
59264fa6 438 static_cast<Int_t>(max2[1]),
439 static_cast<Int_t>(max2[2]),
440 f2x2CellPhi,f2x2CellEta) ;
441
0964c2e9 442 //Isolated patch?
443 if(fIsolateInSuperModule)
444 fIs2x2Isol = IsPatchIsolated(0, ampmatrix, iSM, mtru2, f2x2MaxAmp, f2x2CellPhi,f2x2CellEta) ;
445 else
446 fIs2x2Isol = IsPatchIsolated(0, ampmatrix, iSM, mtru2, f2x2MaxAmp, static_cast<Int_t>(max2[1]), static_cast<Int_t>(max2[2])) ;
447
59264fa6 448 //Transform digit amplitude in Raw Samples
449 fADCValuesLow2x2 = new Int_t[nTimeBins];
450 fADCValuesHigh2x2 = new Int_t[nTimeBins];
133abe1f 451 rawUtil.RawSampledResponse(maxtimeR2, f2x2MaxAmp, fADCValuesHigh2x2, fADCValuesLow2x2) ;
59264fa6 452
453 //Set Trigger Inputs, compare ADC time bins until threshold is attained
454 //Set L0
455 for(Int_t i = 0 ; i < nTimeBins ; i++){
456 if(fADCValuesHigh2x2[i] >= fL0Threshold || fADCValuesLow2x2[i] >= fL0Threshold){
457 SetInput("EMCAL_L0") ;
458 break;
459 }
460 }
f0377b23 461 }
59264fa6 462
0b2ec9f7 463 //------------Set max of nxn amplitudes and select L1 trigger---------
464 if(maxn[0] > fnxnMaxAmp ){
465 fnxnMaxAmp = maxn[0] ;
466 fnxnSM = iSM ;
467 maxtimeRn = maxn[3] ;
0964c2e9 468 geom->GetCellPhiEtaIndexInSModuleFromTRUIndex(mtrun,
0b2ec9f7 469 static_cast<Int_t>(maxn[1]),
470 static_cast<Int_t>(maxn[2]),
471 fnxnCellPhi,fnxnCellEta) ;
0964c2e9 472
473 //Isolated patch?
474 if(fIsolateInSuperModule)
475 fIsnxnIsol = IsPatchIsolated(1, ampmatrix, iSM, mtrun, fnxnMaxAmp, fnxnCellPhi, fnxnCellEta) ;
476 else
477 fIsnxnIsol = IsPatchIsolated(1, ampmatrix, iSM, mtrun, fnxnMaxAmp, static_cast<Int_t>(maxn[1]), static_cast<Int_t>(maxn[2])) ;
478
59264fa6 479 //Transform digit amplitude in Raw Samples
0b2ec9f7 480 fADCValuesHighnxn = new Int_t[nTimeBins];
481 fADCValuesLownxn = new Int_t[nTimeBins];
133abe1f 482 rawUtil.RawSampledResponse(maxtimeRn, fnxnMaxAmp, fADCValuesHighnxn, fADCValuesLownxn) ;
59264fa6 483
484 //Set Trigger Inputs, compare ADC time bins until threshold is attained
485 //SetL1 Low
486 for(Int_t i = 0 ; i < nTimeBins ; i++){
0b2ec9f7 487 if(fADCValuesHighnxn[i] >= fL1JetLowPtThreshold || fADCValuesLownxn[i] >= fL1JetLowPtThreshold){
59264fa6 488 SetInput("EMCAL_JetLPt_L1") ;
489 break;
490 }
491 }
492
493 //SetL1 Medium
494 for(Int_t i = 0 ; i < nTimeBins ; i++){
0b2ec9f7 495 if(fADCValuesHighnxn[i] >= fL1JetMediumPtThreshold || fADCValuesLownxn[i] >= fL1JetMediumPtThreshold){
59264fa6 496 SetInput("EMCAL_JetMPt_L1") ;
497 break;
498 }
499 }
500
501 //SetL1 High
502 for(Int_t i = 0 ; i < nTimeBins ; i++){
0b2ec9f7 503 if(fADCValuesHighnxn[i] >= fL1JetHighPtThreshold || fADCValuesLownxn[i] >= fL1JetHighPtThreshold){
59264fa6 504 SetInput("EMCAL_JetHPt_L1") ;
505 break;
506 }
507 }
59264fa6 508 }
509}
f0377b23 510
59264fa6 511//____________________________________________________________________________
512void AliEMCALTrigger::Trigger()
513{
514 //Main Method to select triggers.
c787fb51 515 AliRunLoader *runLoader = AliRunLoader::GetRunLoader();
59264fa6 516 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>
c787fb51 517 (runLoader->GetDetectorLoader("EMCAL"));
0964c2e9 518
59264fa6 519 //Load EMCAL Geometry
c787fb51 520 AliEMCALGeometry * geom = 0;
521 if (runLoader->GetAliRun() && runLoader->GetAliRun()->GetDetector("EMCAL"))
522 geom = dynamic_cast<AliEMCAL*>(runLoader->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
523 if (geom == 0)
524 geom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaulGeometryName());
0964c2e9 525
59264fa6 526 if (geom==0)
527 AliFatal("Did not get geometry from EMCALLoader");
0964c2e9 528
59264fa6 529 //Define parameters
530 Int_t nSuperModules = geom->GetNumberOfSuperModules() ; //12 SM in EMCAL
0964c2e9 531 fNTRU = geom->GetNTRU(); //3 TRU per super module
532 fNTRUEta = geom->GetNTRUEta(); //3 TRU in eta per super module
533 fNTRUPhi = geom->GetNTRUPhi(); //1 TRU in phi per super module
534 fNCellsPhi = geom->GetNPhi()*2/geom->GetNTRUPhi() ;
535 fNCellsEta = geom->GetNEta()*2/geom->GetNTRUEta() ;
59264fa6 536
537 //Intialize data members each time the trigger is called in event loop
538 f2x2MaxAmp = -1; f2x2CellPhi = -1; f2x2CellEta = -1;
0b2ec9f7 539 fnxnMaxAmp = -1; fnxnCellPhi = -1; fnxnCellEta = -1;
59264fa6 540
541 //Take the digits list if simulation
542 if(fSimulation){
c787fb51 543 runLoader->LoadDigits("EMCAL");
59264fa6 544 fDigitsList = emcalLoader->Digits() ;
545 }
59264fa6 546 if(!fDigitsList)
547 AliFatal("Digits not found !") ;
548
549 //Take the digits list
550
551 //Fill TRU Matrix
552 TClonesArray * amptrus = new TClonesArray("TMatrixD",1000);
0964c2e9 553 TClonesArray * ampsmods = new TClonesArray("TMatrixD",1000);
59264fa6 554 TClonesArray * timeRtrus = new TClonesArray("TMatrixD",1000);
0964c2e9 555
556 geom->FillTRU(fDigitsList, amptrus, ampsmods, timeRtrus) ;
59264fa6 557
558 //Do Cell Sliding and select Trigger
559 //Initialize varible that will contain maximum amplitudes and
560 //its corresponding cell position in eta and phi, and time.
0964c2e9 561 TMatrixD * ampmax2 = new TMatrixD(4,fNTRU) ;
562 TMatrixD * ampmaxn = new TMatrixD(4,fNTRU) ;
563
33d0b833 564 for(Int_t iSM = 0 ; iSM < nSuperModules ; iSM++) {
0b2ec9f7 565 //Do 2x2 and nxn sums, select maximums.
0964c2e9 566 MakeSlidingCell(amptrus, timeRtrus, iSM, ampmax2, ampmaxn);
567
59264fa6 568 //Set the trigger
0964c2e9 569 if(fIsolateInSuperModule)
570 SetTriggers(ampsmods,iSM,ampmax2,ampmaxn,geom) ;
571 if(!fIsolateInSuperModule)
572 SetTriggers(amptrus,iSM,ampmax2,ampmaxn,geom) ;
59264fa6 573 }
0964c2e9 574
575 //Print();
576
f0377b23 577}