]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/correlationHF/macros/AddTaskDStarCorrelations.C
Merge branch 'TPCdev' of https://git.cern.ch/reps/AliRoot into TPCdev
[u/mrichter/AliRoot.git] / PWGHF / correlationHF / macros / AddTaskDStarCorrelations.C
1  //DEFINITION OF A FEW CONSTANTS
2 //----------------------------------------------------
3
4 /* $Id$ */
5
6 AliAnalysisTaskDStarCorrelations *AddTaskDStarCorrelations(AliAnalysisTaskDStarCorrelations::CollSyst syst, 
7                                                             Bool_t theMCon, Bool_t mixing, Bool_t UseReco=kTRUE,Bool_t UseHadChannelinMC,Bool_t fullmode = kFALSE,Bool_t UseEffic=kFALSE,Bool_t UseDEffic = kFALSE,
8                                                         AliAnalysisTaskDStarCorrelations::DEffVariable var,
9                                                             Int_t trackselect =1, Int_t usedispl =0, Int_t nbins, Float_t DStarSigma, Float_t D0Sigma, Float_t D0SBSigmaLow, Float_t D0SBSigmaHigh, Float_t eta,
10                                                                      TString DStarCutsFile, TString TrackCutsFile,
11                                                                      Int_t tasknumber = 0)
12 {
13
14  
15     
16   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
17   if (!mgr) {
18     ::Error(" AliAnalysisTaskDStarCorrelations", "No analysis manager to connect to.");
19     return NULL;
20   } 
21
22         cout << "==========================================================" << endl;
23     cout << "Set Inputs : " << endl;
24     cout << " " << endl;
25     if(syst == AliAnalysisTaskDStarCorrelations::pp) cout << "Running on pp @ 7 TeV" << endl;
26     if(syst == AliAnalysisTaskDStarCorrelations::pA) cout << "Running on pPb @ 5.02 TeV" << endl;
27     if(syst == AliAnalysisTaskDStarCorrelations::AA) cout << "Running on PbPb @ 2.76 TeV" << endl;
28     
29     if(theMCon) cout << "Analysis on MonteCarlo" << endl;
30     else cout << "Analysis on Data" << endl;
31     
32     if(mixing) cout << "Analysis on Mixed Events" << endl;
33     else cout << "Analysis on Single Events" << endl;
34     
35     if(UseReco) cout << "Using Reconstructed objects" << endl;
36     else cout << "Using Pure MC information " << endl;
37
38     if(fullmode) cout << "Running in full mode" << endl;
39     else cout << "Running in fast mode " << endl;
40     
41     if(UseEffic) cout << "Using single track efficiency map" << endl;
42     else cout << "Not Using single track efficiency map " << endl;
43     
44     if(UseDEffic) cout << "Using Dmeson efficiency map" << endl;
45     else cout << "Not Using Dmeson efficiency map " << endl;
46     
47  
48     if(var == AliAnalysisTaskDStarCorrelations::kNone) cout << "Applying D Efficiency map vs pT " << endl;
49     if(var == AliAnalysisTaskDStarCorrelations::kMult) cout << "Applying D Efficiency map vs pT vs Multiplicity" << endl;
50     if(var == AliAnalysisTaskDStarCorrelations::kCentr) cout << "Applying D Efficiency map vs pT vs Centrality" << endl;
51     if(var == AliAnalysisTaskDStarCorrelations::kRapidity) cout << "Applying D Efficiency map vs pT vs Rapidity" << endl;
52     if(var == AliAnalysisTaskDStarCorrelations::kEta) cout << "Applying D Efficiency map vs pT vs Eta" << endl;
53
54     if(trackselect == 1) cout << "Correlating with hadrons" << endl;
55     if(trackselect == 2) cout << "Correlating with kaons" << endl;
56     if(trackselect == 3) cout << "Correlating with kzeros" << endl;
57     
58     if(usedispl == 0) cout << "Not using displacement cut" << endl;
59     if(usedispl == 1) cout << "Using absolute displacement cut" << endl;
60     if(usedispl == 2) cout << "Using relative displacement cut" << endl;
61     
62     
63     cout << "Number of bins in deltaphi = " << nbins << endl;
64     
65     cout << "N of Sigmas in D* selection =" << DStarSigma << endl;
66     cout << "N of Sigmas in D0 selection = " << D0Sigma << endl;
67     cout << "D0 Sidebands taken from  = " << D0SBSigmaLow << " - " << D0SBSigmaHigh << " sigmas " << endl; endl;
68     
69    
70     
71     cout << "DStar cut object:     " << DStarCutsFile << endl;
72     cout << "Tracks cut object:    " << TrackCutsFile << endl;
73   
74     
75     cout << "==========================================================" << endl;
76     //gSystem->Sleep(2000);
77     
78 //      TString DCutObjPath = "CutObjects/DStar/";
79                 
80         
81 // ******************************** OPENING THE D* CUTS ************************************
82     cout << "Getting D meson cut object from file \n" << DStarCutsFile.Data() << "\n " << endl;
83     TFile* filecuts=TFile::Open(DStarCutsFile.Data());
84     if(!filecuts->IsOpen()){
85     cout<<"DStar cut object file not found: exit"<<endl;
86     return;
87     }
88     
89     AliRDHFCutsDStartoKpipi* RDHFDStartoKpipi=new AliRDHFCutsDStartoKpipi();
90     RDHFDStartoKpipi = (AliRDHFCutsDStartoKpipi*)filecuts->Get("DStartoKpipiCuts");
91     RDHFDStartoKpipi->SetName("DStartoKpipiCuts");
92     
93     // mm let's see if everything is ok
94         if(!RDHFDStartoKpipi){
95                 cout<<"Specific AliRDHFCuts not found"<<endl;
96                 return;
97         }
98     
99         
100        // RDHFDStartoKpipi->SetTriggerClass("");
101        // RDHFDStartoKpipi->SetTriggerMask(AliVEvent::kCentral);
102     
103     
104         
105 // ******************************** OPENING THE ASSOCIATED TRACK CUTS ************************************
106         cout << "Getting associated track cut object from file \n" << TrackCutsFile.Data() << "\n " << endl;
107         TFile* filecuts2=TFile::Open(TrackCutsFile.Data());
108           if(!filecuts2->IsOpen()){
109                   cout<<"Track cut object file not found: exit"<<endl;
110                   return;
111     }
112         AliHFAssociatedTrackCuts* corrCuts=new AliHFAssociatedTrackCuts();
113         corrCuts = (AliHFAssociatedTrackCuts*)filecuts2->Get("AssociatedCuts");
114         corrCuts->SetName("AssociatedCuts");
115         corrCuts->PrintAll();
116         if(!corrCuts){
117                 cout<<"Specific associated track cuts not found"<<endl;
118                 return;
119         }
120         
121
122 // ******************************** SELECTING THE MC PROCESS  ************************************
123
124         TString selectMCproc = "";
125         
126         Int_t NMCevents = corrCuts->GetNofMCEventType();
127         for(Int_t k=0; k<NMCevents; k++){
128                 Int_t * MCEventType = corrCuts->GetMCEventType();
129                 selectMCproc += Form("%d",MCEventType[k]);
130         }
131
132          cout << "Select process string = " << selectMCproc << endl;
133         
134
135
136 // ******************************** CREATING THE TASK ************************************
137  
138     printf("CREATE TASK \n");
139   // create the task
140   AliAnalysisTaskDStarCorrelations *task = new AliAnalysisTaskDStarCorrelations("AliAnalysisTaskDStarCorrelations",RDHFDStartoKpipi,corrCuts,syst,fullmode);
141         
142         // Setters
143
144         if(!theMCon) {
145                 printf("Analysis on Data - reconstruction only!");
146                 UseReco = kTRUE;
147         printf("Analysis on Data - hadronic channel only!");
148                 UseHadChannelinMC = kFALSE;
149         }
150     
151     
152
153         
154     
155     task->SetNofPhiBins(nbins);
156         task->SetMonteCarlo(theMCon);
157         task->SetUseMixing(mixing);
158         task->SetCorrelator(trackselect) ;
159         task->SetUseDisplacement(usedispl);
160         //task->SetCollSys(syst);
161         task->SetLevelOfDebug(2);
162         task->SetUseReconstruction(UseReco); // set kTRUE for Using Reconstruction, kFALSe for MC Truth
163     task->SetDMesonSigmas(DStarSigma,D0Sigma,D0SBSigmaLow,D0SBSigmaHigh);
164         //task->SetDMesonSigmas(sigmas);
165     //task->SetDMesonSigmas(sigmas);
166     task->SetUseEfficiencyCorrection(UseEffic);
167     task->SetUseDmesonEfficiencyCorrection(UseDEffic);
168     
169     task->SetEfficiencyVariable(var);
170     task->SetMaxDStarEta(eta);
171     task->SetUseHadronicChannelAtKineLevel(UseHadChannelinMC);
172         
173
174         if(trackselect == 1) Info(" AliAnalysisTaskDStarCorrelations","Correlating D* with charged hadrons \n");
175         else if(trackselect == 2) Info(" AliAnalysisTaskDStarCorrelations","Correlating D* with charged kaons \n");
176         else if(trackselect == 3) Info(" AliAnalysisTaskDStarCorrelations","Correlating D* with reconstructed K0s \n");
177         else Fatal(" AliAnalysisTaskDStarCorrelations","Nothing to correlate with!");
178         if(mixing) Info (" AliAnalysisTaskDStarCorrelations","Event Mixing Analysis\n");
179         if(!mixing) Info (" AliAnalysisTaskDStarCorrelations","Single Event Analysis \n");
180
181   // Create and connect containers for input/output
182         //TString dcavalue = " ";
183         if(!theMCon) TString contname = "Data";
184         if(theMCon) TString contname = "MonteCarlo";
185         TString contname2 = "MC";
186         if(trackselect ==1) TString particle = "Hadron";
187         if(trackselect ==2) TString particle = "Kaon";
188         if(trackselect ==3) TString particle = "KZero";
189         
190         TString cutname = "cuts" ;
191         TString cutname2 = "hadroncuts" ;
192         TString outputfile = AliAnalysisManager::GetCommonFileName();
193         TString outputfileMC = AliAnalysisManager::GetCommonFileName();
194         TString counter = "NormCounter";
195         outputfile += ":PWGHF_HFCJ_";
196         outputfileMC += ":PWGHF_HFCJ_";
197         
198         if(!mixing) {
199                 outputfile += "SE";
200                 outputfileMC += "SE";
201                 contname += "SE";
202                 contname2 += "SE";
203                 cutname += "SE";
204                 cutname2 += "SE";
205                 counter+= "SE";
206         }
207         if(mixing){
208                 outputfile += "ME";
209                 outputfileMC += "ME";
210                 contname += "ME";
211                 contname2 += "ME";
212                 cutname += "ME";
213                 cutname2 += "ME";
214                 counter+= "ME";
215         }
216     
217
218     
219         outputfile += "Dphi_DStar";
220         outputfileMC += "Dphi_DStar";
221         outputfile += particle;
222         outputfileMC += particle;
223         cutname += particle;
224         cutname2 += particle;
225         contname += particle;
226         contname2 += particle;
227         counter+= particle;
228         
229     if(UseEffic){
230         outputfile += "_EffY_";
231                 outputfileMC += "_EffY_";
232                 contname += "_EffY_";
233                 contname2 += "_EffY_";
234                 cutname += "_EffY_";
235                 cutname2 += "_EffY_";
236                 counter+= "_EffY_";
237     }
238     
239     if(!UseEffic){
240         outputfile += "_EffN_";
241                 outputfileMC += "_EffN_";
242                 contname += "_EffN_";
243                 contname2 += "_EffN_";
244                 cutname += "_EffN_";
245                 cutname2 += "_EffN_";
246                 counter+= "_EffN_";
247     }
248     
249     if(UseDEffic){
250         TString string = "DEffY_";
251         
252         if(var == AliAnalysisTaskDStarCorrelations::kNone) string += "vsPt_";
253         if(var == AliAnalysisTaskDStarCorrelations::kMult) string += "vsPtMult_";
254         if(var == AliAnalysisTaskDStarCorrelations::kCentr) string += "vsPCentrt_";
255         if(var == AliAnalysisTaskDStarCorrelations::kRapidity) string += "vsPtY_";
256         if(var == AliAnalysisTaskDStarCorrelations::kEta) string += "vsPtEta_";
257         
258         outputfile += string;
259                 outputfileMC += string;
260                 contname += string;
261                 contname2 += string;
262                 cutname += string;
263                 cutname2 += string;
264                 counter+= string;
265     }
266     
267     if(!UseDEffic){
268         outputfile += "DEffN_";
269                 outputfileMC += "DEffN_";
270                 contname += "DEffN_";
271                 contname2 += "DEffN_";
272                 cutname += "DEffN_";
273                 cutname2 += "DEffN_";
274                 counter+= "DEffN_";
275     }
276         
277     
278     outputfile += Form("%d_bins_",nbins);
279         outputfileMC += Form("%d_bins_",nbins);
280         cutname += Form("%d_bins_",nbins);
281         cutname2 += Form("%d_bins_",nbins);
282         contname += Form("%d_bins_",nbins);
283         contname2 += Form("%d_bins_",nbins);
284         counter+= Form("%d_bins_",nbins);
285     
286         
287         outputfile += Form("task_%d",tasknumber);
288         outputfileMC += Form("task_%d",tasknumber);
289         cutname += Form("task_%d",tasknumber);
290         cutname2 += Form("task_%d",tasknumber);
291         contname += Form("task_%d",tasknumber);
292         contname2 += Form("task_%d",tasknumber);
293         counter+= Form("task_%d",tasknumber);
294         
295 /*      outputfile += TrackCutObjNamePrefix;
296         outputfileMC += TrackCutObjNamePrefix;
297         cutname += TrackCutObjNamePrefix;
298         cutname2 += TrackCutObjNamePrefix;
299         contname += TrackCutObjNamePrefix;
300         contname2 += TrackCutObjNamePrefix;
301         counter+= TrackCutObjNamePrefix;
302 */      
303         outputfile += selectMCproc;
304         outputfileMC += selectMCproc;
305         cutname += selectMCproc;
306         cutname2 += selectMCproc;
307         contname += selectMCproc;
308         contname2 += selectMCproc;
309         counter+= selectMCproc;
310         
311         TString reco = "";
312         
313         if(UseReco) reco = "_reco";
314         if(!UseReco) {
315         if(UseHadChannelinMC) reco = "_MCTruthHadChan";
316         if(!UseHadChannelinMC) reco = "_MCTruthAllChan";
317         }
318         outputfile += reco;
319         outputfileMC += reco;
320         cutname += reco;
321         cutname2 += reco;
322         contname += reco;
323         contname2 += reco;
324         counter+= reco;
325         
326         TString nsigma = Form("_%.0f_%.0f%.0f%.0f_sigmas",DStarSigma,D0Sigma,D0SBSigmaLow,D0SBSigmaHigh);
327         
328         //cout << "nsigma string = "<< nsigma << endl;
329         
330         outputfile += nsigma;
331         outputfileMC += nsigma;
332         cutname += nsigma;
333         cutname2 += nsigma;
334         contname += nsigma;
335         contname2 += nsigma;
336         counter+= nsigma;
337         
338         
339         cout << contname << endl;
340         cout << contname2 << endl;
341         cout << cutname << endl;
342         cout << cutname2 << endl;
343         cout << counter << endl;
344         cout << outputfile << endl;
345         //return;
346         
347   mgr->AddTask(task);
348   // ------ input data ------
349   AliAnalysisDataContainer *cinput0  = mgr->GetCommonInputContainer();
350   
351   // ----- output data -----
352   
353   // output TH1I for event counting
354         
355         //TLists
356   AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contname, TList::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
357   AliAnalysisDataContainer *coutput2 = mgr->CreateContainer(contname2, TList::Class(),AliAnalysisManager::kOutputContainer,outputfileMC.Data());
358    // Cut Objects
359   AliAnalysisDataContainer *coutput3 = mgr->CreateContainer(cutname,AliRDHFCutsDStartoKpipi::Class(),AliAnalysisManager::kOutputContainer, outputfile.Data()); //cuts D
360   AliAnalysisDataContainer *coutput4 = mgr->CreateContainer(cutname2,AliHFAssociatedTrackCuts::Class(),AliAnalysisManager::kOutputContainer, outputfile.Data()); //cuts tracks
361    // Normalization Counter
362   AliAnalysisDataContainer *coutput5 = mgr->CreateContainer(counter,AliNormalizationCounter::Class(),AliAnalysisManager::kOutputContainer, outputfile.Data());
363   
364         
365   mgr->ConnectInput(task,0,mgr->GetCommonInputContainer());
366   mgr->ConnectOutput(task,1,coutput1);
367   mgr->ConnectOutput(task,2,coutput2);
368   mgr->ConnectOutput(task,3,coutput3);
369   mgr->ConnectOutput(task,4,coutput4);
370   mgr->ConnectOutput(task,5,coutput5);
371
372   return task ;
373
374 }
375