]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGGA/CaloTrackCorrelations/macros/QA/AddTaskPi0IMGammaCorrQA.C
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / PWGGA / CaloTrackCorrelations / macros / QA / AddTaskPi0IMGammaCorrQA.C
1
2 AliAnalysisTaskCaloTrackCorrelation *AddTaskPi0IMGammaCorrQA(const TString  calorimeter   = "EMCAL",
3                                                              const Bool_t   simulation    = kFALSE,
4                                                              const TString  collision     = "pp",
5                                                              const TString  suffix        = "default",
6                                                              const Bool_t   qaan          = kFALSE,
7                                                              const Bool_t   hadronan      = kFALSE,
8                                                              const Int_t    minCen        = -1,
9                                                              const Int_t    maxCen        = -1,
10                                                              const Int_t    debugLevel    = -1
11                                                           )
12 {
13   // Creates a CaloTrackCorr task, configures it and adds it to the analysis manager.
14   
15   
16   if(simulation && !suffix.Contains("default"))
17   {
18     printf("AddTaskPi0IMGammaCorrQA - CAREFUL : Triggered events not checked in simulation!! \n");
19     return 0x0;
20   }
21
22   // Get the pointer to the existing analysis manager via the static access method.
23   
24   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
25   if (!mgr) 
26   {
27     ::Error("AddTaskPi0IMGammaCorrQA", "No analysis manager to connect to.");
28     return NULL;
29   }  
30   
31   // Check the analysis type using the event handlers connected to the analysis manager.
32   
33   if (!mgr->GetInputEventHandler()) 
34   {
35     ::Error("AddTaskPi0IMGammaCorrQA", "This task requires an input event handler");
36     return NULL;
37   }
38   
39   // Make sure the B field is enabled for track selection, some cuts need it
40   ((AliInputEventHandler*)mgr->GetInputEventHandler())->SetNeedField(kTRUE);
41   
42   TString inputDataType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
43   
44   // Name for containers
45   
46   TString containerName = Form("%s_%s",calorimeter.Data(), suffix.Data());
47   
48   if(collision!="pp" && maxCen>=0) containerName+=Form("Cen%d_%d",minCen,maxCen);
49     
50   printf("AddTaskPi0IMGammaCorrQA - Container NAME: %s \n",containerName.Data());
51   
52   // #### Configure analysis ####
53     
54   AliAnaCaloTrackCorrMaker * maker = new AliAnaCaloTrackCorrMaker();
55
56   // General frame setting and configuration
57   maker->SetReader   ( ConfigureReader   (inputDataType,collision,minCen,maxCen,simulation,debugLevel) );
58   maker->SetCaloUtils( ConfigureCaloUtils(calorimeter,simulation,debugLevel) );
59   
60   // Analysis tasks setting and configuration
61   Int_t n = 0;//Analysis number, order is important
62   
63   // Photon analysis
64   maker->AddAnalysis(ConfigurePhotonAnalysis(calorimeter,collision,containerName,simulation     ,debugLevel), n++); // Photon cluster selection
65   maker->AddAnalysis(ConfigurePi0Analysis   (calorimeter,collision,containerName,simulation,qaan,debugLevel) ,n++); // Previous photon invariant mass
66
67   if(hadronan)
68   {
69     maker->GetReader()->SwitchOnCTS();
70     maker->AddAnalysis(ConfigureChargedAnalysis(collision,containerName,simulation,debugLevel), n++); // charged tracks plots
71     maker->AddAnalysis(ConfigureHadronCorrelationAnalysis("Photon",calorimeter,collision,containerName,simulation,debugLevel), n++); // Gamma hadron correlation
72   }
73   
74   if(qaan) maker->AddAnalysis(ConfigureQAAnalysis(calorimeter,collision,simulation,debugLevel),n++);
75   
76   maker->SetAnaDebug(debugLevel)  ;
77   maker->SwitchOnHistogramsMaker()  ;
78   maker->SwitchOnAODsMaker() ;
79   maker->SwitchOffDataControlHistograms();
80   if(suffix.Contains("EMC"))
81     maker->SwitchOnDataControlHistograms();
82
83   if(debugLevel > 0) maker->Print("");
84   
85   // Create task
86   
87   TString taskName =Form("Pi0IM_GammaTrackCorr_%s",containerName.Data());
88   
89   AliAnalysisTaskCaloTrackCorrelation * task = new AliAnalysisTaskCaloTrackCorrelation (taskName);
90   task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
91   task->SetDebugLevel(debugLevel);
92   //task->SetBranches("ESD:AliESDRun.,AliESDHeader");
93   //task->SetBranches("AOD:header,tracks,vertices,emcalCells,caloClusters");
94   task->SetAnalysisMaker(maker);
95   mgr->AddTask(task);
96   
97   //Create containers
98   
99   TString outputfile = AliAnalysisManager::GetCommonFileName();
100   
101   AliAnalysisDataContainer *cout_pc   = mgr->CreateContainer(taskName, TList::Class(),
102                                                              AliAnalysisManager::kOutputContainer, 
103                                                              Form("%s:%s",outputfile.Data(),taskName.Data()));
104         
105   AliAnalysisDataContainer *cout_cuts = mgr->CreateContainer(Form("Param_%s",taskName.Data()), TList::Class(),
106                                                              AliAnalysisManager::kParamContainer, 
107                                                              Form("%s_Parameters.root",taskName.Data()));
108   
109   // Create ONLY the output containers for the data produced by the task.
110   // Get and connect other common input/output containers via the manager as below
111   //==============================================================================
112   mgr->ConnectInput  (task, 0, mgr->GetCommonInputContainer());
113   mgr->ConnectOutput (task, 1, cout_pc);
114   mgr->ConnectOutput (task, 2, cout_cuts);
115   
116   return task;
117 }
118
119 //___________________________________________________________________________
120 AliCaloTrackReader * ConfigureReader(TString inputDataType, TString collision,
121                                      Int_t   minCen,        Int_t maxCen,
122                                      Bool_t  simulation,    Int_t debugLevel)
123 {
124   
125   AliCaloTrackReader * reader = 0;
126   if     (inputDataType=="AOD")
127     reader = new AliCaloTrackAODReader();
128   else if(inputDataType=="ESD")
129     reader = new AliCaloTrackESDReader();
130   else 
131     printf("AliCaloTrackReader::ConfigureReader() - Data combination not known input Data=%s\n",
132            inputDataType.Data());
133   
134   reader->SetDebug(debugLevel);//10 for lots of messages
135
136   // MC settings
137   if(simulation)
138   {
139     if(inputDataType == "ESD")
140     {
141       reader->SwitchOnStack();
142       reader->SwitchOffAODMCParticles();
143     }
144     else if(inputDataType == "AOD")
145     {
146       reader->SwitchOffStack();
147       reader->SwitchOnAODMCParticles();
148     }
149   }
150   
151   //------------------------
152   // Detector input filling
153   //------------------------
154   
155   //Min cluster/track E
156   reader->SetEMCALEMin(0.3); 
157   reader->SetEMCALEMax(1000); 
158   reader->SetPHOSEMin(0.3);
159   reader->SetPHOSEMax(1000);
160   reader->SetCTSPtMin(0.2);
161   reader->SetCTSPtMax(1000);
162
163   // Time cut off
164   reader->SwitchOffUseTrackTimeCut();
165   reader->SwitchOffUseParametrizedTimeCut();
166   reader->SwitchOffUseEMCALTimeCut() ;
167   reader->SetEMCALTimeCut(-1e10,1e10); // Open time cut
168   reader->SetTrackTimeCut(-1e10,1e10);
169
170   reader->SwitchOnFiducialCut();
171   
172   // Tracks
173   reader->SwitchOffCTS();
174   reader->SwitchOffRejectNoTrackEvents();
175   reader->SwitchOffRecalculateVertexBC();
176   reader->SwitchOffVertexBCEventSelection();
177   reader->SwitchOffUseTrackDCACut();
178   //reader->SetTrackDCACut(0,0.0105);
179   //reader->SetTrackDCACut(1,0.035);
180   //reader->SetTrackDCACut(2,1.1);
181   
182   if(inputDataType=="ESD")
183   {
184     gROOT->LoadMacro("$ALICE_ROOT/PWGJE/macros/CreateTrackCutsPWGJE.C");
185 //    if(year > 2010)
186 //    {
187       //Hybrids 2011
188       AliESDtrackCuts * esdTrackCuts  = CreateTrackCutsPWGJE(10001008);
189       reader->SetTrackCuts(esdTrackCuts);
190       AliESDtrackCuts * esdTrackCuts2 = CreateTrackCutsPWGJE(10011008);
191       reader->SetTrackComplementaryCuts(esdTrackCuts2);
192 //    }
193 //    else
194 //    {
195 //      //Hybrids 2010
196 //      AliESDtrackCuts * esdTrackCuts  = CreateTrackCutsPWGJE(10001006);
197 //      reader->SetTrackCuts(esdTrackCuts);
198 //      AliESDtrackCuts * esdTrackCuts2 = CreateTrackCutsPWGJE(10041006);
199 //      reader->SetTrackComplementaryCuts(esdTrackCuts2);
200 //    }
201   }
202   else if(inputDataType=="AOD")
203   {
204     reader->SwitchOnAODHybridTrackSelection(); // Check that the AODs have Hybrids!!!!
205     reader->SetTrackStatus(AliVTrack::kITSrefit);    
206   }
207   
208   // Calorimeter
209   
210   reader->SetEMCALClusterListName("");
211   reader->SwitchOffClusterRecalculation();
212   
213   reader->SwitchOnEMCALCells();
214   reader->SwitchOnEMCAL();
215
216   reader->SwitchOnPHOSCells();
217   reader->SwitchOnPHOS();
218   
219   //-----------------
220   // Event selection
221   //-----------------
222   
223   reader->SwitchOnEventTriggerAtSE();
224   
225   reader->SetZvertexCut(10.);
226   reader->SwitchOnPrimaryVertexSelection(); // and besides primary vertex
227   reader->SwitchOffPileUpEventRejection();  // remove pileup
228   reader->SwitchOffV0ANDSelection() ;       // and besides v0 AND
229   
230   if(collision=="PbPb")
231   {
232     reader->SetCentralityBin(minCen,maxCen); // Accept all events, if not select range
233     reader->SetCentralityOpt(100);  // 10 (c= 0-10, 10-20 ...), 20  (c= 0-5, 5-10 ...) or 100 (c= 1, 2, 3 ..)
234   }
235   
236   if(debugLevel > 0) reader->Print("");
237   
238   return reader;
239   
240 }
241
242 //_______________________________________________________________________________________________
243 AliCalorimeterUtils* ConfigureCaloUtils(TString calorimeter, Bool_t simulation, Int_t debugLevel)
244 {
245   
246   AliCalorimeterUtils *cu = new AliCalorimeterUtils;
247   cu->SetDebug(debugLevel);
248   
249   // Remove clusters close to borders, at least max energy cell is 1 cell away 
250   cu->SetNumberOfCellsFromEMCALBorder(1);
251   cu->SetNumberOfCellsFromPHOSBorder(2);
252   
253   // Search of local maxima in cluster
254   cu->SetLocalMaximaCutE(0.1);
255   cu->SetLocalMaximaCutEDiff(0.03);
256
257   cu->SwitchOffClusterPlot();
258   cu->SwitchOffRecalculateClusterTrackMatching();
259   
260   cu->SwitchOnBadChannelsRemoval() ;
261   
262   //EMCAL settings
263
264   if(!simulation)
265     cu->SwitchOnLoadOwnEMCALGeometryMatrices();
266   
267   AliEMCALRecoUtils * recou = cu->GetEMCALRecoUtils();
268   cu->SwitchOffRecalibration(); // Check the reader if it is taken into account during filtering
269   cu->SwitchOffRunDepCorrection();
270
271   gROOT->LoadMacro("$ALICE_ROOT/PWGGA/EMCALTasks/macros/ConfigureEMCALRecoUtils.C");
272   ConfigureEMCALRecoUtils(recou,
273                           simulation,
274                           kTRUE,//kExotic,
275                           kTRUE,//kNonLinearity,
276                           kFALSE,//kCalibE,
277                           kTRUE,//kBadMap,
278                           kFALSE);//kCalibT
279   recou->SetExoticCellDiffTimeCut(50.);
280
281   cu->SwitchOnCorrectClusterLinearity();
282
283   if(calorimeter=="PHOS")
284     cu->SetNumberOfSuperModulesUsed(3);
285   else
286     cu->SetNumberOfSuperModulesUsed(10);
287   
288   // PHOS 
289   cu->SwitchOffLoadOwnPHOSGeometryMatrices();
290     
291   if(debugLevel > 0) cu->Print("");
292   
293   return cu;
294   
295 }
296
297 //_______________________________________________________________________________
298 AliAnaPhoton* ConfigurePhotonAnalysis(TString calorimeter, TString collision,
299                                       TString containerName,
300                                       Bool_t simulation, Int_t debugLevel)
301 {
302   
303   AliAnaPhoton *ana = new AliAnaPhoton();
304   ana->SetDebug(debugLevel); //10 for lots of messages
305   
306   // cluster selection cuts
307   
308   ana->SwitchOffFiducialCut();
309
310   ana->SetCalorimeter(calorimeter);
311   
312   if(calorimeter == "PHOS")
313   {
314     ana->SetNCellCut(2);// At least 3 cells
315     ana->SetMinPt(0.3);
316     ana->SetMinDistanceToBadChannel(2, 4, 5);
317     ana->SetTimeCut(-1e10,1e10); // open cut
318   }
319   else 
320   {//EMCAL
321     ana->SetNCellCut(1);// At least 2 cells
322     ana->SetMinEnergy(0.3); // avoid mip peak at E = 260 MeV
323     ana->SetMaxEnergy(1000); 
324     ana->SetTimeCut(-1e10,1e10); // open cut, usual time window of [425-825] ns if time recalibration is off 
325     // restrict to less than 100 ns when time calibration is on 
326     ana->SetMinDistanceToBadChannel(2, 4, 6); 
327     // Not useful if M02 cut is already strong
328     ana->SetNLMCut(1, 2) ;
329   }
330   
331   ana->SwitchOnTrackMatchRejection() ;
332   ana->SwitchOffTMHistoFill() ;
333
334   
335   //PID cuts (shower shape)
336   ana->SwitchOnCaloPID(); // do PID selection, unless specified in GetCaloPID, selection not based on bayesian
337   AliCaloPID* caloPID = ana->GetCaloPID();
338   //Not used in bayesian
339   
340   //EMCAL
341   caloPID->SetEMCALLambda0CutMax(0.4); // Rather open
342   caloPID->SetEMCALLambda0CutMin(0.10);
343   
344   caloPID->SetEMCALDEtaCut(0.025);
345   caloPID->SetEMCALDPhiCut(0.030);
346     
347   //PHOS
348   caloPID->SetPHOSDispersionCut(2.5);
349   caloPID->SetPHOSRCut(2.);
350   
351   ana->SwitchOnFillShowerShapeHistograms();  // Filled before photon shower shape selection
352   //if(!simulation)ana->SwitchOnFillPileUpHistograms();
353
354   // Input / output delta AOD settings
355   ana->SetOutputAODName(Form("Photon%s",containerName.Data()));
356   ana->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
357   ana->SetInputAODName (Form("Photon%s",containerName.Data()));
358
359   //Set Histograms name tag, bins and ranges
360   
361   ana->AddToHistogramsName("AnaPhoton_");
362   SetHistoRangeAndNBins(ana->GetHistogramRanges(),calorimeter,collision); // see method below
363   
364   // Number of particle type MC histograms
365   ana->FillNOriginHistograms(7);
366   ana->FillNPrimaryHistograms(4);
367   
368   if(simulation) ana->SwitchOnDataMC();
369   
370   if(debugLevel > 0 ) ana->Print("");
371   
372   return ana;
373   
374 }
375
376 //_________________________________________________________________________
377 AliAnaPi0* ConfigurePi0Analysis(TString calorimeter, TString collision,
378                                 TString containerName, Bool_t simulation,
379                                 Bool_t qaan, Int_t debugLevel)
380 {
381   
382   AliAnaPi0 *ana = new AliAnaPi0();
383   
384   ana->SetDebug(debugLevel);//10 for lots of messages
385   
386   // Input delta AOD settings
387   ana->SetInputAODName(Form("Photon%s",containerName.Data()));
388   
389   // Calorimeter settings
390   ana->SetCalorimeter(calorimeter);
391   
392   //settings for pp collision mixing
393   ana->SwitchOnOwnMix(); //Off when mixing done with general mixing frame
394   
395   // Cuts 
396   if(calorimeter=="EMCAL") ana->SetPairTimeCut(70);
397   
398   if     (collision == "pp"  )
399   {
400     ana->SetNCentrBin(1);
401     ana->SetNZvertBin(10);
402     ana->SetNRPBin(1);
403     ana->SetNMaxEvMix(100);    
404   }
405   else if(collision =="PbPb")
406   {
407     ana->SetNCentrBin(10);
408     ana->SetNZvertBin(10);
409     ana->SetNRPBin(4);
410     ana->SetNMaxEvMix(10);
411   }
412   else if(collision =="pPb")
413   {
414     ana->SetNCentrBin(1);
415     ana->SetNZvertBin(10);
416     ana->SetNRPBin(4);
417     ana->SetNMaxEvMix(100);
418   }
419
420   ana->SwitchOffMultipleCutAnalysis();
421   ana->SwitchOnSMCombinations();
422   ana->SwitchOffFillAngleHisto();
423   ana->SwitchOffFillOriginHisto();
424
425   ana->SetNPIDBits(1);
426   
427   //Set Histograms name tag, bins and ranges
428   
429   ana->AddToHistogramsName("AnaPi0_");
430   SetHistoRangeAndNBins(ana->GetHistogramRanges(),calorimeter,collision); // see method below
431
432   if(simulation) ana->SwitchOnDataMC();
433
434   if(debugLevel > 0) ana->Print("");
435   
436   return ana;
437   
438 }
439
440 //___________________________________________________________________________________
441 AliAnaChargedParticles* ConfigureChargedAnalysis(TString collision,TString containerName,
442                                                  Bool_t simulation, Int_t debugLevel)
443 {
444   
445   AliAnaChargedParticles *ana = new AliAnaChargedParticles();
446   ana->SetDebug(debugLevel); //10 for lots of messages
447   
448   // selection cuts
449   
450   ana->SetMinPt(0.5);
451   ana->SwitchOnFiducialCut();
452   ana->GetFiducialCut()->SetSimpleCTSFiducialCut(0.8, 0, 360) ; //more restrictive cut in reader and after in isolation
453   
454   ana->SwitchOffFillVertexBC0Histograms() ;
455   //if(!simulation) ana->SwitchOnFillPileUpHistograms();
456   
457   // Input / output delta AOD settings
458   
459   ana->SetOutputAODName(Form("Hadron%s",containerName.Data()));
460   ana->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
461   ana->SetInputAODName(Form("Hadron%s",containerName.Data()));
462
463   //Set Histograms name tag, bins and ranges
464   
465   ana->AddToHistogramsName("AnaHadrons_");
466   SetHistoRangeAndNBins(ana->GetHistogramRanges(),"",collision); // see method below
467   
468   ana->GetHistogramRanges()->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 200) ;
469   ana->GetHistogramRanges()->SetHistoEtaRangeAndNBins(-1.5, 1.5, 300) ;
470   
471   if(debugLevel > 0) ana->Print("");
472   
473   return ana;
474   
475 }
476
477 //__________________________________________________________________________________________________________
478 AliAnaParticleHadronCorrelation* ConfigureHadronCorrelationAnalysis(TString particle,  TString calorimeter,
479                                                                     TString collision, TString containerName,
480                                                                     Bool_t simulation, Int_t debugLevel)
481 {
482   
483   AliAnaParticleHadronCorrelation *ana = new AliAnaParticleHadronCorrelation();
484   ana->SetDebug(debugLevel);
485   
486   ana->SetTriggerPtRange(5,100);
487   ana->SetAssociatedPtRange(0.2,100);
488   //ana->SetDeltaPhiCutRange( TMath::Pi()/2,3*TMath::Pi()/2 ); //[90 deg, 270 deg]
489   ana->SetDeltaPhiCutRange  (TMath::DegToRad()*120.,TMath::DegToRad()*240.);
490   ana->SetUeDeltaPhiCutRange(TMath::DegToRad()*60. ,TMath::DegToRad()*120.);
491   ana->SwitchOffFillEtaGapHistograms();
492
493   ana->SetNAssocPtBins(4);
494   ana->SetAssocPtBinLimit(0, 0.5) ;
495   ana->SetAssocPtBinLimit(1, 2) ;
496   ana->SetAssocPtBinLimit(2, 5) ;
497   ana->SetAssocPtBinLimit(3, 10) ;
498   ana->SetAssocPtBinLimit(4, 20) ;
499
500   ana->SelectIsolated(kFALSE); // do correlation with isolated photons
501
502   //if(!simulation) ana->SwitchOnFillPileUpHistograms();
503   
504   ana->SwitchOnAbsoluteLeading();  // Select trigger leading particle of all the selected tracks
505   ana->SwitchOffNearSideLeading(); // Select trigger leading particle of all the particles at +-90 degrees, default
506   
507   //ana->SwitchOnLeadHadronSelection();
508   //ana->SetLeadHadronPhiCut(TMath::DegToRad()*100., TMath::DegToRad()*260.);
509   //ana->SetLeadHadronPtCut(0.5, 100);
510
511   
512   // Mixing with own pool
513   ana->SwitchOffOwnMix();
514   
515   ana->SetNZvertBin(20);
516   ana->SwitchOffCorrelationVzBin() ;
517   ana->SwitchOffFillHighMultiplicityHistograms();
518   
519   if(collision=="pp")
520   {
521     ana->SetNMaxEvMix(100);    
522     ana->SwitchOnTrackMultBins();
523     ana->SetNTrackMultBin(10); // same as SetNCentrBin(10);
524     ana->SetNRPBin(1);
525   }
526   else 
527   {
528     ana->SetNMaxEvMix(10);    
529     ana->SwitchOffTrackMultBins(); // centrality bins
530     ana->SetNCentrBin(10); 
531     ana->SetNRPBin(3);
532   }
533   
534   // Input / output delta AOD settings
535   
536   ana->SetInputAODName(Form("%s%s",particle.Data(),containerName.Data()));
537   ana->SetAODObjArrayName(Form("%sHadronCorr_%s",particle.Data(),containerName.Data()));
538   
539   ana->SwitchOffPi0TriggerDecayCorr();
540   ana->SwitchOffDecayTriggerDecayCorr();
541   ana->SwitchOffNeutralCorr(); // Do only correlation with TPC
542   ana->SwitchOffHMPIDCorrelation();
543   ana->SwitchOffFillBradHistograms();
544   
545   // Underlying event
546   ana->SwitchOffSeveralUECalculation();
547   ana->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
548   
549   //Set Histograms name tag, bins and ranges
550   
551   ana->AddToHistogramsName(Form("Ana%sHadronCorr_",particle.Data()));
552   SetHistoRangeAndNBins(ana->GetHistogramRanges(),calorimeter, collision); // see method below
553   
554   if(simulation) ana->SwitchOnDataMC();
555   
556   if(debugLevel > 0) ana->Print("");
557  
558   return ana;
559   
560 }
561
562 //________________________________________________________________________________
563 AliAnaCalorimeterQA* ConfigureQAAnalysis(TString calorimeter,  TString collision,
564                                          Bool_t simulation,    Int_t debugLevel)
565 {
566   
567   AliAnaCalorimeterQA *ana = new AliAnaCalorimeterQA();
568   ana->SetDebug(debugLevel); //10 for lots of messages
569   ana->SetCalorimeter(calorimeter);
570   
571   ana->SetTimeCut(-1e10,1e10); // Open time cut
572   ana->SwitchOnCorrelation();
573   ana->SwitchOffStudyBadClusters() ;
574   ana->SwitchOffFiducialCut();
575   ana->SwitchOffFillAllTH3Histogram();
576   ana->SwitchOffFillAllPositionHistogram();
577   ana->SwitchOffFillAllPositionHistogram2();
578   ana->SwitchOffStudyBadClusters();
579   ana->SwitchOffStudyClustersAsymmetry();
580   ana->SwitchOffStudyWeight();
581   ana->SwitchOnFillAllTrackMatchingHistogram();
582   ana->SwitchOnFillAllCellTimeHisto() ;
583   
584   ana->AddToHistogramsName("QA_"); //Begining of histograms name
585   SetHistoRangeAndNBins(ana->GetHistogramRanges(),calorimeter, collision); // see method below
586   
587   if(simulation) ana->SwitchOnDataMC();
588   
589   if(debugLevel > 0) ana->Print("");
590   
591   return ana;
592   
593 }
594
595
596 //________________________________________________________
597 void SetHistoRangeAndNBins (AliHistogramRanges* histoRanges,
598                             TString calorimeter, TString collision)
599 {
600   // Set common bins for all analysis and MC histograms filling
601     
602   histoRanges->SetHistoPtRangeAndNBins(0, 100, 200) ; // Energy and pt histograms
603   
604   if(calorimeter=="EMCAL")
605   {
606 //    if(year==2010)
607 //    {
608 //      histoRanges->SetHistoPhiRangeAndNBins(78*TMath::DegToRad(), 122*TMath::DegToRad(), 78) ;
609 //      histoRanges->SetHistoXRangeAndNBins(-230,90,120); // QA
610 //      histoRanges->SetHistoYRangeAndNBins(370,450,40);  // QA
611 //    }
612 //    else if(year==2011)
613 //    {           
614 //      histoRanges->SetHistoPhiRangeAndNBins(78*TMath::DegToRad(), 182*TMath::DegToRad(), 108) ;
615 //      histoRanges->SetHistoXRangeAndNBins(-600,90,200); // QA
616 //      histoRanges->SetHistoYRangeAndNBins(100,450,100); // QA
617 //    }
618 //    else
619     {
620       histoRanges->SetHistoPhiRangeAndNBins(78*TMath::DegToRad(), 190*TMath::DegToRad(), 122) ;
621       histoRanges->SetHistoXRangeAndNBins(-100,90,200); // QA
622       histoRanges->SetHistoYRangeAndNBins(50,450,100);  // QA
623     }
624
625     histoRanges->SetHistoEtaRangeAndNBins(-0.72, 0.72, 144) ;
626   }
627   else
628   {
629     histoRanges->SetHistoPhiRangeAndNBins(260*TMath::DegToRad(), 320*TMath::DegToRad(), 60) ;
630     histoRanges->SetHistoEtaRangeAndNBins(-0.13, 0.13, 130) ;
631   }
632   
633   histoRanges->SetHistoShowerShapeRangeAndNBins(-0.1, 4.9, 500);
634   
635   // Invariant mass histoRangeslysis
636   histoRanges->SetHistoMassRangeAndNBins(0., 1., 200) ;
637   histoRanges->SetHistoAsymmetryRangeAndNBins(0., 1. , 100) ;
638   
639   // check if time calibration is on
640   histoRanges->SetHistoTimeRangeAndNBins(-1000.,1000,500);
641   //histoRanges->SetHistoTimeRangeAndNBins(-400.,400,400);
642   histoRanges->SetHistoDiffTimeRangeAndNBins(-200, 200, 800);
643   
644   // track-cluster residuals
645   histoRanges->SetHistoTrackResidualEtaRangeAndNBins(-0.15,0.15,300);
646   histoRanges->SetHistoTrackResidualPhiRangeAndNBins(-0.15,0.15,300);
647   histoRanges->SetHistodRRangeAndNBins(0.,0.15,150);//QA
648
649   // QA, electron, charged
650   histoRanges->SetHistoPOverERangeAndNBins(0,  2. ,200);
651   histoRanges->SetHistodEdxRangeAndNBins  (0.,200.0,200);
652   
653   // QA
654   histoRanges->SetHistoFinePtRangeAndNBins(0, 10, 200) ; // bining for fhAmpId
655   histoRanges->SetHistoVertexDistRangeAndNBins(0.,500.,500);
656   histoRanges->SetHistoZRangeAndNBins(-400,400,200);
657   histoRanges->SetHistoRRangeAndNBins(400,450,25);
658   histoRanges->SetHistoV0SignalRangeAndNBins(0,5000,500);
659   histoRanges->SetHistoV0MultiplicityRangeAndNBins(0,5000,500);
660   
661   // QA, correlation
662   if(collision=="PbPb")
663   {
664     histoRanges->SetHistoNClusterCellRangeAndNBins(0,100,100);
665     histoRanges->SetHistoNClustersRangeAndNBins(0,500,50);
666     histoRanges->SetHistoTrackMultiplicityRangeAndNBins(0,2000,200);
667   }
668   else
669   {
670     histoRanges->SetHistoNClusterCellRangeAndNBins(0,50,50);
671     histoRanges->SetHistoNClustersRangeAndNBins(0,50,50);
672     histoRanges->SetHistoTrackMultiplicityRangeAndNBins(0,200,200);
673   }
674
675   // xE, zT
676   histoRanges->SetHistoRatioRangeAndNBins(0.,2.,200);
677   histoRanges->SetHistoHBPRangeAndNBins  (0.,10.,200);
678   
679   // Isolation
680   histoRanges->SetHistoPtInConeRangeAndNBins(0, 50 , 250);
681   histoRanges->SetHistoPtSumRangeAndNBins   (0, 100, 250);
682   
683 }
684