TENDER becomes Tender
[u/mrichter/AliRoot.git] / PWGPP / TPC / macros / AddTaskPerformanceTPCdEdxQA.C
CommitLineData
6f96924c 1///////////////////////////////////////////////////////////////////////////////
2// Macro to setup AliPerformanceTask for
2bfe5463 3// TPC performance QA to run on PWGPP QA train.
6f96924c 4//
5// Input: ESDs, ESDfriends (optional), Kinematics (optional), TrackRefs (optional)
6// ESD and MC input handlers must be attached to AliAnalysisManager
7// to run default configuration.
8//
9// By default 1 performance components are added to
10// the task:
302b750a 11// 0. AliPerformanceTPC (TPC cluster and track and event information)
12// 1. AliPerformanceMatch (TPC and ITS/TRD matching and TPC eff w.r.t ITS)
13// 2. AliPerformanceMatch (TPC and ITS/TRD matching and TPC eff w.r.t TPC)
14// 3. AliPerformancedEdx (TPC dEdx information)
15// 4. AliPerformanceRes (TPC track resolution w.r.t MC at DCA)
16// 5. AliPerformanceEff (TPC track reconstruction efficiency, MC primaries)
9f5fbaba 17// 6. AliPerformanceMatch (Comparison of TPC constrain and global tracking)
6f96924c 18//
19// Usage on the analysis train (default configuration):
20// gSystem->Load("libANALYSIS");
21// gSystem->Load("libANALYSISalice");
22// gSystem->Load("libTPCcalib.so");
af472fff 23// gSystem->Load("libTender.so");
2bfe5463 24// gSystem->Load("libPWGPP.so");
6f96924c 25//
2bfe5463 26// gROOT->LoadMacro("$ALICE_ROOT/PWGPP/TPC/macros/AddTaskPerformanceTPCdEdxQA.C");
302b750a 27// AliPerformanceTask *tpcQA = AddTaskPerformanceTPCdEdxQA("kFALSE","kTRUE","kFALSE","triggerClass",kFALSE);
6f96924c 28//
29// Output:
30// TPC.Performance.root file with TPC performance components is created.
31//
32// Each of the components contains THnSparse generic histograms which
33// have to be analysed (post-analysis) by using Analyse() function.
34// Each component contains such function.
35//
36//30.09.2010 - J.Otwinowski@gsi.de
302b750a 37//22.09.2011 - jochen@thaeder.de - Updated
6f96924c 38///////////////////////////////////////////////////////////////////////////////
39
40//____________________________________________
302b750a 41AliPerformanceTask* AddTaskPerformanceTPCdEdxQA(Bool_t bUseMCInfo=kFALSE, Bool_t bUseESDfriend=kTRUE,
42 Bool_t highMult = kFALSE, const char *triggerClass=0,
e95d4942 43 Bool_t bUseHLT = kFALSE, Bool_t bUseTOF = kFALSE, Bool_t bTPCOnly = kFALSE,
44 Bool_t bDoEffTpcSec = kFALSE)
6f96924c 45{
302b750a 46 Char_t *taskName[] = {"TPC", "HLT"};
47 Int_t idx = 0;
48 if (bUseHLT) idx = 1;
49
6f96924c 50 //
51 // Add AliPerformanceTask with TPC performance components
52 //
53 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
54 if(!mgr) {
55 Error("AddTaskPerformanceTPCdEdxQA","AliAnalysisManager not set!");
56 return NULL;
57 }
58
59 TString type = mgr->GetInputEventHandler()->GetDataType();
60 if (!type.Contains("ESD")) {
61 Error("AddTaskPerformanceTPCdEdxQA", "ESD input handler needed!");
62 return NULL;
63 }
64
65 AliMCEventHandler *mcH = (AliMCEventHandler*)mgr->GetMCtruthEventHandler();
66 if (!mcH && bUseMCInfo) {
67 Error("AddTaskPerformanceTPCdEdxQA", "MC input handler needed!");
68 return NULL;
69 }
70
71 //
302b750a 72 // Add HLT Event
73 //
74 if (bUseHLT) {
75 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*>(mgr->GetInputEventHandler());
76 esdH->SetReadHLT();
77 }
78
79 //
6f96924c 80 // Create task
81 //
302b750a 82 AliPerformanceTask *task = new AliPerformanceTask("PerformanceQA",Form("%s Performance",taskName[idx]));
6f96924c 83 if (!task) {
302b750a 84 Error("AddTaskPerformanceTPCdEdxQA", Form("%s performance task cannot be created!",taskName[idx]));
6f96924c 85 return NULL;
86 }
87 task->SetUseMCInfo(bUseMCInfo);
88 task->SetUseESDfriend(bUseESDfriend);
1833a193 89 // task->SetUseTerminate(kFALSE);
302b750a 90 task->SetUseHLT(bUseHLT);
6f96924c 91
92 //
93 // Add task to analysis manager
94 //
95 mgr->AddTask(task);
96
97 //
98 // Create TPC-ESD track reconstruction cuts
99 // MB tracks
100 //
101 AliRecInfoCuts *pRecInfoCutsTPC = new AliRecInfoCuts();
102 if(pRecInfoCutsTPC) {
103 pRecInfoCutsTPC->SetMaxDCAToVertexXY(3.0);
104 pRecInfoCutsTPC->SetMaxDCAToVertexZ(3.0);
105 pRecInfoCutsTPC->SetRequireSigmaToVertex(kFALSE);
106 pRecInfoCutsTPC->SetRequireTPCRefit(kFALSE);
1833a193 107 pRecInfoCutsTPC->SetAcceptKinkDaughters(kFALSE);
6f96924c 108 pRecInfoCutsTPC->SetMinNClustersTPC(70);
1833a193 109 pRecInfoCutsTPC->SetMaxChi2PerClusterTPC(4.);
110 pRecInfoCutsTPC->SetDCAToVertex2D(kTRUE);
6f96924c 111
112 pRecInfoCutsTPC->SetHistogramsOn(kFALSE);
113 }
114 else {
302b750a 115 Error("AddTaskPerformanceTPCdEdxQA", "AliRecInfoCutsTPC cannot be created!");
6f96924c 116 return NULL;
117 }
118
119 //
120 // Create TPC-MC track reconstruction cuts
121 //
122 AliMCInfoCuts *pMCInfoCuts = new AliMCInfoCuts();
123 if(pMCInfoCuts) {
124 pMCInfoCuts->SetMinTrackLength(70);
125 }
126 else {
302b750a 127 Error("AddTaskPerformanceTPCdEdxQA", "AliMCInfoCuts cannot be created!");
6f96924c 128 return NULL;
129 }
130
131 //
132 // Create performance objects for TPC and set cuts
133 //
134 enum { kTPC = 0, kTPCITS, kConstrained, kTPCInner, kTPCOuter, kTPCSec };
135
136 //
137 // TPC performance
138 //
c11cd0fa 139 AliPerformanceTPC *pCompTPC0 = new AliPerformanceTPC("AliPerformanceTPC","AliPerformanceTPC",kTPC,kFALSE,-1,highMult);
6f96924c 140 if(!pCompTPC0) {
302b750a 141 Error("AddTaskPerformanceTPCdEdxQA", "Cannot create AliPerformanceTPC");
6f96924c 142 }
143 pCompTPC0->SetAliRecInfoCuts(pRecInfoCutsTPC);
144 pCompTPC0->SetAliMCInfoCuts(pMCInfoCuts);
1833a193 145 // pCompTPC0->SetUseTrackVertex(kFALSE);
146 pCompTPC0->SetUseTrackVertex(kTRUE);
302b750a 147 pCompTPC0->SetUseHLT(bUseHLT);
9f5fbaba 148 pCompTPC0->SetUseTOFBunchCrossing(bUseTOF);
1833a193 149
150 //
151 // TPC ITS match
152 //
153 AliPerformanceMatch *pCompMatch1 = new AliPerformanceMatch("AliPerformanceMatchTPCITS","AliPerformanceMatchTPCITS",0,kFALSE);
154 if(!pCompMatch1) {
302b750a 155 Error("AddTaskPerformanceTPCdEdxQA", "Cannot create AliPerformanceMatchTPCITS");
1833a193 156 }
157 pCompMatch1->SetAliRecInfoCuts(pRecInfoCutsTPC);
158 pCompMatch1->SetAliMCInfoCuts(pMCInfoCuts);
9f5fbaba 159 pCompMatch1->SetUseTOFBunchCrossing(bUseTOF);
1833a193 160
161
162 //
163 // ITS TPC match
164 //
165 AliPerformanceMatch *pCompMatch2 = new AliPerformanceMatch("AliPerformanceMatchITSTPC","AliPerformanceMatchITSTPC",1,kFALSE);
166 if(!pCompMatch2) {
302b750a 167 Error("AddTaskPerformanceTPCdEdxQA", "Cannot create AliPerformanceMatchITSTPC"); }
1833a193 168 pCompMatch2->SetAliRecInfoCuts(pRecInfoCutsTPC);
169 pCompMatch2->SetAliMCInfoCuts(pMCInfoCuts);
9f5fbaba 170 pCompMatch2->SetUseTOFBunchCrossing(bUseTOF);
1833a193 171
6f96924c 172 //
173 // dEdx
174 //
175 AliPerformanceDEdx *pCompDEdx3 = new AliPerformanceDEdx("AliPerformanceDEdxTPCInner","AliPerformanceDEdxTPCInner",kTPCInner,kFALSE);
176 if(!pCompDEdx3) {
302b750a 177 Error("AddTaskPerformanceTPCdEdxQA", "Cannot create AliPerformanceDEdxTPCInner");
6f96924c 178 }
179 pCompDEdx3->SetAliRecInfoCuts(pRecInfoCutsTPC);
180 pCompDEdx3->SetAliMCInfoCuts(pMCInfoCuts);
1833a193 181 //pCompDEdx3->SetUseTrackVertex(kFALSE);
182 pCompDEdx3->SetUseTrackVertex(kTRUE);
6f96924c 183
302b750a 184 //
185 // Resolution ------------------------------------------------------------------------------------
186 //
187
188 AliPerformanceRes *pCompRes4 = new AliPerformanceRes("AliPerformanceRes",
e95d4942 189 "AliPerformanceRes", bTPCOnly == kTRUE ? kTPCInner : kTPC,kFALSE);
302b750a 190 if(!pCompRes4) {
191 Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceRes");
192 }
193
194
195 pCompRes4->SetAliRecInfoCuts(pRecInfoCutsTPC);
196 pCompRes4->SetAliMCInfoCuts(pMCInfoCuts);
e95d4942 197 pCompRes4->SetUseTrackVertex(bTPCOnly == kTRUE ? kFALSE : kTRUE);
302b750a 198
199 //
200 // Efficiency ------------------------------------------------------------------------------------
201 //
202
203 AliPerformanceEff *pCompEff5 = new AliPerformanceEff("AliPerformanceEff",
204 "AliPerformanceEff",kTPC,kFALSE);
205 if(!pCompEff5) {
206 Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceEff");
207 }
208
209 pCompEff5->SetAliRecInfoCuts(pRecInfoCutsTPC);
210 pCompEff5->SetAliMCInfoCuts(pMCInfoCuts);
e95d4942 211 pCompEff5->SetUseTrackVertex(bTPCOnly == kTRUE ? kFALSE : kTRUE);
212
213 AliPerformanceEff *pCompEff5Sec;
214 if (bDoEffTpcSec)
215 {
216 pCompEff5Sec = new AliPerformanceEff("AliPerformanceEffSec",
217 "AliPerformanceEffSec",kTPCSec,kFALSE);
218 if(!pCompEff5Sec) {
219 Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceEff");
220 }
221
222 pCompEff5Sec->SetAliRecInfoCuts(pRecInfoCutsTPC);
223 pCompEff5Sec->SetAliMCInfoCuts(pMCInfoCuts);
224 pCompEff5Sec->SetUseTrackVertex(bTPCOnly == kTRUE ? kFALSE : kTRUE);
225 }
302b750a 226
9f5fbaba 227 //
228 // TPC Constrain to vertex
229 //
230 AliPerformanceMatch *pCompConstrain6 = new AliPerformanceMatch("AliPerformanceMatchTPCConstrain","AliPerformanceMatchTPCConstrain",2,kFALSE);
231 if(!pCompConstrain6) {
232 Error("AddTaskPerformanceTPCdEdxQA", "Cannot create AliPerformanceMatchTPCConstrain"); }
233 pCompConstrain6->SetAliRecInfoCuts(pRecInfoCutsTPC);
234 pCompConstrain6->SetAliMCInfoCuts(pMCInfoCuts);
235 pCompConstrain6->SetUseTOFBunchCrossing(bUseTOF);
236
302b750a 237
6f96924c 238
239 //
240 // Add components to the performance task
241 //
242 if(!bUseMCInfo) {
243 pCompTPC0->SetTriggerClass(triggerClass);
1833a193 244 pCompMatch1->SetTriggerClass(triggerClass);
245 pCompMatch2->SetTriggerClass(triggerClass);
6f96924c 246 pCompDEdx3->SetTriggerClass(triggerClass);
9f5fbaba 247 pCompConstrain6->SetTriggerClass(triggerClass);
6f96924c 248 }
249 task->AddPerformanceObject( pCompTPC0 );
1833a193 250 task->AddPerformanceObject( pCompMatch1 );
251 task->AddPerformanceObject( pCompMatch2 );
6f96924c 252 task->AddPerformanceObject( pCompDEdx3 );
9f5fbaba 253 task->AddPerformanceObject( pCompConstrain6 );
302b750a 254 if(bUseMCInfo) {
e95d4942 255 task->AddPerformanceObject( pCompRes4 );
302b750a 256 task->AddPerformanceObject( pCompEff5 );
e95d4942 257 if (bDoEffTpcSec) task->AddPerformanceObject( pCompEff5Sec );
302b750a 258 }
6f96924c 259
260 //
261 // Create containers for input
262 //
263 mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
264
265 //
266 // Create containers for output
267 //
302b750a 268
269 AliAnalysisDataContainer *coutput = mgr->CreateContainer(Form("%sQA", taskName[idx]), TList::Class(),
270 AliAnalysisManager::kOutputContainer,
271 Form("%s:%s_%s", mgr->GetCommonFileName(), taskName[idx],task->GetName()));
814d192f 272
814d192f 273
302b750a 274 AliAnalysisDataContainer *coutput2 = mgr->CreateContainer(Form("%sQASummary", taskName[idx]), TTree::Class(),
275 AliAnalysisManager::kParamContainer,
276 Form("trending.root:Summary%sQA", taskName[idx]));
277
278 mgr->ConnectOutput(task, 1, coutput);
279 mgr->ConnectOutput(task, 0, coutput2);
6f96924c 280
281return task;
282}