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