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