]>
Commit | Line | Data |
---|---|---|
2229ac91 | 1 | //-*- Mode: C++ -*- |
2 | // $Id: AddTaskDxHFECorrelation.C 60786 2013-02-08 18:16:19Z arossi $ | |
3 | ||
4 | #ifndef __CINT__ | |
5 | //#include "AliESDtrackCuts.h" | |
6 | //#include "AliAnalysisCuts.h" | |
7 | //#include "AliFlowTrackSimple.h" // added as hint for hidden library dependency to libPWGflowBase | |
8 | //#include "AliFlowCandidateTrack.h" // added as hint for hidden library dependency to libPWGflowTasks | |
9 | //#include "AliCFContainer.h" // added as hint for hidden library dependency to libCORRFW | |
10 | //#include "AliAODRecoDecayHF2Prong.h" // added as hint for hidden library dependency to libPWGHFvertexingHF | |
11 | #include "AliHFAssociatedTrackCuts.h" | |
12 | #include "AliAnalysisTaskDxHFEParticleSelection.h" | |
13 | #include "AliDxHFEParticleSelection.h" | |
14 | #include "AliAnalysisManager.h" | |
15 | #include "AliAnalysisDataContainer.h" | |
16 | #include "AliHFEcuts.h" | |
17 | #include "AliLog.h" | |
18 | #include "TObject.h" | |
19 | #include "TClass.h" | |
20 | #include "TDirectory.h" | |
21 | #include "TROOT.h" | |
22 | #include "AliRDHFCutsD0toKpi.h" | |
23 | using namespace std; | |
24 | #endif | |
25 | ||
26 | const char* poolInfoName="PoolInfo"; | |
27 | AliAnalysisCuts* createDefaultPoolConfig(); | |
28 | ||
29 | /// @file AddTaskDxHFEParticleSelection.C | |
30 | /// @author Matthias.Richter@ift.uib.no, Hege.Erdal@ift.uib.no | |
31 | /// @date 2013-02-12 | |
32 | /// @brief Add the ParticleSelection task to the manager | |
33 | /// | |
b4779749 | 34 | int AddTaskDxHFEParticleSelection(TString configuration="",TString analysisName="PWGHFCJParticleSelection") |
2229ac91 | 35 | { |
b4779749 | 36 | |
37 | //First check to see if user wants to see help | |
38 | if (configuration.BeginsWith("help") || | |
39 | configuration.BeginsWith("--help") || | |
40 | configuration.BeginsWith("-h") || | |
41 | configuration.BeginsWith("options") ) { | |
42 | cout <<"\n\n============================================" << endl; | |
43 | cout << "Keywords for AddTaskDxHFEParticleSelection.C:\n" | |
44 | << "file= - Filename to store output in\n" | |
45 | << "name= - Name of analysis, will correspond to directory inside the file \n" | |
46 | << "cutname= - Filename where information on event pool for event-mixing is stored (if use external file)\n" | |
47 | << "runD0MassReference - If you also want to include D2H task for D0selection (for comparison purposes)\n" | |
48 | << "mc - Run on MC\n" | |
49 | << "PbPb - Run on PbPbn" | |
50 | << "usekine - To run on kinematical level \n" | |
51 | << "particle=D0/electron - Which particle to run analysis on \n" | |
52 | << "\nD0 settings: \n" | |
53 | << "fillD0scheme=both/D0/D0bar - Which fillsheme to use for D0\n" | |
54 | << "\nelectron settings: \n" | |
55 | << "useinvmasscut - If you want to use invariant mass cut (default is 100MeV/c)\n" | |
56 | << "invmasscut= - If you want to specify a different invariant mass cut \n" | |
57 | << "extraname= - extraname for directory and list if you run several tasks at once\n" | |
58 | << "tpcclusters= - How many TPC clusters to use on single track cuts for electrons (default=120)\n" | |
59 | << "itsclusters= - How many itsclusters to be used in single track cuts for electrons (default=4) \n" | |
60 | << "itsreq= - (kFirst,kAny,kNone) Which ITSpixel requirement you want to impose\n" | |
61 | << "elmcreco= - (aftertrackcuts/aftertofpid/afterfullpid) Where you want to stop in track selection to look for electrons for mc \n\n"; | |
62 | return; | |
63 | } | |
64 | ||
2229ac91 | 65 | AliAnalysisManager *pManager = AliAnalysisManager::GetAnalysisManager(); |
66 | if (!pManager) { | |
67 | ::Error("AddTaskDxHFEParticleSelection", "No analysis manager to connect to."); | |
68 | return; | |
69 | } | |
70 | ||
71 | Bool_t bUseMC=kFALSE; | |
72 | TString ofilename; | |
73 | Int_t system=0; | |
74 | TString taskOptions; | |
b4779749 | 75 | Bool_t bUseKine=kFALSE; |
76 | Bool_t bUseMCReco=kFALSE; | |
77 | Int_t NrTPCclusters=120; // quick fix for problems sending track cut objects in some instances to task | |
78 | Int_t NrITSclusters=4; // quick fix for problem sending hfe track cut object to addtask | |
79 | Int_t ITSreq=AliHFEextraCuts::kFirst; | |
2229ac91 | 80 | Int_t Particle=AliAnalysisTaskDxHFEParticleSelection::kD0; |
b4779749 | 81 | TString extraname=""; |
2229ac91 | 82 | |
83 | // look for configuration arguments | |
b4779749 | 84 | cout << endl << "===============================================" << endl; |
85 | cout << "Setting up Particle Selection task: " << configuration << endl; | |
86 | ||
87 | // look for configuration arguments if nothing specified | |
88 | // in the function call | |
89 | if (configuration.IsNull() && gDirectory) { | |
2229ac91 | 90 | const char* confObjectName="run_single_task_configuration"; |
91 | TObject* confObject=gDirectory->FindObject(confObjectName); | |
92 | if (confObject) { | |
b4779749 | 93 | configuration=confObject->GetTitle(); |
94 | } | |
95 | } | |
96 | {// deprecated, but keep for formatting | |
97 | {// deprecated, but keep for formatting | |
2229ac91 | 98 | TObjArray* tokens=configuration.Tokenize(" "); |
99 | if (tokens) { | |
100 | TIter next(tokens); | |
101 | TObject* token; | |
102 | while ((token=next())) { | |
103 | TString argument=token->GetName(); | |
104 | if (argument.BeginsWith("file=")) { | |
105 | argument.ReplaceAll("file=", ""); | |
106 | ofilename=argument; | |
107 | } else if (argument.BeginsWith("name=")) { | |
108 | argument.ReplaceAll("name=", ""); | |
b4779749 | 109 | analysisName=" "+argument+"PartSel"; |
2229ac91 | 110 | } |
111 | if (argument.BeginsWith("mc")) { | |
112 | bUseMC=kTRUE; | |
113 | taskOptions+=" mc"; | |
114 | } | |
fad30eb8 | 115 | if (argument.BeginsWith("PbPb") || argument.BeginsWith("Pb-Pb")) { |
2229ac91 | 116 | system=1; |
fad30eb8 | 117 | taskOptions+=" system=Pb-Pb"; |
118 | cout << "Use PbPb" << endl; | |
2229ac91 | 119 | } |
b4779749 | 120 | if(argument.BeginsWith("tpcclusters=")){ |
121 | argument.ReplaceAll("tpcclusters=", ""); | |
122 | NrTPCclusters=argument.Atoi(); | |
123 | ::Info("AddTaskDxHFEParticleSelection",Form("Setting nr TPC clusters to %d",NrTPCclusters)); | |
124 | } | |
2229ac91 | 125 | if (argument.BeginsWith("fillD0scheme=")){ |
126 | argument.ReplaceAll("fillD0scheme=",""); | |
127 | taskOptions+=" fillD0scheme="+argument; | |
128 | } | |
b4779749 | 129 | if(argument.BeginsWith("elmcreco")){ |
130 | bUseMCReco=kTRUE; | |
131 | taskOptions+=" "+argument; | |
132 | } | |
133 | if (argument.BeginsWith("usekine") ||argument.BeginsWith("kine")) { | |
134 | bUseKine=kTRUE; | |
135 | taskOptions+=" usekine"; | |
136 | } | |
2229ac91 | 137 | if (argument.BeginsWith("particle=")) { |
138 | taskOptions+=" "+argument; | |
139 | argument.ReplaceAll("particle=",""); | |
140 | if (argument.CompareTo("D0")==0){ | |
141 | Particle=AliAnalysisTaskDxHFEParticleSelection::kD0; | |
142 | } | |
143 | else if (argument.CompareTo("electron")==0){ | |
144 | Particle=AliAnalysisTaskDxHFEParticleSelection::kElectron; | |
b4779749 | 145 | } |
146 | } | |
147 | if(argument.BeginsWith("useinvmasscut")) | |
148 | taskOptions+=" "+argument; | |
fad30eb8 | 149 | if(argument.BeginsWith("twoselectedinvmasscut")) |
150 | taskOptions+=" "+argument; | |
b4779749 | 151 | if(argument.BeginsWith("invmasscut=")) |
152 | taskOptions+=" "+argument; | |
fad30eb8 | 153 | if(argument.BeginsWith("impactparamcut")) |
154 | taskOptions+=" "+argument; | |
155 | if(argument.BeginsWith("etacut")) | |
156 | taskOptions+=" "+argument; | |
157 | if(argument.BeginsWith("storelastcutstep")) | |
158 | taskOptions+=" "+argument; | |
b4779749 | 159 | if(argument.BeginsWith("itsclusters=")){ |
160 | argument.ReplaceAll("itsclusters=", ""); | |
161 | NrITSclusters=argument.Atoi(); | |
162 | } | |
163 | if(argument.BeginsWith("itsreq=")){ | |
164 | argument.ReplaceAll("itsreq=", ""); | |
165 | if(argument.CompareTo("kFirst")==0) ITSreq=AliHFEextraCuts::kFirst; | |
166 | else if(argument.CompareTo("kAny")==0) ITSreq=AliHFEextraCuts::kAny; | |
167 | else if(argument.CompareTo("kNone")==0) ITSreq=AliHFEextraCuts::kNone; | |
168 | } | |
169 | if(argument.BeginsWith("extraname=")){ | |
170 | argument.ReplaceAll("extraname=", ""); | |
171 | extraname=argument; | |
2229ac91 | 172 | } |
173 | } | |
174 | ||
175 | } | |
176 | delete tokens; | |
177 | } | |
178 | } | |
179 | ||
b4779749 | 180 | if(bUseMCReco && bUseKine) { |
181 | ::Fatal("AddTaskDxHFECorrelation","CAN'T SET BOTH usekine AND elmcreco AT THE SAME TIME"); | |
182 | return; | |
183 | } | |
184 | ||
2229ac91 | 185 | // check for existence of PID task and add if not available |
186 | const char* pidTaskName="PIDResponseTask"; | |
187 | const char* pidTaskMacro="$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C"; | |
188 | AliAnalysisTask* pidTask=pManager->GetTask(pidTaskName); | |
189 | if (!pidTask) { | |
190 | gROOT->LoadMacro(pidTaskMacro); | |
191 | TString pidFunction; | |
192 | pidFunction.Form("AddTaskPIDResponse(%d, %d)", bUseMC, kTRUE); | |
193 | gROOT->ProcessLine(pidFunction); | |
194 | if (pManager->GetTask(pidTaskName)==NULL) { | |
195 | ::Error("AddTaskDxHFEParticleSelection", Form("failed to add PID task '%s' from macro '%s'", | |
196 | pidTaskName, pidTaskMacro)); | |
197 | return 0; | |
198 | } | |
199 | } else { | |
200 | // TODO: would like to check if the PID task was set up | |
201 | // with consistent parameters, however there are no getters at the moment | |
202 | ::Info("AddTaskDxHFEParticleSelection", Form("PID task '%s' already existing", pidTaskName)); | |
203 | } | |
204 | ||
205 | if (ofilename.IsNull()) ofilename=AliAnalysisManager::GetCommonFileName(); | |
206 | ofilename+=":"+analysisName; | |
207 | ||
208 | ///______________________________________________________________________ | |
209 | /// Cuts For D0 | |
2229ac91 | 210 | AliRDHFCutsD0toKpi* RDHFD0toKpi=new AliRDHFCutsD0toKpi(); |
fad30eb8 | 211 | if (system==0) { |
212 | RDHFD0toKpi->SetStandardCutsPP2010(); | |
213 | } else { | |
214 | // TODO: think about p-Pb | |
215 | RDHFD0toKpi->SetStandardCutsPbPb2011(); | |
216 | ||
217 | // For centrality 0-10%, add centrality flattening | |
218 | //NB! NEED FOR THE MOMENT THE FILE! | |
219 | TFile *fFlat=TFile::Open("CentrDistrBins005.root","READ"); | |
220 | TCanvas *c=fFlat->Get("cintegral"); | |
221 | TH1F *hfl=(TH1F*)c->FindObject("hint"); | |
222 | RDHFD0toKpi->SetHistoForCentralityFlattening(hfl,0.,10.,0.,0); | |
223 | // RDHFD0toKpi->SetUseCentrality(AliRDHFCuts::kCentV0M); | |
224 | ||
225 | RDHFD0toKpi->SetMinCentrality(0.);// 40.*1.01 | |
226 | RDHFD0toKpi->SetMaxCentrality(10.);// 80.*1.01 | |
227 | } | |
2229ac91 | 228 | |
229 | ///______________________________________________________________________ | |
230 | /// Cuts for HFE | |
231 | AliHFEcuts *hfecuts = new AliHFEcuts("hfeCutsTPCTOF","HFE Standard Cuts"); | |
232 | hfecuts->CreateStandardCuts(); | |
233 | ||
234 | hfecuts->SetTPCmodes(AliHFEextraCuts::kFound,AliHFEextraCuts::kFoundOverFindable); | |
b4779749 | 235 | hfecuts->SetMinNClustersTPC(NrTPCclusters); //Default = 80 |
2229ac91 | 236 | hfecuts->SetMinNClustersTPCPID(80); //Default = 80 |
237 | hfecuts->SetMinRatioTPCclusters(0.6); //Default = 0.6 | |
238 | ||
239 | ///ITS | |
b4779749 | 240 | hfecuts->SetCutITSpixel(ITSreq); //Cut on SPD |
2229ac91 | 241 | //hfecuts->SetCutITSdrift(AliHFEextraCuts::kAny); //Cut on SDD |
242 | //hfecuts->SetCheckITSLayerStatus(kFALSE); | |
b4779749 | 243 | hfecuts->SetMinNClustersITS(NrITSclusters); //Default = 4 |
244 | ||
2229ac91 | 245 | ///TOF |
246 | hfecuts->SetTOFPIDStep(kTRUE); | |
247 | ||
248 | ///Additional Cuts | |
249 | hfecuts->SetPtRange(0.30, 10.5); | |
250 | hfecuts->SetMaxImpactParam(1.,2.); | |
251 | hfecuts->SetVertexRange(10.); | |
252 | ||
253 | // ________________________________________________________________________ | |
254 | // PID for HFE | |
255 | // PID for Only TOF | |
256 | AliHFEpid *fPIDOnlyTOF = new AliHFEpid("hfePidTOF"); | |
257 | if(!fPIDOnlyTOF->GetNumberOfPIDdetectors()) { | |
258 | fPIDOnlyTOF->AddDetector("TOF",0); | |
259 | } | |
260 | fPIDOnlyTOF->ConfigureTOF(3); // number of sigma TOF | |
261 | fPIDOnlyTOF->InitializePID(); | |
262 | ||
263 | // PID object for TPC and TOF combined | |
264 | // Check if PID is set from outside (passed as argument) | |
b4779749 | 265 | ::Info("AddTaskDxHFEParticleSelection",Form("Setting up new combined PID object")); |
266 | AliHFEpid* fPID = new AliHFEpid("hfePid"); | |
267 | if(!fPID->GetNumberOfPIDdetectors()) { | |
268 | fPID->AddDetector("TOF",0); | |
269 | fPID->AddDetector("TPC",1); | |
2229ac91 | 270 | } |
b4779749 | 271 | //Add settings for asymmetric cut on nSigma TPC |
272 | const int paramSize=4; | |
273 | Double_t params[paramSize]; | |
274 | memset(params, 0, sizeof(Double_t)*paramSize); | |
275 | params[0]=-1.; | |
276 | fPID->ConfigureTPCdefaultCut(NULL, params, 3.); | |
277 | fPID->InitializePID(); | |
fad30eb8 | 278 | |
279 | // PID for Only TPC | |
280 | AliHFEpid *fPIDOnlyTPC = new AliHFEpid("hfePidTPC"); | |
281 | if(!fPIDOnlyTPC->GetNumberOfPIDdetectors()) { | |
282 | fPIDOnlyTPC->AddDetector("TPC",0); | |
283 | } | |
284 | fPIDOnlyTPC->ConfigureTPCdefaultCut(NULL, params, 3.); | |
285 | fPIDOnlyTPC->InitializePID(); | |
2229ac91 | 286 | |
287 | //========================================================= | |
288 | //Create TList of cut (and pid) objects for D0 or electron | |
289 | TList *Cutlist = new TList; | |
290 | if(Particle==AliAnalysisTaskDxHFEParticleSelection::kD0){ | |
291 | Cutlist->SetName("cut objects D0"); | |
292 | Cutlist->Add(RDHFD0toKpi); | |
293 | } | |
294 | else if(Particle==AliAnalysisTaskDxHFEParticleSelection::kElectron){ | |
295 | Cutlist->SetName("cut objects HFE"); | |
296 | Cutlist->Add(hfecuts); | |
297 | Cutlist->Add(fPID); | |
298 | Cutlist->Add(fPIDOnlyTOF); | |
fad30eb8 | 299 | Cutlist->Add(fPIDOnlyTPC); |
2229ac91 | 300 | } |
301 | ||
302 | //=======================Setting up the task========================================= | |
303 | AliAnalysisTaskDxHFEParticleSelection *pTask=new AliAnalysisTaskDxHFEParticleSelection(taskOptions); | |
304 | if (!pTask) { | |
305 | ::Error("AddTaskDxHFEParticleSelection", "failed to create task."); | |
306 | return 0; | |
307 | } | |
308 | pTask->SetCutList(Cutlist); | |
309 | pManager->AddTask(pTask); | |
310 | ||
311 | // The AnalysisManager handles the output file name in the following way: | |
312 | // The output file names are set by the function SetOutputFiles | |
313 | // If the file name given to the container begins with one of the initialized | |
314 | // file names, the data is stored in the corresponding file in a folder with | |
315 | // the full name specified to the container | |
316 | // E.g. output file has been set to "myanalysis", the container is created with | |
317 | // file name "myanalysis_A", data ends up in file "myanalysis" in folder | |
318 | // "myanalysis_A" | |
319 | // IMPORTANT: choosing a file name with a different stem at this point will | |
320 | // probably lead to an empty file. | |
321 | ||
322 | TString listName=""; | |
323 | ||
324 | TString cutname=""; | |
325 | if(Particle==AliAnalysisTaskDxHFEParticleSelection::kD0){ | |
fad30eb8 | 326 | listName="D0list"+extraname; |
327 | cutname="cutsD0Selection"+extraname; | |
2229ac91 | 328 | } |
329 | else if(Particle==AliAnalysisTaskDxHFEParticleSelection::kElectron){ | |
fad30eb8 | 330 | listName="ElList"+extraname; |
331 | cutname="cutsElectronSelection"+extraname; | |
2229ac91 | 332 | } |
333 | ||
334 | ::Info("AddTaskDxHFEParticleSelection", Form("\ninitializing analysis '%s'%s, output file '%s'", analysisName.Data(), bUseMC?" (using MC)":"", ofilename.Data())); | |
335 | ||
336 | ||
337 | AliAnalysisDataContainer *pContainer=pManager->CreateContainer(listName, TList::Class(), AliAnalysisManager::kOutputContainer, ofilename.Data()); | |
338 | AliAnalysisDataContainer *pContainer2=pManager->CreateContainer(cutname,TList::Class(),AliAnalysisManager::kOutputContainer, ofilename.Data()); //cuts D0/El | |
339 | ||
340 | pManager->ConnectInput(pTask,0,pManager->GetCommonInputContainer()); | |
341 | pManager->ConnectOutput(pTask,1,pContainer); | |
342 | pManager->ConnectOutput(pTask,2,pContainer2); | |
343 | ||
344 | ||
345 | return 1; | |
346 | } | |
347 |