Fix bining
[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");
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,
9f5fbaba 43 Bool_t bUseHLT = kFALSE, Bool_t bUseTOF = kFALSE)
6f96924c 44{
302b750a 45 Char_t *taskName[] = {"TPC", "HLT"};
46 Int_t idx = 0;
47 if (bUseHLT) idx = 1;
48
6f96924c 49 //
50 // Add AliPerformanceTask with TPC performance components
51 //
52 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
53 if(!mgr) {
54 Error("AddTaskPerformanceTPCdEdxQA","AliAnalysisManager not set!");
55 return NULL;
56 }
57
58 TString type = mgr->GetInputEventHandler()->GetDataType();
59 if (!type.Contains("ESD")) {
60 Error("AddTaskPerformanceTPCdEdxQA", "ESD input handler needed!");
61 return NULL;
62 }
63
64 AliMCEventHandler *mcH = (AliMCEventHandler*)mgr->GetMCtruthEventHandler();
65 if (!mcH && bUseMCInfo) {
66 Error("AddTaskPerformanceTPCdEdxQA", "MC input handler needed!");
67 return NULL;
68 }
69
70 //
302b750a 71 // Add HLT Event
72 //
73 if (bUseHLT) {
74 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*>(mgr->GetInputEventHandler());
75 esdH->SetReadHLT();
76 }
77
78 //
6f96924c 79 // Create task
80 //
302b750a 81 AliPerformanceTask *task = new AliPerformanceTask("PerformanceQA",Form("%s Performance",taskName[idx]));
6f96924c 82 if (!task) {
302b750a 83 Error("AddTaskPerformanceTPCdEdxQA", Form("%s performance task cannot be created!",taskName[idx]));
6f96924c 84 return NULL;
85 }
86 task->SetUseMCInfo(bUseMCInfo);
87 task->SetUseESDfriend(bUseESDfriend);
1833a193 88 // task->SetUseTerminate(kFALSE);
302b750a 89 task->SetUseHLT(bUseHLT);
6f96924c 90
91 //
92 // Add task to analysis manager
93 //
94 mgr->AddTask(task);
95
96 //
97 // Create TPC-ESD track reconstruction cuts
98 // MB tracks
99 //
100 AliRecInfoCuts *pRecInfoCutsTPC = new AliRecInfoCuts();
101 if(pRecInfoCutsTPC) {
102 pRecInfoCutsTPC->SetMaxDCAToVertexXY(3.0);
103 pRecInfoCutsTPC->SetMaxDCAToVertexZ(3.0);
104 pRecInfoCutsTPC->SetRequireSigmaToVertex(kFALSE);
105 pRecInfoCutsTPC->SetRequireTPCRefit(kFALSE);
1833a193 106 pRecInfoCutsTPC->SetAcceptKinkDaughters(kFALSE);
6f96924c 107 pRecInfoCutsTPC->SetMinNClustersTPC(70);
1833a193 108 pRecInfoCutsTPC->SetMaxChi2PerClusterTPC(4.);
109 pRecInfoCutsTPC->SetDCAToVertex2D(kTRUE);
6f96924c 110
111 pRecInfoCutsTPC->SetHistogramsOn(kFALSE);
112 }
113 else {
302b750a 114 Error("AddTaskPerformanceTPCdEdxQA", "AliRecInfoCutsTPC cannot be created!");
6f96924c 115 return NULL;
116 }
117
118 //
119 // Create TPC-MC track reconstruction cuts
120 //
121 AliMCInfoCuts *pMCInfoCuts = new AliMCInfoCuts();
122 if(pMCInfoCuts) {
123 pMCInfoCuts->SetMinTrackLength(70);
124 }
125 else {
302b750a 126 Error("AddTaskPerformanceTPCdEdxQA", "AliMCInfoCuts cannot be created!");
6f96924c 127 return NULL;
128 }
129
130 //
131 // Create performance objects for TPC and set cuts
132 //
133 enum { kTPC = 0, kTPCITS, kConstrained, kTPCInner, kTPCOuter, kTPCSec };
134
135 //
136 // TPC performance
137 //
c11cd0fa 138 AliPerformanceTPC *pCompTPC0 = new AliPerformanceTPC("AliPerformanceTPC","AliPerformanceTPC",kTPC,kFALSE,-1,highMult);
6f96924c 139 if(!pCompTPC0) {
302b750a 140 Error("AddTaskPerformanceTPCdEdxQA", "Cannot create AliPerformanceTPC");
6f96924c 141 }
142 pCompTPC0->SetAliRecInfoCuts(pRecInfoCutsTPC);
143 pCompTPC0->SetAliMCInfoCuts(pMCInfoCuts);
1833a193 144 // pCompTPC0->SetUseTrackVertex(kFALSE);
145 pCompTPC0->SetUseTrackVertex(kTRUE);
302b750a 146 pCompTPC0->SetUseHLT(bUseHLT);
9f5fbaba 147 pCompTPC0->SetUseTOFBunchCrossing(bUseTOF);
1833a193 148
149 //
150 // TPC ITS match
151 //
152 AliPerformanceMatch *pCompMatch1 = new AliPerformanceMatch("AliPerformanceMatchTPCITS","AliPerformanceMatchTPCITS",0,kFALSE);
153 if(!pCompMatch1) {
302b750a 154 Error("AddTaskPerformanceTPCdEdxQA", "Cannot create AliPerformanceMatchTPCITS");
1833a193 155 }
156 pCompMatch1->SetAliRecInfoCuts(pRecInfoCutsTPC);
157 pCompMatch1->SetAliMCInfoCuts(pMCInfoCuts);
9f5fbaba 158 pCompMatch1->SetUseTOFBunchCrossing(bUseTOF);
1833a193 159
160
161 //
162 // ITS TPC match
163 //
164 AliPerformanceMatch *pCompMatch2 = new AliPerformanceMatch("AliPerformanceMatchITSTPC","AliPerformanceMatchITSTPC",1,kFALSE);
165 if(!pCompMatch2) {
302b750a 166 Error("AddTaskPerformanceTPCdEdxQA", "Cannot create AliPerformanceMatchITSTPC"); }
1833a193 167 pCompMatch2->SetAliRecInfoCuts(pRecInfoCutsTPC);
168 pCompMatch2->SetAliMCInfoCuts(pMCInfoCuts);
9f5fbaba 169 pCompMatch2->SetUseTOFBunchCrossing(bUseTOF);
1833a193 170
6f96924c 171 //
172 // dEdx
173 //
174 AliPerformanceDEdx *pCompDEdx3 = new AliPerformanceDEdx("AliPerformanceDEdxTPCInner","AliPerformanceDEdxTPCInner",kTPCInner,kFALSE);
175 if(!pCompDEdx3) {
302b750a 176 Error("AddTaskPerformanceTPCdEdxQA", "Cannot create AliPerformanceDEdxTPCInner");
6f96924c 177 }
178 pCompDEdx3->SetAliRecInfoCuts(pRecInfoCutsTPC);
179 pCompDEdx3->SetAliMCInfoCuts(pMCInfoCuts);
1833a193 180 //pCompDEdx3->SetUseTrackVertex(kFALSE);
181 pCompDEdx3->SetUseTrackVertex(kTRUE);
6f96924c 182
302b750a 183 //
184 // Resolution ------------------------------------------------------------------------------------
185 //
186
187 AliPerformanceRes *pCompRes4 = new AliPerformanceRes("AliPerformanceRes",
188 "AliPerformanceRes",kTPC,kFALSE);
189 if(!pCompRes4) {
190 Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceRes");
191 }
192
193
194 pCompRes4->SetAliRecInfoCuts(pRecInfoCutsTPC);
195 pCompRes4->SetAliMCInfoCuts(pMCInfoCuts);
196 pCompRes4->SetUseTrackVertex(kTRUE);
197
198 //
199 // Efficiency ------------------------------------------------------------------------------------
200 //
201
202 AliPerformanceEff *pCompEff5 = new AliPerformanceEff("AliPerformanceEff",
203 "AliPerformanceEff",kTPC,kFALSE);
204 if(!pCompEff5) {
205 Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceEff");
206 }
207
208 pCompEff5->SetAliRecInfoCuts(pRecInfoCutsTPC);
209 pCompEff5->SetAliMCInfoCuts(pMCInfoCuts);
210 pCompEff5->SetUseTrackVertex(kTRUE);
211
9f5fbaba 212 //
213 // TPC Constrain to vertex
214 //
215 AliPerformanceMatch *pCompConstrain6 = new AliPerformanceMatch("AliPerformanceMatchTPCConstrain","AliPerformanceMatchTPCConstrain",2,kFALSE);
216 if(!pCompConstrain6) {
217 Error("AddTaskPerformanceTPCdEdxQA", "Cannot create AliPerformanceMatchTPCConstrain"); }
218 pCompConstrain6->SetAliRecInfoCuts(pRecInfoCutsTPC);
219 pCompConstrain6->SetAliMCInfoCuts(pMCInfoCuts);
220 pCompConstrain6->SetUseTOFBunchCrossing(bUseTOF);
221
302b750a 222
6f96924c 223
224 //
225 // Add components to the performance task
226 //
227 if(!bUseMCInfo) {
228 pCompTPC0->SetTriggerClass(triggerClass);
1833a193 229 pCompMatch1->SetTriggerClass(triggerClass);
230 pCompMatch2->SetTriggerClass(triggerClass);
6f96924c 231 pCompDEdx3->SetTriggerClass(triggerClass);
9f5fbaba 232 pCompConstrain6->SetTriggerClass(triggerClass);
6f96924c 233 }
234 task->AddPerformanceObject( pCompTPC0 );
1833a193 235 task->AddPerformanceObject( pCompMatch1 );
236 task->AddPerformanceObject( pCompMatch2 );
6f96924c 237 task->AddPerformanceObject( pCompDEdx3 );
9f5fbaba 238 task->AddPerformanceObject( pCompConstrain6 );
302b750a 239 if(bUseMCInfo) {
eccc4f1c 240 //task->AddPerformanceObject( pCompRes4 );
302b750a 241 task->AddPerformanceObject( pCompEff5 );
242 }
6f96924c 243
244 //
245 // Create containers for input
246 //
247 mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
248
249 //
250 // Create containers for output
251 //
302b750a 252
253 AliAnalysisDataContainer *coutput = mgr->CreateContainer(Form("%sQA", taskName[idx]), TList::Class(),
254 AliAnalysisManager::kOutputContainer,
255 Form("%s:%s_%s", mgr->GetCommonFileName(), taskName[idx],task->GetName()));
814d192f 256
814d192f 257
302b750a 258 AliAnalysisDataContainer *coutput2 = mgr->CreateContainer(Form("%sQASummary", taskName[idx]), TTree::Class(),
259 AliAnalysisManager::kParamContainer,
260 Form("trending.root:Summary%sQA", taskName[idx]));
261
262 mgr->ConnectOutput(task, 1, coutput);
263 mgr->ConnectOutput(task, 0, coutput2);
6f96924c 264
265return task;
266}