Add the efficiency estimation to common FF task.
[u/mrichter/AliRoot.git] / PWG4 / macros / AddTaskFragmentationFunction.C
CommitLineData
1db1733e 1
2/*************************************************************************************************
3*** Add Fragmentation Function Task ***
4**************************************************************************************************
5The fragmenation function task expects an ESD filter and jet finder running before this task.
6Or it runs on delta-AODs filled with filtered tracks and jets before.
7
8** Parameters **
9(char) recJetsBranch: branch in AOD for (reconstructed) jets
10(char) genJetsBranch: branch in AOD for (generated) jets
11(char) jetType: "AOD" jets from recJetsBranch
12 "AODMC" jets from genJetsBranch
13 "KINE" jets from PYCELL
14 +"b" (e.g. "AODb") jets with acceptance cuts
15(char) trackType: "AOD" reconstructed tracks from AOD filled by ESD filter (choose filter mask!)
16 "AODMC" MC tracks from AOD filled by kine filter
17 "KINE" kine particles from MC event
18 +"2" (e.g. "AOD2") charged tracks only
19 +"b" (e.g. "AOD2b") with acceptance cuts
20(UInt_t) filterMask: select filter bit of ESD filter task
21
22***************************************************************************************************/
23
24
25
26
27AliAnalysisTaskFragmentationFunction *AddTaskFragmentationFunction(UInt_t iFlag=1, UInt_t filterMask=16){
28
29 AliAnalysisTaskFragmentationFunction *ff=0;
30
31 // only reconstructed (default)
32 if(iFlag&(1<<0)) ff = AddTaskFragmentationFunction("jets", "", "", "", filterMask);
33 // MC tracks in acceptance, MC jets in acceptance
34 if(iFlag&(1<<1)) ff = AddTaskFragmentationFunction("jets", "AODMC2b", "AODMCb", "AODMCb", filterMask);
35 // kine tracks in acceptance, pythia jets in acceptance
36 if(iFlag&(1<<2)) ff = AddTaskFragmentationFunction("jets", "", "KINEb", "KINEb", filterMask);
37 // reconstructed charged tracks after cuts, MC jets in acceptance
38 if(iFlag&(1<<3)) ff = AddTaskFragmentationFunction("jets", "AODMC2b", "AODMCb", "AOD2b", filterMask);
39
40 return ff;
41}
42
43// _______________________________________________________________________________________
44
45AliAnalysisTaskFragmentationFunction *AddTaskFragmentationFunction(
46 const char* recJetsBranch,
47 const char* genJetsBranch,
48 const char* jetType,
49 const char* trackType,
50 UInt_t filterMask)
6bec8236 51{
1db1733e 52 // Creates a fragmentation function task,
53 // configures it and adds it to the analysis manager.
54
55 //******************************************************************************
56 //*** Configuration Parameter **************************************************
57 //******************************************************************************
58
59 // space for configuration parameter: histo bin, cuts, ...
60 // so far only default parameter used
61
62 Int_t debug = -1; // debug level, -1: not set here
6bec8236 63
1db1733e 64 //******************************************************************************
65
66
67
6bec8236 68 // Get the pointer to the existing analysis manager via the static access method.
69 //==============================================================================
70 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
71 if (!mgr) {
1db1733e 72 ::Error("AddTaskFragmentationFunction", "No analysis manager to connect to.");
73 return NULL;
74 }
6bec8236 75
76 // Check the analysis type using the event handlers connected to the analysis manager.
77 //==============================================================================
78 if (!mgr->GetInputEventHandler()) {
1db1733e 79 ::Error("AddTaskFragmentationFunction", "This task requires an input event handler");
80 return NULL;
6bec8236 81 }
82
1db1733e 83 TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
84 Printf("Data Type: %s", type.Data());
85
86 TString branchRecJets(recJetsBranch);
87 TString branchGenJets(genJetsBranch);
88 TString typeJets(jetType);
89 TString typeTracks(trackType);
90
91 if(branchRecJets.Length()==0) branchRecJets = "noRecJets";
92 if(branchGenJets.Length()==0) branchGenJets = "noGenJets";
93 if(typeTracks.Length()==0) typeTracks = "trackTypeUndef";
94 if(typeJets.Length()==0) typeJets = "jetTypeUndef";
95
6bec8236 96 // Create the task and configure it.
97 //===========================================================================
1db1733e 98
99 AliAnalysisTaskFragmentationFunction *task = new AliAnalysisTaskFragmentationFunction(
100 Form("Fragmenation Function %s %s %s %s", branchRecJets.Data(), branchGenJets.Data(), typeJets.Data(), typeTracks.Data()));
101
102 if(debug>=0) task->SetDebugLevel(debug);
6bec8236 103
1db1733e 104 Printf("Rec Jets %s", branchRecJets.Data());
105 Printf("Gen Jets %s", branchGenJets.Data());
106 Printf("Jet Type %s", typeJets.Data());
107 Printf("Track Type %s", typeTracks.Data());
6bec8236 108
1db1733e 109 if(!branchRecJets.Contains("noRecJets")) task->SetBranchRecJets(branchRecJets);
110 if(!branchGenJets.Contains("noGenJets")) task->SetBranchGenJets(branchGenJets);
6bec8236 111
112
1db1733e 113 if(typeTracks.Contains("AODMC2b")) task->SetTrackTypeGen(AliAnalysisTaskFragmentationFunction::kTrackAODMCChargedAcceptance);
114 else if(typeTracks.Contains("AODMC2")) task->SetTrackTypeGen(AliAnalysisTaskFragmentationFunction::kTrackAODMCCharged);
115 else if(typeTracks.Contains("AODMC")) task->SetTrackTypeGen(AliAnalysisTaskFragmentationFunction::kTrackAODMCAll);
116 else if(typeTracks.Contains("KINE2b")) task->SetTrackTypeGen(AliAnalysisTaskFragmentationFunction::kTrackKineChargedAcceptance);
117 else if(typeTracks.Contains("KINE2")) task->SetTrackTypeGen(AliAnalysisTaskFragmentationFunction::kTrackKineCharged);
118 else if(typeTracks.Contains("KINE")) task->SetTrackTypeGen(AliAnalysisTaskFragmentationFunction::kTrackKineAll);
119 else if(typeTracks.Contains("AODb")) task->SetTrackTypeGen(AliAnalysisTaskFragmentationFunction::kTrackAODCuts);
120 else if(typeTracks.Contains("AOD")) task->SetTrackTypeGen(AliAnalysisTaskFragmentationFunction::kTrackAOD);
121 else if(typeTracks.Contains("trackTypeUndef")) task->SetTrackTypeGen(0); // undefined
122 else Printf("trackType %s not found", typeTracks.Data());
123
124 if(typeJets.Contains("AODMCb")) task->SetJetTypeGen(AliAnalysisTaskFragmentationFunction::kJetsGenAcceptance);
125 else if(typeJets.Contains("AODMC")) task->SetJetTypeGen(AliAnalysisTaskFragmentationFunction::kJetsGen);
126 else if(typeJets.Contains("KINEb")) task->SetJetTypeGen(AliAnalysisTaskFragmentationFunction::kJetsKineAcceptance);
127 else if(typeJets.Contains("KINE")) task->SetJetTypeGen(AliAnalysisTaskFragmentationFunction::kJetsKine);
128 else if(typeJets.Contains("AODb")) task->SetJetTypeGen(AliAnalysisTaskFragmentationFunction::kJetsRecAcceptance);
129 else if(typeJets.Contains("AOD")) task->SetJetTypeGen(AliAnalysisTaskFragmentationFunction::kJetsRec);
130 else if(typeJets.Contains("jetTypeUndef")) task->SetJetTypeGen(0); // undefined
131 else Printf("jetType %s not found", typeJets.Data());
132
7d9e8b32 133 if(typeJets.Contains("AODMCb")) task->SetJetTypeRecEff(AliAnalysisTaskFragmentationFunction::kJetsGenAcceptance); // kJetsRecAcceptance
134 else if(typeJets.Contains("AODb")) task->SetJetTypeRecEff(AliAnalysisTaskFragmentationFunction::kJetsRecAcceptance);
135 else task->SetJetTypeRecEff(0);
136
1db1733e 137 task->SetFilterMask(filterMask);
138
f3564520 139 // Set default parameters
140 // Cut selection
1db1733e 141 task->SetTrackCuts(); // default : pt > 0.150 GeV, |eta|<0.9, full phi acc
142 task->SetJetCuts(); // default: jet pt > 5 GeV, |eta|<0.5, full phi acc
f3564520 143 task->SetDiJetCuts(); // default: type of cut = 1 (cut in deltaPhi), deltaPhi = 0., cdf = 0.5, fraction of pt = 0.6
144 task->SetKindSlices(); // default: kindSlice = 1 (inv mass)
1db1733e 145 task->SetFFRadius(); // default: R = 0.4
1db1733e 146 task->SetHighPtThreshold(); // default: pt > 5 Gev
f3564520 147 // Define histo bins
1db1733e 148 task->SetFFHistoBins();
149 task->SetQAJetHistoBins();
150 task->SetQATrackHistoBins();
f3564520 151 task->SetIJHistoBins();
152 task->SetDiJetHistoBins();
153 task->SetQADiJetHistoBins();
1db1733e 154
155 mgr->AddTask(task);
6bec8236 156
6bec8236 157 // Create ONLY the output containers for the data produced by the task.
158 // Get and connect other common input/output containers via the manager as below
159 //==============================================================================
6bec8236 160
1db1733e 161 AliAnalysisDataContainer *coutput_FragFunc = mgr->CreateContainer(
162 Form("fracfunc_%s_%s_%s_%s", branchRecJets.Data(), branchGenJets.Data(), typeTracks.Data(), typeJets.Data()),
163 TList::Class(),
164 AliAnalysisManager::kOutputContainer,
165 Form("%s:PWG4_FragmentationFunction_%s_%s_%s_%s",
166 AliAnalysisManager::GetCommonFileName(), branchRecJets.Data(), branchGenJets. Data(), typeTracks.Data(), typeJets.Data()));
167
168 mgr->ConnectInput (task, 0, mgr->GetCommonInputContainer());
169 mgr->ConnectOutput (task, 0, mgr->GetCommonOutputContainer());
170 mgr->ConnectOutput (task, 1, coutput_FragFunc);
6bec8236 171
1db1733e 172 return task;
6bec8236 173}