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 // modules 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->SetL1GammaLowPtThreshold(1000);
35 // tr->SetL1GammaMediumPtThreshold(10000);
36 // tr->SetL1GammaHighPtThreshold(20000);
38 // tr->Trigger(); //Execute Trigger
39 // tr->Print(""); //Print results
41 //*-- Author: Gustavo Conesa & Yves Schutz (IFIC, CERN)
42 //////////////////////////////////////////////////////////////////////////////
46 // --- ROOT system ---
52 // --- ALIROOT system ---
54 #include "AliRunLoader.h"
55 #include "AliTriggerInput.h"
57 #include "AliEMCALLoader.h"
58 #include "AliEMCALDigit.h"
59 #include "AliEMCALTrigger.h"
60 #include "AliEMCALGeometry.h"
61 #include "AliEMCALRawUtils.h"
63 #include "AliCaloConstants.h"
64 #include "AliEMCALRawResponse.h"
68 ClassImp(AliEMCALTrigger)
70 TString AliEMCALTrigger::fgNameOfJetTriggers("EMCALJetTriggerL1");
72 //______________________________________________________________________
73 AliEMCALTrigger::AliEMCALTrigger()
74 : AliTriggerDetector(), fGeom(0),
75 f2x2MaxAmp(-1), f2x2ModulePhi(-1), f2x2ModuleEta(-1),
77 fnxnMaxAmp(-1), fnxnModulePhi(-1), fnxnModuleEta(-1),
79 fADCValuesHighnxn(0),fADCValuesLownxn(0),
80 fADCValuesHigh2x2(0),fADCValuesLow2x2(0),
82 fL0Threshold(100),fL1GammaLowPtThreshold(200),
83 fL1GammaMediumPtThreshold(500), fL1GammaHighPtThreshold(1000),
84 fPatchSize(1), fIsolPatchSize(1),
85 f2x2AmpOutOfPatch(-1), fnxnAmpOutOfPatch(-1),
86 f2x2AmpOutOfPatchThres(100000), fnxnAmpOutOfPatchThres(100000),
87 fIs2x2Isol(kFALSE), fIsnxnIsol(kFALSE),
88 fSimulation(kTRUE), fIsolateInSuperModule(kTRUE), fTimeKey(kFALSE),
89 fAmpTrus(0),fTimeRtrus(0),fAmpSMods(0),
90 fTriggerPosition(6), fTriggerAmplitudes(4),
91 fNJetPatchPhi(3), fNJetPatchEta(3), fNJetThreshold(3), fL1JetThreshold(0), fJetMaxAmp(0),
92 fAmpJetMatrix(0), fJetMatrixE(0), fAmpJetMax(6,1), fVZER0Mult(0.)
95 fADCValuesHighnxn = 0x0; //new Int_t[fTimeBins];
96 fADCValuesLownxn = 0x0; //new Int_t[fTimeBins];
97 fADCValuesHigh2x2 = 0x0; //new Int_t[fTimeBins];
98 fADCValuesLow2x2 = 0x0; //new Int_t[fTimeBins];
101 // Define jet threshold - can not change from outside now
102 // fNJetThreshold = 7; // For MB Pythia suppression
103 fNJetThreshold = 10; // Hijing
104 fL1JetThreshold = new Double_t[fNJetThreshold];
105 if(fNJetThreshold == 7) {
106 fL1JetThreshold[0] = 5./0.0153;
107 fL1JetThreshold[1] = 8./0.0153;
108 fL1JetThreshold[2] = 10./0.0153;
109 fL1JetThreshold[3] = 12./0.0153;
110 fL1JetThreshold[4] = 13./0.0153;
111 fL1JetThreshold[5] = 14./0.0153;
112 fL1JetThreshold[6] = 15./0.0153;
113 } else if(fNJetThreshold == 10) {
114 Double_t thGev[10]={5.,8.,10., 12., 13.,14.,15., 17., 20., 25.};
115 for(Int_t i=0; i<fNJetThreshold; i++) fL1JetThreshold[i] = thGev[i]/0.0153;
117 fL1JetThreshold[0] = 5./0.0153;
118 fL1JetThreshold[1] = 10./0.0153;
119 fL1JetThreshold[2] = 15./0.0153;
120 fL1JetThreshold[3] = 20./0.0153;
121 fL1JetThreshold[4] = 25./0.0153;
126 fInputs.SetName("TriggersInputs");
130 //____________________________________________________________________________
131 AliEMCALTrigger::~AliEMCALTrigger() {
136 delete [] fADCValuesHighnxn;
137 delete [] fADCValuesLownxn;
138 delete [] fADCValuesHigh2x2;
139 delete [] fADCValuesLow2x2;
141 if(fAmpTrus) {fAmpTrus->Delete(); delete fAmpTrus;}
142 if(fTimeRtrus) {fTimeRtrus->Delete(); delete fTimeRtrus;}
143 if(fAmpSMods) {fAmpSMods->Delete(); delete fAmpSMods;}
144 if(fAmpJetMatrix) delete fAmpJetMatrix;
145 if(fJetMatrixE) delete fJetMatrixE;
146 if(fL1JetThreshold) delete [] fL1JetThreshold;
149 //----------------------------------------------------------------------
150 void AliEMCALTrigger::CreateInputs()
154 // Do not create inputs again!!
155 if( fInputs.GetEntriesFast() > 0 ) return;
157 // Second parameter should be detector name = "EMCAL"
158 TString det("EMCAL"); // Apr 29, 2008
159 fInputs.AddLast( new AliTriggerInput( det+"_L0", det, 0x02) );
160 fInputs.AddLast( new AliTriggerInput( det+"_GammaHPt_L1", det, 0x04 ) );
161 fInputs.AddLast( new AliTriggerInput( det+"_GammaMPt_L1", det, 0x08 ) );
162 fInputs.AddLast( new AliTriggerInput( det+"_GammaLPt_L1", det, 0x016 ) );
163 fInputs.AddLast( new AliTriggerInput( det+"_JetHPt_L1", det, 0x032 ) );
164 fInputs.AddLast( new AliTriggerInput( det+"_JetMPt_L1", det, 0x048 ) );
165 fInputs.AddLast( new AliTriggerInput( det+"_JetLPt_L1", det, 0x064 ) );
167 if(fNJetThreshold<=0) return;
169 UInt_t level = 0x032;
170 for(Int_t i=0; i<fNJetThreshold; i++ ) {
171 TString name(GetNameOfJetTrigger(i));
172 TString title("EMCAL Jet triger L1 :"); // unused now
173 // 0.0153 - hard coded now
174 title += Form("Th %i(%5.1f GeV) :", (Int_t)fL1JetThreshold[i], fL1JetThreshold[i] * 0.0153);
175 title += Form("patch %ix%i~(%3.2f(#phi)x%3.2f(#eta)) ",
176 fNJetPatchPhi, fNJetPatchEta, 0.11*(fNJetPatchPhi), 0.11*(fNJetPatchEta));
177 fInputs.AddLast( new AliTriggerInput(name, det, UChar_t(level)) );
183 //____________________________________________________________________________
184 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) {
187 // EMCAL RTU size is 4modules(phi) x 24modules (eta)
188 // So maximum size of patch is 4modules x 4modules (EMCAL L0 trigger).
189 // Calculate if the maximum patch found is isolated, find amplitude around maximum (2x2 or nxn) patch,
190 // inside isolation patch . iPatchType = 0 means calculation for 2x2 patch,
191 // iPatchType = 1 means calculation for nxn patch.
192 // In the next table there is an example of the different options of patch size and isolation patch size:
193 // Patch Size (fPatchSize)
195 // fIsolPatchSize 0 2x2 (not overlap) 4x4 (overlapped)
199 if(!ampmatrixes) return kFALSE;
201 // Get matrix of TRU or Module with maximum amplitude patch.
202 Int_t itru = mtru + iSM * fGeom->GetNTRU(); //number of tru, min 0 max 3*12=36.
203 TMatrixD * ampmatrix = 0x0;
206 static int keyPrint = 0;
207 if(keyPrint) AliDebug(2,Form(" IsPatchIsolated : iSM %i mtru %i itru %i maxphi %i maxeta %i \n", iSM, mtru, itru, maxphi, maxeta));
209 if(fIsolateInSuperModule){ // ?
210 ampmatrix = dynamic_cast<TMatrixD *>(ampmatrixes->At(iSM)) ;
211 rowborder = fGeom->GetNPhi();
212 colborder = fGeom->GetNZ();
213 AliDebug(2,"Isolate trigger in Module");
215 ampmatrix = dynamic_cast<TMatrixD *>(ampmatrixes->At(itru)) ;
216 rowborder = fGeom->GetNModulesInTRUPhi();
217 colborder = fGeom->GetNModulesInTRUEta();
218 AliDebug(2,"Isolate trigger in TRU");
220 if(iSM>9) rowborder /= 2; // half size in phi
222 if(!ampmatrixes || !ampmatrix){
223 AliError("Could not recover the matrix with the amplitudes");
227 //Define patch modules - what is this ??
228 Int_t isolmodules = fIsolPatchSize*(1+iPatchType);
229 Int_t ipatchmodules = 2*(1+fPatchSize*iPatchType);
230 Int_t minrow = maxphi - isolmodules;
231 Int_t mincol = maxeta - isolmodules;
232 Int_t maxrow = maxphi + isolmodules + ipatchmodules;
233 Int_t maxcol = maxeta + isolmodules + ipatchmodules;
235 minrow = minrow<0?0 :minrow;
236 mincol = mincol<0?0 :mincol;
238 maxrow = maxrow>rowborder?rowborder :maxrow;
239 maxcol = maxcol>colborder?colborder :maxcol;
241 //printf("%s\n",Form("Number of added Isol Modules %d, Patch Size %d",isolmodules, ipatchmodules));
242 //printf("%s\n",Form("Patch: minrow %d, maxrow %d, mincol %d, maxcol %d",minrow,maxrow,mincol,maxcol));
243 // AliDebug(2,Form("Number of added Isol Modules %d, Patch Size %d",isolmodules, ipatchmodules));
244 //AliDebug(2,Form("Patch: minrow %d, maxrow %d, mincol %d, maxcol %d",minrow,maxrow,mincol,maxcol));
246 //Add amplitudes in all isolation patch
248 for(Int_t irow = minrow ; irow < maxrow; irow ++)
249 for(Int_t icol = mincol ; icol < maxcol ; icol ++)
250 amp += (*ampmatrix)(irow,icol);
252 AliDebug(2,Form("Type %d, Maximum amplitude %f, patch+isol square %f",iPatchType, maxamp, amp));
255 // AliError(Form("Bad sum: Type %d, Maximum amplitude %f, patch+isol square %f",iPatchType, maxamp, amp));
256 // ampmatrix->Print();
259 amp-=maxamp; //Calculate energy in isolation patch that do not comes from maximum patch.
262 AliDebug(2, Form("Maximum amplitude %f, Out of patch %f",maxamp, amp));
264 //Fill isolation amplitude data member and say if patch is isolated.
265 if(iPatchType == 0){ //2x2 case
266 f2x2AmpOutOfPatch = amp;
267 if(amp < f2x2AmpOutOfPatchThres) b=kTRUE;
268 } else if(iPatchType == 1){ //nxn case
269 fnxnAmpOutOfPatch = amp;
270 if(amp < fnxnAmpOutOfPatchThres) b=kTRUE;
273 if(keyPrint) AliDebug(2,Form(" IsPatchIsolated - OUT \n"));
280 //____________________________________________________________________________
281 void AliEMCALTrigger::MakeSlidingCell(const TClonesArray * amptrus, const TClonesArray * timeRtrus, const Int_t isupermod,TMatrixD &max2, TMatrixD &maxn){
283 //Sums energy of all possible 2x2 (L0) and nxn (L1) modules per each TRU.
284 //Fast signal in the experiment is given by 2x2 modules,
285 //for this reason we loop inside the TRU modules by 2.
287 //Declare and initialize variables
288 Int_t nCellsPhi = fGeom->GetNCellsInTRUPhi();
290 nCellsPhi = nCellsPhi / 2 ; //Half size SM. Not Final.
291 // 12(tow)*2(cell)/1 TRU, cells in Phi in one TRU
292 Int_t nCellsEta = fGeom->GetNCellsInTRUEta();
293 Int_t nTRU = fGeom->GetNTRU();
294 // 24(mod)*2(tower)/3 TRU, cells in Eta in one TRU
295 //Int_t nTRU = geom->GeNTRU();//3 TRU per super module
299 for(Int_t i = 0; i < 4; i++){
300 for(Int_t j = 0; j < nTRU; j++){
306 //Create matrix that will contain 2x2 amplitude sums
307 //used to calculate the nxn sums
308 TMatrixD tru2x2(nCellsPhi/2,nCellsEta/2) ;
309 for(Int_t i = 0; i < nCellsPhi/2; i++)
310 for(Int_t j = 0; j < nCellsEta/2; j++)
313 //Loop over all TRUS in a supermodule
314 for(Int_t itru = 0 + isupermod * nTRU ; itru < (isupermod+1)*nTRU ; itru++) {
315 TMatrixD * amptru = dynamic_cast<TMatrixD *>(amptrus->At(itru)) ;
316 TMatrixD * timeRtru = dynamic_cast<TMatrixD *>(timeRtrus->At(itru)) ;
317 Int_t mtru = itru-isupermod*nTRU ; //Number of TRU in Supermodule
319 //Sliding 2x2, add 2x2 amplitudes (NOT OVERLAP)
320 for(Int_t irow = 0 ; irow < nCellsPhi; irow += 2){
321 for(Int_t icol = 0 ; icol < nCellsEta ; icol += 2){
322 amp2 = (*amptru)(irow,icol)+(*amptru)(irow+1,icol)+
323 (*amptru)(irow,icol+1)+(*amptru)(irow+1,icol+1);
325 //Fill matrix with added 2x2 cells for use in nxn sums
326 tru2x2(irow/2,icol/2) = amp2 ;
327 //Select 2x2 maximum sums to select L0
328 if(amp2 > ampmax2(0,mtru)){
329 ampmax2(0,mtru) = amp2 ;
330 ampmax2(1,mtru) = irow;
331 ampmax2(2,mtru) = icol;
336 //Find most recent time in the selected 2x2 cell
337 ampmax2(3,mtru) = 1 ;
338 Int_t row2 = static_cast <Int_t> (ampmax2(1,mtru));
339 Int_t col2 = static_cast <Int_t> (ampmax2(2,mtru));
340 for(Int_t i = 0; i<2; i++){
341 for(Int_t j = 0; j<2; j++){
342 if((*amptru)(row2+i,col2+j) > 0 && (*timeRtru)(row2+i,col2+j)> 0){
343 if((*timeRtru)(row2+i,col2+j) < ampmax2(3,mtru) )
344 ampmax2(3,mtru) = (*timeRtru)(row2+i,col2+j);
349 //Sliding nxn, add nxn amplitudes (OVERLAP)
351 for(Int_t irow = 0 ; irow < nCellsPhi/2; irow++){
352 for(Int_t icol = 0 ; icol < nCellsEta/2 ; icol++){
354 if( (irow+fPatchSize) < nCellsPhi/2 && (icol+fPatchSize) < nCellsEta/2){//Avoid exit the TRU
355 for(Int_t i = 0 ; i <= fPatchSize ; i++)
356 for(Int_t j = 0 ; j <= fPatchSize ; j++)
357 ampn += tru2x2(irow+i,icol+j);
358 //Select nxn maximum sums to select L1
359 if(ampn > ampmaxn(0,mtru)){
360 ampmaxn(0,mtru) = ampn ;
361 ampmaxn(1,mtru) = irow*2;
362 ampmaxn(2,mtru) = icol*2;
368 //Find most recent time in selected nxn cell
369 ampmaxn(3,mtru) = 1 ;
370 Int_t rown = static_cast <Int_t> (ampmaxn(1,mtru));
371 Int_t coln = static_cast <Int_t> (ampmaxn(2,mtru));
372 for(Int_t i = 0; i<4*fPatchSize; i++){
373 for(Int_t j = 0; j<4*fPatchSize; j++){
374 if( (rown+i) < nCellsPhi && (coln+j) < nCellsEta){//Avoid exit the TRU
375 if((*amptru)(rown+i,coln+j) > 0 && (*timeRtru)(rown+i,coln+j)> 0){
376 if((*timeRtru)(rown+i,coln+j) < ampmaxn(3,mtru) )
377 ampmaxn(3,mtru) = (*timeRtru)(rown+i,coln+j);
384 ampmaxn(0,mtru) = ampmax2(0,mtru);
385 ampmaxn(1,mtru) = ampmax2(1,mtru);
386 ampmaxn(2,mtru) = ampmax2(2,mtru);
387 ampmaxn(3,mtru) = ampmax2(3,mtru);
392 //____________________________________________________________________________
393 void AliEMCALTrigger::MakeSlidingTowers(const TClonesArray * amptrus, const TClonesArray * timeRtrus,
394 const Int_t isupermod,TMatrixD &max2, TMatrixD &maxn){
396 // Output from module (2x2 cells from one module)
397 Int_t nModulesPhi = fGeom->GetNModulesInTRUPhi(); // now 4 modules (3 div in phi)
399 nModulesPhi = nModulesPhi / 2 ; // Half size SM. Not Final.
401 Int_t nModulesEta = fGeom->GetNModulesInTRUEta(); // now 24 modules (no division in eta)
402 Int_t nTRU = fGeom->GetNTRU();
403 static int keyPrint = 0;
404 if(keyPrint) AliDebug(2,Form("MakeSlidingTowers : nTRU %i nModulesPhi %i nModulesEta %i ",
405 nTRU, nModulesPhi, nModulesEta ));
409 for(Int_t i = 0; i < 4; i++){
410 for(Int_t j = 0; j < nTRU; j++){
411 ampmax2(i,j) = ampmaxn(i,j) = -1;
415 // Create matrix that will contain 2x2 amplitude sums
416 // used to calculate the nxn sums
417 TMatrixD tru2x2(nModulesPhi/2,nModulesEta/2);
419 // Loop over all TRUS in a supermodule
420 for(Int_t itru = 0 + isupermod * nTRU ; itru < (isupermod+1)*nTRU ; itru++) {
421 TMatrixD * amptru = dynamic_cast<TMatrixD *>(amptrus->At(itru)) ;
422 TMatrixD * timeRtru = dynamic_cast<TMatrixD *>(timeRtrus->At(itru)) ;
423 Int_t mtru = itru - isupermod*nTRU ; // Number of TRU in Supermodule !!
425 if(!amptru || !timeRtru){
426 AliError("Amplitude or Time TRU matrix not available");
430 // Sliding 2x2, add 2x2 amplitudes (NOT OVERLAP)
431 for(Int_t irow = 0 ; irow < nModulesPhi; irow +=2){
432 for(Int_t icol = 0 ; icol < nModulesEta ; icol +=2){
433 amp2 = (*amptru)(irow,icol) +(*amptru)(irow+1,icol)+
434 (*amptru)(irow,icol+1)+(*amptru)(irow+1,icol+1);
436 //Fill matrix with added 2x2 towers for use in nxn sums
437 tru2x2(irow/2,icol/2) = amp2 ;
438 //Select 2x2 maximum sums to select L0
439 if(amp2 > ampmax2(0,mtru)){
440 ampmax2(0,mtru) = amp2 ;
441 ampmax2(1,mtru) = irow;
442 ampmax2(2,mtru) = icol;
447 ampmax2(3,mtru) = 0.;
449 // Find most recent time in the selected 2x2 towers
450 Int_t row2 = static_cast <Int_t> (ampmax2(1,mtru));
451 Int_t col2 = static_cast <Int_t> (ampmax2(2,mtru));
452 for(Int_t i = 0; i<2; i++){
453 for(Int_t j = 0; j<2; j++){
454 if((*amptru)(row2+i,col2+j) > 0 && (*timeRtru)(row2+i,col2+j)> 0){
455 if((*timeRtru)(row2+i,col2+j) > ampmax2(3,mtru) )
456 ampmax2(3,mtru) = (*timeRtru)(row2+i,col2+j); // max time
462 //Sliding nxn, add nxn amplitudes (OVERLAP)
464 for(Int_t irow = 0 ; irow < nModulesPhi/2; irow++){
465 for(Int_t icol = 0 ; icol < nModulesEta/2; icol++){
467 if( (irow+fPatchSize) < nModulesPhi/2 && (icol+fPatchSize) < nModulesEta/2){ //Avoid exit the TRU
468 for(Int_t i = 0 ; i <= fPatchSize ; i++)
469 for(Int_t j = 0 ; j <= fPatchSize ; j++)
470 ampn += tru2x2(irow+i,icol+j);
471 //Select nxn maximum sums to select L1
472 if(ampn > ampmaxn(0,mtru)){
473 ampmaxn(0,mtru) = ampn ;
474 ampmaxn(1,mtru) = irow;
475 ampmaxn(2,mtru) = icol;
481 ampmaxn(3,mtru) = 0.; // Was 1 , I don't know why
483 //Find most recent time in selected nxn cell
484 Int_t rown = static_cast <Int_t> (ampmaxn(1,mtru));
485 Int_t coln = static_cast <Int_t> (ampmaxn(2,mtru));
486 for(Int_t i = 0; i<4*fPatchSize; i++){
487 for(Int_t j = 0; j<4*fPatchSize; j++){
488 if( (rown+i) < nModulesPhi && (coln+j) < nModulesEta){//Avoid exit the TRU
489 if((*amptru)(rown+i,coln+j) > 0 && (*timeRtru)(rown+i,coln+j)> 0){
490 if((*timeRtru)(rown+i,coln+j) > ampmaxn(3,mtru) )
491 ampmaxn(3,mtru) = (*timeRtru)(rown+i,coln+j); // max time
497 } else { // copy 2x2 to nxn
498 ampmaxn(0,mtru) = ampmax2(0,mtru);
499 ampmaxn(1,mtru) = ampmax2(1,mtru);
500 ampmaxn(2,mtru) = ampmax2(2,mtru);
501 ampmaxn(3,mtru) = ampmax2(3,mtru);
504 if(keyPrint) AliDebug(2,Form(" : MakeSlidingTowers -OUt \n"));
507 //____________________________________________________________________________
508 void AliEMCALTrigger::Print(const Option_t * opt) const
511 //Prints main parameters
515 AliTriggerInput* in = 0x0 ;
516 AliInfo(Form(" fSimulation %i (input option) : #digits %i\n", fSimulation, fDigitsList->GetEntries()));
517 AliInfo(Form(" fTimeKey %i \n ", fTimeKey));
519 AliInfo(Form("\t Maximum Amplitude after Sliding Cell, \n")) ;
520 AliInfo(Form("\t -2x2 cells sum (not overlapped): %10.2f, in Super Module %d\n",
521 f2x2MaxAmp,f2x2SM)) ;
522 AliInfo(Form("\t -2x2 from row %d to row %d and from column %d to column %d\n", f2x2ModulePhi, f2x2ModulePhi+2, f2x2ModuleEta, f2x2ModuleEta+2));
523 AliInfo(Form("\t -2x2 Isolation Patch %d x %d, Amplitude out of 2x2 patch is %f, threshold %f, Isolated? %d \n", 2*fIsolPatchSize+2, 2*fIsolPatchSize+2, f2x2AmpOutOfPatch, f2x2AmpOutOfPatchThres,static_cast<Int_t> (fIs2x2Isol)));
525 AliInfo(Form("\t Patch Size, n x n: %d x %d cells\n",2*(fPatchSize+1), 2*(fPatchSize+1)));
526 AliInfo(Form("\t -nxn cells sum (overlapped) : %10.2f, in Super Module %d\n", fnxnMaxAmp,fnxnSM));
527 AliInfo(Form("\t -nxn from row %d to row %d and from column %d to column %d\n", fnxnModulePhi, fnxnModulePhi+4*fPatchSize, fnxnModuleEta, fnxnModuleEta+4*fPatchSize)) ;
528 AliInfo(Form("\t -nxn Isolation Patch %d x %d, Amplitude out of nxn patch is %f, threshold %f, Isolated? %d \n", 4*fIsolPatchSize+2*(fPatchSize+1),4*fIsolPatchSize+2*(fPatchSize+1) , fnxnAmpOutOfPatch, fnxnAmpOutOfPatchThres,static_cast<Int_t> (fIsnxnIsol) ));
531 AliInfo(Form("\t Isolate in SuperModule? %d\n", fIsolateInSuperModule)) ;
532 AliInfo(Form("\t Threshold for LO %10.2f\n", fL0Threshold));
534 in = (AliTriggerInput*)fInputs.FindObject( "EMCAL_L0" );
536 AliInfo(Form("\t *** EMCAL LO is set ***\n"));
538 AliInfo(Form("\t Gamma Low Pt Threshold for L1 %10.2f\n", fL1GammaLowPtThreshold));
539 in = (AliTriggerInput*)fInputs.FindObject( "EMCAL_GammaLPt_L1" );
541 AliInfo(Form("\t *** EMCAL Gamma Low Pt for L1 is set ***\n"));
543 AliInfo(Form("\t Gamma Medium Pt Threshold for L1 %10.2f\n", fL1GammaMediumPtThreshold));
544 in = (AliTriggerInput*) fInputs.FindObject( "EMCAL_GammaMPt_L1" );
546 AliInfo(Form("\t *** EMCAL Gamma Medium Pt for L1 is set ***\n"));
548 AliInfo(Form("\t Gamma High Pt Threshold for L1 %10.2f\n", fL1GammaHighPtThreshold));
549 in = (AliTriggerInput*) fInputs.FindObject( "EMCAL_GammaHPt_L1" );
551 AliInfo(Form("\t *** EMCAL Gamma High Pt for L1 is set ***\n")) ;
555 //____________________________________________________________________________
556 void AliEMCALTrigger::SetTriggers(const TClonesArray * ampmatrix,const Int_t iSM,
557 const TMatrixD &max2,
558 const TMatrixD &maxn)
560 //Checks the 2x2 and nxn maximum amplitude per each TRU and
561 //compares with the different L0 and L1 triggers thresholds
562 Float_t max2[] = {-1,-1,-1,-1} ;
563 Float_t maxn[] = {-1,-1,-1,-1} ;
567 Int_t nTRU = fGeom->GetNTRU();
569 //Find maximum summed amplitude of all the TRU
571 for(Int_t i = 0 ; i < nTRU ; i++){
572 if(max2[0] < ampmax2(0,i) ){
573 max2[0] = ampmax2(0,i) ; // 2x2 summed max amplitude
574 max2[1] = ampmax2(1,i) ; // corresponding phi position in TRU
575 max2[2] = ampmax2(2,i) ; // corresponding eta position in TRU
576 max2[3] = ampmax2(3,i) ; // corresponding most recent time
579 if(maxn[0] < ampmaxn(0,i) ){
580 maxn[0] = ampmaxn(0,i) ; // nxn summed max amplitude
581 maxn[1] = ampmaxn(1,i) ; // corresponding phi position in TRU
582 maxn[2] = ampmaxn(2,i) ; // corresponding eta position in TRU
583 maxn[3] = ampmaxn(3,i) ; // corresponding most recent time
588 //--------Set max amplitude if larger than in other Super Modules------------
589 Float_t maxtimeR2 = -1 ;
590 Float_t maxtimeRn = -1 ;
591 static AliEMCALRawUtils rawUtil;
592 // Int_t nTimeBins = rawUtil.GetRawFormatTimeBins() ;
593 Int_t nTimeBins = TIMEBINS; //changed by PTH
595 //Set max of 2x2 amplitudes and select L0 trigger
596 if(max2[0] > f2x2MaxAmp ){
597 // if(max2[0] > 5) printf(" L0 : iSM %i: max2[0] %5.0f : max2[3] %5.0f (maxtimeR2) \n",
598 // iSM, max2[0], max2[3]);
599 f2x2MaxAmp = max2[0] ;
601 maxtimeR2 = max2[3] ;
602 fGeom->GetModulePhiEtaIndexInSModuleFromTRUIndex(mtru2,
603 static_cast<Int_t>(max2[1]),
604 static_cast<Int_t>(max2[2]),
605 f2x2ModulePhi,f2x2ModuleEta);
608 if(fIsolateInSuperModule)
609 fIs2x2Isol = IsPatchIsolated(0, ampmatrix, iSM, mtru2, f2x2MaxAmp, f2x2ModulePhi,f2x2ModuleEta) ;
611 fIs2x2Isol = IsPatchIsolated(0, ampmatrix, iSM, mtru2, f2x2MaxAmp, static_cast<Int_t>(max2[1]), static_cast<Int_t>(max2[2])) ;
614 //Transform digit amplitude in Raw Samples
615 if (fADCValuesLow2x2 == 0) {
616 fADCValuesLow2x2 = new Int_t[nTimeBins];
617 fADCValuesHigh2x2 = new Int_t[nTimeBins];
619 //printf(" maxtimeR2 %12.5e (1)\n", maxtimeR2);
620 // rawUtil.RawSampledResponse(maxtimeR2 * AliEMCALRawUtils::GetRawFormatTimeBin(),
621 // f2x2MaxAmp, fADCValuesHigh2x2, fADCValuesLow2x2) ;
623 // rawUtil.RawSampledResponse(maxtimeR2*TIMEBINMAX/TIMEBINS,
624 // f2x2MaxAmp, fADCValuesHigh2x2, fADCValuesLow2x2) ;
626 AliEMCALRawResponse::RawSampledResponse( maxtimeR2*TIMEBINMAX/TIMEBINS,
627 f2x2MaxAmp, fADCValuesHigh2x2, fADCValuesLow2x2) ;
629 // Set Trigger Inputs, compare ADC time bins until threshold is attained
631 for(Int_t i = 0 ; i < nTimeBins ; i++){
632 // printf(" fADCValuesHigh2x2[%i] %i : %i \n", i, fADCValuesHigh2x2[i], fADCValuesLow2x2[i]);
633 if(fADCValuesHigh2x2[i] >= fL0Threshold || fADCValuesLow2x2[i] >= fL0Threshold){
634 SetInput("EMCAL_L0") ;
639 // Nov 5 - no analysis of time information
640 if(f2x2MaxAmp >= fL0Threshold) { // should add the low amp too
641 SetInput("EMCAL_L0");
646 //------------Set max of nxn amplitudes and select L1 trigger---------
647 if(maxn[0] > fnxnMaxAmp ){
648 fnxnMaxAmp = maxn[0] ;
650 maxtimeRn = maxn[3] ;
651 fGeom->GetModulePhiEtaIndexInSModuleFromTRUIndex(mtrun,
652 static_cast<Int_t>(maxn[1]),
653 static_cast<Int_t>(maxn[2]),
654 fnxnModulePhi,fnxnModuleEta) ;
657 if(fIsolateInSuperModule)
658 fIsnxnIsol = IsPatchIsolated(1, ampmatrix, iSM, mtrun, fnxnMaxAmp, fnxnModulePhi, fnxnModuleEta) ;
660 fIsnxnIsol = IsPatchIsolated(1, ampmatrix, iSM, mtrun, fnxnMaxAmp, static_cast<Int_t>(maxn[1]), static_cast<Int_t>(maxn[2])) ;
663 //Transform digit amplitude in Raw Samples
664 if (fADCValuesLownxn == 0) {
665 fADCValuesHighnxn = new Int_t[nTimeBins];
666 fADCValuesLownxn = new Int_t[nTimeBins];
668 // rawUtil.RawSampledResponse(maxtimeRn * AliEMCALRawUtils::GetRawFormatTimeBin(),
669 // fnxnMaxAmp, fADCValuesHighnxn, fADCValuesLownxn) ;
671 //rawUtil.RawSampledResponse(maxtimeRn*TIMEBINMAX/TIMEBINS,
672 // fnxnMaxAmp, fADCValuesHighnxn, fADCValuesLownxn) ;
674 AliEMCALRawResponse::RawSampledResponse (maxtimeRn*TIMEBINMAX/TIMEBINS,
675 fnxnMaxAmp, fADCValuesHighnxn, fADCValuesLownxn) ;
677 //Set Trigger Inputs, compare ADC time bins until threshold is attained
679 for(Int_t i = 0 ; i < nTimeBins ; i++){
680 if(fADCValuesHighnxn[i] >= fL1GammaLowPtThreshold || fADCValuesLownxn[i] >= fL1GammaLowPtThreshold){
681 SetInput("EMCAL_GammaLPt_L1") ;
687 for(Int_t i = 0 ; i < nTimeBins ; i++){
688 if(fADCValuesHighnxn[i] >= fL1GammaMediumPtThreshold || fADCValuesLownxn[i] >= fL1GammaMediumPtThreshold){
689 SetInput("EMCAL_GammaMPt_L1") ;
695 for(Int_t i = 0 ; i < nTimeBins ; i++){
696 if(fADCValuesHighnxn[i] >= fL1GammaHighPtThreshold || fADCValuesLownxn[i] >= fL1GammaHighPtThreshold){
697 SetInput("EMCAL_GammaHPt_L1") ;
702 // Nov 5 - no analysis of time information
703 if(fnxnMaxAmp >= fL1GammaLowPtThreshold) { // should add the low amp too
704 SetInput("EMCAL_GammaLPt_L1") ; //SetL1 Low
706 if(fnxnMaxAmp >= fL1GammaMediumPtThreshold) { // should add the low amp too
707 SetInput("EMCAL_GammaMPt_L1") ; //SetL1 Medium
709 if(fnxnMaxAmp >= fL1GammaHighPtThreshold) { // should add the low amp too
710 SetInput("EMCAL_GammaHPt_L1") ; //SetL1 High
716 //____________________________________________________________________________
717 void AliEMCALTrigger::FillTRU(const TClonesArray * digits, TClonesArray * ampmatrix, TClonesArray * ampmatrixsmod, TClonesArray * timeRmatrix) {
719 // Orders digits ampitudes list in fNTRU TRUs (384 cells) per supermodule.
720 // Each TRU is a TMatrixD, and they are kept in TClonesArrays. The number of
721 // TRU in phi is fNTRUPhi, and the number of TRU in eta is fNTRUEta.
722 // Last 2 modules are half size in Phi, I considered that the number of TRU
723 // is maintained for the last modules but decision not taken. If different,
724 // then this must be changed. Also fill a matrix with all amplitudes in supermodule for isolation studies.
726 // Initilize and declare variables
727 // List of TRU matrices initialized to 0.
728 // printf("<I> AliEMCALTrigger::FillTRU() started : # digits %i\n", digits->GetEntriesFast());
731 // One input per EMCAL module so size of matrix is reduced by 4 (2x2 division case)
733 Int_t nPhi = fGeom->GetNPhi();
734 Int_t nZ = fGeom->GetNZ();
735 Int_t nTRU = fGeom->GetNTRU();
736 // Int_t nTRUPhi = fGeom->GetNTRUPhi();
737 Int_t nModulesPhi = fGeom->GetNModulesInTRUPhi();
738 Int_t nModulesPhi2 = fGeom->GetNModulesInTRUPhi();
739 Int_t nModulesEta = fGeom->GetNModulesInTRUEta();
740 // printf("<I> AliEMCALTrigger::FillTRU() nTRU %i nTRUPhi %i : nModulesPhi %i nModulesEta %i \n",
741 // nTRU, nTRUPhi, nModulesPhi, nModulesEta);
752 // iphim, ietam - module indexes in SM
756 //List of TRU matrices initialized to 0.
757 Int_t nSup = fGeom->GetNumberOfSuperModules();
758 for(Int_t k = 0; k < nTRU*nSup; k++){
759 TMatrixD amptrus(nModulesPhi,nModulesEta) ;
760 TMatrixD timeRtrus(nModulesPhi,nModulesEta) ;
761 // Do we need to initialise? I think TMatrixD does it by itself...
762 for(Int_t i = 0; i < nModulesPhi; i++){
763 for(Int_t j = 0; j < nModulesEta; j++){
765 timeRtrus(i,j) = 0.0;
768 new((*ampmatrix)[k]) TMatrixD(amptrus) ;
769 new((*timeRmatrix)[k]) TMatrixD(timeRtrus) ;
772 // List of Modules matrices initialized to 0.
773 for(Int_t k = 0; k < nSup ; k++){
775 // if(nSup>9) mphi = nPhi/2; // the same size
776 TMatrixD ampsmods( mphi, nZ);
777 for(Int_t i = 0; i < mphi; i++){
778 for(Int_t j = 0; j < nZ; j++){
782 new((*ampmatrixsmod)[k]) TMatrixD(ampsmods) ;
785 AliEMCALDigit * dig ;
787 //Digits loop to fill TRU matrices with amplitudes.
788 for(Int_t idig = 0 ; idig < digits->GetEntriesFast() ; idig++){
790 dig = dynamic_cast<AliEMCALDigit *>(digits->At(idig)) ;
792 amp = Float_t(dig->GetAmplitude()); // Energy of the digit (arbitrary units)
793 id = dig->GetId() ; // Id label of the cell
794 timeR = dig->GetTimeR() ; // Earliest time of the digit
795 if(amp<=0.0) AliDebug(1,Form(" id %i amp %f \n", id, amp));
796 // printf(" FILLTRU : timeR %10.5e time %10.5e : amp %10.5e \n", timeR, dig->GetTime(), amp);
797 // Get eta and phi cell position in supermodule
798 Bool_t bCell = fGeom->GetCellIndex(id, iSupMod, nModule, nIphi, nIeta) ;
800 AliError(Form("%i Wrong cell id number %i ", idig, id)) ;
802 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
803 // iphim, ietam - module indexes in SM
804 fGeom->GetModuleIndexesFromCellIndexesInSModule(iSupMod,iphi,ieta, iphim, ietam, nModule);
806 //printf("iSupMod %i nModule %i iphi %i ieta %i iphim %i ietam %i \n",
807 //iSupMod,nModule, iphi, ieta, iphim, ietam);
809 // Check to which TRU in the supermodule belongs the cell.
810 // Supermodules are divided in a TRU matrix of dimension
811 // (fNTRUPhi,fNTRUEta).
812 // Each TRU is a cell matrix of dimension (nModulesPhi,nModulesEta)
814 // First calculate the row and column in the supermodule
815 // of the TRU to which the cell belongs.
816 Int_t row = iphim / nModulesPhi;
817 Int_t col = ietam / nModulesEta;
818 //Calculate label number of the TRU
819 Int_t itru = fGeom->GetAbsTRUNumberFromNumberInSm(row, col, iSupMod);
821 //Fill TRU matrix with cell values
822 TMatrixD * amptrus = dynamic_cast<TMatrixD *>(ampmatrix->At(itru)) ;
823 TMatrixD * timeRtrus = dynamic_cast<TMatrixD *>(timeRmatrix->At(itru)) ;
825 if(!amptrus || !timeRtrus){
826 AliError("Could not recover the TRU matrix with amplitudes or times");
829 //Calculate row and column of the module inside the TRU with number itru
830 Int_t irow = iphim - row * nModulesPhi;
832 irow = iphim - row * nModulesPhi2; // size of matrix the same
833 Int_t icol = ietam - col * nModulesEta;
835 (*amptrus)(irow,icol) += amp ;
836 if((*timeRtrus)(irow,icol) <0.0 || (*timeRtrus)(irow,icol) <= timeR){ // ??
837 (*timeRtrus)(irow,icol) = timeR ;
840 //printf(" ieta %i iphi %i iSM %i || col %i row %i : itru %i -> amp %f\n",
841 // ieta, iphi, iSupMod, col, row, itru, amp);
842 //####################SUPERMODULE MATRIX ##################
843 TMatrixD * ampsmods = dynamic_cast<TMatrixD *>(ampmatrixsmod->At(iSupMod)) ;
845 AliError("Could not recover the matrix per SM");
848 (*ampsmods)(iphim,ietam) += amp ;
849 // printf(" id %i iphim %i ietam %i SM %i : irow %i icol %i itru %i : amp %6.0f\n",
850 //id, iphim, ietam, iSupMod, irow, icol, itru, amp);
852 else AliError("Could not recover the digit");
855 //printf("<I> AliEMCALTrigger::FillTRU() is ended \n");
858 //____________________________________________________________________________
859 void AliEMCALTrigger::Trigger()
861 //Main Method to select triggers.
862 TH1::AddDirectory(0);
864 AliRunLoader *runLoader = AliRunLoader::Instance();
865 AliEMCALLoader *emcalLoader = 0;
867 emcalLoader = dynamic_cast<AliEMCALLoader*>(runLoader->GetDetectorLoader("EMCAL"));
870 //Load EMCAL Geometry
871 if (runLoader && runLoader->GetAliRun()){
872 AliEMCAL* emcal = dynamic_cast<AliEMCAL*>(runLoader->GetAliRun()->GetDetector("EMCAL"));
873 if(emcal)fGeom = emcal->GetGeometry();
877 fGeom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
880 AliFatal("Did not get geometry from EMCALLoader");
883 Int_t nSuperModules = fGeom->GetNumberOfSuperModules() ; //12 SM in EMCAL
884 Int_t nTRU = fGeom->GetNTRU(); // 3 TRU per super module
886 //Intialize data members each time the trigger is called in event loop
887 f2x2MaxAmp = -1; f2x2ModulePhi = -1; f2x2ModuleEta = -1;
888 fnxnMaxAmp = -1; fnxnModulePhi = -1; fnxnModuleEta = -1;
890 // Take the digits list if simulation
891 if(fSimulation && runLoader && emcalLoader){ // works than run seperate macros
892 runLoader->LoadDigits("EMCAL");
893 fDigitsList = emcalLoader->Digits() ;
894 runLoader->LoadSDigits("EMCAL");
896 // Digits list should be set by method SetDigitsList(TClonesArray * digits)
898 AliFatal("Digits not found !") ;
900 //Take the digits list
902 // Delete old if unzero
903 if(fAmpTrus) {fAmpTrus->Delete(); delete fAmpTrus;}
904 if(fTimeRtrus) {fTimeRtrus->Delete(); delete fTimeRtrus;}
905 if(fAmpSMods) {fAmpSMods->Delete(); delete fAmpSMods;}
906 // Fill TRU and SM matrix
907 fAmpTrus = new TClonesArray("TMatrixD",nTRU);
908 fAmpTrus->SetName("AmpTrus");
909 fTimeRtrus = new TClonesArray("TMatrixD",nTRU);
910 fTimeRtrus->SetName("TimeRtrus");
911 fAmpSMods = new TClonesArray("TMatrixD",nSuperModules);
912 fAmpSMods->SetName("AmpSMods");
914 FillTRU(fDigitsList, fAmpTrus, fAmpSMods, fTimeRtrus);
916 // Jet stuff - only one case, no freedom here
917 if(fGeom->GetNEtaSubOfTRU() == 6) {
918 if(fAmpJetMatrix) {delete fAmpJetMatrix; fAmpJetMatrix=0;}
919 if(fJetMatrixE) {delete fJetMatrixE; fJetMatrixE=0;}
921 fAmpJetMatrix = new TMatrixD(17,12); // 17-phi(row), 12-eta(col)
922 fJetMatrixE = new TH2F("fJetMatrixE"," E of max patch in (#phi,#eta)",
923 17, 80.*TMath::DegToRad(), (180.+20.*2/3.)*TMath::DegToRad(), 12, -0.7, 0.7);
924 for(Int_t row=0; row<fAmpJetMatrix->GetNrows(); row++) {
925 for(Int_t col=0; col<fAmpJetMatrix->GetNcols(); col++) {
926 (*fAmpJetMatrix)(row,col) = 0.;
929 FillJetMatrixFromSMs(fAmpSMods, fAmpJetMatrix, fGeom);
931 if(!CheckConsistentOfMatrixes()) assert(0);
933 // Do Tower Sliding and select Trigger
934 // Initialize varible that will contain maximum amplitudes and
935 // its corresponding tower position in eta and phi, and time.
936 TMatrixD ampmax2(4,nTRU) ; // 0-max amp, 1-irow, 2-icol, 3-timeR
937 TMatrixD ampmaxn(4,nTRU) ;
939 for(Int_t iSM = 0 ; iSM < nSuperModules ; iSM++) {
940 //Do 2x2 and nxn sums, select maximums.
942 MakeSlidingTowers(fAmpTrus, fTimeRtrus, iSM, ampmax2, ampmaxn);
945 if(fIsolateInSuperModule) // here some discripency between tru and SM
946 SetTriggers(fAmpSMods,iSM,ampmax2,ampmaxn) ;
947 if(!fIsolateInSuperModule)
948 SetTriggers(fAmpTrus,iSM,ampmax2,ampmaxn) ;
951 // Do patch sliding and select Jet Trigger
952 // 0-max amp-meanFromVZERO(if), 1-irow, 2-icol, 3-timeR,
953 // 4-max amp , 5-meanFromVZERO (Nov 25, 2007)
955 MakeSlidingPatch((*fAmpJetMatrix), fNJetPatchPhi, fAmpJetMax); // no timing information here
961 //____________________________________________________________________________
962 void AliEMCALTrigger::GetTriggerInfo(TArrayF &triggerPosition, TArrayF &triggerAmplitudes) const
964 // Template - should be defined; Nov 5, 2007
965 triggerPosition[0] = 0.;
966 triggerAmplitudes[0] = 0.;
969 //____________________________________________________________________________
970 void AliEMCALTrigger::FillJetMatrixFromSMs(TClonesArray *ampmatrixsmod, TMatrixD* jetMat, AliEMCALGeometry *g)
973 // Fill matrix for jet trigger from SM matrixes of modules
975 static int keyPrint = 0;
977 if(ampmatrixsmod==0 || jetMat==0 || g==0) return;
978 Double_t amp = 0.0, ampSum=0.0;
980 Int_t nEtaModSum = g->GetNZ() / g->GetNEtaSubOfTRU(); // should be 4
981 Int_t nPhiModSum = g->GetNPhi() / g->GetNTRUPhi(); // should be 4
983 if(keyPrint) AliDebug(2,Form("%s",Form(" AliEMCALTrigger::FillJetMatrixFromSMs | nEtaModSum %i : nPhiModSum %i \n", nEtaModSum, nPhiModSum)));
984 Int_t jrow=0, jcol=0; // indexes of jet matrix
985 Int_t nEtaSM=0, nPhiSM=0;
986 for(Int_t iSM=0; iSM<ampmatrixsmod->GetEntries(); iSM++) {
987 TMatrixD * ampsmods = dynamic_cast<TMatrixD *>(ampmatrixsmod->At(iSM));
989 if(!ampsmods) return;
991 Int_t nrow = ampsmods->GetNrows();
992 Int_t ncol = ampsmods->GetNcols();
993 //printf("%s",Form(" ######## SM %i : nrow %i : ncol %i ##### \n", iSM, nrow, ncol));
994 for(Int_t row=0; row<nrow; row++) {
995 for(Int_t col=0; col<ncol; col++) {
996 amp = (*ampsmods)(row,col);
1000 if(keyPrint) AliDebug(2,Form("%s",Form(" ** nPhiSm %i : nEtaSM %i : row %2.2i : col %2.2i -> ", nPhiSM, nEtaSM, row, col)));
1001 if(nEtaSM == 0) { // positive Z
1002 jrow = 3*nPhiSM + row/nPhiModSum;
1003 jcol = 6 + col / nEtaModSum;
1004 } else { // negative Z
1005 if(iSM<=9) jrow = 3*nPhiSM + 2 - row/nPhiModSum;
1006 else jrow = 3*nPhiSM + 1 - row/nPhiModSum; // half size
1007 jcol = 5 - col / nEtaModSum;
1009 if(keyPrint) AliDebug(2,Form("%s",Form(" jrow %2.2i : jcol %2.2i : amp %f (jetMat) \n", jrow, jcol, amp)));
1011 (*jetMat)(jrow,jcol) += amp;
1012 ampSum += amp; // For controling
1013 } else if(amp<0.0) {
1014 AliDebug(1,Form(" jrow %2.2i : jcol %2.2i : amp %f (jetMat: amp<0) \n", jrow, jcol, amp));
1020 if(ampSum <= 0.0) AliDebug(1,Form("ampSum %f (<=0.0) ", ampSum));
1023 //____________________________________________________________________________
1024 void AliEMCALTrigger::MakeSlidingPatch(const TMatrixD &jm, const Int_t nPatchSize, TMatrixD &JetMax)
1026 // Sliding patch : nPatchSize x nPatchSize (OVERLAP)
1027 static int keyPrint = 0;
1028 if(keyPrint) AliDebug(2,Form(" AliEMCALTrigger::MakeSlidingPatch() was started \n"));
1029 Double_t ampCur = 0.0, e=0.0;
1030 ampJetMax(0,0) = 0.0;
1031 ampJetMax(3,0) = 0.0; // unused now
1032 ampJetMax(4,0) = ampJetMax(5,0) = 0.0;
1033 for(Int_t row=0; row<fAmpJetMatrix->GetNrows(); row ++) {
1034 for(Int_t col=0; col<fAmpJetMatrix->GetNcols(); col++) {
1036 // check on patch size
1037 if( (row+nPatchSize-1) < fAmpJetMatrix->GetNrows() && (col+nPatchSize-1) < fAmpJetMatrix->GetNcols()){
1038 for(Int_t i = 0 ; i < nPatchSize ; i++) {
1039 for(Int_t j = 0 ; j < nPatchSize ; j++) {
1040 ampCur += jm(row+i, col+j);
1042 } // end cycle on patch
1043 if(ampCur > ampJetMax(0,0)){
1044 ampJetMax(0,0) = ampCur;
1045 ampJetMax(1,0) = row;
1046 ampJetMax(2,0) = col;
1048 } // check on patch size
1051 if(keyPrint) AliDebug(2,Form(" ampJetMax %i row %2i->%2i col %2i->%2i \n", Int_t(ampJetMax(0,0)), Int_t(ampJetMax(1,0)), Int_t(ampJetMax(1,0))+nPatchSize-1, Int_t(ampJetMax(2,0)), Int_t(ampJetMax(2,0))+nPatchSize-1));
1053 Double_t eCorrJetMatrix=0.0;
1054 if(fVZER0Mult > 0.0) {
1055 // Correct patch energy (adc) and jet patch matrix energy
1056 Double_t meanAmpBG = GetMeanEmcalPatchEnergy(Int_t(fVZER0Mult), nPatchSize)/0.0153;
1057 ampJetMax(4,0) = ampJetMax(0,0);
1058 ampJetMax(5,0) = meanAmpBG;
1060 Double_t eCorr = ampJetMax(0,0) - meanAmpBG;
1061 AliDebug(2,Form(" ampJetMax(0,0) %f meanAmpBG %f eCorr %f : ampJetMax(4,0) %f \n",
1062 ampJetMax(0,0), meanAmpBG, eCorr, ampJetMax(5,0)));
1063 ampJetMax(0,0) = eCorr;
1065 eCorrJetMatrix = GetMeanEmcalEnergy(Int_t(fVZER0Mult)) / 208.;
1067 // Fill patch energy matrix
1068 for(int row=Int_t(ampJetMax(1,0)); row<Int_t(ampJetMax(1,0))+nPatchSize; row++) {
1069 for(int col=Int_t(ampJetMax(2,0)); col<Int_t(ampJetMax(2,0))+nPatchSize; col++) {
1070 e = Double_t(jm(row,col)*0.0153); // 0.0153 - hard coded now
1071 if(eCorrJetMatrix > 0.0) { // BG subtraction case
1072 e -= eCorrJetMatrix;
1073 fJetMatrixE->SetBinContent(row+1, col+1, e);
1074 } else if(e > 0.0) {
1075 fJetMatrixE->SetBinContent(row+1, col+1, e);
1079 // PrintJetMatrix();
1080 // Set the jet trigger(s), multiple threshold now, Nov 19,2007
1081 for(Int_t i=0; i<fNJetThreshold; i++ ) {
1082 if(ampJetMax(0,0) >= fL1JetThreshold[i]) {
1083 SetInput(GetNameOfJetTrigger(i));
1088 //____________________________________________________________________________
1089 Double_t AliEMCALTrigger::GetEmcalSumAmp() const
1091 // Return sum of amplidutes from EMCal
1092 // Used calibration coefficeint for transition to energy
1093 return fAmpJetMatrix >0 ?fAmpJetMatrix->Sum() :0.0;
1096 //____________________________________________________________________________
1097 void AliEMCALTrigger::PrintJetMatrix() const
1099 // fAmpJetMatrix : (17,12); // 17-phi(row), 12-eta(col)
1100 if(fAmpJetMatrix == 0) return;
1102 AliInfo(Form("\n #### jetMatrix : (%i,%i) ##### \n ",
1103 fAmpJetMatrix->GetNrows(), fAmpJetMatrix->GetNcols()));
1104 PrintMatrix(*fAmpJetMatrix);
1107 //____________________________________________________________________________
1108 void AliEMCALTrigger::PrintAmpTruMatrix(Int_t ind) const
1110 // Print matrix with TRU patches
1111 TMatrixD * tru = dynamic_cast<TMatrixD *>(fAmpTrus->At(ind));
1112 if(tru == 0) return;
1113 AliInfo(Form("\n #### Amp TRU matrix(%i) : (%i,%i) ##### \n ",
1114 ind, tru->GetNrows(), tru->GetNcols()));
1118 //____________________________________________________________________________
1119 void AliEMCALTrigger::PrintAmpSmMatrix(Int_t ind) const
1121 // Print matrix with SM amplitudes
1122 TMatrixD * sm = dynamic_cast<TMatrixD *>(fAmpSMods->At(ind));
1124 AliInfo(Form("\n #### Amp SM matrix(%i) : (%i,%i) ##### \n ",
1125 ind, sm->GetNrows(), sm->GetNcols()));
1129 //____________________________________________________________________________
1130 void AliEMCALTrigger::PrintMatrix(const TMatrixD &mat) const
1132 //Print matrix object
1133 for(Int_t col=0; col<mat.GetNcols(); col++) AliInfo(Form(" %3i ", col));
1134 AliInfo(Form("\n -- \n"));
1135 for(Int_t row=0; row<mat.GetNrows(); row++) {
1136 AliInfo(Form(" row:%2i ", row));
1137 for(Int_t col=0; col<mat.GetNcols(); col++) {
1138 AliInfo(Form(" %4i", (Int_t)mat(row,col)));
1144 //____________________________________________________________________________
1145 Bool_t AliEMCALTrigger::CheckConsistentOfMatrixes(const Int_t pri)
1147 // Check consitency of matrices
1148 Double_t sumSM = 0.0, smCur=0.0;
1149 Double_t sumTru=0.0, sumTruInSM = 0.0, truSum=0.0;
1150 // Bool_t key = kTRUE;
1152 for(Int_t i=0; i<fAmpSMods->GetEntries(); i++) {
1153 TMatrixD * sm = dynamic_cast<TMatrixD *>(fAmpSMods->At(i));
1159 for(Int_t itru=0; itru<3; itru++) { // Cycle on tru inside SM
1160 Int_t ind = 3*i + itru;
1161 TMatrixD *tru = dynamic_cast<TMatrixD *>(fAmpTrus->At(ind));
1163 truSum = tru->Sum();
1164 sumTruInSM += truSum;
1167 sumTru += sumTruInSM;
1169 if(sumTruInSM != smCur) {
1170 AliDebug(1,Form(" sm %i : smCur %f -> sumTruInSM %f \n", i, smCur, sumTruInSM));
1175 Double_t sumJetMat = fAmpJetMatrix->Sum();
1176 if(pri || TMath::Abs(sumSM-sumTru)>0.0001 || TMath::Abs(sumSM-sumJetMat) > 0.0001)
1177 AliDebug(1,Form(" sumSM %f : sumTru %f : sumJetMat %f \n", sumSM, sumTru, sumJetMat));
1178 if(TMath::Abs(sumSM - sumTru)>0.0001 || TMath::Abs(sumSM-sumJetMat) > 0.0001) return kFALSE;
1182 //____________________________________________________________________________
1183 void AliEMCALTrigger::Browse(TBrowser* b)
1186 if(&fInputs) b->Add(&fInputs);
1187 if(fAmpTrus) b->Add(fAmpTrus);
1188 if(fTimeRtrus) b->Add(fTimeRtrus);
1189 if(fAmpSMods) b->Add(fAmpSMods);
1190 if(fAmpJetMatrix) b->Add(fAmpJetMatrix);
1191 if(fJetMatrixE) b->Add(fJetMatrixE);