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