]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG/CaloTrackCorrBase/AliAnaCaloTrackCorrMaker.cxx
fc81bc30f10c2dbbdd18d45572e33b59a46be8f4
[u/mrichter/AliRoot.git] / PWG / CaloTrackCorrBase / AliAnaCaloTrackCorrMaker.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 // Steering class for particle (gamma, hadron) identification and correlation
18 // analysis. It is called by the task class AliAnalysisTaskCaloTrackCorrelation
19 // and it connects the input (ESD/AOD/MonteCarlo) got with AliCaloTrackReader
20 // (produces TClonesArrays of AODs (TParticles in MC case if requested)), with
21 // the analysis classes that derive from AliAnaCaloTrackCorrBaseClass
22 //
23 // -- Author: Gustavo Conesa (INFN-LNF, LPSC-Grenoble)
24
25 #include <cstdlib>
26
27 // --- ROOT system ---
28 #include <TClonesArray.h>
29 #include <TList.h>
30 #include <TH1F.h>
31 //#include <TObjectTable.h>
32 #include <TGeoGlobalMagField.h>
33
34 //---- AliRoot system ----
35 #include "AliAnalysisManager.h"
36 #include "AliInputEventHandler.h"
37 #include "AliESDEvent.h"
38 #include "AliAODEvent.h"
39 #include "AliAnaCaloTrackCorrBaseClass.h"
40 #include "AliAnaCaloTrackCorrMaker.h"
41 #include "AliLog.h"
42
43 ClassImp(AliAnaCaloTrackCorrMaker)
44
45
46 //__________________________________________________
47 AliAnaCaloTrackCorrMaker::AliAnaCaloTrackCorrMaker() :
48 TObject(),
49 fReader(0),                   fCaloUtils(0),
50 fOutputContainer(new TList ), fAnalysisContainer(new TList ),
51 fMakeHisto(kFALSE),           fMakeAOD(kFALSE),
52 fAnaDebug(0),                 fCuts(new TList),
53 fScaleFactor(-1),
54 fFillDataControlHisto(kTRUE),
55 // Control histograms
56 fhNEventsIn(0),               fhNEvents(0),
57 fhNExoticEvents(0),           fhNEventsNoTriggerFound(0),
58 fhNPileUpEvents(0),           fhNPileUpEventsTriggerBC0(0),
59 fhXVertex(0),                 fhYVertex(0),                       fhZVertex(0),
60 fhXVertexExotic(0),           fhYVertexExotic(0),                 fhZVertexExotic(0),
61 fhPileUpClusterMult(0),       fhPileUpClusterMultAndSPDPileUp(0),
62 fhTrackMult(0),
63 fhCentrality(0),              fhEventPlaneAngle(0),
64 fhNMergedFiles(0),            fhScaleFactor(0),
65 fhEMCalBCEvent(0),            fhEMCalBCEventCut(0),
66 fhTrackBCEvent(0),            fhTrackBCEventCut(0),
67 fhPrimaryVertexBC(0),         fhTimeStampFraction(0),
68 fhNPileUpVertSPD(0),          fhNPileUpVertTracks(0),
69
70 fhClusterTriggerBC(0),                  fhClusterTriggerBCExotic(0),
71 fhClusterTriggerBCBadCell(0),           fhClusterTriggerBCBadCellExotic(0),
72 fhClusterTriggerBCBadCluster(0),        fhClusterTriggerBCBadClusterExotic(0),
73 fhClusterTriggerBCUnMatch(0),           fhClusterTriggerBCExoticUnMatch(0),
74 fhClusterTriggerBCBadCellUnMatch(0),    fhClusterTriggerBCBadCellExoticUnMatch(0),
75 fhClusterTriggerBCBadClusterUnMatch(0), fhClusterTriggerBCBadClusterExoticUnMatch(0),
76 fhClusterTriggerBCEventBC(0),           fhClusterTriggerBCEventBCUnMatch(0),
77 fhClusterTriggerBCExoticEventBC(0),     fhClusterTriggerBCExoticEventBCUnMatch(0)
78 {
79   //Default Ctor
80   AliDebug(1,"*** Analysis Maker Constructor ***");
81   
82   for(Int_t i = 0; i < 3; i++)
83   {
84     fhClusterTriggerBCUnMatchReMatch      [0] = 0;
85     fhClusterTriggerBCExoticUnMatchReMatch[0] = 0;
86   }
87   
88   //Initialize parameters, pointers and histograms
89   InitParameters();
90 }
91
92 //________________________________________________________________________________________
93 AliAnaCaloTrackCorrMaker::AliAnaCaloTrackCorrMaker(const AliAnaCaloTrackCorrMaker & maker) :
94 TObject(),
95 fReader(),   //(new AliCaloTrackReader(*maker.fReader)),
96 fCaloUtils(),//(new AliCalorimeterUtils(*maker.fCaloUtils)),
97 fOutputContainer(new TList()), fAnalysisContainer(new TList()),
98 fMakeHisto(maker.fMakeHisto),  fMakeAOD(maker.fMakeAOD),
99 fAnaDebug(maker.fAnaDebug),    fCuts(new TList()),
100 fScaleFactor(maker.fScaleFactor),
101 fFillDataControlHisto(maker.fFillDataControlHisto),
102 fhNEventsIn(maker.fhNEventsIn),
103 fhNEvents(maker.fhNEvents),
104 fhNExoticEvents(maker.fhNExoticEvents),
105 fhNEventsNoTriggerFound(maker.fhNEventsNoTriggerFound),
106 fhNPileUpEvents(maker.fhNPileUpEvents),
107 fhNPileUpEventsTriggerBC0(maker.fhNPileUpEventsTriggerBC0),
108 fhXVertex(maker.fhXVertex),
109 fhYVertex(maker.fhYVertex),
110 fhZVertex(maker.fhZVertex),
111 fhXVertexExotic(maker.fhXVertexExotic),
112 fhYVertexExotic(maker.fhYVertexExotic),
113 fhZVertexExotic(maker.fhZVertexExotic),
114 fhPileUpClusterMult(maker.fhPileUpClusterMult),
115 fhPileUpClusterMultAndSPDPileUp(maker.fhPileUpClusterMultAndSPDPileUp),
116 fhTrackMult(maker.fhTrackMult),
117 fhCentrality(maker.fhCentrality),
118 fhEventPlaneAngle(maker.fhEventPlaneAngle),
119 fhNMergedFiles(maker.fhNMergedFiles),
120 fhScaleFactor(maker.fhScaleFactor),
121 fhEMCalBCEvent(maker.fhEMCalBCEvent),
122 fhEMCalBCEventCut(maker.fhEMCalBCEventCut),
123 fhTrackBCEvent(maker.fhTrackBCEvent),
124 fhTrackBCEventCut(maker.fhTrackBCEventCut),
125 fhPrimaryVertexBC(maker.fhPrimaryVertexBC),
126 fhTimeStampFraction(maker.fhTimeStampFraction),
127 fhNPileUpVertSPD(maker.fhNPileUpVertSPD),
128 fhNPileUpVertTracks(maker.fhNPileUpVertTracks),
129 fhClusterTriggerBC(maker.fhClusterTriggerBC),
130 fhClusterTriggerBCExotic(maker.fhClusterTriggerBCExotic),
131 fhClusterTriggerBCBadCell(maker.fhClusterTriggerBCBadCell),
132 fhClusterTriggerBCBadCellExotic(maker.fhClusterTriggerBCBadCellExotic),
133 fhClusterTriggerBCBadCluster(maker.fhClusterTriggerBCBadCluster),
134 fhClusterTriggerBCBadClusterExotic(maker.fhClusterTriggerBCBadClusterExotic),
135 fhClusterTriggerBCUnMatch(maker.fhClusterTriggerBCUnMatch),
136 fhClusterTriggerBCExoticUnMatch(maker.fhClusterTriggerBCExoticUnMatch),
137 fhClusterTriggerBCBadCellUnMatch(maker.fhClusterTriggerBCBadCellUnMatch),
138 fhClusterTriggerBCBadCellExoticUnMatch(maker.fhClusterTriggerBCBadCellExoticUnMatch),
139 fhClusterTriggerBCBadClusterUnMatch(maker.fhClusterTriggerBCBadClusterUnMatch),
140 fhClusterTriggerBCBadClusterExoticUnMatch(maker.fhClusterTriggerBCBadClusterExoticUnMatch),
141 fhClusterTriggerBCEventBC(maker.fhClusterTriggerBCEventBC),
142 fhClusterTriggerBCEventBCUnMatch(maker.fhClusterTriggerBCEventBCUnMatch),
143 fhClusterTriggerBCExoticEventBC(maker.fhClusterTriggerBCExoticEventBC),
144 fhClusterTriggerBCExoticEventBCUnMatch(maker.fhClusterTriggerBCExoticEventBCUnMatch)
145
146 {
147   for(Int_t i = 0; i < 3; i++)
148   {
149     fhClusterTriggerBCUnMatchReMatch      [i] = maker.fhClusterTriggerBCUnMatchReMatch      [i];
150     fhClusterTriggerBCExoticUnMatchReMatch[i] = maker.fhClusterTriggerBCExoticUnMatchReMatch[i];
151   }
152   // cpy ctor
153 }
154
155 //___________________________________________________
156 AliAnaCaloTrackCorrMaker::~AliAnaCaloTrackCorrMaker()
157 {
158   // Remove all owned pointers.
159   
160   //  Do not delete it here, already done somewhere else, need to understand where.
161   //  if (fOutputContainer) {
162   //    fOutputContainer->Clear();
163   //    delete fOutputContainer ;
164   //  }
165   
166   if (fAnalysisContainer)
167   {
168     fAnalysisContainer->Delete();
169     delete fAnalysisContainer ;
170   }
171   
172   if (fReader)    delete fReader ;
173   if (fCaloUtils) delete fCaloUtils ;
174   
175   if(fCuts)
176   {
177           fCuts->Delete();
178           delete fCuts;
179   }
180         
181 }
182
183 //__________________________________________________________________
184 void    AliAnaCaloTrackCorrMaker::AddAnalysis(TObject* ana, Int_t n)
185 {
186   // Add analysis depending on AliAnaCaloTrackCorrBaseClass to list
187   
188   if ( fAnalysisContainer)
189   {
190     fAnalysisContainer->AddAt(ana,n);
191   }
192   else
193   {
194     AliFatal("AnalysisContainer not initialized");
195   }
196 }
197
198 //_________________________________________________________
199 TList * AliAnaCaloTrackCorrMaker::FillAndGetAODBranchList()
200 {
201         
202   // Get any new output AOD branches from analysis and put them in a list
203   // The list is filled in the maker, and new branch passed to the analysis frame
204   // AliAnalysisTaskCaloTrackCorrelation
205   
206   TList *aodBranchList = fReader->GetAODBranchList() ;
207   
208   for(Int_t iana = 0; iana <  fAnalysisContainer->GetEntries(); iana++)
209   {
210     AliAnaCaloTrackCorrBaseClass * ana =  ((AliAnaCaloTrackCorrBaseClass *) fAnalysisContainer->At(iana)) ;
211     if(ana->NewOutputAOD()) aodBranchList->Add(ana->GetCreateOutputAODBranch());
212   }
213   
214   return aodBranchList ;
215   
216 }
217
218 //____________________________________________________
219 void AliAnaCaloTrackCorrMaker::FillControlHistograms()
220 {
221   // Event control histograms
222   
223   AliVEvent* event =  fReader->GetInputEvent();
224   AliESDEvent* esdevent = dynamic_cast<AliESDEvent*> (event);
225   AliAODEvent* aodevent = dynamic_cast<AliAODEvent*> (event);
226   
227   fhNEvents        ->Fill(0); // Number of events analyzed
228   
229   Double_t v[3];
230   event->GetPrimaryVertex()->GetXYZ(v) ;
231   fhXVertex->Fill(v[0]);
232   fhYVertex->Fill(v[1]);
233   fhZVertex->Fill(v[2]);
234   
235   fhTrackMult         ->Fill(fReader->GetTrackMultiplicity());
236   fhCentrality        ->Fill(fReader->GetEventCentrality  ());
237   fhEventPlaneAngle   ->Fill(fReader->GetEventPlaneAngle  ());
238   
239   if(fFillDataControlHisto)
240   {
241     if( fReader->IsPileUpFromSPD())
242       fhNPileUpEvents->Fill(0.5);
243     //if( event->IsPileupFromSPDInMultBins())
244     //  fhNPileUpEvents->Fill(1.5);
245     if( fReader->IsPileUpFromEMCal())
246       fhNPileUpEvents->Fill(2.5);
247     if( fReader->IsPileUpFromSPDOrEMCal() )
248       fhNPileUpEvents->Fill(3.5);
249     if( fReader->IsPileUpFromSPDAndEMCal() )
250       fhNPileUpEvents->Fill(4.5);
251     if( fReader->IsPileUpFromSPDAndNotEMCal() )
252       fhNPileUpEvents->Fill(5.5);
253     if( fReader->IsPileUpFromEMCalAndNotSPD() )
254       fhNPileUpEvents->Fill(6.5);
255     if( fReader->IsPileUpFromNotSPDAndNotEMCal() )
256       fhNPileUpEvents->Fill(7.5);
257     
258     Int_t triggerBC = fReader->GetTriggerClusterBC() ;
259     if( triggerBC == 0            &&
260        !fReader->IsExoticEvent()  &&
261        !fReader->IsBadCellTriggerEvent())
262     {
263       if( fReader->IsPileUpFromSPD())
264         fhNPileUpEventsTriggerBC0->Fill(0.5);
265       //if( event->IsPileupFromSPDInMultBins())
266       //  fhNPileUpEventsTriggerBC0->Fill(1.5);
267       if( fReader->IsPileUpFromEMCal())
268         fhNPileUpEventsTriggerBC0->Fill(2.5);
269       if( fReader->IsPileUpFromSPDOrEMCal() )
270         fhNPileUpEventsTriggerBC0->Fill(3.5);
271       if( fReader->IsPileUpFromSPDAndEMCal() )
272         fhNPileUpEventsTriggerBC0->Fill(4.5);
273       if( fReader->IsPileUpFromSPDAndNotEMCal() )
274         fhNPileUpEventsTriggerBC0->Fill(5.5);
275       if( fReader->IsPileUpFromEMCalAndNotSPD() )
276         fhNPileUpEventsTriggerBC0->Fill(6.5);
277       if( fReader->IsPileUpFromNotSPDAndNotEMCal() )
278         fhNPileUpEventsTriggerBC0->Fill(7.5);
279     }
280     
281     if(fReader->IsPileUpFromSPD())
282       fhPileUpClusterMultAndSPDPileUp ->Fill(fReader->GetNPileUpClusters());
283     
284     fhPileUpClusterMult ->Fill(fReader->GetNPileUpClusters  ());
285     
286     for(Int_t i = 0; i < 19; i++)
287     {
288       if(fReader->IsAccessToTrackTimeOn())
289       {
290         if(fReader->GetTrackEventBC(i))   fhTrackBCEvent   ->Fill(i);
291         if(fReader->GetTrackEventBCcut(i))fhTrackBCEventCut->Fill(i);
292       }
293       if(fReader->GetEMCalEventBC(i))   fhEMCalBCEvent   ->Fill(i);
294       if(fReader->GetEMCalEventBCcut(i))fhEMCalBCEventCut->Fill(i);
295     }
296     
297     Int_t bc = fReader->GetVertexBC();
298     if(bc!=AliVTrack::kTOFBCNA) fhPrimaryVertexBC->Fill(bc);
299     
300     // N pile up vertices
301     Int_t nVerticesSPD    = -1;
302     Int_t nVerticesTracks = -1;
303     
304     if      (esdevent)
305     {
306       nVerticesSPD    = esdevent->GetNumberOfPileupVerticesSPD();
307       nVerticesTracks = esdevent->GetNumberOfPileupVerticesTracks();
308       
309     }//ESD
310     else if (aodevent)
311     {
312       nVerticesSPD    = aodevent->GetNumberOfPileupVerticesSPD();
313       nVerticesTracks = aodevent->GetNumberOfPileupVerticesTracks();
314     }//AOD
315     
316     fhNPileUpVertSPD   ->Fill(nVerticesSPD);
317     fhNPileUpVertTracks->Fill(nVerticesTracks);
318     
319     // Time stamp
320     if(fReader->IsSelectEventTimeStampOn() && esdevent)
321     {
322       Int_t timeStamp = esdevent->GetTimeStamp();
323       Float_t timeStampFrac = 1.*(timeStamp-fReader->GetRunTimeStampMin()) /
324       (fReader->GetRunTimeStampMax()-fReader->GetRunTimeStampMin());
325       
326       //printf("stamp %d, min %d, max %d, frac %f\n", timeStamp, fReader->GetRunTimeStampMin(), fReader->GetRunTimeStampMax(), timeStampFrac);
327       
328       fhTimeStampFraction->Fill(timeStampFrac);
329     }
330   }
331 }
332
333 //___________________________________________________________
334 void AliAnaCaloTrackCorrMaker::FillTriggerControlHistograms()
335 {
336   if(!fFillDataControlHisto) return;
337   
338   Int_t  triggerBC   = fReader->GetTriggerClusterBC() ;
339   Bool_t exotic      = fReader->IsExoticEvent();
340   Bool_t badCluster  = fReader->IsBadCellTriggerEvent();
341   Bool_t badCell     = fReader->IsBadMaxCellTriggerEvent();
342   Bool_t triggerMatch= fReader->IsTriggerMatched();
343   Bool_t triggerBCOK = kTRUE;
344   Int_t  triggerId   = fReader->GetTriggerClusterId() ;
345   
346   Bool_t reMatchOpenTime = fReader->IsTriggerMatchedOpenCuts(0);
347   Bool_t reMatchNeigbour = fReader->IsTriggerMatchedOpenCuts(1);
348   Bool_t reMatchBoth     = fReader->IsTriggerMatchedOpenCuts(2);
349   
350   if(triggerId < 0)
351   {
352     //printf("Trigger id %d\n",triggerId);
353     if(triggerId == -2) fhNEventsNoTriggerFound->Fill(0);
354     triggerBCOK = kFALSE;
355   }
356   
357   if(exotic)
358   {
359     fhNExoticEvents->Fill(0) ;
360     Double_t v[3];
361     fReader->GetInputEvent()->GetPrimaryVertex()->GetXYZ(v) ;
362     fhXVertexExotic->Fill(v[0]);
363     fhYVertexExotic->Fill(v[1]);
364     fhZVertexExotic->Fill(v[2]);
365   }
366   //if(fReader->IsExoticEvent()) printf("Maker: EXOTIC Cluster trigger\n");
367   
368   if(!triggerBCOK) return;
369   
370   Int_t eventBC = fReader->GetInputEvent()->GetBunchCrossNumber();
371   if(eventBC%4 < 0 || eventBC%4 > 3 )
372     AliWarning(Form("STRANGE: Trigger BC %d - Event BC %d, modulo4 %d",triggerBC,eventBC,eventBC%4));
373   
374   if(triggerMatch)
375   {
376     if     (!exotic     && !badCluster) fhClusterTriggerBC->Fill(triggerBC);
377     else if( exotic     &&  badCluster)
378     {
379       fhClusterTriggerBCBadClusterExotic->Fill(triggerBC);
380       if(badCell) fhClusterTriggerBCBadCellExotic->Fill(triggerBC);
381     }
382     else if( exotic     && !badCluster) fhClusterTriggerBCExotic->Fill(triggerBC);
383     else if( badCluster && !exotic    )
384     {
385       fhClusterTriggerBCBadCluster ->Fill(triggerBC);
386       if(badCell) fhClusterTriggerBCBadCell->Fill(triggerBC);
387     }
388     
389     if(!exotic) fhClusterTriggerBCEventBC      ->Fill(triggerBC,eventBC%4);
390     else        fhClusterTriggerBCExoticEventBC->Fill(triggerBC,eventBC%4);
391   }
392   else
393   {
394     if     (!exotic     && !badCluster)
395     {
396       fhClusterTriggerBCUnMatch->Fill(triggerBC);
397       if(reMatchOpenTime) fhClusterTriggerBCUnMatchReMatch[0]->Fill(triggerBC);
398       if(reMatchNeigbour) fhClusterTriggerBCUnMatchReMatch[1]->Fill(triggerBC);
399       if(reMatchBoth)     fhClusterTriggerBCUnMatchReMatch[2]->Fill(triggerBC);
400     }
401     else if( exotic     &&  badCluster)
402     {
403       fhClusterTriggerBCBadClusterExoticUnMatch->Fill(triggerBC);
404       if(badCell)   fhClusterTriggerBCBadCellExoticUnMatch   ->Fill(triggerBC);
405     }
406     else if( exotic     && !badCluster)
407     {
408       fhClusterTriggerBCExoticUnMatch->Fill(triggerBC);
409       if(reMatchOpenTime) fhClusterTriggerBCExoticUnMatchReMatch[0]->Fill(triggerBC);
410       if(reMatchNeigbour) fhClusterTriggerBCExoticUnMatchReMatch[1]->Fill(triggerBC);
411       if(reMatchBoth)     fhClusterTriggerBCExoticUnMatchReMatch[2]->Fill(triggerBC);
412     }
413     else if( badCluster && !exotic )
414     {
415       fhClusterTriggerBCBadClusterUnMatch->Fill(triggerBC);
416       if(badCell)fhClusterTriggerBCBadCellUnMatch->Fill(triggerBC);
417     }
418     
419     if(!exotic) fhClusterTriggerBCEventBCUnMatch      ->Fill(triggerBC,eventBC%4);
420     else        fhClusterTriggerBCExoticEventBCUnMatch->Fill(triggerBC,eventBC%4);
421   }
422   
423 }
424
425
426 //_______________________________________________________
427 TList * AliAnaCaloTrackCorrMaker::GetListOfAnalysisCuts()
428 {
429   
430   // Get the list of the cuts used for the analysis
431   // The list is filled in the maker, called by the task in LocalInit() and posted there
432   
433   for(Int_t iana = 0; iana <  fAnalysisContainer->GetEntries(); iana++)
434   {
435     AliAnaCaloTrackCorrBaseClass * ana =  ((AliAnaCaloTrackCorrBaseClass *) fAnalysisContainer->At(iana)) ;
436     TObjString * objstring = ana->GetAnalysisCuts();
437     
438     if(objstring)fCuts->Add(objstring);
439   }
440   
441   return fCuts ;
442   
443 }
444
445 //___________________________________________________
446 TList *AliAnaCaloTrackCorrMaker::GetOutputContainer()
447 {
448   // Fill the output list of histograms during the CreateOutputObjects stage.
449   
450   //Initialize calorimeters  geometry pointers
451   //GetCaloUtils()->InitPHOSGeometry();
452   //GetCaloUtils()->InitEMCALGeometry();
453   
454   //General event histograms
455
456   fhNEventsIn      = new TH1F("hNEventsIn",   "Number of input events"     , 1 , 0 , 1  ) ;
457   fhNEventsIn->SetYTitle("# events");
458   fOutputContainer->Add(fhNEventsIn);
459   
460   fhNEvents      = new TH1F("hNEvents",   "Number of analyzed events"     , 1 , 0 , 1  ) ;
461   fhNEvents->SetYTitle("# events");
462   fOutputContainer->Add(fhNEvents);
463   
464   fhXVertex      = new TH1F("hXVertex", " X vertex distribution"   , 200 , -4 , 4  ) ;
465   fhXVertex->SetXTitle("v_{x} (cm)");
466   fOutputContainer->Add(fhXVertex);
467   
468   fhYVertex      = new TH1F("hYVertex", " Y vertex distribution"   , 200 , -4 , 4  ) ;
469   fhYVertex->SetXTitle("v_{y} (cm)");
470   fOutputContainer->Add(fhYVertex);
471   
472   fhZVertex      = new TH1F("hZVertex", " Z vertex distribution"   , 200 , -50 , 50  ) ;
473   fhZVertex->SetXTitle("v_{z} (cm)");
474   fOutputContainer->Add(fhZVertex);
475
476   fhCentrality   = new TH1F("hCentrality","Number of events in centrality bin",100,0.,100) ;
477   fhCentrality->SetXTitle("Centrality bin");
478   fOutputContainer->Add(fhCentrality) ;
479   
480   fhEventPlaneAngle=new TH1F("hEventPlaneAngle","Number of events in event plane",100,0.,TMath::Pi()) ;
481   fhEventPlaneAngle->SetXTitle("EP angle (rad)");
482   fOutputContainer->Add(fhEventPlaneAngle) ;
483
484   fhTrackMult    = new TH1F("hTrackMult", "Number of tracks per events"   , 2000 , 0 , 2000  ) ;
485   fhTrackMult->SetXTitle("# tracks");
486   fOutputContainer->Add(fhTrackMult);
487
488   if(fFillDataControlHisto)
489   {
490     fhNExoticEvents      = new TH1F("hNExoticEvents",   "Number of analyzed events triggered by exotic cluster"     , 1 , 0 , 1  ) ;
491     fhNExoticEvents->SetYTitle("# exotic events");
492     fOutputContainer->Add(fhNExoticEvents);
493     
494     fhNEventsNoTriggerFound      = new TH1F("hNEventsNoTriggerFound",   "Number of analyzed events triggered but no trigger found"     , 1 , 0 , 1  ) ;
495     fhNEventsNoTriggerFound->SetYTitle("# exotic events");
496     fOutputContainer->Add(fhNEventsNoTriggerFound);
497     
498     
499     Int_t   nbin   = 11;
500     Float_t minbin =-5.5;
501     Float_t maxbin = 5.5;
502     Int_t  labelshift = 6;
503     
504     fhClusterTriggerBCEventBC      = new TH2F("hClusterTriggerBCEventBC", "Found trigger BC and  Event BC",
505                                               nbin , minbin ,maxbin,4,0, 4) ;
506     fhClusterTriggerBCEventBC->SetXTitle("cluster trigger BC");
507     for(Int_t i = 0; i < 4; i++)
508       fhClusterTriggerBCEventBC->GetYaxis()->SetBinLabel(i+1 ,Form("BC/4=%d",i));
509     fhClusterTriggerBCEventBC->SetXTitle("cluster trigger BC");
510     for(Int_t i = 1; i < 12; i++)
511       fhClusterTriggerBCEventBC->GetXaxis()->SetBinLabel(i ,Form("BC%d",i-labelshift));
512     fhClusterTriggerBCEventBC->SetYTitle("Event BC%4");
513     fOutputContainer->Add(fhClusterTriggerBCEventBC);
514     
515     fhClusterTriggerBCExoticEventBC      = new TH2F("hClusterTriggerBCExoticEventBC", "Found exotic trigger BC and  Event BC",
516                                                     nbin , minbin ,maxbin,4,1, 4) ;
517     for(Int_t i = 0; i < 4; i++)
518       fhClusterTriggerBCExoticEventBC->GetYaxis()->SetBinLabel(i+1 ,Form("BC/4=%d",i));
519     fhClusterTriggerBCExoticEventBC->SetXTitle("cluster trigger BC");
520     for(Int_t i = 1; i < 12; i++)
521       fhClusterTriggerBCExoticEventBC->GetXaxis()->SetBinLabel(i ,Form("BC%d",i-labelshift));
522     fhClusterTriggerBCExoticEventBC->SetYTitle("Event BC%4");
523     fOutputContainer->Add(fhClusterTriggerBCExoticEventBC);
524     
525     fhClusterTriggerBCEventBCUnMatch      = new TH2F("hClusterTriggerBCEventBCUnMatch", "Found unmatched trigger BC and  Event BC",
526                                                      nbin , minbin ,maxbin,4,1, 4) ;
527     for(Int_t i = 0; i < 4; i++)
528       fhClusterTriggerBCEventBCUnMatch->GetYaxis()->SetBinLabel(i+1 ,Form("BC/4=%d",i));
529     fhClusterTriggerBCEventBCUnMatch->SetXTitle("cluster trigger BC");
530     for(Int_t i = 1; i < 12; i++)
531       fhClusterTriggerBCEventBCUnMatch->GetXaxis()->SetBinLabel(i ,Form("BC%d",i-labelshift));
532     fhClusterTriggerBCEventBCUnMatch->SetYTitle("Event BC%4");
533     fOutputContainer->Add(fhClusterTriggerBCEventBCUnMatch);
534     
535     fhClusterTriggerBCExoticEventBCUnMatch      = new TH2F("hClusterTriggerExoticBCEventBCUnMatch", "Found unmatched trigger BC and  Event BC",
536                                                            nbin , minbin ,maxbin,4,1, 4) ;
537     for(Int_t i = 0; i < 4; i++)
538       fhClusterTriggerBCExoticEventBCUnMatch->GetYaxis()->SetBinLabel(i+1 ,Form("BC/4=%d",i));
539     fhClusterTriggerBCExoticEventBCUnMatch->SetXTitle("cluster trigger BC");
540     for(Int_t i = 1; i < 12; i++)
541       fhClusterTriggerBCExoticEventBCUnMatch->GetXaxis()->SetBinLabel(i ,Form("BC%d",i-labelshift));
542     fhClusterTriggerBCExoticEventBCUnMatch->SetYTitle("Event BC%4");
543     fOutputContainer->Add(fhClusterTriggerBCExoticEventBCUnMatch);
544     
545     fhClusterTriggerBC              = new TH1F("hClusterTriggerBC",
546                                                "Number of analyzed events triggered by a cluster in a given BC",
547                                                nbin , minbin ,maxbin) ;
548     fhClusterTriggerBC->SetYTitle("# events");
549     for(Int_t i = 1; i < 12; i++)
550       fhClusterTriggerBC->GetXaxis()->SetBinLabel(i ,Form("BC%d",i-labelshift));
551     fOutputContainer->Add(fhClusterTriggerBC);
552     
553     fhClusterTriggerBCExotic        = new TH1F("hClusterTriggerBCExotic",
554                                                "Number of analyzed events triggered by a exotic cluster in a given BC",
555                                                nbin , minbin ,maxbin) ;
556     fhClusterTriggerBCExotic->SetYTitle("# events");
557     for(Int_t i = 1; i < 12; i++)
558       fhClusterTriggerBCExotic->GetXaxis()->SetBinLabel(i ,Form("BC%d",i-labelshift));
559     fOutputContainer->Add(fhClusterTriggerBCExotic);
560     
561     
562     fhClusterTriggerBCBadCell         = new TH1F("hClusterTriggerBCBadCell",
563                                                  "Number of analyzed events triggered by a bad cell in a given BC",
564                                                  nbin , minbin ,maxbin) ;
565     
566     fhClusterTriggerBCBadCell->SetYTitle("# events");
567     for(Int_t i = 1; i < 12; i++)
568       fhClusterTriggerBCBadCell->GetXaxis()->SetBinLabel(i ,Form("BC%d",i-labelshift));
569     fOutputContainer->Add(fhClusterTriggerBCBadCell);
570     
571     fhClusterTriggerBCBadCellExotic    = new TH1F("hClusterTriggerBCBadCellExotic",
572                                                   "Number of analyzed events triggered by a bad cell & exotic cluster in a given BC",
573                                                   nbin , minbin ,maxbin) ;
574     fhClusterTriggerBCBadCellExotic->SetYTitle("# events");
575     for(Int_t i = 1; i < 12; i++)
576       fhClusterTriggerBCBadCellExotic->GetXaxis()->SetBinLabel(i ,Form("BC%d",i-labelshift));
577     fOutputContainer->Add(fhClusterTriggerBCBadCellExotic);
578     
579     fhClusterTriggerBCBadCluster           = new TH1F("hClusterTriggerBCBadCluster",
580                                                       "Number of analyzed events triggered by a bad cluster in a given BC",
581                                                       nbin , minbin ,maxbin) ;
582     
583     fhClusterTriggerBCBadCluster->SetYTitle("# events");
584     for(Int_t i = 1; i < 12; i++)
585       fhClusterTriggerBCBadCluster->GetXaxis()->SetBinLabel(i ,Form("BC%d",i-labelshift));
586     fOutputContainer->Add(fhClusterTriggerBCBadCluster);
587     
588     
589     fhClusterTriggerBCBadClusterExotic    = new TH1F("hClusterTriggerBCBadClusterExotic",
590                                                      "Number of analyzed events triggered by a bad cluster & exotic cluster in a given BC",
591                                                      nbin , minbin ,maxbin) ;
592     
593     fhClusterTriggerBCBadClusterExotic->SetYTitle("# events");
594     for(Int_t i = 1; i < 12; i++)
595       fhClusterTriggerBCBadClusterExotic->GetXaxis()->SetBinLabel(i ,Form("BC%d",i-labelshift));
596     fOutputContainer->Add(fhClusterTriggerBCBadClusterExotic);
597     
598     fhClusterTriggerBCUnMatch       = new TH1F("hClusterTriggerBCUnMatch",
599                                                "Number of analyzed events triggered by a cluster (no trigger patch match) in a given BC",
600                                                nbin , minbin ,maxbin) ;
601     fhClusterTriggerBCUnMatch->SetYTitle("# events");
602     for(Int_t i = 1; i < 12; i++)
603       fhClusterTriggerBCUnMatch->GetXaxis()->SetBinLabel(i ,Form("BC%d",i-labelshift));
604     fOutputContainer->Add(fhClusterTriggerBCUnMatch);
605     
606     fhClusterTriggerBCExoticUnMatch = new TH1F("hClusterTriggerBCExoticUnMatch",
607                                                "Number of analyzed events triggered by a exotic cluster (no trigger patch match) in a given BC",
608                                                nbin , minbin ,maxbin) ;
609     fhClusterTriggerBCExoticUnMatch->SetYTitle("# events");
610     for(Int_t i = 1; i < 12; i++)
611       fhClusterTriggerBCExoticUnMatch->GetXaxis()->SetBinLabel(i ,Form("BC%d",i-labelshift));
612     fOutputContainer->Add(fhClusterTriggerBCExoticUnMatch);
613     
614     
615     fhClusterTriggerBCBadCellUnMatch    = new TH1F("hClusterTriggerBCBadCellUnMatch",
616                                                    "Number of analyzed events triggered by a bad cluster  (no trigger patch match) in a given BC",
617                                                    nbin , minbin ,maxbin) ;
618     fhClusterTriggerBCBadCellUnMatch->SetYTitle("# events");
619     for(Int_t i = 1; i < 12; i++)
620       fhClusterTriggerBCBadCellUnMatch->GetXaxis()->SetBinLabel(i ,Form("BC%d",i-labelshift));
621     fOutputContainer->Add(fhClusterTriggerBCBadCellUnMatch);
622     
623     
624     fhClusterTriggerBCBadCellExoticUnMatch = new TH1F("hClusterTriggerBCBadCellExoticUnMatch",
625                                                       "Number of analyzed events triggered by a bad&exotic cluster  (no trigger patch match) in a given BC",
626                                                       nbin , minbin ,maxbin) ;
627     fhClusterTriggerBCBadCellExoticUnMatch->SetYTitle("# events");
628     for(Int_t i = 1; i < 12; i++)
629       fhClusterTriggerBCBadCellExoticUnMatch->GetXaxis()->SetBinLabel(i ,Form("BC%d",i-labelshift));
630     fOutputContainer->Add(fhClusterTriggerBCBadCellExoticUnMatch);
631     
632     
633     fhClusterTriggerBCBadClusterUnMatch    = new TH1F("hClusterTriggerBCBadClusterUnMatch",
634                                                       "Number of analyzed events triggered by a bad cluster  (no trigger patch match) in a given BC",
635                                                       nbin , minbin ,maxbin) ;
636     fhClusterTriggerBCBadClusterUnMatch->SetYTitle("# events");
637     for(Int_t i = 1; i < 12; i++)
638       fhClusterTriggerBCBadClusterUnMatch->GetXaxis()->SetBinLabel(i ,Form("BC%d",i-labelshift));
639     fOutputContainer->Add(fhClusterTriggerBCBadClusterUnMatch);
640     
641     
642     fhClusterTriggerBCBadClusterExoticUnMatch = new TH1F("hClusterTriggerBCBadClusterExoticUnMatch",
643                                                          "Number of analyzed events triggered by a bad&exotic cluster  (no trigger patch match) in a given BC",
644                                                          nbin , minbin ,maxbin) ;
645     fhClusterTriggerBCBadClusterExoticUnMatch->SetYTitle("# events");
646     for(Int_t i = 1; i < 12; i++)
647       fhClusterTriggerBCBadClusterExoticUnMatch->GetXaxis()->SetBinLabel(i ,Form("BC%d",i-labelshift));
648     fOutputContainer->Add(fhClusterTriggerBCBadClusterExoticUnMatch);
649     
650     TString rematch[] = {"OpenTime","CheckNeighbours","Both"};
651     for(Int_t j = 0; j < 3; j++)
652     {
653       fhClusterTriggerBCUnMatchReMatch[j]       = new TH1F(Form("hClusterTriggerBCUnMatch_ReMatch_%s",rematch[j].Data()),
654                                                            Form("Number of analyzed events triggered by a cluster (no trigger patch match) in a given BC, re-match %s",rematch[j].Data()),
655                                                            nbin , minbin ,maxbin) ;
656       fhClusterTriggerBCUnMatchReMatch[j]->SetYTitle("# events");
657       for(Int_t i = 1; i < 12; i++)
658         fhClusterTriggerBCUnMatchReMatch[j]->GetXaxis()->SetBinLabel(i ,Form("BC%d",i-labelshift));
659       fOutputContainer->Add(fhClusterTriggerBCUnMatchReMatch[j]);
660       
661       fhClusterTriggerBCExoticUnMatchReMatch[j] = new TH1F(Form("hClusterTriggerBCExoticUnMatch_ReMatch_%s",rematch[j].Data()),
662                                                            Form("Number of analyzed events triggered by a exotic cluster (no trigger patch match) in a given BC, re-match %s",rematch[j].Data()),
663                                                            nbin , minbin ,maxbin) ;
664       fhClusterTriggerBCExoticUnMatchReMatch[j]->SetYTitle("# events");
665       for(Int_t i = 1; i < 12; i++)
666         fhClusterTriggerBCExoticUnMatchReMatch[j]->GetXaxis()->SetBinLabel(i ,Form("BC%d",i-labelshift));
667       fOutputContainer->Add(fhClusterTriggerBCExoticUnMatchReMatch[j]);
668     }
669     
670     fhNPileUpEvents      = new TH1F("hNPileUpEvents",   "Number of events considered as pile-up", 8 , 0 , 8 ) ;
671     fhNPileUpEvents->SetYTitle("# events");
672     fhNPileUpEvents->GetXaxis()->SetBinLabel(1 ,"SPD");
673     fhNPileUpEvents->GetXaxis()->SetBinLabel(2 ,"Multi SPD");
674     fhNPileUpEvents->GetXaxis()->SetBinLabel(3 ,"EMCal");
675     fhNPileUpEvents->GetXaxis()->SetBinLabel(4 ,"EMCal || SPD");
676     fhNPileUpEvents->GetXaxis()->SetBinLabel(5 ,"EMCal && SPD");
677     fhNPileUpEvents->GetXaxis()->SetBinLabel(6 ,"!EMCal && SPD");
678     fhNPileUpEvents->GetXaxis()->SetBinLabel(7 ,"EMCal && !SPD");
679     fhNPileUpEvents->GetXaxis()->SetBinLabel(8 ,"!EMCal && !SPD");
680     fOutputContainer->Add(fhNPileUpEvents);
681     
682     fhNPileUpEventsTriggerBC0      = new TH1F("hNPileUpEventsTriggerBC0","Number of events considered as pile-up, trigger cluster in BC=0", 8 , 0 , 8 ) ;
683     fhNPileUpEventsTriggerBC0->SetYTitle("# events");
684     fhNPileUpEventsTriggerBC0->GetXaxis()->SetBinLabel(1 ,"SPD");
685     fhNPileUpEventsTriggerBC0->GetXaxis()->SetBinLabel(2 ,"Multi SPD");
686     fhNPileUpEventsTriggerBC0->GetXaxis()->SetBinLabel(3 ,"EMCal");
687     fhNPileUpEventsTriggerBC0->GetXaxis()->SetBinLabel(4 ,"EMCal || SPD");
688     fhNPileUpEventsTriggerBC0->GetXaxis()->SetBinLabel(5 ,"EMCal && SPD");
689     fhNPileUpEventsTriggerBC0->GetXaxis()->SetBinLabel(6 ,"!EMCal && SPD");
690     fhNPileUpEventsTriggerBC0->GetXaxis()->SetBinLabel(7 ,"EMCal && !SPD");
691     fhNPileUpEventsTriggerBC0->GetXaxis()->SetBinLabel(8 ,"!EMCal && !SPD");
692     fOutputContainer->Add(fhNPileUpEventsTriggerBC0);
693     
694     if(fReader->IsAccessToTrackTimeOn())
695     {
696       fhTrackBCEvent      = new TH1F("hTrackBCEvent",   "Number of events with at least 1 track in a bunch crossing ", 19 , 0 , 19 ) ;
697       fhTrackBCEvent->SetYTitle("# events");
698       fhTrackBCEvent->SetXTitle("Bunch crossing");
699       for(Int_t i = 1; i < 20; i++)
700         fhTrackBCEvent->GetXaxis()->SetBinLabel(i ,Form("%d",i-10));
701       fOutputContainer->Add(fhTrackBCEvent);
702       
703       fhTrackBCEventCut      = new TH1F("hTrackBCEventCut",   "Number of events with at least 1 track in a bunch crossing ", 19 , 0 , 19 ) ;
704       fhTrackBCEventCut->SetYTitle("# events");
705       fhTrackBCEventCut->SetXTitle("Bunch crossing");
706       for(Int_t i = 1; i < 20; i++)
707         fhTrackBCEventCut->GetXaxis()->SetBinLabel(i ,Form("%d",i-10));
708       fOutputContainer->Add(fhTrackBCEventCut);
709     }
710     
711     fhPrimaryVertexBC      = new TH1F("hPrimaryVertexBC", "Number of primary vertex per bunch crossing ", 41 , -20 , 20  ) ;
712     fhPrimaryVertexBC->SetYTitle("# events");
713     fhPrimaryVertexBC->SetXTitle("Bunch crossing");
714     fOutputContainer->Add(fhPrimaryVertexBC);
715     
716     fhEMCalBCEvent      = new TH1F("hEMCalBCEvent",   "Number of events with at least 1 cluster in a bunch crossing ", 19 , 0 , 19 ) ;
717     fhEMCalBCEvent->SetYTitle("# events");
718     fhEMCalBCEvent->SetXTitle("Bunch crossing");
719     for(Int_t i = 1; i < 20; i++)
720       fhEMCalBCEvent->GetXaxis()->SetBinLabel(i ,Form("%d",i-10));
721     fOutputContainer->Add(fhEMCalBCEvent);
722     
723     fhEMCalBCEventCut      = new TH1F("hEMCalBCEventCut",   "Number of events with at least 1 cluster in a bunch crossing", 19 , 0 , 19 ) ;
724     fhEMCalBCEventCut->SetYTitle("# events");
725     fhEMCalBCEventCut->SetXTitle("Bunch crossing");
726     for(Int_t i = 1; i < 20; i++)
727       fhEMCalBCEventCut->GetXaxis()->SetBinLabel(i ,Form("%d",i-10));
728     fOutputContainer->Add(fhEMCalBCEventCut);
729     
730     fhXVertexExotic      = new TH1F("hXVertexExotic", " X vertex distribution in exotic events"   , 200 , -4 , 4  ) ;
731     fhXVertexExotic->SetXTitle("v_{x} (cm)");
732     fOutputContainer->Add(fhXVertexExotic);
733     
734     fhYVertexExotic      = new TH1F("hYVertexExotic", " Y vertex distribution in exotic events"   , 200 , -4 , 4  ) ;
735     fhYVertexExotic->SetXTitle("v_{y} (cm)");
736     fOutputContainer->Add(fhYVertexExotic);
737     
738     fhZVertexExotic      = new TH1F("hZVertexExotic", " Z vertex distribution in exotic events"   , 200 , -50 , 50  ) ;
739     fhZVertexExotic->SetXTitle("v_{z} (cm)");
740     fOutputContainer->Add(fhZVertexExotic);
741     
742     fhPileUpClusterMult    = new TH1F("hPileUpClusterMult", "Number of clusters per event with large time (|t| > 20 ns)" , 100 , 0 , 100  ) ;
743     fhPileUpClusterMult->SetXTitle("# clusters");
744     fOutputContainer->Add(fhPileUpClusterMult);
745     
746     fhPileUpClusterMultAndSPDPileUp = new TH1F("hPileUpClusterMultAndSPDPileUp", "Number of clusters per event with large time (|t| > 20 ns, events tagged as pile-up by SPD)" , 100 , 0 , 100 ) ;
747     fhPileUpClusterMultAndSPDPileUp->SetXTitle("# clusters");
748     fOutputContainer->Add(fhPileUpClusterMultAndSPDPileUp);
749     
750     fhNPileUpVertSPD  = new TH1F ("hNPileUpVertSPD","N pile-up SPD vertex", 50,0,50);
751     fhNPileUpVertSPD->SetYTitle("# vertex ");
752     fOutputContainer->Add(fhNPileUpVertSPD);
753     
754     fhNPileUpVertTracks  = new TH1F ("hNPileUpVertTracks","N pile-up Tracks vertex", 50,0,50);
755     fhNPileUpVertTracks->SetYTitle("# vertex ");
756     fOutputContainer->Add(fhNPileUpVertTracks);
757     
758     if(fReader->IsSelectEventTimeStampOn())
759     {
760       fhTimeStampFraction = new TH1F("hTimeStampFraction","Fraction of events within a given time stamp range",150, -1, 2) ;
761       fhTimeStampFraction->SetXTitle("fraction");
762       fOutputContainer->Add(fhTimeStampFraction) ;
763     }
764   }
765   
766   if(fScaleFactor > 0)
767   {
768     fhNMergedFiles = new TH1F("hNMergedFiles",   "Number of merged output files"     , 1 , 0 , 1  ) ;
769     fhNMergedFiles->SetYTitle("# files");
770     fhNMergedFiles->Fill(1); // Fill here with one entry, while merging it will count the rest
771     fOutputContainer->Add(fhNMergedFiles);
772     
773     fhScaleFactor = new TH1F("hScaleFactor",   "Number of merged output files"     , 1 , 0 , 1  ) ;
774     fhScaleFactor->SetYTitle("scale factor");
775     fhScaleFactor->SetBinContent(1,fScaleFactor); // Fill here
776     fOutputContainer->Add(fhScaleFactor);
777   }
778   
779   if(!fAnalysisContainer || fAnalysisContainer->GetEntries()==0)
780   {
781     AliWarning("Analysis job list not initialized!!!");
782     return fOutputContainer;
783   }
784   
785   const Int_t buffersize = 255;
786   char newname[buffersize];
787   for(Int_t iana = 0; iana <  fAnalysisContainer->GetEntries(); iana++)
788   {
789     
790     AliAnaCaloTrackCorrBaseClass * ana =  ((AliAnaCaloTrackCorrBaseClass *) fAnalysisContainer->At(iana)) ;
791     
792     if(fMakeHisto) // Analysis with histograms as output on
793     {
794       
795       //Fill container with appropriate histograms
796       TList * templist =  ana ->GetCreateOutputObjects();
797       templist->SetOwner(kFALSE); //Owner is fOutputContainer.
798       
799       for(Int_t i = 0; i < templist->GetEntries(); i++)
800       {
801         
802         //Add only  to the histogram name the name of the task
803         if(   strcmp((templist->At(i))->ClassName(),"TObjString")   )
804         {
805           snprintf(newname,buffersize, "%s%s", (ana->GetAddedHistogramsStringToName()).Data(), (templist->At(i))->GetName());
806           //printf("name %s, new name %s\n",(templist->At(i))->GetName(),newname);
807           ((TH1*) templist->At(i))->SetName(newname);
808         }
809         
810         //Add histogram to general container
811         fOutputContainer->Add(templist->At(i)) ;
812         
813       }
814       
815       delete templist;
816       
817     }// Analysis with histograms as output on
818     
819   }//Loop on analysis defined
820   
821   return fOutputContainer;
822   
823 }
824
825 //___________________________________
826 void AliAnaCaloTrackCorrMaker::Init()
827 {
828   //Init container histograms and other common variables
829   // Fill the output list of histograms during the CreateOutputObjects stage.
830   
831   // Activate debug level in maker
832   if( fAnaDebug >= 0 )
833     (AliAnalysisManager::GetAnalysisManager())->AddClassDebug(this->ClassName(),fAnaDebug);
834   
835   //Initialize reader
836   GetReader()->Init();
837   GetReader()->SetCaloUtils(GetCaloUtils()); // pass the calo utils pointer to the reader
838
839   // Activate debug level in reader
840   if( fReader->GetDebug() >= 0 )
841     (AliAnalysisManager::GetAnalysisManager())->AddClassDebug(fReader->ClassName(), fReader->GetDebug());
842   
843   // Activate debug level in calo utils
844   if( fCaloUtils->GetDebug() >= 0 )
845     (AliAnalysisManager::GetAnalysisManager())->AddClassDebug(fCaloUtils->ClassName(), fCaloUtils->GetDebug());
846   
847   if(!fAnalysisContainer || fAnalysisContainer->GetEntries()==0)
848   {
849     AliWarning("Analysis job list not initialized");
850     return;
851   }
852   
853   for(Int_t iana = 0; iana <  fAnalysisContainer->GetEntries(); iana++)
854   {
855     AliAnaCaloTrackCorrBaseClass * ana =  ((AliAnaCaloTrackCorrBaseClass *) fAnalysisContainer->At(iana)) ;
856     
857     ana->SetReader(fReader);       // Set Reader for each analysis
858     ana->SetCaloUtils(fCaloUtils); // Set CaloUtils for each analysis
859     
860     ana->Init();
861     ana->InitDebug();
862     
863 //    // Activate debug level in analysis
864 //    if( ana->GetDebug() >= 0 )
865 //      (AliAnalysisManager::GetAnalysisManager())->AddClassDebug(ana->ClassName(),ana->GetDebug());
866
867   }//Loop on analysis defined
868   
869 }
870
871 //_____________________________________________
872 void AliAnaCaloTrackCorrMaker::InitParameters()
873 {
874   //Init data members
875   
876   fMakeHisto  = kTRUE;
877   fMakeAOD    = kTRUE;
878   fAnaDebug   = 0; // No debugging info displayed by default
879         
880 }
881
882 //______________________________________________________________
883 void AliAnaCaloTrackCorrMaker::Print(const Option_t * opt) const
884 {
885   //Print some relevant parameters set for the analysis
886         
887   if(! opt)
888     return;
889   
890   printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
891   printf("Debug level                =     %d\n", fAnaDebug   ) ;
892   printf("Produce Histo              =     %d\n", fMakeHisto  ) ;
893   printf("Produce AOD                =     %d\n", fMakeAOD    ) ;
894   printf("Number of analysis tasks   =     %d\n", fAnalysisContainer->GetEntries()) ;
895   
896   if(!strcmp("all",opt))
897   {
898     printf("Print analysis Tasks settings :\n") ;
899     for(Int_t iana = 0; iana<fAnalysisContainer->GetEntries(); iana++)
900     {
901       ((AliAnaCaloTrackCorrBaseClass *) fAnalysisContainer->At(iana))->Print("");
902     }
903     
904     printf("Print analysis Reader settings :\n") ;
905     fReader->Print("");
906     printf("Print analysis Calorimeter Utils settings :\n") ;
907     fCaloUtils->Print("");
908     
909   }
910   
911 }
912
913 //_____________________________________________________________________________________
914 void AliAnaCaloTrackCorrMaker::ProcessEvent(Int_t iEntry, const char * currentFileName)
915 {
916   //Process analysis for this event
917   
918   if(fMakeHisto && !fOutputContainer)
919     AliFatal("Histograms not initialized");
920   
921   AliDebug(1,Form("***  AliAnaCaloTrackCorrMaker::ProcessEvent() Event %d   ***",iEntry));
922   AliDebug(2,Form("Current File Name : %s", currentFileName));
923   //printf("fAODBranchList %p, entries %d\n",fAODBranchList,fAODBranchList->GetEntries());
924   
925   //Each event needs an empty branch
926   TList * aodList = fReader->GetAODBranchList();
927   Int_t nAODBranches = aodList->GetEntries();
928   for(Int_t iaod = 0; iaod < nAODBranches; iaod++)
929   {
930           TClonesArray *tca = dynamic_cast<TClonesArray*> (aodList->At(iaod));
931           if(tca) tca->Clear("C");
932   }
933   
934   //Set geometry matrices before filling arrays, in case recalibration/position calculation etc is needed
935   fCaloUtils->AccessGeometry(fReader->GetInputEvent());
936   
937   //Set the AODB calibration, bad channels etc. parameters at least once
938   fCaloUtils->AccessOADB(fReader->GetInputEvent());
939   
940   //Tell the reader to fill the data in the 3 detector lists
941   Bool_t ok = fReader->FillInputEvent(iEntry, currentFileName);
942   
943   //Access pointers, and trigger mask check needed in mixing case
944   AliAnalysisManager   *manager      = AliAnalysisManager::GetAnalysisManager();
945   AliInputEventHandler *inputHandler = dynamic_cast<AliInputEventHandler*>(manager->GetInputEventHandler());
946   
947   UInt_t isMBTrigger = kFALSE;
948   UInt_t isTrigger   = kFALSE;
949   if(inputHandler)
950   {
951     isMBTrigger = inputHandler->IsEventSelected() & fReader->GetMixEventTriggerMask();
952     isTrigger   = inputHandler->IsEventSelected() & fReader->GetEventTriggerMask();
953   }
954   
955   //Fill trigger control histograms, make sure it is only for triggered events and
956   // not the MB events used for mixing
957   if(fReader->IsEventTriggerAtSEOn() || isTrigger)
958   {
959     fhNEventsIn->Fill(0);
960     FillTriggerControlHistograms();
961   }
962   
963   if(!ok)
964   {
965     AliDebug(1,Form("*** Skip event *** %d",iEntry));
966     fReader->ResetLists();
967     return ;
968   }
969   
970   //Magic line to write events to file
971   if(fReader->WriteDeltaAODToFile())AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kTRUE);
972   
973   //printf(">>>>>>>>>> BEFORE >>>>>>>>>>>\n");
974   //gObjectTable->Print();
975   
976   // Init mag field for tracks in case of ESDs, not really necessary
977   if (!TGeoGlobalMagField::Instance()->GetField() && ((AliESDEvent*) fReader->GetInputEvent()))
978     ((AliESDEvent*)fReader->GetInputEvent())->InitMagneticField();
979   
980   //Loop on analysis algorithms
981   
982   AliDebug(1,"*** Begin analysis ***");
983   
984   Int_t nana = fAnalysisContainer->GetEntries() ;
985   for(Int_t iana = 0; iana <  nana; iana++)
986   {
987     AliAnaCaloTrackCorrBaseClass * ana =  ((AliAnaCaloTrackCorrBaseClass *) fAnalysisContainer->At(iana)) ;
988     
989     ana->ConnectInputOutputAODBranches(); //Sets branches for each analysis
990     
991     //Fill pool for mixed event for the analysis that need it
992     if(!fReader->IsEventTriggerAtSEOn() && isMBTrigger)
993     {
994       ana->FillEventMixPool();
995       if(!isTrigger) continue; // pool filled do not try to fill AODs or histograms if trigger is not MB
996     }
997     
998     //Make analysis, create aods in aod branch and in some cases fill histograms
999     if(fMakeAOD  )  ana->MakeAnalysisFillAOD()  ;
1000     
1001     //Make further analysis with aod branch and fill histograms
1002     if(fMakeHisto)  ana->MakeAnalysisFillHistograms()  ;
1003     
1004   }
1005         
1006   fReader->ResetLists();
1007   
1008   // In case of mixing analysis, non triggered events are used,
1009   // do not fill control histograms for a non requested triggered event
1010   if(!fReader->IsEventTriggerAtSEOn() && !isTrigger)
1011   {
1012     AliDebug(1,"*** End analysis, MB for mixing ***");
1013     return;
1014   }
1015   
1016   FillControlHistograms();
1017   
1018   //printf(">>>>>>>>>> AFTER >>>>>>>>>>>\n");
1019   //gObjectTable->Print();
1020         
1021   AliDebug(1,"*** End analysis ***");
1022   
1023 }
1024
1025 //__________________________________________________________
1026 void AliAnaCaloTrackCorrMaker::Terminate(TList * outputList)
1027 {
1028   //Execute Terminate of analysis
1029   //Do some final plots.
1030   
1031   if (!outputList)
1032   {
1033     AliError("No output list");
1034     return;
1035   }
1036   
1037   for(Int_t iana = 0; iana <  fAnalysisContainer->GetEntries(); iana++)
1038   {
1039     
1040     AliAnaCaloTrackCorrBaseClass * ana =  ((AliAnaCaloTrackCorrBaseClass *) fAnalysisContainer->At(iana)) ;
1041     if(ana->MakePlotsOn())ana->Terminate(outputList);
1042     
1043   }//Loop on analysis defined
1044   
1045 }
1046