1 /*************************************************************************************************
2 *** Add Fragmentation Function Task ***
3 **************************************************************************************************
4 The ID fragmentation function task expects an ESD filter and jet finder running before this task.
5 Or it runs on delta-AODs filled with filtered tracks and jets before.
8 (char) recJetsBranch: branch in AOD for (reconstructed) jets
9 (char) genJetsBranch: branch in AOD for (generated) jets
10 (char) jetType: "AOD" jets from recJetsBranch
11 "AODMC" jets from genJetsBranch
12 "KINE" jets from PYCELL
13 +"b" (e.g. "AODb") jets with acceptance cuts
14 (char) trackType: "AOD" reconstructed tracks from AOD filled by ESD filter (choose filter mask!)
15 "AODMC" MC tracks from AOD filled by kine filter
16 "KINE" kine particles from MC event
17 +"2" (e.g. "AOD2") charged tracks only
18 +"b" (e.g. "AOD2b") with acceptance cuts
19 (UInt_t) filterMask: select filter bit of ESD filter task
21 Typical parameters to run on 11a1* (MC_pp@7TeV):
22 "clustersAOD_ANTIKT", "", "clustersAODMC2_ANTIKT", "AODMCb", "AODMC2b", AliAnalysisManager::GetGlobalInt("kHighPtFilterMask", gDebug),
23 -0.4, 0, 1000*AliAnalysisManager::GetGlobalDbl("kTrackPtCut", gDebug), 0, "_Skip00", "", "_Skip00", 0.4, -1, 0, 0, kFALSE,
24 "PWGJE_taskPID_Jets", "", "PWGJE_taskPID_Jets_Inclusive", ""
26 ***************************************************************************************************/
28 void postConfig(AliAnalysisTaskIDFragmentationFunction* task, TString suffixPIDtaskJets1, TString suffixPIDtaskJets2,
29 TString suffixPIDtaskInclusive1, TString suffixPIDtaskInclusive2) {
31 task->SetBckgType(AliAnalysisTaskIDFragmentationFunction::kBckgPerp2,
32 AliAnalysisTaskIDFragmentationFunction::kBckgPerp,
33 AliAnalysisTaskIDFragmentationFunction::kBckgPerp2Area,
34 AliAnalysisTaskIDFragmentationFunction::kBckgOutAJStat,
35 AliAnalysisTaskIDFragmentationFunction::kBckgOut2J);
37 task->SetBranchRecBackClusters("");
40 //task->SetFFHistoBins(23, 5, 120, 480, 0., 120.,70, 0., 7., 52, 0., 1.3);
41 task->SetQATrackHistoBins(2400,0,120); // 50 MeV binning for comp to track dN/dpt prel. plot
48 // Set name of PID framework tasks
50 // Invalid: Second suffix set, but first one not set -> No PID tasks set
51 const Int_t numJetPIDtasks = (suffixPIDtaskJets1 != "") * ((suffixPIDtaskJets1 != "") + (suffixPIDtaskJets2 != ""));
52 if (numJetPIDtasks > 0) {
53 TString namesJetPIDtasks[numJetPIDtasks];
54 namesJetPIDtasks[0] = suffixPIDtaskJets1;
55 if (numJetPIDtasks > 1)
56 namesJetPIDtasks[1] = suffixPIDtaskJets2;
57 task->SetNamesOfJetPIDtasks(numJetPIDtasks, namesJetPIDtasks);
60 task->SetNamesOfJetPIDtasks(numJetPIDtasks, 0x0);
63 const Int_t numInclusivePIDtasks = (suffixPIDtaskInclusive1 != "") *
64 ((suffixPIDtaskInclusive1 != "") + (suffixPIDtaskInclusive2 != ""));
65 if (numInclusivePIDtasks > 0) {
66 TString namesInclusivePIDtasks[numInclusivePIDtasks];
67 namesInclusivePIDtasks[0] = suffixPIDtaskInclusive1;
68 if (numInclusivePIDtasks > 1)
69 namesInclusivePIDtasks[1] = suffixPIDtaskInclusive2;
70 task->SetNamesOfInclusivePIDtasks(numInclusivePIDtasks, namesInclusivePIDtasks);
73 task->SetNamesOfInclusivePIDtasks(numInclusivePIDtasks, 0x0);
75 printf("PID framework:\n");
76 printf("Jet PID tasks: ");
77 for (Int_t i = 0; i < numJetPIDtasks; i++)
78 printf("%s ", task->GetNamesOfJetPIDtasks()[i].Data());
80 printf("Inclusive PID task: ");
81 for (Int_t i = 0; i < numInclusivePIDtasks; i++)
82 printf("%s ", task->GetNamesOfInclusivePIDtasks()[i].Data());
87 AliAnalysisTaskIDFragmentationFunction *AddTaskIDFragmentationFunction(UInt_t iFlag=1, UInt_t filterMask=32, Int_t eventClass=0){
89 AliAnalysisTaskIDFragmentationFunction *ff=0;
92 // only reconstructed (default)
93 if(iFlag&(1<<0)) ff = AddTaskIDFragmentationFunction("jetsAOD_UA1", "", "", "", "", filterMask, 0.4,0,1000., eventClass);
94 // charged MC tracks and jets
95 if(iFlag&(1<<1)) ff = AddTaskIDFragmentationFunction("jetsAOD_UA1", "", "jetsAODMC2_UA1", "AODMC", "AODMC2", filterMask, 0.4,0,1000., eventClass);
96 // charged MC tracks and jets with acceptance cuts
97 if(iFlag&(1<<2)) ff = AddTaskIDFragmentationFunction("jetsAOD_UA1", "", "jetsAODMC2_UA1", "AODMCb", "AODMC2b", filterMask, 0.4,0,1000., eventClass);
98 // kine tracks in acceptance, pythia jets in acceptance
99 if(iFlag&(1<<3)) ff = AddTaskIDFragmentationFunction("jetsAOD_UA1", "", "", "KINEb", "KINEb", filterMask, 0.4,0,1000., eventClass);
100 // reconstructed charged tracks after cuts, MC jets in acceptance
101 if(iFlag&(1<<4)) ff = AddTaskIDFragmentationFunction("jetsAOD_UA1", "", "jetsMC2b", "AODMCb", "AOD2b", filterMask, 0.4,0,1000., eventClass);
102 // reconstruction efficiency: pointing with rec jet axis into gen tracks
103 if(iFlag&(1<<5)) ff = AddTaskIDFragmentationFunction("jetsAOD_UA1", "", "jetsAODMC2_UA1", "AODb", "AODMC2b", filterMask, 0.4,0,1000., eventClass);
107 // Jet background subtracted
108 // anti-kt, pt cut 1 GeV
109 if(iFlag&(1<<20)) ff = AddTaskIDFragmentationFunction("clustersAOD_ANTIKT", "", "", "", "", filterMask, 0.4,2,1000.,eventClass, "_Skip00");
110 // anti-kt, pt cut 2 GeV
111 if(iFlag&(1<<21)) ff = AddTaskIDFragmentationFunction("clustersAOD_ANTIKT", "", "", "", "", filterMask, 0.4,2,2000.,eventClass, "_Skip00");
112 // anti-kt, pt cut 150 MeV
113 if(iFlag&(1<<22)) ff = AddTaskIDFragmentationFunction("clustersAOD_ANTIKT", "", "", "", "", filterMask, 0.2,2,150.,eventClass, "_Skip00");
116 // Jet background subtracted
117 if(iFlag&(1<<23)) ff = AddTaskIDFragmentationFunction("clustersAOD_ANTIKT", "", "", "", "", filterMask, 0.4,2,150.,eventClass, "_Skip00");
118 // charged MC tracks and jets
119 if(iFlag&(1<<24)) ff = AddTaskIDFragmentationFunction("clustersAOD_ANTIKT", "", "jetsAODMC2_FASTJET", "AODMC", "AODMC2", filterMask, 0.4,2,150.,eventClass, "_Skip00");
120 // charged MC tracks and jets with acceptance cuts
121 if(iFlag&(1<<25)) ff = AddTaskIDFragmentationFunction("clustersAOD_ANTIKT", "", "jetsAODMC2_FASTJET", "AODMCb", "AODMC2b", filterMask, 0.4,2,150., eventClass, "_Skip00");
123 if(iFlag&(1<<26)) ff = AddTaskIDFragmentationFunction("clustersAOD_ANTIKT", "", "", "", "", filterMask, 0.4,1,150.,eventClass, "_Skip00");
125 if(iFlag&(1<<27)) ff = AddTaskIDFragmentationFunction("clustersAOD_ANTIKT", "", "", "", "", filterMask, 0.4,3,150.,eventClass, "_Skip00");
128 if(iFlag&(1<<28)) ff = AddTaskIDFragmentationFunction("jetsAOD_SISCONE", "", "", "", "", filterMask, 0.4,1,150.,eventClass);
129 if(iFlag&(1<<29)) ff = AddTaskIDFragmentationFunction("jetsAOD_SISCONE", "", "", "", "", filterMask, 0.4,2,150.,eventClass);
130 if(iFlag&(1<<30)) ff = AddTaskIDFragmentationFunction("jetsAOD_SISCONE", "", "", "", "", filterMask, 0.4,3,150.,eventClass);
135 // _______________________________________________________________________________________
137 AliAnalysisTaskIDFragmentationFunction *AddTaskIDFragmentationFunctionAllCent(
138 const char* recJetsBranch,
139 const char* recJetsBackBranch,
140 const char* genJetsBranch,
142 const char* trackType,
150 Float_t radiusBckg=0.4,
151 Int_t FFMaxTrackPt = -1,
152 Float_t FFMinNTracks = 0,
153 TString suffixPIDtaskJets1 = "",
154 TString suffixPIDtaskJets2 = "",
155 TString suffixPIDtaskInclusive1 = "",
156 TString suffixPIDtaskInclusive2 = "")
159 // adds task with given configuration for all centralities
161 AliAnalysisTaskIDFragmentationFunction *ff=0;
163 for(Int_t eventClass=1; eventClass<=4; eventClass++){
165 ff = AddTaskIDFragmentationFunction(recJetsBranch,
183 suffixPIDtaskInclusive1,
184 suffixPIDtaskInclusive2);
190 // _______________________________________________________________________________________
192 AliAnalysisTaskIDFragmentationFunction *AddTaskIDFragmentationFunction(
193 const char* recJetsBranch,
194 const char* recJetsBackBranch,
195 const char* genJetsBranch,
197 const char* trackType,
200 Int_t kBackgroundMode,
206 Float_t radiusBckg=0.4,
207 Int_t FFMaxTrackPt = -1,
208 Int_t FFMinNTracks = 0,
209 UInt_t filterMaskTracks = 0,
210 Bool_t onlyConsiderLeadingJets = kFALSE,
211 TString suffixPIDtaskJets1 = "",
212 TString suffixPIDtaskJets2 = "",
213 TString suffixPIDtaskInclusive1 = "",
214 TString suffixPIDtaskInclusive2 = "")
216 // Creates a fragmentation function task,
217 // configures it and adds it to the analysis manager.
219 //******************************************************************************
220 //*** Configuration Parameter **************************************************
221 //******************************************************************************
223 // space for configuration parameter: histo bin, cuts, ...
224 // so far only default parameter used
226 Int_t debug = -1; // debug level, -1: not set here
228 //******************************************************************************
232 // Get the pointer to the existing analysis manager via the static access method.
233 //==============================================================================
234 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
236 ::Error("AddTaskIDFragmentationFunction", "No analysis manager to connect to.");
240 // Check the analysis type using the event handlers connected to the analysis manager.
241 //==============================================================================
242 if (!mgr->GetInputEventHandler()) {
243 ::Error("AddTaskIDFragmentationFunction", "This task requires an input event handler");
247 TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
248 Printf("Data Type: %s", type.Data());
250 TString branchRecBackJets(recJetsBackBranch);
251 TString branchRecJets(recJetsBranch);
252 TString branchGenJets(genJetsBranch);
253 TString typeJets(jetType);
254 TString typeTracks(trackType);
256 if(branchRecBackJets.Length()==0) branchRecBackJets = "noRecBackJets";
257 if(branchRecJets.Length()==0) branchRecJets = "noRecJets";
258 if(branchGenJets.Length()==0) branchGenJets = "noGenJets";
259 if(typeTracks.Length()==0) typeTracks = "trackTypeUndef";
260 if(typeJets.Length()==0) typeJets = "jetTypeUndef";
262 // Create the task and configure it.
263 //===========================================================================
265 AliAnalysisTaskIDFragmentationFunction *task = new AliAnalysisTaskIDFragmentationFunction(
266 Form("Fragmentation_Function_%s_%s_%s_%s", branchRecJets.Data(), branchGenJets.Data(), typeJets.Data(), typeTracks.Data()));
268 if(debug>=0) task->SetDebugLevel(debug);
270 Printf("Rec Jets %s", branchRecJets.Data());
271 Printf("Back Rec Jets %s", branchRecBackJets.Data());
272 Printf("Gen Jets %s", branchGenJets.Data());
273 Printf("Jet Type %s", typeJets.Data());
274 Printf("Track Type %s", typeTracks.Data());
276 // attach the filter mask and options
278 cAdd += Form("%02d",(int)((TMath::Abs(radius)+0.01)*10.));
279 cAdd += Form("_B%d",(int)((kBackgroundMode)));
280 cAdd += Form("_Filter%05d",filterMask);
281 cAdd += Form("_Cut%05d",PtTrackMin);
282 cAdd += Form("%s",BrOpt.Data());
283 cAdd += Form("%s",BrOpt2.Data());
285 Printf("%s",cAdd.Data());
288 cAddb += Form("%02d",(int)((radiusBckg+0.01)*10.));
289 cAddb += Form("_B%d",(int)((kBackgroundMode)));
290 cAddb += Form("_Filter%05d",filterMask);
291 cAddb += Form("_Cut%05d",PtTrackMin);
292 cAddb += Form("%s",BrOpt.Data());
293 cAddb += Form("%s",BrOpt2.Data());
295 Printf("%s",cAddb.Data());
298 cAddmc += Form("%02d",(int)((TMath::Abs(radius)+0.01)*10.));
299 cAddmc += Form("_B%d",(int)((kBackgroundMode)));
300 cAddmc += Form("_Filter%05d",filterMask);
301 cAddmc += Form("_Cut%05d",PtTrackMin);
302 cAddmc += Form("%s",BrOpt3.Data());
304 Printf("%s",cAddmc.Data());
307 if(branchRecJets.Contains("AOD")&&branchRecJets.Contains("jets")&&!branchRecJets.Contains("MC"))branchRecJets = branchRecJets + cAdd;
308 if(branchRecJets.Contains("AOD")&&branchRecJets.Contains("cluster")&&!branchRecJets.Contains("MC"))branchRecJets = branchRecJets + cAdd;
310 if(branchRecBackJets.Contains("back")&&branchRecBackJets.Contains("cluster")&&!branchRecBackJets.Contains("MC"))branchRecBackJets = branchRecBackJets + cAddb;
312 if(branchGenJets.Contains("AOD")&&branchGenJets.Contains("MC"))branchGenJets = branchGenJets + cAddmc;
314 Printf("Gen jets branch %s: ", branchGenJets.Data());
315 Printf("Rec jets branch %s: ", branchRecJets.Data());
316 Printf("Jet backg branch %s: ", branchRecBackJets.Data());
318 if(!branchRecJets.Contains("noRecJets")) task->SetBranchRecJets(branchRecJets);
319 if(!branchRecBackJets.Contains("noRecBackJets")) task->SetBranchRecBackJets(branchRecBackJets);
320 if(!branchGenJets.Contains("noGenJets")) task->SetBranchGenJets(branchGenJets);
323 if(typeTracks.Contains("AODMC2b")) task->SetTrackTypeGen(AliAnalysisTaskIDFragmentationFunction::kTrackAODMCChargedAcceptance);
324 else if(typeTracks.Contains("AODMC2")) task->SetTrackTypeGen(AliAnalysisTaskIDFragmentationFunction::kTrackAODMCCharged);
325 else if(typeTracks.Contains("AODMC")) task->SetTrackTypeGen(AliAnalysisTaskIDFragmentationFunction::kTrackAODMCAll);
326 else if(typeTracks.Contains("KINE2b")) task->SetTrackTypeGen(AliAnalysisTaskIDFragmentationFunction::kTrackKineChargedAcceptance);
327 else if(typeTracks.Contains("KINE2")) task->SetTrackTypeGen(AliAnalysisTaskIDFragmentationFunction::kTrackKineCharged);
328 else if(typeTracks.Contains("KINE")) task->SetTrackTypeGen(AliAnalysisTaskIDFragmentationFunction::kTrackKineAll);
329 else if(typeTracks.Contains("AODb")) task->SetTrackTypeGen(AliAnalysisTaskIDFragmentationFunction::kTrackAODCuts);
330 else if(typeTracks.Contains("AOD")) task->SetTrackTypeGen(AliAnalysisTaskIDFragmentationFunction::kTrackAOD);
331 else if(typeTracks.Contains("trackTypeUndef")) task->SetTrackTypeGen(0); // undefined
332 else Printf("trackType %s not found", typeTracks.Data());
334 if(typeJets.Contains("AODMCb")) task->SetJetTypeGen(AliAnalysisTaskIDFragmentationFunction::kJetsGenAcceptance);
335 else if(typeJets.Contains("AODMC")) task->SetJetTypeGen(AliAnalysisTaskIDFragmentationFunction::kJetsGen);
336 else if(typeJets.Contains("KINEb")) task->SetJetTypeGen(AliAnalysisTaskIDFragmentationFunction::kJetsKineAcceptance);
337 else if(typeJets.Contains("KINE")) task->SetJetTypeGen(AliAnalysisTaskIDFragmentationFunction::kJetsKine);
338 else if(typeJets.Contains("AODb")) task->SetJetTypeGen(AliAnalysisTaskIDFragmentationFunction::kJetsRecAcceptance);
339 else if(typeJets.Contains("AOD")) task->SetJetTypeGen(AliAnalysisTaskIDFragmentationFunction::kJetsRec);
340 else if(typeJets.Contains("jetTypeUndef")) task->SetJetTypeGen(0); // undefined
341 else Printf("jetType %s not found", typeJets.Data());
343 if(typeJets.Contains("AODMCb")) task->SetJetTypeRecEff(AliAnalysisTaskIDFragmentationFunction::kJetsGenAcceptance); // kJetsRecAcceptance
344 else if(typeJets.Contains("AODb")) task->SetJetTypeRecEff(AliAnalysisTaskIDFragmentationFunction::kJetsRecAcceptance);
345 else task->SetJetTypeRecEff(0);
347 if(!filterMaskTracks) task->SetFilterMask(filterMask);
348 else task->SetFilterMask(filterMaskTracks);
350 task->SetEventSelectionMask(AliVEvent::kMB);
351 task->SetEventClass(eventClass);
353 // Set default parameters
356 if(PtTrackMin == 150) task->SetTrackCuts(); // default : pt > 0.150 GeV, |eta|<0.9, full phi acc
357 else if(PtTrackMin == 1000) task->SetTrackCuts(1.0, -0.9, 0.9, 0., 2*TMath::Pi());
358 else if(PtTrackMin == 2000) task->SetTrackCuts(2.0, -0.9, 0.9, 0., 2*TMath::Pi());
359 else task->SetTrackCuts(0.001*PtTrackMin,-0.9, 0.9, 0., 2*TMath::Pi());
362 task->SetJetCuts(); // default: jet pt > 5 GeV, |eta|<0.5, full phi acc
363 task->SetFFRadius(radius);
364 task->SetFFBckgRadius(); // default: R = 0.7
365 task->SetQAMode(); // default: qaMode = 3
366 task->SetFFMode(); // default: ffMode = 1
367 task->SetIDFFMode(0); // default: IDffMode = 0
368 task->SetEffMode(0); // default: effMode = 1
369 task->SetHighPtThreshold(); // default: pt > 5 Gev
371 task->SetBckgMode(1); // default: bgMode = 1
373 task->SetBranchRecBackClusters(Form("clustersAOD_KT04_B0_Filter%05d_Cut00150_Skip00",filterMask));
375 task->SetOnlyLeadingJets(onlyConsiderLeadingJets); // default: kFALSE
378 task->SetFFHistoBins(23, 5, 120, 480, 0., 120.,70, 0., 7.,22, 0., 1.1);
380 task->SetQAJetHistoBins();
381 task->SetQATrackHistoBins();
383 if(FFMaxTrackPt>0) task->SetFFMaxTrackPt(FFMaxTrackPt);
384 if(FFMinNTracks>0) task->SetFFMinNTracks(FFMinNTracks);
388 // Create ONLY the output containers for the data produced by the task.
389 // Get and connect other common input/output containers via the manager as below
390 //==============================================================================
392 TString strList(Form("fracfunc_%s_%s_%s_%s_cl%d", branchRecJets.Data(), branchGenJets.Data(), typeTracks.Data(), typeJets.Data(), eventClass));
394 TString strDir(Form("%s:PWGJE_IDFragmentationFunction_%s_%s_%s_%s_cl%d",
395 AliAnalysisManager::GetCommonFileName(), branchRecJets.Data(), branchGenJets. Data(),
396 typeTracks.Data(), typeJets.Data(), eventClass));
400 strList += Form("_FFMaxPt%d", FFMaxTrackPt);
401 strDir += Form("_FFMaxPt%d", FFMaxTrackPt);
404 strList += Form("_minNTr%d",FFMinNTracks);
405 strDir += Form("_minNTr%d",FFMinNTracks);
409 strList += "_trackRefs";
410 strDir += "_trackRefs";
412 if(filterMaskTracks){
413 strList += Form("_TrackFilter%05d",filterMaskTracks);
414 strDir += Form("_TrackFilter%05d",filterMaskTracks);
418 AliAnalysisDataContainer *coutput_FragFunc = mgr->CreateContainer(strList,TList::Class(),
419 AliAnalysisManager::kOutputContainer,
422 mgr->ConnectInput (task, 0, mgr->GetCommonInputContainer());
423 mgr->ConnectOutput (task, 0, mgr->GetCommonOutputContainer());
424 mgr->ConnectOutput (task, 1, coutput_FragFunc);
426 postConfig(task, suffixPIDtaskJets1, suffixPIDtaskJets2, suffixPIDtaskInclusive1, suffixPIDtaskInclusive2);