]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliQAChecker.cxx
Updates for pile-up vertex (F. Prino)
[u/mrichter/AliRoot.git] / STEER / AliQAChecker.cxx
CommitLineData
421ab0fb 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: */
17
18///////////////////////////////////////////////////////////////////////////////
19// //
20// class for running the Quality Assurance Checker
21// //
22///////////////////////////////////////////////////////////////////////////////
23
4edbc5bc 24#include "AliCDBEntry.h"
b03591ab 25#include "AliQAManager.h"
96d67a8d 26#include "AliCDBStorage.h"
1aaf4118 27#include "AliRunInfo.h"
421ab0fb 28#include "AliLog.h"
29#include "AliModule.h"
4e25ac79 30#include "AliQAv1.h"
2e42b4d4 31#include "AliQAChecker.h"
32#include "AliQACheckerBase.h"
a2b64fbd 33#include "AliCorrQAChecker.h"
401b84d6 34#include "AliGlobalQAChecker.h"
44e45fac 35#include "AliGRPObject.h"
421ab0fb 36
a5fa6165 37#include <TKey.h>
421ab0fb 38#include <TObjArray.h>
cbae8032 39#include <TObjString.h>
a5fa6165 40#include <TPluginManager.h>
41#include <TROOT.h>
421ab0fb 42#include <TStopwatch.h>
43#include <TString.h>
a5fa6165 44#include <TSystem.h>
a4976ef3 45#include <TList.h>
a2b64fbd 46#include <TNtupleD.h>
421ab0fb 47
2e42b4d4 48ClassImp(AliQAChecker)
49 AliQAChecker * AliQAChecker::fgQAChecker = 0x0 ;
421ab0fb 50
51//_____________________________________________________________________________
2e42b4d4 52AliQAChecker::AliQAChecker(const char* name, const char* title) :
421ab0fb 53 TNamed(name, title),
a5fa6165 54 fDataFile(0x0),
7e88424f 55 fRunInfo(0x0),
56 fRunInfoOwner(kFALSE),
4edbc5bc 57 fRefFile(0x0),
57acd2d2 58 fFoundDetectors("."),
634696f5 59 fEventSpecie(AliRecoParam::kDefault),
60 fRun(0)
421ab0fb 61{
a5fa6165 62 // ctor: initialise checkers and open the data file
4e25ac79 63 for (Int_t det = 0 ; det < AliQAv1::kNDET ; det++)
a5fa6165 64 fCheckers[det] = NULL ;
421ab0fb 65}
66
67//_____________________________________________________________________________
2e42b4d4 68AliQAChecker::AliQAChecker(const AliQAChecker& qac) :
421ab0fb 69 TNamed(qac),
a5fa6165 70 fDataFile(qac.fDataFile),
7e88424f 71 fRunInfo(qac.fRunInfo),
72 fRunInfoOwner(kFALSE),
4edbc5bc 73 fRefFile(qac.fRefFile),
57acd2d2 74 fFoundDetectors(qac.fFoundDetectors),
634696f5 75 fEventSpecie(qac.fEventSpecie),
76 fRun(qac.fRun)
421ab0fb 77{
a5fa6165 78 // copy constructor
79
4e25ac79 80 for (Int_t det = 0 ; det < AliQAv1::kNDET ; det++)
a5fa6165 81 fCheckers[det] = NULL ;
421ab0fb 82}
83
84//_____________________________________________________________________________
2e42b4d4 85AliQAChecker& AliQAChecker::operator = (const AliQAChecker& qac)
421ab0fb 86{
87// assignment operator
88
2e42b4d4 89 this->~AliQAChecker();
90 new(this) AliQAChecker(qac);
421ab0fb 91 return *this;
92}
93
94//_____________________________________________________________________________
2e42b4d4 95AliQAChecker::~AliQAChecker()
421ab0fb 96{
97// clean up
7e88424f 98 if (fRunInfo)
99 delete fRunInfo ;
a4976ef3 100 delete [] fCheckers ;
4e25ac79 101 AliQAv1::Close() ;
421ab0fb 102}
103
104//_____________________________________________________________________________
2e42b4d4 105 AliQACheckerBase * AliQAChecker::GetDetQAChecker(Int_t det)
421ab0fb 106{
7ce961eb 107 // Gets the Quality Assurance checker for the detector specified by its name
108
109 if (fCheckers[det])
a5fa6165 110 return fCheckers[det];
111
401b84d6 112 AliQACheckerBase * qac = NULL ;
a5fa6165 113
4e25ac79 114 TString detName(AliQAv1::GetDetName(det)) ;
401b84d6 115
4e25ac79 116 if (det == AliQAv1::kGLOBAL) {
401b84d6 117 qac = new AliGlobalQAChecker() ;
4e25ac79 118 } else if (det == AliQAv1::kCORR) {
a2b64fbd 119 qac = new AliCorrQAChecker() ;
401b84d6 120 } else {
634696f5 121 AliDebugClass(AliQAv1::GetQADebugLevel(), Form("Retrieving QA checker for %s", detName.Data())) ;
401b84d6 122 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
123 TString qacName = "Ali" + detName + "QAChecker" ;
124
125 // first check if a plugin is defined for the quality assurance checker
126 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQAChecker", detName.Data());
127 // if not, add a plugin for it
128 if (!pluginHandler) {
5379c4a3 129 //AliDebug(AliQAv1::GetQADebugLevel(), Form("defining plugin for %s", qacName.Data()));
401b84d6 130 TString libs = gSystem->GetLibraries();
7ce961eb 131
401b84d6 132 if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0))
133 pluginManager->AddHandler("AliQAChecker", detName, qacName, detName + "qac", qacName + "()");
134 else
135 pluginManager->AddHandler("AliQAChecker", detName, qacName, detName, qacName + "()");
a5fa6165 136
401b84d6 137 pluginHandler = pluginManager->FindHandler("AliQAChecker", detName);
a5fa6165 138
401b84d6 139 if (pluginHandler && (pluginHandler->LoadPlugin() == 0))
140 qac = (AliQACheckerBase *) pluginHandler->ExecPlugin(0);
a5fa6165 141
401b84d6 142 }
7ce961eb 143 }
401b84d6 144 if (qac)
145 fCheckers[det] = qac ;
146
147 return qac ;
a5fa6165 148}
421ab0fb 149
a4976ef3 150//_____________________________________________________________________________
2e42b4d4 151AliQAChecker * AliQAChecker::Instance()
a4976ef3 152{
153 // returns unique instance of the checker
154 if ( ! fgQAChecker )
2e42b4d4 155 fgQAChecker = new AliQAChecker() ;
a4976ef3 156 return fgQAChecker ;
157}
158
cbae8032 159//_____________________________________________________________________________
7e88424f 160void AliQAChecker::LoadRunInfoFromGRP()
cbae8032 161{
162 AliCDBManager* man = AliCDBManager::Instance() ;
4e25ac79 163 AliCDBEntry* entry = man->Get(AliQAv1::GetGRPPath().Data());
44e45fac 164 AliGRPObject* grpObject = 0x0;
165 if (entry) {
166
eca4fa66 167 TMap* m = static_cast<TMap*>(entry->GetObject()); // old GRP entry
44e45fac 168
169 if (m) {
5379c4a3 170 AliDebug(AliQAv1::GetQADebugLevel(), "It is a map");
44e45fac 171 //m->Print();
172 grpObject = new AliGRPObject();
173 grpObject->ReadValuesFromMap(m);
174 }
175
176 else {
5379c4a3 177 AliDebug(AliQAv1::GetQADebugLevel(), "It is a new GRP object");
eca4fa66 178 grpObject = static_cast<AliGRPObject*>(entry->GetObject()); // new GRP entry
44e45fac 179 }
180
181 entry->SetOwner(0);
182 AliCDBManager::Instance()->UnloadFromCache("GRP/GRP/Data");
183 }
184
185 if (!grpObject) {
186 AliFatal("No GRP entry found in OCDB!");
cbae8032 187 }
44e45fac 188
189 TString lhcState = grpObject->GetLHCState();
190 if (lhcState==AliGRPObject::GetInvalidString()) {
191 AliError("GRP/GRP/Data entry: missing value for the LHC state ! Using UNKNOWN");
192 lhcState = "UNKNOWN";
193 }
194
195 TString beamType = grpObject->GetBeamType();
196 if (beamType==AliGRPObject::GetInvalidString()) {
197 AliError("GRP/GRP/Data entry: missing value for the beam type ! Using UNKNOWN");
198 beamType = "UNKNOWN";
cbae8032 199 }
44e45fac 200
201 Float_t beamEnergy = grpObject->GetBeamEnergy();
202 if (beamEnergy==AliGRPObject::GetInvalidFloat()) {
203 AliError("GRP/GRP/Data entry: missing value for the beam energy ! Using 0");
204 beamEnergy = 0;
cbae8032 205 }
44e45fac 206
207 TString runType = grpObject->GetRunType();
208 if (runType==AliGRPObject::GetInvalidString()) {
209 AliError("GRP/GRP/Data entry: missing value for the run type ! Using UNKNOWN");
210 runType = "UNKNOWN";
7e88424f 211 }
44e45fac 212
213 Int_t activeDetectors = grpObject->GetDetectorMask();
214 if (activeDetectors==AliGRPObject::GetInvalidInt()) {
215 AliError("GRP/GRP/Data entry: missing value for the detector mask ! Using 1074790399");
216 activeDetectors = 1074790399;
cbae8032 217 }
44e45fac 218
219 fRunInfo = new AliRunInfo(lhcState, beamType, beamEnergy, runType, activeDetectors);
220
7e88424f 221 fRunInfoOwner = kTRUE ;
57acd2d2 222
223 // set the event specie
224 fEventSpecie = AliRecoParam::kDefault ;
225 if (strcmp(runType,"PHYSICS")) {
226 // Not a physics run, the event specie is set to kCalib
227 fEventSpecie = AliRecoParam::kCalib ;
228 return;
229 }
230 if (strcmp(lhcState,"STABLE_BEAMS") == 0) {
231 // Heavy ion run (any beam tha is not pp, the event specie is set to kHighMult
232 fEventSpecie = AliRecoParam::kHighMult ;
233 if ((strcmp(beamType,"p-p") == 0) ||
234 (strcmp(beamType,"p-") == 0) ||
235 (strcmp(beamType,"-p") == 0) ||
236 (strcmp(beamType,"P-P") == 0) ||
237 (strcmp(beamType,"P-") == 0) ||
238 (strcmp(beamType,"-P") == 0)) {
239 // Proton run, the event specie is set to kLowMult
240 fEventSpecie = AliRecoParam::kLowMult ;
241 }
242 else if (strcmp(beamType,"-") == 0) {
243 // No beams, we assume cosmic data
244 fEventSpecie = AliRecoParam::kCosmic ;
245 }
246 else if (strcmp(beamType,"UNKNOWN") == 0) {
247 // No LHC beam information is available, we use the default event specie
248 fEventSpecie = AliRecoParam::kDefault ;
249 }
250 }
cbae8032 251}
252
421ab0fb 253//_____________________________________________________________________________
9c980fe5 254Bool_t AliQAChecker::Run(const char * fileName, AliDetectorRecoParam * recoParam)
421ab0fb 255{
44ed7a66 256 // run the Quality Assurance Checker for all tasks Hits, SDigits, Digits, DigitsR, RecPoints, TrackSegments, RecParticles and ESDs
57acd2d2 257 // starting from data in file
421ab0fb 258 TStopwatch stopwatch;
259 stopwatch.Start();
c39ee44c 260
a5fa6165 261 //search for all detectors QA directories
4e25ac79 262 TList * detKeyList = AliQAv1::GetQADataFile(fileName)->GetListOfKeys() ;
a5fa6165 263 TIter nextd(detKeyList) ;
264 TKey * detKey ;
eca4fa66 265 while ( (detKey = static_cast<TKey *>(nextd()) ) ) {
5379c4a3 266 AliDebug(AliQAv1::GetQADebugLevel(), Form("Found %s", detKey->GetName())) ;
a5fa6165 267 //Check which detector
268 TString detName ;
269 TString detNameQA(detKey->GetName()) ;
270 Int_t det ;
4e25ac79 271 for ( det = 0; det < AliQAv1::kNDET ; det++) {
272 detName = AliQAv1::GetDetName(det) ;
a5fa6165 273 if (detNameQA.Contains(detName)) {
57acd2d2 274 fFoundDetectors+=detName ;
275 fFoundDetectors+="." ;
276 break ;
a5fa6165 277 }
278 }
4e25ac79 279 TDirectory * detDir = AliQAv1::GetQADataFile(fileName)->GetDirectory(detKey->GetName()) ;
a5fa6165 280 TList * taskKeyList = detDir->GetListOfKeys() ;
281 TIter nextt(taskKeyList) ;
282 TKey * taskKey ;
283 // now search for the tasks dir
284 while ( (taskKey = static_cast<TKey *>(nextt()) ) ) {
285 TString taskName( taskKey->GetName() ) ;
5379c4a3 286 AliDebug(AliQAv1::GetQADebugLevel(), Form("Found %s", taskName.Data())) ;
a5fa6165 287 TDirectory * taskDir = detDir->GetDirectory(taskName.Data()) ;
288 taskDir->cd() ;
2e42b4d4 289 AliQACheckerBase * qac = GetDetQAChecker(det) ;
a5fa6165 290 if (qac)
5379c4a3 291 AliDebug(AliQAv1::GetQADebugLevel(), Form("QA checker found for %s", detName.Data())) ;
a5fa6165 292 if (!qac)
57acd2d2 293 AliFatal(Form("QA checker not found for %s", detName.Data())) ;
4e25ac79 294 AliQAv1::ALITASK_t index = AliQAv1::kNULLTASK ;
295 if ( taskName == AliQAv1::GetTaskName(AliQAv1::kHITS) )
296 index = AliQAv1::kSIM ;
297 if ( taskName == AliQAv1::GetTaskName(AliQAv1::kSDIGITS) )
298 index = AliQAv1::kSIM ;
299 if ( taskName == AliQAv1::GetTaskName(AliQAv1::kDIGITS) )
300 index = AliQAv1::kSIM ;
d62b07c8 301 if ( taskName == AliQAv1::GetTaskName(AliQAv1::kRAWS) )
302 index = AliQAv1::kRAW ;
44ed7a66 303 if ( taskName == AliQAv1::GetTaskName(AliQAv1::kDIGITSR) )
304 index = AliQAv1::kREC ;
4e25ac79 305 if ( taskName == AliQAv1::GetTaskName(AliQAv1::kRECPOINTS) )
306 index = AliQAv1::kREC ;
307 if ( taskName == AliQAv1::GetTaskName(AliQAv1::kTRACKSEGMENTS) )
308 index = AliQAv1::kREC ;
309 if ( taskName == AliQAv1::GetTaskName(AliQAv1::kRECPARTICLES) )
310 index = AliQAv1::kREC ;
311 if ( taskName == AliQAv1::GetTaskName(AliQAv1::kESDS) )
312 index = AliQAv1::kESD ;
313 qac->Init(AliQAv1::DETECTORINDEX_t(det)) ;
9c980fe5 314 qac->Run(index, recoParam) ;
57acd2d2 315 }
4edbc5bc 316 }
c39ee44c 317 TString detList ;
4e25ac79 318 for ( Int_t det = 0; det < AliQAv1::kNDET; det++) {
2a022cb2 319 if (fFoundDetectors.Contains(AliQAv1::GetDetName(det))) {
320 detList += AliQAv1::GetDetName(det) ;
c39ee44c 321 detList += " " ;
2a022cb2 322 fFoundDetectors.ReplaceAll(AliQAv1::GetDetName(det), "") ;
323 AliQAv1::Instance()->Show(AliQAv1::GetDetIndex(AliQAv1::GetDetName(det))) ;
a5fa6165 324 }
421ab0fb 325 }
c39ee44c 326 AliInfo(Form("QA performed for following detectors: %s", detList.Data())) ;
57acd2d2 327 return kTRUE ;
421ab0fb 328}
329
a4976ef3 330//_____________________________________________________________________________
9c980fe5 331Bool_t AliQAChecker::Run(AliQAv1::DETECTORINDEX_t det, AliQAv1::TASKINDEX_t task, TObjArray ** list, AliDetectorRecoParam * recoParam)
a4976ef3 332{
d6372ce8 333 // run the Quality Assurance Checker for detector det, for task task starting from data in list
a4976ef3 334
d6372ce8 335 AliQACheckerBase * qac = GetDetQAChecker(det) ;
336 if (qac)
5379c4a3 337 AliDebug(AliQAv1::GetQADebugLevel(), Form("QA checker found for %s", AliQAv1::GetDetName(det).Data())) ;
d6372ce8 338 if (!qac)
4e25ac79 339 AliError(Form("QA checker not found for %s", AliQAv1::GetDetName(det).Data())) ;
a4976ef3 340
4e25ac79 341 AliQAv1::ALITASK_t index = AliQAv1::kNULLTASK ;
342 if ( task == AliQAv1::kRAWS )
343 index = AliQAv1::kRAW ;
344 else if ( task == AliQAv1::kHITS )
345 index = AliQAv1::kSIM ;
346 else if ( task == AliQAv1::kSDIGITS )
347 index = AliQAv1::kSIM ;
348 else if ( task == AliQAv1::kDIGITS )
349 index = AliQAv1::kSIM ;
44ed7a66 350 else if ( task == AliQAv1::kDIGITSR )
351 index = AliQAv1::kREC ;
4e25ac79 352 else if ( task == AliQAv1::kRECPOINTS )
353 index = AliQAv1::kREC ;
354 else if ( task == AliQAv1::kTRACKSEGMENTS )
355 index = AliQAv1::kREC ;
356 else if ( task == AliQAv1::kRECPARTICLES )
357 index = AliQAv1::kREC ;
358 else if ( task == AliQAv1::kESDS )
359 index = AliQAv1::kESD ;
4edbc5bc 360
57acd2d2 361 qac->Init(det) ;
9c980fe5 362 qac->Run(index, list, recoParam) ;
634696f5 363
364 // make the image
365 qac->MakeImage(list, task, AliQAv1::Mode(task)) ;
366
d6372ce8 367 return kTRUE ;
31316597 368}
57acd2d2 369
370//_____________________________________________________________________________
9c980fe5 371Bool_t AliQAChecker::Run(AliQAv1::DETECTORINDEX_t det, AliQAv1::TASKINDEX_t task, TNtupleD ** list, AliDetectorRecoParam * recoParam)
57acd2d2 372{
373 // run the Quality Assurance Checker for detector det, for task task starting from data in list
374
375 AliQACheckerBase * qac = GetDetQAChecker(det) ;
376 if (qac)
5379c4a3 377 AliDebug(AliQAv1::GetQADebugLevel(), Form("QA checker found for %s", AliQAv1::GetDetName(det).Data())) ;
57acd2d2 378 if (!qac)
4e25ac79 379 AliError(Form("QA checker not found for %s", AliQAv1::GetDetName(det).Data())) ;
57acd2d2 380
4e25ac79 381 AliQAv1::ALITASK_t index = AliQAv1::kNULLTASK ;
382 if ( task == AliQAv1::kRAWS )
383 index = AliQAv1::kRAW ;
384 else if ( task == AliQAv1::kHITS )
385 index = AliQAv1::kSIM ;
386 else if ( task == AliQAv1::kSDIGITS )
387 index = AliQAv1::kSIM ;
388 else if ( task == AliQAv1::kDIGITS )
389 index = AliQAv1::kSIM ;
44ed7a66 390 else if ( task == AliQAv1::kDIGITSR )
391 index = AliQAv1::kREC ;
4e25ac79 392 else if ( task == AliQAv1::kRECPOINTS )
393 index = AliQAv1::kREC ;
394 else if ( task == AliQAv1::kTRACKSEGMENTS )
395 index = AliQAv1::kREC ;
396 else if ( task == AliQAv1::kRECPARTICLES )
397 index = AliQAv1::kREC ;
398 else if ( task == AliQAv1::kESDS )
399 index = AliQAv1::kESD ;
57acd2d2 400
57acd2d2 401 qac->Init(det) ;
9c980fe5 402 qac->Run(index, list, recoParam) ;
634696f5 403
57acd2d2 404 return kTRUE ;
405}