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