]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/macros/AddTaskPartCorr.C
open default time cut in AliAnaPhoton, specially the minimum time from -1 ns to ...
[u/mrichter/AliRoot.git] / PWG4 / macros / AddTaskPartCorr.C
1
2 Bool_t  kPrint         = kFALSE;
3 Bool_t  kSimulation    = kFALSE;
4 Bool_t  kUseKinematics = kFALSE;
5 Bool_t  kOutputAOD     = kFALSE;
6 Int_t   kRunNumber     = 0;
7 Int_t   kYears         = 2011;
8 TString kCollisions    = "pp";
9 TString kTrig          = "EMC7" ;
10 TString kClusterArray  = "";
11 TString kData          = "ESD";
12 TString kInputDataType = "ESD";
13 TString kCalorimeter   = "EMCAL";
14
15 AliAnalysisTaskParticleCorrelation *AddTaskPartCorr(
16                                                     const TString data          = "AOD",
17                                                     const TString calorimeter   = "EMCAL", 
18                                                     const Bool_t  printSettings = kFALSE,
19                                                     const Bool_t  simulation    = kFALSE,
20                                                     const Bool_t  outputAOD     = kFALSE, 
21                                                     const TString outputfile    = "",
22                                                     const Int_t   year          = 2010,
23                                                     const Int_t   run           = 0,
24                                                     const TString col           = "pp", 
25                                                     const TString trigger       = "MB", 
26                                                     const TString clustersArray = "V1" 
27                                                     )
28 {
29   // Creates a PartCorr task, configures it and adds it to the analysis manager.
30   
31   kPrint         = printSettings;
32   kSimulation    = simulation;
33   kRunNumber     = run;
34   kYears         = year;
35   kCollisions    = col;
36   kTrig          = trigger;
37   kClusterArray  = clustersArray;
38   kData          = data;
39   kCalorimeter   = calorimeter;
40   kOutputAOD     = outputAOD;
41   
42   // Get the pointer to the existing analysis manager via the static access method.
43   
44   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
45   if (!mgr) {
46     ::Error("AddTask", "No analysis manager to connect to.");
47     return NULL;
48   }  
49   
50   // Check the analysis type using the event handlers connected to the analysis manager.
51   
52   if (!mgr->GetInputEventHandler()) {
53     ::Error("AddTask", "This task requires an input event handler");
54     return NULL;
55   }
56   kInputDataType = "AOD";
57   if(!kData.Contains("delta"))
58     kInputDataType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
59   
60   if(kSimulation) { 
61     kUseKinematics = (mgr->GetMCtruthEventHandler())?kTRUE:kFALSE; 
62     if (!kUseKinematics && data=="AOD" && kInputDataType != "ESD") kUseKinematics = kTRUE; //AOD primary should be available ... 
63   } 
64   
65   cout<<"********* ACCESS KINE? "<<kUseKinematics<<endl;
66   
67   // #### Configure analysis ####
68     
69   AliAnaPartCorrMaker * maker = new AliAnaPartCorrMaker();
70   
71   // General frame setting and configuration
72   maker->SetReader   (ConfigureReader()   ); 
73   maker->SetCaloUtils(ConfigureCaloUtils()); 
74   
75   // Analysis tasks setting and configuration
76   Int_t n = 0;//Analysis number, order is important
77   
78   maker->AddAnalysis(ConfigureQAAnalysis()    , n++);  
79
80   // Isolation settings
81   Int_t partInCone = AliIsolationCut::kNeutralAndCharged;//kOnlyCharged;
82   Int_t thresType  = AliIsolationCut::kSumPtFracIC;      // kPtThresIC;
83   
84   if(kClusterArray==""  && kCalorimeter!="PHOS")
85   {
86     //Trigger on tracks, do only once, tracks do not depend on clusterizer
87     maker->AddAnalysis(ConfigureChargedAnalysis(), n++);                                // track selection
88     maker->AddAnalysis(ConfigureIsolationAnalysis("Hadron",partInCone,thresType), n++); // track isolation
89     maker->AddAnalysis(ConfigureHadronCorrelationAnalysis("Hadron",kFALSE), n++);       // track-track correlation
90     maker->AddAnalysis(ConfigureHadronCorrelationAnalysis("Hadron",kTRUE) , n++);       // Isolated track-track correlation
91   }  
92   else
93   {
94     maker->AddAnalysis(ConfigurePhotonAnalysis(), n++); // Photon cluster selection
95     maker->AddAnalysis(ConfigurePi0Analysis()   , n++); // Pi0 invariant mass analysis
96     maker->AddAnalysis(ConfigurePi0EbEAnalysis("Pi0", AliAnaPi0EbE::kIMCalo), n++); // Pi0 event by event selection, and photon tagging from decay
97     maker->AddAnalysis(ConfigurePi0EbEAnalysis("Eta", AliAnaPi0EbE::kIMCalo), n++); // Eta event by event selection, and photon tagging from decay
98     
99     //maker->AddAnalysis(ConfigurePi0EbEAnalysis("Pi0", AliAnaPi0EbE::kIMCaloTracks), n++); // Pi0 (calo+conversion) event by event selection, 
100     // and photon tagging from decay, need to execute at the same time conversions analysis
101     
102     maker->AddAnalysis(ConfigureIsolationAnalysis("Photon",partInCone,thresType), n++); // Photon isolation
103     maker->AddAnalysis(ConfigureIsolationAnalysis("Pi0",   partInCone,thresType), n++); // Pi0 isolation
104     
105     maker->AddAnalysis(ConfigureHadronCorrelationAnalysis("Photon",kFALSE), n++); // Gamma hadron correlation
106     maker->AddAnalysis(ConfigureHadronCorrelationAnalysis("Photon",kTRUE) , n++); // Isolated gamma hadron correlation
107     maker->AddAnalysis(ConfigureHadronCorrelationAnalysis("Pi0"   ,kFALSE), n++); // Pi0 hadron correlation
108     maker->AddAnalysis(ConfigureHadronCorrelationAnalysis("Pi0"   ,kTRUE) , n++); // Isolated pi0 hadron correlation
109   }
110   
111   
112   maker->SetAnaDebug(-1)  ;
113   maker->SwitchOnHistogramsMaker()  ;
114   if(kData.Contains("delta")) maker->SwitchOffAODsMaker() ;
115   else                        maker->SwitchOnAODsMaker()  ;
116         
117   if(kPrint) maker->Print("");
118   
119   printf("<< End Configuration of %d analysis for calorimeter %s >>\n",n, kCalorimeter.Data());
120   
121   // Create task
122   
123   AliAnalysisTaskParticleCorrelation * task = new AliAnalysisTaskParticleCorrelation (Form("PartCorr%s_Trig%s_Cl%s",kCalorimeter.Data(),kTrig.Data(),kClusterArray.Data()));
124   task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
125   //task->SetDebugLevel(-1);
126   task->SetBranches("ESD:AliESDRun.,AliESDHeader"); //just a trick to get Constantin's analysis to work
127   task->SetAnalysisMaker(maker);
128   mgr->AddTask(task);
129   
130   //Create containers
131   
132   if(outputfile.Length()==0)outputfile = AliAnalysisManager::GetCommonFileName(); 
133   
134   AliAnalysisDataContainer *cout_pc   = mgr->CreateContainer(Form("%s_Trig%s_Cl%s",kCalorimeter.Data(),kTrig.Data(),kClusterArray.Data()), TList::Class(), 
135                                                              AliAnalysisManager::kOutputContainer, 
136                                                              Form("%s",outputfile.Data()));
137         
138   AliAnalysisDataContainer *cout_cuts = mgr->CreateContainer(Form("%sCuts_Trig%s_Cl%s",kCalorimeter.Data(),kTrig.Data(), kClusterArray.Data()), TList::Class(), 
139                                                              AliAnalysisManager::kParamContainer, 
140                                                              Form("%s",outputfile.Data()));
141   // Create ONLY the output containers for the data produced by the task.
142   // Get and connect other common input/output containers via the manager as below
143   //==============================================================================
144   mgr->ConnectInput  (task, 0, mgr->GetCommonInputContainer());
145   // AOD output slot will be used in a different way in future
146   if(!kData.Contains("delta")   && outputAOD) mgr->ConnectOutput (task, 0, mgr->GetCommonOutputContainer());
147   mgr->ConnectOutput (task, 1, cout_pc);
148   mgr->ConnectOutput (task, 2, cout_cuts);
149   
150   
151   if(kTrig=="EMC7"){
152     printf("PartCorr trigger EMC7\n");
153     task->SelectCollisionCandidates(AliVEvent::kEMC7);
154   }
155   else if (kTrig=="INT7"){
156     printf("PartCorr trigger INT7\n");
157     task->SelectCollisionCandidates(AliVEvent::kINT7);
158   }
159   else if(kTrig=="EMC1"){
160     printf("PartCorr trigger EMC1\n");
161     task->SelectCollisionCandidates(AliVEvent::kEMC1);
162   }
163   else if(kTrig=="MB"){
164     printf("PartCorr trigger MB\n");
165     task->SelectCollisionCandidates(AliVEvent::kMB);
166   }  
167   else if(kTrig=="PHOS"){
168     printf("PartCorr trigger PHOS\n");
169     task->SelectCollisionCandidates(AliVEvent::kPHI7);
170   }
171   
172   return task;
173 }
174
175 //____________________________________
176 AliCaloTrackReader * ConfigureReader()
177 {
178   
179   AliCaloTrackReader * reader = 0;
180   if     (kData.Contains("AOD"))   reader = new AliCaloTrackAODReader();
181   else if(kData=="ESD")            reader = new AliCaloTrackESDReader();
182   else if(kData=="MC" && 
183           kInputDataType == "ESD") reader = new AliCaloTrackMCReader();
184   
185   reader->SetDebug(-1);//10 for lots of messages
186   
187   //Delta AOD?
188   //reader->SetDeltaAODFileName("");
189   if(kOutputAOD) reader->SwitchOnWriteDeltaAOD()  ;
190   
191   // MC settings
192   if(kUseKinematics){
193     if(kInputDataType == "ESD"){
194       reader->SwitchOnStack();          
195       reader->SwitchOffAODMCParticles(); 
196     }
197     else if(kInputDataType == "AOD"){
198       reader->SwitchOffStack();          
199       reader->SwitchOnAODMCParticles(); 
200     }
201   }  
202   
203   //------------------------
204   // Detector input filling
205   //------------------------
206   
207   //Min cluster/track E
208   reader->SetEMCALEMin(0.5); 
209   reader->SetEMCALEMax(1000); 
210   reader->SetPHOSEMin(0.3);
211   reader->SetPHOSEMax(1000);
212   reader->SetCTSPtMin(0.1);
213   reader->SetCTSPtMax(1000);
214   
215   reader->SwitchOffFiducialCut();
216   
217   // Tracks
218   reader->SwitchOnCTS();
219   gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/CreateTrackCutsPWG4.C"); 
220   AliESDtrackCuts * esdTrackCuts = CreateTrackCutsPWG4(10041004);   //no ITSrefit
221   reader->SetTrackCuts(esdTrackCuts);
222   
223   // Calorimeter
224   
225   reader->SetEMCALClusterListName(kClusterArray);
226   if(kClusterArray == "") {
227     printf("**************** Standard EMCAL clusters branch analysis **************** \n");
228     reader->SwitchOnClusterRecalculation();
229     // Check in ConfigureCaloUtils that the recalibration and bad map are ON 
230   }
231   else {
232     printf("**************** Input for analysis is Clusterizer %s **************** \n", kClusterArray.Data());
233     reader->SwitchOffClusterRecalculation();
234   }  
235   
236   //if(kCalorimeter == "EMCAL") {
237     reader->SwitchOnEMCALCells();  
238     reader->SwitchOnEMCAL();
239   //}
240   //if(kCalorimeter == "PHOS") { 
241     reader->SwitchOnPHOSCells();  
242     reader->SwitchOnPHOS();
243   //}
244   
245   // for case data="deltaAOD", no need to fill the EMCAL/PHOS cluster lists
246   if(kData.Contains("delta")){
247     reader->SwitchOffEMCAL();
248     reader->SwitchOffPHOS();
249     reader->SwitchOffEMCALCells(); 
250     reader->SwitchOffPHOSCells(); 
251   }
252   
253   //-----------------
254   // Event selection
255   //-----------------
256   
257   // Settings for LHC11a
258   if(kRunNumber > 140000 && kRunNumber < = 146860){
259     if(kClusterArray == "") reader->SwitchOnLEDEventsRemoval();
260     reader->RejectFastClusterEvents();
261     printf("Reader: Reject LED events and Fast cluster\n");
262   }  
263   
264   //if(!kUseKinematics) reader->SetFiredTriggerClassName("CEMC7EGA-B-NOPF-CENTNOTRD"); // L1 Gamma
265   
266   if     (kCollisions=="pp"  ) {
267     if(kRunNumber < 140000) reader->SwitchOnEventSelection(); // remove pileup by default
268     else                    reader->SwitchOffEventSelection(); 
269     reader->SwitchOffV0ANDSelection() ;        // and besides v0 AND
270     reader->SwitchOffPrimaryVertexSelection(); // and besides primary vertex
271     reader->SetZvertexCut(50.);                // Open cut
272   }
273   else if(kCollisions=="PbPb") {
274     reader->SwitchOffEventSelection();         // remove pileup by default
275     reader->SwitchOffV0ANDSelection() ;        // and besides v0 AND
276     reader->SwitchOffPrimaryVertexSelection(); // and besides primary vertex
277     reader->SetZvertexCut(10.);                // Centrality defined in this range.
278     
279     // Centrality
280     reader->SetCentralityClass("V0M");
281     reader->SetCentralityOpt("10");  // 10 centrality bins
282     reader->SetCentralityBin(-1,-1); // Accept all events, if not select range
283     
284     // Event plane (only used in AliAnaPi0 for the moment)
285     reader->SetEventPlaneMethod("Q");
286   }
287   
288   reader->SetImportGeometryFromFile(kTRUE);
289   
290   if(kPrint) reader->Print("");
291   
292   return reader;
293   
294 }
295
296 //_______________________________________
297 AliCalorimeterUtils* ConfigureCaloUtils()
298 {
299   
300   AliCalorimeterUtils *cu = new AliCalorimeterUtils;
301   cu->SetDebug(-1);
302   
303   // Remove clusters close to borders, at least max energy cell is 1 cell away 
304   cu->SetNumberOfCellsFromEMCALBorder(1);
305   cu->SetNumberOfCellsFromPHOSBorder(2);
306   
307   if(kClusterArray == "") 
308     cu->SwitchOffRecalculateClusterTrackMatching(); // Done in clusterization
309   else            
310     cu->SwitchOnRecalculateClusterTrackMatching();
311   
312   cu->SwitchOnBadChannelsRemoval() ;
313   
314   //EMCAL settings
315   if(kCalorimeter=="EMCAL"){
316     
317     if(kYears==2010) cu->SetEMCALGeometryName("EMCAL_FIRSTYEARV1");
318     else             cu->SetEMCALGeometryName("EMCAL_COMPLETEV1");
319     
320     AliEMCALRecoUtils * recou = cu->GetEMCALRecoUtils();
321     
322     Bool_t bCalib = kTRUE;
323     Bool_t bBadMap= kTRUE;
324     cu->SwitchOnRecalibration();      // Check the reader if it is taken into account during filtering
325     
326     TGeoHMatrix* matrix[12];
327     gROOT->LoadMacro("ConfigureEMCALRecoUtils.C");
328     ConfigureEMCALRecoUtils(
329                             recou,
330                             kSimulation, 
331                             matrix,
332                             "",//AODB path, default
333                             kRunNumber, 
334                             kPass,
335                             bCalib, 
336                             bBadMap
337                             );   
338     
339     printf("ConfigureCaloUtils() - EMCAL Recalibration ON? %d %d\n",recou->IsRecalibrationOn(), cu->IsRecalibrationOn());
340     printf("ConfigureCaloUtils() - EMCAL BadMap        ON? %d %d\n",recou->IsBadChannelsRemovalSwitchedOn(), cu->IsBadChannelsRemovalSwitchedOn());
341     
342     //Alignment matrices
343     cu->SwitchOffLoadOwnEMCALGeometryMatrices();
344     /*
345      for (Int_t mod=0;mod<12;mod++)
346      {
347      //((TGeoHMatrix*) mobj->At(mod))->Print();
348      cu->SetEMCALGeometryMatrixInSM(matrix[mod],mod);
349      }
350      */
351     
352     // Non linearity
353     if(kCollisions=="pp"  ) { // Do only for pp for the moment
354       cu->SwitchOnCorrectClusterLinearity();
355       if(!kSimulation) recou->SetNonLinearityFunction(AliEMCALRecoUtils::kBeamTestCorrected);
356       else             recou->SetNonLinearityFunction(AliEMCALRecoUtils::kPi0MC);
357     }
358     
359     recou->SwitchOnRejectExoticCell();
360     if(kClusterArray == "") recou->SwitchOnRejectExoticCluster();
361     else                    recou->SwitchOffRejectExoticCluster();
362     
363   }  
364   else { // PHOS settings 
365     
366     Int_t run2010 = kRunNumber;
367     //Use a fixed run number from year 2010 for 2011 runs, not available yet.
368     if(kRunNumber > 140000) run2010 = 139000;
369     
370     // Bad map
371     
372     AliOADBContainer badmapContainer(Form("phosBadMap"));
373     TString fileName="$ALICE_ROOT/OADB/PHOS/PHOSBadMaps.root";
374     //if(path!="") fileName=path+"PHOSBadMaps.root";
375     badmapContainer.InitFromFile((char*)fileName.Data(),"phosBadMap");
376     //Use a fixed run number from year 2010, this year not available yet.
377     TObjArray *maps = (TObjArray*)badmapContainer.GetObject(run2010,"phosBadMap");
378     if(!maps){
379       printf("Can not read Bad map for run %d. \n You may choose to use your map with ForceUsingBadMap()\n",run2010) ;    
380     }
381     else{
382       printf("Setting PHOS bad map with name %s \n",maps->GetName()) ;
383       for(Int_t mod=1; mod<5;mod++){
384         TH2I *hbmPH = cu->GetPHOSChannelStatusMap(mod);
385         
386         if(hbmPH) 
387           delete hbmPH ;        
388         hbmPH=(TH2I*)maps->At(mod);
389         
390         if(hbmPH) hbmPH->SetDirectory(0);
391         
392         cu->SetPHOSChannelStatusMap(mod-1,hbmPH);
393       }   
394     }
395     
396     //Alignment matrices
397     cu->SwitchOffLoadOwnPHOSGeometryMatrices();
398     /*
399      fileName="$ALICE_ROOT/OADB/PHOS/PHOSGeometry.root";
400      //if(path!="") fileName=path+"PHOSGeometry.root";
401      AliOADBContainer geomContainer("phosGeo");
402      geomContainer.InitFromFile((char*)fileName.Data(),"PHOSRotationMatrixes");
403      TObjArray *matrixes = (TObjArray*)geomContainer.GetObject(run2010,"PHOSRotationMatrixes");    
404      for (Int_t mod=0;mod<5;mod++)
405      {
406      printf("PHOS matrices mod %d, %p\n",mod,((TGeoHMatrix*)matrixes->At(mod)));
407      //((TGeoHMatrix*) mobj->At(mod))->Print();
408      cu->SetPHOSGeometryMatrixInSM(((TGeoHMatrix*)matrixes->At(mod)),mod);
409      }    
410      */
411   }// PHOS
412   
413   if(kPrint) cu->Print("");
414   
415   return cu;
416   
417 }
418
419 //_____________________________________
420 AliAnaPhoton* ConfigurePhotonAnalysis()
421 {
422   
423   AliAnaPhoton *anaphoton = new AliAnaPhoton();
424   anaphoton->SetDebug(-1); //10 for lots of messages
425   
426   // cluster selection cuts
427   
428   anaphoton->SwitchOffFiducialCut();
429   
430   anaphoton->SetCalorimeter(kCalorimeter);
431   
432   if(kCalorimeter == "PHOS"){
433     anaphoton->SetNCellCut(2);// At least 2 cells
434     anaphoton->SetMinPt(0.3);
435     anaphoton->SetMinDistanceToBadChannel(2, 4, 5);
436     anaphoton->SetTimeCut(-2000,2000); // open cut, usual time window of [425-825] ns if time recalibration is off 
437   }
438   else {//EMCAL
439     anaphoton->SetNCellCut(1);// At least 2 cells
440     anaphoton->SetMinPt(0.5); // avoid mip peak at E = 260 MeV
441     anaphoton->SetMaxPt(1000); 
442     anaphoton->SetTimeCut(-1000,1000); // open cut, usual time window of [425-825] ns if time recalibration is off 
443     // restrict to less than 100 ns when time calibration is on 
444     anaphoton->SetMinDistanceToBadChannel(1, 2, 3); // For filtered AODs, new releases.
445   }
446   
447   anaphoton->SwitchOnTrackMatchRejection() ;
448   
449   //PID cuts (shower shape)
450   anaphoton->SwitchOnCaloPID(); // do PID selection, unless specified in GetCaloPID, selection not based on bayesian
451   AliCaloPID* caloPID = anaphoton->GetCaloPID();
452   //Not used in bayesian
453   
454   //EMCAL
455   caloPID->SetEMCALLambda0CutMax(0.30);
456   caloPID->SetEMCALLambda0CutMin(0.10);
457   
458   caloPID->SetEMCALDEtaCut(0.025);
459   caloPID->SetEMCALDPhiCut(0.05);
460   // In case of official AODs when dX and dZ was not stored, open the cuts 
461   // and rely on having a match recorded. In case of reclusterization, try.
462   if(kData=="AOD" && kClusterArray==""){
463     caloPID->SetEMCALDEtaCut(2000);  
464     caloPID->SetEMCALDPhiCut(2000); 
465   }
466   
467   //PHOS
468   caloPID->SetPHOSDispersionCut(2.5);
469   caloPID->SetPHOSRCut(2.);
470   if(kData=="AOD") caloPID->SetPHOSRCut(2000.); // Open cut since dX, dZ not stored
471   
472   if(kCalorimeter=="PHOS"){
473     caloPID->SetHistoDEtaRangeAndNBins(-200, 200, 200); // dZ
474     caloPID->SetHistoDPhiRangeAndNBins(-200, 200, 200); // dX
475   }
476   
477   //caloPID->SetTOFCut(10000000); // Not used, only to set PID bits
478   
479   anaphoton->SwitchOffFillShowerShapeHistograms();  // Filled before photon shower shape selection
480   
481   // Input / output delta AOD settings
482   
483   if(!kData.Contains("delta")) {
484     anaphoton->SetOutputAODName(Form("Photon%s_Trig%s_Cl%s",kCalorimeter.Data(), kTrig.Data(),kClusterArray.Data()));
485     anaphoton->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
486     //anaphoton->SetOutputAODClassName("AliAODPWG4Particle"); // use if no correlation done
487   }
488   else anaphoton->SetInputAODName(Form("Photon%s_Trig%s_Cl%s",kCalorimeter.Data(), kTrig.Data(),kClusterArray.Data()));
489   
490   //Set Histograms name tag, bins and ranges
491   
492   anaphoton->AddToHistogramsName("AnaPhoton_");
493   SetHistoRangeAndNBins(anaphoton); // see method below
494   
495   // Number of particle type MC histograms
496   anaphoton->FillNOriginHistograms(8);
497   anaphoton->FillNPrimaryHistograms(4);
498   
499   if(kPrint) anaphoton->Print("");
500   
501   return anaphoton;
502   
503 }
504
505 //_______________________________________________
506 AliAnaChargedParticles* ConfigureChargedAnalysis()
507 {
508   
509   AliAnaChargedParticles *anatrack = new AliAnaChargedParticles();
510   anatrack->SetDebug(-1); //10 for lots of messages
511   
512   // selection cuts
513   
514   anatrack->SetDebug(-1);//10 for lots of messages
515   anatrack->SetMinPt(5.);
516   anatrack->SwitchOffFiducialCut();
517   
518   // Input / output delta AOD settings
519   
520   if(!kData.Contains("delta")) {
521     anatrack->SetOutputAODName(Form("Hadron%s_Trig%s_Cl%s",kCalorimeter.Data(), kTrig.Data(),kClusterArray.Data()));
522     anatrack->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
523     //anaphoton->SetOutputAODClassName("AliAODPWG4Particle"); // use if no correlation done
524   }
525   else anatrack->SetInputAODName(Form("Hadron%s_Trig%s_Cl%s",kCalorimeter.Data(), kTrig.Data(),kClusterArray.Data()));
526   printf("Set Hadron%s_Trig%s_Cl%s\n",kCalorimeter.Data(), kTrig.Data(),kClusterArray.Data());
527   //Set Histograms name tag, bins and ranges
528   
529   anatrack->AddToHistogramsName("AnaHadrons_");
530   SetHistoRangeAndNBins(anatrack); // see method below
531
532   if(kPrint) anatrack->Print("");
533   
534   return anatrack;
535   
536 }
537
538
539 //_______________________________
540 AliAnaPi0* ConfigurePi0Analysis()
541 {
542   
543   AliAnaPi0 *anapi0 = new AliAnaPi0();
544   
545   anapi0->SetDebug(-1);//10 for lots of messages
546   if(kPrint) anapi0->Print("");
547   
548   // Input delta AOD settings
549   anapi0->SetInputAODName(Form("Photon%s_Trig%s_Cl%s",kCalorimeter.Data(), kTrig.Data(),kClusterArray.Data()));
550   
551   // Calorimeter settings
552   anapi0->SetCalorimeter(kCalorimeter);
553   if(kCalorimeter=="PHOS") anapi0->SetNumberOfModules(3); //PHOS first year
554   else {                   
555     if(kYears==2010) anapi0->SetNumberOfModules(4); //EMCAL first year
556     else             anapi0->SetNumberOfModules(10);
557   }
558   
559   //settings for pp collision mixing
560   anapi0->SwitchOnOwnMix(); //Off when mixing done with general mixing frame
561   
562   // Cuts 
563   if(kCalorimeter=="EMCAL") anapi0->SetPairTimeCut(70);
564   
565   if     (kCollisions=="pp"  ) {
566     anapi0->SetNCentrBin(1);
567     anapi0->SetNZvertBin(10);
568     anapi0->SetNRPBin(1);
569     anapi0->SetNMaxEvMix(100);    
570     anapi0->SwitchOffSMCombinations();
571     anapi0->SwitchOffMultipleCutAnalysis();
572   }
573   else if(kCollisions=="PbPb") {
574     anapi0->SetNCentrBin(10);
575     anapi0->SetNZvertBin(10);
576     anapi0->SetNRPBin(4);
577     anapi0->SetNMaxEvMix(10);
578     anapi0->SwitchOffSMCombinations();
579   }
580   
581   //Set Histograms name tag, bins and ranges
582   
583   anapi0->AddToHistogramsName("AnaPi0_");
584   SetHistoRangeAndNBins(anapi0); // see method below
585   
586   return anapi0;
587   
588 }
589
590 //_____________________________________________________
591 AliAnaPi0EbE* ConfigurePi0EbEAnalysis(TString particle, 
592                                       Int_t analysis)
593 {
594   
595   AliAnaPi0EbE *anapi0ebe = new AliAnaPi0EbE();
596   anapi0ebe->SetDebug(-1);//10 for lots of messages
597   
598   anapi0ebe->SetAnalysisType(analysis);
599   TString opt = "";
600   if(analysis==AliAnaPi0EbE::kIMCaloTracks) opt = "Conv";
601   if(analysis==AliAnaPi0EbE::kSSCalo)       opt = "SS";
602   
603   anapi0ebe->SwitchOffFillWeightHistograms();
604   anapi0ebe->SetMinPt(0.5);
605   if(kCalorimeter=="EMCAL")anapi0ebe->SetPairTimeCut(20); 
606   anapi0ebe->SetCalorimeter(kCalorimeter);
607   
608   // Input / output delta AOD settings
609   
610   anapi0ebe->SetInputAODName(Form("Photon%s_Trig%s_Cl%s",kCalorimeter.Data(), kTrig.Data(),kClusterArray.Data()));
611   if(!kInputDataType.Contains("delta")) {
612     anapi0ebe->SetOutputAODName(Form("%s%s%s_Trig%s_Cl%s",particle.Data(), opt.Data(), kCalorimeter.Data(), kTrig.Data(),kClusterArray.Data()));
613     anapi0ebe->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
614   }
615   else  anapi0ebe->SetInputAODName(Form("%s%s%s_Trig%s_Cl%s",particle.Data(),opt.Data(),kCalorimeter.Data(), kTrig.Data(),kClusterArray.Data()));
616   
617   if(analysis == AliAnaPi0EbE::kIMCaloTracks) anapi0ebe->SetInputAODGammaConvName("PhotonsCTS");
618   
619   if(analysis!=AliAnaPi0EbE::kSSCalo){
620     
621     AliNeutralMesonSelection *nms = anapi0ebe->GetNeutralMesonSelection();
622     nms->SetParticle(particle);
623     nms->SwitchOffAngleSelection();
624     nms->KeepNeutralMesonSelectionHistos(kTRUE);
625     //nms->SetAngleMaxParam(2,0.2);
626     nms->SetHistoERangeAndNBins(0, 20, 100) ;
627     //nms->SetHistoIMRangeAndNBins(0, 1, 400);
628   }
629   
630   //Set Histograms name tag, bins and ranges
631   
632   anapi0ebe->AddToHistogramsName(Form("Ana%s%sEbE_",particle.Data(),opt.Data()));
633   SetHistoRangeAndNBins(anapi0ebe); // see method below
634   
635   if(kPrint) anapi0ebe->Print("");
636   
637   return  anapi0ebe;
638   
639 }
640
641 //___________________________________________________________________
642 AliAnaParticleIsolation* ConfigureIsolationAnalysis(TString particle="Photon", 
643                                                     Int_t  partInCone = AliIsolationCut::kOnlyCharged,
644                                                     Int_t  thresType  = AliIsolationCut::kSumPtFracIC,
645                                                     Bool_t multi      = kFALSE)
646 {
647   
648   AliAnaParticleIsolation *anaisol = new AliAnaParticleIsolation();
649   anaisol->SetDebug(-1);
650   
651   anaisol->SetMinPt(5);
652   
653   // Input / output delta AOD settings
654   
655   anaisol->SetInputAODName(Form("%s%s_Trig%s_Cl%s",particle.Data(),kCalorimeter.Data(), kTrig.Data(),kClusterArray.Data()));
656   anaisol->SetAODObjArrayName(Form("IC%s",particle.Data())); 
657   
658   anaisol->SetCalorimeter(kCalorimeter);
659   
660   //Do settings for main isolation cut class
661   AliIsolationCut * ic =  anaisol->GetIsolationCut();   
662   ic->SetConeSize(0.4);
663   ic->SetPtThreshold(0.5);
664   ic->SetPtFraction(0.1);
665   ic->SetSumPtThreshold(1.0) ;
666   ic->SetParticleTypeInCone(partInCone);
667   ic->SetICMethod(thresType);
668   
669   //Do or not do isolation with previously produced AODs.
670   //No effect if use of SwitchOnSeveralIsolation()
671   anaisol->SwitchOffReIsolation();
672   //Multiple IC
673   if(multi) anaisol->SwitchOnSeveralIsolation() ;
674   else      anaisol->SwitchOffSeveralIsolation() ;
675   
676   //Set Histograms name tag, bins and ranges
677   
678   anaisol->AddToHistogramsName(Form("AnaIsol%s_",particle.Data()));
679   SetHistoRangeAndNBins(anaisol); // see method below
680   
681   if(kPrint) ic     ->Print("");
682   if(kPrint) anaisol->Print("");
683   
684   return anaisol;
685   
686 }
687
688 //___________________________________________________________________________________
689 AliAnaParticleHadronCorrelation* ConfigureHadronCorrelationAnalysis(TString particle, 
690                                                                     Int_t bIsolated)
691 {
692   
693   AliAnaParticleHadronCorrelation *anacorrhadron = new AliAnaParticleHadronCorrelation();
694   anacorrhadron->SetDebug(-1);
695   
696   anacorrhadron->SetPtCutRange(5,200);
697   
698   // Input / output delta AOD settings
699   
700   anacorrhadron->SetInputAODName(Form("%s%s_Trig%s_Cl%s",particle.Data(),kCalorimeter.Data(), kTrig.Data(),kClusterArray.Data()));
701   anacorrhadron->AddToHistogramsName(Form("Ana%sHadronCorrIso%d_",particle.Data(),bIsolated));
702   anacorrhadron->SetAODObjArrayName(Form("%sHadronCorrIso%d",particle.Data(),bIsolated)); 
703   
704   anacorrhadron->SelectIsolated(bIsolated); // do correlation with isolated photons
705   
706   anacorrhadron->SwitchOnDecayCorr();
707   anacorrhadron->SetMultiBin(1);
708   anacorrhadron->SwitchOffNeutralCorr();
709   anacorrhadron->SwitchOffEventSelection();
710   anacorrhadron->SetDeltaPhiCutRange(1.5,4.5);
711   
712   anacorrhadron->SwitchOnSeveralUECalculation();
713   anacorrhadron->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
714   
715   //if(kCalorimeter=="PHOS"){
716   //Correlate with particles in EMCAL
717   //anacorrhadron->SwitchOnCaloPID();
718   //anacorrhadron->SwitchOnCaloPIDRecalculation(); 
719   //}
720   
721   //Set Histograms name tag, bins and ranges
722   
723   anacorrhadron->AddToHistogramsName(Form("Ana%sHadronCorr_Iso%d_",particle.Data(),bIsolated));
724   SetHistoRangeAndNBins(anacorrhadron); // see method below
725   
726   if(kPrint) anacorrhadron->Print("");  
727   
728   return anacorrhadron;
729   
730 }
731
732 //________________________________________
733 AliAnaCalorimeterQA* ConfigureQAAnalysis()
734 {
735   
736   AliAnaCalorimeterQA *anaQA = new AliAnaCalorimeterQA();
737   //anaQA->SetDebug(10); //10 for lots of messages
738   anaQA->SetCalorimeter(kCalorimeter);
739   
740   anaQA->SetTimeCut(-1000,1000); // Open time cut
741   
742   if(kCalorimeter=="EMCAL" && kClusterArray=="")
743     anaQA->SwitchOnCorrelation(); // make sure you switch in the reader PHOS and EMCAL cells and clusters if option is ON
744   else 
745     anaQA->SwitchOffCorrelation();  
746   
747   anaQA->SwitchOffFiducialCut();
748   anaQA->SwitchOffFillAllTH3Histogram();
749   anaQA->SwitchOffFillAllPositionHistogram();
750   anaQA->SwitchOffFillAllPositionHistogram2();
751   
752   anaQA->SwitchOffStudyBadClusters() ; // On only for EMCAL
753   anaQA->SwitchOffStudyClustersAsymmetry();
754   anaQA->SwitchOffStudyWeight();
755   anaQA->SwitchOffFillAllTrackMatchingHistogram();
756   
757   if(kCalorimeter=="EMCAL")
758   {
759     if(kYears==2010)  
760       anaQA->SetNumberOfModules(4); 
761     else{           
762       anaQA->SetNumberOfModules(10); 
763     }
764   }
765   else 
766   {//PHOS
767     anaQA->SetNumberOfModules(3); 
768   }
769   
770   anaQA->AddToHistogramsName("QA_"); //Begining of histograms name
771   SetHistoRangeAndNBins(anaQA); // see method below
772   
773   if(kPrint) anaQA->Print("");  
774   
775   return anaQA;
776   
777 }
778
779 //________________________________________________________
780 void SetHistoRangeAndNBins (AliAnaPartCorrBaseClass* ana)
781 {
782   // Set common bins for all analysis and MC histograms filling
783   
784   if(kSimulation) ana->SwitchOnDataMC() ;//Access MC stack and fill more histograms, AOD MC not implemented yet.
785   else            ana->SwitchOffDataMC() ;
786   
787   ana->SetHistoPtRangeAndNBins(0, 100, 250) ; // Energy and pt histograms
788   
789   if(kCalorimeter=="EMCAL"){
790     if(kYears==2010){
791       ana->SetHistoPhiRangeAndNBins(78*TMath::DegToRad(), 122*TMath::DegToRad(), 78) ;
792       ana->SetHistoXRangeAndNBins(-230,90,120); // QA
793       ana->SetHistoYRangeAndNBins(370,450,40);  // QA
794     }
795     else {           
796       ana->SetHistoPhiRangeAndNBins(78*TMath::DegToRad(), 182*TMath::DegToRad(), 108) ;
797       ana->SetHistoXRangeAndNBins(-600,90,200); // QA
798       ana->SetHistoYRangeAndNBins(100,450,100); // QA
799     }
800     
801     ana->SetHistoEtaRangeAndNBins(-0.72, 0.72, 144) ;
802   }
803   else{
804     ana->SetHistoPhiRangeAndNBins(260*TMath::DegToRad(), 320*TMath::DegToRad(), 60) ;
805     ana->SetHistoEtaRangeAndNBins(-0.13, 0.13, 130) ;
806     
807   }
808   
809   ana->SetHistoShowerShapeRangeAndNBins(0, 3, 300);
810   
811   // Invariant mass analysis
812   ana->SetHistoMassRangeAndNBins(0., 1., 200) ;
813   ana->SetHistoAsymmetryRangeAndNBins(0., 1. , 100) ;
814   
815   // check if time calibration is on
816   ana->SetHistoTimeRangeAndNBins(-1000.,1000,1000);
817   ana->SetHistoDiffTimeRangeAndNBins(-200, 200, 800);
818   
819   // QA, electron, charged
820   ana->SetHistoPOverERangeAndNBins(0,10.,100);
821   ana->SetHistodEdxRangeAndNBins(0.,200.,200);
822   
823   // QA
824   ana->SetHistoFinePtRangeAndNBins(0, 10, 200) ; // bining for fhAmpId
825   ana->SetHistodRRangeAndNBins(0.,TMath::Pi(),150);
826   ana->SetHistoRatioRangeAndNBins(0.,2.,100);
827   ana->SetHistoVertexDistRangeAndNBins(0.,500.,500);
828   ana->SetHistoNClusterCellRangeAndNBins(0,500,500);
829   ana->SetHistoZRangeAndNBins(-400,400,200);
830   ana->SetHistoRRangeAndNBins(400,450,25);
831   ana->SetHistoV0SignalRangeAndNBins(0,5000,500);
832   ana->SetHistoV0MultiplicityRangeAndNBins(0,5000,500);
833   ana->SetHistoTrackMultiplicityRangeAndNBins(0,5000,500);
834   
835 }
836