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 ---
31 #include <TObjArray.h>
33 // --- Standard library ---
35 // --- AliRoot header files ---
36 #include "AliCDBPath.h"
37 #include "AliCDBEntry.h"
38 #include "AliDetectorRecoParam.h"
39 #include "AliCDBManager.h"
42 #include "AliQADataMakerRec.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),
59 fDetectorDirName = GetName() ;
62 //____________________________________________________________________________
63 AliQADataMakerRec::AliQADataMakerRec(const AliQADataMakerRec& qadm) :
64 AliQADataMaker(qadm.GetName(), qadm.GetTitle()),
65 fDigitsQAList(qadm.fDigitsQAList),
66 fESDsQAList(qadm.fESDsQAList),
67 fRawsQAList(qadm.fRawsQAList),
68 fRecPointsQAList(qadm.fRecPointsQAList),
69 fCorrNt(qadm.fCorrNt),
70 fRecoParam(qadm.fRecoParam)
73 SetName(qadm.GetName()) ;
74 SetTitle(qadm.GetTitle()) ;
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 if ( fESDsQAList[specie]->IsOwner() )
86 fESDsQAList[specie]->Delete() ;
89 delete[] fESDsQAList ;
92 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
93 if ( fRawsQAList[specie] ) {
94 if ( fRawsQAList[specie]->IsOwner() )
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 if ( fDigitsQAList[specie]->IsOwner() )
104 fDigitsQAList[specie]->Delete() ;
107 delete[] fDigitsQAList ;
109 if ( fRecPointsQAList ) {
110 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
111 if ( fRecPointsQAList[specie] ) {
112 if ( fRecPointsQAList[specie]->IsOwner() )
113 fRecPointsQAList[specie]->Delete() ;
116 delete[] fRecPointsQAList ;
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
145 TObjArray ** list = NULL ;
147 if ( task == AliQAv1::kRAWS )
149 else if ( task == AliQAv1::kDIGITSR )
150 list = fDigitsQAList ;
151 else if ( task == AliQAv1::kRECPOINTS )
152 list = fRecPointsQAList ;
153 else if ( task == AliQAv1::kESDS )
157 if ( ! list && ! fCorrNt )
159 //DefaultEndOfDetectorCycle(task) ;
160 EndOfDetectorCycle(task, list) ;
161 fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
163 fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
164 TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
166 subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
168 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
169 if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie)) )
171 TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
173 eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ;
174 eventSpecieDir->cd() ;
176 TIter next(list[specie]) ;
178 while( (obj = next()) ) {
179 if (!obj->TestBit(AliQAv1::GetExpertBit()))
183 TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
185 expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
188 while( (obj = next()) ) {
189 if (!obj->TestBit(AliQAv1::GetExpertBit()))
197 if (fCorrNt[specie] && AliQAv1::GetDetIndex(GetName()) == AliQAv1::kCORR) {
198 eventSpecieDir->cd() ;
199 fCorrNt[specie]->Write() ;
206 //____________________________________________________________________________
207 void AliQADataMakerRec::MakeImage(AliQAv1::TASKINDEX_t task)
209 // create a drawing of detetor defined histograms
210 TObjArray ** list = NULL ;
217 case AliQAv1::kSDIGITS:
219 case AliQAv1::kDIGITS:
221 case AliQAv1::kDIGITSR:
222 list = fDigitsQAList ;
224 case AliQAv1::kRECPOINTS:
225 list = fRecPointsQAList ;
227 case AliQAv1::kTRACKSEGMENTS:
229 case AliQAv1::kRECPARTICLES:
234 case AliQAv1::kNTASKINDEX:
240 AliError("data not initialized, call AliQADataMaker::Init");
243 MakeTheImage(list, task, "Rec") ;
246 //____________________________________________________________________________
247 void AliQADataMakerRec::Exec(AliQAv1::TASKINDEX_t task, TObject * data)
249 // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
251 if ( task == AliQAv1::kRAWS ) {
252 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Raws QA") ;
253 AliRawReader * rawReader = static_cast<AliRawReader *>(data) ;
255 MakeRaws(rawReader) ;
257 AliDebug(AliQAv1::GetQADebugLevel(), "Raw data are not processed") ;
258 } else if ( task == AliQAv1::kDIGITSR ) {
259 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Digits QA") ;
260 TTree * tree = static_cast<TTree *>(data) ;
261 if (strcmp(tree->ClassName(), "TTree") == 0) {
264 AliWarning("data are not a TTree") ;
266 } else if ( task == AliQAv1::kRECPOINTS ) {
267 AliDebug(AliQAv1::GetQADebugLevel(), "Processing RecPoints QA") ;
268 TTree * tree = static_cast<TTree *>(data) ;
269 if (strcmp(tree->ClassName(), "TTree") == 0) {
270 MakeRecPoints(tree) ;
272 AliWarning("data are not a TTree") ;
274 } else if ( task == AliQAv1::kESDS ) {
275 AliDebug(AliQAv1::GetQADebugLevel(), "Processing ESDs QA") ;
276 AliESDEvent * esd = static_cast<AliESDEvent *>(data) ;
277 if (strcmp(esd->ClassName(), "AliESDEvent") == 0)
280 AliError("Wrong type of esd container") ;
284 //____________________________________________________________________________
285 TObjArray ** AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, Int_t cycles)
287 // general intialisation
289 TObjArray ** rv = NULL ;
294 if ( task == AliQAv1::kRAWS ) {
295 if (! fRawsQAList ) {
296 fRawsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
297 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
298 fRawsQAList[specie] = new TObjArray(1) ;
299 fRawsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
303 } else if ( task == AliQAv1::kDIGITSR ) {
304 if ( ! fDigitsQAList ) {
305 fDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
306 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
307 fDigitsQAList[specie] = new TObjArray(1) ;
308 fDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
312 } else if ( task == AliQAv1::kRECPOINTS ) {
313 if ( ! fRecPointsQAList ) {
314 fRecPointsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
315 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
316 fRecPointsQAList[specie] = new TObjArray(1) ;
317 fRecPointsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
320 rv = fRecPointsQAList ;
321 } else if ( task == AliQAv1::kESDS ) {
322 if ( ! fESDsQAList ) {
323 fESDsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
324 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
325 fESDsQAList[specie] = new TObjArray(1) ;
326 fESDsQAList[specie]->SetName(Form("%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
334 //____________________________________________________________________________
335 void AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles)
337 // Intialisation by passing the list of QA data booked elsewhere
344 if ( task == AliQAv1::kRAWS ) {
346 } else if ( task == AliQAv1::kDIGITSR ) {
347 fDigitsQAList = list ;
348 } else if ( task == AliQAv1::kRECPOINTS ) {
349 fRecPointsQAList = list ;
350 } else if ( task == AliQAv1::kESDS ) {
355 //____________________________________________________________________________
356 void AliQADataMakerRec::InitRecoParams()
359 AliDebug(AliQAv1::GetQADebugLevel(), Form("Loading reconstruction parameter objects for detector %s", GetName()));
360 AliCDBPath path(GetName(),"Calib","RecoParam");
361 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
364 AliWarning(Form("Couldn't find RecoParam entry in OCDB for detector %s",GetName()));
367 TObject * recoParamObj = entry->GetObject() ;
368 if ( strcmp(recoParamObj->ClassName(), "TObjArray") == 0 ) {
369 // The detector has only one set of reco parameters
370 AliDebug(AliQAv1::GetQADebugLevel(), Form("Array of reconstruction parameters found for detector %s",GetName()));
371 TObjArray *recoParamArray = static_cast<TObjArray*>(recoParamObj) ;
372 for (Int_t iRP=0; iRP<recoParamArray->GetEntriesFast(); iRP++) {
373 fRecoParam = static_cast<AliDetectorRecoParam*>(recoParamArray->At(iRP)) ;
376 else if (fRecoParam->IsDefault())
380 else if (recoParamObj->InheritsFrom("AliDetectorRecoParam")) {
381 // The detector has only one set of reco parameters
382 // Registering it in AliRecoParam
383 AliDebug(AliQAv1::GetQADebugLevel(), Form("Single set of reconstruction parameters found for detector %s",GetName()));
384 fRecoParam = static_cast<AliDetectorRecoParam*>(recoParamObj) ;
385 static_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
387 AliError(Form("No valid RecoParam object found in the OCDB for detector %s",GetName()));
390 AliCDBManager::Instance()->UnloadFromCache(path.GetPath());
394 //____________________________________________________________________________
395 void AliQADataMakerRec::StartOfCycle(Int_t run)
397 // Finishes a cycle of QA for all the tasks
398 Bool_t samecycle = kFALSE ;
399 StartOfCycle(AliQAv1::kRAWS, run, samecycle) ;
401 StartOfCycle(AliQAv1::kDIGITSR, run, samecycle) ;
402 StartOfCycle(AliQAv1::kRECPOINTS, run, samecycle) ;
403 StartOfCycle(AliQAv1::kESDS, run, samecycle) ;
406 //____________________________________________________________________________
407 void AliQADataMakerRec::StartOfCycle(AliQAv1::TASKINDEX_t task, Int_t run, const Bool_t sameCycle)
409 // Finishes a cycle of QA data acquistion
412 if ( !sameCycle || fCurrentCycle == -1) {
416 fOutput = AliQAv1::GetQADataFile(GetName(), fRun) ;
418 AliDebug(AliQAv1::GetQADebugLevel(), Form(" Run %d Cycle %d task %s file %s",
419 fRun, fCurrentCycle, AliQAv1::GetTaskName(task).Data(), fOutput->GetName() )) ;
421 // fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
422 // if (!fDetectorDir)
423 // fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
425 // TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
427 // subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
429 // for ( Int_t specie = AliRecoParam::kDefault ; specie < AliRecoParam::kNSpecies ; specie++ ) {
430 // TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
431 // if (!eventSpecieDir)
432 // eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ;
433 // TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
435 // expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
437 StartOfDetectorCycle() ;