]>
Commit | Line | Data |
---|---|---|
04236e67 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
940d8e5f | 10 | * copies and that both the copyright notice and this permission notifce * |
04236e67 | 11 | * appear in the supporting documentation. The authors make no claims * |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | ||
17 | /* $Id$ */ | |
18 | ||
202374b1 | 19 | // |
20 | // Base Class | |
21 | // Produces the data needed to calculate the quality assurance for Reconstruction | |
22 | // All data must be mergeable objects. | |
23 | // Y. Schutz CERN July 2007 | |
24 | // | |
04236e67 | 25 | |
26 | // --- ROOT system --- | |
7d297381 | 27 | #include <TCanvas.h> |
04236e67 | 28 | #include <TFile.h> |
04236e67 | 29 | #include <TTree.h> |
57acd2d2 | 30 | #include <TNtupleD.h> |
fb6e511e | 31 | #include <TObjArray.h> |
04236e67 | 32 | |
33 | // --- Standard library --- | |
34 | ||
35 | // --- AliRoot header files --- | |
fb6e511e | 36 | #include "AliCDBPath.h" |
37 | #include "AliCDBEntry.h" | |
38 | #include "AliDetectorRecoParam.h" | |
39 | #include "AliCDBManager.h" | |
40 | ||
04236e67 | 41 | #include "AliLog.h" |
42 | #include "AliQADataMakerRec.h" | |
04236e67 | 43 | #include "AliESDEvent.h" |
44 | #include "AliRawReader.h" | |
45 | ||
46 | ClassImp(AliQADataMakerRec) | |
47 | ||
48 | //____________________________________________________________________________ | |
49 | AliQADataMakerRec::AliQADataMakerRec(const char * name, const char * title) : | |
50 | AliQADataMaker(name, title), | |
a2b64fbd | 51 | fESDsQAList(NULL), |
52 | fRawsQAList(NULL), | |
53 | fRecPointsQAList(NULL), | |
57acd2d2 | 54 | fCorrNt(NULL), |
a2b64fbd | 55 | fRecoParam(NULL) |
04236e67 | 56 | { |
57 | // ctor | |
58 | fDetectorDirName = GetName() ; | |
59 | } | |
60 | ||
61 | //____________________________________________________________________________ | |
62 | AliQADataMakerRec::AliQADataMakerRec(const AliQADataMakerRec& qadm) : | |
b8bd1ab8 | 63 | AliQADataMaker(qadm.GetName(), qadm.GetTitle()), |
64 | fESDsQAList(qadm.fESDsQAList), | |
65 | fRawsQAList(qadm.fRawsQAList), | |
66 | fRecPointsQAList(qadm.fRecPointsQAList), | |
57acd2d2 | 67 | fCorrNt(qadm.fCorrNt), |
a2b64fbd | 68 | fRecoParam(qadm.fRecoParam) |
04236e67 | 69 | { |
70 | //copy ctor | |
71 | SetName(qadm.GetName()) ; | |
72 | SetTitle(qadm.GetTitle()) ; | |
73 | fDetectorDirName = GetName() ; | |
74 | } | |
75 | ||
63c6f8ae | 76 | //____________________________________________________________________________ |
77 | AliQADataMakerRec::~AliQADataMakerRec() | |
78 | { | |
79 | //dtor: delete the TObjArray and thei content | |
7ff8385d | 80 | if ( fESDsQAList ) { |
57acd2d2 | 81 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { |
82 | if ( fESDsQAList[specie] ) { | |
83 | if ( fESDsQAList[specie]->IsOwner() ) | |
84 | fESDsQAList[specie]->Delete() ; | |
85 | } | |
86 | } | |
87 | delete[] fESDsQAList ; | |
7ff8385d | 88 | } |
89 | if ( fRawsQAList ) { | |
57acd2d2 | 90 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { |
91 | if ( fRawsQAList[specie] ) { | |
92 | if ( fRawsQAList[specie]->IsOwner() ) | |
93 | fRawsQAList[specie]->Delete() ; | |
94 | } | |
95 | } | |
96 | delete[] fRawsQAList ; | |
97 | } | |
7ff8385d | 98 | if ( fRecPointsQAList ) { |
57acd2d2 | 99 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { |
100 | if ( fRecPointsQAList[specie] ) { | |
101 | if ( fRecPointsQAList[specie]->IsOwner() ) | |
102 | fRecPointsQAList[specie]->Delete() ; | |
103 | } | |
104 | } | |
105 | delete[] fRecPointsQAList ; | |
7ff8385d | 106 | } |
63c6f8ae | 107 | } |
108 | ||
04236e67 | 109 | //__________________________________________________________________ |
110 | AliQADataMakerRec& AliQADataMakerRec::operator = (const AliQADataMakerRec& qadm ) | |
111 | { | |
112 | // Assignment operator. | |
113 | this->~AliQADataMakerRec(); | |
114 | new(this) AliQADataMakerRec(qadm); | |
115 | return *this; | |
116 | } | |
117 | ||
930e6e3e | 118 | //____________________________________________________________________________ |
119 | void AliQADataMakerRec::EndOfCycle() | |
120 | { | |
121 | // Finishes a cycle of QA for all the tasks | |
4e25ac79 | 122 | EndOfCycle(AliQAv1::kRAWS) ; |
123 | EndOfCycle(AliQAv1::kRECPOINTS) ; | |
124 | EndOfCycle(AliQAv1::kESDS) ; | |
930e6e3e | 125 | ResetCycle() ; |
126 | } | |
127 | ||
04236e67 | 128 | //____________________________________________________________________________ |
4e25ac79 | 129 | void AliQADataMakerRec::EndOfCycle(AliQAv1::TASKINDEX_t task) |
04236e67 | 130 | { |
930e6e3e | 131 | // Finishes a cycle of QA |
04236e67 | 132 | |
57acd2d2 | 133 | TObjArray ** list = NULL ; |
04236e67 | 134 | |
4e25ac79 | 135 | if ( task == AliQAv1::kRAWS ) |
04236e67 | 136 | list = fRawsQAList ; |
4e25ac79 | 137 | else if ( task == AliQAv1::kRECPOINTS ) |
04236e67 | 138 | list = fRecPointsQAList ; |
4e25ac79 | 139 | else if ( task == AliQAv1::kESDS ) |
04236e67 | 140 | list = fESDsQAList ; |
7c002d48 | 141 | |
930e6e3e | 142 | |
57acd2d2 | 143 | if ( ! list && ! fCorrNt ) |
930e6e3e | 144 | return ; |
145 | //DefaultEndOfDetectorCycle(task) ; | |
0774e4a4 | 146 | EndOfDetectorCycle(task, list) ; |
a2b64fbd | 147 | TDirectory * subDir = NULL ; |
7c002d48 | 148 | if (fDetectorDir) |
4e25ac79 | 149 | subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ; |
45c5be2d | 150 | if ( subDir ) { |
eecc22a3 | 151 | subDir->cd() ; |
57acd2d2 | 152 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { |
153 | TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ; | |
154 | if (eventSpecieDir) { | |
155 | eventSpecieDir->cd() ; | |
156 | if (list[specie]) { | |
157 | TIter next(list[specie]) ; | |
158 | TObject * obj ; | |
750730d8 | 159 | while( (obj = next()) ) { |
4e25ac79 | 160 | if (!obj->TestBit(AliQAv1::GetExpertBit())) |
57acd2d2 | 161 | obj->Write() ; |
162 | } | |
163 | if (WriteExpert()) { | |
4e25ac79 | 164 | TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ; |
57acd2d2 | 165 | if ( expertDir ) { // Write only if requested |
166 | expertDir->cd() ; | |
167 | next.Reset() ; | |
168 | while( (obj = next()) ) { | |
4e25ac79 | 169 | if (!obj->TestBit(AliQAv1::GetExpertBit())) |
57acd2d2 | 170 | continue ; |
171 | obj->Write() ; | |
172 | } | |
173 | } | |
174 | } | |
175 | } | |
176 | if ( !fCorrNt ) | |
177 | continue ; | |
4e25ac79 | 178 | if (fCorrNt[specie] && AliQAv1::GetDetIndex(GetName()) == AliQAv1::kCORR) { |
57acd2d2 | 179 | eventSpecieDir->cd() ; |
180 | fCorrNt[specie]->Write() ; | |
b1af1125 | 181 | } |
6e65319c | 182 | } |
183 | } | |
a595ac34 | 184 | fOutput->Save() ; |
eecc22a3 | 185 | } |
7d297381 | 186 | MakeImage(task) ; |
04236e67 | 187 | } |
7d297381 | 188 | |
189 | //____________________________________________________________________________ | |
190 | void AliQADataMakerRec::MakeImage(AliQAv1::TASKINDEX_t task) | |
191 | { | |
192 | // create a drawing of detetor defined histograms | |
193 | TObjArray ** list = NULL ; | |
194 | switch (task) { | |
195 | case AliQAv1::kRAWS: | |
196 | list = fRawsQAList ; | |
197 | break; | |
198 | case AliQAv1::kHITS: | |
199 | break; | |
200 | case AliQAv1::kSDIGITS: | |
201 | break; | |
202 | case AliQAv1::kDIGITS: | |
203 | break; | |
204 | case AliQAv1::kRECPOINTS: | |
205 | list = fRecPointsQAList ; | |
206 | break; | |
207 | case AliQAv1::kTRACKSEGMENTS: | |
208 | break; | |
209 | case AliQAv1::kRECPARTICLES: | |
210 | break; | |
211 | case AliQAv1::kESDS: | |
212 | list = fESDsQAList ; | |
213 | break; | |
214 | case AliQAv1::kNTASKINDEX: | |
215 | break; | |
216 | default: | |
217 | break; | |
218 | } | |
219 | if ( !list) { | |
220 | AliError("data not initialized, call AliQADataMaker::Init"); | |
221 | return ; | |
222 | } | |
223 | TIter next(list[0]) ; | |
224 | TH1 * hdata = NULL ; | |
225 | Int_t nImages = 0 ; | |
226 | while ( (hdata=dynamic_cast<TH1 *>(next())) ) { | |
227 | if ( hdata->TestBit(AliQAv1::GetImageBit()) ) | |
228 | nImages++; | |
229 | } | |
230 | if ( nImages == 0 ) { | |
231 | AliInfo(Form("No histogram will be plotted for %s %s\n", GetName(), AliQAv1::GetTaskName(task).Data())) ; | |
232 | } else { | |
233 | AliInfo(Form("%d histograms will be plotted for %s %s\n", nImages, GetName(), AliQAv1::GetTaskName(task).Data())) ; | |
234 | Double_t w = 1000 ; | |
235 | Double_t h = 1000 ; | |
236 | for (Int_t esIndex = 0 ; esIndex < AliRecoParam::kNSpecies ; esIndex++) { | |
237 | TCanvas * canvasQA = new TCanvas(Form("QA_%s_%s_%s", | |
238 | GetName(), | |
239 | AliQAv1::GetTaskName(task).Data(), | |
240 | AliRecoParam::GetEventSpecieName(esIndex)), | |
241 | Form("QA control plots for det=%s task=%s eventspecie=%s", | |
242 | GetName(), | |
243 | AliQAv1::GetTaskName(task).Data(), | |
244 | AliRecoParam::GetEventSpecieName(esIndex)), | |
245 | w, h) ; | |
246 | canvasQA->SetWindowSize(w + (w - canvasQA->GetWw()), h + (h - canvasQA->GetWh())) ; | |
247 | Int_t nx = TMath::Sqrt(nImages) ; | |
248 | Int_t ny = nx ; | |
249 | if ( nx < TMath::Sqrt(nImages)) | |
250 | ny++ ; | |
251 | canvasQA->Divide(nx, ny) ; | |
252 | TIter nexthist(list[esIndex]) ; | |
253 | TH1* hist = NULL ; | |
254 | Int_t npad = 1 ; | |
255 | canvasQA->cd(npad) ; | |
256 | while ( (hist=dynamic_cast<TH1*>(nexthist())) ) { | |
257 | if(hist->TestBit(AliQAv1::GetImageBit())) { | |
258 | hist->Draw() ; | |
259 | canvasQA->cd(++npad) ; | |
260 | } | |
261 | } | |
262 | canvasQA->Print() ; | |
263 | } | |
264 | } | |
265 | } | |
266 | ||
04236e67 | 267 | //____________________________________________________________________________ |
4e25ac79 | 268 | void AliQADataMakerRec::Exec(AliQAv1::TASKINDEX_t task, TObject * data) |
04236e67 | 269 | { |
270 | // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs) | |
271 | ||
4e25ac79 | 272 | if ( task == AliQAv1::kRAWS ) { |
04236e67 | 273 | AliDebug(1, "Processing Raws QA") ; |
274 | AliRawReader * rawReader = dynamic_cast<AliRawReader *>(data) ; | |
275 | if (rawReader) | |
276 | MakeRaws(rawReader) ; | |
277 | else | |
930e6e3e | 278 | AliInfo("Raw data are not processed") ; |
4e25ac79 | 279 | } else if ( task == AliQAv1::kRECPOINTS ) { |
04236e67 | 280 | AliDebug(1, "Processing RecPoints QA") ; |
281 | TTree * tree = dynamic_cast<TTree *>(data) ; | |
282 | if (tree) { | |
283 | MakeRecPoints(tree) ; | |
284 | } else { | |
285 | AliWarning("data are not a TTree") ; | |
286 | } | |
4e25ac79 | 287 | } else if ( task == AliQAv1::kESDS ) { |
04236e67 | 288 | AliDebug(1, "Processing ESDs QA") ; |
289 | AliESDEvent * esd = dynamic_cast<AliESDEvent *>(data) ; | |
290 | if (esd) | |
291 | MakeESDs(esd) ; | |
292 | else | |
293 | AliError("Wrong type of esd container") ; | |
294 | } | |
295 | } | |
296 | ||
297 | //____________________________________________________________________________ | |
4e25ac79 | 298 | TObjArray ** AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, Int_t cycles) |
04236e67 | 299 | { |
300 | // general intialisation | |
fb6e511e | 301 | InitRecoParams() ; |
57acd2d2 | 302 | TObjArray ** rv = NULL ; |
04236e67 | 303 | |
04236e67 | 304 | if (cycles > 0) |
305 | SetCycle(cycles) ; | |
306 | ||
4e25ac79 | 307 | if ( task == AliQAv1::kRAWS ) { |
63c6f8ae | 308 | if (! fRawsQAList ) { |
57acd2d2 | 309 | fRawsQAList = new TObjArray *[AliRecoParam::kNSpecies] ; |
310 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { | |
311 | fRawsQAList[specie] = new TObjArray(100) ; | |
4e25ac79 | 312 | fRawsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ; |
57acd2d2 | 313 | } |
63c6f8ae | 314 | InitRaws() ; |
315 | } | |
04236e67 | 316 | rv = fRawsQAList ; |
4e25ac79 | 317 | } else if ( task == AliQAv1::kRECPOINTS ) { |
63c6f8ae | 318 | if ( ! fRecPointsQAList ) { |
57acd2d2 | 319 | fRecPointsQAList = new TObjArray *[AliRecoParam::kNSpecies] ; |
320 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { | |
321 | fRecPointsQAList[specie] = new TObjArray(100) ; | |
4e25ac79 | 322 | fRecPointsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ; |
57acd2d2 | 323 | } |
324 | InitRecPoints() ; | |
63c6f8ae | 325 | } |
04236e67 | 326 | rv = fRecPointsQAList ; |
4e25ac79 | 327 | } else if ( task == AliQAv1::kESDS ) { |
63c6f8ae | 328 | if ( ! fESDsQAList ) { |
57acd2d2 | 329 | fESDsQAList = new TObjArray *[AliRecoParam::kNSpecies] ; |
330 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { | |
331 | fESDsQAList[specie] = new TObjArray(100) ; | |
4e25ac79 | 332 | fESDsQAList[specie]->SetName(Form("%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ; |
57acd2d2 | 333 | } |
63c6f8ae | 334 | InitESDs() ; |
335 | } | |
04236e67 | 336 | rv = fESDsQAList ; |
337 | } | |
04236e67 | 338 | return rv ; |
339 | } | |
340 | ||
341 | //____________________________________________________________________________ | |
4e25ac79 | 342 | void AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles) |
04236e67 | 343 | { |
344 | // Intialisation by passing the list of QA data booked elsewhere | |
345 | ||
fb6e511e | 346 | InitRecoParams() ; |
347 | fRun = run ; | |
04236e67 | 348 | if (cycles > 0) |
349 | SetCycle(cycles) ; | |
350 | ||
4e25ac79 | 351 | if ( task == AliQAv1::kRAWS ) { |
04236e67 | 352 | fRawsQAList = list ; |
4e25ac79 | 353 | } else if ( task == AliQAv1::kRECPOINTS ) { |
04236e67 | 354 | fRecPointsQAList = list ; |
4e25ac79 | 355 | } else if ( task == AliQAv1::kESDS ) { |
04236e67 | 356 | fESDsQAList = list ; |
357 | } | |
358 | } | |
359 | ||
fb6e511e | 360 | //____________________________________________________________________________ |
361 | void AliQADataMakerRec::InitRecoParams() | |
362 | { | |
363 | if (!fRecoParam) { | |
364 | AliInfo(Form("Loading reconstruction parameter objects for detector %s", GetName())); | |
365 | AliCDBPath path(GetName(),"Calib","RecoParam"); | |
366 | AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath()); | |
367 | if(!entry) { | |
368 | fRecoParam = NULL ; | |
369 | AliWarning(Form("Couldn't find RecoParam entry in OCDB for detector %s",GetName())); | |
370 | } | |
371 | else { | |
372 | TObject * recoParamObj = entry->GetObject() ; | |
42383dda | 373 | if (dynamic_cast<TObjArray*>(recoParamObj)) { |
374 | // The detector has only one set of reco parameters | |
375 | AliInfo(Form("Array of reconstruction parameters found for detector %s",GetName())); | |
376 | TObjArray *recoParamArray = dynamic_cast<TObjArray*>(recoParamObj) ; | |
377 | for (Int_t iRP=0; iRP<recoParamArray->GetEntriesFast(); iRP++) { | |
378 | fRecoParam = dynamic_cast<AliDetectorRecoParam*>(recoParamArray->At(iRP)) ; | |
379 | if (fRecoParam->IsDefault()) break; | |
380 | } | |
381 | } | |
382 | else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) { | |
fb6e511e | 383 | // The detector has only onse set of reco parameters |
384 | // Registering it in AliRecoParam | |
385 | AliInfo(Form("Single set of reconstruction parameters found for detector %s",GetName())); | |
386 | dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault(); | |
387 | fRecoParam = dynamic_cast<AliDetectorRecoParam*>(recoParamObj) ; | |
388 | } else { | |
389 | AliError(Form("No valid RecoParam object found in the OCDB for detector %s",GetName())); | |
390 | } | |
391 | } | |
42383dda | 392 | AliCDBManager::Instance()->UnloadFromCache(path.GetPath()); |
fb6e511e | 393 | } |
394 | } | |
395 | ||
04236e67 | 396 | //____________________________________________________________________________ |
930e6e3e | 397 | void AliQADataMakerRec::StartOfCycle(Int_t run) |
398 | { | |
399 | // Finishes a cycle of QA for all the tasks | |
400 | Bool_t samecycle = kFALSE ; | |
4e25ac79 | 401 | StartOfCycle(AliQAv1::kRAWS, run, samecycle) ; |
930e6e3e | 402 | samecycle = kTRUE ; |
4e25ac79 | 403 | StartOfCycle(AliQAv1::kRECPOINTS, run, samecycle) ; |
404 | StartOfCycle(AliQAv1::kESDS, run, samecycle) ; | |
930e6e3e | 405 | } |
406 | ||
407 | //____________________________________________________________________________ | |
4e25ac79 | 408 | void AliQADataMakerRec::StartOfCycle(AliQAv1::TASKINDEX_t task, Int_t run, const Bool_t sameCycle) |
04236e67 | 409 | { |
410 | // Finishes a cycle of QA data acquistion | |
930e6e3e | 411 | if ( run > 0 ) |
412 | fRun = run ; | |
04236e67 | 413 | if ( !sameCycle || fCurrentCycle == -1) { |
414 | ResetCycle() ; | |
415 | if (fOutput) | |
416 | fOutput->Close() ; | |
4e25ac79 | 417 | fOutput = AliQAv1::GetQADataFile(GetName(), fRun) ; |
04236e67 | 418 | } |
7c002d48 | 419 | AliInfo(Form(" Run %d Cycle %d task %s file %s", |
4e25ac79 | 420 | fRun, fCurrentCycle, AliQAv1::GetTaskName(task).Data(), fOutput->GetName() )) ; |
04236e67 | 421 | |
422 | fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ; | |
423 | if (!fDetectorDir) | |
424 | fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ; | |
425 | ||
4e25ac79 | 426 | TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ; |
04236e67 | 427 | if (!subDir) |
4e25ac79 | 428 | subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ; |
6e65319c | 429 | |
57acd2d2 | 430 | for ( Int_t specie = AliRecoParam::kDefault ; specie < AliRecoParam::kNSpecies ; specie++ ) { |
431 | TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ; | |
432 | if (!eventSpecieDir) | |
433 | eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ; | |
4e25ac79 | 434 | TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ; |
57acd2d2 | 435 | if (!expertDir) |
4e25ac79 | 436 | expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ; |
57acd2d2 | 437 | } |
04236e67 | 438 | StartOfDetectorCycle() ; |
439 | } |