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
151 TObjArray ** list = NULL ;
153 if ( task == AliQAv1::kRAWS )
155 else if ( task == AliQAv1::kDIGITSR )
156 list = fDigitsQAList ;
157 else if ( task == AliQAv1::kRECPOINTS )
158 list = fRecPointsQAList ;
159 else if ( task == AliQAv1::kESDS )
163 if ( ! list && ! fCorrNt )
165 //DefaultEndOfDetectorCycle(task) ;
166 EndOfDetectorCycle(task, list) ;
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 eventSpecieDir->cd() ;
207 fCorrNt[specie]->Write() ;
214 //____________________________________________________________________________
215 void AliQADataMakerRec::Exec(AliQAv1::TASKINDEX_t task, TObject * data)
217 // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
219 if ( task == AliQAv1::kRAWS ) {
220 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Raws QA") ;
221 AliRawReader * rawReader = static_cast<AliRawReader *>(data) ;
223 MakeRaws(rawReader) ;
225 AliDebug(AliQAv1::GetQADebugLevel(), "Raw data are not processed") ;
226 } else if ( task == AliQAv1::kDIGITSR ) {
227 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Digits QA") ;
228 TTree * tree = static_cast<TTree *>(data) ;
229 if (strcmp(tree->ClassName(), "TTree") == 0) {
232 AliWarning("data are not a TTree") ;
234 } else if ( task == AliQAv1::kRECPOINTS ) {
235 AliDebug(AliQAv1::GetQADebugLevel(), "Processing RecPoints QA") ;
236 TTree * tree = static_cast<TTree *>(data) ;
237 if (strcmp(tree->ClassName(), "TTree") == 0) {
238 MakeRecPoints(tree) ;
240 AliWarning("data are not a TTree") ;
242 } else if ( task == AliQAv1::kESDS ) {
243 AliDebug(AliQAv1::GetQADebugLevel(), "Processing ESDs QA") ;
244 AliESDEvent * esd = static_cast<AliESDEvent *>(data) ;
245 if (strcmp(esd->ClassName(), "AliESDEvent") == 0)
248 AliError("Wrong type of esd container") ;
252 //____________________________________________________________________________
253 TObjArray ** AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, Int_t cycles)
255 // general intialisation
257 TObjArray ** rv = NULL ;
262 if ( task == AliQAv1::kRAWS ) {
263 if (! fRawsQAList ) {
264 fRawsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
265 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
266 fRawsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
267 fRawsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
271 } else if ( task == AliQAv1::kDIGITSR ) {
272 if ( ! fDigitsQAList ) {
273 fDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
274 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
275 fDigitsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
276 fDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
280 } else if ( task == AliQAv1::kRECPOINTS ) {
281 if ( ! fRecPointsQAList ) {
282 fRecPointsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
283 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
284 fRecPointsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
285 fRecPointsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
288 rv = fRecPointsQAList ;
289 } else if ( task == AliQAv1::kESDS ) {
290 if ( ! fESDsQAList ) {
291 fESDsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
292 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
293 fESDsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
294 fESDsQAList[specie]->SetName(Form("%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
302 //____________________________________________________________________________
303 void AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles)
305 // Intialisation by passing the list of QA data booked elsewhere
312 if ( task == AliQAv1::kRAWS ) {
314 } else if ( task == AliQAv1::kDIGITSR ) {
315 fDigitsQAList = list ;
316 } else if ( task == AliQAv1::kRECPOINTS ) {
317 fRecPointsQAList = list ;
318 } else if ( task == AliQAv1::kESDS ) {
323 //____________________________________________________________________________
324 void AliQADataMakerRec::InitRecoParams()
327 AliDebug(AliQAv1::GetQADebugLevel(), Form("Loading reconstruction parameter objects for detector %s", GetName()));
328 AliCDBPath path(GetName(),"Calib","RecoParam");
329 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
332 AliDebug(AliQAv1::GetQADebugLevel(), Form("Couldn't find RecoParam entry in OCDB for detector %s",GetName()));
335 TObject * recoParamObj = entry->GetObject() ;
336 if ( strcmp(recoParamObj->ClassName(), "TObjArray") == 0 ) {
337 // The detector has only one set of reco parameters
338 AliDebug(AliQAv1::GetQADebugLevel(), Form("Array of reconstruction parameters found for detector %s",GetName()));
339 TObjArray *recoParamArray = static_cast<TObjArray*>(recoParamObj) ;
340 for (Int_t iRP=0; iRP<recoParamArray->GetEntriesFast(); iRP++) {
341 fRecoParam = static_cast<AliDetectorRecoParam*>(recoParamArray->At(iRP)) ;
344 else if (fRecoParam->IsDefault())
348 else if (recoParamObj->InheritsFrom("AliDetectorRecoParam")) {
349 // The detector has only one set of reco parameters
350 // Registering it in AliRecoParam
351 AliDebug(AliQAv1::GetQADebugLevel(), Form("Single set of reconstruction parameters found for detector %s",GetName()));
352 fRecoParam = static_cast<AliDetectorRecoParam*>(recoParamObj) ;
353 static_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
355 AliError(Form("No valid RecoParam object found in the OCDB for detector %s",GetName()));
361 //____________________________________________________________________________
362 void AliQADataMakerRec::StartOfCycle(Int_t run)
364 // Finishes a cycle of QA for all the tasks
365 Bool_t samecycle = kFALSE ;
366 StartOfCycle(AliQAv1::kRAWS, run, samecycle) ;
368 StartOfCycle(AliQAv1::kDIGITSR, run, samecycle) ;
369 StartOfCycle(AliQAv1::kRECPOINTS, run, samecycle) ;
370 StartOfCycle(AliQAv1::kESDS, run, samecycle) ;
373 //____________________________________________________________________________
374 void AliQADataMakerRec::StartOfCycle(AliQAv1::TASKINDEX_t task, Int_t run, const Bool_t sameCycle)
376 // Finishes a cycle of QA data acquistion
379 if ( !sameCycle || fCurrentCycle == -1) {
383 if (AliQAManager::QAManager(AliQAv1::kRECMODE)->IsSaveData())
384 fOutput = AliQAv1::GetQADataFile(GetName(), fRun) ;
386 AliDebug(AliQAv1::GetQADebugLevel(), Form(" Run %d Cycle %d task %s file %s",
387 fRun, fCurrentCycle, AliQAv1::GetTaskName(task).Data(), fOutput->GetName() )) ;
389 // fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
390 // if (!fDetectorDir)
391 // fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
393 // TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
395 // subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
397 // for ( Int_t specie = AliRecoParam::kDefault ; specie < AliRecoParam::kNSpecies ; specie++ ) {
398 // TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
399 // if (!eventSpecieDir)
400 // eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ;
401 // TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
403 // expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
405 StartOfDetectorCycle() ;