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