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