1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 *
10 * copies and that both the copyright notice and this permission notifce *
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 **************************************************************************/
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
26 // --- ROOT system ---
30 #include <TObjArray.h>
32 // --- Standard library ---
34 // --- AliRoot header files ---
35 #include "AliCDBPath.h"
36 #include "AliCDBEntry.h"
37 #include "AliDetectorRecoParam.h"
38 #include "AliCDBManager.h"
41 #include "AliQADataMakerRec.h"
42 #include "AliQAManager.h"
43 #include "AliESDEvent.h"
44 #include "AliRawReader.h"
46 ClassImp(AliQADataMakerRec)
48 //____________________________________________________________________________
49 AliQADataMakerRec::AliQADataMakerRec(const char * name, const char * title) :
50 AliQADataMaker(name, title),
54 fRecPointsQAList(NULL),
60 fDetectorDirName = GetName() ;
63 //____________________________________________________________________________
64 AliQADataMakerRec::AliQADataMakerRec(const AliQADataMakerRec& qadm) :
65 AliQADataMaker(qadm.GetName(), qadm.GetTitle()),
66 fDigitsQAList(qadm.fDigitsQAList),
67 fESDsQAList(qadm.fESDsQAList),
68 fRawsQAList(qadm.fRawsQAList),
69 fRecPointsQAList(qadm.fRecPointsQAList),
70 fCorrNt(qadm.fCorrNt),
71 fRecoParam(qadm.fRecoParam),
75 SetName(qadm.GetName()) ;
76 SetTitle(qadm.GetTitle()) ;
77 fDetectorDirName = GetName() ;
80 //____________________________________________________________________________
81 AliQADataMakerRec::~AliQADataMakerRec()
83 //dtor: delete the TObjArray and thei content
85 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
86 if ( fESDsQAList[specie] ) {
87 if ( fESDsQAList[specie]->IsOwner() )
88 fESDsQAList[specie]->Delete() ;
91 delete[] fESDsQAList ;
94 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
95 if ( fRawsQAList[specie] ) {
96 if ( fRawsQAList[specie]->IsOwner() )
97 fRawsQAList[specie]->Delete() ;
100 delete[] fRawsQAList ;
102 if ( fDigitsQAList ) {
103 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
104 if ( fDigitsQAList[specie] ) {
105 if ( fDigitsQAList[specie]->IsOwner() )
106 fDigitsQAList[specie]->Delete() ;
109 delete[] fDigitsQAList ;
111 if ( fRecPointsQAList ) {
112 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
113 if ( fRecPointsQAList[specie] ) {
114 if ( fRecPointsQAList[specie]->IsOwner() )
115 fRecPointsQAList[specie]->Delete() ;
118 delete[] fRecPointsQAList ;
120 if (fRecPointsArray) {
121 fRecPointsArray->Clear() ;
122 delete fRecPointsArray ;
126 //__________________________________________________________________
127 AliQADataMakerRec& AliQADataMakerRec::operator = (const AliQADataMakerRec& qadm )
129 // Assignment operator.
130 this->~AliQADataMakerRec();
131 new(this) AliQADataMakerRec(qadm);
135 //____________________________________________________________________________
136 void AliQADataMakerRec::EndOfCycle()
138 // Finishes a cycle of QA for all the tasks
139 EndOfCycle(AliQAv1::kRAWS) ;
140 EndOfCycle(AliQAv1::kDIGITSR) ;
141 EndOfCycle(AliQAv1::kRECPOINTS) ;
142 EndOfCycle(AliQAv1::kESDS) ;
146 //____________________________________________________________________________
147 void AliQADataMakerRec::EndOfCycle(AliQAv1::TASKINDEX_t task)
149 // Finishes a cycle of QA
152 TObjArray ** list = NULL ;
154 if ( task == AliQAv1::kRAWS )
156 else if ( task == AliQAv1::kDIGITSR )
157 list = fDigitsQAList ;
158 else if ( task == AliQAv1::kRECPOINTS )
159 list = fRecPointsQAList ;
160 else if ( task == AliQAv1::kESDS )
164 if ( ! list && ! fCorrNt )
166 //DefaultEndOfDetectorCycle(task) ;
167 EndOfDetectorCycle(task, list) ;
169 if (! AliQAManager::QAManager(AliQAv1::kRECMODE)->IsSaveData())
172 fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
174 fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
175 TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
177 subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
179 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { // skip Default
180 if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie)) || AliRecoParam::ConvertIndex(specie) == AliRecoParam::kDefault)
182 TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
184 eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ;
185 eventSpecieDir->cd() ;
188 TIter next(list[specie]) ;
190 while( (obj = next()) ) {
191 if (!obj->TestBit(AliQAv1::GetExpertBit()))
195 TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
197 expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
200 while( (obj = next()) ) {
201 if (!obj->TestBit(AliQAv1::GetExpertBit()))
208 else if ( fCorrNt ) {
209 if (fCorrNt[specie] && AliQAv1::GetDetIndex(GetName()) == AliQAv1::kCORR) {
210 eventSpecieDir->cd() ;
211 fCorrNt[specie]->Write() ;
218 //____________________________________________________________________________
219 void AliQADataMakerRec::Exec(AliQAv1::TASKINDEX_t task, TObject * data)
221 // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
223 if ( task == AliQAv1::kRAWS ) {
224 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Raws QA") ;
225 AliRawReader * rawReader = static_cast<AliRawReader *>(data) ;
227 MakeRaws(rawReader) ;
229 AliDebug(AliQAv1::GetQADebugLevel(), "Raw data are not processed") ;
230 } else if ( task == AliQAv1::kDIGITSR ) {
231 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Digits QA") ;
232 TTree * tree = static_cast<TTree *>(data) ;
233 if (strcmp(tree->ClassName(), "TTree") == 0) {
236 AliWarning("data are not a TTree") ;
238 } else if ( task == AliQAv1::kRECPOINTS ) {
239 AliDebug(AliQAv1::GetQADebugLevel(), "Processing RecPoints QA") ;
240 TTree * tree = static_cast<TTree *>(data) ;
241 if (strcmp(tree->ClassName(), "TTree") == 0) {
242 MakeRecPoints(tree) ;
244 AliWarning("data are not a TTree") ;
246 } else if ( task == AliQAv1::kESDS ) {
247 AliDebug(AliQAv1::GetQADebugLevel(), "Processing ESDs QA") ;
248 AliESDEvent * esd = static_cast<AliESDEvent *>(data) ;
249 if (strcmp(esd->ClassName(), "AliESDEvent") == 0)
252 AliError("Wrong type of esd container") ;
256 //____________________________________________________________________________
257 TObjArray ** AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, Int_t cycles)
259 // general intialisation
261 TObjArray ** rv = NULL ;
266 if ( task == AliQAv1::kRAWS ) {
267 if (! fRawsQAList ) {
268 fRawsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
269 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
270 fRawsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
271 fRawsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
275 } else if ( task == AliQAv1::kDIGITSR ) {
276 if ( ! fDigitsQAList ) {
277 fDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
278 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
279 fDigitsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
280 fDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
284 } else if ( task == AliQAv1::kRECPOINTS ) {
285 if ( ! fRecPointsQAList ) {
286 fRecPointsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
287 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
288 fRecPointsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
289 fRecPointsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
292 rv = fRecPointsQAList ;
293 } else if ( task == AliQAv1::kESDS ) {
294 if ( ! fESDsQAList ) {
295 fESDsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
296 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
297 fESDsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
298 fESDsQAList[specie]->SetName(Form("%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
306 //____________________________________________________________________________
307 void AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles)
309 // Intialisation by passing the list of QA data booked elsewhere
316 if ( task == AliQAv1::kRAWS ) {
318 } else if ( task == AliQAv1::kDIGITSR ) {
319 fDigitsQAList = list ;
320 } else if ( task == AliQAv1::kRECPOINTS ) {
321 fRecPointsQAList = list ;
322 } else if ( task == AliQAv1::kESDS ) {
327 //____________________________________________________________________________
328 void AliQADataMakerRec::InitRecoParams()
331 AliDebug(AliQAv1::GetQADebugLevel(), Form("Loading reconstruction parameter objects for detector %s", GetName()));
332 AliCDBPath path(GetName(),"Calib","RecoParam");
333 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
336 AliDebug(AliQAv1::GetQADebugLevel(), Form("Couldn't find RecoParam entry in OCDB for detector %s",GetName()));
339 TObject * recoParamObj = entry->GetObject() ;
340 if ( strcmp(recoParamObj->ClassName(), "TObjArray") == 0 ) {
341 // The detector has only one set of reco parameters
342 AliDebug(AliQAv1::GetQADebugLevel(), Form("Array of reconstruction parameters found for detector %s",GetName()));
343 TObjArray *recoParamArray = static_cast<TObjArray*>(recoParamObj) ;
344 for (Int_t iRP=0; iRP<recoParamArray->GetEntriesFast(); iRP++) {
345 fRecoParam = static_cast<AliDetectorRecoParam*>(recoParamArray->At(iRP)) ;
348 else if (fRecoParam->IsDefault())
352 else if (recoParamObj->InheritsFrom("AliDetectorRecoParam")) {
353 // The detector has only one set of reco parameters
354 // Registering it in AliRecoParam
355 AliDebug(AliQAv1::GetQADebugLevel(), Form("Single set of reconstruction parameters found for detector %s",GetName()));
356 fRecoParam = static_cast<AliDetectorRecoParam*>(recoParamObj) ;
357 static_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
359 AliError(Form("No valid RecoParam object found in the OCDB for detector %s",GetName()));
365 //____________________________________________________________________________
366 void AliQADataMakerRec::ResetDetector(AliQAv1::TASKINDEX_t task)
368 // default reset that resets all the QA objects.
369 // to be overloaded by detectors, if necessary
371 TObjArray ** list = NULL ;
372 if ( task == AliQAv1::kRAWS ) {
374 } else if ( task == AliQAv1::kDIGITSR ) {
375 list = fDigitsQAList ;
376 } else if ( task == AliQAv1::kRECPOINTS ) {
377 list = fRecPointsQAList ;
378 } else if ( task == AliQAv1::kESDS ) {
381 //list was not initialized, skip
385 for (int spec = 0; spec < AliRecoParam::kNSpecies; spec++) {
386 if (!AliQAv1::Instance()->IsEventSpecieSet(AliRecoParam::ConvertIndex(spec)))
388 TIter next(list[spec]) ;
390 while ( (histo = dynamic_cast<TH1*> (next())) ) {
396 //____________________________________________________________________________
397 void AliQADataMakerRec::StartOfCycle(Int_t run)
399 // Finishes a cycle of QA for all the tasks
400 Bool_t samecycle = kFALSE ;
401 StartOfCycle(AliQAv1::kRAWS, run, samecycle) ;
403 StartOfCycle(AliQAv1::kDIGITSR, run, samecycle) ;
404 StartOfCycle(AliQAv1::kRECPOINTS, run, samecycle) ;
405 StartOfCycle(AliQAv1::kESDS, run, samecycle) ;
408 //____________________________________________________________________________
409 void AliQADataMakerRec::StartOfCycle(AliQAv1::TASKINDEX_t task, Int_t run, const Bool_t sameCycle)
411 // Finishes a cycle of QA data acquistion
414 if ( !sameCycle || fCurrentCycle == -1) {
418 if (AliQAManager::QAManager(AliQAv1::kRECMODE)->IsSaveData())
419 fOutput = AliQAv1::GetQADataFile(GetName(), fRun) ;
421 AliDebug(AliQAv1::GetQADebugLevel(), Form(" Run %d Cycle %d task %s file %s",
422 fRun, fCurrentCycle, AliQAv1::GetTaskName(task).Data(), fOutput->GetName() )) ;
424 // fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
425 // if (!fDetectorDir)
426 // fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
428 // TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
430 // subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
432 // for ( Int_t specie = AliRecoParam::kDefault ; specie < AliRecoParam::kNSpecies ; specie++ ) {
433 // TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
434 // if (!eventSpecieDir)
435 // eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ;
436 // TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
438 // expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
440 StartOfDetectorCycle() ;