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