]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGGA/CaloTrackCorrelations/macros/AddTaskIsoPhoton.C
remove duplicated setting, and some cosmetics
[u/mrichter/AliRoot.git] / PWGGA / CaloTrackCorrelations / macros / AddTaskIsoPhoton.C
1 // Configuration macro for analysis of isolated photon spectra
2 // Author : Gustavo Conesa;  Marie Germain.
3
4 TString kAnaIsoPhotonName = "";
5 AliAnalysisTaskCaloTrackCorrelation *AddTaskIsoPhoton(const Float_t  cone          = 0.4,
6                                                       const Float_t  pth           = 5.,
7                                                       const Bool_t   timecut       = kFALSE,
8                                                       const TString  calorimeter   = "EMCAL",
9                                                       const Bool_t   simu          = kFALSE,
10                                                       const Bool_t   exotic        = kTRUE,
11                                                       const Bool_t   nonlin        = kFALSE,
12                                                       const TString  trigger       = "EMC7",
13                                                       const Bool_t   tm            = kTRUE,
14                                                       const Int_t    minCen        = -1,
15                                                       const Int_t    maxCen        = -1,
16                                                       const Float_t  deltaphicut   = 0.03,
17                                                       const Float_t  deltaetacut   = 0.02,
18                                                       const Int_t    disttobad     = 0,
19                                                       const Int_t    nlmMax        =  2,
20                                                       const Bool_t   qaan          = kFALSE,
21                                                       const Int_t    debug         = -1,
22                                                       const Bool_t   print         = kFALSE
23                                                       )
24 {
25   // Creates a CaloTrackCorr task, configures it and adds it to the analysis manager.
26   
27   printf("AddTaskIsoPhoton() - Settings: cone %2.2f, pth %2.2f, timeCut On %d, NLM max cut %d, calorimeter %s, simu %d, exotic %d, non lin %d, trigger %s, TM %d, qa %d, debug %d, centrality %d-%d\n",
28                                          cone,    pth,    timecut   ,    nlmMax,      calorimeter.Data(),simu, exotic,    nonlin,     trigger.Data(), tm,    qaan,   debug, minCen, maxCen );
29   
30   // Get the pointer to the existing analysis manager via the static access method.
31   
32   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
33   if (!mgr) 
34   {
35     ::Error("AddTask", "No analysis manager to connect to.");
36     return NULL;
37   }  
38   
39   // Check the analysis type using the event handlers connected to the analysis manager.
40   
41   if (!mgr->GetInputEventHandler()) 
42   {
43     ::Error("AddTask", "This task requires an input event handler");
44     return NULL;
45   }
46
47   // Make sure the B field is enabled for track selection, some cuts need it
48   ((AliInputEventHandler*)mgr->GetInputEventHandler())->SetNeedField(kTRUE);
49   
50   Bool_t useKinematics = kFALSE;
51   useKinematics = (mgr->GetMCtruthEventHandler())?kTRUE:kFALSE;
52
53   // Name for containers
54   
55   kAnaIsoPhotonName = Form("%s_Trig%s_TM%d_%1.3f_dB%d_R%1.1f_Pt%1.1f",calorimeter.Data(), trigger.Data(),tm,deltaphicut,disttobad,cone,pth);
56
57   if(maxCen>=0) kAnaIsoPhotonName+=Form("Cen%d_%d",minCen,maxCen);
58     
59   printf("<<<< NAME: %s >>>>>\n",kAnaIsoPhotonName.Data());
60   
61   // #### Configure analysis ####
62     
63   AliAnaCaloTrackCorrMaker * maker = new AliAnaCaloTrackCorrMaker();
64   
65   //maker->SetScaleFactor(scaleFactor); // for MC, negative (not scaled) by default
66   
67   // General frame setting and configuration
68   maker->SetReader   (ConfigureReader   (mgr->GetInputEventHandler()->GetDataType(),useKinematics,simu,
69                                          calorimeter,nonlin, timecut,minCen, maxCen, debug,print));
70   maker->SetCaloUtils(ConfigureCaloUtils(nonlin,exotic,simu,timecut,debug,print));
71   
72   // Analysis tasks setting and configuration
73   Int_t n = 0;//Analysis number, order is important
74
75   // Isolation settings
76   Int_t partInCone = AliIsolationCut::kNeutralAndCharged; // kOnlyCharged;
77   //  Int_t thresType  = AliIsolationCut::kPtThresIC;//  AliIsolationCut::kSumPtFracIC ; 
78   Int_t thresType  = AliIsolationCut::kSumPtIC ; 
79   
80   // Photon analysis
81   maker->AddAnalysis(ConfigurePhotonAnalysis(calorimeter,tm,deltaphicut,deltaetacut,disttobad,nlmMax,simu,debug,print), n++); // Photon cluster selection
82   
83   // Isolation analysis
84   maker->AddAnalysis(ConfigureIsolationAnalysis(calorimeter,"Photon", partInCone,thresType,cone, pth,tm,kFALSE,simu,debug,print), n++); // Photon isolation
85
86   // QA histograms on clusters or tracks
87   if(qaan)
88   {
89     maker->AddAnalysis(ConfigureQAAnalysis(calorimeter,simu,debug,print),n++);
90     maker->AddAnalysis(ConfigureChargedAnalysis(simu,debug), n++); // charged tracks plots
91   }
92   
93   maker->SetAnaDebug(debug)  ;
94   maker->SwitchOnHistogramsMaker()  ;
95   maker->SwitchOnAODsMaker()  ;
96   
97   if(print) maker->Print("");
98   
99   maker->SwitchOffDataControlHistograms();
100   
101   printf("<< End Configuration of %d analysis for calorimeter %s >>\n",n, calorimeter.Data());
102  
103   // Create task
104   
105   AliAnalysisTaskCaloTrackCorrelation * task = new AliAnalysisTaskCaloTrackCorrelation (Form("CaloTrackCorr%s",kAnaIsoPhotonName.Data()));
106   task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
107   task->SetDebugLevel(debug);
108   task->SetBranches("ESD:AliESDRun.,AliESDHeader"); 
109   task->SetAnalysisMaker(maker);
110   mgr->AddTask(task);
111   
112   //Create containers
113   
114   TString outputfile = AliAnalysisManager::GetCommonFileName();
115   
116   AliAnalysisDataContainer *cout_pc   = mgr->CreateContainer(kAnaIsoPhotonName, TList::Class(), 
117                                                              AliAnalysisManager::kOutputContainer, 
118                                                              Form("%s",outputfile.Data()));
119         
120   AliAnalysisDataContainer *cout_cuts = mgr->CreateContainer(Form("Param_%s",kAnaIsoPhotonName.Data()), TList::Class(), 
121                                                              AliAnalysisManager::kParamContainer, 
122                                                              "AnalysisParameters.root");
123   
124   // Create ONLY the output containers for the data produced by the task.
125   // Get and connect other common input/output containers via the manager as below
126   //==============================================================================
127   mgr->ConnectInput  (task, 0, mgr->GetCommonInputContainer());
128   // AOD output slot will be used in a different way in future
129   mgr->ConnectOutput (task, 1, cout_pc);
130   mgr->ConnectOutput (task, 2, cout_cuts);
131
132   // Set the trigger selection
133   UInt_t mask =  SetTriggerMaskFromName(trigger);
134   task->SelectCollisionCandidates(mask);
135   
136   return task;
137 }
138
139 //____________________________________
140 AliCaloTrackReader * ConfigureReader(TString inputDataType = "AOD", Bool_t useKinematics = kFALSE, Bool_t simu = kFALSE,
141                                      TString calorimeter = "EMCAL", Bool_t nonlin = kTRUE, Bool_t timecut = kFALSE,
142                                      Float_t minCen = -1, Float_t maxCen = -1,
143                                      Int_t debug = -1, Bool_t print = kFALSE)
144 {
145   // Init reader settings: event selection, basic cluster track cuts, etc
146   
147   if(simu)
148   {
149     if (!useKinematics && inputDataType=="AOD") useKinematics = kTRUE; //AOD primary should be available ...
150   }
151   
152   cout<<"********* ACCESS KINE? "<<useKinematics<< endl;
153
154   AliCaloTrackReader * reader = 0;
155   if     (inputDataType=="AOD") reader = new AliCaloTrackAODReader();
156   else if(inputDataType=="ESD") reader = new AliCaloTrackESDReader();
157   else  printf("AliCaloTrackReader::ConfigureReader() - Data not known inputData=%s\n",inputDataType.Data());
158   
159   reader->SetDebug(debug);//10 for lots of messages
160   
161   reader->SwitchOffTriggerPatchMatching();
162   reader->SwitchOffBadTriggerEventsRemoval();
163   
164   reader->SwitchOffWriteDeltaAOD()  ;
165   
166   // MC settings
167   if(useKinematics)
168   {
169     if(inputDataType == "ESD")
170     {
171       reader->SwitchOnStack();          
172       reader->SwitchOffAODMCParticles(); 
173     }
174     else if(inputDataType == "AOD")
175     {
176       reader->SwitchOffStack();          
177       reader->SwitchOnAODMCParticles(); 
178     }
179   }  
180   
181   //------------------------
182   // Detector input filling
183   //------------------------
184   
185   //Min cluster/track E
186   reader->SetEMCALEMin(0.3); 
187   reader->SetEMCALEMax(1000); 
188   reader->SetPHOSEMin(0.3);
189   reader->SetPHOSEMax(1000);
190   reader->SetCTSPtMin(0.2);
191   reader->SetCTSPtMax(1000);
192
193   // Time cuts
194   if(simu)
195   {
196     reader->SwitchOffUseTrackTimeCut();
197     reader->SwitchOffUseParametrizedTimeCut();
198     reader->SwitchOffUseEMCALTimeCut();
199     reader->SetEMCALTimeCut(-1e10,1e10); // Open time cut
200   }
201   else
202   {
203     reader->SwitchOffUseParametrizedTimeCut();
204
205     if(timecut)
206     {
207       printf("Set time cut \n");
208       reader->SwitchOnUseEMCALTimeCut();
209       //Absolute window
210       reader->SetEMCALTimeCut(-30.,30.); // default is -25ns-20ns
211     }
212     else
213     {
214       printf("Off time cuts time cut \n");
215       reader->SwitchOffUseEMCALTimeCut();
216       //Absolute window
217       reader->SetEMCALTimeCut(-1.e6,1.e6);
218     }
219   }
220   
221   reader->SwitchOffFiducialCut();
222   reader->GetFiducialCut()->SetSimpleCTSFiducialCut(0.8, 0, 360) ;
223
224   // Tracks
225   reader->SwitchOnCTS();
226
227
228   reader->SwitchOffRecalculateVertexBC();
229   reader->SwitchOffVertexBCEventSelection();
230   
231   reader->SwitchOffUseTrackTimeCut();
232   reader->SetTrackTimeCut(0,50);
233   
234   reader->SwitchOffUseTrackDCACut();
235   //reader->SetTrackDCACut(0,0.0105);
236   //reader->SetTrackDCACut(1,0.035);
237   //reader->SetTrackDCACut(2,1.1);
238   
239   if(inputDataType=="ESD")
240   {
241     gROOT->LoadMacro("$ALICE_ROOT/PWGJE/macros/CreateTrackCutsPWGJE.C");
242     //AliESDtrackCuts * esdTrackCuts = CreateTrackCutsPWGJE(10041004);
243     //reader->SetTrackCuts(esdTrackCuts);
244     //reader->SwitchOnConstrainTrackToVertex();
245     
246 //    if(kYears>2010)
247     {
248       //Hybrids 2011
249       AliESDtrackCuts * esdTrackCuts  = CreateTrackCutsPWGJE(10001008);
250       reader->SetTrackCuts(esdTrackCuts);
251       AliESDtrackCuts * esdTrackCuts2 = CreateTrackCutsPWGJE(10011008);
252       reader->SetTrackComplementaryCuts(esdTrackCuts2);
253     }
254 //    else
255 //    {
256 //      //Hybrids 2010
257 //      AliESDtrackCuts * esdTrackCuts  = CreateTrackCutsPWGJE(10001006);
258 //      reader->SetTrackCuts(esdTrackCuts);
259 //      AliESDtrackCuts * esdTrackCuts2 = CreateTrackCutsPWGJE(10041006);
260 //      reader->SetTrackComplementaryCuts(esdTrackCuts2);
261 //    }
262   }
263   else if(inputDataType=="AOD")
264   {
265     //reader->SetTrackFilterMask(128);           // Filter bit, not mask, use if off hybrid
266     reader->SwitchOnAODHybridTrackSelection(); // Check that the AODs have Hybrids!!!!
267     reader->SetTrackStatus(AliVTrack::kITSrefit);
268     //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
269   }
270   
271   // Calorimeter
272   
273   reader->SwitchOffClusterRecalculation();
274   
275   
276   // CAREFUL
277   if(!nonlin) reader->SwitchOffClusterELinearityCorrection();
278   else        reader->SwitchOnClusterELinearityCorrection();
279   
280   if(calorimeter == "EMCAL") {
281     reader->SwitchOnEMCALCells();
282     reader->SwitchOnEMCAL();
283   }
284   if(calorimeter == "PHOS") { // Should be on if QA is activated with correlation on
285     reader->SwitchOffPHOSCells();
286     reader->SwitchOffPHOS();
287   }
288   
289   //-----------------
290   // Event selection
291   //-----------------
292   
293   //if(!kUseKinematics) reader->SetFiredTriggerClassName("CEMC7EGA-B-NOPF-CENTNOTRD"); // L1 Gamma
294   
295   // reader->RejectFastClusterEvents() ;
296   
297   reader->SwitchOnEventTriggerAtSE();
298   
299   reader->SetZvertexCut(10.);               // Open cut
300   reader->SwitchOnPrimaryVertexSelection(); // and besides primary vertex
301   reader->SwitchOnRejectNoTrackEvents();
302  
303   reader->SwitchOffPileUpEventRejection();   // remove pileup
304   reader->SwitchOffV0ANDSelection() ;        // and besides v0 AND
305
306   if(maxCen > 0 )
307   {
308     // Centrality
309     reader->SetCentralityClass("V0M");
310     reader->SetCentralityOpt(100);  // 10 (c= 0-10, 10-20 ...), 20  (c= 0-5, 5-10 ...) or 100 (c= 1, 2, 3 ..)
311     reader->SetCentralityBin(minCen,maxCen); // Accept all events, if not select range
312     
313     // Event plane (only used in Maker and mixing for AliAnaPi0/AliAnaHadronCorrelation for the moment)
314     reader->SetEventPlaneMethod("V0");
315   }
316   
317   if(print) reader->Print("");
318   
319   return reader;
320     
321 }
322
323 //_______________________________________
324 AliCalorimeterUtils* ConfigureCaloUtils(Bool_t nonlin = kTRUE, Bool_t exotic = kTRUE ,Bool_t simu = kFALSE, Bool_t timecut = kFALSE, Int_t debug = -1, Bool_t print = kFALSE)
325 {
326   
327   AliCalorimeterUtils *cu = new AliCalorimeterUtils;
328   cu->SetDebug(debug);
329   
330   // Remove clusters close to borders, at least max energy cell is 1 cell away 
331   cu->SetNumberOfCellsFromEMCALBorder(1);
332   cu->SetNumberOfCellsFromPHOSBorder(2);
333   
334   cu->SwitchOffRecalculateClusterTrackMatching();
335   
336   cu->SwitchOffBadChannelsRemoval() ;
337   
338   //EMCAL settings
339
340   if(simu)
341     cu->SwitchOnLoadOwnEMCALGeometryMatrices();
342   
343   /*  AliEMCALRecoUtils * recou = cu->GetEMCALRecoUtils();
344   
345   cu->SwitchOffRecalibration();
346   cu->SwitchOffRunDepCorrection();
347   
348   gROOT->LoadMacro("$ALICE_ROOT/PWGGA/EMCALTasks/macros/ConfigureEMCALRecoUtils.C");
349   ConfigureEMCALRecoUtils(recou,
350                           simu,
351                           exotic,
352                           nonlin,
353                           kFALSE, // e calib
354                           kFALSE, // bad map
355                           kFALSE); // time calib
356   if(timecut) recou->SetExoticCellDiffTimeCut(50.);
357   */
358   if( nonlin)
359   { 
360     printf("ConfigureCaloUtils() - Apply non linearity to EMCAL\n");
361     cu->SwitchOnCorrectClusterLinearity();
362   }
363   /*   
364   printf("ConfigureCaloUtils() - EMCAL Recalibration ON? %d %d\n",recou->IsRecalibrationOn(), cu->IsRecalibrationOn());
365   printf("ConfigureCaloUtils() - EMCAL BadMap        ON? %d %d\n",recou->IsBadChannelsRemovalSwitchedOn(), cu->IsBadChannelsRemovalSwitchedOn());
366   */
367   cu->SetNumberOfSuperModulesUsed(10);
368
369   if(print) cu->Print("");
370   
371   return cu;
372   
373 }
374
375 //_____________________________________
376 AliAnaPhoton* ConfigurePhotonAnalysis(TString calorimeter = "EMCAL", Bool_t tm = kFALSE, Float_t deltaphicut = 0.02, Float_t deltaetacut = 0.03,Int_t disttobad=0,Int_t nlmMax = 2, Bool_t simu = kFALSE, Int_t debug = -1, Bool_t print = kFALSE)
377 {
378   
379   AliAnaPhoton *ana = new AliAnaPhoton();
380   ana->SetDebug(debug); //10 for lots of messages
381   
382   // cluster selection cuts
383   
384   ana->SwitchOffFiducialCut();
385
386   ana->SetCalorimeter(calorimeter);
387   
388   if(calorimeter == "PHOS")
389   {
390     ana->SetNCellCut(2);// At least 3 cells
391     ana->SetMinPt(0.3);
392     ana->SetMinDistanceToBadChannel(2, 4, 5);
393     ana->SetTimeCut(-1e10,1e10); // open cut
394   }
395   else 
396   {//EMCAL
397     ana->SetNCellCut(1);// At least 2 cells
398     ana->SetMinEnergy(0.3); // avoid mip peak at E = 260 MeV
399     ana->SetMaxEnergy(1000); 
400     //    ana->SetTimeCut(-1e10,1e10); // open cut, usual time window of [425-825] ns if time recalibration is off 
401     // restrict to less than 100 ns when time calibration is on 
402     ana->SetMinDistanceToBadChannel(disttobad, 4, 6); 
403     
404     // NLM cut, used in all, exclude clusters with more than 2 maxima
405     // Not needed if M02 cut is already strong or clusterizer V2
406     ana->SetNLMCut(1, nlmMax) ;
407   }
408   
409   if(tm)
410   {
411     ana->SwitchOnTrackMatchRejection() ;
412     ana->SwitchOffTMHistoFill() ;
413   }
414   else
415   {
416     ana->SwitchOffTrackMatchRejection() ;
417     ana->SwitchOnTMHistoFill() ;
418   }
419   
420   //PID cuts (shower shape)
421   ana->SwitchOnCaloPID(); // do PID selection, unless specified in GetCaloPID, selection not based on bayesian
422   AliCaloPID* caloPID = ana->GetCaloPID();
423   //Not used in bayesian
424   
425   //EMCAL
426   caloPID->SetEMCALLambda0CutMax(10.);
427   caloPID->SetEMCALLambda0CutMin(0.10);
428   
429   // caloPID->SetEMCALDEtaCut(0.025);
430   // caloPID->SetEMCALDPhiCut(0.030);
431   caloPID->SetEMCALDEtaCut(deltaetacut);
432   caloPID->SetEMCALDPhiCut(deltaphicut);
433
434   ana->SwitchOnFillShowerShapeHistograms();  // Filled before photon shower shape selection
435   if(!simu) ana->SwitchOnFillPileUpHistograms();
436
437   // Input / output delta AOD settings
438   
439   ana->SetOutputAODName(Form("Photon%s",kAnaIsoPhotonName.Data()));
440   ana->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
441   
442   //Set Histograms name tag, bins and ranges
443   
444   ana->AddToHistogramsName(Form("AnaPhoton_TM%d_",tm));
445   SetHistoRangeAndNBins(ana->GetHistogramRanges(), calorimeter); // see method below
446   
447   // Number of particle type MC histograms
448   ana->FillNOriginHistograms(20);
449   ana->FillNPrimaryHistograms(20);
450   
451   ConfigureMC(ana,simu);
452   
453   if(print) ana->Print("");
454   
455   return ana;
456   
457 }
458
459 //____________________________________________________________________________________________________
460 AliAnaParticleIsolation* ConfigureIsolationAnalysis(TString calorimeter = "EMCAL", TString particle="Photon",
461                                                     Int_t  partInCone = AliIsolationCut::kOnlyCharged,
462                                                     Int_t  thresType  = AliIsolationCut::kSumPtFracIC,
463                                                     Float_t cone = 0.3,
464                                                     Float_t pth  = 0.3,
465                                                     Bool_t tm = kFALSE,
466                                                     Bool_t multi = kFALSE, Bool_t simu = kFALSE,
467                                                     Int_t debug = -1, Bool_t print = kFALSE)
468 {
469   
470   AliAnaParticleIsolation *ana = new AliAnaParticleIsolation();
471   ana->SetDebug(debug);
472   
473   ana->SwitchOnFiducialCut();
474   //Avoid borders of EMCal
475   if(calorimeter=="EMCAL")
476   {
477     //ana->GetFiducialCut()->SetSimpleEMCALFiducialCut(0.6, 86, 174) ;
478     ana->GetFiducialCut()->SetSimpleEMCALFiducialCut(0.27, 103, 157) ;
479   }
480   
481   ana->SetMinPt(5);
482   
483   // Input / output delta AOD settings
484   
485   ana->SetInputAODName(Form("%s%s",particle.Data(),kAnaIsoPhotonName.Data()));
486   ana->SetAODObjArrayName(Form("IC%s_%s",particle.Data(),kAnaIsoPhotonName.Data())); 
487   
488   ana->SetCalorimeter(calorimeter);
489   
490   if(!tm)  ana->SwitchOnTMHistoFill();
491   else     ana->SwitchOffTMHistoFill();
492   //   ana->SwitchOnTMHistoFill();
493  
494   // ana->SwitchOffSSHistoFill();
495   // if(!kSimulation) ana->SwitchOnFillPileUpHistograms();
496    ana->SwitchOnSSHistoFill();
497   if(!simu) ana->SwitchOnFillPileUpHistograms();
498
499   //Do settings for main isolation cut class
500   AliIsolationCut * ic =  ana->GetIsolationCut();       
501   ic->SetDebug(debug);
502   
503   printf("\t *** Set: R = %2.2f, Threshold %2.2f, Method %d, Neutral/Charged option %d ***\n",cone,pth,thresType,partInCone);
504   
505   //Main parameters
506   //****
507   ic->SetConeSize(cone);
508   
509   ic->SetPtFraction    (0.1);
510   ic->SetPtThreshold   (pth);
511   ic->SetSumPtThreshold(pth);
512   
513   ic->SetParticleTypeInCone(partInCone);
514   
515   ic->SetICMethod(thresType);
516   //****
517   
518   //Do or not do isolation with previously produced AODs.
519   //No effect if use of SwitchOnSeveralIsolation()
520   ana->SwitchOffReIsolation();
521   
522   //Multiple IC
523   if(multi) 
524   {
525     ic->SetConeSize(1.);    // Take all for first iteration
526     ic->SetPtThreshold(100);// Take all for first iteration
527     ana->SwitchOnSeveralIsolation() ;
528     ana->SetAODObjArrayName(Form("MultiIC%sTM%d",particle.Data(),tm));
529      
530     ana->SetNCones(4);
531     ana->SetNPtThresFrac(4);
532     ana->SetConeSizes(0,0.3);       ana->SetConeSizes(1,0.4);
533     ana->SetConeSizes(2,0.5);       ana->SetConeSizes(3,0.6);
534     ana->SetPtThresholds(0, 0.5);   ana->SetPtThresholds(1, 1);     ana->SetPtThresholds(2, 2);
535     ana->SetPtFractions (0, 0.05) ; ana->SetPtFractions (1, 0.1);   ana->SetPtFractions (2, 0.2) ;  ana->SetPtFractions (3, 0.3) ;
536     ana->SetSumPtThresholds(0, 1) ; ana->SetSumPtThresholds(1, 3) ; ana->SetSumPtThresholds(2, 5);  ana->SetSumPtThresholds(3, 7)  ;
537     
538     ana->SwitchOffTMHistoFill();
539     ana->SwitchOffSSHistoFill();
540   }
541   else      
542     ana->SwitchOffSeveralIsolation() ;
543   
544   AliCaloPID* caloPID = ana->GetCaloPID();
545   caloPID->SetEMCALDEtaCut(0.02);
546   caloPID->SetEMCALDPhiCut(0.030);
547   
548   //Set Histograms name tag, bins and ranges
549   
550   if(!multi)ana->AddToHistogramsName(Form("AnaIsol%s_TM%d_",particle.Data(),tm));
551   else      ana->AddToHistogramsName(Form("AnaMultiIsol%s_TM%d_",particle.Data(),tm));
552
553   SetHistoRangeAndNBins(ana->GetHistogramRanges(),calorimeter); // see method below
554   
555   ana->SetHistoPtInConeRangeAndNBins(0, 50 , 250);
556   ana->SetHistoPtSumRangeAndNBins   (0, 100, 250);
557   
558   if(particle=="Hadron"  || particle.Contains("CTS"))
559   {
560     ana->GetHistogramRanges()->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 200) ;
561     ana->GetHistogramRanges()->SetHistoEtaRangeAndNBins(-1.5, 1.5, 300) ;
562   }
563   
564   ConfigureMC(ana,simu);
565   
566   if(print) ic ->Print("");
567   if(print) ana->Print("");
568   
569   return ana;
570   
571 }
572
573
574 //________________________________________
575 AliAnaCalorimeterQA* ConfigureQAAnalysis(TString calorimeter = "EMCAL", Bool_t simu = kFALSE, Int_t debug = -1, Bool_t print = kFALSE)
576 {
577   
578   AliAnaCalorimeterQA *ana = new AliAnaCalorimeterQA();
579   ana->SetDebug(debug); //10 for lots of messages
580   ana->SetCalorimeter(calorimeter);
581   
582   ana->SetTimeCut(-1e10,1e10); // Open time cut
583   ana->SwitchOffCorrelation();
584   
585   // Study exotic clusters PHOS and EMCAL
586   ana->SwitchOffStudyBadClusters() ;
587   
588   
589   ana->SwitchOffFiducialCut();
590   ana->SwitchOffFillAllTH3Histogram();
591   ana->SwitchOffFillAllPositionHistogram();
592   ana->SwitchOffFillAllPositionHistogram2();
593   ana->SwitchOffStudyBadClusters();
594   ana->SwitchOffStudyClustersAsymmetry();
595   ana->SwitchOffStudyWeight();
596   ana->SwitchOnFillAllTrackMatchingHistogram();
597   ana->SwitchOnFillAllCellTimeHisto() ;
598
599   
600   ana->AddToHistogramsName("QA_"); //Begining of histograms name
601   SetHistoRangeAndNBins(ana->GetHistogramRanges(),calorimeter); // see method below
602   
603   ConfigureMC(ana,simu);
604   
605   if(print) ana->Print("");
606   
607   return ana;
608   
609 }
610
611 //___________________________________________________________________________________
612 AliAnaChargedParticles* ConfigureChargedAnalysis(Bool_t simulation, Int_t debugLevel)
613 {
614   
615   AliAnaChargedParticles *ana = new AliAnaChargedParticles();
616   ana->SetDebug(debugLevel); //10 for lots of messages
617   
618   // selection cuts
619   
620   ana->SetMinPt(0.5);
621   ana->SwitchOnFiducialCut();
622   ana->GetFiducialCut()->SetSimpleCTSFiducialCut(0.8, 0, 360) ; //more restrictive cut in reader and after in isolation
623   
624   ana->SwitchOffFillVertexBC0Histograms() ;
625   //if(!simulation) ana->SwitchOnFillPileUpHistograms();
626   
627   // Input / output delta AOD settings
628   
629   ana->SetOutputAODName(Form("Hadron%s",kAnaIsoPhotonName.Data()));
630   ana->SetOutputAODClassName("AliAODPWG4Particle");
631   ana->SetInputAODName(Form("Hadron%s",kAnaIsoPhotonName.Data()));
632   
633   //Set Histograms name tag, bins and ranges
634   
635   ana->AddToHistogramsName("AnaHadrons_");
636   SetHistoRangeAndNBins(ana->GetHistogramRanges(),""); // see method below
637   
638   ana->GetHistogramRanges()->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 200) ;
639   ana->GetHistogramRanges()->SetHistoEtaRangeAndNBins(-1.5, 1.5, 300) ;
640   
641   if(debugLevel > 0) ana->Print("");
642   
643   return ana;
644   
645 }
646
647 //________________________________________________________
648 void ConfigureMC(AliAnaCaloTrackCorrBaseClass* ana, Bool_t simu = kFALSE)
649 {
650   if(simu) ana->SwitchOnDataMC() ;//Access MC stack and fill more histograms, AOD MC not implemented yet.
651   else     ana->SwitchOffDataMC() ;
652
653   //Set here generator name, default pythia
654   //ana->GetMCAnalysisUtils()->SetMCGenerator("");
655 }  
656
657 //________________________________________________________
658 void SetHistoRangeAndNBins (AliHistogramRanges* histoRanges, TString calorimeter = "EMCAL")
659 {
660   // Set common bins for all analysis and MC histograms filling
661     
662   histoRanges->SetHistoPtRangeAndNBins(-0.25, 99.75, 200) ; // Energy and pt histograms
663   
664   if(calorimeter=="EMCAL")
665   {
666     
667     histoRanges->SetHistoPhiRangeAndNBins(78*TMath::DegToRad(), 182*TMath::DegToRad(), 108) ;
668     histoRanges->SetHistoXRangeAndNBins(-600,90,200); // QA
669     histoRanges->SetHistoYRangeAndNBins(100,450,100); // QA
670
671     histoRanges->SetHistoEtaRangeAndNBins(-0.72, 0.72, 144) ;
672   }
673   else
674   {
675     histoRanges->SetHistoPhiRangeAndNBins(260*TMath::DegToRad(), 320*TMath::DegToRad(), 60) ;
676     histoRanges->SetHistoEtaRangeAndNBins(-0.13, 0.13, 130) ;
677   }
678   
679   histoRanges->SetHistoShowerShapeRangeAndNBins(-0.1, 4.9, 500);
680   
681   // Invariant mass histoRangeslysis
682   histoRanges->SetHistoMassRangeAndNBins(0., 1., 200) ;
683   histoRanges->SetHistoAsymmetryRangeAndNBins(0., 1. , 100) ;
684   
685   // check if time calibration is on
686   histoRanges->SetHistoTimeRangeAndNBins(-1000.,1000,1000);
687   histoRanges->SetHistoDiffTimeRangeAndNBins(-200, 200, 800);
688   
689   // track-cluster residuals
690   histoRanges->SetHistoTrackResidualEtaRangeAndNBins(-0.15,0.15,300);
691   histoRanges->SetHistoTrackResidualPhiRangeAndNBins(-0.15,0.15,300);
692   histoRanges->SetHistodRRangeAndNBins(0.,0.15,150);//QA
693
694   // QA, electron, charged
695   histoRanges->SetHistoPOverERangeAndNBins(0,  2.5 ,500);
696   histoRanges->SetHistodEdxRangeAndNBins  (0.,250.0,500);
697   
698   // QA
699   histoRanges->SetHistoFinePtRangeAndNBins(0, 10, 200) ; // bining for fhAmpId
700   histoRanges->SetHistoRatioRangeAndNBins(0.,2.,100);
701   histoRanges->SetHistoVertexDistRangeAndNBins(0.,500.,500);
702   histoRanges->SetHistoNClusterCellRangeAndNBins(0,50,50);
703   histoRanges->SetHistoZRangeAndNBins(-400,400,200);
704   histoRanges->SetHistoRRangeAndNBins(400,450,25);
705   histoRanges->SetHistoV0SignalRangeAndNBins(0,5000,500);
706   histoRanges->SetHistoV0MultiplicityRangeAndNBins(0,5000,500);
707   histoRanges->SetHistoTrackMultiplicityRangeAndNBins(0,5000,500);
708   
709 }
710
711 //_____________________________
712 UInt_t SetTriggerMaskFromName(TString trigger)
713 {
714   if(trigger=="EMC7")
715   {
716     printf("CaloTrackCorr trigger EMC7\n");
717     return AliVEvent::kEMC7;
718   }
719   else if (trigger=="INT7")
720   {
721     printf("CaloTrackCorr trigger INT7\n");
722     return AliVEvent::kINT7;
723   }
724   else if(trigger=="EMC1")
725   {
726     printf("CaloTrackCorr trigger EMC1\n");
727     return AliVEvent::kEMC1;
728   }
729   else if(trigger=="MB")
730   {
731     printf("CaloTrackCorr trigger MB\n");
732     return AliVEvent::kMB;
733   }  
734   else if(trigger=="PHOS")
735   {
736     printf("CaloTrackCorr trigger PHOS\n");
737     return AliVEvent::kPHI7;
738   }  
739   else if(trigger=="PHOSPb")
740   {
741     printf("CaloTrackCorr trigger PHOSPb\n");
742     return AliVEvent::kPHOSPb;
743   }
744   else if(trigger=="AnyINT")
745   {
746     printf("CaloTrackCorr trigger AnyINT\n");
747     return AliVEvent::kAnyINT;
748   }  
749   else if(trigger=="INT")
750   {
751     printf("CaloTrackCorr trigger AnyINT\n");
752     return AliVEvent::kAny;
753   }
754   else if(trigger=="EMCEGA")
755   {
756     printf("CaloTrackCorr trigger EMC Gamma\n");
757     return AliVEvent::kEMCEGA;
758   } 
759   else if(trigger=="EMCEJE")
760   {
761     printf("CaloTrackCorr trigger EMC Jet\n");
762     return AliVEvent::kEMCEJE;
763   }
764   else if(trigger=="Central")
765   {
766     printf("CaloTrackCorr trigger Central\n");
767     return (AliVEvent::kCentral  | AliVEvent::kMB);
768   }
769   else if(trigger=="CentralEGA")
770   {
771     printf("CaloTrackCorr trigger Central+EMCEGA\n");
772     return (AliVEvent::kCentral | AliVEvent::kEMCEGA);
773   }
774   else if(trigger=="SemiCentral")
775   {
776     printf("CaloTrackCorr trigger SemiCentral\n");
777     return (AliVEvent::kSemiCentral | AliVEvent::kMB);
778   }
779   else if(trigger=="SemiOrCentral")
780   {
781     printf("CaloTrackCorr trigger SemiCentral Or Central\n");
782     return (AliVEvent::kSemiCentral | AliVEvent::kCentral  | AliVEvent::kMB);
783   }
784 }
785