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