]>
Commit | Line | Data |
---|---|---|
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 | |
38 | ClassImp(AliQADataMakerSim) | |
39 | ||
40 | //____________________________________________________________________________ | |
41 | AliQADataMakerSim::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 | //____________________________________________________________________________ | |
52 | AliQADataMakerSim::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 | //____________________________________________________________________________ |
63 | AliQADataMakerSim::~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 | //__________________________________________________________________ |
90 | AliQADataMakerSim& AliQADataMakerSim::operator = (const AliQADataMakerSim& qadm ) | |
91 | { | |
92 | // Assignment operator. | |
93 | this->~AliQADataMakerSim(); | |
94 | new(this) AliQADataMakerSim(qadm); | |
95 | return *this; | |
96 | } | |
97 | ||
930e6e3e | 98 | //____________________________________________________________________________ |
99 | void 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 | 109 | void 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 | } |
7d297381 | 155 | MakeImage(task) ; |
04236e67 | 156 | } |
157 | ||
158 | //____________________________________________________________________________ | |
4e25ac79 | 159 | void AliQADataMakerSim::Exec(AliQAv1::TASKINDEX_t task, TObject * data) |
04236e67 | 160 | { |
161 | // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs) | |
162 | ||
4e25ac79 | 163 | if ( task == AliQAv1::kHITS ) { |
5379c4a3 | 164 | AliDebug(AliQAv1::GetQADebugLevel(), "Processing Hits QA") ; |
04236e67 | 165 | TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ; |
166 | if (arr) { | |
167 | MakeHits(arr) ; | |
168 | } else { | |
169 | TTree * tree = dynamic_cast<TTree *>(data) ; | |
170 | if (tree) { | |
171 | MakeHits(tree) ; | |
172 | } else { | |
173 | AliWarning("data are neither a TClonesArray nor a TTree") ; | |
174 | } | |
175 | } | |
4e25ac79 | 176 | } else if ( task == AliQAv1::kSDIGITS ) { |
5379c4a3 | 177 | AliDebug(AliQAv1::GetQADebugLevel(), "Processing SDigits QA") ; |
04236e67 | 178 | TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ; |
179 | if (arr) { | |
180 | MakeSDigits(arr) ; | |
181 | } else { | |
182 | TTree * tree = dynamic_cast<TTree *>(data) ; | |
183 | if (tree) { | |
184 | MakeSDigits(tree) ; | |
185 | } else { | |
186 | AliWarning("data are neither a TClonesArray nor a TTree") ; | |
187 | } | |
188 | } | |
4e25ac79 | 189 | } else if ( task == AliQAv1::kDIGITS ) { |
5379c4a3 | 190 | AliDebug(AliQAv1::GetQADebugLevel(), "Processing Digits QA") ; |
04236e67 | 191 | TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ; |
192 | if (arr) { | |
193 | MakeDigits(arr) ; | |
194 | } else { | |
195 | TTree * tree = dynamic_cast<TTree *>(data) ; | |
196 | if (tree) { | |
197 | MakeDigits(tree) ; | |
198 | } else { | |
199 | AliWarning("data are neither a TClonesArray nor a TTree") ; | |
200 | } | |
201 | } | |
202 | } | |
203 | } | |
204 | ||
7d297381 | 205 | //____________________________________________________________________________ |
206 | void AliQADataMakerSim::MakeImage(AliQAv1::TASKINDEX_t task) | |
207 | { | |
208 | // create a drawing of detetor defined histograms | |
209 | TObjArray ** list = NULL ; | |
210 | switch (task) { | |
211 | case AliQAv1::kRAWS: | |
212 | break; | |
213 | case AliQAv1::kHITS: | |
214 | list = fHitsQAList ; | |
215 | break; | |
216 | case AliQAv1::kSDIGITS: | |
217 | list = fSDigitsQAList ; | |
218 | break; | |
219 | case AliQAv1::kDIGITS: | |
220 | list = fDigitsQAList ; | |
221 | break; | |
222 | case AliQAv1::kRECPOINTS: | |
223 | break; | |
224 | case AliQAv1::kTRACKSEGMENTS: | |
225 | break; | |
226 | case AliQAv1::kRECPARTICLES: | |
227 | break; | |
228 | case AliQAv1::kESDS: | |
229 | break; | |
230 | case AliQAv1::kNTASKINDEX: | |
231 | break; | |
232 | default: | |
233 | break; | |
234 | } | |
235 | if ( !list) { | |
236 | AliFatal("data not initialized, call AliQADataMaker::Init"); | |
237 | return ; | |
238 | } | |
239 | TIter next(list[0]) ; | |
240 | TH1 * hdata = NULL ; | |
241 | Int_t nImages = 0 ; | |
242 | while ( (hdata=dynamic_cast<TH1 *>(next())) ) { | |
243 | if ( hdata->TestBit(AliQAv1::GetImageBit()) ) | |
244 | nImages++; | |
245 | } | |
246 | if ( nImages == 0 ) { | |
5379c4a3 | 247 | AliWarning(Form("No histogram will be plotted for %s %s\n", GetName(), AliQAv1::GetTaskName(task).Data())) ; |
7d297381 | 248 | } else { |
5379c4a3 | 249 | AliDebug(AliQAv1::GetQADebugLevel(), Form("%d histograms will be plotted for %s %s\n", nImages, GetName(), AliQAv1::GetTaskName(task).Data())) ; |
7d297381 | 250 | Double_t w = 1000 ; |
251 | Double_t h = 1000 ; | |
252 | for (Int_t esIndex = 0 ; esIndex < AliRecoParam::kNSpecies ; esIndex++) { | |
253 | TCanvas * canvasQA = new TCanvas(Form("QA_%s_%s_%s", | |
254 | GetName(), | |
255 | AliQAv1::GetTaskName(task).Data(), | |
256 | AliRecoParam::GetEventSpecieName(esIndex)), | |
257 | Form("QA control plots for det=%s task=%s eventspecie=%s", | |
258 | GetName(), | |
259 | AliQAv1::GetTaskName(task).Data(), | |
260 | AliRecoParam::GetEventSpecieName(esIndex)), | |
261 | w, h) ; | |
262 | canvasQA->SetWindowSize(w + (w - canvasQA->GetWw()), h + (h - canvasQA->GetWh())) ; | |
263 | Int_t nx = TMath::Sqrt(nImages) ; | |
264 | Int_t ny = nx ; | |
265 | if ( nx < TMath::Sqrt(nImages)) | |
266 | ny++ ; | |
267 | canvasQA->Divide(nx, ny) ; | |
268 | TIter nexthist(list[esIndex]) ; | |
269 | TH1* hist = NULL ; | |
270 | Int_t npad = 1 ; | |
271 | canvasQA->cd(npad) ; | |
272 | while ( (hist=dynamic_cast<TH1*>(nexthist())) ) { | |
273 | if(hist->TestBit(AliQAv1::GetImageBit())) { | |
274 | hist->Draw() ; | |
275 | canvasQA->cd(++npad) ; | |
276 | } | |
277 | } | |
5379c4a3 | 278 | if ( AliDebugLevel() == AliQAv1::GetQADebugLevel() ) |
279 | canvasQA->Print() ; | |
7d297381 | 280 | } |
281 | } | |
282 | } | |
283 | ||
04236e67 | 284 | //____________________________________________________________________________ |
4e25ac79 | 285 | TObjArray ** AliQADataMakerSim::Init(AliQAv1::TASKINDEX_t task, Int_t cycles) |
04236e67 | 286 | { |
287 | // general intialisation | |
288 | ||
04236e67 | 289 | if (cycles > 0) |
290 | SetCycle(cycles) ; | |
57acd2d2 | 291 | TObjArray ** rv = NULL ; |
4e25ac79 | 292 | if ( task == AliQAv1::kHITS ) { |
63c6f8ae | 293 | if ( ! fHitsQAList ) { |
57acd2d2 | 294 | fHitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ; |
295 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { | |
296 | fHitsQAList[specie] = new TObjArray(100) ; | |
4e25ac79 | 297 | fHitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ; |
57acd2d2 | 298 | } |
63c6f8ae | 299 | InitHits() ; |
300 | } | |
04236e67 | 301 | rv = fHitsQAList ; |
4e25ac79 | 302 | } else if ( task == AliQAv1::kSDIGITS ) { |
63c6f8ae | 303 | if ( ! fSDigitsQAList ) { |
57acd2d2 | 304 | fSDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ; |
305 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { | |
306 | fSDigitsQAList[specie] = new TObjArray(100) ; | |
4e25ac79 | 307 | fSDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ; |
57acd2d2 | 308 | } |
309 | InitSDigits() ; | |
63c6f8ae | 310 | } |
04236e67 | 311 | rv = fSDigitsQAList ; |
4e25ac79 | 312 | } else if ( task == AliQAv1::kDIGITS ) { |
63c6f8ae | 313 | if ( ! fDigitsQAList ) { |
57acd2d2 | 314 | fDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ; |
315 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { | |
316 | fDigitsQAList[specie] = new TObjArray(100) ; | |
4e25ac79 | 317 | fDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ; |
57acd2d2 | 318 | } |
63c6f8ae | 319 | InitDigits() ; |
320 | } | |
04236e67 | 321 | rv = fDigitsQAList ; |
322 | } | |
323 | ||
324 | return rv ; | |
325 | } | |
326 | ||
327 | //____________________________________________________________________________ | |
4e25ac79 | 328 | void AliQADataMakerSim::Init(AliQAv1::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles) |
04236e67 | 329 | { |
330 | // Intialisation by passing the list of QA data booked elsewhere | |
331 | ||
332 | fRun = run ; | |
333 | if (cycles > 0) | |
334 | SetCycle(cycles) ; | |
335 | ||
4e25ac79 | 336 | if ( task == AliQAv1::kHITS ) { |
04236e67 | 337 | fHitsQAList = list ; |
4e25ac79 | 338 | } else if ( task == AliQAv1::kSDIGITS) { |
04236e67 | 339 | fSDigitsQAList = list ; |
4e25ac79 | 340 | } else if ( task == AliQAv1::kDIGITS ) { |
04236e67 | 341 | fDigitsQAList = list ; |
342 | } | |
343 | } | |
344 | ||
345 | //____________________________________________________________________________ | |
930e6e3e | 346 | void AliQADataMakerSim::StartOfCycle(Int_t run) |
347 | { | |
348 | // Finishes a cycle of QA for all tasks | |
349 | Bool_t samecycle = kFALSE ; | |
4e25ac79 | 350 | StartOfCycle(AliQAv1::kHITS, run, samecycle) ; |
930e6e3e | 351 | samecycle = kTRUE ; |
4e25ac79 | 352 | StartOfCycle(AliQAv1::kSDIGITS, run, samecycle) ; |
353 | StartOfCycle(AliQAv1::kDIGITS, run, samecycle) ; | |
930e6e3e | 354 | } |
355 | ||
356 | //____________________________________________________________________________ | |
4e25ac79 | 357 | void AliQADataMakerSim::StartOfCycle(AliQAv1::TASKINDEX_t task, Int_t run, const Bool_t sameCycle) |
04236e67 | 358 | { |
359 | // Finishes a cycle of QA data acquistion | |
930e6e3e | 360 | if ( run > 0 ) |
361 | fRun = run ; | |
04236e67 | 362 | if ( !sameCycle || fCurrentCycle == -1) { |
363 | ResetCycle() ; | |
364 | if (fOutput) | |
365 | fOutput->Close() ; | |
4e25ac79 | 366 | fOutput = AliQAv1::GetQADataFile(GetName(), fRun) ; |
04236e67 | 367 | } |
368 | ||
5379c4a3 | 369 | AliDebug(AliQAv1::GetQADebugLevel(), Form(" Run %d Cycle %d task %s file %s", |
4e25ac79 | 370 | fRun, fCurrentCycle, AliQAv1::GetTaskName(task).Data(), fOutput->GetName() )) ; |
04236e67 | 371 | |
372 | fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ; | |
373 | if (!fDetectorDir) | |
374 | fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ; | |
375 | ||
4e25ac79 | 376 | TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ; |
04236e67 | 377 | if (!subDir) |
4e25ac79 | 378 | subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ; |
6e65319c | 379 | |
57acd2d2 | 380 | for ( Int_t index = AliRecoParam::kDefault ; index < AliRecoParam::kNSpecies ; index++ ) { |
381 | TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(index)) ; | |
382 | if (!eventSpecieDir) | |
383 | eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(index)) ; | |
4e25ac79 | 384 | TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ; |
57acd2d2 | 385 | if (!expertDir) |
4e25ac79 | 386 | expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ; |
57acd2d2 | 387 | } |
04236e67 | 388 | StartOfDetectorCycle() ; |
389 | } |