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 "AliESDEvent.h"
43 #include "AliRawReader.h"
45 ClassImp(AliQADataMakerRec)
47 //____________________________________________________________________________
48 AliQADataMakerRec::AliQADataMakerRec(const char * name, const char * title) :
49 AliQADataMaker(name, title),
52 fRecPointsQAList(NULL),
57 fDetectorDirName = GetName() ;
60 //____________________________________________________________________________
61 AliQADataMakerRec::AliQADataMakerRec(const AliQADataMakerRec& qadm) :
62 AliQADataMaker(qadm.GetName(), qadm.GetTitle()),
63 fESDsQAList(qadm.fESDsQAList),
64 fRawsQAList(qadm.fRawsQAList),
65 fRecPointsQAList(qadm.fRecPointsQAList),
66 fCorrNt(qadm.fCorrNt),
67 fRecoParam(qadm.fRecoParam)
70 SetName(qadm.GetName()) ;
71 SetTitle(qadm.GetTitle()) ;
72 fDetectorDirName = GetName() ;
75 //____________________________________________________________________________
76 AliQADataMakerRec::~AliQADataMakerRec()
78 //dtor: delete the TObjArray and thei content
80 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
81 if ( fESDsQAList[specie] ) {
82 if ( fESDsQAList[specie]->IsOwner() )
83 fESDsQAList[specie]->Delete() ;
86 delete[] fESDsQAList ;
89 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
90 if ( fRawsQAList[specie] ) {
91 if ( fRawsQAList[specie]->IsOwner() )
92 fRawsQAList[specie]->Delete() ;
95 delete[] fRawsQAList ;
97 if ( fRecPointsQAList ) {
98 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
99 if ( fRecPointsQAList[specie] ) {
100 if ( fRecPointsQAList[specie]->IsOwner() )
101 fRecPointsQAList[specie]->Delete() ;
104 delete[] fRecPointsQAList ;
108 //__________________________________________________________________
109 AliQADataMakerRec& AliQADataMakerRec::operator = (const AliQADataMakerRec& qadm )
111 // Assignment operator.
112 this->~AliQADataMakerRec();
113 new(this) AliQADataMakerRec(qadm);
117 //____________________________________________________________________________
118 void AliQADataMakerRec::EndOfCycle()
120 // Finishes a cycle of QA for all the tasks
121 EndOfCycle(AliQA::kRAWS) ;
122 EndOfCycle(AliQA::kRECPOINTS) ;
123 EndOfCycle(AliQA::kESDS) ;
127 //____________________________________________________________________________
128 void AliQADataMakerRec::EndOfCycle(AliQA::TASKINDEX_t task)
130 // Finishes a cycle of QA
132 TObjArray ** list = NULL ;
134 if ( task == AliQA::kRAWS )
136 else if ( task == AliQA::kRECPOINTS )
137 list = fRecPointsQAList ;
138 else if ( task == AliQA::kESDS )
142 if ( ! list && ! fCorrNt )
144 //DefaultEndOfDetectorCycle(task) ;
145 EndOfDetectorCycle(task, list) ;
146 TDirectory * subDir = NULL ;
148 subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ;
151 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
152 TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
153 if (eventSpecieDir) {
154 eventSpecieDir->cd() ;
156 TIter next(list[specie]) ;
158 while( (obj = next()) ) {
159 if (!obj->TestBit(AliQA::GetExpertBit()))
163 TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQA::GetExpert()) ;
164 if ( expertDir ) { // Write only if requested
167 while( (obj = next()) ) {
168 if (!obj->TestBit(AliQA::GetExpertBit()))
177 if (fCorrNt[specie] && AliQA::GetDetIndex(GetName()) == AliQA::kCORR) {
178 eventSpecieDir->cd() ;
179 fCorrNt[specie]->Write() ;
187 //____________________________________________________________________________
188 void AliQADataMakerRec::Exec(AliQA::TASKINDEX_t task, TObject * data)
190 // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
192 if ( task == AliQA::kRAWS ) {
193 AliDebug(1, "Processing Raws QA") ;
194 AliRawReader * rawReader = dynamic_cast<AliRawReader *>(data) ;
196 MakeRaws(rawReader) ;
198 AliInfo("Raw data are not processed") ;
199 } else if ( task == AliQA::kRECPOINTS ) {
200 AliDebug(1, "Processing RecPoints QA") ;
201 TTree * tree = dynamic_cast<TTree *>(data) ;
203 MakeRecPoints(tree) ;
205 AliWarning("data are not a TTree") ;
207 } else if ( task == AliQA::kESDS ) {
208 AliDebug(1, "Processing ESDs QA") ;
209 AliESDEvent * esd = dynamic_cast<AliESDEvent *>(data) ;
213 AliError("Wrong type of esd container") ;
217 //____________________________________________________________________________
218 TObjArray ** AliQADataMakerRec::Init(AliQA::TASKINDEX_t task, Int_t cycles)
220 // general intialisation
222 TObjArray ** rv = NULL ;
227 if ( task == AliQA::kRAWS ) {
228 if (! fRawsQAList ) {
229 fRawsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
230 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
231 fRawsQAList[specie] = new TObjArray(100) ;
232 fRawsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
237 } else if ( task == AliQA::kRECPOINTS ) {
238 if ( ! fRecPointsQAList ) {
239 fRecPointsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
240 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
241 fRecPointsQAList[specie] = new TObjArray(100) ;
242 fRecPointsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
246 rv = fRecPointsQAList ;
247 } else if ( task == AliQA::kESDS ) {
248 if ( ! fESDsQAList ) {
249 fESDsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
250 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
251 fESDsQAList[specie] = new TObjArray(100) ;
252 fESDsQAList[specie]->SetName(Form("%s_%s", GetName(), AliQA::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
261 //____________________________________________________________________________
262 void AliQADataMakerRec::Init(AliQA::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles)
264 // Intialisation by passing the list of QA data booked elsewhere
271 if ( task == AliQA::kRAWS ) {
273 } else if ( task == AliQA::kRECPOINTS ) {
274 fRecPointsQAList = list ;
275 } else if ( task == AliQA::kESDS ) {
280 //____________________________________________________________________________
281 void AliQADataMakerRec::InitRecoParams()
284 AliInfo(Form("Loading reconstruction parameter objects for detector %s", GetName()));
285 AliCDBPath path(GetName(),"Calib","RecoParam");
286 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
289 AliWarning(Form("Couldn't find RecoParam entry in OCDB for detector %s",GetName()));
292 TObject * recoParamObj = entry->GetObject() ;
293 if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
294 // The detector has only onse set of reco parameters
295 // Registering it in AliRecoParam
296 AliInfo(Form("Single set of reconstruction parameters found for detector %s",GetName()));
297 dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
298 fRecoParam = dynamic_cast<AliDetectorRecoParam*>(recoParamObj) ;
300 AliError(Form("No valid RecoParam object found in the OCDB for detector %s",GetName()));
306 //____________________________________________________________________________
307 void AliQADataMakerRec::StartOfCycle(Int_t run)
309 // Finishes a cycle of QA for all the tasks
310 Bool_t samecycle = kFALSE ;
311 StartOfCycle(AliQA::kRAWS, run, samecycle) ;
313 StartOfCycle(AliQA::kRECPOINTS, run, samecycle) ;
314 StartOfCycle(AliQA::kESDS, run, samecycle) ;
317 //____________________________________________________________________________
318 void AliQADataMakerRec::StartOfCycle(AliQA::TASKINDEX_t task, Int_t run, const Bool_t sameCycle)
320 // Finishes a cycle of QA data acquistion
323 if ( !sameCycle || fCurrentCycle == -1) {
327 fOutput = AliQA::GetQADataFile(GetName(), fRun) ;
329 AliInfo(Form(" Run %d Cycle %d task %s file %s",
330 fRun, fCurrentCycle, AliQA::GetTaskName(task).Data(), fOutput->GetName() )) ;
332 fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
334 fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
336 TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ;
338 subDir = fDetectorDir->mkdir(AliQA::GetTaskName(task)) ;
340 for ( Int_t specie = AliRecoParam::kDefault ; specie < AliRecoParam::kNSpecies ; specie++ ) {
341 TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
343 eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ;
344 TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQA::GetExpert()) ;
346 expertDir = eventSpecieDir->mkdir(AliQA::GetExpert()) ;
348 StartOfDetectorCycle() ;