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