]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGGA/EMCALTasks/AliAnalysisTaskEMCALTriggerQA.cxx
changing hardcoded value for a parameter
[u/mrichter/AliRoot.git] / PWGGA / EMCALTasks / AliAnalysisTaskEMCALTriggerQA.cxx
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
16 //------------------------------------------------------------------------//
17 //  Fill histograms with basic QA information for EMCAL offline trigger   //
18 //  Author: Nicolas Arbor (LPSC-Grenoble), Rachid Guernane (LPSC-Grenoble)//
19 //          Gustavo Conesa Balbastre  (LPSC-Grenoble)                     //
20 //                                                                        //
21 //  $Id$ //
22 //------------------------------------------------------------------------//
23
24 #include <TList.h>
25 #include <TH2F.h>
26 #include <TF1.h>
27 #include <TProfile2D.h>
28 #include <TStreamerInfo.h>
29 #include <TFile.h>
30
31 #include "AliLog.h"
32 #include "AliVCluster.h"
33 #include "AliVCaloCells.h"
34 #include "AliVEvent.h"
35 #include "AliCentrality.h"
36
37 #include "AliVEvent.h"
38 #include "AliVCaloTrigger.h"
39 #include "AliESDVZERO.h"
40
41 #include "AliEMCALGeometry.h"
42 #include "AliEMCALRecoUtils.h"
43 #include "AliOADBContainer.h"
44 #include "AliAnalysisManager.h"
45
46 #include "AliAnalysisTaskEMCALTriggerQA.h"
47
48 ClassImp(AliAnalysisTaskEMCALTriggerQA)
49
50 //______________________________________________________________
51 AliAnalysisTaskEMCALTriggerQA::AliAnalysisTaskEMCALTriggerQA() :
52 AliAnalysisTaskSE(),
53 fOutputList(0),            fRecoUtils(0x0),
54 fGeoSet(0),                fGeometry(0),         fGeoName(""),
55 fOADBSet(kFALSE),          fAccessOADB(kTRUE),   fOADBFilePath(""),
56 fBitEGA(0),                fBitEJE(0),
57 fEtaPhiEnMin(3.),
58 fSTUTotal(0),              fTRUTotal(0),
59 fV0Trigger(0),             fV0A(0),              fV0C(0),
60 fFillV0SigHisto(1),        fFillClusAcceptHisto(0),
61 fMCData(kFALSE),
62 fEventMB   (0),            fEventL0   (0),
63 fEventL1G  (0),            fEventL1G2 (0),
64 fEventL1J  (0),            fEventL1J2 (0),
65 fEventCen  (0),            fEventSem  (0),
66 //Histograms
67 fhNEvents(0),              fhFORAmp(0),
68 fhFORAmpL1G(0),            fhFORAmpL1G2(0),
69 fhFORAmpL1J(0),            fhFORAmpL1J2(0),
70 fhL0Amp(0),                fhL0AmpL1G(0),        fhL0AmpL1J(0),
71 fhL1Amp(0),                fhL1GAmp(0),          fhL1G2Amp(0),
72 fhL1JAmp(0),               fhL1J2Amp(0),         fhL1FOREnergy(0),
73 fhL0Patch(0),              fhL1GPatch(0),        fhL1G2Patch(0),
74 fhL1GPatchNotFake(0),      fhL1GPatchFake(0),    fhL1GPatchNotAllFake(0),
75 fhL1GPatchAllFake(0),      fhL1GPatchNotAllFakeMax(0),
76 fhL1GPatchAllFakeMax(0),   fhL1GPatchNotAllFakeMaxE(0),
77 fhL1GPatchAllFakeMaxE(0),  fhL1GPatchNotAllFakeE(0),
78 fhL1GPatchAllFakeE(0),     fhL1GPatchFakeE(0),
79 fhL1GPatchNotFakeE(0),     fhNPatchFake(0),      fhNPatchNotFake(0),
80 fhL1JPatch(0),             fhL1J2Patch(0),
81 fhFEESTU(0),               fhTRUSTU(0),          fhV0STU(0),
82 fhGPMaxVV0TT(0),           fhJPMaxVV0TT(0),
83 fhFORMeanAmp(0),           fhL0MeanAmp(0),       fhL1MeanAmp(0),
84 fhL1GPatchMax(0),          fhL1G2PatchMax(0),
85 fhL1JPatchMax(0),          fhL1J2PatchMax(0),
86 //Histogram settings
87 fNBinsSTUSignal  (2000),   fMaxSTUSignal  (200000),
88 fNBinsTRUSignal  (2000),   fMaxTRUSignal  (200000),
89 fNBinsV0Signal   (5000),   fMaxV0Signal   (100000),
90 fNBinsSTUFEERatio(1000),   fMaxSTUFEERatio(100),
91 fNBinsSTUTRURatio(1000),   fMaxSTUTRURatio(100),
92 fNBinsClusterE   (500),    fMaxClusterE   (200),
93 fMapCell     (),
94 fMapCellL1G  (),           fMapCellL1G2 (),
95 fMapCellL1J  (),           fMapCellL1J2 (),
96 fMapTrigL0   (),           fMapTrigL1   (),
97 fMapTrigL0L1G(),           fMapTrigL0L1J(),
98 fMapTrigL1G  (),           fMapTrigL1G2 (),
99 fMapTrigL1J  (),           fMapTrigL1J2 ()
100 {
101   // Constructor
102         
103   InitHistogramArrays();
104   
105   DefineOutput(1, TList::Class());
106   
107 }
108
109 //______________________________________________________________________________
110 AliAnalysisTaskEMCALTriggerQA::AliAnalysisTaskEMCALTriggerQA(const char *name) :
111 AliAnalysisTaskSE(name),
112 fOutputList(0),            fRecoUtils(0x0),
113 fGeoSet(0),                fGeometry(0),         fGeoName(""),
114 fOADBSet(kFALSE),          fAccessOADB(kTRUE),   fOADBFilePath(""),
115 fBitEGA(0),                fBitEJE(0),
116 fEtaPhiEnMin(3.),
117 fSTUTotal(0),              fTRUTotal(0),
118 fV0Trigger(0),             fV0A(0),              fV0C(0),
119 fFillV0SigHisto(1),        fFillClusAcceptHisto(0),
120 fMCData(kFALSE),
121 fEventMB   (0),            fEventL0   (0),
122 fEventL1G  (0),            fEventL1G2 (0),
123 fEventL1J  (0),            fEventL1J2 (0),
124 fEventCen  (0),            fEventSem  (0),
125 //Histograms
126 fhNEvents(0),              fhFORAmp(0),
127 fhFORAmpL1G(0),            fhFORAmpL1G2(0),
128 fhFORAmpL1J(0),            fhFORAmpL1J2(0),
129 fhL0Amp(0),                fhL0AmpL1G(0),        fhL0AmpL1J(0),
130 fhL1Amp(0),                fhL1GAmp(0),          fhL1G2Amp(0),
131 fhL1JAmp(0),               fhL1J2Amp(0),         fhL1FOREnergy(0),
132 fhL0Patch(0),              fhL1GPatch(0),        fhL1G2Patch(0),
133 fhL1GPatchNotFake(0),      fhL1GPatchFake(0),    fhL1GPatchNotAllFake(0),
134 fhL1GPatchAllFake(0),      fhL1GPatchNotAllFakeMax(0),
135 fhL1GPatchAllFakeMax(0),   fhL1GPatchNotAllFakeMaxE(0),
136 fhL1GPatchAllFakeMaxE(0),  fhL1GPatchNotAllFakeE(0),
137 fhL1GPatchAllFakeE(0),     fhL1GPatchFakeE(0),
138 fhL1GPatchNotFakeE(0),     fhNPatchFake(0),      fhNPatchNotFake(0),
139 fhL1JPatch(0),             fhL1J2Patch(0),
140 fhFEESTU(0),               fhTRUSTU(0),          fhV0STU(0),
141 fhGPMaxVV0TT(0),           fhJPMaxVV0TT(0),
142 fhFORMeanAmp(0),           fhL0MeanAmp(0),       fhL1MeanAmp(0),
143 fhL1GPatchMax(0),          fhL1G2PatchMax(0),
144 fhL1JPatchMax(0),          fhL1J2PatchMax(0),
145 //Histogram settings
146 fNBinsSTUSignal  (2000),   fMaxSTUSignal  (200000),
147 fNBinsTRUSignal  (2000),   fMaxTRUSignal  (200000),
148 fNBinsV0Signal   (5000),   fMaxV0Signal   (100000),
149 fNBinsSTUFEERatio(1000),   fMaxSTUFEERatio(100),
150 fNBinsSTUTRURatio(1000),   fMaxSTUTRURatio(100),
151 fNBinsClusterE   (500),    fMaxClusterE   (200),
152 fMapCell     (),
153 fMapCellL1G  (),           fMapCellL1G2 (),
154 fMapCellL1J  (),           fMapCellL1J2 (),
155 fMapTrigL0   (),           fMapTrigL1   (),
156 fMapTrigL0L1G(),           fMapTrigL0L1J(),
157 fMapTrigL1G  (),           fMapTrigL1G2 (),
158 fMapTrigL1J  (),           fMapTrigL1J2 ()
159 {
160   // Constructor
161         
162   InitHistogramArrays();
163         
164   DefineOutput(1, TList::Class());
165   
166 }
167
168 //______________________________________________
169 void AliAnalysisTaskEMCALTriggerQA::AccessOADB()
170 {
171   // Set the AODB  bad channels at least once
172   
173   //Set it only once
174   if(fOADBSet) return ;
175   
176   if(fOADBFilePath == "") fOADBFilePath = "$ALICE_ROOT/OADB/EMCAL" ;
177   
178   Int_t   runnumber = InputEvent()->GetRunNumber() ;
179   
180   if(DebugLevel() > 0)
181     printf("AliAnalysisTaskEMCALClusterize::SetOADBParameters() - Get AODB parameters from EMCAL in %s for run %d\n",fOADBFilePath.Data(),runnumber);
182   
183   Int_t nSM = fGeometry->GetNumberOfSuperModules();
184   
185   // Bad map
186   if(fRecoUtils->IsBadChannelsRemovalSwitchedOn())
187   {
188     AliOADBContainer *contBC=new AliOADBContainer("");
189     contBC->InitFromFile(Form("%s/EMCALBadChannels.root",fOADBFilePath.Data()),"AliEMCALBadChannels");
190     
191     TObjArray *arrayBC=(TObjArray*)contBC->GetObject(runnumber);
192     
193     if(arrayBC)
194     {
195       if(DebugLevel() > 0)
196         printf("AliAnalysisTaskEMCALClusterize::SetOADBParameters() - Remove EMCAL bad cells \n");
197       
198       for (Int_t i=0; i<nSM; ++i)
199       {
200         TH2I *hbm = fRecoUtils->GetEMCALChannelStatusMap(i);
201         
202         if (hbm)
203           delete hbm;
204         
205         hbm=(TH2I*)arrayBC->FindObject(Form("EMCALBadChannelMap_Mod%d",i));
206         
207         if (!hbm)
208         {
209           AliError(Form("Can not get EMCALBadChannelMap_Mod%d",i));
210           continue;
211         }
212         
213         hbm->SetDirectory(0);
214         fRecoUtils->SetEMCALChannelStatusMap(i,hbm);
215         
216       } // loop
217     } else if(DebugLevel() > 0)
218       printf("AliAnalysisTaskEMCALClusterize::SetOADBParameters() - Do NOT remove EMCAL bad channels\n"); // run array
219   }  // Remove bad
220   
221   fOADBSet = kTRUE;
222   
223 }
224
225 //________________________________________________
226 void AliAnalysisTaskEMCALTriggerQA::FillCellMaps()
227 {
228   // Cells analysis
229   // Fill FEE energy per channel array
230   Int_t posX    = -1, posY = -1;
231   Int_t nSupMod = -1, ieta = -1, iphi = -1, nModule = -1, nIphi = -1, nIeta = -1;
232   Short_t absId = -1;
233   Int_t nCells  =  0;
234   
235   AliVCaloCells& cells= *(InputEvent()->GetEMCALCells());
236   
237   if(cells.IsEMCAL())
238   {
239     for (Int_t icell = 0; icell <  cells.GetNumberOfCells(); icell++)
240     {
241       nCells ++;
242       
243       Double_t amp =0., time = 0., efrac = 0;
244       Int_t mclabel = -1;
245       
246       cells.GetCell(icell, absId, amp, time,mclabel,efrac);
247       
248       fGeometry->GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
249       fGeometry->GetCellPhiEtaIndexInSModule(nSupMod, nModule, nIphi, nIeta, iphi, ieta);
250       
251       posX = (nSupMod % 2) ? ieta + AliEMCALGeoParams::fgkEMCALCols : ieta;
252       posY = iphi + AliEMCALGeoParams::fgkEMCALRows * int(nSupMod / 2);
253       
254       Int_t indexX = Int_t(posX/2);
255       Int_t indexY = Int_t(posY/2);
256       
257       if(indexX >= fgkFALTROCols || indexY >= fgkFALTRORows )
258       {
259         if(DebugLevel() > 0) printf("AliAnalysisTaskEMCALTriggerQA::UserExec() - Wrong Position (x,y) = (%d,%d)\n",
260                                     posX,posY);
261         continue;
262       }
263       
264       // here it is the amplitude for each cell
265       fMapCell[indexY][indexX] += amp;
266       
267       if(fEventL1G)
268       {
269         fMapCellL1G[indexY][indexX] += amp;
270         //printf("L1G cell[%i,%i] amp=%f\n",indexY,indexX,fMapCellL1G[indexY][indexX]);
271       }
272       
273       if(fEventL1G2)
274       {
275         fMapCellL1G2[indexY][indexX] += amp;
276         //printf("L1G2 cell[%i,%i] amp=%f\n",indexY,indexX,fMapCellL1G2[indexY][indexX]);
277       }
278                         
279       if(fEventL1J)  fMapCellL1J [indexY][indexX] += amp;
280       if(fEventL1J2) fMapCellL1J2[indexY][indexX] += amp;
281                         
282       //printf("cell[%i,%i] amp=%f\n",indexY,indexX,fMapCell[indexY][indexX]);
283                         
284     }
285   }
286
287 }
288
289 //______________________________________________________________________________
290 void AliAnalysisTaskEMCALTriggerQA::FillTriggerPatchMaps(TString triggerclasses)
291 {
292   // Trigger analysis, fill L0, L1 arrays
293   
294   AliVCaloTrigger& trg= * (InputEvent()->GetCaloTrigger("EMCAL"));
295   
296   fV0Trigger = trg.GetL1V0(0)+trg.GetL1V0(1); // used elsewhere
297
298   Int_t posX    = -1, posY = -1;
299
300   Int_t    nL0Patch = 0 ;
301   //Int_t    nL1Patch = 0 ;
302   fSTUTotal = 0;
303   fTRUTotal = 0;
304   
305   trg.Reset();
306   // loop on FASTOR
307          
308   while (trg.Next())
309   {
310     trg.GetPosition(posX,posY);
311     
312     if (posX > -1 && posY > -1)
313     {
314       //L0 analysis
315       Int_t nTimes = 0;
316       trg.GetNL0Times(nTimes);
317       Int_t l0Times[10];
318       trg.GetL0Times(l0Times);
319                         
320       Float_t ampL0 = 0.;
321       trg.GetAmplitude(ampL0);
322       if (ampL0 > 0) fMapTrigL0[posY][posX] = ampL0;
323                         
324       if(triggerclasses.Contains("CEMC7EGA-B-NOPF-CENTNOTRD") || triggerclasses.Contains("CPBI2EGA") || triggerclasses.Contains("CPBI2EG1")) fMapTrigL0L1G[posY][posX] += ampL0;
325       if(triggerclasses.Contains("CEMC7EJE-B-NOPF-CENTNOTRD") || triggerclasses.Contains("CPBI2EJE") || triggerclasses.Contains("CPBI2EJ1")) fMapTrigL0L1J[posY][posX] += ampL0;
326       fTRUTotal += ampL0;
327       
328       Int_t l0fired = 0;
329       for (Int_t itime = 0; itime < nTimes; itime++)
330       {
331         if (l0Times[itime] > 7 && l0Times[itime] < 10) l0fired = 1;
332       }
333                         
334       if (l0fired)
335       {
336         nL0Patch += nTimes;
337         fhL0Patch->Fill(posX,posY);
338       }
339                         
340       //L1 analysis
341       Int_t bit = 0;
342       trg.GetTriggerBits(bit);
343       
344       Int_t ts = 0;
345       trg.GetL1TimeSum(ts);
346       if (ts > 0) fMapTrigL1[posY][posX] = ts;
347       fSTUTotal += ts;
348       // cout << "ts =" <<ts<<endl;
349
350       //L1
351       Bool_t isEGA1 = ((bit >>  fBitEGA   ) & 0x1) && fEventL1G  ;
352       Bool_t isEGA2 = ((bit >> (fBitEGA+1)) & 0x1) && fEventL1G2 ;
353       Bool_t isEJE1 = ((bit >>  fBitEJE   ) & 0x1) && fEventL1J  ;
354       Bool_t isEJE2 = ((bit >> (fBitEJE+1)) & 0x1) && fEventL1J2 ;
355       
356       //if(isEGA1 || isEGA2 || isEJE1 || isEJE2) nL1Patch++;
357       //if(isEJE1 || isEJE2) printf("Jet STU patch %d, time sum %d, posX %d , posY %d\n",nL1Patch,ts,posX, posY);
358       
359       //   L1-Gamma
360       
361       if (isEGA1)
362       {
363         fhL1GPatch ->Fill(posX,posY);
364         if (ts > 0)  fMapTrigL1G [posY][posX] = ts;
365       }
366       
367       if (isEGA2)
368       {
369         fhL1G2Patch->Fill(posX,posY);
370         if (ts > 0) fMapTrigL1G2[posY][posX] = ts;
371       }
372       
373       //    L1-Jet
374       if (isEJE1)
375       {
376         fhL1JPatch ->Fill(posX,posY);
377         if (ts > 0) fMapTrigL1J [posY][posX] = ts;
378         
379       }
380       
381       if (isEJE2)
382       {
383         fhL1J2Patch->Fill(posX,posY);
384         if (ts > 0) fMapTrigL1J2[posY][posX] = ts;
385       }
386       
387     }
388   }
389  
390 //  // NOT SURE WHY THIS LINE, COMMENT IF NOT CLUSTER HISTO NOT FILLED FOR LHC13
391 //  if (!nL0Patch)
392 //  {
393 //    fEventL0 = kFALSE;
394 //    if (!triggerclasses.Contains("CPBI2")) fEventL1G = fEventL1G2 = fEventL1J = fEventL1J2 = kFALSE; // pp running
395 //  }
396          
397   if(fTRUTotal > fMaxTRUSignal && DebugLevel() > 0) printf("AliAnalysisTaskEMCALTriggerQA::FillTriggerPatchMaps() - Large fTRUTotal %f\n",fTRUTotal);
398   if(fSTUTotal > fMaxSTUSignal && DebugLevel() > 0) printf("AliAnalysisTaskEMCALTriggerQA::FillTriggerPatchMaps() - Large fSTUTotal %d\n",fSTUTotal);
399         
400 }
401
402 //___________________________________________________
403 void AliAnalysisTaskEMCALTriggerQA::ClusterAnalysis()
404 {
405   // Loop on clusters and fill corresponding histograms
406   
407   // Not interesting in case of data analysis, REVISE in future
408   if(fMCData) return ;
409   
410   // Init OADB
411   if(fAccessOADB) AccessOADB(); // only once
412   
413   //Get Vertex
414   Double_t v[3] = {0,0,0};
415   InputEvent()->GetPrimaryVertex()->GetXYZ(v);
416   
417   //clusters distribution
418   TRefArray* caloClus = new TRefArray();
419   InputEvent()->GetEMCALClusters(caloClus);
420   
421   Int_t nCaloClusters = caloClus->GetEntriesFast();
422   
423   Float_t emax   = 0;
424   Float_t etamax = 0;
425   Float_t phimax = 0;
426   Float_t ietamax=-1;
427   Float_t iphimax=-1;
428   
429   Float_t e      = 0;
430   Float_t eta    = 0;
431   Float_t phi    = 0;
432   
433   Int_t nSupMod = -1, ieta = -1, iphi = -1;
434
435   TLorentzVector mom;
436   
437   //Get vertex for momentum calculation
438   Double_t vertex[] = {0.0,0.0,0.0};
439   //InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
440   
441   Float_t centrality = -1;
442   if(InputEvent()->GetCentrality()) centrality = InputEvent()->GetCentrality()->GetCentralityPercentile("V0M");
443   
444   //if(!fEventMB) printf("MB : %d; L0 : %d; L1-Gam1 : %d; L1-Gam2 : %d; L1-Jet1 : %d; L1-Jet2 : %d; Central : %d; SemiCentral : %d \n",
445         //       fEventMB,fEventL0,fEventL1G,fEventL1G2,fEventL1J,fEventL1J2,fEventCen,fEventSem);
446   
447   for(Int_t icalo = 0; icalo < nCaloClusters; icalo++)
448   {
449     AliVCluster *clus = (AliVCluster*) (caloClus->At(icalo));
450     
451     if(!clus->IsEMCAL()) continue;
452     
453     if(!fRecoUtils->IsGoodCluster(clus,fGeometry,InputEvent()->GetEMCALCells(),InputEvent()->GetBunchCrossNumber()))
454       continue;
455     
456     if(clus->GetNCells() < 2) continue ; // Avoid 1 cell clusters, noisy, exotic.
457     
458     clus->GetMomentum(mom, vertex);
459     
460     Bool_t shared = kFALSE;
461     Int_t  idAbs  = -1, iphi0 = -1, ieta0 = -1;
462     fRecoUtils->GetMaxEnergyCell(fGeometry, InputEvent()->GetEMCALCells(),clus,
463                                  idAbs,nSupMod,ieta0,iphi0,shared);
464     //Change index to be continuous over SM
465     ieta = (nSupMod % 2) ? ieta0 + AliEMCALGeoParams::fgkEMCALCols : ieta0;
466     iphi = iphi0 + AliEMCALGeoParams::fgkEMCALRows * int(nSupMod / 2);
467     ieta/=2;
468     iphi/=2;
469     
470     if(ieta > fgkFALTROCols || iphi > fgkFALTRORows )
471       printf("AliAnalysisTaskEMCALTriggerQA::UserExec() - Wrong Position (x,y) = (%d,%d)\n",ieta,iphi);
472     
473     e   = clus->E();
474     eta = mom.Eta();
475     phi = mom.Phi();
476     
477     if(e > emax)
478     {
479       emax    = e;
480       etamax  = eta;
481       phimax  = phi;
482       ietamax = ieta;
483       iphimax = iphi;
484     }
485     
486     // Fill cluster histograms depending on the event trigger selection
487     if( fEventMB  ) FillClusterHistograms(kMBTrig         ,kFALSE,e,eta,phi,ieta,iphi,centrality,fV0A+fV0C);
488     if( fEventCen ) FillClusterHistograms(kCentralTrig    ,kFALSE,e,eta,phi,ieta,iphi,centrality,fV0A+fV0C);
489     if( fEventSem ) FillClusterHistograms(kSemiCentralTrig,kFALSE,e,eta,phi,ieta,iphi,centrality,fV0A+fV0C);
490     
491     if( fEventL0  ) FillClusterHistograms(kL0Trig         ,kFALSE,e,eta,phi,ieta,iphi,centrality,fV0A+fV0C);
492     if( fEventL1G ) FillClusterHistograms(kL1GammaTrig    ,kFALSE,e,eta,phi,ieta,iphi,centrality,fV0A+fV0C);
493     if( fEventL1G2) FillClusterHistograms(kL1GammaTrig2   ,kFALSE,e,eta,phi,ieta,iphi,centrality,fV0A+fV0C);
494     if( fEventL1J ) FillClusterHistograms(kL1JetTrig      ,kFALSE,e,eta,phi,ieta,iphi,centrality,fV0A+fV0C);
495     if( fEventL1J2) FillClusterHistograms(kL1JetTrig2     ,kFALSE,e,eta,phi,ieta,iphi,centrality,fV0A+fV0C);
496
497     if( fEventL1G2 && !fEventL1G) FillClusterHistograms(kL1Gamma2OnlyGammaTrig,kFALSE,e,eta,phi,ieta,iphi,centrality,fV0A+fV0C);
498     if( fEventL1J2 && !fEventL1J) FillClusterHistograms(kL1Jet2OnlyJetTrig    ,kFALSE,e,eta,phi,ieta,iphi,centrality,fV0A+fV0C);
499
500     if( fEventL1G && !fEventL1J )
501     FillClusterHistograms       (kL1GammaOnlyTrig,kFALSE,e,eta,phi,ieta,iphi,centrality,fV0A+fV0C);
502     if( fEventL1J && !fEventL1G )
503     FillClusterHistograms       (kL1JetOnlyTrig  ,kFALSE,e,eta,phi,ieta,iphi,centrality,fV0A+fV0C);
504     
505     if( fEventMB  && !fEventL1G && !fEventL1J && !fEventL0  ) fhClusMBPure[0]  ->Fill(e);
506     if( fEventCen && !fEventL1G && !fEventL1J && !fEventL0  ) fhClusMBPure[1]  ->Fill(e);
507     if( fEventSem && !fEventL1G && !fEventL1J && !fEventL0  ) fhClusMBPure[2]  ->Fill(e);
508     
509   }
510   
511   // Maximum energy cluster per event histograms
512   
513   if( fEventMB  ) FillClusterHistograms(kMBTrig         ,kTRUE,emax,etamax,phimax,ietamax,iphimax,centrality,fV0A+fV0C);
514   if( fEventCen ) FillClusterHistograms(kCentralTrig    ,kTRUE,emax,etamax,phimax,ietamax,iphimax,centrality,fV0A+fV0C);
515   if( fEventSem ) FillClusterHistograms(kSemiCentralTrig,kTRUE,emax,etamax,phimax,ietamax,iphimax,centrality,fV0A+fV0C);
516   
517   if( fEventL0  ) FillClusterHistograms(kL0Trig         ,kTRUE,emax,etamax,phimax,ietamax,iphimax,centrality,fV0A+fV0C);
518   if( fEventL1G ) FillClusterHistograms(kL1GammaTrig    ,kTRUE,emax,etamax,phimax,ietamax,iphimax,centrality,fV0A+fV0C);
519   if( fEventL1G2) FillClusterHistograms(kL1GammaTrig2   ,kTRUE,emax,etamax,phimax,ietamax,iphimax,centrality,fV0A+fV0C);
520   if( fEventL1J ) FillClusterHistograms(kL1JetTrig      ,kTRUE,emax,etamax,phimax,ietamax,iphimax,centrality,fV0A+fV0C);
521   if( fEventL1J2) FillClusterHistograms(kL1JetTrig2     ,kTRUE,emax,etamax,phimax,ietamax,iphimax,centrality,fV0A+fV0C);
522
523   if( fEventL1G2 && !fEventL1G) FillClusterHistograms(kL1Gamma2OnlyGammaTrig,kTRUE,emax,etamax,phimax,ietamax,iphimax,centrality,fV0A+fV0C);
524   if( fEventL1J2 && !fEventL1J) FillClusterHistograms(kL1Jet2OnlyJetTrig    ,kTRUE,emax,etamax,phimax,ietamax,iphimax,centrality,fV0A+fV0C);
525
526   if( fEventL1G && !fEventL1J )
527   FillClusterHistograms         (kL1GammaOnlyTrig,kTRUE,emax,etamax,phimax,ietamax,iphimax,centrality,fV0A+fV0C);
528   if( fEventL1J && !fEventL1G )
529   FillClusterHistograms         (kL1JetOnlyTrig  ,kTRUE,emax,etamax,phimax,ietamax,iphimax,centrality,fV0A+fV0C);
530   
531   if( fEventMB  && !fEventL1G && !fEventL1J && !fEventL0  ) fhClusMaxMBPure[0]  ->Fill(emax);
532   if( fEventCen && !fEventL1G && !fEventL1J && !fEventL0  ) fhClusMaxMBPure[1]  ->Fill(emax);
533   if( fEventSem && !fEventL1G && !fEventL1J && !fEventL0  ) fhClusMaxMBPure[2]  ->Fill(emax);
534
535 }
536
537 //______________________________________________________________________________________________
538 void AliAnalysisTaskEMCALTriggerQA::FillClusterHistograms(Int_t triggerNumber, Bool_t max,
539                                                           Float_t e,  Float_t eta, Float_t phi,
540                                                           Float_t ieta, Float_t iphi,
541                                                           Float_t centrality, Float_t fV0AC)
542 {
543   //Fill normal cluster related histograms depending on the trigger type selection
544   // (10 options, MB, L0, L1 Gamma ... defined in enum triggerType)
545         
546   if(!max)
547   {
548     fhClus   [triggerNumber]->Fill(e);
549     fhClusCen[triggerNumber]->Fill(e,centrality);
550     if(fFillV0SigHisto) fhClusV0 [triggerNumber]->Fill(e,fV0AC);
551     
552     if(!fFillClusAcceptHisto)
553     {
554       // just fill 2
555       if(e > fEtaPhiEnMin) fhClusEtaPhiHigh[triggerNumber]->Fill( eta, phi);
556       else                 fhClusEtaPhiLow [triggerNumber]->Fill( eta, phi);
557     }
558     else
559     {
560       fhClusEta[triggerNumber]->Fill(e,eta);
561       fhClusPhi[triggerNumber]->Fill(e,phi);
562       
563       if(e > fEtaPhiEnMin)
564       {
565         fhClusEtaPhiHigh       [triggerNumber]->Fill( eta, phi);
566         fhClusEtaPhiHighCellMax[triggerNumber]->Fill(ieta,iphi);
567       }
568       else
569       {
570         fhClusEtaPhiLow       [triggerNumber]->Fill( eta, phi);
571         fhClusEtaPhiLowCellMax[triggerNumber]->Fill(ieta,iphi);
572       }
573     }
574   }
575   else
576   {
577     fhClusMax   [triggerNumber]->Fill(e);
578     fhClusCenMax[triggerNumber]->Fill(e,centrality);
579     if(fFillV0SigHisto) fhClusV0Max [triggerNumber]->Fill(e,fV0AC);
580     
581     if(fFillClusAcceptHisto)
582     {
583       fhClusEtaMax[triggerNumber]->Fill(e,eta);
584       fhClusPhiMax[triggerNumber]->Fill(e,phi);
585       
586       if(e > fEtaPhiEnMin)
587       {
588         fhClusEtaPhiHighCluMax       [triggerNumber]->Fill( eta, phi);
589         fhClusEtaPhiHighCellMaxCluMax[triggerNumber]->Fill(ieta,iphi);
590       }
591       else
592       {
593         fhClusEtaPhiLowCluMax       [triggerNumber]->Fill( eta, phi);
594         fhClusEtaPhiLowCellMaxCluMax[triggerNumber]->Fill(ieta,iphi);
595       }
596     }
597   }
598 }
599
600 //_____________________________________________________________
601 void AliAnalysisTaskEMCALTriggerQA::FillCorrelationHistograms()
602 {
603   //FEE-TRU-STU correlation checks
604   
605   Double_t ampFOR[30] = {0.}, ampL0[30] = {0.}, ampL1[30] = {0.};
606   for (Int_t i = 0; i < fgkFALTRORows; i++)
607   {
608     for (Int_t j = 0; j < fgkFALTROCols; j++)
609     {
610       //method to get TRU number
611       Int_t idFOR = -1;
612       fGeometry->GetAbsFastORIndexFromPositionInEMCAL(j,i,idFOR);
613       Int_t iTRU  = -1;
614       Int_t iADC  = -1;
615       fGeometry->GetTRUFromAbsFastORIndex(idFOR,iTRU,iADC);
616       
617       //printf("i %d, j %d, iTRU %d, iADC %d, idFOR %d; cell %f, L0 %f, L1 %f\n",
618       //       i,j,iTRU,iADC,idFOR, fMapCell  [i][j],fMapTrigL0[i][j],fMapTrigL1[i][j]);
619       
620       if (iTRU >= 0)
621       {
622         ampFOR[iTRU] += fMapCell  [i][j];
623         ampL0[iTRU]  += fMapTrigL0[i][j];
624         ampL1[iTRU]  += fMapTrigL1[i][j];
625       }
626     }
627   }
628         
629   // FEE vs STU and TRU vs STU ratios
630   for (Int_t i = 0; i < 30; i++)
631   {
632     if (ampFOR[i] != 0 && ampL1[i] != 0)
633     {
634       fhFEESTU->Fill(ampL1[i]/ampFOR[i],i);
635       if(ampL1[i]/ampFOR[i] > fMaxSTUFEERatio  && DebugLevel() > 0 ) printf("AliAnalysisTaskEMCALTriggerQA::FillCorrelationHistograms() - Large STU/FEE ratio %f\n",ampL1[i]/ampFOR[i]);
636     }
637     
638     if (ampL0[i]  != 0 && ampL1[i] != 0)
639     {
640       fhTRUSTU->Fill(ampL1[i]/ampL0[i] ,i);
641       if(ampL1[i]/ampL0[i] > fMaxSTUTRURatio  && DebugLevel() > 0 ) printf("AliAnalysisTaskEMCALTriggerQA::FillCorrelationHistograms() - Large STU/TRU ratio %f\n",ampL1[i]/ampL0[i]);
642     }
643   }
644 }
645
646 //_____________________________________________________________
647 void AliAnalysisTaskEMCALTriggerQA::FillEventCounterHistogram()
648 {
649   // Fill a TH1 histogram, each bin corresponds to a even trigger type
650   
651   fhNEvents->Fill(0.5); // All physics events
652   
653   if( fEventMB )
654   {
655     fhNEvents->Fill(1.5);
656     if( !fEventL1G && !fEventL1J && !fEventL1G2 && !fEventL1J2 && !fEventL0 ) fhNEvents->Fill(12.5);
657   }
658   else
659   {
660     if( fEventL0  ) fhNEvents->Fill(13.5);
661     if( fEventL1G ) fhNEvents->Fill(14.5);
662     if( fEventL1J ) fhNEvents->Fill(15.5);
663   }
664         
665   if( fEventCen)   fhNEvents->Fill(2.5);
666   if( fEventSem)   fhNEvents->Fill(3.5);
667   
668   if( fEventL0 )
669   {
670     fhNEvents->Fill(4.5);
671   }
672   
673   if( fEventL1G )
674   {
675     fhNEvents->Fill(5.5);
676     if(!fEventL1J)  fhNEvents->Fill(9.5);
677     if(fEventCen || fEventSem) fhNEvents->Fill(16.5);
678   }
679         
680   if( fEventL1G2 )
681   {
682     fhNEvents->Fill(6.5);
683     if( !fEventL1G ) fhNEvents->Fill(18.5);
684     
685   }
686   
687   if( fEventL1J )
688   {
689     fhNEvents->Fill(7.5);
690     if(!fEventL1G)  fhNEvents->Fill(10.5);
691     if(fEventCen || fEventSem) fhNEvents->Fill(17.5);
692   }
693   
694   if( fEventL1J2 )
695   {
696     fhNEvents->Fill(8.5);
697     if( !fEventL1J ) fhNEvents->Fill(19.5);
698   }
699   
700   if(fEventL1J && fEventL1G) fhNEvents->Fill(11.5);
701   
702 }
703
704 //______________________________________________________________
705 void AliAnalysisTaskEMCALTriggerQA::FillL1GammaPatchHistograms()
706 {
707   // L1 Gamma
708   
709   // Study fakes  - Make it more understandable!!!
710   
711   Int_t    areAllFakes        = 2;
712   Int_t    numberpatchNotFake = 0;
713   Int_t    numberpatchFake    = 0;
714
715   Int_t    threshold = 10;// it's not GeV it's ADC !!
716   Bool_t   enoughE   = kFALSE;
717   Double_t patchMax  = 0;
718   Int_t    colMax    = -1;
719   Int_t    rowMax    = -1;
720   Int_t    shiftCol  = -1;
721   Int_t    shiftRow  = -1;
722   
723   // loop on patchs
724   for (Int_t posx = 0; posx < fgkFALTROCols; posx++)
725   {
726     for (Int_t posy = 0; posy < fgkFALTRORows; posy++)
727     {
728       Double_t patchEnergy = 0;
729       
730       if(fMapTrigL1G[posy][posx] > 0)
731       {
732         for(Int_t irow = 0; irow < 2; irow++)
733         {
734           for(Int_t icol = 0; icol < 2; icol++)
735           {
736             // loop on cells
737             shiftCol = posx+icol;
738             shiftRow = posy+irow;
739             
740             //      printf("cell[%i,%i]=%f\n",posy+icol,posx+irow, fMapCellL1G[posy+icol][posx+irow]);
741             if(shiftRow < fgkFALTRORows && shiftCol < fgkFALTROCols)
742             {
743               patchEnergy += fMapCellL1G[shiftRow][shiftCol] ;
744             
745               if( fMapCellL1G[shiftRow][shiftCol] > threshold/2 ) enoughE = kTRUE;
746             }
747           }
748         }
749         
750         if (patchEnergy > patchMax)
751         {
752           patchMax = patchEnergy;
753           colMax = posx;
754           rowMax = posy;
755         }
756         
757         if(patchEnergy>threshold || (patchEnergy>threshold-3 && enoughE))
758         {
759           numberpatchNotFake++;
760           fhL1GPatchNotFake ->Fill(posx,posy);
761           fhL1GPatchNotFakeE->Fill(patchEnergy);
762           areAllFakes = 1;
763         }
764         else
765         {
766           numberpatchFake++;
767           areAllFakes = 0;
768           fhL1GPatchFake ->Fill(posx,posy);
769           fhL1GPatchFakeE->Fill(patchEnergy);
770         }
771       }
772     }
773   }
774   
775   fhNPatchNotFake->Fill(areAllFakes,numberpatchNotFake);
776   fhNPatchFake   ->Fill(areAllFakes,numberpatchFake);
777   
778   if(areAllFakes == 0)
779   {
780     // loop on patchs
781     for (Int_t col = 0; col < fgkFALTROCols; col++)
782     {
783       for (Int_t row = 0; row < fgkFALTRORows; row++)
784       {
785         if(fMapTrigL1G[row][col] > 0)
786         {
787           //    cout <<"checking fMapTrigL1G[row][col]"<<fMapTrigL1G[row][col]<<endl;
788           fhL1GPatchAllFake->Fill(col,row);
789           
790           Double_t patchEnergy=0;
791           for(Int_t irow = 0; irow < 2; irow++)
792           {
793             for(Int_t icol = 0; icol < 2; icol++)
794             {
795               shiftCol = col+icol;
796               shiftRow = row+irow;
797               
798               if(shiftRow < fgkFALTRORows && shiftCol < fgkFALTROCols)
799                 patchEnergy += fMapCellL1G[shiftRow][shiftCol] ;
800
801             }
802           }
803           fhL1GPatchAllFakeE->Fill(patchEnergy);
804         }
805       }
806     }
807     //  cout << "row max"<<rowMax<<" colmax"<<colMax<< " fMapTrigL1G[rowMax][colMax]"<< fMapTrigL1G[rowMax][colMax]<<endl;
808     
809     if(fMapTrigL1G[rowMax][colMax] > 0)
810     {
811       //  printf("\npatch max [%i,%i] = %f\n",rowMax,colMax,patchMax);
812       fhL1GPatchAllFakeMax ->Fill(colMax,rowMax);
813       fhL1GPatchAllFakeMaxE->Fill(patchMax);
814     }
815   }
816   else
817   {
818     // loop on patches
819     for (Int_t col = 0; col < fgkFALTROCols; col++)
820     {
821       for (Int_t row = 0; row < fgkFALTRORows; row++)
822       {
823         if(fMapTrigL1G[row][col] > 0)
824         {
825           fhL1GPatchNotAllFake->Fill(col,row);
826           
827           Double_t patchEnergy = 0;
828           for(Int_t irow = 0; irow < 2; irow++)
829           {
830             for(Int_t icol = 0; icol < 2; icol++)
831             {
832               shiftCol = col+icol;
833               shiftRow = row+irow;
834               
835               if(shiftRow < fgkFALTRORows && shiftCol < fgkFALTROCols)
836                 patchEnergy += fMapCellL1G[shiftRow][shiftCol] ;
837             }
838           }
839           
840           fhL1GPatchNotAllFakeE->Fill(patchEnergy);
841           
842         }
843       }
844     }
845     
846     if(fMapTrigL1G[rowMax][colMax] > 0 )
847     {
848       fhL1GPatchNotAllFakeMax ->Fill(colMax,rowMax);
849       fhL1GPatchNotAllFakeMaxE->Fill(patchMax);
850     }
851   }
852   
853   fhGPMaxVV0TT->Fill(fV0Trigger, patchMax);
854   if( fEventL1G )  fhL1GPatchMax ->Fill(colMax,rowMax);
855   if( fEventL1G2 ) fhL1G2PatchMax->Fill(colMax,rowMax);
856   
857 }
858
859 //____________________________________________________________
860 void AliAnalysisTaskEMCALTriggerQA::FillL1JetPatchHistograms()
861 {
862   // L1 Jet
863   
864   Double_t patchMax =  0;
865   Int_t    colMax   = -1;
866   Int_t    rowMax   = -1;
867   Int_t    col, row =  0;
868   
869   for (Int_t i = 0; i < 9; i++)
870   {
871     for (Int_t j = 0; j < 12; j++)
872     {
873       Int_t patchJ = 0;
874       col = i;
875       row = j;
876       
877       for (Int_t k = 0; k < 16; k++)
878       {
879         for (Int_t l = 0; l < 16; l++)
880         {
881           patchJ += Int_t(fMapTrigL1[4*j + l][4*i + k]);
882         }
883       }
884       
885       if (patchJ > patchMax)
886       {
887         patchMax = patchJ;
888         colMax = 4*col;
889         rowMax = 4*row;
890       }
891     }
892   }
893   
894   fhJPMaxVV0TT->Fill(fV0Trigger, patchMax);
895   if( fEventL1J )  fhL1JPatchMax ->Fill(colMax,rowMax);
896   if( fEventL1J2 ) fhL1J2PatchMax->Fill(colMax,rowMax);
897   
898 }
899
900 //______________________________________________________
901 void AliAnalysisTaskEMCALTriggerQA::FillMapHistograms()
902 {
903   //Matrix with signal per channel
904   
905   for (Int_t i = 0; i < fgkFALTRORows; i++)
906   {
907     for (Int_t j = 0; j < fgkFALTROCols; j++) //check x,y direction for reading FOR ((0,0) = top left);
908     {
909       fhFORAmp    ->Fill( j, i, fMapCell     [i][j]);
910       fhFORAmpL1G ->Fill( j, i, fMapCellL1G  [i][j]);
911       fhFORAmpL1G2->Fill( j, i, fMapCellL1G2 [i][j]);
912       fhFORAmpL1J ->Fill( j, i, fMapCellL1J  [i][j]);
913       fhFORAmpL1J2->Fill( j, i, fMapCellL1J2 [i][j]);
914       fhL0Amp     ->Fill( j, i, fMapTrigL0   [i][j]);
915       fhL0AmpL1G  ->Fill( j, i, fMapTrigL0L1G[i][j]);
916       fhL0AmpL1J  ->Fill( j, i, fMapTrigL0L1J[i][j]);
917       fhL1Amp     ->Fill( j, i, fMapTrigL1   [i][j]);
918       
919       fhL1FOREnergy->Fill(i+fgkFALTRORows*j,  fMapTrigL1   [i][j]);
920       fhL1GAmp    ->Fill( j, i, fMapTrigL1G  [i][j]);
921       fhL1G2Amp   ->Fill( j, i, fMapTrigL1G2 [i][j]);
922       fhL1JAmp    ->Fill( j, i, fMapTrigL1J  [i][j]);
923       fhL1J2Amp   ->Fill( j, i, fMapTrigL1J2 [i][j]);
924       fhFORMeanAmp->Fill( j, i, fMapCell     [i][j]);
925       fhL0MeanAmp ->Fill( j, i, fMapTrigL0   [i][j]);
926       fhL1MeanAmp ->Fill( j, i, fMapTrigL1   [i][j]);
927     }
928   }
929 }
930
931 //____________________________________________________
932 void AliAnalysisTaskEMCALTriggerQA::FillV0Histograms()
933 {
934   //V0 analysis, only for ESDs
935   
936   
937   AliESDVZERO* eventV0 = dynamic_cast<AliESDVZERO*> (InputEvent()->GetVZEROData());
938   
939   if(eventV0)
940   {
941     for (Int_t i = 0; i < 32; i++)
942     {
943       fV0C += eventV0->GetAdcV0C(i);
944       fV0A += eventV0->GetAdcV0A(i);
945     }
946     
947     if (fSTUTotal != 0 && fFillV0SigHisto)
948     {
949       fhV0STU->Fill(fV0A+fV0C,fSTUTotal);
950       if( fV0A+fV0C > fMaxV0Signal && DebugLevel() > 0) printf("AliAnalysisTaskEMCALTriggerQA::UserExec() - Large fV0A+fV0C %f\n",fV0A+fV0C);
951     }
952     
953     // Not interesting in case of data analysis, REVISE in future
954     if(fMCData || !fFillV0SigHisto) return ;
955     
956     if( fEventL1G )  fhV0[kL1GammaTrig]    ->Fill(fV0A+fV0C);
957     if( fEventL1G2 ) fhV0[kL1GammaTrig2]   ->Fill(fV0A+fV0C);
958     if( fEventL1J )  fhV0[kL1JetTrig]      ->Fill(fV0A+fV0C);
959     if( fEventL1J2 ) fhV0[kL1JetTrig2]     ->Fill(fV0A+fV0C);
960     if( fEventMB  )  fhV0[kMBTrig]         ->Fill(fV0A+fV0C);
961     if( fEventL0  )  fhV0[kL0Trig]         ->Fill(fV0A+fV0C);
962     if( fEventCen )  fhV0[kCentralTrig]    ->Fill(fV0A+fV0C);
963     if( fEventSem )  fhV0[kSemiCentralTrig]->Fill(fV0A+fV0C);
964     if( fEventL1G  && !fEventL1J) fhV0[kL1GammaOnlyTrig]      ->Fill(fV0A+fV0C);
965     if( fEventL1J  && !fEventL1G) fhV0[kL1JetOnlyTrig]        ->Fill(fV0A+fV0C);
966     if( fEventL1G2 && !fEventL1G) fhV0[kL1Gamma2OnlyGammaTrig]->Fill(fV0A+fV0C);
967     if( fEventL1J2 && !fEventL1J) fhV0[kL1Jet2OnlyJetTrig]    ->Fill(fV0A+fV0C);
968     //if(nL0Patch!=0 || nL1Patch!=0) printf("total TRU %f, total STU %f, V0C+V0A %f; nL0 %d, nL1 %d \n",
969     //       fTRUTotal,fSTUTotal,fV0A+fV0C,nL0Patch,nL1Patch);
970   }
971 }
972
973 //________________________________________
974 void AliAnalysisTaskEMCALTriggerQA::Init()
975 {
976   //Init analysis parameters not set before
977         
978   if(!fRecoUtils)
979   {
980     fRecoUtils    = new AliEMCALRecoUtils ;
981     fRecoUtils->SwitchOnBadChannelsRemoval();
982   }
983   
984 }
985
986 //_____________________________________________________
987 void AliAnalysisTaskEMCALTriggerQA::InitCellPatchMaps()
988 {
989   //Init to 0 and per event different cell/patch maps, depending on trigger type
990
991   for (Int_t i = 0; i < fgkFALTRORows; i++)
992   {
993     for (Int_t j = 0; j < fgkFALTROCols; j++)
994     {
995       fMapTrigL0   [i][j] = 0.;
996       fMapTrigL0L1G[i][j] = 0.;
997       fMapTrigL0L1J[i][j] = 0.;
998       fMapTrigL1G  [i][j] = 0.;
999       fMapTrigL1G2 [i][j] = 0.;
1000       fMapTrigL1J  [i][j] = 0.;
1001       fMapTrigL1J2 [i][j] = 0.;
1002       fMapTrigL1   [i][j] = 0.;
1003       fMapCell     [i][j] = 0.;
1004       fMapCellL1G  [i][j] = 0.;
1005       fMapCellL1G2 [i][j] = 0.;
1006       fMapCellL1J  [i][j] = 0.;
1007       fMapCellL1J2 [i][j] = 0.;
1008     }
1009   }
1010 }
1011
1012 //________________________________________________
1013 void AliAnalysisTaskEMCALTriggerQA::InitGeometry()
1014 {
1015   // Init geometry and set the geometry matrix, for the first event, skip the rest
1016   // Also set once the run dependent calibrations
1017   
1018   if(fGeoSet) return;
1019   
1020   // Init the trigger bit once, correct depending on version
1021   fBitEGA = 4;
1022   fBitEJE = 5;
1023   
1024   TFile* file = AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile();
1025         
1026   const TList *clist = file->GetStreamerInfoCache();
1027  
1028   if(clist)
1029   {
1030     TStreamerInfo *cinfo = (TStreamerInfo*)clist->FindObject("AliESDCaloTrigger");
1031     Int_t verid = 5; // newer ESD header version
1032     if(!cinfo)
1033     {
1034       cinfo = (TStreamerInfo*)clist->FindObject("AliAODCaloTrigger");
1035       verid = 3; // newer AOD header version
1036     }
1037     if(cinfo)
1038     {
1039       Int_t classversionid = cinfo->GetClassVersion();
1040       //printf("********* Header class version %d *********** \n",classversionid);
1041       
1042       if (classversionid >= verid)
1043       {
1044         fBitEGA = 6;
1045         fBitEJE = 8;
1046       }
1047     }  else printf("AliAnalysisTaskEMCALTriggerQA - Streamer info for trigger class not available, bit not changed\n");
1048   } else printf("AliAnalysisTaskEMCALTriggerQA - Streamer list not available!, bit not changed\n");
1049   
1050   Int_t runnumber = InputEvent()->GetRunNumber() ;
1051   
1052   if (!fGeometry)
1053   {
1054     if(fGeoName=="")
1055     {
1056       if     (runnumber < 140000) fGeoName = "EMCAL_FIRSTYEARV1";
1057       else if(runnumber < 171000) fGeoName = "EMCAL_COMPLETEV1";
1058       else                        fGeoName = "EMCAL_COMPLETE12SMV1";
1059       if(DebugLevel() > 0)
1060         printf("AliAnalysisTaskEMCALTriggerQA::InitGeometry() - Set EMCAL geometry name to <%s> for run %d\n",fGeoName.Data(),runnumber);
1061     }
1062     
1063     fGeometry = AliEMCALGeometry::GetInstance(fGeoName);
1064   }
1065   
1066   fGeoSet = kTRUE;
1067         
1068 }
1069
1070 //_______________________________________________________
1071 void AliAnalysisTaskEMCALTriggerQA::InitHistogramArrays()
1072 {
1073   //Histograms array initialization
1074   
1075   for (Int_t i = 0; i < fgkTriggerCombi; i++)
1076   {
1077     fhV0     [i] = 0;
1078     fhClus   [i] = 0;              fhClusMax   [i] = 0;
1079     fhClusCen[i] = 0;              fhClusCenMax[i] = 0;
1080     fhClusV0 [i] = 0;              fhClusV0Max [i] = 0;
1081     fhClusEta[i] = 0;              fhClusEtaMax[i] = 0;
1082     fhClusPhi[i] = 0;              fhClusPhiMax[i] = 0;
1083     
1084     fhClusEtaPhiHigh       [i] = 0;  fhClusEtaPhiHighCluMax       [i] = 0;
1085     fhClusEtaPhiHighCellMax[i] = 0;  fhClusEtaPhiHighCellMaxCluMax[i] = 0;
1086     fhClusEtaPhiLow        [i] = 0;  fhClusEtaPhiLowCluMax        [i] = 0;
1087     fhClusEtaPhiLowCellMax [i] = 0;  fhClusEtaPhiLowCellMaxCluMax [i] = 0;
1088     
1089     if(i<3){ fhClusMBPure[i] = 0;   fhClusMaxMBPure[i] = 0; }
1090   }
1091 }
1092
1093 //_____________________________________________________________________________
1094 void AliAnalysisTaskEMCALTriggerQA::SetTriggerEventBit( TString triggerclasses)
1095 {
1096   // Check what trigger is the event, set the corresponding bit
1097   
1098   // Init trigger event bit
1099   fEventMB   = kFALSE;
1100   fEventL0   = kFALSE;
1101   fEventL1G  = kFALSE;
1102   fEventL1G2 = kFALSE;
1103   fEventL1J  = kFALSE;
1104   fEventL1J2 = kFALSE;
1105   fEventCen  = kFALSE;
1106   fEventSem  = kFALSE;
1107   
1108   //Min bias event trigger?
1109   if((triggerclasses.Contains("CINT") || triggerclasses.Contains("CPBI2_B1") ) &&
1110      (triggerclasses.Contains("-B-")  || triggerclasses.Contains("-I-"))       &&
1111                  triggerclasses.Contains("-NOPF-ALLNOTRD") )   fEventMB  = kTRUE;
1112   
1113   if(fMCData && triggerclasses.Contains("MB")) fEventMB = kTRUE;
1114   
1115   // EMC triggered event? Which type?
1116   if( triggerclasses.Contains("-B-") || triggerclasses.Contains("-S-") || triggerclasses.Contains("-I-") )
1117   {
1118     if( triggerclasses.Contains("CEMC") &&
1119        !triggerclasses.Contains("EGA" ) &&
1120        !triggerclasses.Contains("EJE" ) &&
1121        !triggerclasses.Contains("EG1" ) &&
1122        !triggerclasses.Contains("EJ1" ) &&
1123        !triggerclasses.Contains("EG2" ) &&
1124        !triggerclasses.Contains("EJ2" )    ) fEventL0  = kTRUE;
1125     
1126     if( triggerclasses.Contains("EGA" ) || triggerclasses.Contains("EG1" )   ) fEventL1G  = kTRUE;
1127     if( triggerclasses.Contains("EG2" ) )                                      fEventL1G2 = kTRUE;
1128     
1129     if( triggerclasses.Contains("EJE" ) || triggerclasses.Contains("EJ1" )   ) fEventL1J  = kTRUE;
1130     if( triggerclasses.Contains("EJ2" ) )                                      fEventL1J2 = kTRUE;
1131   }
1132   
1133   // Semi/Central PbPb trigger
1134   if     (triggerclasses.Contains("CCENT_R2-B-NOPF-ALLNOTRD")) fEventCen = kTRUE;
1135   else if(triggerclasses.Contains("CSEMI_R1-B-NOPF-ALLNOTRD")) fEventSem = kTRUE;
1136
1137   //printf("MB : %d; L0 : %d; L1-Gam1 : %d; L1-Gam2 : %d; L1-Jet1 : %d; L1-Jet2 : %d; Central : %d; SemiCentral : %d; Trigger Names : %s \n ",
1138         //       fEventMB,fEventL0,fEventL1G,fEventL1G2,fEventL1J,fEventL1J2,fEventCen,fEventSem,triggerclasses.Data());
1139   
1140 }
1141
1142 //___________________________________________________________
1143 void AliAnalysisTaskEMCALTriggerQA::UserCreateOutputObjects()
1144 {
1145   // Init histograms and geometry
1146   
1147   fOutputList  = new TList;
1148   fOutputList ->SetOwner(kTRUE);
1149   
1150   fhNEvents    = new TH1F("hNEvents","Number of selected events",20,0,20);
1151   fhNEvents   ->SetYTitle("N events");
1152   fhNEvents   ->GetXaxis()->SetBinLabel(1 ,"All");
1153   fhNEvents   ->GetXaxis()->SetBinLabel(2 ,"MB");
1154   fhNEvents   ->GetXaxis()->SetBinLabel(3 ,"Central Pb");
1155   fhNEvents   ->GetXaxis()->SetBinLabel(4 ,"SemiCentral Pb");
1156   fhNEvents   ->GetXaxis()->SetBinLabel(5 ,"L0");
1157   fhNEvents   ->GetXaxis()->SetBinLabel(6 ,"L1-G1");
1158   fhNEvents   ->GetXaxis()->SetBinLabel(7 ,"L1-G2");
1159   fhNEvents   ->GetXaxis()->SetBinLabel(8 ,"L1-J1");
1160   fhNEvents   ->GetXaxis()->SetBinLabel(9 ,"L1-J2");
1161   fhNEvents   ->GetXaxis()->SetBinLabel(10 ,"L1-G1 & !L1-J1");
1162   fhNEvents   ->GetXaxis()->SetBinLabel(11 ,"L1-J1 & !L1-G1");
1163   fhNEvents   ->GetXaxis()->SetBinLabel(12 ,"L1-J1 & L1-G1");
1164   fhNEvents   ->GetXaxis()->SetBinLabel(13 ,"MB & !L1 & !L0");
1165   fhNEvents   ->GetXaxis()->SetBinLabel(14,"L0 & !MB");
1166   fhNEvents   ->GetXaxis()->SetBinLabel(15,"L1-G1 & !MB");
1167   fhNEvents   ->GetXaxis()->SetBinLabel(16,"L1-J1 & !MB");
1168   fhNEvents   ->GetXaxis()->SetBinLabel(17,"L1-G1 & (Cen | Semi)");
1169   fhNEvents   ->GetXaxis()->SetBinLabel(18,"L1-J1 & (Cen | Semi)");
1170   fhNEvents   ->GetXaxis()->SetBinLabel(19,"L1-G2 & !L1-G1");
1171   fhNEvents   ->GetXaxis()->SetBinLabel(20,"L1-J2 & !L1-J1");
1172
1173   fhFORAmp     = new TH2F("hFORAmp", "FEE cells deposited energy, grouped like FastOR 2x2 per Row and Column",
1174                           fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1175   fhFORAmp    ->SetXTitle("Index #eta (columnns)");
1176   fhFORAmp    ->SetYTitle("Index #phi (rows)");
1177   fhFORAmp    ->SetZTitle("Amplitude");
1178   
1179   fhFORAmpL1G  = new TH2F("hFORAmpL1G1", "FEE cells deposited energy, grouped like FastOR 2x2 per Row and Column, with L1G1 trigger condition",
1180                           fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1181   fhFORAmpL1G ->SetXTitle("Index #eta (columnns)");
1182   fhFORAmpL1G ->SetYTitle("Index #phi (rows)");
1183   fhFORAmpL1G ->SetZTitle("Amplitude");
1184         
1185   fhFORAmpL1G2  = new TH2F("hFORAmpL1G2", "FEE cells deposited energy, grouped like FastOR 2x2 per Row and Column, with L1G2 trigger condition",
1186                            fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1187   fhFORAmpL1G2 ->SetXTitle("Index #eta (columnns)");
1188   fhFORAmpL1G2 ->SetYTitle("Index #phi (rows)");
1189   fhFORAmpL1G2 ->SetZTitle("Amplitude");
1190   
1191   fhFORAmpL1J  = new TH2F("hFORAmpL1J1", "FEE cells deposited energy, grouped like FastOR 2x2 per Row and Column, with L1J1 trigger condition",
1192                           fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1193   fhFORAmpL1J ->SetXTitle("Index #eta (columnns)");
1194   fhFORAmpL1J ->SetYTitle("Index #phi (rows)");
1195   fhFORAmpL1J ->SetZTitle("Amplitude");
1196         
1197   fhFORAmpL1J2  = new TH2F("hFORAmpL1J2", "FEE cells deposited energy, grouped like FastOR 2x2 per Row and Column, with L1J2 trigger condition",
1198                            fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1199   fhFORAmpL1J2 ->SetXTitle("Index #eta (columnns)");
1200   fhFORAmpL1J2 ->SetYTitle("Index #phi (rows)");
1201   fhFORAmpL1J2 ->SetZTitle("Amplitude");
1202   
1203   
1204   fhL0Amp      = new TH2F("hL0Amp","FALTRO signal per Row and Column",
1205                           fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1206   fhL0Amp     ->SetXTitle("Index #eta (columnns)");
1207   fhL0Amp     ->SetYTitle("Index #phi (rows)");
1208   fhL0Amp     ->SetZTitle("Amplitude");
1209   
1210   fhL0AmpL1G   = new TH2F("hL0AmpL1G","FALTRO signal per Row and Column, with L1G trigger condition",
1211                           fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1212   fhL0AmpL1G  ->SetXTitle("Index #eta (columnns)");
1213   fhL0AmpL1G  ->SetYTitle("Index #phi (rows)");
1214   fhL0AmpL1G  ->SetZTitle("Amplitude");
1215         
1216   
1217   fhL0AmpL1J   = new TH2F("hL0AmpL1J","FALTRO signal per Row and Column, with L1j trigger condition",
1218                           fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1219   fhL0AmpL1J  ->SetXTitle("Index #eta (columnns)");
1220   fhL0AmpL1J  ->SetYTitle("Index #phi (rows)");
1221   fhL0AmpL1J  ->SetZTitle("Amplitude");
1222         
1223   
1224   fhL1Amp      = new TH2F("hL1Amp","STU signal per Row and Column",
1225                           fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1226   fhL1Amp     ->SetXTitle("Index #eta (columnns)");
1227   fhL1Amp     ->SetYTitle("Index #phi (rows)");
1228   fhL1Amp     ->SetZTitle("Amplitude");
1229   
1230   fhL1GAmp     = new TH2F("hL1G1Amp","STU signal per Row and Column for L1 Gamma1",
1231                           fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1232   fhL1GAmp    ->SetXTitle("Index #eta (columnns)");
1233   fhL1GAmp    ->SetYTitle("Index #phi (rows)");
1234   fhL1GAmp    ->SetZTitle("Amplitude");
1235         
1236   fhL1G2Amp     = new TH2F("hL1G2Amp","STU signal per Row and Column for L1 Gamma2",
1237                            fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1238   fhL1G2Amp    ->SetXTitle("Index #eta (columnns)");
1239   fhL1G2Amp    ->SetYTitle("Index #phi (rows)");
1240   fhL1G2Amp    ->SetZTitle("Amplitude");
1241   
1242   fhL1JAmp     = new TH2F("hL1J1Amp","STU signal per Row and Column for L1 Jet1",
1243                           fgkFALTROCols/4,0,fgkFALTROCols,fgkFALTRORows/4,0,fgkFALTRORows);
1244   fhL1JAmp    ->SetXTitle("Index #eta (columnns)");
1245   fhL1JAmp    ->SetYTitle("Index #phi (rows)");
1246   fhL1JAmp    ->SetZTitle("Amplitude");
1247         
1248   fhL1J2Amp     = new TH2F("hL1J2Amp","STU signal per Row and Column for L1 Jet2",
1249                            fgkFALTROCols/4,0,fgkFALTROCols,fgkFALTRORows/4,0,fgkFALTRORows);
1250   fhL1J2Amp    ->SetXTitle("Index #eta (columnns)");
1251   fhL1J2Amp    ->SetYTitle("Index #phi (rows)");
1252   fhL1J2Amp    ->SetZTitle("Amplitude");
1253         
1254   fhL1FOREnergy     = new TH2F("hL1FOREnergy","FOR index vs FOR energy",
1255                                fgkFALTROCols*fgkFALTRORows,0,fgkFALTROCols*fgkFALTRORows,200,0,200);
1256   fhL1FOREnergy    ->SetXTitle("Index FOR");
1257   fhL1FOREnergy    ->SetYTitle("Energy (ADC)");
1258   
1259   fhL0Patch    = new TH2F("hL0Patch","FOR with associated L0 Patch",
1260                           fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1261   fhL0Patch   ->SetXTitle("Index #eta (columnns)");
1262   fhL0Patch   ->SetYTitle("Index #phi (rows)");
1263   fhL0Patch   ->SetZTitle("counts");
1264   
1265   fhL1GPatch   = new TH2F("hL1G1Patch","FOR with associated L1 Gamma Patch1",
1266                           fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1267   fhL1GPatch  ->SetXTitle("Index #eta (columnns)");
1268   fhL1GPatch  ->SetYTitle("Index #phi (rows)");
1269   fhL1GPatch  ->SetZTitle("counts");
1270         
1271   fhL1G2Patch   = new TH2F("hL1G2Patch","FOR with associated L1 Gamma2 Patch",
1272                            fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1273   fhL1G2Patch  ->SetXTitle("Index #eta (columnns)");
1274   fhL1G2Patch  ->SetYTitle("Index #phi (rows)");
1275   fhL1G2Patch  ->SetZTitle("counts");
1276   
1277   fhL1GPatchNotFake   = new TH2F("hL1G1PatchNotFake","FOR with L1 Gamma1 Patch associated to energetic cells",
1278                                  fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1279   fhL1GPatchNotFake  ->SetXTitle("Index #eta (columnns)");
1280   fhL1GPatchNotFake  ->SetYTitle("Index #phi (rows)");
1281   fhL1GPatchNotFake  ->SetZTitle("counts");
1282         
1283   fhL1GPatchFake   = new TH2F("hL1G1PatchFake","FOR without L1 Gamma1 Patch associated to energetic cells",
1284                               fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1285   fhL1GPatchFake  ->SetXTitle("Index #eta (columnns)");
1286   fhL1GPatchFake  ->SetYTitle("Index #phi (rows)");
1287   fhL1GPatchFake  ->SetZTitle("counts");
1288         
1289         
1290   fhL1GPatchNotAllFake   = new TH2F("hL1G1PatchNotAllFake","FOR with one L1 Gamma1 Patch associated to an energetic cell",
1291                                     fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1292   fhL1GPatchNotAllFake  ->SetXTitle("Index #eta (columnns)");
1293   fhL1GPatchNotAllFake  ->SetYTitle("Index #phi (rows)");
1294   fhL1GPatchNotAllFake  ->SetZTitle("counts");
1295         
1296   fhL1GPatchAllFake   = new TH2F("hL1G1PatchAllFake","FOR without any L1 Gamma1 Patch associated to an energetic cell",
1297                                  fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1298   fhL1GPatchAllFake  ->SetXTitle("Index #eta (columnns)");
1299   fhL1GPatchAllFake  ->SetYTitle("Index #phi (rows)");
1300   fhL1GPatchAllFake  ->SetZTitle("counts");
1301         
1302   fhL1GPatchAllFakeMax   = new TH2F("hL1G1PatchAllFakeMax","FOR with L1 Gamma1 Patch Max not associated to an energetic cell",
1303                                     fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1304   fhL1GPatchAllFakeMax  ->SetXTitle("Index #eta (columnns)");
1305   fhL1GPatchAllFakeMax  ->SetYTitle("Index #phi (rows)");
1306   fhL1GPatchAllFakeMax  ->SetZTitle("counts");
1307         
1308   fhL1GPatchNotAllFakeMax   = new TH2F("hL1G1PatchNotAllFakeMax","FOR with one L1 Gamma1 Patch Max associated to an energetic cell",
1309                                        fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1310   fhL1GPatchNotAllFakeMax  ->SetXTitle("Index #eta (columnns)");
1311   fhL1GPatchNotAllFakeMax  ->SetYTitle("Index #phi (rows)");
1312   fhL1GPatchNotAllFakeMax  ->SetZTitle("counts");
1313         
1314         fhL1GPatchNotAllFakeMaxE   = new TH1F("hL1G1PatchNotAllFakeMaxE","Energy distribution of FOR in events with L1 Gamma1 Patch Max associated to an energetic cell",
1315                                         fNBinsClusterE,0,fMaxClusterE);
1316         fhL1GPatchNotAllFakeMaxE ->SetXTitle("Energy (GeV)");
1317   
1318         
1319   fhL1GPatchAllFakeMaxE   = new TH1F("hL1G1PatchAllFakeMaxE","Energy distribution of FOR in events with L1 Gamma1 Patch Max not associated to an energetic cell",
1320                                      fNBinsClusterE,0,fMaxClusterE);
1321         fhL1GPatchAllFakeMaxE ->SetXTitle("Energy (GeV)");
1322   
1323   fhL1GPatchNotAllFakeE   = new TH1F("hL1G1PatchNotAllFakeE","Energy distribution of FOR in events with L1 Gamma1 Patch not associated to an energetic cell",
1324                                      fNBinsClusterE,0,fMaxClusterE);
1325         fhL1GPatchNotAllFakeE ->SetXTitle("Energy (GeV)");
1326         
1327   fhL1GPatchAllFakeE   = new TH1F("hL1G1PatchAllFakeE","Energy distribution of FOR in events with L1 Gamma1 Patch  associated to an energetic cell",
1328                                   fNBinsClusterE,0,fMaxClusterE);
1329         fhL1GPatchAllFakeE ->SetXTitle("Energy (GeV)");
1330         
1331         
1332   fhL1GPatchFakeE   = new TH1F("hL1G1PatchFakeE","Energy distribution of FOR with L1 Gamma1 Patch not associated to an energetic cell",
1333                                fNBinsClusterE,0,fMaxClusterE);
1334         fhL1GPatchFakeE ->SetXTitle("Energy (GeV)");
1335         
1336   fhL1GPatchNotFakeE   = new TH1F("hL1G1PatchNotFakeE","Energy distribution of FOR with L1 Gamma1 Patch  associated to an energetic cell",
1337                                   fNBinsClusterE,0,fMaxClusterE);
1338         fhL1GPatchNotFakeE ->SetXTitle("Energy (GeV)");
1339         
1340   fhNPatchFake   = new TH2F("hNPatchFake","number of fake patchs vs. all patchs are fake",
1341                             3,0,3, 2880,0,2880);
1342   fhNPatchFake  ->SetYTitle("number of fake patchs");
1343   fhNPatchFake  ->SetXTitle("all fake event");
1344   fhNPatchFake  ->SetZTitle("counts");
1345         
1346         
1347   fhNPatchNotFake   = new TH2F("hNPatchNotFake","number of Not fake patchs vs. all patchs are fake",
1348                                3, 0, 3, 2000,0,2000);
1349   fhNPatchNotFake  ->SetYTitle("number of Not fake patchs");
1350   fhNPatchNotFake  ->SetXTitle("all fake event");
1351   fhNPatchNotFake  ->SetZTitle("counts");
1352         
1353         
1354   fhL1JPatch   = new TH2F("hL1J1Patch","FOR with associated L1 Jet1 Patch",
1355                           fgkFALTROCols/4,0,fgkFALTROCols,fgkFALTRORows/4,0,fgkFALTRORows);
1356   fhL1JPatch  ->SetXTitle("Index #eta (columnns)");
1357   fhL1JPatch  ->SetYTitle("Index #phi (rows)");
1358   fhL1JPatch  ->SetZTitle("counts");
1359         
1360   fhL1J2Patch   = new TH2F("hL1J2Patch","FOR with associated L1 Jet2 Patch",
1361                            fgkFALTROCols/4,0,fgkFALTROCols,fgkFALTRORows/4,0,fgkFALTRORows);
1362   fhL1J2Patch  ->SetXTitle("Index #eta (columnns)");
1363   fhL1J2Patch  ->SetYTitle("Index #phi (rows)");
1364   fhL1J2Patch  ->SetZTitle("counts");
1365   
1366   if(fFillV0SigHisto)
1367   {
1368     fhV0STU      = new TH2I("hV0STU","Total signal STU vs V0C+V0S",
1369                             fNBinsV0Signal,0,fMaxV0Signal,fNBinsSTUSignal,0,fMaxSTUSignal);
1370     fhV0STU     ->SetXTitle("Signal V0C+V0A");
1371     fhV0STU     ->SetYTitle("Total signal STU");
1372     fhV0STU     ->SetZTitle("counts");
1373   }
1374   
1375   fhFEESTU     = new TH2F("hFEESTU","STU / FEE vs channel", fNBinsSTUFEERatio,0,fMaxSTUFEERatio,30,0,30);
1376   fhFEESTU    ->SetXTitle("STU/FEE signal");
1377   fhFEESTU    ->SetYTitle("channel");
1378   fhFEESTU    ->SetZTitle("counts");
1379   
1380   fhTRUSTU     = new TH2F("hTRUSTU","STU / TRU vs channel", fNBinsSTUTRURatio,0,fMaxSTUTRURatio,30,0,30);
1381   fhTRUSTU    ->SetXTitle("STU/TRU signal");
1382   fhTRUSTU    ->SetYTitle("channel");
1383   fhTRUSTU    ->SetZTitle("counts");
1384   
1385   fhGPMaxVV0TT = new TH2F("hGPMaxVV0TT","Maximum patch of L1-Gamma vs V0 signal in STU",fNBinsV0Signal,0,fMaxV0Signal,1000,0,1000);
1386   fhGPMaxVV0TT ->SetXTitle("V0 from STU");
1387   fhGPMaxVV0TT ->SetYTitle("Patch Max");
1388   
1389   fhJPMaxVV0TT = new TH2F("hJPMaxVV0TT","Maximum patch of L1-Jet   vs V0 signal in STU",fNBinsV0Signal,0,fMaxV0Signal,1000,0,1000);
1390   fhJPMaxVV0TT ->SetXTitle("V0 from STU");
1391   fhJPMaxVV0TT ->SetYTitle("Patch Max");
1392   
1393   fhFORMeanAmp = new TProfile2D("hFORMeanAmp", "Mean FastOR(FEE) signal per Row and Column", fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1394   fhFORMeanAmp->SetXTitle("Index #eta");
1395   fhFORMeanAmp->SetYTitle("Index #phi");
1396   
1397   fhL0MeanAmp = new TProfile2D("hL0MeanAmp", "Mean FastOR(TRU) signal per Row and Column", fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1398   fhL0MeanAmp->SetXTitle("Index #eta");
1399   fhL0MeanAmp->SetYTitle("Index #phi");
1400   
1401   fhL1MeanAmp = new TProfile2D("hL1MeanAmp", "Mean FastOR(STU) signal per Row and Column", fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1402   fhL1MeanAmp->SetXTitle("Index #eta");
1403   fhL1MeanAmp->SetYTitle("Index #phi");
1404   
1405   fhL1GPatchMax   = new TH2F("hL1G1PatchMax","FOR of max amplitude patch with associated L1 Gamma1 Patch",
1406                              fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1407   fhL1GPatchMax  ->SetXTitle("Index #eta (columnns)");
1408   fhL1GPatchMax  ->SetYTitle("Index #phi (rows)");
1409   fhL1GPatchMax  ->SetZTitle("counts");
1410         
1411   fhL1G2PatchMax   = new TH2F("hL1G2PatchMax","FOR of max amplitude patch with associated L1 Gamma2 Patch",
1412                               fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1413   fhL1G2PatchMax  ->SetXTitle("Index #eta (columnns)");
1414   fhL1G2PatchMax  ->SetYTitle("Index #phi (rows)");
1415   fhL1G2PatchMax  ->SetZTitle("counts");
1416   
1417   fhL1JPatchMax   = new TH2F("hL1J1PatchMax","FOR of max amplitude patch with associated L1 Jet1 Patch",
1418                              fgkFALTROCols/4,0,fgkFALTROCols,fgkFALTRORows/4,0,fgkFALTRORows);
1419   fhL1JPatchMax  ->SetXTitle("Index #eta (columnns)");
1420   fhL1JPatchMax  ->SetYTitle("Index #phi (rows)");
1421   fhL1JPatchMax  ->SetZTitle("counts");
1422         
1423   fhL1J2PatchMax   = new TH2F("hL1J2PatchMax","FOR of max amplitude patch with associated L1 Jet2 Patch",
1424                               fgkFALTROCols/4,0,fgkFALTROCols,fgkFALTRORows/4,0,fgkFALTRORows);
1425   fhL1J2PatchMax  ->SetXTitle("Index #eta (columnns)");
1426   fhL1J2PatchMax  ->SetYTitle("Index #phi (rows)");
1427   fhL1J2PatchMax  ->SetZTitle("counts");
1428   
1429   fOutputList->Add(fhNEvents);
1430   fOutputList->Add(fhV0STU);
1431   fOutputList->Add(fhFORAmp);
1432   fOutputList->Add(fhFORAmpL1G);
1433   fOutputList->Add(fhFORAmpL1G2);
1434   fOutputList->Add(fhFORAmpL1J);
1435   fOutputList->Add(fhFORAmpL1J2);
1436   fOutputList->Add(fhL0Amp);
1437   fOutputList->Add(fhL0AmpL1G);
1438   fOutputList->Add(fhL0AmpL1J);
1439   fOutputList->Add(fhL1Amp);
1440   fOutputList->Add(fhL1GAmp);
1441   fOutputList->Add(fhL1G2Amp);
1442   fOutputList->Add(fhL1JAmp);
1443   fOutputList->Add(fhL1J2Amp);
1444   fOutputList->Add(fhL1FOREnergy);
1445   fOutputList->Add(fhL0Patch);
1446   fOutputList->Add(fhL1GPatch);
1447   fOutputList->Add(fhL1G2Patch);
1448   fOutputList->Add(fhL1GPatchNotFake);
1449   fOutputList->Add(fhL1GPatchFake);
1450   fOutputList->Add(fhL1GPatchAllFake);
1451   fOutputList->Add(fhL1GPatchNotAllFake);
1452   fOutputList->Add(fhL1GPatchNotAllFakeMax);
1453   fOutputList->Add(fhL1GPatchAllFakeMax);
1454   fOutputList->Add(fhL1GPatchNotAllFakeMaxE);
1455   fOutputList->Add(fhL1GPatchAllFakeMaxE);
1456   fOutputList->Add(fhL1GPatchNotAllFakeE);
1457   fOutputList->Add(fhL1GPatchAllFakeE);
1458   fOutputList->Add(fhL1GPatchFakeE);
1459   fOutputList->Add(fhL1GPatchNotFakeE);
1460   fOutputList->Add(fhNPatchFake);
1461   fOutputList->Add(fhNPatchNotFake);
1462         
1463   fOutputList->Add(fhL1JPatch);
1464   fOutputList->Add(fhL1J2Patch);
1465   fOutputList->Add(fhFEESTU);
1466   fOutputList->Add(fhTRUSTU);
1467   
1468   fOutputList->Add(fhGPMaxVV0TT);
1469   fOutputList->Add(fhJPMaxVV0TT);
1470   
1471   fOutputList->Add(fhFORMeanAmp);
1472   fOutputList->Add(fhL0MeanAmp);
1473   fOutputList->Add(fhL1MeanAmp);
1474         
1475   fOutputList->Add(fhL1GPatchMax);
1476   fOutputList->Add(fhL1G2PatchMax);
1477   fOutputList->Add(fhL1JPatchMax);
1478   fOutputList->Add(fhL1J2PatchMax);
1479   
1480   if(fMCData)
1481   {
1482     PostData(1, fOutputList);
1483     return;
1484   }
1485   
1486   // Cluster histograms, E
1487   TString hName  [] = {"MB","L0","L1G1","L1G2","L1J1","L1J2","L1G1NoL1J1","L1J1NoLG1","L1G2NoL1G1","L1J2NoL1J1","Central","SemiCentral"};
1488   TString hTitle [] = {"MB trigger","L0 trigger","L1 Gamma1 trigger","L1 Gamma2 trigger","L1 Jet1 trigger","L1 Jet2 trigger",
1489                        "L1 Gamma1 trigger and not L1 Jet1"  ,"L1 Jet1 trigger and not L1 Gamma1",
1490                        "L1 Gamma2 trigger and not L1 Gamma1","L1 Jet2 trigger and not L1 Jet1",
1491                         "Central trigger","SemiCentral trigger"};
1492         
1493   for(Int_t i=0; i < 3; i++)
1494   {
1495     Int_t j = i+5;
1496     if(i==0)j=0;
1497     
1498     fhClusMBPure[i]  = new TH1F(Form("hClus%sPure",hName[j].Data()),
1499                                 Form("clusters E distribution for %s, no other EMCAL trigger on",hTitle[j].Data()),
1500                                 fNBinsClusterE,0,fMaxClusterE);
1501     fhClusMBPure[i] ->SetXTitle("Energy (GeV)");
1502     fOutputList->Add(fhClusMBPure[i]);
1503                 
1504     fhClusMaxMBPure[i]  = new TH1F(Form("hClusMax%sPure",hName[j].Data()),
1505                                    Form("maximum energy cluster per event for %s, no other EMCAL trigger on",hTitle[j].Data()),
1506                                    fNBinsClusterE,0,fMaxClusterE);
1507     fhClusMaxMBPure[i] ->SetXTitle("Energy (GeV)");
1508     fOutputList->Add(fhClusMaxMBPure[i]);
1509   }
1510   
1511   for(Int_t i=0; i < fgkTriggerCombi; i++)
1512   {
1513     if(fFillV0SigHisto)
1514     {
1515       fhV0[i] = new TH1F(Form("hV0%s",hName[i].Data()),
1516                          Form("V0 distribution for %s",hTitle[i].Data()),
1517                          fNBinsV0Signal,0,fMaxV0Signal);
1518       fhV0[i]->SetXTitle("V0");
1519       fOutputList->Add(fhV0[i] );
1520                 }
1521     
1522     fhClus[i]    = new TH1F(Form("hClus%s",hName[i].Data()),
1523                             Form("clusters E distribution for %s",hTitle[i].Data()),
1524                             fNBinsClusterE,0,fMaxClusterE);
1525     fhClus[i]   ->SetXTitle("Energy (GeV)");
1526     fOutputList->Add(fhClus[i]);
1527     
1528     fhClusMax[i] = new TH1F(Form("hClusMax%s",hName[i].Data()),
1529                             Form("maximum energy cluster per event for %s",hTitle[i].Data()),
1530                             fNBinsClusterE,0,fMaxClusterE);
1531     fhClusMax[i]->SetXTitle("Energy (GeV)");
1532     fOutputList->Add(fhClusMax[i]);
1533     
1534     // Cluster histograms, E vs Cen
1535     
1536     fhClusCen[i]    = new TH2F(Form("hClusCen%s",hName[i].Data()),
1537                                Form("clusters E distribution vs centrality for %s",hTitle[i].Data()),
1538                                fNBinsClusterE,0,fMaxClusterE,100, 0, 100);
1539     fhClusCen[i]   ->SetXTitle("Energy (GeV)");
1540     fhClusCen[i]   ->SetYTitle("Centrality");
1541     fOutputList->Add(fhClusCen[i]);
1542     
1543     fhClusCenMax[i] = new TH2F(Form("hClusCenMax%s",hName[i].Data()),
1544                                Form("maximum energy cluster per event vs centrality for %s",hTitle[i].Data()),
1545                                fNBinsClusterE,0,fMaxClusterE,100, 0, 100);
1546     fhClusCenMax[i]->SetXTitle("Energy (GeV)");
1547     fhClusCenMax[i]->SetYTitle("Centrality");
1548     fOutputList->Add(fhClusCenMax[i]);
1549     
1550     // Cluster histograms, E vs V0
1551     
1552     if(fFillV0SigHisto)
1553     {
1554       fhClusV0[i]    = new TH2F(Form("hClusV0%s",hName[i].Data()),
1555                                 Form("clusters E distribution vs V0 for %s",hTitle[i].Data()),
1556                                 fNBinsClusterE,0,fMaxClusterE,fNBinsV0Signal,0,fMaxV0Signal);
1557       fhClusV0[i]   ->SetXTitle("Energy (GeV)");
1558       fhClusV0[i]   ->SetYTitle("V0");
1559       fOutputList->Add(fhClusV0[i]);
1560       
1561       fhClusV0Max[i] = new TH2F(Form("hClusV0Max%s",hName[i].Data()),
1562                                 Form("maximum energy cluster per event vs V0 for %s",hTitle[i].Data()),
1563                                 fNBinsClusterE,0,fMaxClusterE,fNBinsV0Signal,0,fMaxV0Signal);
1564       fhClusV0Max[i]->SetXTitle("Energy (GeV)");
1565       fhClusV0Max[i]->SetYTitle("V0");
1566       fOutputList->Add(fhClusV0Max[i]);
1567     }
1568     
1569     // Cluster acceptance histograms
1570     Float_t etamin =-0.7;
1571     Float_t etamax = 0.7;
1572     Int_t neta     = 140;
1573     
1574     Float_t phimin = 80. *TMath::DegToRad();
1575     Float_t phimax = 190.*TMath::DegToRad();
1576     Int_t   nphi   = 110;
1577     
1578     // Cluster histograms, Pseudorapidity vs Azimuthal angle
1579     
1580     fhClusEtaPhiHigh[i]    = new TH2F(Form("hClusEtaPhiHigh%s",hName[i].Data()),
1581                                       Form("clusters distribution #eta vs #phi for %s, E > %1.1f GeV",hTitle[i].Data(),fEtaPhiEnMin),
1582                                       neta, etamin, etamax,nphi, phimin, phimax);
1583     fhClusEtaPhiHigh[i]   ->SetXTitle("#eta");
1584     fhClusEtaPhiHigh[i]   ->SetYTitle("#phi (rad)");
1585     fOutputList->Add(fhClusEtaPhiHigh[i]);
1586     
1587     fhClusEtaPhiLow[i]    = new TH2F(Form("hClusEtaPhiLow%s",hName[i].Data()),
1588                                      Form("clusters distribution #eta vs #phi for %s, E < %1.1f GeV",hTitle[i].Data(),fEtaPhiEnMin),
1589                                      neta, etamin, etamax,nphi, phimin, phimax);
1590     fhClusEtaPhiLow[i]   ->SetXTitle("#eta");
1591     fhClusEtaPhiLow[i]   ->SetYTitle("#phi (rad)");
1592     fOutputList->Add(fhClusEtaPhiLow[i]);
1593
1594     if(fFillClusAcceptHisto)
1595     {
1596       fhClusEtaPhiHighCluMax[i] = new TH2F(Form("hClusEtaPhiHighCluMax%s",hName[i].Data()),
1597                                            Form("maximum energy cluster per event #eta  vs #phi for %s, E > %1.1f GeV",hTitle[i].Data(),fEtaPhiEnMin),
1598                                            neta, etamin, etamax,nphi, phimin, phimax);
1599       fhClusEtaPhiHighCluMax[i]->SetXTitle("#eta");
1600       fhClusEtaPhiHighCluMax[i]->SetYTitle("#phi (rad)");
1601       fOutputList->Add(fhClusEtaPhiHighCluMax[i]);
1602       
1603       fhClusEtaPhiLowCluMax[i] = new TH2F(Form("hClusEtaPhiLowCluMax%s",hName[i].Data()),
1604                                           Form("maximum energy cluster per event #eta  vs #phi for %s, E < %1.1f GeV",hTitle[i].Data(),fEtaPhiEnMin),
1605                                           neta, etamin, etamax,nphi, phimin, phimax);
1606       fhClusEtaPhiLowCluMax[i]->SetXTitle("#eta");
1607       fhClusEtaPhiLowCluMax[i]->SetYTitle("#phi (rad)");
1608       fOutputList->Add(fhClusEtaPhiLowCluMax[i]);
1609       
1610       fhClusEtaPhiHighCellMax[i]    = new TH2F(Form("hClusEtaPhiHighCellMax%s",hName[i].Data()),
1611                                                Form("Cluster hit map in calorimeter (max cell), column vs row for %s, E > %1.1f GeV",hTitle[i].Data(),fEtaPhiEnMin),
1612                                                fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1613       fhClusEtaPhiHighCellMax[i]   ->SetXTitle("Index #eta (columnns)");
1614       fhClusEtaPhiHighCellMax[i]   ->SetYTitle("Index #phi (rows)");
1615       fOutputList->Add(fhClusEtaPhiHighCellMax[i]);
1616       
1617       fhClusEtaPhiHighCellMaxCluMax[i] = new TH2F(Form("hClusEtaPhiHighCellMaxCluMax%s",hName[i].Data()),
1618                                                   Form("Max E cluster hit map in calorimeter (max cell), column vs row  for %s, E > %1.1f GeV",
1619                                                        hTitle[i].Data(),fEtaPhiEnMin),fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1620       fhClusEtaPhiHighCellMaxCluMax[i]->SetXTitle("Index #eta (columnns)");
1621       fhClusEtaPhiHighCellMaxCluMax[i]->SetYTitle("Index #phi (rows)");
1622       fOutputList->Add(fhClusEtaPhiHighCellMaxCluMax[i]);
1623       
1624       fhClusEtaPhiLowCellMax[i]    = new TH2F(Form("hClusEtaPhiLowCellMax%s",hName[i].Data()),
1625                                               Form("Cluster hit map in calorimeter (max cell), column vs row for %s, E < %1.1f GeV",hTitle[i].Data(),fEtaPhiEnMin),
1626                                               fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1627       fhClusEtaPhiLowCellMax[i]   ->SetXTitle("Index #eta (columnns)");
1628       fhClusEtaPhiLowCellMax[i]   ->SetYTitle("#phi (rad)");
1629       fOutputList->Add(fhClusEtaPhiLowCellMax[i]);
1630       
1631       fhClusEtaPhiLowCellMaxCluMax[i] = new TH2F(Form("hClusEtaPhiLowCellMaxCluMax%s",hName[i].Data()),
1632                                                  Form("Max E cluster hit map in calorimeter (max cell), column vs row  for %s, E < %1.1f GeV",
1633                                                       hTitle[i].Data(),fEtaPhiEnMin),fgkFALTROCols,0,fgkFALTROCols,fgkFALTRORows,0,fgkFALTRORows);
1634       fhClusEtaPhiLowCellMaxCluMax[i]->SetXTitle("Index #eta (columnns)");
1635       fhClusEtaPhiLowCellMaxCluMax[i]->SetYTitle("#phi (rad)");
1636       fOutputList->Add(fhClusEtaPhiLowCellMaxCluMax[i]);
1637       
1638       // Cluster histograms, E vs Pseudorapidity
1639       
1640       fhClusEta[i]    = new TH2F(Form("hClusEta%s",hName[i].Data()),
1641                                  Form("clusters distribution vs #eta for %s",hTitle[i].Data()),
1642                                  fNBinsClusterE,0,fMaxClusterE,neta, etamin, etamax);
1643       fhClusEta[i]   ->SetXTitle("Energy (GeV)");
1644       fhClusEta[i]   ->SetYTitle("#eta");
1645       fOutputList->Add(fhClusEta[i]);
1646       
1647       fhClusEtaMax[i] = new TH2F(Form("hClusEtaMax%s",hName[i].Data()),
1648                                  Form("maximum energy cluster per event vs #eta for %s",hTitle[i].Data()),
1649                                  fNBinsClusterE,0,fMaxClusterE,neta, etamin, etamax);
1650       fhClusEtaMax[i]->SetXTitle("Energy (GeV)");
1651       fhClusEtaMax[i]->SetYTitle("#eta");
1652       fOutputList->Add(fhClusEtaMax[i]);
1653       
1654       // Cluster histograms, E vs Azimuthal angle
1655       
1656       fhClusPhi[i]    = new TH2F(Form("hClusPhi%s",hName[i].Data()),
1657                                  Form("clusters distribution vs #phi for %s",hTitle[i].Data()),
1658                                  fNBinsClusterE,0,fMaxClusterE,nphi, phimin, phimax);
1659       fhClusPhi[i]   ->SetXTitle("Energy (GeV)");
1660       fhClusPhi[i]   ->SetYTitle("#phi (rad)");
1661       fOutputList->Add(fhClusPhi[i]);
1662       
1663       fhClusPhiMax[i] = new TH2F(Form("hClusPhiMax%s",hName[i].Data()),
1664                                  Form("maximum energy cluster per event vs #phi for %s",hTitle[i].Data()),
1665                                  fNBinsClusterE,0,fMaxClusterE,nphi, phimin, phimax);
1666       fhClusPhiMax[i]->SetXTitle("Energy (GeV)");
1667       fhClusPhiMax[i]->SetYTitle("#phi (rad)");
1668       fOutputList->Add(fhClusPhiMax[i]);
1669     }
1670   }
1671   
1672   PostData(1, fOutputList);
1673 }
1674
1675 //______________________________________________________
1676 void AliAnalysisTaskEMCALTriggerQA::UserExec(Option_t *)
1677 {
1678   // Main loop
1679         
1680   AliVEvent* event = InputEvent();
1681   
1682   if (!event)
1683   {
1684     AliError("No Event, exit");
1685     return;
1686   }
1687   
1688   ////////////////////////////////////////////////
1689   // Execute task on physics events with triggers
1690   
1691   //trigger configuration
1692   TString triggerclasses = event->GetFiredTriggerClasses();
1693   
1694   // event type
1695   Int_t eventType = ((AliVHeader*)event->GetHeader())->GetEventType();
1696   
1697   if(!fMCData)
1698   {
1699     // physics events eventType=7, select only those
1700     if(triggerclasses=="" || eventType != 7) return;
1701   }
1702   
1703   //printf("Event Type %d; Trigger classes: %s\n",eventType,triggerclasses.Data());
1704   
1705   // Check what trigger we had
1706   SetTriggerEventBit(triggerclasses);
1707   
1708   if(!fEventMB && !fEventL0 && !fEventL1G && !fEventL1G2 && !fEventL1J && ! fEventL1J2 && !fEventCen && !fEventSem) return;
1709   
1710   ////////////////////////////
1711   // Init geometry, OADB, maps
1712   
1713   InitGeometry(); // only once, must be done before OADB, geo OADB accessed here
1714   
1715   InitCellPatchMaps();   //init to 0 map for cells and patches
1716   
1717   ///////////////////
1718   // Do the analysis
1719   
1720   FillEventCounterHistogram();
1721   
1722   FillCellMaps();
1723   
1724   FillTriggerPatchMaps(triggerclasses);
1725   
1726   //if(!fEventMB)printf("MB : %d; L0 : %d; L1-Gam1 : %d; L1-Gam2 : %d; L1-Jet1 : %d; L1-Jet2 : %d; Central : %d; SemiCentral : %d; Trigger Names : %s \n",
1727   //                    fEventMB,fEventL0,fEventL1G,fEventL1G2,fEventL1J,fEventL1J2,fEventCen,fEventSem,triggerclasses.Data());
1728
1729   FillMapHistograms();
1730   
1731   FillV0Histograms();
1732   
1733   FillL1GammaPatchHistograms();
1734   
1735   FillL1JetPatchHistograms();
1736
1737   // FEE vs STU vs TRU
1738   FillCorrelationHistograms();
1739         
1740   ClusterAnalysis();
1741   
1742   PostData(1, fOutputList);
1743   
1744 }