from nagmeh: addtask for pid config task and updates to pid config task
[u/mrichter/AliRoot.git] / PWGCF / FLOW / macros / AddTaskPIDconfig.C
1
2 void AddTaskPIDconfig(Int_t CentralityTriggerSelection = AliVEvent::kMB, Double_t centralityMin=0, Double_t centralityMax=5 ,Double_t FilterBit=1, Bool_t PIDcuts=kFALSE,TString useroutputfile="output.root"){
3
4     AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
5     if (!mgr) {
6         ::Error("AddTaskPID", "No analysis manager to connect to.");
7         return 0x0;
8     }
9     
10     // standard with task
11     printf("========================================================================================\n");
12     printf("PID: Initialising AliAnalysisTaskPIDconfig\n");
13     printf("========================================================================================\n");
14     
15     Double_t centrMin[9] = {0,5,10,20,30,40,50,60,70};
16     Double_t centrMax[9] = {5,10,20,30,40,50,60,70,80};
17     Bool_t Pass_Min = kFALSE;
18     Bool_t Pass_Max = kFALSE;
19
20     for(int i=0;i<9;i++)
21     {
22         if(centralityMin == centrMin[i]){
23             const int iMin = i;
24             Pass_Min = kTRUE;
25         }
26         if(centralityMax == centrMax[i]){
27             const int iMax = i;
28             Pass_Max = kTRUE;
29         }
30     }
31     if(!Pass_Min || !Pass_Max){
32         ::Error("centrality Min and Max don't match the defined ranges");
33         return 0x0;
34     }
35     
36     const int ncentr = iMax - iMin +1;
37     TString outputfile[ncentr];
38     AliAnalysisDataContainer *coutput1[ncentr];
39     AliAnalysisTaskPIDconfig *pidTask[ncentr];
40     int icentr = 0;
41     
42     
43     
44     for(int i=0;i<iMax-iMin+1;i++){
45         icentr = i + iMin;
46         outputfile[i] = useroutputfile;
47         pidTask[i] = new AliAnalysisTaskPIDconfig(Form("pidTask_%.f-%.f",centrMin[icentr],centrMax[icentr]));
48         pidTask[i]->SelectCollisionCandidates(CentralityTriggerSelection);
49         pidTask[i]->SetCutTPCmultiplicityOutliersAOD(kTRUE);
50         pidTask[i]->SetData2011(kFALSE);
51         pidTask[i]->SetFilterBit(FilterBit);
52         pidTask[i]->SetUseCentrality(kTRUE);
53         pidTask[i]->SetCentralityPercentileMin(centrMin[icentr]);
54         pidTask[i]->SetCentralityPercentileMax(centrMax[icentr]);
55         pidTask[i]->SetCentralityEstimator("V0M");
56         pidTask[i]->SetDCAxyCut(10);
57         pidTask[i]->SetDCAzCut(10);
58         pidTask[i]->SetCuts(PIDcuts);
59         if(PIDcuts){
60             TFile *ContoursFile = new TFile(Form("PurityHistContours_%.f-%.f.root",centrMin[icentr],centrMax[icentr]));
61
62             Contourlist = new TDirectory;
63             Contourlist=(TDirectory*)ContoursFile->Get("Filterbit1");
64             if(!Contourlist){printf("The contour file is empty"); continue;}
65     
66             pidTask[i]->SetPIDcontoursList(Contourlist);
67             
68         }
69         
70         mgr->AddTask(pidTask[i]);
71         
72         coutput1[i] = mgr->CreateContainer(Form("PID_%.f-%.f",centrMin[icentr],centrMax[icentr]), TList::Class(),AliAnalysisManager::kOutputContainer,outputfile[i]);
73   
74         //connect containers
75         mgr->ConnectInput  (pidTask[i],  0, mgr->GetCommonInputContainer());
76         mgr->ConnectOutput (pidTask[i],  1, coutput1[i]);
77         
78         //return pidTask[icentr];
79
80     }
81 }