Undoing some unwanted method renames
[u/mrichter/AliRoot.git] / PWGJE / macros / AddTaskIDFFTCF.C
CommitLineData
7f0c28ff
ML
1
2/*************************************************************************************************
3*** Add Fragmentation Function Task ***
4**************************************************************************************************
5The fragmentation 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
26AliAnalysisTaskIDFFTCF *AddTaskIDFFTCF(
27 const char* recJetsBranch,
28 const char* recJetsBackBranch,
29 const char* genJetsBranch,
30 const char* jetType,
31 const char* trackType,
32 UInt_t filterMask,
33 Float_t radius,
34 int kBackgroundMode,
35 Int_t PtTrackMin,
36 Int_t TPCCutMode,
37 Int_t TOFCutMode,
38 Int_t eventClass=0,
39 TString BrOpt="",
40 TString BrOpt2="",
41 TString BrOpt3="",
42 Float_t radiusBckg=0.4,
43 Int_t FFMaxTrackPt = -1,
44 Int_t FFMinNTracks = 0,
45 UInt_t filterMaskTracks = 0,
46 Bool_t useLeading = kFALSE)
47{
48 // Creates a fragmentation function task,
49 // configures it and adds it to the analysis manager.
50
51 //******************************************************************************
52 //*** Configuration Parameter **************************************************
53 //******************************************************************************
54
55 // space for configuration parameter: histo bin, cuts, ...
56 // so far only default parameter used
57
58 Int_t debug = -1; // debug level, -1: not set here
59
60 //******************************************************************************
61
62
63 // Get the pointer to the existing analysis manager via the static access method.
64 //==============================================================================
65 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
66 if (!mgr) {
67 ::Error("AddTaskFragmentationFunctionNew", "No analysis manager to connect to.");
68 return NULL;
69 }
70
71 // Check the analysis type using the event handlers connected to the analysis manager.
72 //==============================================================================
73 if (!mgr->GetInputEventHandler()) {
74 ::Error("AddTaskFragmentationFunctionNew", "This task requires an input event handler");
75 return NULL;
76 }
77
78 TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
79 Printf("Data Type: %s", type.Data());
80
81 TString branchRecBackJets(recJetsBackBranch);
82 TString branchRecJets(recJetsBranch);
83 TString branchGenJets(genJetsBranch);
84 TString typeJets(jetType);
85 TString typeTracks(trackType);
86
87 if(branchRecBackJets.Length()==0) branchRecBackJets = "noRecBackJets";
88 if(branchRecJets.Length()==0) branchRecJets = "noRecJets";
89 if(branchGenJets.Length()==0) branchGenJets = "noGenJets";
90 if(typeTracks.Length()==0) typeTracks = "trackTypeUndef";
91 if(typeJets.Length()==0) typeJets = "jetTypeUndef";
92
93 // Create the task and configure it.
94 //===========================================================================
95
96 AliAnalysisTaskIDFFTCF *task = new AliAnalysisTaskIDFFTCF(
97 Form("IFFFTCF %s %s %s %s", branchRecJets.Data(), branchGenJets.Data(), typeJets.Data(), typeTracks.Data()));
98
99 if(debug>=0) task->SetDebugLevel(debug);
100
101 task->SetTPCCutMode(TPCCutMode);
102 task->SetTOFCutMode(TOFCutMode);
103
104 Printf("Rec Jets %s", branchRecJets.Data());
105 Printf("Back Rec Jets %s", branchRecBackJets.Data());
106 Printf("Gen Jets %s", branchGenJets.Data());
107 Printf("Jet Type %s", typeJets.Data());
108 Printf("Track Type %s", typeTracks.Data());
109
110 // attach the filter mask and options
111 TString cAdd = "";
112 cAdd += Form("%02d",(int)((TMath::Abs(radius)+0.01)*10.));
113 cAdd += Form("_B%d",(int)((kBackgroundMode)));
114 cAdd += Form("_Filter%05d",filterMask);
115 cAdd += Form("_Cut%05d",PtTrackMin);
116 cAdd += Form("%s",BrOpt.Data());
117 cAdd += Form("%s",BrOpt2.Data());
118
119 Printf("%s",cAdd.Data());
120
121 TString cAddb = "";
122 cAddb += Form("%02d",(int)((radiusBckg+0.01)*10.));
123 cAddb += Form("_B%d",(int)((kBackgroundMode)));
124 cAddb += Form("_Filter%05d",filterMask);
125 cAddb += Form("_Cut%05d",PtTrackMin);
126 cAddb += Form("%s",BrOpt.Data());
127 cAddb += Form("%s",BrOpt2.Data());
128
129 Printf("%s",cAddb.Data());
130
131 TString cAddmc = "";
132 cAddmc += Form("%02d",(int)((TMath::Abs(radius)+0.01)*10.));
133 cAddmc += Form("_B%d",(int)((kBackgroundMode)));
134 cAddmc += Form("_Filter%05d",filterMask);
135 cAddmc += Form("_Cut%05d",PtTrackMin);
136 cAddmc += Form("%s",BrOpt3.Data());
137
138 Printf("%s",cAddmc.Data());
139
140
141 if(branchRecJets.Contains("AOD")&&branchRecJets.Contains("jets")&&!branchRecJets.Contains("MC"))branchRecJets = branchRecJets + cAdd;
142 if(branchRecJets.Contains("AOD")&&branchRecJets.Contains("cluster")&&!branchRecJets.Contains("MC"))branchRecJets = branchRecJets + cAdd;
143
144 if(branchRecBackJets.Contains("back")&&branchRecBackJets.Contains("cluster")&&!branchRecBackJets.Contains("MC"))branchRecBackJets = branchRecBackJets + cAddb;
145
146 if(branchGenJets.Contains("AOD")&&branchGenJets.Contains("MC"))branchGenJets = branchGenJets + cAddmc;
147
148 Printf("Gen jets branch %s: ", branchGenJets.Data());
149 Printf("Rec jets branch %s: ", branchRecJets.Data());
150 Printf("Jet backg branch %s: ", branchRecBackJets.Data());
151
152 if(!branchRecJets.Contains("noRecJets")) task->SetBranchRecJets(branchRecJets);
153 if(!branchRecBackJets.Contains("noRecBackJets")) task->SetBranchRecBackJets(branchRecBackJets);
154 if(!branchGenJets.Contains("noGenJets")) task->SetBranchGenJets(branchGenJets);
155
156
157 if(typeTracks.Contains("AODMC2b")) task->SetTrackTypeGen(AliAnalysisTaskIDFFTCF::kTrackAODMCChargedAcceptance);
158 else if(typeTracks.Contains("AODMC2")) task->SetTrackTypeGen(AliAnalysisTaskIDFFTCF::kTrackAODMCCharged);
159 else if(typeTracks.Contains("AODMC")) task->SetTrackTypeGen(AliAnalysisTaskIDFFTCF::kTrackAODMCAll);
160 else if(typeTracks.Contains("KINE2b")) task->SetTrackTypeGen(AliAnalysisTaskIDFFTCF::kTrackKineChargedAcceptance);
161 else if(typeTracks.Contains("KINE2")) task->SetTrackTypeGen(AliAnalysisTaskIDFFTCF::kTrackKineCharged);
162 else if(typeTracks.Contains("KINE")) task->SetTrackTypeGen(AliAnalysisTaskIDFFTCF::kTrackKineAll);
163 else if(typeTracks.Contains("AODb")) task->SetTrackTypeGen(AliAnalysisTaskIDFFTCF::kTrackAODCuts);
164 else if(typeTracks.Contains("AOD")) task->SetTrackTypeGen(AliAnalysisTaskIDFFTCF::kTrackAOD);
165 else if(typeTracks.Contains("trackTypeUndef")) task->SetTrackTypeGen(0); // undefined
166 else Printf("trackType %s not found", typeTracks.Data());
167
168 if(typeJets.Contains("AODMCb")) task->SetJetTypeGen(AliAnalysisTaskIDFFTCF::kJetsGenAcceptance);
169 else if(typeJets.Contains("AODMC")) task->SetJetTypeGen(AliAnalysisTaskIDFFTCF::kJetsGen);
170 else if(typeJets.Contains("KINEb")) task->SetJetTypeGen(AliAnalysisTaskIDFFTCF::kJetsKineAcceptance);
171 else if(typeJets.Contains("KINE")) task->SetJetTypeGen(AliAnalysisTaskIDFFTCF::kJetsKine);
172 else if(typeJets.Contains("AODb")) task->SetJetTypeGen(AliAnalysisTaskIDFFTCF::kJetsRecAcceptance);
173 else if(typeJets.Contains("AOD")) task->SetJetTypeGen(AliAnalysisTaskIDFFTCF::kJetsRec);
174 else if(typeJets.Contains("jetTypeUndef")) task->SetJetTypeGen(0); // undefined
175 else Printf("jetType %s not found", typeJets.Data());
176
177 if(typeJets.Contains("AODMCb")) task->SetJetTypeRecEff(AliAnalysisTaskIDFFTCF::kJetsGenAcceptance); // kJetsRecAcceptance
178 else if(typeJets.Contains("AODb")) task->SetJetTypeRecEff(AliAnalysisTaskIDFFTCF::kJetsRecAcceptance);
179 else task->SetJetTypeRecEff(0);
180
181 if(!filterMaskTracks) task->SetFilterMask(filterMask);
182 else task->SetFilterMask(filterMaskTracks);
183
184 task->SetEventSelectionMask(AliVEvent::kMB);
185 task->SetEventClass(eventClass);
186
187 // Set default parameters
188 // Cut selection
189
190 if(PtTrackMin == 150) task->SetTrackCuts(); // default : pt > 0.150 GeV, |eta|<0.9, full phi acc
191 else if(PtTrackMin == 1000) task->SetTrackCuts(1.0, -0.9, 0.9, 0., 2*TMath::Pi());
192 else if(PtTrackMin == 2000) task->SetTrackCuts(2.0, -0.9, 0.9, 0., 2*TMath::Pi());
193 else task->SetTrackCuts(0.001*PtTrackMin,-0.9, 0.9, 0., 2*TMath::Pi());
194
195
196 task->SetJetCuts(); // default: jet pt > 5 GeV, |eta|<0.5, full phi acc
197 task->SetFFRadius(radius);
198 task->SetQAMode(); // default: qaMode = 3
199 task->SetFFMode(); // default: ffMode = 1
200 task->SetEffMode(0); // default: effMode = 1
201 task->SetHighPtThreshold(); // default: pt > 5 Gev
202
203 // Define histo bins
204 task->SetFFHistoBins(23, 5, 120, 480, 0., 120.,70, 0., 7., 52, 0., 1.3);
205
206 task->SetQAJetHistoBins();
207 task->SetQATrackHistoBins();
208
209 if(FFMaxTrackPt>0) task->SetFFMaxTrackPt(FFMaxTrackPt);
210 if(FFMinNTracks>0) task->SetFFMinNTracks(FFMinNTracks);
211 if(useLeading) task->UseLeadingJet(kTRUE);
212
213 mgr->AddTask(task);
214
215 // Create ONLY the output containers for the data produced by the task.
216 // Get and connect other common input/output containers via the manager as below
217 //==============================================================================
218
219 TString strList(Form("fracfunc_%s_%s_%s_%s_tpc%d_tof%d_cl%d", branchRecJets.Data(), branchGenJets.Data(), typeTracks.Data(), typeJets.Data(), TPCCutMode, TOFCutMode, eventClass));
220
221 TString strDir(Form("%s:PWGJE_FragmentationFunction_%s_%s_%s_%s_tpc%d_tof%d_cl%d",
222 AliAnalysisManager::GetCommonFileName(), branchRecJets.Data(), branchGenJets. Data(),
223 typeTracks.Data(), typeJets.Data(), TPCCutMode, TOFCutMode, eventClass));
224
225
226
227 if(FFMaxTrackPt>0){
228 strList += Form("_FFMaxPt%d", FFMaxTrackPt);
229 strDir += Form("_FFMaxPt%d", FFMaxTrackPt);
230 }
231 if(FFMinNTracks>0){
232 strList += Form("_minNTr%d",FFMinNTracks);
233 strDir += Form("_minNTr%d",FFMinNTracks);
234 }
235
236 if(radius<0){
237 strList += "_trackRefs";
238 strDir += "_trackRefs";
239 }
240 if(filterMaskTracks){
241 strList += Form("_TrackFilter%05d",filterMaskTracks);
242 strDir += Form("_TrackFilter%05d",filterMaskTracks);
243 }
244 if(useLeading){
245 strList += "_lJet";
246 strDir += "_lJet";
247 }
248
249
250 AliAnalysisDataContainer *coutput_FragFunc = mgr->CreateContainer(strList,TList::Class(),
251 AliAnalysisManager::kOutputContainer,
252 strDir);
253
254 mgr->ConnectInput (task, 0, mgr->GetCommonInputContainer());
255 //mgr->ConnectOutput (task, 0, mgr->GetCommonOutputContainer()); // OB
256 mgr->ConnectOutput (task, 1, coutput_FragFunc);
257
258 if(AliAnalysisTaskIDFFTCF::fkDump){
259 AliAnalysisDataContainer *dtree = mgr->CreateContainer(strList+"_tree", TTree::Class(), AliAnalysisManager::kOutputContainer, strDir);
260 mgr->ConnectOutput (task, 2, dtree);
261 }
262
263 printf("======================= TPCCutMode %d ----------- TOFCutMode %d\n", task->GetTPCCutMode(), task->GetTOFCutMode());
264
265 return task;
266}