]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGGA/CaloTrackCorrelations/macros/AddTaskCaloTrackCorr.C
7cf3081532489bec7d2e2ae27da6433054c9343e
[u/mrichter/AliRoot.git] / PWGGA / CaloTrackCorrelations / 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 Bool_t  kEventSelection= kFALSE;
7 Bool_t  kExotic        = kTRUE;
8 Bool_t  kNonLinearity  = kFALSE;
9 Int_t   kYears         = 2011;
10 TString kCollisions    = "pp";
11 TString kTrig          = "EMC7" ;
12 TString kClusterArray  = "";
13 TString kData          = ""; // MC or deltaAOD
14 TString kInputDataType = "ESD";
15 TString kCalorimeter   = "EMCAL";
16 Bool_t  kTM            = kTRUE;
17 Bool_t  kRecalTM       = kTRUE;
18 Int_t   kMinCen        = -1;
19 Int_t   kMaxCen        = -1;
20 TString kName          = "";
21 Int_t   kDebug         = -1; 
22 Bool_t  kQA            = kFALSE;
23 Bool_t  kHadronAN      = kFALSE;
24 Bool_t  kCalibE        = kTRUE;
25 Bool_t  kCalibT        = kTRUE;
26 Bool_t  kBadMap        = kTRUE;
27 Bool_t  kTender        = kFALSE;
28 Bool_t  kMix           = kFALSE;
29 Int_t   kRunNumber     = -1;
30
31 AliAnalysisTaskCaloTrackCorrelation *AddTaskCaloTrackCorr(const TString  data          = "",
32                                                           const TString  calorimeter   = "EMCAL", 
33                                                           const Bool_t   simulation    = kFALSE,
34                                                           const Bool_t   eventsel      = kFALSE,
35                                                           const Bool_t   exotic        = kTRUE,
36                                                           const Bool_t   nonlin        = kFALSE,
37                                                           TString        outputfile    = "",
38                                                           const Int_t    year          = 2010,
39                                                           const TString  col           = "pp", 
40                                                           const TString  trigger       = "MB", 
41                                                           const TString  clustersArray = "V1",
42                                                           const Bool_t   mix           = kTRUE,
43                                                           const Bool_t   recaltm       = kTRUE,
44                                                           const Bool_t   tm            = kTRUE,
45                                                           const Int_t    minCen        = -1,
46                                                           const Int_t    maxCen        = -1,
47                                                           const Bool_t   qaan          = kFALSE,
48                                                           const Bool_t   hadronan      = kFALSE,
49                                                           const Bool_t   calibE        = kTRUE,
50                                                           const Bool_t   badmap        = kTRUE,
51                                                           const Bool_t   calibT        = kTRUE,
52                                                           const Bool_t   tender        = kFALSE,
53                                                           const Bool_t   outputAOD     = kFALSE, 
54                                                           const Bool_t   printSettings = kFALSE,
55                                                           const Double_t scaleFactor   = -1, 
56                                                           const Int_t    runNumber     = -1
57                                                           )
58 {
59   // Creates a CaloTrackCorr task, configures it and adds it to the analysis manager.
60   
61   kPrint         = printSettings;
62   kSimulation    = simulation;
63   kYears         = year;
64   kCollisions    = col;
65   kExotic        = exotic;
66   kNonLinearity  = nonlin;
67   kTrig          = trigger;
68   kClusterArray  = clustersArray;
69   kData          = data;
70   kCalorimeter   = calorimeter;
71   kOutputAOD     = outputAOD;
72   kTM            = tm;
73   kRecalTM       = recaltm;
74   kMinCen        = minCen;
75   kMaxCen        = maxCen;
76   kEventSelection= eventsel;
77   kQA            = qaan;
78   kHadronAN      = hadronan;
79   kCalibE        = calibE;
80   kCalibT        = calibT;
81   kBadMap        = badmap;
82   kTender        = tender;
83   kMix           = mix;
84   kRunNumber     = runNumber;
85   
86   // Get the pointer to the existing analysis manager via the static access method.
87   
88   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
89   if (!mgr) 
90   {
91     ::Error("AddTask", "No analysis manager to connect to.");
92     return NULL;
93   }  
94   
95   // Check the analysis type using the event handlers connected to the analysis manager.
96   
97   if (!mgr->GetInputEventHandler()) 
98   {
99     ::Error("AddTask", "This task requires an input event handler");
100     return NULL;
101   }
102   
103   kInputDataType = "AOD";
104   if(!kData.Contains("delta"))
105     kInputDataType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
106   
107   if(kSimulation) 
108   { 
109     kUseKinematics = (mgr->GetMCtruthEventHandler())?kTRUE:kFALSE; 
110     if (!kUseKinematics && data=="AOD" && kInputDataType != "ESD") kUseKinematics = kTRUE; //AOD primary should be available ... 
111   } 
112   
113   cout<<"********* ACCESS KINE? "<<kUseKinematics<<endl;
114   
115   // Name for containers
116   
117   kName = Form("%s_Trig%s_Cl%s_TM%d",kCalorimeter.Data(), kTrig.Data(),kClusterArray.Data(),kTM);
118
119   if(kCollisions=="PbPb" && kMaxCen>=0) kName+=Form("Cen%d_%d",kMinCen,kMaxCen);
120     
121   printf("<<<< NAME: %s >>>>>\n",kName.Data());
122   
123   // #### Configure analysis ####
124     
125   AliAnaCaloTrackCorrMaker * maker = new AliAnaCaloTrackCorrMaker();
126   
127   maker->SetScaleFactor(scaleFactor); // for MC, negative (not scaled) by default
128   
129   // General frame setting and configuration
130   maker->SetReader   (ConfigureReader()   ); 
131   maker->SetCaloUtils(ConfigureCaloUtils()); 
132   
133   // Analysis tasks setting and configuration
134   Int_t n = 0;//Analysis number, order is important
135
136   // Isolation settings
137   Int_t partInCone = AliIsolationCut::kNeutralAndCharged; // kOnlyCharged;
138   Int_t thresType  = AliIsolationCut::kPtThresIC;//  AliIsolationCut::kSumPtFracIC ; 
139   Float_t cone = -1;
140   Float_t pth  = -1;
141   
142   // Photon analysis
143   
144   maker->AddAnalysis(ConfigurePhotonAnalysis(), n++); // Photon cluster selection
145
146   // Invariant mass analysis Put here to tag selected photons as decay
147   maker->AddAnalysis(ConfigurePi0EbEAnalysis("Pi0", AliAnaPi0EbE::kIMCalo), n++); // Pi0 event by event selection, invariant mass and photon tagging from decay    
148   maker->AddAnalysis(ConfigurePi0EbEAnalysis("Eta", AliAnaPi0EbE::kIMCalo), n++); // Eta event by event selection, invariant mass and photon tagging from decay
149   
150   // Photon analysis
151   maker->AddAnalysis(ConfigureIsolationAnalysis("Photon", partInCone,thresType,cone, pth), n++); // Photon isolation   
152   maker->AddAnalysis(ConfigureHadronCorrelationAnalysis("Photon",kFALSE), n++); // Gamma hadron correlation
153   maker->AddAnalysis(ConfigureHadronCorrelationAnalysis("Photon",kTRUE,partInCone,thresType, cone, pth) , n++); // Isolated gamma hadron correlation
154   //maker->AddAnalysis(ConfigureIsolationAnalysis("Photon", partInCone,thresType,kTRUE), n++); // Photon multi isolation, leave it the last   
155
156   
157   // Split cluster analysis
158   if(kCalorimeter == "EMCAL")
159   {
160     maker->AddAnalysis(ConfigurePi0EbEAnalysis("Pi0", AliAnaPi0EbE::kSSCalo), n++); // Pi0 event by event selection, cluster splitting   
161     maker->AddAnalysis(ConfigureIsolationAnalysis("Pi0SS", partInCone,thresType,cone, pth), n++);       // Pi0 isolation, cluster splits   
162     maker->AddAnalysis(ConfigureHadronCorrelationAnalysis("Pi0SS" ,kFALSE), n++); // Pi0 hadron correlation
163     maker->AddAnalysis(ConfigureHadronCorrelationAnalysis("Pi0SS" ,kTRUE,partInCone,thresType, cone, pth) , n++); // Isolated pi0 hadron correlation
164     //maker->AddAnalysis(ConfigureIsolationAnalysis("Pi0SS",  partInCone,thresType,kTRUE), n++); // Pi0 multi isolation, split cluster  
165     //maker->AddAnalysis(ConfigureInClusterIMAnalysis(0.5,3), n++); 
166   }
167   
168   // Invariant mass analysis
169   maker->AddAnalysis(ConfigurePi0EbEAnalysis("Pi0SideBand", AliAnaPi0EbE::kIMCalo), n++); // Pi0 event by event selection, and photon tagging from decay    
170   maker->AddAnalysis(ConfigureIsolationAnalysis("Pi0", partInCone,thresType,cone, pth), n++);         // Pi0 isolation, invariant mass   
171   maker->AddAnalysis(ConfigureIsolationAnalysis("Pi0SideBand", partInCone,thresType,cone, pth), n++); // Pi0 isolation, side band   
172   maker->AddAnalysis(ConfigureHadronCorrelationAnalysis("Pi0"   ,kFALSE), n++); // Pi0 hadron correlation
173   maker->AddAnalysis(ConfigureHadronCorrelationAnalysis("Pi0"   ,kTRUE,partInCone,thresType, cone, pth) , n++); // Isolated pi0 hadron correlation
174   maker->AddAnalysis(ConfigureHadronCorrelationAnalysis("Pi0SideBand" ,kFALSE), n++); // Pi0 hadron correlation
175   maker->AddAnalysis(ConfigureHadronCorrelationAnalysis("Pi0SideBand" ,kTRUE,partInCone,thresType, cone, pth) , n++); // Isolated pi0 hadron correlation
176   //maker->AddAnalysis(ConfigureIsolationAnalysis("Pi0",    partInCone,thresType,kTRUE), n++); // Pi0 multi isolation, invariant mass, leave it the last   
177
178   if(kHadronAN)
179   {
180     maker->AddAnalysis(ConfigureChargedAnalysis(), n++);                                // track selection
181     maker->AddAnalysis(ConfigureIsolationAnalysis("Hadron",AliIsolationCut::kOnlyCharged,thresType,cone, pth), n++); // track isolation
182     maker->AddAnalysis(ConfigureHadronCorrelationAnalysis("Hadron",kFALSE), n++);       // track-track correlation
183     maker->AddAnalysis(ConfigureHadronCorrelationAnalysis("Hadron",kTRUE,partInCone,thresType, cone, pth) , n++);       // Isolated track-track correlation
184     //maker->AddAnalysis(ConfigureIsolationAnalysis("Hadron",partInCone,thresType,kTRUE), n++);// Hadron multi isolation  
185   }
186   
187   // Analysis with ghost triggers, only for Min Bias like events
188   if( kTrig.Contains("INT") || kTrig.Contains("Central") || kTrig.Contains("MB")  )
189   {
190     maker->AddAnalysis(ConfigureRandomTriggerAnalysis(), n++); 
191     maker->AddAnalysis(ConfigureIsolationAnalysis(Form("RandomTrigger%s",kCalorimeter.Data()), partInCone,thresType,cone, pth), n++); // Ghost trigger isolation   
192     maker->AddAnalysis(ConfigureHadronCorrelationAnalysis(Form("RandomTrigger%s",kCalorimeter.Data()),kFALSE), n++); // Ghost trigger hadron correlation
193     maker->AddAnalysis(ConfigureHadronCorrelationAnalysis(Form("RandomTrigger%s",kCalorimeter.Data()),kTRUE,partInCone,thresType, cone, pth) , n++); // Isolated ghost hadron correlation
194     //maker->AddAnalysis(ConfigureIsolationAnalysis(Form("RandomTrigger%s",kCalorimeter.Data()), partInCone,thresType,kTRUE), n++); // Ghost multi isolation   
195     
196     if(kHadronAN)
197     {
198       maker->AddAnalysis(ConfigureRandomTriggerAnalysis("CTS"), n++);                                // track selection
199       maker->AddAnalysis(ConfigureIsolationAnalysis("RandomTriggerCTS",AliIsolationCut::kOnlyCharged,thresType,cone, pth), n++); // track isolation
200       maker->AddAnalysis(ConfigureHadronCorrelationAnalysis("RandomTriggerCTS",kFALSE), n++);       // track-track correlation
201       maker->AddAnalysis(ConfigureHadronCorrelationAnalysis("RandomTriggerCTS",kTRUE,partInCone,thresType, cone, pth) , n++);       // Isolated track-track correlation
202       //maker->AddAnalysis(ConfigureIsolationAnalysis("RandomTriggerCTS",AliIsolationCut::kOnlyCharged,thresType,kTRUE), n++); // Ghost multi isolation   
203     }
204   }
205   
206   if(kQA)  maker->AddAnalysis(ConfigureQAAnalysis(),n++);
207   
208   maker->SetAnaDebug(kDebug)  ;
209   maker->SwitchOnHistogramsMaker()  ;
210   if(kData.Contains("delta")) maker->SwitchOffAODsMaker() ;
211   else                        maker->SwitchOnAODsMaker()  ;
212   
213   if(kPrint) maker->Print("");
214   
215   printf("<< End Configuration of %d analysis for calorimeter %s >>\n",n, kCalorimeter.Data());
216  
217   // Create task
218   
219   AliAnalysisTaskCaloTrackCorrelation * task = new AliAnalysisTaskCaloTrackCorrelation (Form("CaloTrackCorr%s",kName.Data()));
220   task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
221   task->SetDebugLevel(kDebug);
222   task->SetBranches("ESD:AliESDRun.,AliESDHeader"); 
223   task->SetAnalysisMaker(maker);
224   mgr->AddTask(task);
225   
226   //Create containers
227   
228   if(outputfile.Length()==0) outputfile = AliAnalysisManager::GetCommonFileName(); 
229   
230   AliAnalysisDataContainer *cout_pc   = mgr->CreateContainer(kName, TList::Class(), 
231                                                              AliAnalysisManager::kOutputContainer, 
232                                                              Form("%s",outputfile.Data()));
233         
234   AliAnalysisDataContainer *cout_cuts = mgr->CreateContainer(Form("Param_%s",kName.Data()), TList::Class(), 
235                                                              AliAnalysisManager::kParamContainer, 
236                                                              "AnalysisParameters.root");
237   
238   // Create ONLY the output containers for the data produced by the task.
239   // Get and connect other common input/output containers via the manager as below
240   //==============================================================================
241   mgr->ConnectInput  (task, 0, mgr->GetCommonInputContainer());
242   // AOD output slot will be used in a different way in future
243   if(!kData.Contains("delta")   && outputAOD) mgr->ConnectOutput (task, 0, mgr->GetCommonOutputContainer());
244   mgr->ConnectOutput (task, 1, cout_pc);
245   mgr->ConnectOutput (task, 2, cout_cuts);
246   
247   if(!kMix)
248   {    
249     UInt_t mask =  SetTriggerMaskFromName();
250     task->SelectCollisionCandidates(mask);
251   } 
252   
253   return task;
254 }
255
256 //____________________________________
257 AliCaloTrackReader * ConfigureReader()
258 {
259   
260   AliCaloTrackReader * reader = 0;
261   if     (kInputDataType == "ESD"&& kData=="MC" ) 
262     reader = new AliCaloTrackMCReader();
263   else if(kInputDataType=="AOD" || kData.Contains("AOD"))   
264     reader = new AliCaloTrackAODReader();
265   else if(kInputDataType=="ESD")            
266     reader = new AliCaloTrackESDReader();
267   else 
268     printf("AliCaloTrackReader::ConfigureReader() - Data combination not known kData=%s, kInputData=%s\n",kData.Data(),kInputDataType.Data());
269   
270   reader->SetDebug(kDebug);//10 for lots of messages
271   
272   /*
273    // Event rejection cuts for jet-jet simulations
274    reader->SetPtHardAndJetPtComparison(kTRUE);
275    reader->SetPtHardAndJetPtFactor(4);
276    
277    reader->SetPtHardAndClusterPtComparison(kTRUE);
278    reader->SetPtHardAndClusterPtFactor(1.5);
279    */
280   
281   //Delta AOD?
282   //reader->SetDeltaAODFileName("");
283   if(kOutputAOD) reader->SwitchOnWriteDeltaAOD()  ;
284   
285   // MC settings
286   if(kUseKinematics){
287     if(kInputDataType == "ESD"){
288       reader->SwitchOnStack();          
289       reader->SwitchOffAODMCParticles(); 
290     }
291     else if(kInputDataType == "AOD"){
292       reader->SwitchOffStack();          
293       reader->SwitchOnAODMCParticles(); 
294     }
295   }  
296   
297   //------------------------
298   // Detector input filling
299   //------------------------
300   
301   //Min cluster/track E
302   reader->SetEMCALEMin(0.3); 
303   reader->SetEMCALEMax(1000); 
304   reader->SetPHOSEMin(0.3);
305   reader->SetPHOSEMax(1000);
306   reader->SetCTSPtMin(0.2);
307   reader->SetCTSPtMax(1000);
308
309   // Time cuts
310   if(kSimulation) 
311   {
312     reader->SwitchOffUseTrackTimeCut();
313     reader->SwitchOffUseParametrizedTimeCut();
314     reader->SwitchOffUseEMCALTimeCut();
315     reader->SetEMCALTimeCut(-1000,1000); // Open time cut
316   }
317   else
318   {
319     if(kCalibT)
320     { 
321       printf("Set time cut parameters for run %d\n",kRunNumber);
322       reader->SwitchOnUseEMCALTimeCut();
323       reader->SwitchOnUseParametrizedTimeCut();
324       
325       //Absolute window
326       reader->SetEMCALTimeCut(-20,20);
327       
328       //Parametrization
329       if     (kRunNumber >= 151636 && kRunNumber <= 155384 )
330       {
331         printf("Set time parameters for LHC11c");
332         reader->SetEMCALParametrizedMinTimeCut(0,-5  ); reader->SetEMCALParametrizedMinTimeCut(1,-1 ); reader->SetEMCALParametrizedMinTimeCut(2, 1.87); reader->SetEMCALParametrizedMinTimeCut(3, 0.4);   
333         reader->SetEMCALParametrizedMaxTimeCut(0, 3.5); reader->SetEMCALParametrizedMaxTimeCut(1, 50); reader->SetEMCALParametrizedMaxTimeCut(2, 0.15); reader->SetEMCALParametrizedMaxTimeCut(3, 1.6);   
334       }
335       else if(kRunNumber >= 156447 && kRunNumber <= 159635 )
336       {
337         printf("Set time parameters for LHC11d");
338         reader->SetEMCALParametrizedMinTimeCut(0,-5);  reader->SetEMCALParametrizedMinTimeCut(1,-1 );  reader->SetEMCALParametrizedMinTimeCut(2, 3.5 ); reader->SetEMCALParametrizedMinTimeCut(3, 1.  );   
339         reader->SetEMCALParametrizedMaxTimeCut(0, 5);  reader->SetEMCALParametrizedMaxTimeCut(1, 50);  reader->SetEMCALParametrizedMaxTimeCut(2, 0.45); reader->SetEMCALParametrizedMaxTimeCut(3, 1.25);   
340       }
341       else
342       {
343         reader->SwitchOffUseParametrizedTimeCut();
344       }
345     }
346     else
347     {
348       reader->SwitchOffUseParametrizedTimeCut();
349       reader->SwitchOffUseEMCALTimeCut();
350       reader->SetEMCALTimeCut(-1000,1000); // Open time cut
351     }
352   }
353   
354   reader->SwitchOnFiducialCut();
355   reader->GetFiducialCut()->SetSimpleCTSFiducialCut(0.8, 0, 360) ;
356
357   // Tracks
358   reader->SwitchOnCTS();
359   if(kInputDataType=="ESD")
360   {
361     gROOT->LoadMacro("$ALICE_ROOT/PWGJE/macros/CreateTrackCutsPWGJE.C");
362     AliESDtrackCuts * esdTrackCuts = CreateTrackCutsPWGJE(10041004);
363     reader->SetTrackCuts(esdTrackCuts);
364     reader->SwitchOnConstrainTrackToVertex();
365   }
366   else if(kInputDataType=="AOD")
367   {
368     reader->SwitchOnAODHybridTrackSelection(); // Check that the AODs have Hybrids!!!!
369     //reader->SwitchOnTrackHitSPDSelection();    // Check that the track has at least a hit on the SPD, not much sense to use for hybrid or TPC only tracks
370     //reader->SetTrackFilterMask(128);           // Filter bit, not mask, use if off hybrid
371   }
372   
373   // Calorimeter
374   
375   reader->SetEMCALClusterListName(kClusterArray);
376   if(kClusterArray == "" && !kTender) 
377   {
378     printf("**************** Standard EMCAL clusters branch analysis **************** \n");
379     reader->SwitchOnClusterRecalculation();
380     // Check in ConfigureCaloUtils that the recalibration and bad map are ON 
381   }
382   else 
383   {
384     printf("**************** Input for analysis is Clusterizer %s **************** \n", kClusterArray.Data());
385     reader->SwitchOffClusterRecalculation();
386   }  
387   
388   //if(kCalorimeter == "EMCAL") {
389     reader->SwitchOnEMCALCells();  
390     reader->SwitchOnEMCAL();
391   //}
392   //if(kCalorimeter == "PHOS") { 
393     reader->SwitchOnPHOSCells();  
394     reader->SwitchOnPHOS();
395   //}
396   
397   // for case data="deltaAOD", no need to fill the EMCAL/PHOS cluster lists
398   if(kData.Contains("delta"))
399   {
400     reader->SwitchOffEMCAL();
401     reader->SwitchOffPHOS();
402     reader->SwitchOffEMCALCells(); 
403     reader->SwitchOffPHOSCells(); 
404   }
405   
406   //-----------------
407   // Event selection
408   //-----------------
409   
410   //if(!kUseKinematics) reader->SetFiredTriggerClassName("CEMC7EGA-B-NOPF-CENTNOTRD"); // L1 Gamma
411   
412   // For mixing with AliAnaParticleHadronCorrelation switch it off
413   if(kMix)
414   {
415     reader->SwitchOffEventTriggerAtSE();
416     UInt_t mask =  SetTriggerMaskFromName();
417     reader->SetEventTriggerMaks(mask); // Only for mixing and SwitchOffEventTriggerAtSE();
418     //reader->SetMixEventTriggerMaks(AliVEvent::kMB); // Careful, not all productions work with kMB, try kINT7, kINT1, kAnyINT
419     reader->SetMixEventTriggerMaks(AliVEvent::kAnyINT); // Careful, not all productions work with kMB, try kINT7, kINT1, kAnyINT
420     
421     printf("---Trigger selection done in AliCaloTrackReader!!!\n");
422   }
423   else
424     reader->SwitchOnEventTriggerAtSE();  
425   
426   reader->SetZvertexCut(10.);                // Open cut
427   reader->SwitchOnPrimaryVertexSelection(); // and besides primary vertex
428
429   if(kEventSelection)
430   {
431     reader->SwitchOnEventSelection();         // remove pileup by default
432     reader->SwitchOnV0ANDSelection() ;        // and besides v0 AND
433   }
434   else 
435   {
436     reader->SwitchOffEventSelection();         // remove pileup by default
437     reader->SwitchOffV0ANDSelection() ;        // and besides v0 AND
438   }
439     
440   if(kCollisions=="PbPb") 
441   {
442     // Centrality
443     reader->SetCentralityClass("V0M");
444     reader->SetCentralityOpt(10);  // 10 (c= 0-10, 10-20 ...), 20  (c= 0-5, 5-10 ...) or 100 (c= 1, 2, 3 ..)
445     reader->SetCentralityBin(kMinCen,kMaxCen); // Accept all events, if not select range
446     
447     // Event plane (only used in Maker and mixing for AliAnaPi0/AliAnaHadronCorrelation for the moment)
448     reader->SetEventPlaneMethod("V0");
449   }
450   
451   if     (kYears==2010) reader->SetImportGeometryFromFile(kTRUE,"$ALICE_ROOT/OADB/EMCAL/geometry_2010.root");
452   else if(kYears==2011) reader->SetImportGeometryFromFile(kTRUE,"$ALICE_ROOT/OADB/EMCAL/geometry_2011.root");
453   else                  reader->SetImportGeometryFromFile(kTRUE,"$ALICE_ROOT/OADB/EMCAL/geometry_2012.root");
454   
455   if(kPrint) reader->Print("");
456   
457   return reader;
458   
459 }
460
461 //_______________________________________
462 AliCalorimeterUtils* ConfigureCaloUtils()
463 {
464   
465   AliCalorimeterUtils *cu = new AliCalorimeterUtils;
466   cu->SetDebug(kDebug);
467   
468   // Remove clusters close to borders, at least max energy cell is 1 cell away 
469   cu->SetNumberOfCellsFromEMCALBorder(1);
470   cu->SetNumberOfCellsFromPHOSBorder(2);
471   
472   // Search of local maxima in cluster
473   if(kCollisions=="pp")
474   {
475     cu->SetLocalMaximaCutE(0.1);
476     cu->SetLocalMaximaCutEDiff(0.03);
477   }
478   else 
479   {
480     cu->SetLocalMaximaCutE(0.2);
481     cu->SetLocalMaximaCutEDiff(0.03);
482   }
483   
484   cu->SwitchOffClusterPlot();
485
486   if(kRecalTM) cu->SwitchOnRecalculateClusterTrackMatching(); // Done in clusterization
487   else         cu->SwitchOffRecalculateClusterTrackMatching();
488   
489   cu->SwitchOnBadChannelsRemoval() ;
490   
491   //EMCAL settings
492
493   if(!kSimulation)
494     cu->SwitchOnLoadOwnEMCALGeometryMatrices();
495   
496   AliEMCALRecoUtils * recou = cu->GetEMCALRecoUtils();
497   
498   if(!kSimulation)
499   {
500     cu->SwitchOnRecalibration(); // Check the reader if it is taken into account during filtering
501     cu->SwitchOnRunDepCorrection(); 
502   }
503   
504   gROOT->LoadMacro("$ALICE_ROOT/PWGGA/EMCALTasks/macros/ConfigureEMCALRecoUtils.C");
505   ConfigureEMCALRecoUtils(recou,
506                           kSimulation,                             
507                           kExotic,
508                           kNonLinearity,
509                           kCalibE, 
510                           kBadMap,
511                           kCalibT);   
512   
513   if( kNonLinearity ) 
514   { 
515     printf("ConfigureCaloUtils() - Apply non linearity to EMCAL\n");
516     cu->SwitchOnCorrectClusterLinearity();
517   }
518     
519   printf("ConfigureCaloUtils() - EMCAL Recalibration ON? %d %d\n",recou->IsRecalibrationOn(), cu->IsRecalibrationOn());
520   printf("ConfigureCaloUtils() - EMCAL BadMap        ON? %d %d\n",recou->IsBadChannelsRemovalSwitchedOn(), cu->IsBadChannelsRemovalSwitchedOn());
521   
522     
523   // PHOS 
524   cu->SwitchOffLoadOwnPHOSGeometryMatrices();
525     
526   if(kPrint) cu->Print("");
527   
528   return cu;
529   
530 }
531
532 //_____________________________________
533 AliAnaPhoton* ConfigurePhotonAnalysis()
534 {
535   
536   AliAnaPhoton *ana = new AliAnaPhoton();
537   ana->SetDebug(kDebug); //10 for lots of messages
538   
539   // cluster selection cuts
540   
541   ana->SwitchOffFiducialCut();
542
543   ana->SetCalorimeter(kCalorimeter);
544   
545   if(kCalorimeter == "PHOS")
546   {
547     ana->SetNCellCut(2);// At least 3 cells
548     ana->SetMinPt(0.3);
549     ana->SetMinDistanceToBadChannel(2, 4, 5);
550     ana->SetTimeCut(-2000,2000); // open cut
551   }
552   else 
553   {//EMCAL
554     ana->SetNCellCut(1);// At least 2 cells
555     ana->SetMinEnergy(0.3); // avoid mip peak at E = 260 MeV
556     ana->SetMaxEnergy(1000); 
557     ana->SetTimeCut(-1000,1000); // open cut, usual time window of [425-825] ns if time recalibration is off 
558     // restrict to less than 100 ns when time calibration is on 
559     ana->SetMinDistanceToBadChannel(2, 4, 6); 
560     
561     // NLM cut, used in all, exclude clusters with more than 2 maxima
562     // Not needed if M02 cut is already strong or clusterizer V2
563     ana->SetNLMCut(1, 2) ;
564   }
565   
566   if(kTM)
567   {
568     ana->SwitchOnTrackMatchRejection() ;
569     ana->SwitchOffTMHistoFill() ;
570   }
571   else
572   {
573     ana->SwitchOffTrackMatchRejection() ;
574     ana->SwitchOnTMHistoFill() ;
575   }
576   
577   //PID cuts (shower shape)
578   ana->SwitchOnCaloPID(); // do PID selection, unless specified in GetCaloPID, selection not based on bayesian
579   AliCaloPID* caloPID = ana->GetCaloPID();
580   //Not used in bayesian
581   
582   //EMCAL
583   caloPID->SetEMCALLambda0CutMax(0.27);
584   caloPID->SetEMCALLambda0CutMin(0.10);
585   
586   caloPID->SetEMCALDEtaCut(0.025);
587   caloPID->SetEMCALDPhiCut(0.030);
588     
589   //PHOS
590   caloPID->SetPHOSDispersionCut(2.5);
591   caloPID->SetPHOSRCut(2.);
592   if(kInputData=="AOD") caloPID->SetPHOSRCut(2000.); // Open cut since dX, dZ not stored
593       
594   ana->SwitchOffFillShowerShapeHistograms();  // Filled before photon shower shape selection
595   ana->SwitchOffFillPileUpHistograms();
596   
597   // Input / output delta AOD settings
598   
599   if(!kData.Contains("delta")) 
600   {
601     ana->SetOutputAODName(Form("Photon%s",kName.Data()));
602     ana->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
603     //ana->SetOutputAODClassName("AliAODPWG4Particle"); // use if no correlation done
604   }
605   else ana->SetInputAODName(Form("Photon%s",kName.Data()));
606   
607   //Set Histograms name tag, bins and ranges
608   
609   ana->AddToHistogramsName(Form("AnaPhoton_TM%d_",kTM));
610   SetHistoRangeAndNBins(ana->GetHistogramRanges()); // see method below
611   
612   // Number of particle type MC histograms
613   ana->FillNOriginHistograms(20);
614   ana->FillNPrimaryHistograms(20);
615   
616   ConfigureMC(ana);
617   
618   if(kPrint) ana->Print("");
619   
620   return ana;
621   
622 }
623
624 //________________________________________________________________________________
625 AliAnaElectron* ConfigureElectronAnalysis()
626 {
627   
628   AliAnaElectron *ana = new AliAnaElectron();
629   ana->SetDebug(kDebug); //10 for lots of messages
630     
631   if(kCalorimeter == "PHOS")
632   {
633     ana->SetNCellCut(2);// At least 2 cells
634     ana->SetMinPt(0.3);
635     ana->SetMinDistanceToBadChannel(2, 4, 5);
636   }
637   else 
638   {//EMCAL
639     ana->SetNCellCut(1);// At least 2 cells
640     ana->SetMinPt(0.5); // no effect minium EMCAL cut.
641     ana->SetMaxPt(100); 
642     //ana->SetTimeCut(400,900);// Time window of [400-900] ns
643     ana->SetMinDistanceToBadChannel(2, 4, 6);
644   }
645   
646   //Electron selection cuts with tracks
647   ana->SetEOverP(0.85, 1.2);
648   // TO DO, find a more suitable way to set this
649   if(kSimulation)
650   { // LHC11a
651     ana->SetdEdxCut(76, 85);
652   }
653   else // LHC11c
654   {
655     ana->SetdEdxCut(56, 64);
656   }
657   
658   ana->SetCalorimeter(kCalorimeter);
659   
660   ana->SwitchOnCaloPID();
661   
662   AliCaloPID* caloPID = ana->GetCaloPID();
663   
664   caloPID->SetEMCALLambda0CutMax(0.27);
665   caloPID->SetEMCALLambda0CutMin(0.10);
666
667   ana->SwitchOffFillShowerShapeHistograms();  
668   ana->SwitchOffFillWeightHistograms()  ;
669   ana->SwitchOffFiducialCut();
670   
671   //ana->FillAODWithHadrons();
672   
673   if(!kData.Contains("delta")) 
674   {
675     ana->SetOutputAODName(Form("Electron%s",kName.Data()));
676     ana->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
677   }
678   else ana->SetInputAODName(Form("Electron%s",kName.Data()));
679   
680   //Set Histograms name tag, bins and ranges
681   
682   ana->AddToHistogramsName(Form("AnaElectron_TM%d_",kTM));
683   SetHistoRangeAndNBins(ana->GetHistogramRanges()); // see method below
684   
685   ConfigureMC(ana);
686   
687   if(kPrint) ana->Print("");
688   
689   return ana ;
690   
691 }
692
693 //__________________________________________________________________________________________
694 AliAnaRandomTrigger* ConfigureRandomTriggerAnalysis(TString detector = "")
695 {
696   
697   AliAnaRandomTrigger *ana = new AliAnaRandomTrigger();
698   ana->SetDebug(kDebug); //10 for lots of messages
699   
700   if(detector=="") detector = kCalorimeter;
701   ana->SetDetector(detector);
702
703   // selection cuts
704   ana->SetMinPt(4.); 
705   ana->SetMaxPt(51.);   
706   
707   if     (detector=="EMCAL")
708   {
709     ana->SetEtaCut(-0.71,0.71);
710     ana->SetPhiCut(100*TMath::DegToRad(), 160*TMath::DegToRad());
711   }
712   else if(detector=="PHOS")
713   {
714     ana->SetEtaCut(-0.13,0.13);
715     ana->SetPhiCut(260*TMath::DegToRad(), 320*TMath::DegToRad());
716   }
717   else if(detector=="CTS")
718   {
719     ana->SetEtaCut(-0.9,0.9);
720     ana->SetPhiCut(0, TMath::TwoPi());
721   }
722   
723   // AOD branch
724   if(!kData.Contains("delta")) 
725   {
726     ana->SetOutputAODName(Form("RandomTrigger%s%s",detector.Data(),kName.Data()));
727     ana->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
728   }
729   else 
730     ana->SetInputAODName(Form("RandomTrigger%s%s",detector.Data(),kName.Data()));
731   
732   printf("Set RandomTrigger%s%s\n",detector.Data(),kName.Data());
733   
734   //Set Histograms name tag, bins and ranges
735   
736   ana->AddToHistogramsName(Form("AnaRandomTrigger%s_",detector.Data()));
737   
738   SetHistoRangeAndNBins(ana->GetHistogramRanges()); // see method below
739   
740   if(detector=="CTS")
741   {
742     ana->GetHistogramRanges()->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 200) ;
743     ana->GetHistogramRanges()->SetHistoEtaRangeAndNBins(-1.5, 1.5, 300) ;
744   }
745   
746   if(kPrint) ana->Print("");
747   
748   return ana;
749   
750 }
751
752 //__________________________________________________________________________________________
753 AliAnaInsideClusterInvariantMass* ConfigureInClusterIMAnalysis(Float_t l0min, Float_t l0max)
754 {
755   AliAnaInsideClusterInvariantMass *ana = new AliAnaInsideClusterInvariantMass();
756   ana->SetDebug(kDebug); //10 for lots of messages
757   
758   // selection cuts
759   
760   ana->SetMinEnergy(5); 
761   ana->SetMaxEnergy(200.);   
762   ana->SetMinNCells(3);
763   ana->SetM02Cut(l0min,l0max);
764   ana->SetCalorimeter(kCalorimeter);
765   
766   //ana->AddToHistogramsName(Form("AnaInClusterIM_%1.2f_%1.2f_",l0min,l0max));
767   ana->AddToHistogramsName("AnaInClusterIM_");
768
769   SetHistoRangeAndNBins(ana->GetHistogramRanges()); // see method below
770     
771   AliCaloPID* caloPID = ana->GetCaloPID();
772   caloPID->SetEMCALDEtaCut(0.025);
773   caloPID->SetEMCALDPhiCut(0.030);
774   caloPID->SetClusterSplittingM02Cut(0,100); // Do the selection in the analysis class and not in the PID method to fill SS histograms
775
776   caloPID->SetPi0MassRange(0.11, 0.18);
777   caloPID->SetEtaMassRange(0.40, 0.60);
778   caloPID->SetPhotonMassRange(0.00, 0.08);
779   
780   ConfigureMC(ana);
781   
782   if(kPrint) ana->Print("");
783   
784   return ana;
785   
786 }
787
788 //_______________________________________________
789 AliAnaChargedParticles* ConfigureChargedAnalysis()
790 {
791   
792   AliAnaChargedParticles *ana = new AliAnaChargedParticles();
793   ana->SetDebug(kDebug); //10 for lots of messages
794   
795   // selection cuts
796   
797   ana->SetMinPt(0.5);
798   ana->SwitchOnFiducialCut();
799   ana->GetFiducialCut()->SetSimpleCTSFiducialCut(0.8, 0, 360) ; //more restrictive cut in reader and after in isolation
800   ana->SwitchOffFillPileUpHistograms();
801
802   // Input / output delta AOD settings
803   
804   if(!kData.Contains("delta")) 
805   {
806     ana->SetOutputAODName(Form("Hadron%s",kName.Data()));
807     ana->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
808     //ana->SetOutputAODClassName("AliAODPWG4Particle"); // use if no correlation done
809   }
810   else 
811     ana->SetInputAODName(Form("Hadron%s",kName.Data()));
812   printf("Set Hadron%s\n",kName.Data());
813   //Set Histograms name tag, bins and ranges
814   
815   ana->AddToHistogramsName("AnaHadrons_");
816   SetHistoRangeAndNBins(ana->GetHistogramRanges()); // see method below
817
818   ana->GetHistogramRanges()->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 200) ;
819   ana->GetHistogramRanges()->SetHistoEtaRangeAndNBins(-1.5, 1.5, 300) ;
820   
821   ConfigureMC(ana);
822   
823   if(kPrint) ana->Print("");
824    
825   return ana;
826   
827 }
828
829
830 //_______________________________
831 AliAnaPi0* ConfigurePi0Analysis()
832 {
833   
834   AliAnaPi0 *ana = new AliAnaPi0();
835   
836   ana->SetDebug(kDebug);//10 for lots of messages
837   
838   // Input delta AOD settings
839   ana->SetInputAODName(Form("Photon%s",kName.Data()));
840   
841   // Calorimeter settings
842   ana->SetCalorimeter(kCalorimeter);
843   if(kCalorimeter=="PHOS") ana->SetNumberOfModules(3); //PHOS first year
844   else 
845   {                   
846     if     (kYears == 2010) ana->SetNumberOfModules( 4); // EMCAL first year
847     else if(kYears == 2011) ana->SetNumberOfModules(10); // Second year
848     else                    ana->SetNumberOfModules(12);
849   }
850   
851   //settings for pp collision mixing
852   ana->SwitchOnOwnMix(); //Off when mixing done with general mixing frame
853   
854   // Cuts 
855   if(kCalorimeter=="EMCAL") ana->SetPairTimeCut(70);
856   
857   if     (kCollisions=="pp"  ) 
858   {
859     ana->SetNCentrBin(1);
860     ana->SetNZvertBin(10);
861     ana->SetNRPBin(1);
862     ana->SetNMaxEvMix(100);    
863     ana->SwitchOnSMCombinations();
864   }
865   else if(kCollisions=="PbPb") 
866   {
867     ana->SetNCentrBin(10);
868     ana->SetNZvertBin(10);
869     ana->SetNRPBin(4);
870     ana->SetNMaxEvMix(10);
871     ana->SwitchOffSMCombinations();
872   }
873
874   ana->SwitchOffMultipleCutAnalysis();
875
876   //Set Histograms name tag, bins and ranges
877   
878   ana->AddToHistogramsName(Form("AnaPi0_TM%d_",kTM));
879   SetHistoRangeAndNBins(ana->GetHistogramRanges()); // see method below
880
881   ConfigureMC(ana);
882   
883   if(kPrint) ana->Print("");
884   
885   return ana;
886   
887 }
888
889 //_____________________________________________________
890 AliAnaPi0EbE* ConfigurePi0EbEAnalysis(TString particle, 
891                                       Int_t analysis)
892 {
893   
894   AliAnaPi0EbE *ana = new AliAnaPi0EbE();
895   ana->SetDebug(kDebug);//10 for lots of messages
896   
897   ana->SetAnalysisType(analysis);
898   TString opt = "";
899   if(analysis==AliAnaPi0EbE::kIMCaloTracks) opt = "Conv";
900   if(analysis==AliAnaPi0EbE::kSSCalo)       opt = "SS";
901   
902   if(kCollisions=="pp") ana->SetMinPt(0.5);
903   else                  ana->SetMinPt(1.0);
904   
905   if(kCalorimeter=="EMCAL")ana->SetPairTimeCut(20); // More strict than in pi0 inv mass analysis
906   
907   ana->SetCalorimeter(kCalorimeter);
908   
909   // Input / output delta AOD settings
910   
911   ana->SetInputAODName(Form("Photon%s",kName.Data()));
912   if(!kInputDataType.Contains("delta")) 
913   {
914     ana->SetOutputAODName(Form("%s%s%s",particle.Data(), opt.Data(), kName.Data()));
915     ana->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
916   }
917   else  
918     ana->SetInputAODName(Form("%s%s%s",particle.Data(),opt.Data(),kName.Data()));
919   
920   if(analysis == AliAnaPi0EbE::kIMCaloTracks) ana->SetInputAODGammaConvName("PhotonsCTS");
921     
922   if(analysis!=AliAnaPi0EbE::kSSCalo)
923   {
924     AliNeutralMesonSelection *nms = ana->GetNeutralMesonSelection();
925     nms->SetParticle(particle);
926     
927     // Tighten a bit mass cut with respect to default window
928     if(particle=="Pi0") nms->SetInvMassCutRange(0.120,0.150);
929     if(particle=="Eta") nms->SetInvMassCutRange(0.520,0.580);    
930     
931     nms->SwitchOffAngleSelection(); 
932     if(particle.Contains("Pi0SideBand")) // For pi0, do not consider left band
933       nms->SetSideBandCutRanges(-1,0,0.180,0.220);
934
935     nms->KeepNeutralMesonSelectionHistos(kTRUE);
936     //nms->SetAngleMaxParam(2,0.2);
937     nms->SetHistoERangeAndNBins(0, 20, 80) ;
938     //nms->SetHistoIMRangeAndNBins(0, 1, 400);
939   }
940   else
941   { // cluster splitting settings
942     ana->SetMinEnergy(5); 
943     ana->SetMaxEnergy(200.);   
944     ana->SetTimeCut(-1000,1000); // Open time cut
945     
946     // NLM cut, used in all, exclude clusters with more than 2 maxima
947     ana->SetNLMCut(1, 2) ;
948     
949     AliCaloPID* caloPID = ana->GetCaloPID();
950     caloPID->SetPi0MassRange(0.10, 0.18);
951     caloPID->SetEtaMassRange(0.40, 0.60);
952     caloPID->SetPhotonMassRange(0.00, 0.08);
953     caloPID->SetClusterSplittingM02Cut(0.3,5); // Do the selection in the analysis class and not in the PID method to fill SS histograms
954   }
955   
956   ana->SwitchOffSelectedClusterHistoFill(); 
957   ana->SwitchOffFillWeightHistograms();
958   ana->SwitchOffFillPileUpHistograms();
959
960   if(!kTM) ana->SwitchOnTMHistoFill();
961   else     ana->SwitchOffTMHistoFill();
962   
963   //Set Histograms name tag, bins and ranges
964   
965   ana->AddToHistogramsName(Form("Ana%s%sEbE_TM%d_",particle.Data(),opt.Data(),kTM));
966   SetHistoRangeAndNBins(ana->GetHistogramRanges()); // see method below
967   
968   ConfigureMC(ana);
969   
970   if(kPrint) ana->Print("");
971   
972   return  ana;
973   
974 }
975
976 //____________________________________________________________________________________________________
977 AliAnaParticleIsolation* ConfigureIsolationAnalysis(TString particle="Photon", 
978                                                     Int_t  partInCone = AliIsolationCut::kOnlyCharged,
979                                                     Int_t  thresType  = AliIsolationCut::kSumPtFracIC,
980                                                     Float_t cone = 0.3,
981                                                     Float_t pth  = 0.3,
982                                                     Bool_t multi      = kFALSE)
983 {
984   
985   AliAnaParticleIsolation *ana = new AliAnaParticleIsolation();
986   //ana->SetDebug(kDebug);
987   ana->SetDebug(kDebug);
988   
989   ana->SwitchOnFiducialCut();
990   //Avoid borders of EMCal
991   if(kCalorimeter=="EMCAL")
992     ana->GetFiducialCut()->SetSimpleEMCALFiducialCut(0.6, 86, 174) ;
993
994   // Same Eta as EMCal, cut in phi if EMCAL was triggering
995   if(particle=="Hadron"  || particle.Contains("CTS"))
996   {
997    // if(kTrig.Contains("EMC"))
998    //   ana->GetFiducialCut()->SetSimpleCTSFiducialCut  (0.6, 260, 360) ;
999    // else
1000       ana->GetFiducialCut()->SetSimpleCTSFiducialCut  (0.6, 0, 360) ;    
1001   }
1002   
1003   ana->SetMinPt(5);
1004   
1005   // Input / output delta AOD settings
1006   
1007   ana->SetInputAODName(Form("%s%s",particle.Data(),kName.Data()));
1008   ana->SetAODObjArrayName(Form("IC%s_%s",particle.Data(),kName.Data())); 
1009   
1010   ana->SetCalorimeter(kCalorimeter);
1011   
1012   if(!kTM)  ana->SwitchOnTMHistoFill();
1013   else      ana->SwitchOffTMHistoFill();
1014   
1015   ana->SwitchOffSSHistoFill();
1016   ana->SwitchOffFillPileUpHistograms();
1017
1018   //Do settings for main isolation cut class
1019   AliIsolationCut * ic =  ana->GetIsolationCut();       
1020   ic->SetDebug(kDebug);
1021   
1022   if(cone >0 && pth > 0)
1023   {
1024     ic->SetPtThreshold(pth);
1025     ic->SetConeSize(cone);
1026   }
1027   else
1028   {
1029     if(kCollisions=="pp") 
1030     {
1031       ic->SetPtThreshold(0.5);
1032       ic->SetConeSize(0.4);
1033     }
1034     if(kCollisions=="PbPb")
1035     {
1036       ic->SetPtThreshold(3.);
1037       //ic->SetPtThreshold(1.);
1038       ic->SetConeSize(0.3);
1039     }
1040   }
1041   
1042   ic->SetPtFraction(0.1);
1043   ic->SetSumPtThreshold(1.0) ;
1044   ic->SetParticleTypeInCone(partInCone);
1045   ic->SetICMethod(thresType);
1046   
1047   //Do or not do isolation with previously produced AODs.
1048   //No effect if use of SwitchOnSeveralIsolation()
1049   ana->SwitchOffReIsolation();
1050   
1051   //Multiple IC
1052   if(multi) 
1053   {
1054     ic->SetConeSize(1.);    // Take all for first iteration
1055     ic->SetPtThreshold(100);// Take all for first iteration
1056     ana->SwitchOnSeveralIsolation() ;
1057     ana->SetAODObjArrayName(Form("MultiIC%sTM%d",particle.Data(),kTM));
1058      
1059     ana->SetNCones(4);
1060     ana->SetNPtThresFrac(4);
1061     ana->SetConeSizes(0,0.3);       ana->SetConeSizes(1,0.4);
1062     ana->SetConeSizes(2,0.5);       ana->SetConeSizes(3,0.6);
1063     ana->SetPtThresholds(0, 0.5);   ana->SetPtThresholds(1, 1);     ana->SetPtThresholds(2, 2);
1064     ana->SetPtFractions (0, 0.05) ; ana->SetPtFractions (1, 0.1);   ana->SetPtFractions (2, 0.2) ;  ana->SetPtFractions (3, 0.3) ;
1065     ana->SetSumPtThresholds(0, 1) ; ana->SetSumPtThresholds(1, 3) ; ana->SetSumPtThresholds(2, 5);  ana->SetSumPtThresholds(3, 7)  ;
1066     
1067     ana->SwitchOffTMHistoFill();
1068     ana->SwitchOffSSHistoFill();
1069   }
1070   else      
1071     ana->SwitchOffSeveralIsolation() ;
1072   
1073   AliCaloPID* caloPID = ana->GetCaloPID();
1074   caloPID->SetEMCALDEtaCut(0.025);
1075   caloPID->SetEMCALDPhiCut(0.030);
1076   
1077   //Set Histograms name tag, bins and ranges
1078   
1079   if(!multi)ana->AddToHistogramsName(Form("AnaIsol%s_TM%d_",particle.Data(),kTM));
1080   else      ana->AddToHistogramsName(Form("AnaMultiIsol%s_TM%d_",particle.Data(),kTM));
1081
1082   SetHistoRangeAndNBins(ana->GetHistogramRanges()); // see method below
1083   
1084   ana->SetHistoPtInConeRangeAndNBins(0, 50 , 250);
1085   ana->SetHistoPtSumRangeAndNBins   (0, 100, 250);
1086   
1087   if(particle=="Hadron"  || particle.Contains("CTS"))
1088   {
1089     ana->GetHistogramRanges()->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 200) ;
1090     ana->GetHistogramRanges()->SetHistoEtaRangeAndNBins(-1.5, 1.5, 300) ;
1091   }
1092   
1093   ConfigureMC(ana);
1094   
1095   if(kPrint) ic ->Print("");
1096   if(kPrint) ana->Print("");
1097   
1098   return ana;
1099   
1100 }
1101
1102 //___________________________________________________________________________________
1103 AliAnaParticleHadronCorrelation* ConfigureHadronCorrelationAnalysis(TString particle, 
1104                                                                     Bool_t bIsolated,
1105                                                                     Int_t  partInCone = AliIsolationCut::kOnlyCharged,
1106                                                                     Int_t  thresType  = AliIsolationCut::kSumPtFracIC,
1107                                                                     Float_t cone = 0.3,
1108                                                                     Float_t pth  = 0.3)
1109 {
1110   
1111   AliAnaParticleHadronCorrelation *ana = new AliAnaParticleHadronCorrelation();
1112   ana->SetDebug(kDebug);
1113   
1114   ana->SetMinimumTriggerPt(5);
1115   ana->SetAssociatedPtRange(0.2,100); 
1116   ana->SetDeltaPhiCutRange( TMath::Pi()/2,3*TMath::Pi()/2 ); //[90 deg, 270 deg]
1117   
1118   ana->SetNAssocPtBins(9);
1119   
1120   ana->SetAssocPtBinLimit(0, 0.2) ;
1121   ana->SetAssocPtBinLimit(1, 0.5) ;
1122   ana->SetAssocPtBinLimit(2, 1)   ;
1123   ana->SetAssocPtBinLimit(3, 2)   ;
1124   ana->SetAssocPtBinLimit(4, 3)   ;
1125   ana->SetAssocPtBinLimit(5, 4)   ;
1126   ana->SetAssocPtBinLimit(6, 6)   ;
1127   ana->SetAssocPtBinLimit(7, 10)  ;
1128   ana->SetAssocPtBinLimit(8, 30)  ;
1129   ana->SetAssocPtBinLimit(9, 200) ;
1130   
1131   ana->SelectIsolated(bIsolated); // do correlation with isolated photons
1132   
1133   if(bIsolated)
1134   {
1135     //Do settings for main isolation cut class
1136     AliIsolationCut * ic =  ana->GetIsolationCut();     
1137     ic->SetDebug(kDebug);
1138     
1139     if(cone >0 && pth > 0)
1140     {
1141       ic->SetPtThreshold(pth);
1142       ic->SetConeSize(cone);
1143     }
1144     else
1145     {
1146       if(kCollisions=="pp") 
1147       {
1148         ic->SetPtThreshold(0.5);
1149         ic->SetConeSize(0.4);
1150       }
1151       if(kCollisions=="PbPb")
1152       {
1153         ic->SetPtThreshold(3.);
1154         //ic->SetPtThreshold(1.);
1155         ic->SetConeSize(0.3);
1156       }
1157     }
1158     
1159     ic->SetPtFraction(0.1);
1160     ic->SetSumPtThreshold(1.0) ;
1161     ic->SetParticleTypeInCone(partInCone);
1162     ic->SetICMethod(thresType);
1163     
1164   }  
1165   
1166   ana->SwitchOnAbsoluteLeading();  // Select trigger leading particle of all the selected tracks
1167   ana->SwitchOffNearSideLeading(); // Select trigger leading particle of all the particles at +-90 degrees, default
1168   
1169   // Mixing with own pool
1170   if(kMix)
1171   {
1172     ana->SwitchOnOwnMix();
1173     ana->SwitchOnFillNeutralInMixedEvent();
1174   }
1175   else
1176     ana->SwitchOffOwnMix();
1177   
1178   ana->SetNZvertBin(20);
1179   
1180   if(kCollisions=="pp")
1181   {
1182     ana->SetNMaxEvMix(100);    
1183     ana->SwitchOnTrackMultBins();
1184     ana->SetNCentrBin(9); // Fixed track mult values
1185     ana->SetNRPBin(1);
1186   }
1187   else 
1188   {
1189     ana->SetNMaxEvMix(10);    
1190     ana->SwitchOffTrackMultBins(); // centrality bins
1191     ana->SetNCentrBin(3); 
1192     ana->SetNRPBin(3);
1193     if(kName.Contains("60_90"))
1194     {
1195       printf("*** Set mixing for peripheral\n");
1196       ana->SetNMaxEvMix(50);    
1197       ana->SetNCentrBin(2); 
1198     }    
1199   }  
1200   
1201   ana->SwitchOnFiducialCut();
1202   
1203   //Avoid borders of EMCal, same as for isolation
1204   if(kCalorimeter=="EMCAL")
1205     ana->GetFiducialCut()->SetSimpleEMCALFiducialCut(0.6, 86, 174) ;
1206   
1207   // Same Eta as EMCal, cut in phi if EMCAL was triggering
1208   if(particle=="Hadron" || particle.Contains("CTS"))
1209   {
1210     //if(kTrig.Contains("EMC"))
1211     //  ana->GetFiducialCut()->SetSimpleCTSFiducialCut  (0.6, 260, 360) ;
1212     //else
1213       ana->GetFiducialCut()->SetSimpleCTSFiducialCut  (0.6, 0, 360) ;    
1214   }
1215   
1216   // Input / output delta AOD settings
1217   
1218   ana->SetInputAODName(Form("%s%s",particle.Data(),kName.Data()));
1219   ana->SetAODObjArrayName(Form("%sHadronCorrIso%d_%s",particle.Data(),bIsolated,kName.Data())); 
1220   
1221   // Fill extra plots on tagged decay photons
1222   // If trigger is pi0/eta found with invariant mass, get the decays
1223   // If trigger is photon, check if it was tagged as decay previously
1224   if(particle!="Hadron" )
1225   {
1226     if(particle.Contains("Pi0") || particle.Contains("Eta"))
1227     {
1228       ana->SwitchOffPi0TriggerDecayCorr();
1229       ana->SwitchOffDecayTriggerDecayCorr();
1230     }
1231     else
1232     {
1233       ana->SwitchOffPi0TriggerDecayCorr();
1234       ana->SwitchOnDecayTriggerDecayCorr(); // Make sure pi0 decay tagging runs before this task
1235     }
1236   }
1237   else
1238   {
1239     ana->SwitchOffPi0TriggerDecayCorr();
1240     ana->SwitchOffDecayTriggerDecayCorr(); 
1241   }
1242   
1243   if(particle=="Photon")
1244   {
1245     printf("**** SET M02 limits *** \n");
1246     ana->SetM02Cut(0.1,0.27);
1247   }
1248   
1249   // if triggering on PHOS and EMCAL is on
1250   //if(kCalorimeter=="PHOS") ana->SwitchOnNeutralCorr();
1251   ana->SwitchOffNeutralCorr(); // Do only correlation with TPC
1252   
1253   ana->SwitchOffHMPIDCorrelation();
1254   
1255   ana->SwitchOffFillBradHistograms();
1256   
1257   // Underlying event
1258   ana->SwitchOffEventSelection();
1259   ana->SwitchOnSeveralUECalculation();
1260   ana->SetUeDeltaPhiCutRange(TMath::Pi()/3, 2*TMath::Pi()/3);
1261   ana->SetMultiBin(1);
1262   
1263   //Set Histograms name tag, bins and ranges
1264   
1265   ana->AddToHistogramsName(Form("Ana%sHadronCorr_Iso%d_TM%d_",particle.Data(),bIsolated,kTM));
1266   SetHistoRangeAndNBins(ana->GetHistogramRanges()); // see method below
1267   
1268   if(particle=="Hadron"  || particle.Contains("CTS"))
1269   {
1270     ana->GetHistogramRanges()->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 200) ;
1271     ana->GetHistogramRanges()->SetHistoEtaRangeAndNBins(-1.5, 1.5, 300) ;
1272   }  
1273   
1274   ConfigureMC(ana);
1275   
1276   if(kPrint) ana->Print("");  
1277   
1278   return ana;
1279   
1280 }
1281
1282 //________________________________________
1283 AliAnaCalorimeterQA* ConfigureQAAnalysis()
1284 {
1285   
1286   AliAnaCalorimeterQA *ana = new AliAnaCalorimeterQA();
1287   ana->SetDebug(kDebug); //10 for lots of messages
1288   ana->SetCalorimeter(kCalorimeter);
1289   
1290   ana->SetTimeCut(-1000,1000); // Open time cut
1291   
1292   // Study inter detector correlation (PHOS, EMCAL, Tracks, V0)
1293   if(kCalorimeter=="PHOS"  && kTrig=="PHOS")
1294     ana->SwitchOnCorrelation(); // make sure you switch in the reader PHOS and EMCAL cells and clusters if option is ON
1295   if(kCalorimeter=="EMCAL" && kClusterArray=="")
1296     ana->SwitchOnCorrelation(); // make sure you switch in the reader PHOS and EMCAL cells and clusters if option is ON
1297   else 
1298     ana->SwitchOffCorrelation();
1299   
1300   // Study exotic clusters PHOS and EMCAL
1301   if(kClusterArray=="") ana->SwitchOnStudyBadClusters() ; 
1302   else                  ana->SwitchOffStudyBadClusters() ;
1303   
1304   
1305   ana->SwitchOffFiducialCut();
1306   ana->SwitchOffFillAllTH3Histogram();
1307   ana->SwitchOffFillAllPositionHistogram();
1308   ana->SwitchOffFillAllPositionHistogram2();
1309   if(!kExotic)ana->SwitchOnStudyBadClusters();
1310   else        ana->SwitchOffStudyBadClusters();
1311   ana->SwitchOffStudyClustersAsymmetry();
1312   ana->SwitchOffStudyWeight();
1313   ana->SwitchOnFillAllTrackMatchingHistogram();
1314   ana->SwitchOnFillAllCellTimeHisto() ;
1315
1316   if(kCalorimeter=="EMCAL")
1317   {
1318     if     (kYears==2010)  ana->SetNumberOfModules(4); 
1319     else if(kYears==2011)  ana->SetNumberOfModules(10);
1320     else                   ana->SetNumberOfModules(12); 
1321   }
1322   else 
1323   {//PHOS
1324     ana->SetNumberOfModules(3); 
1325   }
1326   
1327   ana->AddToHistogramsName("QA_"); //Begining of histograms name
1328   SetHistoRangeAndNBins(ana->GetHistogramRanges()); // see method below
1329   
1330   ConfigureMC(ana);
1331   
1332   if(kPrint) ana->Print("");    
1333   
1334   return ana;
1335   
1336 }
1337
1338 //________________________________________________________
1339 void ConfigureMC(AliAnaCaloTrackCorrBaseClass* ana)
1340 {
1341   if(kSimulation) ana->SwitchOnDataMC() ;//Access MC stack and fill more histograms, AOD MC not implemented yet.
1342   else            ana->SwitchOffDataMC() ;
1343
1344   //Set here generator name, default pythia
1345   //ana->GetMCAnalysisUtils()->SetMCGenerator("");
1346 }  
1347
1348 //________________________________________________________
1349 void SetHistoRangeAndNBins (AliHistogramRanges* histoRanges)
1350 {
1351   // Set common bins for all analysis and MC histograms filling
1352     
1353   histoRanges->SetHistoPtRangeAndNBins(0, 100, 200) ; // Energy and pt histograms
1354   
1355   if(kCalorimeter=="EMCAL")
1356   {
1357     if(kYears==2010)
1358     {
1359       histoRanges->SetHistoPhiRangeAndNBins(78*TMath::DegToRad(), 122*TMath::DegToRad(), 78) ;
1360       histoRanges->SetHistoXRangeAndNBins(-230,90,120); // QA
1361       histoRanges->SetHistoYRangeAndNBins(370,450,40);  // QA
1362     }
1363     else if(kYears==2011)
1364     {           
1365       histoRanges->SetHistoPhiRangeAndNBins(78*TMath::DegToRad(), 182*TMath::DegToRad(), 108) ;
1366       histoRanges->SetHistoXRangeAndNBins(-600,90,200); // QA
1367       histoRanges->SetHistoYRangeAndNBins(100,450,100); // QA
1368     }
1369     else
1370     {
1371       histoRanges->SetHistoPhiRangeAndNBins(78*TMath::DegToRad(), 190*TMath::DegToRad(), 122) ;
1372       histoRanges->SetHistoXRangeAndNBins(-100,90,200); // QA
1373       histoRanges->SetHistoYRangeAndNBins(50,450,100);  // QA
1374     }
1375
1376     histoRanges->SetHistoEtaRangeAndNBins(-0.72, 0.72, 144) ;
1377   }
1378   else
1379   {
1380     histoRanges->SetHistoPhiRangeAndNBins(260*TMath::DegToRad(), 320*TMath::DegToRad(), 60) ;
1381     histoRanges->SetHistoEtaRangeAndNBins(-0.13, 0.13, 130) ;
1382   }
1383   
1384   histoRanges->SetHistoShowerShapeRangeAndNBins(-0.1, 4.9, 500);
1385   
1386   // Invariant mass histoRangeslysis
1387   histoRanges->SetHistoMassRangeAndNBins(0., 1., 200) ;
1388   histoRanges->SetHistoAsymmetryRangeAndNBins(0., 1. , 100) ;
1389   
1390   // check if time calibration is on
1391   histoRanges->SetHistoTimeRangeAndNBins(-1000.,1000,1000);
1392   histoRanges->SetHistoDiffTimeRangeAndNBins(-200, 200, 800);
1393   
1394   // track-cluster residuals
1395   histoRanges->SetHistoTrackResidualEtaRangeAndNBins(-0.15,0.15,300);
1396   histoRanges->SetHistoTrackResidualPhiRangeAndNBins(-0.15,0.15,300);
1397   histoRanges->SetHistodRRangeAndNBins(0.,0.15,150);//QA
1398
1399   // QA, electron, charged
1400   histoRanges->SetHistoPOverERangeAndNBins(0,10.,100);
1401   histoRanges->SetHistodEdxRangeAndNBins(0.,200.,200);
1402   
1403   // QA
1404   histoRanges->SetHistoFinePtRangeAndNBins(0, 10, 200) ; // bining for fhAmpId
1405   histoRanges->SetHistoRatioRangeAndNBins(0.,2.,100);
1406   histoRanges->SetHistoVertexDistRangeAndNBins(0.,500.,500);
1407   histoRanges->SetHistoNClusterCellRangeAndNBins(0,500,500);
1408   histoRanges->SetHistoZRangeAndNBins(-400,400,200);
1409   histoRanges->SetHistoRRangeAndNBins(400,450,25);
1410   histoRanges->SetHistoV0SignalRangeAndNBins(0,5000,500);
1411   histoRanges->SetHistoV0MultiplicityRangeAndNBins(0,5000,500);
1412   histoRanges->SetHistoTrackMultiplicityRangeAndNBins(0,5000,500);
1413   
1414 }
1415
1416 //_____________________________
1417 UInt_t SetTriggerMaskFromName()
1418 {
1419   if(kTrig=="EMC7")
1420   {
1421     printf("CaloTrackCorr trigger EMC7\n");
1422     return AliVEvent::kEMC7;
1423   }
1424   else if (kTrig=="INT7")
1425   {
1426     printf("CaloTrackCorr trigger INT7\n");
1427     return AliVEvent::kINT7;
1428   }
1429   else if(kTrig=="EMC1")
1430   {
1431     printf("CaloTrackCorr trigger EMC1\n");
1432     return AliVEvent::kEMC1;
1433   }
1434   else if(kTrig=="MB")
1435   {
1436     printf("CaloTrackCorr trigger MB\n");
1437     return AliVEvent::kMB;
1438   }  
1439   else if(kTrig=="PHOS")
1440   {
1441     printf("CaloTrackCorr trigger PHOS\n");
1442     return AliVEvent::kPHI7;
1443   }  
1444   else if(kTrig=="PHOSPb")
1445   {
1446     printf("CaloTrackCorr trigger PHOSPb\n");
1447     return AliVEvent::kPHOSPb;
1448   }
1449   else if(kTrig=="AnyINT")
1450   {
1451     printf("CaloTrackCorr trigger AnyINT\n");
1452     return AliVEvent::kAnyINT;
1453   }  
1454   else if(kTrig=="INT")
1455   {
1456     printf("CaloTrackCorr trigger AnyINT\n");
1457     return AliVEvent::kAny;
1458   }
1459   else if(kTrig=="EMCEGA")
1460   {
1461     printf("CaloTrackCorr trigger EMC Gamma\n");
1462     return AliVEvent::kEMCEGA;
1463   } 
1464   else if(kTrig=="EMCEJE")
1465   {
1466     printf("CaloTrackCorr trigger EMC Jet\n");
1467     return AliVEvent::kEMCEJE;
1468   }
1469   else if(kTrig=="Central")
1470   {
1471     printf("CaloTrackCorr trigger Central\n");
1472     return AliVEvent::kCentral;
1473   } 
1474   else if(kTrig=="SemiCentral")
1475   {
1476     printf("CaloTrackCorr trigger SemiCentral\n");
1477     return AliVEvent::kSemiCentral;
1478   }
1479   else if(kTrig=="SemiOrCentral")
1480   {
1481     printf("CaloTrackCorr trigger SemiCentral Or Central\n");
1482     return (AliVEvent::kSemiCentral | AliVEvent::kCentral);
1483   }    
1484 }
1485