]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliQADataMakerSim.cxx
MergeQA is now an intrinsic part of AliReconstruction
[u/mrichter/AliRoot.git] / STEER / AliQADataMakerSim.cxx
CommitLineData
04236e67 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 notice *
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 **************************************************************************/
15
16
17/* $Id$ */
18
202374b1 19//
20// Base Class
21// Produces the data needed to calculate the quality assurance.
22// All data must be mergeable objects.
23// Y. Schutz CERN July 2007
24//
04236e67 25
26// --- ROOT system ---
7d297381 27#include <TCanvas.h>
04236e67 28#include <TFile.h>
04236e67 29#include <TTree.h>
30#include <TClonesArray.h>
31
32// --- Standard library ---
33
34// --- AliRoot header files ---
35#include "AliLog.h"
36#include "AliQADataMakerSim.h"
04236e67 37
38ClassImp(AliQADataMakerSim)
39
40//____________________________________________________________________________
41AliQADataMakerSim::AliQADataMakerSim(const char * name, const char * title) :
42 AliQADataMaker(name, title),
43 fDigitsQAList(0x0),
44 fHitsQAList(0x0),
45 fSDigitsQAList(0x0)
46{
47 // ctor
48 fDetectorDirName = GetName() ;
49}
50
51//____________________________________________________________________________
52AliQADataMakerSim::AliQADataMakerSim(const AliQADataMakerSim& qadm) :
53 AliQADataMaker(qadm.GetName(), qadm.GetTitle()),
54 fDigitsQAList(qadm.fDigitsQAList),
55 fHitsQAList(qadm.fHitsQAList),
56 fSDigitsQAList(qadm.fSDigitsQAList)
57{
58 //copy ctor
59 fDetectorDirName = GetName() ;
60}
61
63c6f8ae 62//____________________________________________________________________________
63AliQADataMakerSim::~AliQADataMakerSim()
64{
65 //dtor: delete the TObjArray and thei content
7ff8385d 66 if ( fDigitsQAList ) {
57acd2d2 67 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
68 if ( fDigitsQAList[specie]->IsOwner() )
69 fDigitsQAList[specie]->Delete() ;
70 }
71 delete[] fDigitsQAList ;
7ff8385d 72 }
73 if ( fHitsQAList ) {
57acd2d2 74 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
75 if ( fHitsQAList[specie]->IsOwner() )
76 fHitsQAList[specie]->Delete() ;
77 }
78 delete[] fHitsQAList ;
7ff8385d 79 }
80 if ( fSDigitsQAList ) {
57acd2d2 81 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
82 if ( fSDigitsQAList[specie]->IsOwner() )
83 fSDigitsQAList[specie]->Delete() ;
84 }
85 delete[] fSDigitsQAList ;
7ff8385d 86 }
63c6f8ae 87}
88
04236e67 89//__________________________________________________________________
90AliQADataMakerSim& AliQADataMakerSim::operator = (const AliQADataMakerSim& qadm )
91{
92 // Assignment operator.
93 this->~AliQADataMakerSim();
94 new(this) AliQADataMakerSim(qadm);
95 return *this;
96}
97
930e6e3e 98//____________________________________________________________________________
99void AliQADataMakerSim::EndOfCycle()
100{
101 // Finishes a cycle of QA for all tasks
4e25ac79 102 EndOfCycle(AliQAv1::kHITS) ;
103 EndOfCycle(AliQAv1::kSDIGITS) ;
104 EndOfCycle(AliQAv1::kDIGITS) ;
930e6e3e 105 ResetCycle() ;
106}
107
04236e67 108//____________________________________________________________________________
4e25ac79 109void AliQADataMakerSim::EndOfCycle(AliQAv1::TASKINDEX_t task)
04236e67 110{
111 // Finishes a cycle of QA data acquistion
57acd2d2 112 TObjArray ** list = NULL ;
04236e67 113
4e25ac79 114 if ( task == AliQAv1::kHITS )
04236e67 115 list = fHitsQAList ;
4e25ac79 116 else if ( task == AliQAv1::kSDIGITS )
04236e67 117 list = fSDigitsQAList ;
4e25ac79 118 else if ( task == AliQAv1::kDIGITS )
04236e67 119 list = fDigitsQAList ;
930e6e3e 120
121 if ( ! list )
122 return ;
04236e67 123 EndOfDetectorCycle(task, list) ;
6294b9a7 124 TDirectory * subDir = NULL ;
125 if (fDetectorDir)
4e25ac79 126 subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
ccbf0759 127 if (subDir) {
128 subDir->cd() ;
57acd2d2 129 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
130 TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
131 if (eventSpecieDir) {
132 eventSpecieDir->cd() ;
133 TIter next(list[specie]) ;
134 TObject * obj ;
135 while ( (obj = next()) ) {
4e25ac79 136 if (!obj->TestBit(AliQAv1::GetExpertBit()))
57acd2d2 137 obj->Write() ;
138 }
139 if (WriteExpert()) {
4e25ac79 140 TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
57acd2d2 141 if ( expertDir ) {
142 expertDir->cd() ;
143 next.Reset() ;
144 while ( (obj = next()) ) {
4e25ac79 145 if (!obj->TestBit(AliQAv1::GetExpertBit()))
57acd2d2 146 continue ;
147 obj->Write() ;
148 }
149 }
150 }
b1af1125 151 }
6e65319c 152 }
57acd2d2 153 fOutput->Save() ;
6e65319c 154 }
fec0891b 155 if (fPrintImage)
156 MakeImage(task) ;
04236e67 157}
158
159//____________________________________________________________________________
4e25ac79 160void AliQADataMakerSim::Exec(AliQAv1::TASKINDEX_t task, TObject * data)
04236e67 161{
162 // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
163
4e25ac79 164 if ( task == AliQAv1::kHITS ) {
5379c4a3 165 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Hits QA") ;
04236e67 166 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ;
167 if (arr) {
168 MakeHits(arr) ;
169 } else {
170 TTree * tree = dynamic_cast<TTree *>(data) ;
171 if (tree) {
172 MakeHits(tree) ;
173 } else {
174 AliWarning("data are neither a TClonesArray nor a TTree") ;
175 }
176 }
4e25ac79 177 } else if ( task == AliQAv1::kSDIGITS ) {
5379c4a3 178 AliDebug(AliQAv1::GetQADebugLevel(), "Processing SDigits QA") ;
04236e67 179 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ;
180 if (arr) {
181 MakeSDigits(arr) ;
182 } else {
183 TTree * tree = dynamic_cast<TTree *>(data) ;
184 if (tree) {
185 MakeSDigits(tree) ;
186 } else {
187 AliWarning("data are neither a TClonesArray nor a TTree") ;
188 }
189 }
4e25ac79 190 } else if ( task == AliQAv1::kDIGITS ) {
5379c4a3 191 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Digits QA") ;
04236e67 192 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ;
193 if (arr) {
194 MakeDigits(arr) ;
195 } else {
196 TTree * tree = dynamic_cast<TTree *>(data) ;
197 if (tree) {
198 MakeDigits(tree) ;
199 } else {
200 AliWarning("data are neither a TClonesArray nor a TTree") ;
201 }
202 }
203 }
204}
205
7d297381 206//____________________________________________________________________________
207void AliQADataMakerSim::MakeImage(AliQAv1::TASKINDEX_t task)
208{
209 // create a drawing of detetor defined histograms
210 TObjArray ** list = NULL ;
211 switch (task) {
212 case AliQAv1::kRAWS:
213 break;
214 case AliQAv1::kHITS:
215 list = fHitsQAList ;
216 break;
217 case AliQAv1::kSDIGITS:
218 list = fSDigitsQAList ;
219 break;
220 case AliQAv1::kDIGITS:
221 list = fDigitsQAList ;
222 break;
44ed7a66 223 case AliQAv1::kDIGITSR:
224 break;
7d297381 225 case AliQAv1::kRECPOINTS:
226 break;
227 case AliQAv1::kTRACKSEGMENTS:
228 break;
229 case AliQAv1::kRECPARTICLES:
230 break;
231 case AliQAv1::kESDS:
232 break;
233 case AliQAv1::kNTASKINDEX:
234 break;
235 default:
236 break;
237 }
238 if ( !list) {
239 AliFatal("data not initialized, call AliQADataMaker::Init");
240 return ;
241 }
fec0891b 242 MakeTheImage(list, task, "Sim") ;
7d297381 243}
244
04236e67 245//____________________________________________________________________________
4e25ac79 246TObjArray ** AliQADataMakerSim::Init(AliQAv1::TASKINDEX_t task, Int_t cycles)
04236e67 247{
248 // general intialisation
249
04236e67 250 if (cycles > 0)
251 SetCycle(cycles) ;
57acd2d2 252 TObjArray ** rv = NULL ;
4e25ac79 253 if ( task == AliQAv1::kHITS ) {
63c6f8ae 254 if ( ! fHitsQAList ) {
57acd2d2 255 fHitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
256 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
257 fHitsQAList[specie] = new TObjArray(100) ;
4e25ac79 258 fHitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
57acd2d2 259 }
63c6f8ae 260 InitHits() ;
261 }
04236e67 262 rv = fHitsQAList ;
4e25ac79 263 } else if ( task == AliQAv1::kSDIGITS ) {
63c6f8ae 264 if ( ! fSDigitsQAList ) {
57acd2d2 265 fSDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
266 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
267 fSDigitsQAList[specie] = new TObjArray(100) ;
4e25ac79 268 fSDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
57acd2d2 269 }
270 InitSDigits() ;
63c6f8ae 271 }
04236e67 272 rv = fSDigitsQAList ;
4e25ac79 273 } else if ( task == AliQAv1::kDIGITS ) {
63c6f8ae 274 if ( ! fDigitsQAList ) {
57acd2d2 275 fDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
276 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
277 fDigitsQAList[specie] = new TObjArray(100) ;
4e25ac79 278 fDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
57acd2d2 279 }
63c6f8ae 280 InitDigits() ;
281 }
04236e67 282 rv = fDigitsQAList ;
283 }
284
285 return rv ;
286}
287
288//____________________________________________________________________________
4e25ac79 289void AliQADataMakerSim::Init(AliQAv1::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles)
04236e67 290{
291 // Intialisation by passing the list of QA data booked elsewhere
292
293 fRun = run ;
294 if (cycles > 0)
295 SetCycle(cycles) ;
296
4e25ac79 297 if ( task == AliQAv1::kHITS ) {
04236e67 298 fHitsQAList = list ;
4e25ac79 299 } else if ( task == AliQAv1::kSDIGITS) {
04236e67 300 fSDigitsQAList = list ;
4e25ac79 301 } else if ( task == AliQAv1::kDIGITS ) {
04236e67 302 fDigitsQAList = list ;
303 }
304}
305
306//____________________________________________________________________________
930e6e3e 307void AliQADataMakerSim::StartOfCycle(Int_t run)
308{
309 // Finishes a cycle of QA for all tasks
310 Bool_t samecycle = kFALSE ;
4e25ac79 311 StartOfCycle(AliQAv1::kHITS, run, samecycle) ;
930e6e3e 312 samecycle = kTRUE ;
4e25ac79 313 StartOfCycle(AliQAv1::kSDIGITS, run, samecycle) ;
314 StartOfCycle(AliQAv1::kDIGITS, run, samecycle) ;
930e6e3e 315}
316
317//____________________________________________________________________________
4e25ac79 318void AliQADataMakerSim::StartOfCycle(AliQAv1::TASKINDEX_t task, Int_t run, const Bool_t sameCycle)
04236e67 319{
320 // Finishes a cycle of QA data acquistion
930e6e3e 321 if ( run > 0 )
322 fRun = run ;
04236e67 323 if ( !sameCycle || fCurrentCycle == -1) {
324 ResetCycle() ;
325 if (fOutput)
326 fOutput->Close() ;
4e25ac79 327 fOutput = AliQAv1::GetQADataFile(GetName(), fRun) ;
04236e67 328 }
329
5379c4a3 330 AliDebug(AliQAv1::GetQADebugLevel(), Form(" Run %d Cycle %d task %s file %s",
4e25ac79 331 fRun, fCurrentCycle, AliQAv1::GetTaskName(task).Data(), fOutput->GetName() )) ;
04236e67 332
333 fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
334 if (!fDetectorDir)
335 fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
336
4e25ac79 337 TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
04236e67 338 if (!subDir)
4e25ac79 339 subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
6e65319c 340
57acd2d2 341 for ( Int_t index = AliRecoParam::kDefault ; index < AliRecoParam::kNSpecies ; index++ ) {
342 TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(index)) ;
343 if (!eventSpecieDir)
344 eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(index)) ;
4e25ac79 345 TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
57acd2d2 346 if (!expertDir)
4e25ac79 347 expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
57acd2d2 348 }
04236e67 349 StartOfDetectorCycle() ;
350}