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 fESDsQAList[specie]->Delete() ;
90 delete[] fESDsQAList ;
93 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
94 if ( fRawsQAList[specie] ) {
95 fRawsQAList[specie]->Delete() ;
98 delete[] fRawsQAList ;
100 if ( fDigitsQAList ) {
101 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
102 if ( fDigitsQAList[specie] ) {
103 fDigitsQAList[specie]->Delete() ;
106 delete[] fDigitsQAList ;
108 if ( fRecPointsQAList ) {
109 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
110 if ( fRecPointsQAList[specie] ) {
111 fRecPointsQAList[specie]->Delete() ;
114 delete[] fRecPointsQAList ;
116 if (fRecPointsArray) {
117 fRecPointsArray->Clear() ;
118 delete fRecPointsArray ;
122 //__________________________________________________________________
123 AliQADataMakerRec& AliQADataMakerRec::operator = (const AliQADataMakerRec& qadm )
125 // Assignment operator.
126 this->~AliQADataMakerRec();
127 new(this) AliQADataMakerRec(qadm);
131 //____________________________________________________________________________
132 void AliQADataMakerRec::EndOfCycle()
134 // Finishes a cycle of QA for all the tasks
135 EndOfCycle(AliQAv1::kRAWS) ;
136 EndOfCycle(AliQAv1::kDIGITSR) ;
137 EndOfCycle(AliQAv1::kRECPOINTS) ;
138 EndOfCycle(AliQAv1::kESDS) ;
142 //____________________________________________________________________________
143 void AliQADataMakerRec::EndOfCycle(AliQAv1::TASKINDEX_t task)
145 // Finishes a cycle of QA
148 TObjArray ** list = NULL ;
150 if ( task == AliQAv1::kRAWS )
152 else if ( task == AliQAv1::kDIGITSR )
153 list = fDigitsQAList ;
154 else if ( task == AliQAv1::kRECPOINTS )
155 list = fRecPointsQAList ;
156 else if ( task == AliQAv1::kESDS )
160 if ( ! list && ! fCorrNt )
162 //DefaultEndOfDetectorCycle(task) ;
163 EndOfDetectorCycle(task, list) ;
165 if (! AliQAManager::QAManager(AliQAv1::kRECMODE)->IsSaveData())
168 fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
170 fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
171 TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
173 subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
175 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { // skip Default
176 if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie)) || AliRecoParam::ConvertIndex(specie) == AliRecoParam::kDefault)
178 TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
180 eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ;
181 eventSpecieDir->cd() ;
184 TIter next(list[specie]) ;
186 while( (obj = next()) ) {
187 if (!obj->TestBit(AliQAv1::GetExpertBit()))
191 TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
193 expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
196 while( (obj = next()) ) {
197 if (!obj->TestBit(AliQAv1::GetExpertBit()))
204 else if ( fCorrNt ) {
205 if (fCorrNt[specie] && AliQAv1::GetDetIndex(GetName()) == AliQAv1::kCORR) {
206 if (fCorrNt[specie]->GetNvar() != 0) {
207 eventSpecieDir->cd() ;
208 fCorrNt[specie]->Write() ;
216 //____________________________________________________________________________
217 void AliQADataMakerRec::Exec(AliQAv1::TASKINDEX_t task, TObject * data)
219 // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
221 if ( task == AliQAv1::kRAWS ) {
222 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Raws QA") ;
223 AliRawReader * rawReader = static_cast<AliRawReader *>(data) ;
225 MakeRaws(rawReader) ;
227 AliDebug(AliQAv1::GetQADebugLevel(), "Raw data are not processed") ;
228 } else if ( task == AliQAv1::kDIGITSR ) {
229 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Digits QA") ;
230 TTree * tree = static_cast<TTree *>(data) ;
231 if (strcmp(tree->ClassName(), "TTree") == 0) {
234 AliWarning("data are not a TTree") ;
236 } else if ( task == AliQAv1::kRECPOINTS ) {
237 AliDebug(AliQAv1::GetQADebugLevel(), "Processing RecPoints QA") ;
238 TTree * tree = static_cast<TTree *>(data) ;
239 if (strcmp(tree->ClassName(), "TTree") == 0) {
240 MakeRecPoints(tree) ;
242 AliWarning("data are not a TTree") ;
244 } else if ( task == AliQAv1::kESDS ) {
245 AliDebug(AliQAv1::GetQADebugLevel(), "Processing ESDs QA") ;
246 AliESDEvent * esd = static_cast<AliESDEvent *>(data) ;
247 if (strcmp(esd->ClassName(), "AliESDEvent") == 0)
250 AliError("Wrong type of esd container") ;
254 //____________________________________________________________________________
255 TObjArray ** AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, Int_t cycles)
257 // general intialisation
259 TObjArray ** rv = NULL ;
264 if ( task == AliQAv1::kRAWS ) {
265 if (! fRawsQAList ) {
266 fRawsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
267 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
268 fRawsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
269 fRawsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
273 } else if ( task == AliQAv1::kDIGITSR ) {
274 if ( ! fDigitsQAList ) {
275 fDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
276 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
277 fDigitsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
278 fDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
282 } else if ( task == AliQAv1::kRECPOINTS ) {
283 if ( ! fRecPointsQAList ) {
284 fRecPointsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
285 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
286 fRecPointsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
287 fRecPointsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
290 rv = fRecPointsQAList ;
291 } else if ( task == AliQAv1::kESDS ) {
292 if ( ! fESDsQAList ) {
293 fESDsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
294 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
295 fESDsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
296 fESDsQAList[specie]->SetName(Form("%s_%s", GetName(), AliQAv1::GetTaskName(task).Data())); //, AliRecoParam::GetEventSpecieName(specie))) ;
304 //____________________________________________________________________________
305 void AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles)
307 // Intialisation by passing the list of QA data booked elsewhere
314 if ( task == AliQAv1::kRAWS ) {
316 } else if ( task == AliQAv1::kDIGITSR ) {
317 fDigitsQAList = list ;
318 } else if ( task == AliQAv1::kRECPOINTS ) {
319 fRecPointsQAList = list ;
320 } else if ( task == AliQAv1::kESDS ) {
325 //____________________________________________________________________________
326 void AliQADataMakerRec::InitRecoParams()
328 // Get the recoparam form the OCDB
330 AliDebug(AliQAv1::GetQADebugLevel(), Form("Loading reconstruction parameter objects for detector %s", GetName()));
331 AliCDBPath path(GetName(),"Calib","RecoParam");
332 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
335 AliDebug(AliQAv1::GetQADebugLevel(), Form("Couldn't find RecoParam entry in OCDB for detector %s",GetName()));
338 TObject * recoParamObj = entry->GetObject() ;
339 if ( strcmp(recoParamObj->ClassName(), "TObjArray") == 0 ) {
340 // The detector has only one set of reco parameters
341 AliDebug(AliQAv1::GetQADebugLevel(), Form("Array of reconstruction parameters found for detector %s",GetName()));
342 TObjArray *recoParamArray = static_cast<TObjArray*>(recoParamObj) ;
343 for (Int_t iRP=0; iRP<recoParamArray->GetEntriesFast(); iRP++) {
344 fRecoParam = static_cast<AliDetectorRecoParam*>(recoParamArray->At(iRP)) ;
347 else if (fRecoParam->IsDefault())
351 else if (recoParamObj->InheritsFrom("AliDetectorRecoParam")) {
352 // The detector has only one set of reco parameters
353 // Registering it in AliRecoParam
354 AliDebug(AliQAv1::GetQADebugLevel(), Form("Single set of reconstruction parameters found for detector %s",GetName()));
355 fRecoParam = static_cast<AliDetectorRecoParam*>(recoParamObj) ;
356 static_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
358 AliError(Form("No valid RecoParam object found in the OCDB for detector %s",GetName()));
364 //____________________________________________________________________________
365 void AliQADataMakerRec::ResetDetector(AliQAv1::TASKINDEX_t task)
367 // default reset that resets all the QA objects.
368 // to be overloaded by detectors, if necessary
370 TObjArray ** list = NULL ;
371 if ( task == AliQAv1::kRAWS ) {
373 } else if ( task == AliQAv1::kDIGITSR ) {
374 list = fDigitsQAList ;
375 } else if ( task == AliQAv1::kRECPOINTS ) {
376 list = fRecPointsQAList ;
377 } else if ( task == AliQAv1::kESDS ) {
380 //list was not initialized, skip
384 for (int spec = 0; spec < AliRecoParam::kNSpecies; spec++) {
385 if (!AliQAv1::Instance()->IsEventSpecieSet(AliRecoParam::ConvertIndex(spec)))
387 TIter next(list[spec]) ;
389 while ( (histo = dynamic_cast<TH1*> (next())) ) {
390 histo->Reset("ICE") ;
391 histo->ResetStats() ;
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() ;