]>
Commit | Line | Data |
---|---|---|
2e331c8b | 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 | /* $Id: AliQAManager.cxx 30894 2009-02-05 13:46:48Z schutz $ */ | |
17 | /////////////////////////////////////////////////////////////////////////////// | |
18 | // // | |
19 | // class for running the QA makers // | |
20 | // // | |
bf76b847 | 21 | // AliQAManager qas; // |
22 | // qas.Run(AliQAv1::kRAWS, rawROOTFileName); // | |
23 | // qas.Run(AliQAv1::kHITS); // | |
24 | // qas.Run(AliQAv1::kSDIGITS); // | |
25 | // qas.Run(AliQAv1::kDIGITS); // | |
26 | // qas.Run(AliQAv1::kRECPOINTS); // | |
27 | // qas.Run(AliQAv1::kESDS); // | |
2e331c8b | 28 | // // |
29 | /////////////////////////////////////////////////////////////////////////////// | |
30 | ||
fec0891b | 31 | #include <TCanvas.h> |
2e331c8b | 32 | #include <TKey.h> |
33 | #include <TFile.h> | |
34 | #include <TFileMerger.h> | |
149a2367 | 35 | #include <TGrid.h> |
36 | #include <TGridCollection.h> | |
37 | #include <TGridResult.h> | |
2e331c8b | 38 | #include <TPluginManager.h> |
39 | #include <TROOT.h> | |
40 | #include <TString.h> | |
41 | #include <TSystem.h> | |
42 | ||
43 | #include "AliCDBManager.h" | |
44 | #include "AliCDBEntry.h" | |
45 | #include "AliCDBId.h" | |
46 | #include "AliCDBMetaData.h" | |
47 | #include "AliCodeTimer.h" | |
48 | #include "AliCorrQADataMakerRec.h" | |
49 | #include "AliDetectorRecoParam.h" | |
50 | #include "AliESDEvent.h" | |
51 | #include "AliGeomManager.h" | |
52 | #include "AliGlobalQADataMaker.h" | |
53 | #include "AliHeader.h" | |
54 | #include "AliLog.h" | |
55 | #include "AliModule.h" | |
4e25ac79 | 56 | #include "AliQAv1.h" |
634696f5 | 57 | #include "AliQAChecker.h" |
58 | #include "AliQACheckerBase.h" | |
2e331c8b | 59 | #include "AliQADataMakerRec.h" |
60 | #include "AliQADataMakerSim.h" | |
61 | #include "AliQAManager.h" | |
62 | #include "AliRawReaderDate.h" | |
63 | #include "AliRawReaderFile.h" | |
64 | #include "AliRawReaderRoot.h" | |
65 | #include "AliRun.h" | |
66 | #include "AliRunLoader.h" | |
67 | #include "AliRunTag.h" | |
68 | ||
69 | ClassImp(AliQAManager) | |
70 | AliQAManager* AliQAManager::fgQAInstance = 0x0; | |
71 | ||
72 | //_____________________________________________________________________________ | |
73 | AliQAManager::AliQAManager() : | |
74 | AliCDBManager(), | |
75 | fCurrentEvent(0), | |
76 | fCycleSame(kFALSE), | |
77 | fDetectors("ALL"), | |
78 | fDetectorsW("ALL"), | |
79 | fESD(NULL), | |
80 | fESDTree(NULL), | |
81 | fGAliceFileName(""), | |
82 | fFirstEvent(0), | |
83 | fMaxEvents(0), | |
84 | fMode(""), | |
85 | fNumberOfEvents(999999), | |
86 | fRecoParam(), | |
87 | fRunNumber(0), | |
88 | fRawReader(NULL), | |
89 | fRawReaderDelete(kTRUE), | |
90 | fRunLoader(NULL), | |
bc8761a0 | 91 | fTasks(""), |
fec0891b | 92 | fEventSpecie(AliRecoParam::kDefault), |
50dee02c | 93 | fPrintImage(kTRUE), |
94 | fSaveData(kTRUE) | |
2e331c8b | 95 | { |
96 | // default ctor | |
97 | fMaxEvents = fNumberOfEvents ; | |
98 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
4e25ac79 | 99 | if (IsSelected(AliQAv1::GetDetName(iDet))) { |
2e331c8b | 100 | fLoader[iDet] = NULL ; |
101 | fQADataMaker[iDet] = NULL ; | |
102 | fQACycles[iDet] = 999999 ; | |
2e331c8b | 103 | } |
104 | } | |
75373542 | 105 | SetWriteExpert() ; |
2e331c8b | 106 | } |
107 | ||
108 | //_____________________________________________________________________________ | |
634696f5 | 109 | AliQAManager::AliQAManager(AliQAv1::MODE_t mode, const Char_t* gAliceFilename) : |
2e331c8b | 110 | AliCDBManager(), |
111 | fCurrentEvent(0), | |
112 | fCycleSame(kFALSE), | |
113 | fDetectors("ALL"), | |
114 | fDetectorsW("ALL"), | |
115 | fESD(NULL), | |
116 | fESDTree(NULL), | |
117 | fGAliceFileName(gAliceFilename), | |
118 | fFirstEvent(0), | |
119 | fMaxEvents(0), | |
634696f5 | 120 | fMode(AliQAv1::GetModeName(mode)), |
2e331c8b | 121 | fNumberOfEvents(999999), |
122 | fRecoParam(), | |
123 | fRunNumber(0), | |
124 | fRawReader(NULL), | |
125 | fRawReaderDelete(kTRUE), | |
126 | fRunLoader(NULL), | |
bc8761a0 | 127 | fTasks(""), |
fec0891b | 128 | fEventSpecie(AliRecoParam::kDefault), |
50dee02c | 129 | fPrintImage(kTRUE), |
130 | fSaveData(kTRUE) | |
2e331c8b | 131 | { |
132 | // default ctor | |
133 | fMaxEvents = fNumberOfEvents ; | |
134 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
4e25ac79 | 135 | if (IsSelected(AliQAv1::GetDetName(iDet))) { |
2e331c8b | 136 | fLoader[iDet] = NULL ; |
137 | fQADataMaker[iDet] = NULL ; | |
138 | fQACycles[iDet] = 999999 ; | |
65660bf3 | 139 | } |
140 | } | |
75373542 | 141 | SetWriteExpert() ; |
2e331c8b | 142 | } |
143 | ||
144 | //_____________________________________________________________________________ | |
145 | AliQAManager::AliQAManager(const AliQAManager & qas) : | |
146 | AliCDBManager(), | |
147 | fCurrentEvent(qas.fCurrentEvent), | |
148 | fCycleSame(kFALSE), | |
149 | fDetectors(qas.fDetectors), | |
150 | fDetectorsW(qas.fDetectorsW), | |
151 | fESD(NULL), | |
152 | fESDTree(NULL), | |
153 | fGAliceFileName(qas.fGAliceFileName), | |
154 | fFirstEvent(qas.fFirstEvent), | |
155 | fMaxEvents(qas.fMaxEvents), | |
156 | fMode(qas.fMode), | |
157 | fNumberOfEvents(qas.fNumberOfEvents), | |
158 | fRecoParam(), | |
159 | fRunNumber(qas.fRunNumber), | |
160 | fRawReader(NULL), | |
161 | fRawReaderDelete(kTRUE), | |
162 | fRunLoader(NULL), | |
bc8761a0 | 163 | fTasks(qas.fTasks), |
fec0891b | 164 | fEventSpecie(qas.fEventSpecie), |
50dee02c | 165 | fPrintImage(qas.fPrintImage), |
166 | fSaveData(qas.fSaveData) | |
fec0891b | 167 | |
2e331c8b | 168 | { |
169 | // cpy ctor | |
170 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
171 | fLoader[iDet] = qas.fLoader[iDet] ; | |
172 | fQADataMaker[iDet] = qas.fQADataMaker[iDet] ; | |
173 | fQACycles[iDet] = qas.fQACycles[iDet] ; | |
174 | fQAWriteExpert[iDet] = qas.fQAWriteExpert[iDet] ; | |
175 | } | |
176 | } | |
177 | ||
178 | //_____________________________________________________________________________ | |
179 | AliQAManager & AliQAManager::operator = (const AliQAManager & qas) | |
180 | { | |
181 | // assignment operator | |
182 | this->~AliQAManager() ; | |
183 | new(this) AliQAManager(qas) ; | |
184 | return *this ; | |
185 | } | |
186 | ||
187 | //_____________________________________________________________________________ | |
188 | AliQAManager::~AliQAManager() | |
189 | { | |
190 | // dtor | |
191 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
4e25ac79 | 192 | if (IsSelected(AliQAv1::GetDetName(iDet))) { |
2e331c8b | 193 | fLoader[iDet] = NULL; |
194 | if (fQADataMaker[iDet]) { | |
195 | (fQADataMaker[iDet])->Finish() ; | |
196 | delete fQADataMaker[iDet] ; | |
197 | } | |
198 | } | |
199 | } | |
200 | if (fRawReaderDelete) { | |
201 | fRunLoader = NULL ; | |
202 | delete fRawReader ; | |
203 | fRawReader = NULL ; | |
204 | } | |
fec0891b | 205 | TCanvas fakeCanvas ; |
206 | if (fPrintImage) | |
207 | fakeCanvas.Print(Form("%s%s%d.%s]", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())); | |
2e331c8b | 208 | } |
209 | ||
210 | //_____________________________________________________________________________ | |
4e25ac79 | 211 | Bool_t AliQAManager::DoIt(const AliQAv1::TASKINDEX_t taskIndex) |
2e331c8b | 212 | { |
213 | // Runs all the QA data Maker for every detector | |
214 | ||
215 | Bool_t rv = kFALSE ; | |
216 | // Fill QA data in event loop | |
217 | for (UInt_t iEvent = fFirstEvent ; iEvent < (UInt_t)fMaxEvents ; iEvent++) { | |
218 | fCurrentEvent++ ; | |
219 | // Get the event | |
220 | if ( iEvent%10 == 0 ) | |
5379c4a3 | 221 | AliDebug(AliQAv1::GetQADebugLevel(), Form("processing event %d", iEvent)); |
4e25ac79 | 222 | if ( taskIndex == AliQAv1::kRAWS ) { |
2e331c8b | 223 | if ( !fRawReader->NextEvent() ) |
224 | break ; | |
4e25ac79 | 225 | } else if ( taskIndex == AliQAv1::kESDS ) { |
2e331c8b | 226 | if ( fESDTree->GetEntry(iEvent) == 0 ) |
227 | break ; | |
228 | } else { | |
229 | if ( fRunLoader->GetEvent(iEvent) != 0 ) | |
230 | break ; | |
231 | } | |
232 | // loop over active loaders | |
233 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { | |
4e25ac79 | 234 | if (IsSelected(AliQAv1::GetDetName(iDet))) { |
2e331c8b | 235 | AliQADataMaker * qadm = GetQADataMaker(iDet) ; |
236 | if (!qadm) continue; // This detector doesn't have any QA (for example, HLT) | |
237 | if ( qadm->IsCycleDone() ) { | |
238 | qadm->EndOfCycle(taskIndex) ; | |
239 | } | |
240 | TTree * data = NULL ; | |
241 | AliLoader* loader = GetLoader(qadm->GetUniqueID()); | |
242 | switch (taskIndex) { | |
4e25ac79 | 243 | case AliQAv1::kNULLTASKINDEX : |
2e331c8b | 244 | break ; |
4e25ac79 | 245 | case AliQAv1::kRAWS : |
2e331c8b | 246 | qadm->Exec(taskIndex, fRawReader) ; |
247 | break ; | |
4e25ac79 | 248 | case AliQAv1::kHITS : |
2e331c8b | 249 | if( loader ) { |
250 | loader->LoadHits() ; | |
251 | data = loader->TreeH() ; | |
252 | if ( ! data ) { | |
4e25ac79 | 253 | AliWarning(Form(" Hit Tree not found for %s", AliQAv1::GetDetName(iDet))) ; |
2e331c8b | 254 | break ; |
255 | } | |
eca4fa66 | 256 | qadm->Exec(taskIndex, data) ; |
2e331c8b | 257 | } |
2e331c8b | 258 | break ; |
4e25ac79 | 259 | case AliQAv1::kSDIGITS : |
2e331c8b | 260 | if( loader ) { |
261 | loader->LoadSDigits() ; | |
262 | data = loader->TreeS() ; | |
263 | if ( ! data ) { | |
4e25ac79 | 264 | AliWarning(Form(" SDigit Tree not found for %s", AliQAv1::GetDetName(iDet))) ; |
2e331c8b | 265 | break ; |
266 | } | |
eca4fa66 | 267 | qadm->Exec(taskIndex, data) ; |
2e331c8b | 268 | } |
2e331c8b | 269 | break; |
4e25ac79 | 270 | case AliQAv1::kDIGITS : |
fec0891b | 271 | if( loader ) { |
272 | loader->LoadDigits() ; | |
273 | data = loader->TreeD() ; | |
274 | if ( ! data ) { | |
275 | AliWarning(Form(" Digit Tree not found for %s", AliQAv1::GetDetName(iDet))) ; | |
276 | break ; | |
277 | } | |
eca4fa66 | 278 | qadm->Exec(taskIndex, data) ; |
fec0891b | 279 | } |
eca4fa66 | 280 | break; |
fec0891b | 281 | case AliQAv1::kDIGITSR : |
282 | if( loader ) { | |
283 | loader->LoadDigits() ; | |
284 | data = loader->TreeD() ; | |
285 | if ( ! data ) { | |
286 | AliWarning(Form(" Digit Tree not found for %s", AliQAv1::GetDetName(iDet))) ; | |
287 | break ; | |
288 | } | |
eca4fa66 | 289 | qadm->Exec(taskIndex, data) ; |
fec0891b | 290 | } |
2e331c8b | 291 | break; |
4e25ac79 | 292 | case AliQAv1::kRECPOINTS : |
2e331c8b | 293 | if( loader ) { |
294 | loader->LoadRecPoints() ; | |
295 | data = loader->TreeR() ; | |
296 | if (!data) { | |
4e25ac79 | 297 | AliWarning(Form("RecPoints not found for %s", AliQAv1::GetDetName(iDet))) ; |
2e331c8b | 298 | break ; |
299 | } | |
eca4fa66 | 300 | qadm->Exec(taskIndex, data) ; |
2e331c8b | 301 | } |
2e331c8b | 302 | break; |
4e25ac79 | 303 | case AliQAv1::kTRACKSEGMENTS : |
2e331c8b | 304 | break; |
4e25ac79 | 305 | case AliQAv1::kRECPARTICLES : |
2e331c8b | 306 | break; |
4e25ac79 | 307 | case AliQAv1::kESDS : |
2e331c8b | 308 | qadm->Exec(taskIndex, fESD) ; |
309 | break; | |
4e25ac79 | 310 | case AliQAv1::kNTASKINDEX : |
2e331c8b | 311 | break; |
312 | } //task switch | |
313 | } | |
314 | } // detector loop | |
5e303886 | 315 | Increment(taskIndex) ; |
2e331c8b | 316 | } // event loop |
317 | // Save QA data for all detectors | |
5e303886 | 318 | |
2e331c8b | 319 | rv = Finish(taskIndex) ; |
320 | ||
4e25ac79 | 321 | if ( taskIndex == AliQAv1::kRAWS ) |
2e331c8b | 322 | fRawReader->RewindEvents() ; |
323 | ||
324 | return rv ; | |
325 | } | |
326 | ||
327 | //_____________________________________________________________________________ | |
4e25ac79 | 328 | Bool_t AliQAManager::Finish(const AliQAv1::TASKINDEX_t taskIndex) |
2e331c8b | 329 | { |
330 | // write output to file for all detectors | |
8fa875cb | 331 | |
332 | AliQAChecker::Instance()->SetRunNumber(fRunNumber) ; | |
333 | ||
2e331c8b | 334 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { |
4e25ac79 | 335 | if (IsSelected(AliQAv1::GetDetName(iDet))) { |
2e331c8b | 336 | AliQADataMaker * qadm = GetQADataMaker(iDet) ; |
337 | if (qadm) | |
338 | qadm->EndOfCycle(taskIndex) ; | |
339 | } | |
340 | } | |
341 | return kTRUE ; | |
342 | } | |
343 | ||
344 | //_____________________________________________________________________________ | |
fec0891b | 345 | TObjArray * AliQAManager::GetFromOCDB(AliQAv1::DETECTORINDEX_t det, AliQAv1::TASKINDEX_t task, const Char_t * year) const |
2e331c8b | 346 | { |
347 | // Retrieve the list of QA data for a given detector and a given task | |
348 | TObjArray * rv = NULL ; | |
4e25ac79 | 349 | if ( !strlen(AliQAv1::GetQARefStorage()) ) { |
350 | AliError("No storage defined, use AliQAv1::SetQARefStorage") ; | |
2e331c8b | 351 | return NULL ; |
352 | } | |
353 | if ( ! IsDefaultStorageSet() ) { | |
4e25ac79 | 354 | TString tmp(AliQAv1::GetQARefDefaultStorage()) ; |
2e331c8b | 355 | tmp.Append(year) ; |
356 | tmp.Append("/") ; | |
357 | Instance()->SetDefaultStorage(tmp.Data()) ; | |
4e25ac79 | 358 | Instance()->SetSpecificStorage(Form("%s/*", AliQAv1::GetQAName()), AliQAv1::GetQARefStorage()) ; |
2e331c8b | 359 | } |
4e25ac79 | 360 | TString detOCDBDir(Form("%s/%s/%s", AliQAv1::GetQAName(), AliQAv1::GetDetName((Int_t)det), AliQAv1::GetRefOCDBDirName())) ; |
5379c4a3 | 361 | AliDebug(AliQAv1::GetQADebugLevel(), Form("Retrieving reference data from %s/%s for %s", AliQAv1::GetQARefStorage(), detOCDBDir.Data(), AliQAv1::GetTaskName(task).Data())) ; |
2e331c8b | 362 | AliCDBEntry* entry = QAManager()->Get(detOCDBDir.Data(), 0) ; //FIXME 0 --> Run Number |
eca4fa66 | 363 | TList * listDetQAD = static_cast<TList *>(entry->GetObject()) ; |
2e331c8b | 364 | if ( listDetQAD ) |
eca4fa66 | 365 | rv = static_cast<TObjArray *>(listDetQAD->FindObject(AliQAv1::GetTaskName(task))) ; |
2e331c8b | 366 | return rv ; |
367 | } | |
368 | ||
fec0891b | 369 | //_____________________________________________________________________________ |
370 | TCanvas ** AliQAManager::GetImage(Char_t * detName) | |
371 | { | |
372 | // retrieves QA Image for the given detector | |
373 | TCanvas ** rv = NULL ; | |
374 | Int_t detIndex = AliQAv1::GetDetIndex(detName) ; | |
634696f5 | 375 | AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(detIndex) ; |
376 | rv = qac->GetImage() ; | |
fec0891b | 377 | return rv ; |
378 | } | |
379 | ||
2e331c8b | 380 | //_____________________________________________________________________________ |
381 | AliLoader * AliQAManager::GetLoader(Int_t iDet) | |
382 | { | |
383 | // get the loader for a detector | |
384 | ||
bf76b847 | 385 | if ( !fRunLoader || iDet == AliQAv1::kCORR || iDet == AliQAv1::kGLOBAL ) |
2e331c8b | 386 | return NULL ; |
387 | ||
4e25ac79 | 388 | TString detName = AliQAv1::GetDetName(iDet) ; |
2e331c8b | 389 | fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader"); |
390 | if (fLoader[iDet]) | |
391 | return fLoader[iDet] ; | |
392 | ||
393 | // load the QA data maker object | |
394 | TPluginManager* pluginManager = gROOT->GetPluginManager() ; | |
395 | TString loaderName = "Ali" + detName + "Loader" ; | |
396 | ||
397 | AliLoader * loader = NULL ; | |
398 | // first check if a plugin is defined for the quality assurance data maker | |
399 | TPluginHandler* pluginHandler = pluginManager->FindHandler("AliLoader", detName) ; | |
400 | // if not, add a plugin for it | |
401 | if (!pluginHandler) { | |
5379c4a3 | 402 | AliDebug(AliQAv1::GetQADebugLevel(), Form("defining plugin for %s", loaderName.Data())) ; |
2e331c8b | 403 | TString libs = gSystem->GetLibraries() ; |
404 | if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) { | |
405 | pluginManager->AddHandler("AliQADataMaker", detName, loaderName, detName + "loader", loaderName + "()") ; | |
406 | } else { | |
407 | pluginManager->AddHandler("AliLoader", detName, loaderName, detName, loaderName + "()") ; | |
408 | } | |
409 | pluginHandler = pluginManager->FindHandler("AliLoader", detName) ; | |
410 | } | |
411 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { | |
412 | loader = (AliLoader *) pluginHandler->ExecPlugin(0) ; | |
413 | } | |
414 | if (loader) | |
415 | fLoader[iDet] = loader ; | |
416 | return loader ; | |
417 | } | |
418 | ||
419 | //_____________________________________________________________________________ | |
4e25ac79 | 420 | AliQAv1 * AliQAManager::GetQA(UInt_t run, UInt_t evt) |
2e331c8b | 421 | { |
422 | // retrieves the QA object stored in a file named "Run{run}.Event{evt}_1.ESD.tag.root" | |
fec0891b | 423 | Char_t * fileName = Form("Run%d.Event%d_1.ESD.tag.root", run, evt) ; |
2e331c8b | 424 | TFile * tagFile = TFile::Open(fileName) ; |
425 | if ( !tagFile ) { | |
426 | AliError(Form("File %s not found", fileName)) ; | |
427 | return NULL ; | |
428 | } | |
eca4fa66 | 429 | TTree * tagTree = static_cast<TTree *>(tagFile->Get("T")) ; |
2e331c8b | 430 | if ( !tagTree ) { |
431 | AliError(Form("Tree T not found in %s", fileName)) ; | |
432 | tagFile->Close() ; | |
433 | return NULL ; | |
434 | } | |
435 | AliRunTag * tag = new AliRunTag ; | |
436 | tagTree->SetBranchAddress("AliTAG", &tag) ; | |
437 | tagTree->GetEntry(evt) ; | |
4e25ac79 | 438 | AliQAv1 * qa = AliQAv1::Instance(tag->GetQALength(), tag->GetQAArray(), tag->GetESLength(), tag->GetEventSpecies()) ; |
2e331c8b | 439 | tagFile->Close() ; |
440 | return qa ; | |
441 | } | |
442 | ||
443 | //_____________________________________________________________________________ | |
444 | AliQADataMaker * AliQAManager::GetQADataMaker(const Int_t iDet) | |
445 | { | |
446 | // get the quality assurance data maker for a detector | |
447 | ||
eca4fa66 | 448 | AliQADataMaker * qadm = fQADataMaker[iDet] ; |
449 | ||
450 | if (qadm) { | |
451 | ||
5e232cd6 | 452 | qadm->SetEventSpecie(fEventSpecie) ; |
bc8761a0 | 453 | if ( qadm->GetRecoParam() ) |
eca4fa66 | 454 | if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault) |
5e232cd6 | 455 | qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; |
2e331c8b | 456 | |
eca4fa66 | 457 | } else if (iDet == AliQAv1::kGLOBAL) { //Global QA |
458 | ||
459 | qadm = new AliGlobalQADataMaker(); | |
4e25ac79 | 460 | qadm->SetName(AliQAv1::GetDetName(iDet)); |
2e331c8b | 461 | qadm->SetUniqueID(iDet); |
462 | fQADataMaker[iDet] = qadm; | |
5e232cd6 | 463 | qadm->SetEventSpecie(fEventSpecie) ; |
bc8761a0 | 464 | if ( qadm->GetRecoParam() ) |
5e232cd6 | 465 | if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault) |
466 | qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; | |
2e331c8b | 467 | |
eca4fa66 | 468 | } else if (iDet == AliQAv1::kCORR && strcmp(GetMode(), "Rec") == 0 ) { //the data maker for correlations among detectors |
469 | qadm = new AliCorrQADataMakerRec(fQADataMaker) ; | |
4e25ac79 | 470 | qadm->SetName(AliQAv1::GetDetName(iDet)); |
2e331c8b | 471 | qadm->SetUniqueID(iDet); |
eca4fa66 | 472 | fQADataMaker[iDet] = qadm; |
5e232cd6 | 473 | qadm->SetEventSpecie(fEventSpecie) ; |
bc8761a0 | 474 | if ( qadm->GetRecoParam() ) |
5e232cd6 | 475 | if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault) |
476 | qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; | |
2e331c8b | 477 | |
6252ceeb | 478 | } else if ( iDet < AliQAv1::kHLT ) { |
eca4fa66 | 479 | |
480 | // load the QA data maker object | |
481 | TPluginManager* pluginManager = gROOT->GetPluginManager() ; | |
482 | TString detName = AliQAv1::GetDetName(iDet) ; | |
483 | TString qadmName = "Ali" + detName + "QADataMaker" + GetMode() ; | |
484 | ||
485 | // first check if a plugin is defined for the quality assurance data maker | |
486 | TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ; | |
487 | // if not, add a plugin for it | |
488 | if (!pluginHandler) { | |
489 | AliDebug(AliQAv1::GetQADebugLevel(), Form("defining plugin for %s", qadmName.Data())) ; | |
490 | TString libs = gSystem->GetLibraries() ; | |
bf76b847 | 491 | TString temp(GetMode()) ; |
492 | temp.ToLower() ; | |
493 | if (libs.Contains("lib" + detName + GetMode() + ".so") || (gSystem->Load("lib" + detName + temp.Data() + ".so") >= 0)) { | |
eca4fa66 | 494 | pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ; |
495 | } else { | |
496 | pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ; | |
497 | } | |
498 | pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ; | |
499 | } | |
500 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { | |
501 | qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ; | |
502 | } | |
503 | if (qadm) { | |
504 | qadm->SetName(AliQAv1::GetDetName(iDet)); | |
505 | qadm->SetUniqueID(iDet); | |
506 | fQADataMaker[iDet] = qadm ; | |
507 | qadm->SetEventSpecie(fEventSpecie) ; | |
508 | if ( qadm->GetRecoParam() ) | |
509 | if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault) | |
510 | qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; | |
511 | } | |
512 | } | |
2e331c8b | 513 | return qadm ; |
514 | } | |
515 | ||
516 | //_____________________________________________________________________________ | |
517 | void AliQAManager::EndOfCycle(TObjArray * detArray) | |
518 | { | |
519 | // End of cycle QADataMakers | |
520 | ||
8fa875cb | 521 | AliQAChecker::Instance()->SetRunNumber(fRunNumber) ; |
522 | if (fPrintImage) { | |
fec0891b | 523 | TCanvas fakeCanvas ; |
524 | fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())) ; | |
525 | } | |
2e331c8b | 526 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { |
4e25ac79 | 527 | if (IsSelected(AliQAv1::GetDetName(iDet))) { |
2e331c8b | 528 | AliQADataMaker * qadm = GetQADataMaker(iDet) ; |
634696f5 | 529 | AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(iDet) ; |
2e331c8b | 530 | if (!qadm) |
531 | continue ; | |
532 | // skip non active detectors | |
533 | if (detArray) { | |
4e25ac79 | 534 | AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ; |
2e331c8b | 535 | if (!det || !det->IsActive()) |
536 | continue ; | |
537 | } | |
634696f5 | 538 | qac->SetPrintImage(fPrintImage) ; |
eca4fa66 | 539 | |
50dee02c | 540 | if (IsSaveData()) { |
541 | for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) { | |
542 | if ( fTasks.Contains(Form("%d", taskIndex)) ) | |
543 | qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ; | |
544 | } | |
545 | } | |
2e331c8b | 546 | qadm->Finish(); |
547 | } | |
548 | } | |
549 | } | |
550 | ||
551 | //_____________________________________________________________________________ | |
552 | void AliQAManager::EndOfCycle(TString detectors) | |
553 | { | |
554 | // End of cycle QADataMakers | |
555 | ||
634696f5 | 556 | AliQAChecker::Instance()->SetRunNumber(fRunNumber) ; |
fec0891b | 557 | if (fPrintImage) { |
558 | TCanvas fakeCanvas ; | |
559 | fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())) ; | |
560 | } | |
561 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { | |
4e25ac79 | 562 | if (IsSelected(AliQAv1::GetDetName(iDet))) { |
2e331c8b | 563 | AliQADataMaker * qadm = GetQADataMaker(iDet) ; |
634696f5 | 564 | AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(iDet) ; |
2e331c8b | 565 | if (!qadm) |
566 | continue ; | |
567 | // skip non active detectors | |
4e25ac79 | 568 | if (!detectors.Contains(AliQAv1::GetDetName(iDet))) |
2e331c8b | 569 | continue ; |
634696f5 | 570 | qac->SetPrintImage(fPrintImage) ; |
50dee02c | 571 | if (IsSaveData()) { |
572 | for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) { | |
573 | if ( fTasks.Contains(Form("%d", taskIndex)) ) | |
574 | qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ; | |
575 | } | |
576 | } | |
2e331c8b | 577 | qadm->Finish(); |
578 | } | |
579 | } | |
580 | } | |
581 | ||
582 | //_____________________________________________________________________________ | |
5e303886 | 583 | void AliQAManager::Increment(const AliQAv1::TASKINDEX_t taskIndex) |
2e331c8b | 584 | { |
585 | // Increments the cycle counter for all QA Data Makers | |
5e303886 | 586 | static AliQAv1::TASKINDEX_t currentTask = AliQAv1::kNTASKINDEX ; |
587 | if (currentTask == taskIndex) | |
588 | return ; | |
589 | else | |
590 | currentTask = taskIndex ; | |
2e331c8b | 591 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { |
4e25ac79 | 592 | if (IsSelected(AliQAv1::GetDetName(iDet))) { |
2e331c8b | 593 | AliQADataMaker * qadm = GetQADataMaker(iDet) ; |
594 | if (qadm) | |
595 | qadm->Increment() ; | |
596 | } | |
597 | } | |
598 | } | |
599 | ||
600 | //_____________________________________________________________________________ | |
fec0891b | 601 | Bool_t AliQAManager::InitQA(const AliQAv1::TASKINDEX_t taskIndex, const Char_t * input ) |
2e331c8b | 602 | { |
603 | // Initialize the event source and QA data makers | |
604 | ||
605 | fTasks += Form("%d", taskIndex) ; | |
606 | ||
4e25ac79 | 607 | if (taskIndex == AliQAv1::kRAWS) { |
2e331c8b | 608 | if (!fRawReader) { |
609 | fRawReader = AliRawReader::Create(input); | |
610 | } | |
611 | if ( ! fRawReader ) | |
612 | return kFALSE ; | |
613 | fRawReaderDelete = kTRUE ; | |
614 | fRawReader->NextEvent() ; | |
615 | fRunNumber = fRawReader->GetRunNumber() ; | |
616 | SetRun(fRunNumber) ; | |
617 | fRawReader->RewindEvents(); | |
618 | fNumberOfEvents = 999999 ; | |
619 | if ( fMaxEvents < 0 ) | |
620 | fMaxEvents = fNumberOfEvents ; | |
4e25ac79 | 621 | } else if (taskIndex == AliQAv1::kESDS) { |
622 | fTasks = AliQAv1::GetTaskName(AliQAv1::kESDS) ; | |
2e331c8b | 623 | if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists |
624 | TFile * esdFile = TFile::Open("AliESDs.root") ; | |
eca4fa66 | 625 | fESDTree = static_cast<TTree *> (esdFile->Get("esdTree")) ; |
2e331c8b | 626 | if ( !fESDTree ) { |
627 | AliError("esdTree not found") ; | |
628 | return kFALSE ; | |
629 | } else { | |
630 | fESD = new AliESDEvent() ; | |
631 | fESD->ReadFromTree(fESDTree) ; | |
632 | fESDTree->GetEntry(0) ; | |
633 | fRunNumber = fESD->GetRunNumber() ; | |
634 | fNumberOfEvents = fESDTree->GetEntries() ; | |
635 | if ( fMaxEvents < 0 ) | |
636 | fMaxEvents = fNumberOfEvents ; | |
637 | } | |
638 | } else { | |
639 | AliError("AliESDs.root not found") ; | |
640 | return kFALSE ; | |
641 | } | |
642 | } else { | |
643 | if ( !InitRunLoader() ) { | |
644 | AliWarning("No Run Loader not found") ; | |
645 | } else { | |
646 | fNumberOfEvents = fRunLoader->GetNumberOfEvents() ; | |
647 | if ( fMaxEvents < 0 ) | |
648 | fMaxEvents = fNumberOfEvents ; | |
649 | } | |
650 | } | |
651 | ||
652 | // Get Detectors | |
653 | TObjArray* detArray = NULL ; | |
654 | if (fRunLoader) // check if RunLoader exists | |
655 | if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root | |
656 | detArray = fRunLoader->GetAliRun()->Detectors() ; | |
657 | fRunNumber = fRunLoader->GetHeader()->GetRun() ; | |
658 | } | |
659 | ||
660 | // Initialize all QA data makers for all detectors | |
661 | fRunNumber = AliCDBManager::Instance()->GetRun() ; | |
662 | if ( ! AliGeomManager::GetGeometry() ) | |
663 | AliGeomManager::LoadGeometry() ; | |
664 | ||
665 | InitQADataMaker(fRunNumber, detArray) ; //, fCycleSame, kTRUE, detArray) ; | |
fec0891b | 666 | if (fPrintImage) { |
667 | TCanvas fakeCanvas ; | |
668 | fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())) ; | |
669 | } | |
2e331c8b | 670 | return kTRUE ; |
671 | } | |
672 | ||
673 | //_____________________________________________________________________________ | |
674 | void AliQAManager::InitQADataMaker(UInt_t run, TObjArray * detArray) | |
675 | { | |
676 | // Initializes The QADataMaker for all active detectors and for all active tasks | |
fec0891b | 677 | fRunNumber = run ; |
2e331c8b | 678 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { |
4e25ac79 | 679 | if (IsSelected(AliQAv1::GetDetName(iDet))) { |
2e331c8b | 680 | AliQADataMaker * qadm = GetQADataMaker(iDet) ; |
681 | if (!qadm) { | |
4e25ac79 | 682 | AliError(Form("AliQADataMaker not found for %s", AliQAv1::GetDetName(iDet))) ; |
683 | fDetectorsW.ReplaceAll(AliQAv1::GetDetName(iDet), "") ; | |
2e331c8b | 684 | } else { |
685 | if (fQAWriteExpert[iDet]) | |
686 | qadm->SetWriteExpert() ; | |
5379c4a3 | 687 | AliDebug(AliQAv1::GetQADebugLevel(), Form("Data Maker found for %s %d", qadm->GetName(), qadm->WriteExpert())) ; |
2e331c8b | 688 | // skip non active detectors |
689 | if (detArray) { | |
4e25ac79 | 690 | AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ; |
2e331c8b | 691 | if (!det || !det->IsActive()) |
692 | continue ; | |
693 | } | |
2e331c8b | 694 | // Set default reco params |
695 | Bool_t sameCycle = kFALSE ; | |
4e25ac79 | 696 | for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) { |
2e331c8b | 697 | if ( fTasks.Contains(Form("%d", taskIndex)) ) { |
4e25ac79 | 698 | qadm->Init(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), GetQACycles(qadm->GetUniqueID())) ; |
699 | qadm->StartOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), run, sameCycle) ; | |
2e331c8b | 700 | sameCycle = kTRUE ; |
701 | } | |
702 | } | |
703 | } | |
704 | } | |
705 | } | |
706 | } | |
707 | ||
708 | ||
709 | //_____________________________________________________________________________ | |
710 | Bool_t AliQAManager::InitRunLoader() | |
711 | { | |
712 | // get or create the run loader | |
713 | if (fRunLoader) { | |
714 | fCycleSame = kTRUE ; | |
715 | } else { | |
716 | if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists | |
717 | // load all base libraries to get the loader classes | |
718 | TString libs = gSystem->GetLibraries() ; | |
719 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
4e25ac79 | 720 | if (!IsSelected(AliQAv1::GetDetName(iDet))) |
2e331c8b | 721 | continue ; |
4e25ac79 | 722 | TString detName = AliQAv1::GetDetName(iDet) ; |
2e331c8b | 723 | if (detName == "HLT") |
724 | continue; | |
725 | if (libs.Contains("lib" + detName + "base.so")) | |
726 | continue; | |
727 | gSystem->Load("lib" + detName + "base.so"); | |
728 | } | |
729 | fRunLoader = AliRunLoader::Open(fGAliceFileName.Data()); | |
730 | if (!fRunLoader) { | |
731 | AliError(Form("no run loader found in file %s", fGAliceFileName.Data())); | |
732 | return kFALSE; | |
733 | } | |
734 | fRunLoader->CdGAFile(); | |
735 | if (fRunLoader->LoadgAlice() == 0) { | |
736 | gAlice = fRunLoader->GetAliRun(); | |
737 | } | |
738 | ||
739 | if (!gAlice) { | |
740 | AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data())); | |
741 | return kFALSE; | |
742 | } | |
743 | ||
744 | } else { // galice.root does not exist | |
745 | AliError(Form("the file %s does not exist", fGAliceFileName.Data())); | |
746 | return kFALSE; | |
747 | } | |
748 | } | |
749 | ||
750 | if (!fRunNumber) { | |
751 | fRunLoader->LoadHeader(); | |
752 | fRunNumber = fRunLoader->GetHeader()->GetRun() ; | |
753 | } | |
754 | return kTRUE; | |
755 | } | |
756 | ||
757 | //_____________________________________________________________________________ | |
fec0891b | 758 | Bool_t AliQAManager::IsSelected(const Char_t * det) |
2e331c8b | 759 | { |
760 | // check whether detName is contained in detectors | |
761 | // if yes, it is removed from detectors | |
762 | ||
763 | Bool_t rv = kFALSE; | |
764 | const TString detName(det) ; | |
765 | // always activates Correlation | |
4e25ac79 | 766 | if ( detName.Contains(AliQAv1::GetDetName(AliQAv1::kCORR))) { |
2e331c8b | 767 | rv = kTRUE ; |
768 | } else { | |
769 | // check if all detectors are selected | |
770 | if (fDetectors.Contains("ALL")) { | |
771 | fDetectors = "ALL"; | |
772 | rv = kTRUE; | |
773 | } else if ((fDetectors.CompareTo(detName) == 0) || | |
774 | fDetectors.BeginsWith(detName+" ") || | |
775 | fDetectors.EndsWith(" "+detName) || | |
776 | fDetectors.Contains(" "+detName+" ")) { | |
777 | rv = kTRUE; | |
778 | } | |
779 | } | |
780 | return rv ; | |
781 | } | |
782 | ||
783 | //_____________________________________________________________________________ | |
87da0921 | 784 | Bool_t AliQAManager::Merge(Int_t runNumber, const char *fileName) const |
2e331c8b | 785 | { |
bededc30 | 786 | // Merge data from all detectors from a given run in one single file |
87da0921 | 787 | // Merge the QA results from all the data chunks in one run |
788 | // The 'fileName' is name of the output file with merged QA data | |
bededc30 | 789 | if ( runNumber == -1) |
790 | runNumber = fRunNumber ; | |
87da0921 | 791 | Bool_t rv = MergeData(runNumber,fileName) ; |
bededc30 | 792 | //rv *= MergeResults(runNumber) ; // not needed for the time being |
2e331c8b | 793 | return rv ; |
794 | } | |
795 | ||
149a2367 | 796 | //______________________________________________________________________ |
fec0891b | 797 | Bool_t AliQAManager::MergeXML(const Char_t * collectionFile, const Char_t * subFile, const Char_t * outFile) |
149a2367 | 798 | { |
799 | // merges files listed in a xml collection | |
800 | // usage Merge(collection, outputFile)) | |
801 | // collection: is a xml collection | |
802 | ||
803 | Bool_t rv = kFALSE ; | |
804 | ||
805 | if ( strstr(collectionFile, ".xml") == 0 ) { | |
806 | AliError("Input collection file must be an \".xml\" file\n") ; | |
807 | return kFALSE ; | |
808 | } | |
809 | ||
810 | if ( !gGrid ) | |
811 | TGrid::Connect("alien://"); | |
812 | if ( !gGrid ) | |
813 | return kFALSE ; | |
814 | ||
815 | // Open the file collection | |
5e232cd6 | 816 | AliInfoClass(Form("*** Create Collection ***\n*** Wk-Dir = |%s| \n*** Coll = |%s| \n",gSystem->WorkingDirectory(), collectionFile)); |
149a2367 | 817 | |
bededc30 | 818 | TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\")",collectionFile)); |
149a2367 | 819 | TGridResult* result = collection->GetGridResult("", 0, 0); |
820 | ||
821 | Int_t index = 0 ; | |
fec0891b | 822 | const Char_t * turl ; |
adae62c9 | 823 | TFileMerger merger(kFALSE) ; |
149a2367 | 824 | if (!outFile) { |
825 | TString tempo(collectionFile) ; | |
826 | if ( subFile) | |
827 | tempo.ReplaceAll(".xml", subFile) ; | |
828 | else | |
829 | tempo.ReplaceAll(".xml", "_Merged.root") ; | |
830 | outFile = tempo.Data() ; | |
831 | } | |
832 | merger.OutputFile(outFile) ; | |
833 | ||
834 | while ( (turl = result->GetKey(index, "turl")) ) { | |
fec0891b | 835 | Char_t * file ; |
149a2367 | 836 | if ( subFile ) |
837 | file = Form("%s#%s", turl, subFile) ; | |
838 | else | |
839 | file = Form("%s", turl) ; | |
840 | ||
5379c4a3 | 841 | AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", file)) ; |
149a2367 | 842 | merger.AddFile(file) ; |
843 | index++ ; | |
844 | } | |
845 | ||
846 | if (index) | |
847 | merger.Merge() ; | |
848 | ||
5379c4a3 | 849 | AliDebug(AliQAv1::GetQADebugLevel(), Form("Files merged into %s\n", outFile)) ; |
149a2367 | 850 | |
851 | rv = kFALSE; | |
852 | return rv ; | |
853 | } | |
854 | ||
69a898e3 | 855 | //_____________________________________________________________________________ |
856 | void AliQAManager::MergeCustom() const | |
857 | { | |
858 | // Custom Merge of QA data from all detectors for all runs in one single file | |
859 | // search all the run numbers | |
860 | // search all the run numbers | |
861 | gROOT->ProcessLine(".! ls *QA*.root > QAtempo.txt") ; | |
862 | TString QAfile ; | |
863 | FILE * QAfiles = fopen("QAtempo.txt", "r") ; | |
864 | Int_t index = 0 ; | |
865 | TList srunList ; | |
866 | TIter nextRun(&srunList) ; | |
867 | TObjString * srun = NULL ; | |
868 | Int_t loRun = 999999999 ; | |
869 | Int_t hiRun = 0 ; | |
870 | while ( QAfile.Gets(QAfiles) ) { | |
871 | Bool_t runExist = kFALSE ; | |
872 | TString srunNew(QAfile(QAfile.Index("QA.")+3, QAfile.Index(".root")-(QAfile.Index("QA.")+3))) ; | |
873 | Int_t cuRun = srunNew.Atoi() ; | |
874 | if (cuRun < loRun) | |
875 | loRun = cuRun ; | |
876 | if (cuRun > hiRun) | |
877 | hiRun = cuRun ; | |
eca4fa66 | 878 | while ( (srun = static_cast<TObjString *> (nextRun())) ) { |
69a898e3 | 879 | if ( cuRun == (srun->String()).Atoi() ) { |
880 | runExist = kTRUE ; | |
881 | break ; | |
882 | } | |
883 | } | |
884 | nextRun.Reset() ; | |
885 | if ( ! runExist ) | |
886 | srunList.Add(new TObjString(srunNew.Data())); | |
887 | } | |
888 | nextRun.Reset() ; | |
889 | Int_t runNumber = 0 ; | |
4e25ac79 | 890 | TFile mergedFile(Form("Merged.%s.Data.root", AliQAv1::GetQADataFileName()), "RECREATE") ; |
69a898e3 | 891 | TH1I * hisRun = new TH1I("hLMR", "List of merged runs", hiRun-loRun+10, loRun, hiRun+10) ; |
892 | // create the structure into the merged file | |
4e25ac79 | 893 | for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) { |
894 | TDirectory * detDir = mergedFile.mkdir(AliQAv1::GetDetName(iDet)) ; | |
895 | for (Int_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) { | |
69a898e3 | 896 | detDir->cd() ; |
4e25ac79 | 897 | TDirectory * taskDir = gDirectory->mkdir(AliQAv1::GetTaskName(taskIndex)) ; |
69a898e3 | 898 | for (Int_t es = 0 ; es < AliRecoParam::kNSpecies ; es++) { |
899 | taskDir->cd() ; | |
900 | TDirectory * esDir = gDirectory->mkdir(AliRecoParam::GetEventSpecieName(es)) ; | |
901 | esDir->cd() ; | |
4e25ac79 | 902 | gDirectory->mkdir(AliQAv1::GetExpert()) ; |
69a898e3 | 903 | } |
904 | } | |
905 | } | |
eca4fa66 | 906 | while ( (srun = static_cast<TObjString *> (nextRun())) ) { |
69a898e3 | 907 | runNumber = (srun->String()).Atoi() ; |
908 | hisRun->Fill(runNumber) ; | |
5379c4a3 | 909 | AliDebug(AliQAv1::GetQADebugLevel(), Form("Merging run number %d", runNumber)) ; |
69a898e3 | 910 | // search all QA files for runNumber in the current directory |
fec0891b | 911 | Char_t * fileList[AliQAv1::kNDET] ; |
69a898e3 | 912 | index = 0 ; |
4e25ac79 | 913 | for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) { |
fec0891b | 914 | Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber)); |
69a898e3 | 915 | if (file) |
916 | fileList[index++] = file ; | |
917 | } | |
918 | if ( index == 0 ) { | |
919 | AliError("No QA data file found\n") ; | |
920 | return ; | |
921 | } | |
922 | for ( Int_t i = 0 ; i < index ; i++) { | |
923 | TFile * inFile = TFile::Open(fileList[i]) ; | |
924 | TList * listOfKeys =inFile->GetListOfKeys() ; | |
925 | TIter nextkey(listOfKeys) ; | |
926 | TObject * obj1 ; | |
927 | TString dirName("") ; | |
928 | while ( (obj1 = nextkey()) ) { | |
929 | TDirectory * directoryDet = inFile->GetDirectory(obj1->GetName()) ; | |
930 | if ( directoryDet ) { | |
5379c4a3 | 931 | AliDebug(AliQAv1::GetQADebugLevel(), Form("%s dir = %s", inFile->GetName(), directoryDet->GetName())) ; |
69a898e3 | 932 | dirName += Form("%s/", directoryDet->GetName() ) ; |
933 | directoryDet->cd() ; | |
934 | TList * listOfTasks = directoryDet->GetListOfKeys() ; | |
935 | TIter nextTask(listOfTasks) ; | |
936 | TObject * obj2 ; | |
937 | while ( (obj2 = nextTask()) ) { | |
938 | TDirectory * directoryTask = directoryDet->GetDirectory(obj2->GetName()) ; | |
939 | if ( directoryTask ) { | |
940 | dirName += Form("%s", obj2->GetName()) ; | |
5379c4a3 | 941 | AliDebug(AliQAv1::GetQADebugLevel(), Form("%s", dirName.Data())) ; |
69a898e3 | 942 | directoryTask->cd() ; |
943 | TList * listOfEventSpecie = directoryTask->GetListOfKeys() ; | |
944 | TIter nextEventSpecie(listOfEventSpecie) ; | |
945 | TObject * obj3 ; | |
946 | while ( (obj3 = nextEventSpecie()) ) { | |
947 | TDirectory * directoryEventSpecie = directoryTask->GetDirectory(obj3->GetName()) ; | |
948 | if ( directoryEventSpecie ) { | |
949 | dirName += Form("/%s/", obj3->GetName()) ; | |
5379c4a3 | 950 | AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", dirName.Data())) ; |
69a898e3 | 951 | directoryEventSpecie->cd() ; |
952 | // histograms are here | |
953 | TDirectory * mergedDirectory = mergedFile.GetDirectory(dirName.Data()) ; | |
954 | TList * listOfData = directoryEventSpecie->GetListOfKeys() ; | |
955 | TIter nextData(listOfData) ; | |
956 | TKey * key ; | |
eca4fa66 | 957 | while ( (key = static_cast<TKey *>(nextData())) ) { |
69a898e3 | 958 | TString className(key->GetClassName()) ; |
959 | if ( className.Contains("TH") || className.Contains("TProfile") ) { | |
eca4fa66 | 960 | TH1 * histIn = static_cast<TH1*> (key->ReadObj()) ; |
961 | TH1 * histOu = static_cast<TH1*> (mergedDirectory->FindObjectAny(histIn->GetName())) ; | |
5379c4a3 | 962 | AliDebug(AliQAv1::GetQADebugLevel(), Form("%s %x %x\n", key->GetName(), histIn, histOu)) ; |
69a898e3 | 963 | mergedDirectory->cd() ; |
964 | if ( ! histOu ) { | |
965 | histIn->Write() ; | |
966 | } else { | |
967 | histOu->Add(histIn) ; | |
968 | histOu->Write(histOu->GetName(), kOverwrite) ; | |
969 | } | |
970 | } | |
971 | else if ( className.Contains("TDirectoryFile") ) { | |
972 | TDirectory * dirExpert = directoryEventSpecie->GetDirectory(key->GetName()) ; | |
973 | dirExpert->cd() ; | |
974 | TDirectory * mergedDirectoryExpert = mergedDirectory->GetDirectory(dirExpert->GetName()) ; | |
975 | TList * listOfExpertData = dirExpert->GetListOfKeys() ; | |
976 | TIter nextExpertData(listOfExpertData) ; | |
977 | TKey * keykey ; | |
eca4fa66 | 978 | while ( (keykey = static_cast<TKey *>(nextExpertData())) ) { |
69a898e3 | 979 | TString classNameExpert(keykey->GetClassName()) ; |
980 | if (classNameExpert.Contains("TH")) { | |
eca4fa66 | 981 | TH1 * histInExpert = static_cast<TH1*> (keykey->ReadObj()) ; |
982 | TH1 * histOuExpert = static_cast<TH1*> (mergedDirectory->FindObjectAny(histInExpert->GetName())) ; | |
69a898e3 | 983 | mergedDirectoryExpert->cd() ; |
984 | if ( ! histOuExpert ) { | |
985 | histInExpert->Write() ; | |
986 | } else { | |
987 | histOuExpert->Add(histInExpert) ; | |
988 | histOuExpert->Write(histOuExpert->GetName(), kOverwrite) ; | |
989 | } | |
990 | } | |
991 | } | |
992 | } else { | |
993 | AliError(Form("No merge done for this object %s in %s", key->GetName(), dirName.Data())) ; | |
994 | } | |
995 | } | |
996 | dirName.ReplaceAll(Form("/%s/",obj3->GetName()), "") ; | |
997 | } | |
998 | } | |
999 | dirName.ReplaceAll(obj2->GetName(), "") ; | |
1000 | } | |
1001 | } | |
1002 | } | |
1003 | } | |
1004 | inFile->Close() ; | |
1005 | } | |
1006 | } | |
1007 | mergedFile.cd() ; | |
1008 | hisRun->Write() ; | |
1009 | mergedFile.Close() ; | |
1010 | srunList.Delete() ; | |
1011 | } | |
1012 | ||
2e331c8b | 1013 | //_____________________________________________________________________________ |
87da0921 | 1014 | Bool_t AliQAManager::MergeData(const Int_t runNumber, const char *fileName) const |
2e331c8b | 1015 | { |
bededc30 | 1016 | // Merge QA data from all detectors for a given run in one single file |
1017 | ||
87da0921 | 1018 | TFileMerger merger(kFALSE) ; |
1019 | TString outFileName = fileName; | |
1020 | if (outFileName.IsNull()) outFileName.Form("Merged.%s.Data.root",AliQAv1::GetQADataFileName()); | |
2e331c8b | 1021 | merger.OutputFile(outFileName.Data()) ; |
bededc30 | 1022 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { |
fec0891b | 1023 | Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber)); |
bededc30 | 1024 | if (file) |
1025 | merger.AddFile(file) ; | |
1026 | } | |
2e331c8b | 1027 | merger.Merge() ; |
1028 | return kTRUE ; | |
1029 | } | |
1030 | ||
1031 | //_____________________________________________________________________________ | |
1032 | Bool_t AliQAManager::MergeResults(const Int_t runNumber) const | |
1033 | { | |
1034 | // Merge the QA result from all the data chunks in a run | |
bededc30 | 1035 | // to be revised whwn it will be used (see MergeData) |
2e331c8b | 1036 | TString cmd ; |
4e25ac79 | 1037 | cmd = Form(".! ls %s*.root > tempo.txt", AliQAv1::GetQADataFileName()) ; |
2e331c8b | 1038 | gROOT->ProcessLine(cmd.Data()) ; |
1039 | ifstream in("tempo.txt") ; | |
1040 | const Int_t chunkMax = 100 ; | |
1041 | TString fileList[chunkMax] ; | |
1042 | ||
1043 | Int_t index = 0 ; | |
1044 | while ( 1 ) { | |
1045 | TString file ; | |
1046 | in >> fileList[index] ; | |
1047 | if ( !in.good() ) | |
1048 | break ; | |
5379c4a3 | 1049 | AliDebug(AliQAv1::GetQADebugLevel(), Form("index = %d file = %s", index, (fileList[index].Data()))) ; |
2e331c8b | 1050 | index++ ; |
1051 | } | |
1052 | ||
1053 | if ( index == 0 ) { | |
1054 | AliError("No QA Result File found") ; | |
1055 | return kFALSE ; | |
1056 | } | |
1057 | ||
1058 | TFileMerger merger ; | |
fc07289e | 1059 | TString outFileName ; |
1060 | if (runNumber != -1) | |
4e25ac79 | 1061 | outFileName = Form("Merged.%s.Result.%d.root",AliQAv1::GetQADataFileName(),runNumber); |
fc07289e | 1062 | else |
4e25ac79 | 1063 | outFileName = Form("Merged.%s.Result.root",AliQAv1::GetQADataFileName()); |
2e331c8b | 1064 | merger.OutputFile(outFileName.Data()) ; |
1065 | for (Int_t ifile = 0 ; ifile < index ; ifile++) { | |
1066 | TString file = fileList[ifile] ; | |
1067 | merger.AddFile(file) ; | |
1068 | } | |
1069 | merger.Merge() ; | |
1070 | ||
1071 | return kTRUE ; | |
1072 | } | |
1073 | ||
1074 | //_____________________________________________________________________________ | |
1075 | void AliQAManager::Reset(const Bool_t sameCycle) | |
1076 | { | |
1077 | // Reset the default data members | |
1078 | ||
1079 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { | |
4e25ac79 | 1080 | if (IsSelected(AliQAv1::GetDetName(iDet))) { |
2e331c8b | 1081 | AliQADataMaker * qadm = GetQADataMaker(iDet); |
1082 | qadm->Reset(); | |
1083 | } | |
1084 | } | |
1085 | if (fRawReaderDelete) { | |
1086 | delete fRawReader ; | |
1087 | fRawReader = NULL ; | |
1088 | } | |
1089 | ||
1090 | fCycleSame = sameCycle ; | |
1091 | fESD = NULL ; | |
1092 | fESDTree = NULL ; | |
1093 | //fFirst = kTRUE ; | |
1094 | fNumberOfEvents = 999999 ; | |
1095 | } | |
1096 | ||
1097 | //_____________________________________________________________________________ | |
634696f5 | 1098 | AliQAManager * AliQAManager::QAManager(AliQAv1::MODE_t mode, TMap *entryCache, Int_t run) |
2e331c8b | 1099 | { |
1100 | // returns AliQAManager instance (singleton) | |
1101 | ||
1102 | if (!fgQAInstance) { | |
634696f5 | 1103 | if ( (mode != AliQAv1::kSIMMODE) && (mode != AliQAv1::kRECMODE) ) { |
1104 | AliErrorClass("You must specify kSIMMODE or kRECMODE") ; | |
bf76b847 | 1105 | return NULL ; |
1106 | } | |
2e331c8b | 1107 | fgQAInstance = new AliQAManager(mode) ; |
1108 | if (!entryCache) | |
1109 | fgQAInstance->Init(); | |
1110 | else | |
1111 | fgQAInstance->InitFromCache(entryCache,run); | |
1112 | } | |
1113 | return fgQAInstance; | |
1114 | } | |
1115 | ||
5e303886 | 1116 | //_____________________________________________________________________________ |
1117 | AliQAManager * AliQAManager::QAManager(AliQAv1::TASKINDEX_t task) | |
1118 | { | |
1119 | // returns AliQAManager instance (singleton) | |
634696f5 | 1120 | return QAManager(AliQAv1::Mode(task)) ; |
5e303886 | 1121 | } |
1122 | ||
2e331c8b | 1123 | //_____________________________________________________________________________ |
fec0891b | 1124 | TString AliQAManager::Run(const Char_t * detectors, AliRawReader * rawReader, const Bool_t sameCycle) |
2e331c8b | 1125 | { |
1126 | //Runs all the QA data Maker for Raws only | |
1127 | ||
1128 | fCycleSame = sameCycle ; | |
1129 | fRawReader = rawReader ; | |
1130 | fDetectors = detectors ; | |
1131 | fDetectorsW = detectors ; | |
1132 | ||
1133 | AliCDBManager* man = AliCDBManager::Instance() ; | |
1134 | ||
1135 | if ( man->GetRun() == -1 ) {// check if run number not set previously and set it from raw data | |
1136 | rawReader->NextEvent() ; | |
1137 | man->SetRun(fRawReader->GetRunNumber()) ; | |
1138 | rawReader->RewindEvents() ; | |
1139 | } | |
1140 | ||
1141 | if (!fCycleSame) | |
4e25ac79 | 1142 | if ( !InitQA(AliQAv1::kRAWS) ) |
9b4aee57 | 1143 | return "" ; |
2e331c8b | 1144 | fRawReaderDelete = kFALSE ; |
1145 | ||
4e25ac79 | 1146 | DoIt(AliQAv1::kRAWS) ; |
2e331c8b | 1147 | return fDetectorsW ; |
1148 | } | |
1149 | ||
1150 | //_____________________________________________________________________________ | |
fec0891b | 1151 | TString AliQAManager::Run(const Char_t * detectors, const Char_t * fileName, const Bool_t sameCycle) |
2e331c8b | 1152 | { |
1153 | //Runs all the QA data Maker for Raws only | |
1154 | ||
1155 | fCycleSame = sameCycle ; | |
1156 | fDetectors = detectors ; | |
1157 | fDetectorsW = detectors ; | |
1158 | ||
1159 | AliCDBManager* man = AliCDBManager::Instance() ; | |
1160 | if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun | |
1161 | AliRunLoader * rl = AliRunLoader::Open("galice.root") ; | |
1162 | if ( ! rl ) { | |
1163 | AliFatal("galice.root file not found in current directory") ; | |
1164 | } else { | |
1165 | rl->CdGAFile() ; | |
1166 | rl->LoadgAlice() ; | |
1167 | if ( ! rl->GetAliRun() ) { | |
1168 | AliFatal("AliRun not found in galice.root") ; | |
1169 | } else { | |
1170 | rl->LoadHeader() ; | |
1171 | man->SetRun(rl->GetHeader()->GetRun()); | |
1172 | } | |
1173 | } | |
1174 | } | |
1175 | ||
1176 | if (!fCycleSame) | |
4e25ac79 | 1177 | if ( !InitQA(AliQAv1::kRAWS, fileName) ) |
9b4aee57 | 1178 | return "" ; |
2e331c8b | 1179 | |
4e25ac79 | 1180 | DoIt(AliQAv1::kRAWS) ; |
2e331c8b | 1181 | return fDetectorsW ; |
1182 | } | |
1183 | ||
1184 | //_____________________________________________________________________________ | |
fec0891b | 1185 | TString AliQAManager::Run(const Char_t * detectors, const AliQAv1::TASKINDEX_t taskIndex, Bool_t const sameCycle, const Char_t * fileName ) |
2e331c8b | 1186 | { |
1187 | // Runs all the QA data Maker for every detector | |
1188 | ||
1189 | fCycleSame = sameCycle ; | |
1190 | fDetectors = detectors ; | |
1191 | fDetectorsW = detectors ; | |
1192 | ||
1193 | AliCDBManager* man = AliCDBManager::Instance() ; | |
1194 | if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun | |
1195 | AliRunLoader * rl = AliRunLoader::Open("galice.root") ; | |
1196 | if ( ! rl ) { | |
1197 | AliFatal("galice.root file not found in current directory") ; | |
1198 | } else { | |
1199 | rl->CdGAFile() ; | |
1200 | rl->LoadgAlice() ; | |
1201 | if ( ! rl->GetAliRun() ) { | |
5379c4a3 | 1202 | AliDebug(AliQAv1::GetQADebugLevel(), "AliRun not found in galice.root") ; |
2e331c8b | 1203 | } else { |
1204 | rl->LoadHeader() ; | |
1205 | man->SetRun(rl->GetHeader()->GetRun()) ; | |
1206 | } | |
1207 | } | |
1208 | } | |
fec0891b | 1209 | if ( taskIndex == AliQAv1::kNULLTASKINDEX) { |
4e25ac79 | 1210 | for (UInt_t task = 0; task < AliQAv1::kNTASKINDEX; task++) { |
2e331c8b | 1211 | if ( fTasks.Contains(Form("%d", task)) ) { |
1212 | if (!fCycleSame) | |
4e25ac79 | 1213 | if ( !InitQA(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task)), fileName) ) |
9b4aee57 | 1214 | return "" ; |
4e25ac79 | 1215 | DoIt(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task))) ; |
2e331c8b | 1216 | } |
1217 | } | |
1218 | } else { | |
1219 | if (! fCycleSame ) | |
1220 | if ( !InitQA(taskIndex, fileName) ) | |
9b4aee57 | 1221 | return "" ; |
2e331c8b | 1222 | DoIt(taskIndex) ; |
1223 | } | |
2e331c8b | 1224 | return fDetectorsW ; |
2e331c8b | 1225 | } |
1226 | ||
1227 | //_____________________________________________________________________________ | |
1228 | void AliQAManager::RunOneEvent(AliRawReader * rawReader) | |
1229 | { | |
1230 | //Runs all the QA data Maker for Raws only and on one event only (event loop done by calling method) | |
1231 | if ( ! rawReader ) | |
1232 | return ; | |
99c136e1 | 1233 | AliCodeTimerAuto("",0) ; |
0d105c36 | 1234 | if (fTasks.Contains(Form("%d", AliQAv1::kRAWS))){ |
2e331c8b | 1235 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
4e25ac79 | 1236 | if (!IsSelected(AliQAv1::GetDetName(iDet))) |
2e331c8b | 1237 | continue; |
1238 | AliQADataMaker *qadm = GetQADataMaker(iDet); | |
1239 | if (!qadm) | |
1240 | continue; | |
1241 | if ( qadm->IsCycleDone() ) { | |
1242 | qadm->EndOfCycle() ; | |
1243 | } | |
4e25ac79 | 1244 | AliCodeTimerStart(Form("running RAW quality assurance data maker for %s", AliQAv1::GetDetName(iDet))); |
5e232cd6 | 1245 | qadm->SetEventSpecie(fEventSpecie) ; |
13a2370e | 1246 | if ( qadm->GetRecoParam() ) |
5e232cd6 | 1247 | if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault) |
1248 | qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; | |
4e25ac79 | 1249 | qadm->Exec(AliQAv1::kRAWS, rawReader) ; |
1250 | AliCodeTimerStop(Form("running RAW quality assurance data maker for %s", AliQAv1::GetDetName(iDet))); | |
2e331c8b | 1251 | } |
1252 | } | |
1253 | } | |
1254 | ||
1255 | //_____________________________________________________________________________ | |
1256 | void AliQAManager::RunOneEvent(AliESDEvent *& esd) | |
1257 | { | |
1258 | //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method) | |
1259 | ||
99c136e1 | 1260 | AliCodeTimerAuto("",0) ; |
0d105c36 | 1261 | if (fTasks.Contains(Form("%d", AliQAv1::kESDS))) { |
2e331c8b | 1262 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
4e25ac79 | 1263 | if (!IsSelected(AliQAv1::GetDetName(iDet))) |
2e331c8b | 1264 | continue; |
1265 | AliQADataMaker *qadm = GetQADataMaker(iDet); | |
1266 | if (!qadm) | |
1267 | continue; | |
5e232cd6 | 1268 | qadm->SetEventSpecie(fEventSpecie) ; |
82a30871 | 1269 | if ( qadm->GetRecoParam() ) |
5e232cd6 | 1270 | if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault) |
1271 | qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; | |
2e331c8b | 1272 | if ( qadm->IsCycleDone() ) { |
1273 | qadm->EndOfCycle() ; | |
1274 | } | |
4e25ac79 | 1275 | AliCodeTimerStart(Form("running ESD quality assurance data maker for %s", AliQAv1::GetDetName(iDet))); |
1276 | qadm->Exec(AliQAv1::kESDS, esd) ; | |
1277 | AliCodeTimerStop(Form("running ESD quality assurance data maker for %s", AliQAv1::GetDetName(iDet))); | |
2e331c8b | 1278 | } |
1279 | } | |
1280 | } | |
1281 | ||
1282 | //_____________________________________________________________________________ | |
1283 | void AliQAManager::RunOneEventInOneDetector(Int_t det, TTree * tree) | |
1284 | { | |
1285 | // Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method) | |
44ed7a66 | 1286 | |
1287 | TString test(tree->GetName()) ; | |
99c136e1 | 1288 | AliCodeTimerAuto("",0) ; |
0d105c36 | 1289 | if (fTasks.Contains(Form("%d", AliQAv1::kRECPOINTS))) { |
4e25ac79 | 1290 | if (IsSelected(AliQAv1::GetDetName(det))) { |
2e331c8b | 1291 | AliQADataMaker *qadm = GetQADataMaker(det); |
1292 | if (qadm) { | |
5e232cd6 | 1293 | qadm->SetEventSpecie(fEventSpecie) ; |
31c31326 | 1294 | if ( qadm->GetRecoParam() ) { |
5e232cd6 | 1295 | if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault) |
31c31326 | 1296 | qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; |
1297 | else | |
1298 | AliFatal(Form("%d is not an event specie", qadm->GetRecoParam()->GetEventSpecie())) ; | |
1299 | } | |
2e331c8b | 1300 | if ( qadm->IsCycleDone() ) { |
1301 | qadm->EndOfCycle() ; | |
1302 | } | |
4e25ac79 | 1303 | AliCodeTimerStart(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det))); |
44ed7a66 | 1304 | if (test.Contains("TreeD")) { |
1305 | qadm->Exec(AliQAv1::kDIGITSR, tree) ; | |
44ed7a66 | 1306 | } else if (test.Contains("TreeR")) { |
1307 | qadm->Exec(AliQAv1::kRECPOINTS, tree) ; | |
1308 | AliCodeTimerStop(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det))); | |
1309 | } | |
2e331c8b | 1310 | } |
1311 | } | |
1312 | } | |
1313 | } | |
1314 | ||
1315 | //_____________________________________________________________________________ | |
fec0891b | 1316 | Bool_t AliQAManager::Save2OCDB(const Int_t runNumber, AliRecoParam::EventSpecie_t es, const Char_t * year, const Char_t * detectors) const |
2e331c8b | 1317 | { |
1318 | // take the locasl QA data merge into a single file and save in OCDB | |
1319 | Bool_t rv = kTRUE ; | |
4e25ac79 | 1320 | TString tmp(AliQAv1::GetQARefStorage()) ; |
2e331c8b | 1321 | if ( tmp.IsNull() ) { |
4e25ac79 | 1322 | AliError("No storage defined, use AliQAv1::SetQARefStorage") ; |
2e331c8b | 1323 | return kFALSE ; |
1324 | } | |
4e25ac79 | 1325 | if ( !(tmp.Contains(AliQAv1::GetLabLocalOCDB()) || tmp.Contains(AliQAv1::GetLabAliEnOCDB())) ) { |
1326 | AliError(Form("%s is a wrong storage, use %s or %s", AliQAv1::GetQARefStorage(), AliQAv1::GetLabLocalOCDB().Data(), AliQAv1::GetLabAliEnOCDB().Data())) ; | |
2e331c8b | 1327 | return kFALSE ; |
1328 | } | |
1329 | TString sdet(detectors) ; | |
1330 | sdet.ToUpper() ; | |
1331 | TFile * inputFile ; | |
1332 | if ( sdet.Contains("ALL") ) { | |
1333 | rv = Merge(runNumber) ; | |
1334 | if ( ! rv ) | |
1335 | return kFALSE ; | |
4e25ac79 | 1336 | TString inputFileName(Form("Merged.%s.Data.%d.root", AliQAv1::GetQADataFileName(), runNumber)) ; |
2e331c8b | 1337 | inputFile = TFile::Open(inputFileName.Data()) ; |
1338 | rv = SaveIt2OCDB(runNumber, inputFile, year, es) ; | |
1339 | } else { | |
4e25ac79 | 1340 | for (Int_t index = 0; index < AliQAv1::kNDET; index++) { |
1341 | if (sdet.Contains(AliQAv1::GetDetName(index))) { | |
1342 | TString inputFileName(Form("%s.%s.%d.root", AliQAv1::GetDetName(index), AliQAv1::GetQADataFileName(), runNumber)) ; | |
2e331c8b | 1343 | inputFile = TFile::Open(inputFileName.Data()) ; |
1344 | rv *= SaveIt2OCDB(runNumber, inputFile, year, es) ; | |
1345 | } | |
1346 | } | |
1347 | } | |
1348 | return rv ; | |
1349 | } | |
1350 | ||
1351 | //_____________________________________________________________________________ | |
fec0891b | 1352 | Bool_t AliQAManager::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const Char_t * year, AliRecoParam::EventSpecie_t es) const |
2e331c8b | 1353 | { |
1354 | // reads the TH1 from file and adds it to appropriate list before saving to OCDB | |
1355 | Bool_t rv = kTRUE ; | |
5379c4a3 | 1356 | AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQAv1::GetQARefStorage())) ; |
2e331c8b | 1357 | if ( ! IsDefaultStorageSet() ) { |
4e25ac79 | 1358 | TString tmp( AliQAv1::GetQARefStorage() ) ; |
1359 | if ( tmp.Contains(AliQAv1::GetLabLocalOCDB()) ) | |
1360 | Instance()->SetDefaultStorage(AliQAv1::GetQARefStorage()) ; | |
2e331c8b | 1361 | else { |
4e25ac79 | 1362 | TString tmp1(AliQAv1::GetQARefDefaultStorage()) ; |
2e331c8b | 1363 | tmp1.Append(year) ; |
1364 | tmp1.Append("?user=alidaq") ; | |
1365 | Instance()->SetDefaultStorage(tmp1.Data()) ; | |
1366 | } | |
1367 | } | |
4e25ac79 | 1368 | Instance()->SetSpecificStorage("*", AliQAv1::GetQARefStorage()) ; |
2e331c8b | 1369 | if(GetRun() < 0) |
1370 | Instance()->SetRun(runNumber); | |
1371 | ||
1372 | AliCDBMetaData mdr ; | |
1373 | mdr.SetResponsible("yves schutz"); | |
1374 | ||
4e25ac79 | 1375 | for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++) { |
1376 | TDirectory * detDir = inputFile->GetDirectory(AliQAv1::GetDetName(detIndex)) ; | |
2e331c8b | 1377 | if ( detDir ) { |
5379c4a3 | 1378 | AliDebug(AliQAv1::GetQADebugLevel(), Form("Entering %s", detDir->GetName())) ; |
4e25ac79 | 1379 | AliQAv1::SetQARefDataDirName(es) ; |
1380 | TString detOCDBDir(Form("%s/%s/%s", AliQAv1::GetDetName(detIndex), AliQAv1::GetRefOCDBDirName(), AliQAv1::GetRefDataDirName())) ; | |
2e331c8b | 1381 | AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity()) ; |
1382 | TList * listDetQAD = new TList() ; | |
4e25ac79 | 1383 | TString listName(Form("%s QA data Reference", AliQAv1::GetDetName(detIndex))) ; |
1384 | mdr.SetComment(Form("%s QA stuff", AliQAv1::GetDetName(detIndex))); | |
2e331c8b | 1385 | listDetQAD->SetName(listName) ; |
1386 | TList * taskList = detDir->GetListOfKeys() ; | |
1387 | TIter nextTask(taskList) ; | |
1388 | TKey * taskKey ; | |
eca4fa66 | 1389 | while ( (taskKey = static_cast<TKey*>(nextTask())) ) { |
2e331c8b | 1390 | TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ; |
1391 | TDirectory * esDir = taskDir->GetDirectory(AliRecoParam::GetEventSpecieName(es)) ; | |
5379c4a3 | 1392 | AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving %s", esDir->GetName())) ; |
2e331c8b | 1393 | TObjArray * listTaskQAD = new TObjArray(100) ; |
1394 | listTaskQAD->SetName(Form("%s/%s", taskKey->GetName(), AliRecoParam::GetEventSpecieName(es))) ; | |
1395 | listDetQAD->Add(listTaskQAD) ; | |
1396 | TList * histList = esDir->GetListOfKeys() ; | |
1397 | TIter nextHist(histList) ; | |
1398 | TKey * histKey ; | |
eca4fa66 | 1399 | while ( (histKey = static_cast<TKey*>(nextHist())) ) { |
2e331c8b | 1400 | TObject * odata = esDir->Get(histKey->GetName()) ; |
1401 | if ( !odata ) { | |
1402 | AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ; | |
1403 | } else { | |
4e25ac79 | 1404 | if ( AliQAv1::GetExpert() == histKey->GetName() ) { |
2e331c8b | 1405 | TDirectory * expertDir = esDir->GetDirectory(histKey->GetName()) ; |
1406 | TList * expertHistList = expertDir->GetListOfKeys() ; | |
1407 | TIter nextExpertHist(expertHistList) ; | |
1408 | TKey * expertHistKey ; | |
eca4fa66 | 1409 | while ( (expertHistKey = static_cast<TKey*>(nextExpertHist())) ) { |
2e331c8b | 1410 | TObject * expertOdata = expertDir->Get(expertHistKey->GetName()) ; |
1411 | if ( !expertOdata ) { | |
1412 | AliError(Form("%s in %s/%s/Expert returns a NULL pointer !!", expertHistKey->GetName(), detDir->GetName(), taskDir->GetName())) ; | |
1413 | } else { | |
5379c4a3 | 1414 | AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ; |
2e331c8b | 1415 | if ( expertOdata->IsA()->InheritsFrom("TH1") ) { |
5379c4a3 | 1416 | AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ; |
2e331c8b | 1417 | TH1 * hExpertdata = static_cast<TH1*>(expertOdata) ; |
1418 | listTaskQAD->Add(hExpertdata) ; | |
1419 | } | |
1420 | } | |
1421 | } | |
1422 | } | |
5379c4a3 | 1423 | AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ; |
2e331c8b | 1424 | if ( odata->IsA()->InheritsFrom("TH1") ) { |
5379c4a3 | 1425 | AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ; |
2e331c8b | 1426 | TH1 * hdata = static_cast<TH1*>(odata) ; |
1427 | listTaskQAD->Add(hdata) ; | |
1428 | } | |
1429 | } | |
1430 | } | |
1431 | } | |
1432 | Instance()->Put(listDetQAD, idr, &mdr) ; | |
1433 | } | |
1434 | } | |
1435 | return rv ; | |
1436 | } | |
1437 | ||
1438 | //_____________________________________________________________________________ | |
1439 | void AliQAManager::SetEventSpecie(AliRecoParam::EventSpecie_t es) | |
1440 | { | |
4e25ac79 | 1441 | // set the current event specie and inform AliQAv1 that this event specie has been encountered |
bc8761a0 | 1442 | fEventSpecie = es ; |
4e25ac79 | 1443 | AliQAv1::Instance()->SetEventSpecie(es) ; |
2e331c8b | 1444 | } |
1445 | ||
1446 | //_____________________________________________________________________________ | |
1447 | void AliQAManager::SetRecoParam(const Int_t det, const AliDetectorRecoParam *par) | |
1448 | { | |
1449 | // Set custom reconstruction parameters for a given detector | |
1450 | // Single set of parameters for all the events | |
1451 | GetQADataMaker(det)->SetRecoParam(par) ; | |
1452 | } | |
1453 | ||
75373542 | 1454 | //_____________________________________________________________________________ |
1455 | void AliQAManager::SetWriteExpert() | |
1456 | { | |
1457 | // enable the writing of QA expert data | |
1458 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
4e25ac79 | 1459 | if (IsSelected(AliQAv1::GetDetName(iDet))) |
75373542 | 1460 | fQAWriteExpert[iDet] = kTRUE ; |
1461 | } | |
1462 | } | |
7cade814 | 1463 | |
1464 | //_____________________________________________________________________________ | |
1465 | void AliQAManager::Destroy() { | |
bf76b847 | 1466 | // delete AliQAManager instance and |
1467 | // all associated objects | |
7cade814 | 1468 | |
1469 | if (fgQAInstance) { | |
eca4fa66 | 1470 | delete fgQAInstance ; |
1471 | fgQAInstance = NULL ; | |
7cade814 | 1472 | } |
1473 | } | |
1474 | ||
bf76b847 | 1475 | //_____________________________________________________________________________ |
1476 | void AliQAManager::ShowQA() { | |
1477 | // Show the result of the QA checking | |
1478 | // for all detectors | |
1479 | for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++) | |
1480 | AliQAv1::Instance(AliQAv1::GetDetIndex(AliQAv1::GetDetName(detIndex)))->Show() ; | |
1481 | } |