]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/macros/AddTaskPartCorr.C
possiblity to read ESD friends (Jacek)
[u/mrichter/AliRoot.git] / PWG4 / macros / AddTaskPartCorr.C
1 AliAnalysisTaskParticleCorrelation *AddTaskPartCorr(TString data, TString calorimeter)
2 {
3   // Creates a PartCorr task, configures it and adds it to the analysis manager.
4   
5   // Get the pointer to the existing analysis manager via the static access method.
6   //==============================================================================
7   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
8   if (!mgr) {
9     ::Error("AddTaskPartCorr", "No analysis manager to connect to.");
10     return NULL;
11   }  
12   
13   // Check the analysis type using the event handlers connected to the analysis manager.
14   //==============================================================================
15   if (!mgr->GetInputEventHandler()) {
16     ::Error("AddTaskPartCorr", "This task requires an input event handler");
17     return NULL;
18   }
19    //TString dataType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
20   
21    // Configure analysis
22    //===========================================================================
23   
24   //Reader
25   AliCaloTrackReader * reader = 0x0;
26   if(data=="AOD") reader = new AliCaloTrackAODReader();
27   else if(data=="ESD") reader = new AliCaloTrackESDReader();
28   else if(data=="MC") reader = new AliCaloTrackMCReader();
29   reader->SetDebug(-1);//10 for lots of messages
30   if(calorimeter == "EMCAL") reader->SwitchOnEMCALCells();
31   if(calorimeter == "PHOS")  reader->SwitchOnPHOSCells();
32   //Min particle pT
33   reader->SetEMCALPtMin(0.2); 
34   reader->SetPHOSPtMin(0.2);
35   reader->SetCTSPtMin(0.2);
36   reader->Print("");
37   
38   // ##### Analysis algorithm settings ####
39
40   // --------------------
41   // --- Pi0 Analysis ---
42   // --------------------
43   
44   AliCaloPID * pid = new AliCaloPID();
45   pid->SetDispersionCut(1.5);
46   pid->SetTOFCut(5.e-9);
47   pid->SetDebug(-1);
48   pid->Print("");
49         
50   AliFidutialCut * fidCut = new AliFidutialCut();
51   fidCut->DoCTSFidutialCut(kFALSE) ;
52   fidCut->DoEMCALFidutialCut(kTRUE) ;
53   fidCut->DoPHOSFidutialCut(kTRUE) ;
54         
55   AliAnaCalorimeterQA *qa = new AliAnaCalorimeterQA();
56   qa->SetDebug(-1); //10 for lots of messages
57   qa->SetCalorimeter(calorimeter);
58   qa->SwitchOnDataMC() ;//Access MC stack and fill more histograms
59   qa->AddToHistogramsName("AnaCaloQA_"+calorimeter);
60   qa->SetFidutialCut(fidCut);
61   qa->SwitchOnFidutialCut();
62   qa->Print("");        
63         
64   AliAnaPhoton *anaphoton1 = new AliAnaPhoton();
65   anaphoton1->SetDebug(-1); //10 for lots of messages
66   //anaphoton->SetMinPt(0.5);
67   anaphoton1->SetMinDistanceToBadChannel(2, 4, 5);
68   anaphoton1->SetCaloPID(pid);
69   anaphoton1->SetCalorimeter(calorimeter);
70   anaphoton1->SwitchOffDataMC() ;//Access MC stack and fill more histograms
71   anaphoton1->SwitchOffCaloPID();
72   anaphoton1->SwitchOffCaloPIDRecalculation(); //recommended for EMCAL
73   anaphoton1->SwitchOffFidutialCut();
74   anaphoton1->SetOutputAODName("PhotonsForIM"+calorimeter);
75   anaphoton1->Print("");
76
77   AliAnaPi0 *anapi0 = new AliAnaPi0();
78   anapi0->SetDebug(-1);//10 for lots of messages
79   anapi0->SetInputAODName("PhotonsForIM"+calorimeter);
80   anapi0->SetCaloPID(pid);
81   anapi0->SetCalorimeter(calorimeter);
82   anapi0->SwitchOnFidutialCut();
83   anapi0->SwitchOffDataMC() ;//Access MC stack and fill more histograms
84   anapi0->Print("");
85   
86 //  AliAnaNeutralMeson *ananeutral = new AliAnaNeutralMeson();
87 //  ananeutral->SetDebug(-1);//10 for lots of messages
88 //  ananeutral->SetInputAODName("PhotonsForIM"+calorimeter);
89 //  ananeutral->SetCaloPID(pid);
90 //  //  ananeutral->SetNCentrBin(5); //number of bins in centrality 
91 //  //  ananeutral->SetNZvertBin(5); //number of bins for vertex position
92 //  //  ananeutral->SetNRPBin(6); //number of bins in reaction plain
93 //  ananeutral->SetAnaPi0Eta(kTRUE); //whether analysis pi0 and eta
94 //  ananeutral->SetAnaOmega(kTRUE);   //whether analysis omega
95 //  ananeutral->SetNPID(3);
96 //  ananeutral->SetInvMassCut(1.);
97 //  ananeutral->SetNEventsMixed(6);
98 //  ananeutral->SetNAsyBinsMinMax(200,0,1.);
99 //  ananeutral->SetNPtBinsMinMax(200,0,20.);
100 //  ananeutral->SetNMassBinsMinMas(200,0,1.);
101 //  ananeutral->SetPi0MassPeakWidthCut(0.015);
102 //  ananeutral->SetCalorimeter(calorimeter);
103 //  ananeutral->SwitchOnFidutialCut();
104 //  ananeutral->SwitchOffDataMC() ;//Access MC stack and fill more histograms
105 //  ananeutral->AddToHistogramsName("AnaNeutralMeson_");
106 //  ananeutral->Print("");
107         
108   // -------------------------------------------------
109   // --- Photon Isolation and Correlation Analysis ---
110   // -------------------------------------------------
111   
112   AliAnaPhoton *anaphoton2 = new AliAnaPhoton();
113   anaphoton2->SetDebug(-1); //10 for lots of messages
114   anaphoton2->SetMinPt(5);
115   anaphoton2->SetCaloPID(pid);
116   anaphoton2->SetCalorimeter(calorimeter);
117   anaphoton2->SwitchOffDataMC() ;//Access MC stack and fill more histograms
118   anaphoton2->SwitchOnCaloPID();
119   if(calorimeter == "EMCAL") anaphoton2->SwitchOnCaloPIDRecalculation();
120   anaphoton2->SwitchOffFidutialCut();
121   anaphoton2->SetOutputAODName("DirectPhotons"+calorimeter);
122   anaphoton2->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
123   anaphoton2->AddToHistogramsName("AnaPhotonCorr_");
124   anaphoton2->Print("");
125   // ### Isolation analysis ### 
126   
127   AliIsolationCut * ic = new AliIsolationCut();
128   ic->SetConeSize(0.5);
129   ic->SetPtThreshold(1.);
130   ic->SetICMethod(AliIsolationCut::kPtThresIC);
131   ic->Print("");
132   
133   AliAnaParticleIsolation *anaisol = new AliAnaParticleIsolation();
134   anaisol->SetDebug(-1);
135   //anaisol->SetMinPt(5);
136   anaisol->SetInputAODName("DirectPhotons"+calorimeter);
137   anaisol->SetCalorimeter(calorimeter);
138   anaisol->SwitchOffDataMC() ;//Access MC stack and fill more histograms
139   //Select clusters with no pair, if both clusters with pi0 mass
140   anaisol->SwitchOffInvariantMass();
141   //anaisol->SetNeutralMesonSelection(nms);
142   //Do isolation cut
143   anaisol->SetIsolationCut(ic); 
144   //Do or not do isolation with previously produced AODs.
145   //No effect if use of SwitchOnSeveralIsolation()
146   anaisol->SwitchOffReIsolation();
147   //Multiple IC
148   anaisol->SwitchOffSeveralIsolation() ;
149   anaisol->Print("");
150   
151   // ### Correlation with Jet Finder AOD output
152   AliAnaParticleJetFinderCorrelation *anacorrjet = new AliAnaParticleJetFinderCorrelation();
153   anacorrjet->SetInputAODName("DirectPhotons"+calorimeter);
154   anacorrjet->SwitchOffFidutialCut();
155   anacorrjet->SetDebug(-1);
156   anacorrjet->SetConeSize(1);  
157   anacorrjet->SelectIsolated(kTRUE); // do correlation with isolated photons
158   anacorrjet->SetPtThresholdInCone(0.2);
159   anacorrjet->SetDeltaPhiCutRange(0.5,5.5);//Mostly Open Cuts 
160   anacorrjet->SetRatioCutRange(0.01,3); //Mostly Open Cuts
161   anacorrjet->UseJetRefTracks(kFALSE); //Not working now
162   anacorrjet->Print("");
163   
164   // ### Correlation with hadrons
165   AliAnaParticleHadronCorrelation *anacorrhadron = new AliAnaParticleHadronCorrelation();
166   anacorrhadron->SetInputAODName("DirectPhotons"+calorimeter);
167   anacorrhadron->SetOutputAODName("CorrelatedPi0s"+calorimeter);
168   anacorrhadron->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
169   anacorrhadron->SetDebug(-1);
170   anacorrhadron->SwitchOffCaloPID();
171   anacorrhadron->SwitchOffFidutialCut();
172   anacorrhadron->SetPtCutRange(1,100);
173   anacorrhadron->SetDeltaPhiCutRange(1.5,4.5);
174   anacorrhadron->SelectIsolated(kTRUE); // do correlation with isolated photons
175   if(calorimeter=="PHOS"){
176     //Correlate with particles in EMCAL
177     anacorrhadron->SwitchOnCaloPID();
178     anacorrhadron->SwitchOnCaloPIDRecalculation(); //recommended for EMCAL
179   }
180   anacorrhadron->Print("");
181   
182   // #### Configure Maker ####
183   AliAnaPartCorrMaker * maker = new AliAnaPartCorrMaker();
184   maker->SetReader(reader);//pointer to reader
185   maker->AddAnalysis(qa,0);
186   maker->AddAnalysis(anaphoton1,1);
187   maker->AddAnalysis(anapi0,2);
188   maker->AddAnalysis(anaphoton2,3);
189   maker->AddAnalysis(anaisol,4);
190   maker->AddAnalysis(anacorrjet,5);
191   maker->AddAnalysis(anacorrhadron,6);
192   //maker->AddAnalysis(ananeutral,7);
193   maker->SetAnaDebug(-1)  ;
194   maker->SwitchOnHistogramsMaker()  ;
195   maker->SwitchOnAODsMaker()  ;
196   maker->Print("");
197   
198   printf("======================== \n");
199   printf(" End Configuration of PartCorr analysis with detector %s \n",calorimeter.Data());
200   printf("======================== \n");
201   
202    // Create task
203    //===========================================================================
204   AliAnalysisTaskParticleCorrelation * task = new AliAnalysisTaskParticleCorrelation ("PartCorr"+calorimeter);
205   task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
206   //task->SetDebugLevel(-1);
207   task->SetAnalysisMaker(maker);                                
208   mgr->AddTask(task);
209   
210   char name[128];
211   sprintf(name,"PartCorr_%s",calorimeter.Data());
212 cout<<"Name of task "<<name<<endl;
213   AliAnalysisDataContainer *cout_pc = mgr->CreateContainer(Form(name),TList::Class(),
214                                                            AliAnalysisManager::kOutputContainer, Form("PartCorr_%s.root",calorimeter.Data()));
215   
216   // Create ONLY the output containers for the data produced by the task.
217   // Get and connect other common input/output containers via the manager as below
218   //==============================================================================
219   mgr->ConnectInput  (task, 0, mgr->GetCommonInputContainer());
220   // AOD output slot will be used in a different way in future
221   mgr->ConnectOutput (task, 0, mgr->GetCommonOutputContainer());
222   mgr->ConnectOutput (task, 1, cout_pc);
223   
224   return task;
225 }
226
227