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