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