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 fDetectorDirName = GetName() ;
78 //____________________________________________________________________________
79 AliQADataMakerRec::~AliQADataMakerRec()
81 //dtor: delete the TObjArray and thei content
83 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
84 if ( fESDsQAList[specie] ) {
85 fESDsQAList[specie]->Delete() ;
88 delete[] fESDsQAList ;
91 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
92 if ( fRawsQAList[specie] ) {
93 fRawsQAList[specie]->Delete() ;
96 delete[] fRawsQAList ;
98 if ( fDigitsQAList ) {
99 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
100 if ( fDigitsQAList[specie] ) {
101 fDigitsQAList[specie]->Delete() ;
104 delete[] fDigitsQAList ;
106 if ( fRecPointsQAList ) {
107 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
108 if ( fRecPointsQAList[specie] ) {
109 fRecPointsQAList[specie]->Delete() ;
112 delete[] fRecPointsQAList ;
114 if (fRecPointsArray) {
115 fRecPointsArray->Clear() ;
116 delete fRecPointsArray ;
120 //__________________________________________________________________
121 AliQADataMakerRec& AliQADataMakerRec::operator = (const AliQADataMakerRec& qadm )
123 // Assignment operator.
124 this->~AliQADataMakerRec();
125 new(this) AliQADataMakerRec(qadm);
129 //____________________________________________________________________________
130 void AliQADataMakerRec::EndOfCycle()
132 // Finishes a cycle of QA for all the tasks
133 EndOfCycle(AliQAv1::kRAWS) ;
134 EndOfCycle(AliQAv1::kDIGITSR) ;
135 EndOfCycle(AliQAv1::kRECPOINTS) ;
136 EndOfCycle(AliQAv1::kESDS) ;
140 //____________________________________________________________________________
141 void AliQADataMakerRec::EndOfCycle(AliQAv1::TASKINDEX_t task)
143 // Finishes a cycle of QA
146 TObjArray ** list = NULL ;
148 if ( task == AliQAv1::kRAWS )
150 else if ( task == AliQAv1::kDIGITSR )
151 list = fDigitsQAList ;
152 else if ( task == AliQAv1::kRECPOINTS )
153 list = fRecPointsQAList ;
154 else if ( task == AliQAv1::kESDS )
158 if ( ! list && ! fCorrNt )
160 //DefaultEndOfDetectorCycle(task) ;
161 EndOfDetectorCycle(task, list) ;
163 if (! AliQAManager::QAManager(AliQAv1::kRECMODE)->IsSaveData()) return;
165 fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
166 if (!fDetectorDir) fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
167 TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
168 if (!subDir) subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
171 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { // skip Default
172 if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie)) || AliRecoParam::ConvertIndex(specie) == AliRecoParam::kDefault) continue ;
173 TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
174 if (!eventSpecieDir) eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ;
175 eventSpecieDir->cd();
178 TIter next(list[specie]) ;
180 while( (obj = next()) ) {
181 if (!obj->TestBit(AliQAv1::GetExpertBit())) obj->Write(); // RS: Note, this can be also TObjArray of clones
184 TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
186 expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
189 while( (obj = next()) ) {
190 if (!obj->TestBit(AliQAv1::GetExpertBit())) continue;
191 obj->Write(); // RS: Note, this can be also TObjArray of clones
196 else if ( fCorrNt ) {
197 if (fCorrNt[specie] && AliQAv1::GetDetIndex(GetName()) == AliQAv1::kCORR) {
198 if (fCorrNt[specie]->GetNvar() != 0) {
199 eventSpecieDir->cd() ;
200 fCorrNt[specie]->Write() ;
208 //____________________________________________________________________________
209 void AliQADataMakerRec::Exec(AliQAv1::TASKINDEX_t task, TObject * data)
211 // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
213 if ( task == AliQAv1::kRAWS ) {
214 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Raws QA") ;
215 AliRawReader * rawReader = static_cast<AliRawReader *>(data) ;
217 MakeRaws(rawReader) ;
219 AliDebug(AliQAv1::GetQADebugLevel(), "Raw data are not processed") ;
220 } else if ( task == AliQAv1::kDIGITSR ) {
221 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Digits QA") ;
222 TTree * tree = static_cast<TTree *>(data) ;
223 if (strcmp(tree->ClassName(), "TTree") == 0) {
226 AliWarning("data are not a TTree") ;
228 } else if ( task == AliQAv1::kRECPOINTS ) {
229 AliDebug(AliQAv1::GetQADebugLevel(), "Processing RecPoints QA") ;
230 TTree * tree = static_cast<TTree *>(data) ;
231 if (strcmp(tree->ClassName(), "TTree") == 0) {
232 MakeRecPoints(tree) ;
234 AliWarning("data are not a TTree") ;
236 } else if ( task == AliQAv1::kESDS ) {
237 AliDebug(AliQAv1::GetQADebugLevel(), "Processing ESDs QA") ;
238 AliESDEvent * esd = static_cast<AliESDEvent *>(data) ;
239 if (strcmp(esd->ClassName(), "AliESDEvent") == 0)
242 AliError("Wrong type of esd container") ;
246 //____________________________________________________________________________
247 TObjArray ** AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, Int_t cycles)
249 // general intialisation
251 TObjArray ** rv = NULL ;
256 if ( task == AliQAv1::kRAWS ) {
257 if (! fRawsQAList ) {
258 fRawsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
259 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
260 fRawsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
261 fRawsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
265 } else if ( task == AliQAv1::kDIGITSR ) {
266 if ( ! fDigitsQAList ) {
267 fDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
268 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
269 fDigitsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
270 fDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
274 } else if ( task == AliQAv1::kRECPOINTS ) {
275 if ( ! fRecPointsQAList ) {
276 fRecPointsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
277 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
278 fRecPointsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
279 fRecPointsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
282 rv = fRecPointsQAList ;
283 } else if ( task == AliQAv1::kESDS ) {
284 if ( ! fESDsQAList ) {
285 fESDsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
286 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
287 fESDsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
288 fESDsQAList[specie]->SetName(Form("%s_%s", GetName(), AliQAv1::GetTaskName(task).Data())); //, AliRecoParam::GetEventSpecieName(specie))) ;
296 //____________________________________________________________________________
297 void AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles)
299 // Intialisation by passing the list of QA data booked elsewhere
306 if ( task == AliQAv1::kRAWS ) {
308 } else if ( task == AliQAv1::kDIGITSR ) {
309 fDigitsQAList = list ;
310 } else if ( task == AliQAv1::kRECPOINTS ) {
311 fRecPointsQAList = list ;
312 } else if ( task == AliQAv1::kESDS ) {
317 //____________________________________________________________________________
318 void AliQADataMakerRec::InitRecoParams()
320 // Get the recoparam form the OCDB
322 AliDebug(AliQAv1::GetQADebugLevel(), Form("Loading reconstruction parameter objects for detector %s", GetName()));
323 AliCDBPath path(GetName(),"Calib","RecoParam");
324 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
327 AliDebug(AliQAv1::GetQADebugLevel(), Form("Couldn't find RecoParam entry in OCDB for detector %s",GetName()));
330 // entry->SetOwner(kTRUE);
331 TObject * recoParamObj = entry->GetObject() ;
332 if ( strcmp(recoParamObj->ClassName(), "TObjArray") == 0 ) {
333 // The detector has only one set of reco parameters
334 AliDebug(AliQAv1::GetQADebugLevel(), Form("Array of reconstruction parameters found for detector %s",GetName()));
335 TObjArray *recoParamArray = static_cast<TObjArray*>(recoParamObj) ;
336 // recoParamArray->SetOwner(kTRUE);
337 for (Int_t iRP=0; iRP<recoParamArray->GetEntriesFast(); iRP++) {
338 fRecoParam = static_cast<AliDetectorRecoParam*>(recoParamArray->At(iRP)) ;
341 else if (fRecoParam->IsDefault())
345 else if (recoParamObj->InheritsFrom("AliDetectorRecoParam")) {
346 // The detector has only one set of reco parameters
347 // Registering it in AliRecoParam
348 AliDebug(AliQAv1::GetQADebugLevel(), Form("Single set of reconstruction parameters found for detector %s",GetName()));
349 fRecoParam = static_cast<AliDetectorRecoParam*>(recoParamObj) ;
350 static_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
352 AliError(Form("No valid RecoParam object found in the OCDB for detector %s",GetName()));
358 //____________________________________________________________________________
359 void AliQADataMakerRec::ResetDetector(AliQAv1::TASKINDEX_t task)
361 // default reset that resets all the QA objects.
362 // to be overloaded by detectors, if necessary
364 TObjArray ** list = NULL ;
365 if ( task == AliQAv1::kRAWS ) {
367 } else if ( task == AliQAv1::kDIGITSR ) {
368 list = fDigitsQAList ;
369 } else if ( task == AliQAv1::kRECPOINTS ) {
370 list = fRecPointsQAList ;
371 } else if ( task == AliQAv1::kESDS ) {
374 //list was not initialized, skip
377 for (int spec = 0; spec < AliRecoParam::kNSpecies; spec++) {
378 if (!AliQAv1::Instance()->IsEventSpecieSet(AliRecoParam::ConvertIndex(spec))) continue;
379 TIter next(list[spec]) ;
381 while ( (obj = next()) ) {
382 if (obj->TestBit(AliQAv1::GetClonedBit())) { // this is array of cloned histos
383 TObjArray* arr = (TObjArray*)obj;
384 for (int ih=arr->GetEntriesFast();ih--;) {
385 TH1* histo = (TH1*)arr->At(ih);
386 if (!histo) continue;
392 ((TH1*)obj)->Reset("ICE");
393 ((TH1*)obj)->ResetStats();
396 ResetEvCountCycle(AliRecoParam::ConvertIndex(spec));
397 ResetEvCountTotal(AliRecoParam::ConvertIndex(spec));
401 //____________________________________________________________________________
402 void AliQADataMakerRec::StartOfCycle(Int_t run)
404 // Finishes a cycle of QA for all the tasks
405 Bool_t samecycle = kFALSE ;
406 StartOfCycle(AliQAv1::kRAWS, run, samecycle) ;
408 StartOfCycle(AliQAv1::kDIGITSR, run, samecycle) ;
409 StartOfCycle(AliQAv1::kRECPOINTS, run, samecycle) ;
410 StartOfCycle(AliQAv1::kESDS, run, samecycle) ;
413 //____________________________________________________________________________
414 void AliQADataMakerRec::StartOfCycle(AliQAv1::TASKINDEX_t task, Int_t run, const Bool_t sameCycle)
416 // Finishes a cycle of QA data acquistion
417 if ( run > 0 ) fRun = run ;
418 if ( !sameCycle || fCurrentCycle == -1) {
422 if (AliQAManager::QAManager(AliQAv1::kRECMODE)->IsSaveData())
423 fOutput = AliQAv1::GetQADataFile(GetName(), fRun) ;
425 if (AliQAManager::QAManager(AliQAv1::kRECMODE)->IsSaveData())
426 AliDebug(AliQAv1::GetQADebugLevel(), Form(" Run %d Cycle %d task %s file %s",
427 fRun, fCurrentCycle, AliQAv1::GetTaskName(task).Data(), fOutput->GetName() )) ;
429 AliDebug(AliQAv1::GetQADebugLevel(), Form(" Run %d Cycle %d task %s not saved",
430 fRun, fCurrentCycle, AliQAv1::GetTaskName(task).Data() )) ;
432 // fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
433 // if (!fDetectorDir)
434 // fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
436 // TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
438 // subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
440 // for ( Int_t specie = AliRecoParam::kDefault ; specie < AliRecoParam::kNSpecies ; specie++ ) {
441 // TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
442 // if (!eventSpecieDir)
443 // eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ;
444 // TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
446 // expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
448 StartOfDetectorCycle();
452 //____________________________________________________________________________
453 void AliQADataMakerRec::ClonePerTrigClass(AliQAv1::TASKINDEX_t task)
455 // clone the histos of the array corresponding to task
458 case AliQAv1::kRAWS : ClonePerTrigClassL(fRawsQAList, task); break;
459 case AliQAv1::kDIGITS : ClonePerTrigClassL(fDigitsQAList, task); break;
460 case AliQAv1::kRECPOINTS : ClonePerTrigClassL(fRecPointsQAList, task); break;
461 case AliQAv1::kESDS : ClonePerTrigClassL(fESDsQAList, task); break;
462 default : AliError(Form("Task %s is invalid in this context", AliQAv1::GetTaskName(task).Data() )); break;