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()) return;
167 fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
168 if (!fDetectorDir) fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
169 TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
170 if (!subDir) subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
173 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { // skip Default
174 if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie)) || AliRecoParam::ConvertIndex(specie) == AliRecoParam::kDefault) continue ;
175 TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
176 if (!eventSpecieDir) eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ;
177 eventSpecieDir->cd();
180 TIter next(list[specie]) ;
182 while( (obj = next()) ) {
183 if (!obj->TestBit(AliQAv1::GetExpertBit())) obj->Write(); // RS: Note, this can be also TObjArray of clones
186 TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
188 expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
191 while( (obj = next()) ) {
192 if (!obj->TestBit(AliQAv1::GetExpertBit())) continue;
193 obj->Write(); // RS: Note, this can be also TObjArray of clones
198 else if ( fCorrNt ) {
199 if (fCorrNt[specie] && AliQAv1::GetDetIndex(GetName()) == AliQAv1::kCORR) {
200 if (fCorrNt[specie]->GetNvar() != 0) {
201 eventSpecieDir->cd() ;
202 fCorrNt[specie]->Write() ;
210 //____________________________________________________________________________
211 void AliQADataMakerRec::Exec(AliQAv1::TASKINDEX_t task, TObject * data)
213 // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
215 if ( task == AliQAv1::kRAWS ) {
216 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Raws QA") ;
217 AliRawReader * rawReader = static_cast<AliRawReader *>(data) ;
219 MakeRaws(rawReader) ;
221 AliDebug(AliQAv1::GetQADebugLevel(), "Raw data are not processed") ;
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) {
228 AliWarning("data are not a TTree") ;
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) ;
236 AliWarning("data are not a TTree") ;
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)
244 AliError("Wrong type of esd container") ;
248 //____________________________________________________________________________
249 TObjArray ** AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, Int_t cycles)
251 // general intialisation
253 TObjArray ** rv = NULL ;
258 if ( task == AliQAv1::kRAWS ) {
259 if (! fRawsQAList ) {
260 fRawsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
261 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
262 fRawsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
263 fRawsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
267 } else if ( task == AliQAv1::kDIGITSR ) {
268 if ( ! fDigitsQAList ) {
269 fDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
270 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
271 fDigitsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
272 fDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
276 } else if ( task == AliQAv1::kRECPOINTS ) {
277 if ( ! fRecPointsQAList ) {
278 fRecPointsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
279 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
280 fRecPointsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
281 fRecPointsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
284 rv = fRecPointsQAList ;
285 } else if ( task == AliQAv1::kESDS ) {
286 if ( ! fESDsQAList ) {
287 fESDsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
288 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
289 fESDsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
290 fESDsQAList[specie]->SetName(Form("%s_%s", GetName(), AliQAv1::GetTaskName(task).Data())); //, AliRecoParam::GetEventSpecieName(specie))) ;
298 //____________________________________________________________________________
299 void AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles)
301 // Intialisation by passing the list of QA data booked elsewhere
308 if ( task == AliQAv1::kRAWS ) {
310 } else if ( task == AliQAv1::kDIGITSR ) {
311 fDigitsQAList = list ;
312 } else if ( task == AliQAv1::kRECPOINTS ) {
313 fRecPointsQAList = list ;
314 } else if ( task == AliQAv1::kESDS ) {
319 //____________________________________________________________________________
320 void AliQADataMakerRec::InitRecoParams()
322 // Get the recoparam form the OCDB
324 AliDebug(AliQAv1::GetQADebugLevel(), Form("Loading reconstruction parameter objects for detector %s", GetName()));
325 AliCDBPath path(GetName(),"Calib","RecoParam");
326 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
329 AliDebug(AliQAv1::GetQADebugLevel(), Form("Couldn't find RecoParam entry in OCDB for detector %s",GetName()));
332 // entry->SetOwner(kTRUE);
333 TObject * recoParamObj = entry->GetObject() ;
334 if ( strcmp(recoParamObj->ClassName(), "TObjArray") == 0 ) {
335 // The detector has only one set of reco parameters
336 AliDebug(AliQAv1::GetQADebugLevel(), Form("Array of reconstruction parameters found for detector %s",GetName()));
337 TObjArray *recoParamArray = static_cast<TObjArray*>(recoParamObj) ;
338 // recoParamArray->SetOwner(kTRUE);
339 for (Int_t iRP=0; iRP<recoParamArray->GetEntriesFast(); iRP++) {
340 fRecoParam = static_cast<AliDetectorRecoParam*>(recoParamArray->At(iRP)) ;
343 else if (fRecoParam->IsDefault())
347 else if (recoParamObj->InheritsFrom("AliDetectorRecoParam")) {
348 // The detector has only one set of reco parameters
349 // Registering it in AliRecoParam
350 AliDebug(AliQAv1::GetQADebugLevel(), Form("Single set of reconstruction parameters found for detector %s",GetName()));
351 fRecoParam = static_cast<AliDetectorRecoParam*>(recoParamObj) ;
352 static_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
354 AliError(Form("No valid RecoParam object found in the OCDB for detector %s",GetName()));
360 //____________________________________________________________________________
361 void AliQADataMakerRec::ResetDetector(AliQAv1::TASKINDEX_t task)
363 // default reset that resets all the QA objects.
364 // to be overloaded by detectors, if necessary
366 TObjArray ** list = NULL ;
367 if ( task == AliQAv1::kRAWS ) {
369 } else if ( task == AliQAv1::kDIGITSR ) {
370 list = fDigitsQAList ;
371 } else if ( task == AliQAv1::kRECPOINTS ) {
372 list = fRecPointsQAList ;
373 } else if ( task == AliQAv1::kESDS ) {
376 //list was not initialized, skip
379 for (int spec = 0; spec < AliRecoParam::kNSpecies; spec++) {
380 if (!AliQAv1::Instance()->IsEventSpecieSet(AliRecoParam::ConvertIndex(spec))) continue;
381 TIter next(list[spec]) ;
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);
394 ((TH1*)obj)->Reset("ICE");
395 ((TH1*)obj)->ResetStats();
398 ResetEvCountCycle(AliRecoParam::ConvertIndex(spec));
399 ResetEvCountTotal(AliRecoParam::ConvertIndex(spec));
403 //____________________________________________________________________________
404 void AliQADataMakerRec::StartOfCycle(Int_t run)
406 // Finishes a cycle of QA for all the tasks
407 Bool_t samecycle = kFALSE ;
408 StartOfCycle(AliQAv1::kRAWS, run, samecycle) ;
410 StartOfCycle(AliQAv1::kDIGITSR, run, samecycle) ;
411 StartOfCycle(AliQAv1::kRECPOINTS, run, samecycle) ;
412 StartOfCycle(AliQAv1::kESDS, run, samecycle) ;
415 //____________________________________________________________________________
416 void AliQADataMakerRec::StartOfCycle(AliQAv1::TASKINDEX_t task, Int_t run, const Bool_t sameCycle)
418 // Finishes a cycle of QA data acquistion
419 if ( run > 0 ) fRun = run ;
420 if ( !sameCycle || fCurrentCycle == -1) {
424 if (AliQAManager::QAManager(AliQAv1::kRECMODE)->IsSaveData())
425 fOutput = AliQAv1::GetQADataFile(GetName(), fRun) ;
427 AliDebug(AliQAv1::GetQADebugLevel(), Form(" Run %d Cycle %d task %s file %s",
428 fRun, fCurrentCycle, AliQAv1::GetTaskName(task).Data(), fOutput->GetName() )) ;
430 // fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
431 // if (!fDetectorDir)
432 // fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
434 // TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
436 // subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
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()) ;
444 // expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
446 StartOfDetectorCycle();
450 //____________________________________________________________________________
451 void AliQADataMakerRec::ClonePerTrigClass(AliQAv1::TASKINDEX_t task)
453 // clone the histos of the array corresponding to task
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;