end-of-line normalization
[u/mrichter/AliRoot.git] / PWGCF / EBYE / macros / AddTaskBalanceEventMixing.C
CommitLineData
a65a7e70 1// now in options
2//=============================================//
3//const char* centralityEstimator = "V0M";
4//const char* centralityEstimator = "CL1";
5//const char* centralityEstimator = "TRK";
6//=============================================//
7//Bool_t gRunShuffling = kFALSE;
8//Bool_t gRunShuffling = kTRUE;
9//=============================================//
10
11//PID config
12Bool_t kUseNSigmaPID = kFALSE;
13Double_t nSigmaMax = 3.0;
14Bool_t kUseBayesianPID = kTRUE;
15Double_t gMinAcceptedProbability = 0.7;
16
17//_________________________________________________________//
18AliAnalysisTaskEventMixingBF *AddTaskBalanceEventMixing(Double_t centrMin=0.,
19 Double_t centrMax=100.,
20 Bool_t gRunShuffling=kFALSE,
21 TString centralityEstimator="V0M",
22 Double_t vertexZ=10.,
23 Double_t DCAxy=-1,
24 Double_t DCAz=-1,
25 Double_t ptMin=0.3,
26 Double_t ptMax=1.5,
27 Double_t etaMin=-0.8,
28 Double_t etaMax=0.8,
29 Double_t maxTPCchi2 = -1,
30 Int_t minNClustersTPC = -1,
31 Bool_t kUsePID = kFALSE,
32 Int_t AODfilterBit = 128,
33 Bool_t bCentralTrigger = kFALSE,
34 Bool_t bHBTcut = kFALSE,
35 Bool_t bConversionCut = kFALSE,
36 TString fileNameBase="AnalysisResults") {
37
38 // Creates a balance function analysis task and adds it to the analysis manager.
39 // Get the pointer to the existing analysis manager via the static access method.
40 TString centralityName("");
41 centralityName+=Form("%.0f",centrMin);
42 centralityName+="-";
43 centralityName+=Form("%.0f",centrMax);
44 centralityName+="_";
45 centralityName+=Form("%s",centralityEstimator.Data());
46 centralityName+="_";
47 centralityName+=Form("vZ%.1f",vertexZ);
48 centralityName+="_";
49 centralityName+=Form("DCAxy%.1f",DCAxy);
50 centralityName+="_";
51 centralityName+=Form("DCAz%.1f",DCAz);
52 centralityName+="_Pt";
53 centralityName+=Form("%.1f",ptMin);
54 centralityName+="-";
55 centralityName+=Form("%.1f",ptMax);
56 centralityName+="_Eta";
57 centralityName+=Form("%.1f",etaMin);
58 centralityName+="-";
59 centralityName+=Form("%.1f",etaMax);
60 centralityName+="_Chi";
61 centralityName+=Form("%.1f",maxTPCchi2);
62 centralityName+="_nClus";
63 centralityName+=Form("%d",minNClustersTPC);
64 centralityName+="_Bit";
65 centralityName+=Form("%d",AODfilterBit);
66 if(bCentralTrigger) centralityName+="_withCentralTrigger";
67 if(bHBTcut) centralityName+="_withHBTcut";
68 if(bConversionCut) centralityName+="_withConversionCut";
69
70
71
72
73
74 TString outputFileName(fileNameBase);
75 outputFileName.Append(".root");
76
77 //===========================================================================
78 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
79 if (!mgr) {
80 ::Error("AddTaskEventMixingBF", "No analysis manager to connect to.");
81 return NULL;
82 }
83
84 // Check the analysis type using the event handlers connected to the analysis manager.
85 //===========================================================================
86 if (!mgr->GetInputEventHandler()) {
87 ::Error("AddTaskEventMixingBF", "This task requires an input event handler");
88 return NULL;
89 }
90 TString analysisType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
91 if(dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler())) analysisType = "MC";
92
93 // for local changed EventMixingBF configuration
94 //gROOT->LoadMacro("./configBalanceFunctionAnalysisEventMixing.C");
95 gROOT->LoadMacro("$ALICE_ROOT/PWGCF/EBYE/macros/configBalanceFunctionAnalysisEventMixing.C");
96 AliBalanceEventMixing *bf = 0; // Balance Function object
97 AliBalanceEventMixing *bfs = 0; // shuffled Balance function object
98
99 if (analysisType=="ESD"){
100 bf = GetBalanceFunctionObject("ESD",centralityEstimator,centrMin,centrMax,kFALSE,bHBTcut,bConversionCut);
101 if(gRunShuffling) bfs = GetBalanceFunctionObject("ESD",centralityEstimator,centrMin,centrMax,kTRUE,bHBTcut,bConversionCut);
102 }
103 else if (analysisType=="AOD"){
104 bf = GetBalanceFunctionObject("AOD",centralityEstimator,centrMin,centrMax,kFALSE,bHBTcut,bConversionCut);
105 if(gRunShuffling) bfs = GetBalanceFunctionObject("AOD",centralityEstimator,centrMin,centrMax,kTRUE,bHBTcut,bConversionCut);
106 }
107 else if (analysisType=="MC"){
108 bf = GetBalanceFunctionObject("MC",centralityEstimator,centrMin,centrMax,kFALSE,bHBTcut,bConversionCut);
109 if(gRunShuffling) bfs = GetBalanceFunctionObject("MC",centralityEstimator,centrMin,centrMax,kTRUE,bHBTcut,bConversionCut);
110 }
111 else{
112 ::Error("AddTaskEventMixingBF", "analysis type NOT known.");
113 return NULL;
114 }
115
116 // Create the task, add it to manager and configure it.
117 //===========================================================================
118 AliAnalysisTaskEventMixingBF *taskEventMixingBF = new AliAnalysisTaskEventMixingBF("TaskEventMixingBF");
119 taskEventMixingBF->SetAnalysisObject(bf);
120 if(gRunShuffling) taskEventMixingBF->SetShufflingObject(bfs);
121
122 taskEventMixingBF->SetCentralityPercentileRange(centrMin,centrMax);
123 if(analysisType == "ESD") {
124 AliESDtrackCuts *trackCuts = GetTrackCutsObject(ptMin,ptMax,etaMin,etaMax,maxTPCchi2,DCAxy,DCAz,minNClustersTPC);
125 taskEventMixingBF->SetAnalysisCutObject(trackCuts);
126 if(kUsePID) {
127 if(kUseBayesianPID)
128 taskEventMixingBF->SetUseBayesianPID(gMinAcceptedProbability);
129 else if(kUseNSigmaPID)
130 taskEventMixingBF->SetUseNSigmaPID(nSigmaMax);
131 taskEventMixingBF->SetParticleOfInterest(AliAnalysistaskEventMixingBF::kProton);
132 taskEventMixingBF->SetDetectorUsedForPID(AliAnalysisTaskEventMixingBF::kTOFpid);
133 }
134 }
135 else if(analysisType == "AOD") {
136 // pt and eta cut (pt_min, pt_max, eta_min, eta_max)
137 taskEventMixingBF->SetAODtrackCutBit(AODfilterBit);
138 taskEventMixingBF->SetKinematicsCutsAOD(ptMin,ptMax,etaMin,etaMax);
139
140 // set extra DCA cuts (-1 no extra cut)
141 taskEventMixingBF->SetExtraDCACutsAOD(DCAxy,DCAz);
142
143 // set extra TPC chi2 / nr of clusters cut
144 taskEventMixingBF->SetExtraTPCCutsAOD(maxTPCchi2, minNClustersTPC);
145
146 }
147 else if(analysisType == "MC") {
148 taskEventMixingBF->SetKinematicsCutsAOD(ptMin,ptMax,etaMin,etaMax);
149 }
150
151 // offline trigger selection (AliVEvent.h)
152 // taskEventMixingBF->UseOfflineTrigger(); // NOT used (selection is done with the AliAnalysisTaskSE::SelectCollisionCandidates())
153 // with this only selected events are analyzed (first 2 bins in event QA histogram are the same))
154 // documentation in https://twiki.cern.ch/twiki/bin/viewauth/ALICE/PWG1EvSelDocumentation
155 if(bCentralTrigger) taskEventMixingBF->SelectCollisionCandidates(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral);
156 else taskEventMixingBF->SelectCollisionCandidates(AliVEvent::kMB);
157
158 // centrality estimator (default = V0M)
159 taskEventMixingBF->SetCentralityEstimator(centralityEstimator);
160
161 // vertex cut (x,y,z)
162 taskEventMixingBF->SetVertexDiamond(.3,.3,vertexZ);
163
164
165
166 //bf->PrintAnalysisSettings();
167 mgr->AddTask(taskEventMixingBF);
168
169 // Create ONLY the output containers for the data produced by the task.
170 // Get and connect other common input/output containers via the manager as below
171 //==============================================================================
172 TString outputFileName = AliAnalysisManager::GetCommonFileName();
173 outputFileName += ":PWGCFEbyE.outputBalanceFunctionAnalysis";
174 AliAnalysisDataContainer *coutQA = mgr->CreateContainer(Form("listQA_%s",centralityName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());
175 AliAnalysisDataContainer *coutEventMixingBF = mgr->CreateContainer(Form("listEventMixingBF_%s",centralityName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());
176 if(gRunShuffling) AliAnalysisDataContainer *coutEventMixingBFS = mgr->CreateContainer(Form("listEventMixingBFShuffled_%s",centralityName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());
177 if(kUsePID) AliAnalysisDataContainer *coutQAPID = mgr->CreateContainer(Form("listQAPID_%s",centralityName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());
178
179 mgr->ConnectInput(taskEventMixingBF, 0, mgr->GetCommonInputContainer());
180 mgr->ConnectOutput(taskEventMixingBF, 1, coutQA);
181 mgr->ConnectOutput(taskEventMixingBF, 2, coutEventMixingBF);
182 if(gRunShuffling) mgr->ConnectOutput(taskEventMixingBF, 3, coutEventMixingBFS);
183 if(kUsePID && analysisType == "ESD") mgr->ConnectOutput(taskEventMixingBF, 4, coutQAPID);
184
185 return taskEventMixingBF;
186}