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),
53 fRecPointsQAList(NULL),
58 fDetectorDirName = GetName() ;
61 //____________________________________________________________________________
62 AliQADataMakerRec::AliQADataMakerRec(const AliQADataMakerRec& qadm) :
63 AliQADataMaker(qadm.GetName(), qadm.GetTitle()),
64 fESDsQAList(qadm.fESDsQAList),
65 fRawsQAList(qadm.fRawsQAList),
66 fRecPointsQAList(qadm.fRecPointsQAList),
67 fCorrNt(qadm.fCorrNt),
68 fRecoParam(qadm.fRecoParam)
71 SetName(qadm.GetName()) ;
72 SetTitle(qadm.GetTitle()) ;
73 fDetectorDirName = GetName() ;
76 //____________________________________________________________________________
77 AliQADataMakerRec::~AliQADataMakerRec()
79 //dtor: delete the TObjArray and thei content
81 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
82 if ( fESDsQAList[specie] ) {
83 if ( fESDsQAList[specie]->IsOwner() )
84 fESDsQAList[specie]->Delete() ;
87 delete[] fESDsQAList ;
90 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
91 if ( fRawsQAList[specie] ) {
92 if ( fRawsQAList[specie]->IsOwner() )
93 fRawsQAList[specie]->Delete() ;
96 delete[] fRawsQAList ;
98 if ( fRecPointsQAList ) {
99 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
100 if ( fRecPointsQAList[specie] ) {
101 if ( fRecPointsQAList[specie]->IsOwner() )
102 fRecPointsQAList[specie]->Delete() ;
105 delete[] fRecPointsQAList ;
109 //__________________________________________________________________
110 AliQADataMakerRec& AliQADataMakerRec::operator = (const AliQADataMakerRec& qadm )
112 // Assignment operator.
113 this->~AliQADataMakerRec();
114 new(this) AliQADataMakerRec(qadm);
118 //____________________________________________________________________________
119 void AliQADataMakerRec::EndOfCycle()
121 // Finishes a cycle of QA for all the tasks
122 EndOfCycle(AliQAv1::kRAWS) ;
123 EndOfCycle(AliQAv1::kRECPOINTS) ;
124 EndOfCycle(AliQAv1::kESDS) ;
128 //____________________________________________________________________________
129 void AliQADataMakerRec::EndOfCycle(AliQAv1::TASKINDEX_t task)
131 // Finishes a cycle of QA
133 TObjArray ** list = NULL ;
135 if ( task == AliQAv1::kRAWS )
137 else if ( task == AliQAv1::kRECPOINTS )
138 list = fRecPointsQAList ;
139 else if ( task == AliQAv1::kESDS )
143 if ( ! list && ! fCorrNt )
145 //DefaultEndOfDetectorCycle(task) ;
146 EndOfDetectorCycle(task, list) ;
147 TDirectory * subDir = NULL ;
149 subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
152 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
153 TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
154 if (eventSpecieDir) {
155 eventSpecieDir->cd() ;
157 TIter next(list[specie]) ;
159 while( (obj = next()) ) {
160 if (!obj->TestBit(AliQAv1::GetExpertBit()))
164 TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
165 if ( expertDir ) { // Write only if requested
168 while( (obj = next()) ) {
169 if (!obj->TestBit(AliQAv1::GetExpertBit()))
178 if (fCorrNt[specie] && AliQAv1::GetDetIndex(GetName()) == AliQAv1::kCORR) {
179 eventSpecieDir->cd() ;
180 fCorrNt[specie]->Write() ;
189 //____________________________________________________________________________
190 void AliQADataMakerRec::MakeImage(AliQAv1::TASKINDEX_t task)
192 // create a drawing of detetor defined histograms
193 TObjArray ** list = NULL ;
200 case AliQAv1::kSDIGITS:
202 case AliQAv1::kDIGITS:
204 case AliQAv1::kRECPOINTS:
205 list = fRecPointsQAList ;
207 case AliQAv1::kTRACKSEGMENTS:
209 case AliQAv1::kRECPARTICLES:
214 case AliQAv1::kNTASKINDEX:
220 AliError("data not initialized, call AliQADataMaker::Init");
223 TIter next(list[0]) ;
226 while ( (hdata=dynamic_cast<TH1 *>(next())) ) {
227 if ( hdata->TestBit(AliQAv1::GetImageBit()) )
230 if ( nImages == 0 ) {
231 AliInfo(Form("No histogram will be plotted for %s %s\n", GetName(), AliQAv1::GetTaskName(task).Data())) ;
233 AliInfo(Form("%d histograms will be plotted for %s %s\n", nImages, GetName(), AliQAv1::GetTaskName(task).Data())) ;
236 for (Int_t esIndex = 0 ; esIndex < AliRecoParam::kNSpecies ; esIndex++) {
237 TCanvas * canvasQA = new TCanvas(Form("QA_%s_%s_%s",
239 AliQAv1::GetTaskName(task).Data(),
240 AliRecoParam::GetEventSpecieName(esIndex)),
241 Form("QA control plots for det=%s task=%s eventspecie=%s",
243 AliQAv1::GetTaskName(task).Data(),
244 AliRecoParam::GetEventSpecieName(esIndex)),
246 canvasQA->SetWindowSize(w + (w - canvasQA->GetWw()), h + (h - canvasQA->GetWh())) ;
247 Int_t nx = TMath::Sqrt(nImages) ;
249 if ( nx < TMath::Sqrt(nImages))
251 canvasQA->Divide(nx, ny) ;
252 TIter nexthist(list[esIndex]) ;
256 while ( (hist=dynamic_cast<TH1*>(nexthist())) ) {
257 if(hist->TestBit(AliQAv1::GetImageBit())) {
259 canvasQA->cd(++npad) ;
267 //____________________________________________________________________________
268 void AliQADataMakerRec::Exec(AliQAv1::TASKINDEX_t task, TObject * data)
270 // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
272 if ( task == AliQAv1::kRAWS ) {
273 AliDebug(1, "Processing Raws QA") ;
274 AliRawReader * rawReader = dynamic_cast<AliRawReader *>(data) ;
276 MakeRaws(rawReader) ;
278 AliInfo("Raw data are not processed") ;
279 } else if ( task == AliQAv1::kRECPOINTS ) {
280 AliDebug(1, "Processing RecPoints QA") ;
281 TTree * tree = dynamic_cast<TTree *>(data) ;
283 MakeRecPoints(tree) ;
285 AliWarning("data are not a TTree") ;
287 } else if ( task == AliQAv1::kESDS ) {
288 AliDebug(1, "Processing ESDs QA") ;
289 AliESDEvent * esd = dynamic_cast<AliESDEvent *>(data) ;
293 AliError("Wrong type of esd container") ;
297 //____________________________________________________________________________
298 TObjArray ** AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, Int_t cycles)
300 // general intialisation
302 TObjArray ** rv = NULL ;
307 if ( task == AliQAv1::kRAWS ) {
308 if (! fRawsQAList ) {
309 fRawsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
310 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
311 fRawsQAList[specie] = new TObjArray(100) ;
312 fRawsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
317 } else if ( task == AliQAv1::kRECPOINTS ) {
318 if ( ! fRecPointsQAList ) {
319 fRecPointsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
320 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
321 fRecPointsQAList[specie] = new TObjArray(100) ;
322 fRecPointsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
326 rv = fRecPointsQAList ;
327 } else if ( task == AliQAv1::kESDS ) {
328 if ( ! fESDsQAList ) {
329 fESDsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
330 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
331 fESDsQAList[specie] = new TObjArray(100) ;
332 fESDsQAList[specie]->SetName(Form("%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
341 //____________________________________________________________________________
342 void AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles)
344 // Intialisation by passing the list of QA data booked elsewhere
351 if ( task == AliQAv1::kRAWS ) {
353 } else if ( task == AliQAv1::kRECPOINTS ) {
354 fRecPointsQAList = list ;
355 } else if ( task == AliQAv1::kESDS ) {
360 //____________________________________________________________________________
361 void AliQADataMakerRec::InitRecoParams()
364 AliInfo(Form("Loading reconstruction parameter objects for detector %s", GetName()));
365 AliCDBPath path(GetName(),"Calib","RecoParam");
366 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
369 AliWarning(Form("Couldn't find RecoParam entry in OCDB for detector %s",GetName()));
372 TObject * recoParamObj = entry->GetObject() ;
373 if (dynamic_cast<TObjArray*>(recoParamObj)) {
374 // The detector has only one set of reco parameters
375 AliInfo(Form("Array of reconstruction parameters found for detector %s",GetName()));
376 TObjArray *recoParamArray = dynamic_cast<TObjArray*>(recoParamObj) ;
377 for (Int_t iRP=0; iRP<recoParamArray->GetEntriesFast(); iRP++) {
378 fRecoParam = dynamic_cast<AliDetectorRecoParam*>(recoParamArray->At(iRP)) ;
379 if (fRecoParam->IsDefault()) break;
382 else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
383 // The detector has only onse set of reco parameters
384 // Registering it in AliRecoParam
385 AliInfo(Form("Single set of reconstruction parameters found for detector %s",GetName()));
386 dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
387 fRecoParam = dynamic_cast<AliDetectorRecoParam*>(recoParamObj) ;
389 AliError(Form("No valid RecoParam object found in the OCDB for detector %s",GetName()));
392 AliCDBManager::Instance()->UnloadFromCache(path.GetPath());
396 //____________________________________________________________________________
397 void AliQADataMakerRec::StartOfCycle(Int_t run)
399 // Finishes a cycle of QA for all the tasks
400 Bool_t samecycle = kFALSE ;
401 StartOfCycle(AliQAv1::kRAWS, run, samecycle) ;
403 StartOfCycle(AliQAv1::kRECPOINTS, run, samecycle) ;
404 StartOfCycle(AliQAv1::kESDS, run, samecycle) ;
407 //____________________________________________________________________________
408 void AliQADataMakerRec::StartOfCycle(AliQAv1::TASKINDEX_t task, Int_t run, const Bool_t sameCycle)
410 // Finishes a cycle of QA data acquistion
413 if ( !sameCycle || fCurrentCycle == -1) {
417 fOutput = AliQAv1::GetQADataFile(GetName(), fRun) ;
419 AliInfo(Form(" Run %d Cycle %d task %s file %s",
420 fRun, fCurrentCycle, AliQAv1::GetTaskName(task).Data(), fOutput->GetName() )) ;
422 fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
424 fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
426 TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
428 subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
430 for ( Int_t specie = AliRecoParam::kDefault ; specie < AliRecoParam::kNSpecies ; specie++ ) {
431 TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
433 eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ;
434 TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
436 expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
438 StartOfDetectorCycle() ;