df5fe78e8523398b3234d07dd44cde37e576fc7a
[u/mrichter/AliRoot.git] / PWGCF / Correlations / macros / DiHadronPID / AddTaskDiHadronPID.C
1 AliAnalysisTaskDiHadronPID* AddTaskDiHadronPID(
2         Int_t NDEtaBins = 32,
3         Int_t NDPhiBins = 32,
4         Int_t MinEventsForMixing = 5,
5         Int_t PoolTrackDepth = 2000,
6         Int_t PoolSize = 1000,
7         Bool_t MixEvents = kTRUE,
8         Bool_t MixTriggers = kTRUE,
9         Double_t MinCentrality = 5.,
10         Double_t MaxCentrality = 0.,
11         const char* CentralityEstimator = "V0M",
12         Double_t maxVertexZ = 7.,
13         Double_t maxEta = 0.8,
14         Double_t minAssociatedPt = 0.2,
15         Double_t maxAssociatedPt = 5.0,
16         Double_t minTriggerPt = 5.,
17         Double_t maxTriggerPt = 10.,
18         Bool_t requestAllSingleTrackHistos = kFALSE,
19         Int_t FilterMaskTrigger = 7,
20         Int_t FilterMaskAssociated = 5,
21         Bool_t isPbPb = kTRUE,
22         Bool_t isMC = kFALSE,
23         Int_t DebugLevel = 0,
24         Bool_t MakeTOFCorrelations = kTRUE,
25         Bool_t MakeTOFTPCCorrelationsPi = kFALSE,
26         Bool_t MakeTOFTPCCorrelationsKa = kFALSE,
27         Bool_t MakeTOFTPCCorrelationsPr = kFALSE,               
28         Double_t TOFIntervalFactorTOFTPC = 1.,
29         const char* outputFileName = 0,
30         const char* containerName = "DiHadronPID",
31         const char* folderName = "PWGCF_DiHadronPID")
32
33 {
34         // Get a pointer to the analysis manager.
35     AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
36     if (!mgr) {
37         cout<<"AddTaskDiHadronPID.C -> No analysis manager found."<<endl;
38         return 0x0;
39     }   
40
41     // Create an instance of the task.
42     AliAnalysisTaskDiHadronPID* DiHadronPIDTask = new AliAnalysisTaskDiHadronPID(containerName);
43
44     // Configure the task.
45     DiHadronPIDTask->SetNDEtaBins(NDEtaBins);
46     DiHadronPIDTask->SetNDPhiBins(NDPhiBins);
47     DiHadronPIDTask->SetMinEventsForMixing(MinEventsForMixing);
48     DiHadronPIDTask->SetPoolTrackDepth(PoolTrackDepth);
49     DiHadronPIDTask->SetPoolSize(PoolSize);
50     DiHadronPIDTask->SetMixEvents(MixEvents);
51     DiHadronPIDTask->SetMixTriggers(MixTriggers);
52     DiHadronPIDTask->SetDebugLevel(DebugLevel);
53     DiHadronPIDTask->SetMakeTOFCorrelations(MakeTOFCorrelations);
54     DiHadronPIDTask->SetMakeTOFTPCCorrelationsPi(MakeTOFTPCCorrelationsPi);
55     DiHadronPIDTask->SetMakeTOFTPCCorrelationsKa(MakeTOFTPCCorrelationsKa);
56     DiHadronPIDTask->SetMakeTOFTPCCorrelationsPr(MakeTOFTPCCorrelationsPr);        
57     DiHadronPIDTask->SetTOFIntervalFactorTOFTPC(TOFIntervalFactorTOFTPC);
58
59     // Configure and add Event Cuts.
60         AliAODEventCutsDiHadronPID* eventcuts = new AliAODEventCutsDiHadronPID("EventCuts");
61         eventcuts->SetTrigger(AliVEvent::kMB);
62         eventcuts->SetCentrality(MaxCentrality, MinCentrality);
63         eventcuts->SetMaxVertexZ(maxVertexZ);
64         eventcuts->SetCentralityEstimator(CentralityEstimator);
65         eventcuts->SetIsPbPb(isPbPb);
66         eventcuts->SetDebugLevel(DebugLevel);
67         DiHadronPIDTask->SetEventCuts(eventcuts);
68
69         // Configure and add track cuts for trigger.
70         AliAODTrackCutsDiHadronPID* triggercuts = new AliAODTrackCutsDiHadronPID("TrackCutsTrigger");
71         triggercuts->SetIsMC(isMC);
72         triggercuts->SetFilterMask(1<<FilterMaskTrigger);
73         triggercuts->SetPtRange(minTriggerPt,maxTriggerPt);
74         triggercuts->SetMaxEta(maxEta);
75         triggercuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kAllCharged);
76         triggercuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kPositive);
77         triggercuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kNegative);
78         if (requestAllSingleTrackHistos) {
79                 triggercuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kAllPion);
80                 triggercuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kPosPion);
81                 triggercuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kNegPion);                                     
82                 triggercuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kAllKaon);
83                 triggercuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kPosKaon);
84                 triggercuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kNegKaon);             
85                 triggercuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kAllProton);
86                 triggercuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kPosProton);
87                 triggercuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kNegProton);
88         }       
89         triggercuts->SetDebugLevel(DebugLevel);
90         DiHadronPIDTask->SetTrackCutsTrigger(triggercuts);
91
92         // Configure and add track cuts for associateds.
93         AliAODTrackCutsDiHadronPID* associatedscuts = new AliAODTrackCutsDiHadronPID("TrackCutsAssociated");
94         associatedscuts->SetIsMC(isMC);
95         associatedscuts->SetFilterMask(1<<FilterMaskAssociated);
96         associatedscuts->SetPtRange(minAssociatedPt,maxAssociatedPt);
97         associatedscuts->SetMaxEta(maxEta);
98         ULong_t associatedflags = (UInt_t)(AliAODTrack::kTOFout)|(UInt_t)(AliAODTrack::kTIME);  
99         associatedscuts->SetDemandFlags(associatedflags);
100         associatedscuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kAllCharged);
101         associatedscuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kPositive);
102         associatedscuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kNegative);
103         if (requestAllSingleTrackHistos) {
104                 associatedscuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kAllPion);
105                 associatedscuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kPosPion);
106                 associatedscuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kNegPion);                                 
107                 associatedscuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kAllKaon);
108                 associatedscuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kPosKaon);
109                 associatedscuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kNegKaon);         
110                 associatedscuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kAllProton);
111                 associatedscuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kPosProton);
112                 associatedscuts->RequestQAHistos(AliAODTrackCutsDiHadronPID::kNegProton);
113         }
114         associatedscuts->SetDebugLevel(DebugLevel);
115         DiHadronPIDTask->SetTrackCutsAssociated(associatedscuts);
116
117         // Add the task.
118         mgr->AddTask(DiHadronPIDTask);
119     
120         // Data containers.
121         AliAnalysisDataContainer* cinput  = mgr->GetCommonInputContainer();
122         mgr->ConnectInput(DiHadronPIDTask, 0, cinput); 
123         
124         if (!outputFileName) {outputFileName = AliAnalysisManager::GetCommonFileName();}
125         
126         AliAnalysisDataContainer* coutput1 = mgr->CreateContainer(containerName, TList::Class(),
127                          AliAnalysisManager::kOutputContainer,Form("%s:%s", outputFileName, folderName));
128         
129         mgr->ConnectOutput(DiHadronPIDTask,1,coutput1);
130         
131         return DiHadronPIDTask;
132
133 }