]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/STEER/AliQADataMakerRec.cxx
Moving the classes that belong to the following libraries: STEERBase, ESD, CDB, AOD...
[u/mrichter/AliRoot.git] / STEER / STEER / AliQADataMakerRec.cxx
CommitLineData
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 ---
04236e67 27#include <TFile.h>
04236e67 28#include <TTree.h>
57acd2d2 29#include <TNtupleD.h>
fb6e511e 30#include <TObjArray.h>
04236e67 31
32// --- Standard library ---
33
34// --- AliRoot header files ---
fb6e511e 35#include "AliCDBPath.h"
36#include "AliCDBEntry.h"
37#include "AliDetectorRecoParam.h"
38#include "AliCDBManager.h"
39
04236e67 40#include "AliLog.h"
41#include "AliQADataMakerRec.h"
50dee02c 42#include "AliQAManager.h"
04236e67 43#include "AliESDEvent.h"
44#include "AliRawReader.h"
45
46ClassImp(AliQADataMakerRec)
47
48//____________________________________________________________________________
49AliQADataMakerRec::AliQADataMakerRec(const char * name, const char * title) :
92664bc8 50AliQADataMaker(name, title),
71f27f1f 51 fDigitsQAList(NULL),
a2b64fbd 52 fESDsQAList(NULL),
53 fRawsQAList(NULL),
54 fRecPointsQAList(NULL),
57acd2d2 55 fCorrNt(NULL),
6252ceeb 56 fRecoParam(NULL),
57 fRecPointsArray(NULL)
04236e67 58{
59 // ctor
92664bc8 60 fDetectorDirName = GetName() ;
04236e67 61}
62
63//____________________________________________________________________________
64AliQADataMakerRec::AliQADataMakerRec(const AliQADataMakerRec& qadm) :
b8bd1ab8 65 AliQADataMaker(qadm.GetName(), qadm.GetTitle()),
71f27f1f 66 fDigitsQAList(qadm.fDigitsQAList),
b8bd1ab8 67 fESDsQAList(qadm.fESDsQAList),
68 fRawsQAList(qadm.fRawsQAList),
69 fRecPointsQAList(qadm.fRecPointsQAList),
57acd2d2 70 fCorrNt(qadm.fCorrNt),
6252ceeb 71 fRecoParam(qadm.fRecoParam),
72 fRecPointsArray(NULL)
04236e67 73{
74 //copy ctor
92664bc8 75 SetName(qadm.GetName()) ;
76 SetTitle(qadm.GetTitle()) ;
77 fDetectorDirName = GetName() ;
04236e67 78}
79
63c6f8ae 80//____________________________________________________________________________
81AliQADataMakerRec::~AliQADataMakerRec()
82{
92664bc8 83 //dtor: delete the TObjArray and thei content
84 if ( fESDsQAList ) {
57acd2d2 85 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
86 if ( fESDsQAList[specie] ) {
92664bc8 87 fESDsQAList[specie]->Delete() ;
57acd2d2 88 }
89 }
90 delete[] fESDsQAList ;
92664bc8 91 }
92 if ( fRawsQAList ) {
57acd2d2 93 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
94 if ( fRawsQAList[specie] ) {
2f9129dd 95 fRawsQAList[specie]->Delete() ;
57acd2d2 96 }
97 }
98 delete[] fRawsQAList ;
44ed7a66 99 }
92664bc8 100 if ( fDigitsQAList ) {
44ed7a66 101 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
102 if ( fDigitsQAList[specie] ) {
2f9129dd 103 fDigitsQAList[specie]->Delete() ;
44ed7a66 104 }
105 }
92664bc8 106 delete[] fDigitsQAList ;
57acd2d2 107 }
92664bc8 108 if ( fRecPointsQAList ) {
57acd2d2 109 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
110 if ( fRecPointsQAList[specie] ) {
2f9129dd 111 fRecPointsQAList[specie]->Delete() ;
57acd2d2 112 }
113 }
92664bc8 114 delete[] fRecPointsQAList ;
eca4fa66 115 }
6252ceeb 116 if (fRecPointsArray) {
117 fRecPointsArray->Clear() ;
118 delete fRecPointsArray ;
119 }
63c6f8ae 120}
121
04236e67 122//__________________________________________________________________
123AliQADataMakerRec& AliQADataMakerRec::operator = (const AliQADataMakerRec& qadm )
124{
125 // Assignment operator.
126 this->~AliQADataMakerRec();
127 new(this) AliQADataMakerRec(qadm);
128 return *this;
129}
130
930e6e3e 131//____________________________________________________________________________
132void AliQADataMakerRec::EndOfCycle()
133{
134 // Finishes a cycle of QA for all the tasks
4e25ac79 135 EndOfCycle(AliQAv1::kRAWS) ;
44ed7a66 136 EndOfCycle(AliQAv1::kDIGITSR) ;
4e25ac79 137 EndOfCycle(AliQAv1::kRECPOINTS) ;
138 EndOfCycle(AliQAv1::kESDS) ;
930e6e3e 139 ResetCycle() ;
140}
141
04236e67 142//____________________________________________________________________________
4e25ac79 143void AliQADataMakerRec::EndOfCycle(AliQAv1::TASKINDEX_t task)
04236e67 144{
92664bc8 145 // Finishes a cycle of QA
04236e67 146
ea5df941 147
148 TObjArray ** list = NULL ;
04236e67 149
92664bc8 150 if ( task == AliQAv1::kRAWS )
151 list = fRawsQAList ;
152 else if ( task == AliQAv1::kDIGITSR )
153 list = fDigitsQAList ;
154 else if ( task == AliQAv1::kRECPOINTS )
155 list = fRecPointsQAList ;
156 else if ( task == AliQAv1::kESDS )
157 list = fESDsQAList ;
7c002d48 158
930e6e3e 159
92664bc8 160 if ( ! list && ! fCorrNt )
930e6e3e 161 return ;
162 //DefaultEndOfDetectorCycle(task) ;
92664bc8 163 EndOfDetectorCycle(task, list) ;
50dee02c 164
92664bc8 165 if (! AliQAManager::QAManager(AliQAv1::kRECMODE)->IsSaveData()) return;
ea5df941 166
eca4fa66 167 fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
92664bc8 168 if (!fDetectorDir) fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
eca4fa66 169 TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
92664bc8 170 if (!subDir) subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
171 subDir->cd();
172 //
6252ceeb 173 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { // skip Default
92664bc8 174 if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie)) || AliRecoParam::ConvertIndex(specie) == AliRecoParam::kDefault) continue ;
7822bb76 175 TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
92664bc8 176 if (!eventSpecieDir) eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ;
177 eventSpecieDir->cd();
af65f4c8 178 if (list) {
179 if (list[specie]) {
180 TIter next(list[specie]) ;
181 TObject * obj ;
eca4fa66 182 while( (obj = next()) ) {
92664bc8 183 if (!obj->TestBit(AliQAv1::GetExpertBit())) obj->Write(); // RS: Note, this can be also TObjArray of clones
af65f4c8 184 }
185 if (WriteExpert()) {
186 TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
187 if (!expertDir)
188 expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
189 expertDir->cd() ;
190 next.Reset() ;
191 while( (obj = next()) ) {
92664bc8 192 if (!obj->TestBit(AliQAv1::GetExpertBit())) continue;
193 obj->Write(); // RS: Note, this can be also TObjArray of clones
af65f4c8 194 }
195 }
eca4fa66 196 }
af65f4c8 197 }
198 else if ( fCorrNt ) {
199 if (fCorrNt[specie] && AliQAv1::GetDetIndex(GetName()) == AliQAv1::kCORR) {
ddfe5350 200 if (fCorrNt[specie]->GetNvar() != 0) {
201 eventSpecieDir->cd() ;
202 fCorrNt[specie]->Write() ;
203 }
af65f4c8 204 }
205 fOutput->Save() ;
7822bb76 206 }
eca4fa66 207 }
7d297381 208}
209
04236e67 210//____________________________________________________________________________
4e25ac79 211void AliQADataMakerRec::Exec(AliQAv1::TASKINDEX_t task, TObject * data)
04236e67 212{
213 // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
214
92664bc8 215 if ( task == AliQAv1::kRAWS ) {
216 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Raws QA") ;
217 AliRawReader * rawReader = static_cast<AliRawReader *>(data) ;
218 if (rawReader)
219 MakeRaws(rawReader) ;
220 else
5379c4a3 221 AliDebug(AliQAv1::GetQADebugLevel(), "Raw data are not processed") ;
92664bc8 222 } else if ( task == AliQAv1::kDIGITSR ) {
223 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Digits QA") ;
224 TTree * tree = static_cast<TTree *>(data) ;
225 if (strcmp(tree->ClassName(), "TTree") == 0) {
226 MakeDigits(tree) ;
227 } else {
228 AliWarning("data are not a TTree") ;
229 }
230 } else if ( task == AliQAv1::kRECPOINTS ) {
231 AliDebug(AliQAv1::GetQADebugLevel(), "Processing RecPoints QA") ;
232 TTree * tree = static_cast<TTree *>(data) ;
233 if (strcmp(tree->ClassName(), "TTree") == 0) {
234 MakeRecPoints(tree) ;
235 } else {
236 AliWarning("data are not a TTree") ;
237 }
238 } else if ( task == AliQAv1::kESDS ) {
239 AliDebug(AliQAv1::GetQADebugLevel(), "Processing ESDs QA") ;
240 AliESDEvent * esd = static_cast<AliESDEvent *>(data) ;
241 if (strcmp(esd->ClassName(), "AliESDEvent") == 0)
242 MakeESDs(esd) ;
243 else
244 AliError("Wrong type of esd container") ;
245 }
04236e67 246}
247
248//____________________________________________________________________________
4e25ac79 249TObjArray ** AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, Int_t cycles)
04236e67 250{
251 // general intialisation
fb6e511e 252 InitRecoParams() ;
92664bc8 253 TObjArray ** rv = NULL ;
04236e67 254
92664bc8 255 if (cycles > 0)
256 SetCycle(cycles) ;
04236e67 257
92664bc8 258 if ( task == AliQAv1::kRAWS ) {
259 if (! fRawsQAList ) {
57acd2d2 260 fRawsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
261 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
49466ea2 262 fRawsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
4e25ac79 263 fRawsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
57acd2d2 264 }
92664bc8 265 }
266 rv = fRawsQAList ;
267 } else if ( task == AliQAv1::kDIGITSR ) {
268 if ( ! fDigitsQAList ) {
44ed7a66 269 fDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
270 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
49466ea2 271 fDigitsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
44ed7a66 272 fDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
273 }
92664bc8 274 }
275 rv = fDigitsQAList ;
276 } else if ( task == AliQAv1::kRECPOINTS ) {
277 if ( ! fRecPointsQAList ) {
57acd2d2 278 fRecPointsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
279 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
49466ea2 280 fRecPointsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
4e25ac79 281 fRecPointsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
57acd2d2 282 }
eca4fa66 283 }
92664bc8 284 rv = fRecPointsQAList ;
285 } else if ( task == AliQAv1::kESDS ) {
286 if ( ! fESDsQAList ) {
57acd2d2 287 fESDsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
288 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
49466ea2 289 fESDsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
65b25288 290 fESDsQAList[specie]->SetName(Form("%s_%s", GetName(), AliQAv1::GetTaskName(task).Data())); //, AliRecoParam::GetEventSpecieName(specie))) ;
57acd2d2 291 }
92664bc8 292 }
293 rv = fESDsQAList ;
294 }
295 return rv ;
04236e67 296}
297
298//____________________________________________________________________________
4e25ac79 299void AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles)
04236e67 300{
301 // Intialisation by passing the list of QA data booked elsewhere
302
fb6e511e 303 InitRecoParams() ;
304 fRun = run ;
92664bc8 305 if (cycles > 0)
306 SetCycle(cycles) ;
04236e67 307
92664bc8 308 if ( task == AliQAv1::kRAWS ) {
309 fRawsQAList = list ;
310 } else if ( task == AliQAv1::kDIGITSR ) {
311 fDigitsQAList = list ;
312 } else if ( task == AliQAv1::kRECPOINTS ) {
313 fRecPointsQAList = list ;
314 } else if ( task == AliQAv1::kESDS ) {
315 fESDsQAList = list ;
316 }
04236e67 317}
318
fb6e511e 319//____________________________________________________________________________
320void AliQADataMakerRec::InitRecoParams()
321{
f14c8c46 322 // Get the recoparam form the OCDB
fb6e511e 323 if (!fRecoParam) {
5379c4a3 324 AliDebug(AliQAv1::GetQADebugLevel(), Form("Loading reconstruction parameter objects for detector %s", GetName()));
fb6e511e 325 AliCDBPath path(GetName(),"Calib","RecoParam");
fcab16e6 326 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
fb6e511e 327 if(!entry) {
328 fRecoParam = NULL ;
55e356ec 329 AliDebug(AliQAv1::GetQADebugLevel(), Form("Couldn't find RecoParam entry in OCDB for detector %s",GetName()));
fb6e511e 330 }
331 else {
fcab16e6 332 entry->SetOwner(kTRUE);
fb6e511e 333 TObject * recoParamObj = entry->GetObject() ;
eca4fa66 334 if ( strcmp(recoParamObj->ClassName(), "TObjArray") == 0 ) {
42383dda 335 // The detector has only one set of reco parameters
5379c4a3 336 AliDebug(AliQAv1::GetQADebugLevel(), Form("Array of reconstruction parameters found for detector %s",GetName()));
eca4fa66 337 TObjArray *recoParamArray = static_cast<TObjArray*>(recoParamObj) ;
fcab16e6 338 recoParamArray->SetOwner(kTRUE);
42383dda 339 for (Int_t iRP=0; iRP<recoParamArray->GetEntriesFast(); iRP++) {
eca4fa66 340 fRecoParam = static_cast<AliDetectorRecoParam*>(recoParamArray->At(iRP)) ;
341 if (!fRecoParam)
342 break ;
343 else if (fRecoParam->IsDefault())
344 break ;
42383dda 345 }
346 }
eca4fa66 347 else if (recoParamObj->InheritsFrom("AliDetectorRecoParam")) {
348 // The detector has only one set of reco parameters
fb6e511e 349 // Registering it in AliRecoParam
5379c4a3 350 AliDebug(AliQAv1::GetQADebugLevel(), Form("Single set of reconstruction parameters found for detector %s",GetName()));
eca4fa66 351 fRecoParam = static_cast<AliDetectorRecoParam*>(recoParamObj) ;
352 static_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
fb6e511e 353 } else {
354 AliError(Form("No valid RecoParam object found in the OCDB for detector %s",GetName()));
355 }
356 }
357 }
358}
359
9ac91920 360//____________________________________________________________________________
361void AliQADataMakerRec::ResetDetector(AliQAv1::TASKINDEX_t task)
362{
92664bc8 363 // default reset that resets all the QA objects.
364 // to be overloaded by detectors, if necessary
9ac91920 365
366 TObjArray ** list = NULL ;
367 if ( task == AliQAv1::kRAWS ) {
92664bc8 368 list = fRawsQAList ;
369 } else if ( task == AliQAv1::kDIGITSR ) {
370 list = fDigitsQAList ;
371 } else if ( task == AliQAv1::kRECPOINTS ) {
372 list = fRecPointsQAList ;
373 } else if ( task == AliQAv1::kESDS ) {
374 list = fESDsQAList ;
375 }
376 //list was not initialized, skip
377 if (!list) return ;
9ac91920 378
379 for (int spec = 0; spec < AliRecoParam::kNSpecies; spec++) {
92664bc8 380 if (!AliQAv1::Instance()->IsEventSpecieSet(AliRecoParam::ConvertIndex(spec))) continue;
9ac91920 381 TIter next(list[spec]) ;
92664bc8 382 TObject *obj = NULL;
383 while ( (obj = next()) ) {
384 if (obj->TestBit(AliQAv1::GetClonedBit())) { // this is array of cloned histos
385 TObjArray* arr = (TObjArray*)obj;
386 for (int ih=arr->GetEntriesFast();ih--;) {
387 TH1* histo = (TH1*)arr->At(ih);
388 if (!ih) continue;
389 histo->Reset("ICE");
390 histo->ResetStats();
391 }
392 }
393 else {
394 ((TH1*)obj)->Reset("ICE");
395 ((TH1*)obj)->ResetStats();
396 }
9ac91920 397 }
92664bc8 398 ResetEvCountCycle(AliRecoParam::ConvertIndex(spec));
399 ResetEvCountTotal(AliRecoParam::ConvertIndex(spec));
9ac91920 400 }
401}
402
04236e67 403//____________________________________________________________________________
930e6e3e 404void AliQADataMakerRec::StartOfCycle(Int_t run)
405{
406 // Finishes a cycle of QA for all the tasks
407 Bool_t samecycle = kFALSE ;
4e25ac79 408 StartOfCycle(AliQAv1::kRAWS, run, samecycle) ;
930e6e3e 409 samecycle = kTRUE ;
44ed7a66 410 StartOfCycle(AliQAv1::kDIGITSR, run, samecycle) ;
4e25ac79 411 StartOfCycle(AliQAv1::kRECPOINTS, run, samecycle) ;
92664bc8 412 StartOfCycle(AliQAv1::kESDS, run, samecycle) ;
930e6e3e 413}
414
415//____________________________________________________________________________
4e25ac79 416void AliQADataMakerRec::StartOfCycle(AliQAv1::TASKINDEX_t task, Int_t run, const Bool_t sameCycle)
04236e67 417{
418 // Finishes a cycle of QA data acquistion
92664bc8 419 if ( run > 0 ) fRun = run ;
420 if ( !sameCycle || fCurrentCycle == -1) {
421 ResetCycle() ;
422 if (fOutput)
423 fOutput->Close() ;
424 if (AliQAManager::QAManager(AliQAv1::kRECMODE)->IsSaveData())
50dee02c 425 fOutput = AliQAv1::GetQADataFile(GetName(), fRun) ;
92664bc8 426 }
427 AliDebug(AliQAv1::GetQADebugLevel(), Form(" Run %d Cycle %d task %s file %s",
428 fRun, fCurrentCycle, AliQAv1::GetTaskName(task).Data(), fOutput->GetName() )) ;
429
430 // fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
431 // if (!fDetectorDir)
432 // fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
433 //
434 // TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
435 // if (!subDir)
436 // subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
437 //
438 // for ( Int_t specie = AliRecoParam::kDefault ; specie < AliRecoParam::kNSpecies ; specie++ ) {
439 // TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
440 // if (!eventSpecieDir)
441 // eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ;
442 // TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
443 // if (!expertDir)
444 // expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
445 // }
446 StartOfDetectorCycle();
447 ResetEvCountCycle();
448}
04236e67 449
92664bc8 450//____________________________________________________________________________
451void AliQADataMakerRec::ClonePerTrigClass(AliQAv1::TASKINDEX_t task)
452{
453 // clone the histos of the array corresponding to task
454 switch (task)
455 {
456 case AliQAv1::kRAWS : ClonePerTrigClassL(fRawsQAList, task); break;
457 case AliQAv1::kDIGITS : ClonePerTrigClassL(fDigitsQAList, task); break;
458 case AliQAv1::kRECPOINTS : ClonePerTrigClassL(fRecPointsQAList, task); break;
459 case AliQAv1::kESDS : ClonePerTrigClassL(fESDsQAList, task); break;
460 default : AliError(Form("Task %s is invalid in this context", AliQAv1::GetTaskName(task).Data() )); break;
461 }
462 //
04236e67 463}