]>
Commit | Line | Data |
---|---|---|
7cc34f08 | 1 | /**************************************************************************\r |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r | |
3 | * *\r | |
4 | * Author: The ALICE Off-line Project. *\r | |
5 | * Contributors are mentioned in the code where appropriate. *\r | |
6 | * *\r | |
7 | * Permission to use, copy, modify and distribute this software and its *\r | |
8 | * documentation strictly for non-commercial purposes is hereby granted *\r | |
9 | * without fee, provided that the above copyright notice appears in all *\r | |
10 | * copies and that both the copyright notice and this permission notice *\r | |
11 | * appear in the supporting documentation. The authors make no claims *\r | |
12 | * about the suitability of this software for any purpose. It is *\r | |
13 | * provided "as is" without express or implied warranty. *\r | |
14 | **************************************************************************/\r | |
15 | \r | |
16 | //------------------------------------------------------------------------------\r | |
17 | // Implementation of the AliPerformanceTask class. It checks reconstruction performance \r | |
18 | // for the reconstructed vs MC particle tracks under several conditions. For real data \r | |
19 | // the control QA histograms are filled.\r | |
20 | //\r | |
21 | // The comparison output objects deriving from AliPerformanceObject \r | |
22 | // (e.g. AliPerformanceRes, AliPerformanceEff, AliPerformanceDEdx, AliPerformanceDCA ...) \r | |
23 | // are stored in the output file (details in description of these classes).\r | |
24 | // \r | |
25 | // Author: J.Otwinowski 01/04/2009 \r | |
814d192f | 26 | // Changes by M.Knichel 15/10/2010\r |
7cc34f08 | 27 | //------------------------------------------------------------------------------\r |
28 | \r | |
29 | #include "iostream"\r | |
30 | \r | |
31 | #include "TChain.h"\r | |
32 | #include "TTree.h"\r | |
33 | #include "TH1F.h"\r | |
34 | #include "TCanvas.h"\r | |
35 | #include "TList.h"\r | |
36 | #include "TFile.h"\r | |
814d192f | 37 | #include "TSystem.h"\r |
7cc34f08 | 38 | \r |
39 | #include "AliAnalysisTask.h"\r | |
40 | #include "AliAnalysisManager.h"\r | |
41 | #include "AliESDEvent.h"\r | |
42 | #include "AliESDfriend.h"\r | |
43 | #include "AliMCEvent.h"\r | |
44 | #include "AliESDInputHandler.h"\r | |
45 | #include "AliMCEventHandler.h"\r | |
46 | #include "AliESDVertex.h"\r | |
47 | #include "AliMagF.h"\r | |
48 | #include "AliTracker.h"\r | |
49 | #include "AliGeomManager.h"\r | |
52abd620 | 50 | #include "AliCDBManager.h"\r |
7cc34f08 | 51 | \r |
5da23c19 | 52 | #include "AliCentrality.h"\r |
36ace53b | 53 | #include "AliESDVZERO.h"\r |
54 | #include "AliMultiplicity.h"\r | |
55 | \r | |
7cc34f08 | 56 | #include "AliMCInfo.h"\r |
57 | #include "AliESDRecInfo.h"\r | |
58 | #include "AliMCInfoCuts.h"\r | |
59 | #include "AliRecInfoCuts.h"\r | |
60 | #include "AliComparisonObject.h"\r | |
61 | #include "AliPerformanceObject.h"\r | |
814d192f | 62 | #include "AliTPCPerformanceSummary.h"\r |
63 | #include "AliPerformanceTPC.h"\r | |
64 | #include "AliPerformanceDEdx.h"\r | |
f69eb048 | 65 | #include "AliPerformanceMatch.h"\r |
7cc34f08 | 66 | #include "AliPerformanceTask.h"\r |
67 | \r | |
814d192f | 68 | \r |
7cc34f08 | 69 | using namespace std;\r |
70 | \r | |
71 | ClassImp(AliPerformanceTask)\r | |
72 | \r | |
73 | //_____________________________________________________________________________\r | |
74 | AliPerformanceTask::AliPerformanceTask() \r | |
a26a028b | 75 | : AliAnalysisTaskSE("Performance")\r |
7cc34f08 | 76 | , fESD(0)\r |
77 | , fESDfriend(0)\r | |
78 | , fMC(0)\r | |
79 | , fOutput(0)\r | |
814d192f | 80 | , fOutputSummary(0)\r |
7cc34f08 | 81 | , fPitList(0)\r |
82 | , fCompList(0)\r | |
83 | , fUseMCInfo(kFALSE)\r | |
84 | , fUseESDfriend(kFALSE)\r | |
636e5a51 | 85 | , fUseHLT(kFALSE)\r |
c1b69b58 | 86 | , fUseTerminate(kTRUE)\r |
36ace53b | 87 | , fUseCentrality(0)\r |
19563116 | 88 | , fUseOCDB(kTRUE)\r |
1e9c263c | 89 | , fUseCentralityBin(0)\r |
7cc34f08 | 90 | {\r |
91 | // Dummy Constructor\r | |
92 | // should not be used\r | |
93 | }\r | |
94 | \r | |
95 | //_____________________________________________________________________________\r | |
a26a028b | 96 | AliPerformanceTask::AliPerformanceTask(const char *name, const char */*title*/) \r |
97 | : AliAnalysisTaskSE(name)\r | |
7cc34f08 | 98 | , fESD(0)\r |
99 | , fESDfriend(0)\r | |
100 | , fMC(0)\r | |
101 | , fOutput(0)\r | |
814d192f | 102 | , fOutputSummary(0)\r |
7cc34f08 | 103 | , fPitList(0)\r |
104 | , fCompList(0)\r | |
105 | , fUseMCInfo(kFALSE)\r | |
106 | , fUseESDfriend(kFALSE)\r | |
636e5a51 | 107 | , fUseHLT(kFALSE)\r |
c1b69b58 | 108 | , fUseTerminate(kTRUE)\r |
36ace53b | 109 | , fUseCentrality(0)\r |
19563116 | 110 | , fUseOCDB(kTRUE)\r |
1e9c263c | 111 | , fUseCentralityBin(0)\r |
7cc34f08 | 112 | {\r |
113 | // Constructor\r | |
114 | \r | |
115 | // Define input and output slots here\r | |
65b3a5e1 | 116 | DefineOutput(1, TList::Class());\r |
814d192f | 117 | DefineOutput(2, TTree::Class());\r |
7cc34f08 | 118 | \r |
119 | // create the list for comparison objects\r | |
120 | fCompList = new TList;\r | |
121 | }\r | |
122 | \r | |
123 | //_____________________________________________________________________________\r | |
124 | AliPerformanceTask::~AliPerformanceTask()\r | |
125 | {\r | |
814d192f | 126 | if (fOutput) delete fOutput; fOutput = 0; \r |
127 | if (fOutputSummary) delete fOutputSummary; fOutputSummary = 0;\r | |
128 | if (fCompList) delete fCompList; fCompList = 0; \r | |
7cc34f08 | 129 | }\r |
130 | \r | |
7cc34f08 | 131 | //_____________________________________________________________________________\r |
132 | Bool_t AliPerformanceTask::AddPerformanceObject(AliPerformanceObject *pObj) \r | |
133 | {\r | |
134 | // add comparison object to the list\r | |
135 | if(pObj == 0) {\r | |
136 | Printf("ERROR: Could not add comparison object");\r | |
137 | return kFALSE;\r | |
138 | }\r | |
139 | \r | |
140 | // add object to the list\r | |
141 | fCompList->AddLast(pObj);\r | |
142 | \r | |
143 | return kTRUE;\r | |
144 | }\r | |
145 | \r | |
146 | //_____________________________________________________________________________\r | |
a26a028b | 147 | void AliPerformanceTask::UserCreateOutputObjects()\r |
7cc34f08 | 148 | {\r |
149 | // Create histograms\r | |
150 | // Called once\r | |
151 | \r | |
152 | // create output list\r | |
153 | fOutput = new TList;\r | |
154 | fOutput->SetOwner();\r | |
155 | fPitList = fOutput->MakeIterator();\r | |
814d192f | 156 | \r |
157 | // create output list\r | |
158 | //fOutputSummary = new TTree;\r | |
159 | \r | |
7cc34f08 | 160 | // add comparison objects to the output\r |
161 | AliPerformanceObject *pObj=0;\r | |
162 | Int_t count=0;\r | |
163 | TIterator *pitCompList = fCompList->MakeIterator();\r | |
164 | pitCompList->Reset();\r | |
165 | while(( pObj = (AliPerformanceObject *)pitCompList->Next()) != NULL) {\r | |
166 | fOutput->Add(pObj);\r | |
167 | count++;\r | |
168 | }\r | |
783eab45 | 169 | Printf("UserCreateOutputObjects(): Number of output comparison objects: %d \n", count);\r |
814d192f | 170 | \r |
171 | PostData(1, fOutput); \r | |
172 | //PostData(2, fOutputSummary); \r | |
7cc34f08 | 173 | }\r |
174 | \r | |
175 | //_____________________________________________________________________________\r | |
a26a028b | 176 | void AliPerformanceTask::UserExec(Option_t *) \r |
7cc34f08 | 177 | {\r |
178 | // Main loop\r | |
179 | // Called for each event\r | |
636e5a51 | 180 | \r |
181 | // Decide whether to use HLT or Offline ESD\r | |
182 | if(fUseHLT){\r | |
183 | \r | |
184 | AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> \r | |
185 | (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());\r | |
186 | \r | |
187 | if (!esdH) {\r | |
188 | printf("ERROR: Could not get ESDInputHandler");\r | |
189 | return;\r | |
190 | } \r | |
191 | fESD = esdH->GetHLTEvent();\r | |
192 | }// end if fUseHLT\r | |
193 | else \r | |
194 | fESD = (AliESDEvent*) (InputEvent());\r | |
195 | \r | |
a26a028b | 196 | if(fUseESDfriend)\r |
197 | {\r | |
198 | fESDfriend = static_cast<AliESDfriend*>(fESD->FindListObject("AliESDfriend"));\r | |
199 | if(!fESDfriend) {\r | |
200 | Printf("ERROR: ESD friends not available");\r | |
201 | }\r | |
202 | }\r | |
203 | \r | |
204 | if(fUseMCInfo) {\r | |
205 | fMC = MCEvent();\r | |
206 | } \r | |
7cc34f08 | 207 | \r |
7cc34f08 | 208 | \r |
209 | if (!fESD) {\r | |
210 | Printf("ERROR: ESD event not available");\r | |
211 | return;\r | |
212 | }\r | |
213 | \r | |
214 | if (fUseMCInfo && !fMC) {\r | |
215 | Printf("ERROR: MC event not available");\r | |
216 | return;\r | |
217 | }\r | |
218 | \r | |
219 | if(fUseESDfriend)\r | |
220 | {\r | |
221 | if(!fESDfriend) {\r | |
222 | Printf("ERROR: ESD friends not available");\r | |
223 | }\r | |
224 | }\r | |
225 | \r | |
1e9c263c | 226 | // Process analysis\r |
227 | Bool_t process = kTRUE;\r | |
36ace53b | 228 | \r |
1e9c263c | 229 | // Check fo centrality\r |
230 | if (fUseCentrality) {\r | |
231 | if ( CalculateCentralityBin() != fUseCentralityBin ) {\r | |
232 | process = kFALSE;\r | |
233 | }\r | |
234 | }\r | |
36ace53b | 235 | \r |
7cc34f08 | 236 | // Process comparison\r |
1e9c263c | 237 | if (process) {\r |
238 | AliPerformanceObject *pObj=0;\r | |
239 | fPitList->Reset();\r | |
240 | while(( pObj = (AliPerformanceObject *)fPitList->Next()) != NULL) {\r | |
241 | pObj->Exec(fMC,fESD,fESDfriend,fUseMCInfo,fUseESDfriend);\r | |
36ace53b | 242 | }\r |
7cc34f08 | 243 | }\r |
244 | \r | |
245 | // Post output data.\r | |
65b3a5e1 | 246 | PostData(1, fOutput);\r |
7cc34f08 | 247 | }\r |
248 | \r | |
249 | //_____________________________________________________________________________\r | |
250 | void AliPerformanceTask::Terminate(Option_t *) \r | |
251 | {\r | |
9ca899e5 | 252 | // Called once at the end \r |
c1b69b58 | 253 | \r |
254 | if ( !fUseTerminate )\r | |
255 | return;\r | |
256 | \r | |
7cc34f08 | 257 | // check output data\r |
814d192f | 258 | fOutputSummary = dynamic_cast<TTree*> (GetOutputData(2));\r |
259 | fOutput = dynamic_cast<TList*> (GetOutputData(1));\r | |
260 | if (!fOutput) {\r | |
d41038d7 | 261 | Printf("ERROR: AliPerformanceTask::Terminate(): fOutput data not available ..." );\r |
814d192f | 262 | return;\r |
263 | }\r | |
264 | if (fOutputSummary) { delete fOutputSummary; fOutputSummary=0; } \r | |
265 | AliPerformanceObject* pObj=0;\r | |
266 | AliPerformanceTPC* pTPC = 0;\r | |
267 | AliPerformanceDEdx* pDEdx = 0;\r | |
f69eb048 | 268 | AliPerformanceMatch* pMatch = 0;\r |
814d192f | 269 | TIterator* itOut = fOutput->MakeIterator();\r |
270 | itOut->Reset();\r | |
271 | while(( pObj = dynamic_cast<AliPerformanceObject*>(itOut->Next())) != NULL) { \r | |
f69eb048 | 272 | pObj->AnalyseFinal();\r |
273 | if (! pTPC) { pTPC = dynamic_cast<AliPerformanceTPC*>(pObj); }\r | |
274 | if (! pDEdx) { pDEdx = dynamic_cast<AliPerformanceDEdx*>(pObj); }\r | |
275 | if (! pMatch) { pMatch = dynamic_cast<AliPerformanceMatch*>(pObj); }\r | |
814d192f | 276 | }\r |
19563116 | 277 | \r |
278 | if(!fUseOCDB) { \r | |
279 | printf("DO NOT USE OCDB \n");\r | |
280 | return;\r | |
281 | }\r | |
282 | \r | |
d41038d7 | 283 | if (! AliCDBManager::Instance()->GetDefaultStorage()) { AliCDBManager::Instance()->SetDefaultStorage("raw://"); }\r |
814d192f | 284 | TUUID uuid;\r |
285 | TString tmpFile = gSystem->TempDirectory() + TString("/TPCQASummary.") + uuid.AsString() + TString(".root");\r | |
f69eb048 | 286 | AliTPCPerformanceSummary::WriteToFile(pTPC, pDEdx, pMatch, tmpFile.Data());\r |
814d192f | 287 | TChain* chain = new TChain("tpcQA");\r |
288 | chain->Add(tmpFile.Data());\r | |
289 | TTree *tree = chain->CopyTree("1");\r | |
290 | if (chain) { delete chain; chain=0; }\r | |
291 | fOutputSummary = tree;\r | |
292 | \r | |
293 | // Post output data.\r | |
294 | PostData(2, fOutputSummary);\r | |
636e5a51 | 295 | \r |
814d192f | 296 | }\r |
297 | \r | |
298 | //_____________________________________________________________________________\r | |
299 | void AliPerformanceTask::FinishTaskOutput()\r | |
300 | {\r | |
301 | // called once at the end of each job (on the workernode)\r | |
302 | //\r | |
303 | // projects THnSparse to TH1,2,3\r | |
304 | \r | |
305 | fOutput = dynamic_cast<TList*> (GetOutputData(1));\r | |
306 | if (!fOutput) {\r | |
307 | Printf("ERROR: AliPerformanceTask::FinishTaskOutput(): fOutput data not available ..." );\r | |
308 | return;\r | |
309 | }\r | |
636e5a51 | 310 | \r |
814d192f | 311 | AliPerformanceObject* pObj=0;\r |
312 | TIterator* itOut = fOutput->MakeIterator(); \r | |
313 | itOut->Reset();\r | |
314 | while(( pObj = dynamic_cast<AliPerformanceObject*>(itOut->Next())) != NULL) {\r | |
315 | pObj->SetRunNumber(fCurrentRunNumber);\r | |
316 | pObj->Analyse();\r | |
317 | }\r | |
318 | \r | |
319 | // Post output data.\r | |
320 | PostData(1, fOutput);\r | |
7cc34f08 | 321 | }\r |
322 | \r | |
323 | //_____________________________________________________________________________\r | |
324 | Bool_t AliPerformanceTask::Notify()\r | |
325 | {\r | |
326 | static Int_t count = 0;\r | |
327 | count++;\r | |
328 | Printf("Processing %d. file", count);\r | |
329 | \r | |
330 | return kTRUE;\r | |
331 | }\r | |
36ace53b | 332 | \r |
333 | //________________________________________________________________________\r | |
1e9c263c | 334 | Int_t AliPerformanceTask::CalculateCentralityBin(){\r |
36ace53b | 335 | // Get Centrality bin\r |
336 | \r | |
337 | Int_t centrality = -1;\r | |
1e9c263c | 338 | Float_t centralityF = -1;\r |
36ace53b | 339 | \r |
340 | if (fUseCentrality == 0)\r | |
341 | return centrality;\r | |
342 | \r | |
5da23c19 | 343 | AliCentrality *esdCentrality = fESD->GetCentrality();\r |
1e9c263c | 344 | \r |
345 | // New : 2010-11-18 JMT \r | |
346 | if ( fUseCentrality == 1 )\r | |
347 | centralityF = esdCentrality->GetCentralityPercentile("V0M");\r | |
348 | else if ( fUseCentrality == 2 )\r | |
349 | centralityF = esdCentrality->GetCentralityPercentile("CL1");\r | |
350 | else if ( fUseCentrality == 3 )\r | |
351 | centralityF = esdCentrality->GetCentralityPercentile("TRK"); \r | |
352 | if (centralityF == 0.)\r | |
353 | centralityF = 100.;\r | |
354 | \r | |
355 | if ( centralityF >= 0. && centralityF < 5.) centrality = 0;\r | |
356 | else if ( centralityF >= 5. && centralityF < 10.) centrality = 5;\r | |
357 | else if ( centralityF >= 10. && centralityF < 20.) centrality = 10;\r | |
358 | else if ( centralityF >= 20. && centralityF < 30.) centrality = 20;\r | |
359 | else if ( centralityF >= 30. && centralityF < 40.) centrality = 30;\r | |
360 | else if ( centralityF >= 40. && centralityF < 50.) centrality = 40;\r | |
361 | else if ( centralityF >= 50. && centralityF < 60.) centrality = 50;\r | |
362 | else if ( centralityF >= 60. && centralityF < 70.) centrality = 60;\r | |
363 | else if ( centralityF >= 70. && centralityF < 80.) centrality = 70;\r | |
364 | else if ( centralityF >= 80. && centralityF < 90.) centrality = 80;\r | |
365 | else if ( centralityF >= 90. && centralityF <=100.) centrality = 90;\r | |
36ace53b | 366 | \r |
367 | return centrality;\r | |
368 | }\r |