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