From 421ab0fb59438f7b070608b0af3c14b9568ca945 Mon Sep 17 00:00:00 2001 From: hristov Date: Wed, 8 Aug 2007 06:26:14 +0000 Subject: [PATCH] New QA classes (Yves) --- STEER/AliModule.h | 7 +- STEER/AliQualAss.cxx | 397 ++++++++++++++++++++++++++++++++ STEER/AliQualAss.h | 79 +++++++ STEER/AliQualAssChecker.cxx | 200 ++++++++++++++++ STEER/AliQualAssChecker.h | 56 +++++ STEER/AliQualAssCheckerBase.cxx | 153 ++++++++++++ STEER/AliQualAssCheckerBase.h | 49 ++++ STEER/AliQualAssDataMaker.cxx | 224 ++++++++++++++++++ STEER/AliQualAssDataMaker.h | 66 ++++++ STEER/STEERLinkDef.h | 5 + STEER/libSTEER.pkg | 6 +- 11 files changed, 1239 insertions(+), 3 deletions(-) create mode 100644 STEER/AliQualAss.cxx create mode 100644 STEER/AliQualAss.h create mode 100644 STEER/AliQualAssChecker.cxx create mode 100644 STEER/AliQualAssChecker.h create mode 100644 STEER/AliQualAssCheckerBase.cxx create mode 100644 STEER/AliQualAssCheckerBase.h create mode 100644 STEER/AliQualAssDataMaker.cxx create mode 100644 STEER/AliQualAssDataMaker.h diff --git a/STEER/AliModule.h b/STEER/AliModule.h index e28974ea1a8..0af74904446 100644 --- a/STEER/AliModule.h +++ b/STEER/AliModule.h @@ -15,6 +15,7 @@ #include #include +#include "AliLog.h" #include "AliTriggerDetector.h" class TClonesArray; @@ -97,6 +98,7 @@ public: virtual void Digits2Raw(); virtual void Raw2Digits() {} virtual Bool_t Raw2SDigits(AliRawReader*) {return kFALSE;} + virtual void QualAssDataMaker (const char *) {} virtual void Browse(TBrowser *) {} //PH Do we need it? virtual void CreateGeometry() {} virtual void CreateMaterials() {} @@ -148,8 +150,9 @@ public: void SetRunLoader(AliRunLoader* runLoader) {fRunLoader = runLoader;} -// - +// Quality Assurance methods + virtual void CheckQA() { ; } + protected: // Data members diff --git a/STEER/AliQualAss.cxx b/STEER/AliQualAss.cxx new file mode 100644 index 00000000000..16aa20bdb76 --- /dev/null +++ b/STEER/AliQualAss.cxx @@ -0,0 +1,397 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ +/* $Id$ */ + +////////////////////////////////////////////////////////////////////////////// +// +// Quality Assurance Object//_________________________________________________________________________ +// Quality Assurance object. The QA status is held in one word per detector, +// each bit corresponds to a different status. +// bit 0-3 : QA raised during simulation (SIM) +// bit 4-7 : QA raised during reconstruction (REC) +// bit 8-11 : QA raised during ESD checking (ESD) +// bit 12-15: QA raised during analysis (ANA) +// Each of the 4 bits corresponds to a severity level of increasing importance +// from lower to higher bit (INFO, WARNING, ERROR, FATAL) +// +//*-- Yves Schutz CERN, July 2007 +////////////////////////////////////////////////////////////////////////////// + + +// --- ROOT system --- +#include +#include + +// --- Standard library --- + +// --- AliRoot header files --- +#include "AliLog.h" +#include "AliQualAss.h" + + +ClassImp(AliQualAss) + + AliQualAss * AliQualAss::fgQA = 0x0 ; + TFile * AliQualAss::fgOutput = 0x0 ; + TString AliQualAss::fgOutputName = "QA.root" ; + +//____________________________________________________________________________ +AliQualAss::AliQualAss() : + TNamed("", ""), + fNdet(12), + fQA(0x0), + fDet(kNULLDET), + fTask(kNULLTASK) +{ + // default constructor + // beware singleton: not to be used +} + +//____________________________________________________________________________ +AliQualAss::AliQualAss(const AliQualAss& qa) : + TNamed(qa), + fNdet(qa.fNdet), + fQA(qa.fQA), + fDet(qa.fDet), + fTask(qa.fTask) +{ + // cpy ctor +} + +//_____________________________________________________________________________ +AliQualAss& AliQualAss::operator = (const AliQualAss& qa) +{ +// assignment operator + + this->~AliQualAss(); + new(this) AliQualAss(qa); + return *this; +} + +//_______________________________________________________________ +AliQualAss::AliQualAss(ALITASK tsk) : + TNamed("QA", "Quality Assurance status"), + fNdet(12), + fQA(0x0), + fDet(kNULLDET), + fTask(tsk) +{ + // constructor to be used in the AliRoot module (SIM, REC, ESD or ANA) + if (! CheckRange(tsk) ) { + fTask = kNULLTASK ; + return ; + } else { + fQA = new ULong_t[fNdet] ; + Int_t index ; + for ( index = 0 ; index <= fNdet ; index++) + ResetStatus(DETECTORINDEX(index)) ; + } +} + +//____________________________________________________________________________ +AliQualAss::~AliQualAss() +{ + // dtor + delete[] fQA ; +} + +//_______________________________________________________________ +const Bool_t AliQualAss::CheckRange(DETECTORINDEX det) const +{ + // check if detector is in given detector range: 0-fNdet + + Bool_t rv = ( det < 0 || det > fNdet ) ? kFALSE : kTRUE ; + if (!rv) + AliFatal(Form("Detector index %d is out of range: 0 <= index <= %d", det, kNDET)) ; + return rv ; +} + +//_______________________________________________________________ +const Bool_t AliQualAss::CheckRange(ALITASK task) const +{ + // check if task is given taskk range: 0:kNTASK + Bool_t rv = ( task < kSIM || task > kNTASK ) ? kFALSE : kTRUE ; + if (!rv) + AliFatal(Form("Module index %d is out of range: 0 <= index <= %d", task, kNTASK)) ; + return rv ; +} + +//_______________________________________________________________ +const Bool_t AliQualAss::CheckRange(QABIT bit) const +{ + // check if bit is in given bit range: 0-kNBit + + Bool_t rv = ( bit < 0 || bit > kNBIT ) ? kFALSE : kTRUE ; + if (!rv) + AliFatal(Form("Status bit %d is out of range: 0 <= bit <= %d", bit, kNBIT)) ; + return rv ; +} + +//_______________________________________________________________ +const char * AliQualAss::GetDetectorName(DETECTORINDEX det) const +{ + // returns the char name corresponding to detector index + + char * detName = ""; + switch (det) { + case kNULLDET: + break ; + case kITS: + detName = "ITS" ; + break ; + case kTPC: + detName = "TPC" ; + break ; + case kTRD: + detName = "TRD" ; + break ; + case kTOF: + detName = "TOF" ; + break ; + case kPHOS: + detName = "PHOS" ; + break ; + case kHMPID: + detName = "HMPID" ; + break ; + case kEMCAL: + detName = "EMCAL" ; + break ; + case kMUON: + detName = "MUON" ; + break ; + case kFMD: + detName = "FMD" ; + break ; + case kZDC: + detName = "ZDC" ; + break ; + case kPMD: + detName = "PMD" ; + break ; + case kT0: + detName = "TO" ; + break ; + case kVZERO: + detName = "VZERO" ; + break ; + case kACORDE: + detName = "ACORDE" ; + break ; + case kHLT: + detName = "HLT" ; + break ; + default: + AliError(Form("%d is not a valid detector index %d <= index <= %d\n", det, 0, kNDET-1)) ; + break ; + } + return detName ; +} + +//_______________________________________________________________ +TFile * AliQualAss::GetQADMOutFile() +{ + // opens the file to store the detectors Quality Assurance Data Maker results + + if (! fgOutput ) { + char opt[6] ; + if (gSystem->AccessPathName(fgOutputName.Data())) + sprintf(opt, "%s", "NEW") ; + else + sprintf(opt, "%s", "UPDATE") ; + + fgOutput = TFile::Open(fgOutputName.Data(), opt) ; + } + return fgOutput ; +} + +//_______________________________________________________________ +const char * AliQualAss::GetTaskName(ALITASK tsk) const +{ + // returns the char name corresponding to module index + char * tskName = "" ; + switch (tsk) { + case kNULLTASK: + break ; + case kSIM: + tskName = "SIM" ; + break ; + case kREC: + tskName = "REC" ; + break ; + case kESD: + tskName = "ESD" ; + break ; + case kANA: + tskName = "ANA" ; + break ; + default: + AliError(Form("%d is not a valid module index %d <= index <= %d\n", tsk, 0, kNTASK-1)) ; + break ; + } + return tskName ; +} + +//_______________________________________________________________ +const Bool_t AliQualAss::CheckFatal() const +{ + // check if any FATAL status is set + Bool_t rv = kFALSE ; + Int_t index ; + for (index = 0; index < kNDET ; index++) + rv = rv || IsSet(DETECTORINDEX(index), fTask, kFATAL) ; + return rv ; +} + +//_______________________________________________________________ +const Bool_t AliQualAss::IsSet(DETECTORINDEX det, ALITASK tsk, QABIT bit) const +{ + // Checks is the requested bit is set + + CheckRange(det) ; + CheckRange(tsk) ; + CheckRange(bit) ; + + ULong_t offset = Offset(tsk) ; + ULong_t status = GetStatus(det) ; + offset+= bit ; + status = (status & 1 << offset) != 0 ; + return status ; +} + +//_______________________________________________________________ +AliQualAss * AliQualAss::Instance() +{ + // Get an instance of the singleton. + // Object must have been instantiated with Instance(ALITASK) first + + return fgQA ; +} + +//_______________________________________________________________ +AliQualAss * AliQualAss::Instance(DETECTORINDEX det) +{ + // Get an instance of the singleton. The only authorized way to call the ctor + + fgQA->Set(det) ; + return fgQA ; +} + +//_______________________________________________________________ +AliQualAss * AliQualAss::Instance(ALITASK tsk) +{ + // get an instance of the singleton. + + if ( ! fgQA) + switch (tsk) { + case kNULLTASK: + break ; + case kSIM: + fgQA = new AliQualAss(tsk) ; + break ; + case kREC: + printf("fgQA = gAlice->GetQA()") ; + break ; + case kESD: + printf("fgQA = dynamic_cast (esdFile->Get(\"QA\")") ; + break ; + case kANA: + printf("fgQA = dynamic_cast (esdFile->Get(\"QA\")") ; + break ; + case kNTASK: + break ; + } + if (fgQA) + fgQA->Set(tsk) ; + return fgQA ; +} + +//_______________________________________________________________ +const ULong_t AliQualAss::Offset(ALITASK tsk) const +{ + // Calculates the bit offset for a given module (SIM, REC, ESD, ANA) + + CheckRange(tsk) ; + + ULong_t offset = 0 ; + switch (tsk) { + case kNULLTASK: + break ; + case kSIM: + offset+= 0 ; + break ; + case kREC: + offset+= 4 ; + break ; + case kESD: + offset+= 8 ; + break ; + case kANA: + offset+= 12 ; + break ; + case kNTASK: + break ; + } + + return offset ; +} + +//_______________________________________________________________ +void AliQualAss::Set(QABIT bit) +{ + // Set the status bit of the current detector in the current module + + SetStatusBit(fDet, fTask, bit) ; +} + +//_______________________________________________________________ +void AliQualAss::SetStatusBit(DETECTORINDEX det, ALITASK tsk, QABIT bit) +{ + // Set the status bit for a given detector and a given task + + CheckRange(det) ; + CheckRange(tsk) ; + CheckRange(bit) ; + + ULong_t offset = Offset(tsk) ; + ULong_t status = GetStatus(det) ; + offset+= bit ; + status = status | 1 << offset ; + SetStatus(det, status) ; +} + +//_______________________________________________________________ +void AliQualAss::ShowAll() const +{ + // dispplay the QA status word + Int_t index ; + for (index = 0 ; index < kNDET ; index++) + ShowStatus(DETECTORINDEX(index)) ; +} + +//_______________________________________________________________ +void AliQualAss::ShowStatus(DETECTORINDEX det) const +{ + // Prints the full QA status of a given detector + CheckRange(det) ; + ULong_t status = GetStatus(det) ; + ULong_t simStatus = status & 0x000f ; + ULong_t recStatus = status & 0x00f0 ; + ULong_t esdStatus = status & 0x0f00 ; + ULong_t anaStatus = status & 0xf000 ; + + AliInfo(Form("QA Status for %s sim=0x%x, rec=0x%x, esd=0x%x, ana=0x%x\n", GetDetectorName(det), simStatus, recStatus, esdStatus, anaStatus )) ; +} + diff --git a/STEER/AliQualAss.h b/STEER/AliQualAss.h new file mode 100644 index 00000000000..766440ca463 --- /dev/null +++ b/STEER/AliQualAss.h @@ -0,0 +1,79 @@ +#ifndef ALIQualAss_H +#define ALIQualAss_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +// +// Quality Assurance Object +// + +#include +class TFile ; + +class AliQualAss : public TNamed { +public: + + enum DETECTORINDEX { + kNULLDET=-1, kITS, kTPC, kTRD, kTOF, kPHOS, kHMPID, kEMCAL, kMUON, kFMD, + kZDC, kPMD, kT0, kVZERO, kACORDE, kHLT, kNDET + }; + enum ALITASK { + kNULLTASK=-1, kSIM, kREC, kESD, kANA, kNTASK + }; + enum QABIT { + kNULLBit=-1, kINFO, kWARNING, kERROR, kFATAL, kNBIT + }; + + enum TASKINDEX { + kHITS, kSDIGITS, kDIGITS, kRECPOINTS, kTRACKSEGMENTS, kRECPARTICLES, kESDS + }; + + // Creators - destructors + AliQualAss(); // beware singleton, not to be used + AliQualAss(ALITASK tsk) ; + AliQualAss(const AliQualAss& qa) ; + AliQualAss& operator = (const AliQualAss& qa) ; + virtual ~AliQualAss(); + + static AliQualAss * Instance() ; + static AliQualAss * Instance(DETECTORINDEX det) ; + static AliQualAss * Instance(ALITASK tsk) ; + const Bool_t CheckFatal() const ; + static const char * GetOutputName() { return fgOutputName.Data() ; } + static TFile * GetQADMOutFile() ; + void Set(QABIT bit) ; + void Show() const { ShowStatus(fDet) ; } + void ShowAll() const ; + +private: + + const Bool_t CheckRange(DETECTORINDEX det) const ; + const Bool_t CheckRange(ALITASK tsk) const ; + const Bool_t CheckRange(QABIT bit) const ; + const char * GetDetectorName(DETECTORINDEX det) const ; + const char * GetTaskName(ALITASK tsk) const ; + const char * GetBitName(QABIT bit) const ; + const ULong_t GetStatus(DETECTORINDEX det) const { return fQA[det] ;} + void Finish() const ; + const Bool_t IsSet(DETECTORINDEX det, ALITASK tsk, QABIT bit) const ; + const ULong_t Offset(ALITASK tsk) const ; + virtual void ShowStatus(DETECTORINDEX det) const ; + void ResetStatus(DETECTORINDEX det) { fQA[det] = 0 ; } + void Set(DETECTORINDEX det) { fDet = det ;} + void Set(ALITASK tsk) { fTask = tsk ; AliInfo(Form("Ready to set QA status in %s\n", GetTaskName(tsk) )) ; } + void SetStatus(DETECTORINDEX det, UShort_t status) { fQA[det] = status ; } + void SetStatusBit(DETECTORINDEX det, ALITASK tsk, QABIT bit) ; + + static AliQualAss *fgQA ; // pointer to the instance of the singleton + Int_t fNdet ; // # of detectors + ULong_t * fQA ; //[kNDET] the status word 4 bits for SIM, REC, ESD, ANA each + DETECTORINDEX fDet ; //! the current detector (ITS, TPC, ....) + ALITASK fTask ; //! the current environment (SIM, REC, ESD, ANA) + static TFile * fgOutput ; //! the output file where the quality assurance maker store their results + static TString fgOutputName ; //! the output name file where the quality assurance maker store their results + + ClassDef(AliQualAss,1) //ALICE Quality Assurance Obbject +}; +#endif diff --git a/STEER/AliQualAssChecker.cxx b/STEER/AliQualAssChecker.cxx new file mode 100644 index 00000000000..61d703e29d8 --- /dev/null +++ b/STEER/AliQualAssChecker.cxx @@ -0,0 +1,200 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id: */ + +/////////////////////////////////////////////////////////////////////////////// +// // +// class for running the Quality Assurance Checker +// // +/////////////////////////////////////////////////////////////////////////////// + +#include "AliLog.h" +#include "AliModule.h" +#include "AliRun.h" +#include "AliRunLoader.h" +#include "AliQualAss.h" +#include "AliQualAssChecker.h" + +#include +#include +#include + + +ClassImp(AliQualAssChecker) + + TFile * AliQualAssChecker::fgOutFile = 0x0 ; + TString AliQualAssChecker::fgOutDir("/RUN/") ; + TString AliQualAssChecker::fgOutName("QA.root") ; + TString AliQualAssChecker::fgRefDir("/QA/Ref/") ; + TString AliQualAssChecker::fgRefName("QA.root") ; + +//_____________________________________________________________________________ +AliQualAssChecker::AliQualAssChecker(const char* name, const char* title) : + TNamed(name, title), + fGAliceFileName("galice.root"), + fStopOnError(kFALSE) +{ + // create simulation object with default parameters + + SetGAliceFile("galice.root"); +} + +//_____________________________________________________________________________ +AliQualAssChecker::AliQualAssChecker(const AliQualAssChecker& qac) : + TNamed(qac), + fGAliceFileName(qac.fGAliceFileName), + fStopOnError(qac.fStopOnError) +{ +// copy constructor +} + +//_____________________________________________________________________________ +AliQualAssChecker& AliQualAssChecker::operator = (const AliQualAssChecker& qac) +{ +// assignment operator + + this->~AliQualAssChecker(); + new(this) AliQualAssChecker(qac); + return *this; +} + +//_____________________________________________________________________________ +AliQualAssChecker::~AliQualAssChecker() +{ +// clean up + fgOutFile->Close() ; + delete fgOutFile ; +} + +//_____________________________________________________________________________ +TFile * AliQualAssChecker:: GetOutFile() +{ + // Check if file to store QA exists, if not create it + + if (fgOutFile) { + if (fgOutFile->IsOpen()){ + fgOutFile->Close() ; + fgOutFile = 0x0 ; + } + } + fgOutName.Prepend(fgOutDir) ; + TString opt("") ; + if ( !gSystem->AccessPathName(fgOutName) ) + opt = "UPDATE" ; + else + opt = "NEW" ; + fgOutFile = TFile::Open(fgOutName, opt) ; + + return fgOutFile ; +} + +//_____________________________________________________________________________ +AliRunLoader* AliQualAssChecker::LoadRun(const char* mode) const +{ +// delete existing run loaders, open a new one and load gAlice + while (AliRunLoader::GetRunLoader()) + delete AliRunLoader::GetRunLoader(); + AliRunLoader* runLoader = + AliRunLoader::Open(fGAliceFileName.Data(), + AliConfig::GetDefaultEventFolderName(), mode); + if (!runLoader) { + AliError(Form("no run loader found in file %s", fGAliceFileName.Data())); + return NULL; + } + runLoader->LoadgAlice(); + gAlice = runLoader->GetAliRun(); + if (!gAlice) { + AliError(Form("no gAlice object found in file %s", + fGAliceFileName.Data())); + return NULL; + } + return runLoader; +} + +//_____________________________________________________________________________ +Bool_t AliQualAssChecker::Run() +{ + // run the Quality Assurance Checker for all tasks Hits, SDigits, Digits, recpoints, tracksegments, recparticles and ESDs + + Bool_t rv = kFALSE ; + + TStopwatch stopwatch; + stopwatch.Start(); + + AliRunLoader* runLoader = LoadRun("READ"); + if (!runLoader) + return rv ; + + TObjArray* detArray = runLoader->GetAliRun()->Detectors(); + for (Int_t iDet = 0; iDet < detArray->GetEntriesFast(); iDet++) { + AliModule* det = (AliModule*) detArray->At(iDet); + if (!det || !det->IsActive()) + continue; + AliInfo(Form("QA checking %s", det->GetName())); + det->CheckQA(); + } + + delete runLoader; + + AliInfo(Form("Execution time for QA: R:%.2fs C:%.2fs", stopwatch.RealTime(),stopwatch.CpuTime())); + + return rv; +} + +//_____________________________________________________________________________ +void AliQualAssChecker::SetGAliceFile(const char* fileName) +{ +// set the name of the galice file +// the path is converted to an absolute one if it is relative + + fGAliceFileName = fileName; + if (!gSystem->IsAbsoluteFileName(fGAliceFileName)) { + char* absFileName = gSystem->ConcatFileName(gSystem->WorkingDirectory(), + fGAliceFileName); + fGAliceFileName = absFileName; + delete[] absFileName; + } + + AliDebug(2, Form("galice file name set to %s", fileName)); +} + +//_____________________________________________________________________________ +void AliQualAssChecker::SetOutDir(const char * outDir) +{ + // Set the root directory where to store the QA status object + + fgOutDir.Prepend(outDir) ; + AliInfo(Form("QA results are in %s", fgOutDir.Data())) ; + if ( fgOutDir.Contains("local://")) + fgOutDir.ReplaceAll("local:/", "") ; +} + +//_____________________________________________________________________________ +void AliQualAssChecker::SetRefDir(const char * refDir) +{ + // Set the root directory of reference data + + fgRefDir.Prepend(refDir) ; + fgRefDir.Append(fgRefName) ; + AliInfo(Form("Reference data are taken from %s", fgRefDir.Data())) ; + if ( fgRefDir.Contains("local://")) + fgRefDir.ReplaceAll("local:/", "") ; +} + + + + + diff --git a/STEER/AliQualAssChecker.h b/STEER/AliQualAssChecker.h new file mode 100644 index 00000000000..84b361131eb --- /dev/null +++ b/STEER/AliQualAssChecker.h @@ -0,0 +1,56 @@ +#ifndef ALIQUALASSChecker_H +#define ALIQUALASSChecker_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +// +// class for running the Quality Assurance Checker +// to run type: +// AliQualAssChecker qac; +// qac.Run(); +// qac.SelectDetectors("list of detectors") ; +// qac.SelectTargets("list of targets among Hits, Digits, ESD") ; +// + +#include +#include + +#include "AliQualAss.h" +class AliRunLoader; + +class AliQualAssChecker: public TNamed { +public: + AliQualAssChecker(const char* name = "AliQualAssChecker", + const char* title = "Quality Assurance checker for Hits, Digits and ESDs"); + AliQualAssChecker(const AliQualAssChecker& qac); + AliQualAssChecker& operator = (const AliQualAssChecker& qac); + virtual ~AliQualAssChecker(); + + static TFile * GetDataFile() { return TFile::Open(AliQualAss::GetOutputName()) ; } + static TFile * GetRefFile() { return TFile::Open(GetRefFileName()) ; } + static const char * GetRefFileName() { return fgRefName.Data() ; } + static TFile * GetOutFile() ; + static const char * GetOutFileName() { return fgOutName.Data() ; } + void SetOutDir(const char * outDir) ; + void SetRefDir(const char * refDir) ; + void SetGAliceFile(const char* fileName) ; + + virtual Bool_t Run(); + +private: + AliRunLoader* LoadRun(const char* mode = "UPDATE") const; + + TString fGAliceFileName ; // name of the galice file + static TFile * fgOutFile ; // File where to find the QA result + static TString fgOutDir ; // directory where to find the QA result + static TString fgOutName ; // file name where to find the QA result + static TString fgRefDir ; // directory where to find the reference data + static TString fgRefName ; // file name where to find the reference data + Bool_t fStopOnError; // stop or continue on errors + + ClassDef(AliQualAssChecker, 1) // class for running generation, simulation and digitization +}; + +#endif diff --git a/STEER/AliQualAssCheckerBase.cxx b/STEER/AliQualAssCheckerBase.cxx new file mode 100644 index 00000000000..ef22e98197c --- /dev/null +++ b/STEER/AliQualAssCheckerBase.cxx @@ -0,0 +1,153 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + + +/* $Id$ */ + +/* + Base class for detectors quality assurance checkers + Compares Data made by QualAssDataMakers with reference data + Y. Schutz CERN August 2007 +*/ + +// --- ROOT system --- +#include +#include +#include +#include +#include +#include + +// --- Standard library --- + +// --- AliRoot header files --- +#include "AliLog.h" +#include "AliQualAss.h" +#include "AliQualAssChecker.h" +#include "AliQualAssCheckerBase.h" +#include "AliQualAssDataMaker.h" + +ClassImp(AliQualAssCheckerBase) + + +//____________________________________________________________________________ +AliQualAssCheckerBase::AliQualAssCheckerBase(const char * name, const char * title) : + TNamed(name, title), + fData(0x0), + fDetectorDir(0x0), + fRef(0x0) +{ + // ctor + Init() ; +} + +//____________________________________________________________________________ +AliQualAssCheckerBase::AliQualAssCheckerBase(const AliQualAssCheckerBase& qadm) : + TNamed(qadm.GetName(), qadm.GetTitle()), + fData(qadm.fData), + fDetectorDir(qadm.fDetectorDir), + fRef(qadm.fRef) +{ + //copy ctor + +} + +//____________________________________________________________________________ +AliQualAssCheckerBase& AliQualAssCheckerBase::operator = (const AliQualAssCheckerBase& qadm ) +{ + // Equal operator. + this->~AliQualAssCheckerBase(); + new(this) AliQualAssCheckerBase(qadm); + return *this; +} + +//____________________________________________________________________________ +const Double_t AliQualAssCheckerBase::DiffC(const TH1 * href, const TH1 * hin) const +{ + // compares two histograms using the Chi2 test + if ( hin->Integral() == 0 ) { + AliWarning(Form("Spectrum %s in %s is empty", hin->GetName(), fData->GetName())) ; + return 0. ; + } + + return hin->Chi2Test(href) ; +} + +//____________________________________________________________________________ +const Double_t AliQualAssCheckerBase::DiffK(const TH1 * href, const TH1 * hin) const +{ + // compares two histograms using the Kolmogorov test + if ( hin->Integral() == 0 ) { + AliWarning(Form("Spectrum %s in %s is empty", hin->GetName(), fData->GetName())) ; + return 0. ; + } + + return hin->KolmogorovTest(href) ; +} + +//____________________________________________________________________________ +void AliQualAssCheckerBase::Init() +{ + //open files and search for the appropriate detector directory + + fRef = AliQualAssChecker::GetRefFile() ; + if (!fRef) + AliFatal(Form("Reference file %s not found", AliQualAssChecker::GetRefFileName())) ; + + fDetectorDir = fRef->GetDirectory(AliQualAssDataMaker::GetDetectorDirName()) ; + if (!fDetectorDir) + AliFatal(Form("Directory %s not found in reference file %s not found", AliQualAssDataMaker::GetDetectorDirName(), AliQualAssChecker::GetRefFileName())) ; + + fData = AliQualAssChecker::GetDataFile() ; + if (!fData) + AliFatal(Form("Reference file %s not found", AliQualAss::GetOutputName())) ; + + if (! fData->GetDirectory(AliQualAssDataMaker::GetDetectorDirName())) ; + AliFatal(Form("Directory %s not found in reference file %s not found", AliQualAssDataMaker::GetDetectorDirName(), AliQualAss::GetOutputName())) ; + + AliQualAss::Instance(AliQualAss::kSIM) ; +} + +//____________________________________________________________________________ +void AliQualAssCheckerBase::Exec(const Option_t * opt) +{ + AliInfo(Form("Processing %s", opt)) ; +// loop over detectors + AliQualAss * qa = AliQualAss::Instance(AliQualAss::kPHOS) ; + Double_t rv = Check(opt) ; + if ( rv <= 0.) + qa->Set(AliQualAss::kFATAL) ; + else if ( rv > 0 && rv <= 0.2 ) + qa->Set(AliQualAss::kERROR) ; + else if ( rv > 0.2 && rv <= 0.5 ) + qa->Set(AliQualAss::kWARNING) ; + else if ( rv > 0.5 && rv < 1 ) + qa->Set(AliQualAss::kINFO) ; + AliInfo(Form("Test result of %s in PHOS", opt)) ; + Finish() ; +// endloop +} + +//____________________________________________________________________________ +void AliQualAssCheckerBase::Finish() const +{ + // wrap up and save QA in proper file + + AliQualAss * qa = AliQualAss::Instance() ; + qa->Show() ; + AliQualAssChecker::GetOutFile()->cd() ; + qa->Write(qa->GetName(), kWriteDelete) ; + AliQualAssChecker::GetOutFile()->Close() ; +} diff --git a/STEER/AliQualAssCheckerBase.h b/STEER/AliQualAssCheckerBase.h new file mode 100644 index 00000000000..eb3ec064056 --- /dev/null +++ b/STEER/AliQualAssCheckerBase.h @@ -0,0 +1,49 @@ +#ifndef ALIQUALASSCHECKERBASE_H +#define ALIQUALASSCHECKERBASE_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + + +/* $Id$ */ + +/* + Base class for detectors quality assurance checkers + Compares Data made by QualAssDataMakers with reference data + Y. Schutz CERN August 2007 +*/ + + +// --- ROOT system --- +#include +class TFile ; + +// --- Standard library --- + +// --- AliRoot header files --- + +class AliQualAssCheckerBase: public TNamed { + +public: + AliQualAssCheckerBase(const char * name = "", const char * title = "") ; // ctor + AliQualAssCheckerBase(const AliQualAssCheckerBase& qac) ; + AliQualAssCheckerBase& operator = (const AliQualAssCheckerBase& qac) ; + virtual ~AliQualAssCheckerBase() {;} // dtor + + void Exec(const Option_t * = ""); + +protected: + void Init() ; + virtual const Double_t Check(const Option_t *) {AliInfo("To be implemented by detectors") ; } + const Double_t DiffC(const TH1 * href, const TH1 * hin) const ; + const Double_t DiffK(const TH1 * href, const TH1 * hin) const ; + void Finish() const ; + + TFile * fData ; //! data root file produced by the QualAssDataMaker + TDirectory * fDetectorDir ; //! directory for the given detector in the data file + TFile * fRef ; //! reference root file + + ClassDef(AliQualAssCheckerBase,1) // description + +}; + +#endif // AliQUALASSCHECKERBASE_H diff --git a/STEER/AliQualAssDataMaker.cxx b/STEER/AliQualAssDataMaker.cxx new file mode 100644 index 00000000000..c6d69db1d16 --- /dev/null +++ b/STEER/AliQualAssDataMaker.cxx @@ -0,0 +1,224 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + + +/* $Id$ */ + +/* + Base Class + Produces the data needed to calculate the quality assurance. + All data must be mergeable objects. + Y. Schutz CERN July 2007 +*/ + +// --- ROOT system --- +#include +#include + +// --- Standard library --- + +// --- AliRoot header files --- +#include "AliLog.h" +#include "AliQualAssDataMaker.h" + +ClassImp(AliQualAssDataMaker) + +TString AliQualAssDataMaker::fDetectorDirName("") ; + + +//____________________________________________________________________________ +AliQualAssDataMaker::AliQualAssDataMaker(const char * name, const char * title) : + TNamed(name, title), + fOutput(0x0), + fDetectorDir(0x0), + fData(0x0) +{ + // ctor + fOutput = AliQualAss::GetQADMOutFile() ; + fDetectorDirName = GetName() ; +} + +//____________________________________________________________________________ +AliQualAssDataMaker::AliQualAssDataMaker(const AliQualAssDataMaker& qadm) : + TNamed(qadm.GetName(), qadm.GetTitle()), + fOutput(qadm.fOutput), + fDetectorDir(qadm.fDetectorDir), + fData(qadm.fData) +{ + //copy ctor + fDetectorDirName = GetName() ; +} + +//__________________________________________________________________ +AliQualAssDataMaker& AliQualAssDataMaker::operator = (const AliQualAssDataMaker& qadm ) +{ + // Equal operator. + this->~AliQualAssDataMaker(); + new(this) AliQualAssDataMaker(qadm); + return *this; +} + +//____________________________________________________________________________ +void AliQualAssDataMaker::Exec(AliQualAss::TASKINDEX task) +{ + // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs) + + fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ; + if (!fDetectorDir) + fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ; + + switch (task) { + case AliQualAss::kHITS: + AliInfo("Processing Hits QA") ; + MakeHits() ; + break ; + + case AliQualAss::kSDIGITS: + AliInfo("Processing SDigits QA") ; + MakeSDigits() ; + break ; + + case AliQualAss::kDIGITS: + AliInfo("Processing Digits QA") ; + MakeDigits() ; + break ; + + case AliQualAss::kRECPOINTS: + AliInfo("Processing RecPoints QA") ; + MakeRecPoints() ; + break ; + + case AliQualAss::kTRACKSEGMENTS: + AliInfo("Processing Track Segments QA") ; + MakeTrackSegments() ; + break ; + + case AliQualAss::kRECPARTICLES: + AliInfo("Processing RecParticles QA") ; + MakeRecParticles() ; + break ; + + case AliQualAss::kESDS: + AliInfo("Processing ESDs QA") ; + MakeESDs() ; + break ; + } +} + +//____________________________________________________________________________ +void AliQualAssDataMaker::Finish(AliQualAss::TASKINDEX task) const +{ + // write to the output File + + fDetectorDir->cd() ; + TDirectory * subDir = 0x0 ; + + switch (task) { + case AliQualAss::kHITS: + subDir = fDetectorDir->GetDirectory("Hits") ; + break ; + + case AliQualAss::kSDIGITS: + subDir = fDetectorDir->GetDirectory("SDigits") ; + break ; + + case AliQualAss::kDIGITS: + subDir = fDetectorDir->GetDirectory("Digits") ; + break ; + + case AliQualAss::kRECPOINTS: + subDir = fDetectorDir->GetDirectory("RecPoints") ; + break ; + + case AliQualAss::kTRACKSEGMENTS: + subDir = fDetectorDir->GetDirectory("TrackSegments") ; + break ; + + case AliQualAss::kRECPARTICLES: + subDir = fDetectorDir->GetDirectory("RecParticles") ; + break ; + + case AliQualAss::kESDS: + subDir = fDetectorDir->GetDirectory("ESDs") ; + break ; + } + subDir->Write() ; +} + +//____________________________________________________________________________ +void AliQualAssDataMaker::Init(AliQualAss::TASKINDEX task) +{ + // general intialisation + + TDirectory * subDir = 0x0 ; + + switch (task) { + case AliQualAss::kHITS: + subDir = fDetectorDir->GetDirectory("Hits") ; + if (!subDir) + subDir = fDetectorDir->mkdir("Hits") ; + subDir->cd() ; + InitHits() ; + break ; + + case AliQualAss::kSDIGITS: + subDir = fDetectorDir->GetDirectory("SDigits") ; + if (!subDir) + subDir = fDetectorDir->mkdir("SDigits") ; + subDir->cd() ; + InitSDigits() ; + break ; + + case AliQualAss::kDIGITS: + subDir = fDetectorDir->GetDirectory("Digits") ; + if (!subDir) + subDir = fDetectorDir->mkdir("Digits") ; + subDir->cd() ; + InitDigits() ; + break ; + + case AliQualAss::kRECPOINTS: + subDir = fDetectorDir->GetDirectory("RecPoints") ; + if(!subDir) + subDir = fDetectorDir->mkdir("RecPoints") ; + subDir->cd() ; + InitRecPoints() ; + break ; + + case AliQualAss::kTRACKSEGMENTS: + subDir = fDetectorDir->GetDirectory("TrackSegments") ; + if (!subDir) + subDir = fDetectorDir->mkdir("TrackSegments") ; + subDir->cd() ; + InitTrackSegments() ; + break ; + + case AliQualAss::kRECPARTICLES: + subDir = fDetectorDir->GetDirectory("RecParticles") ; + if (!subDir) + subDir = fDetectorDir->mkdir("RecParticles") ; + subDir->cd() ; + InitRecParticles() ; + break ; + + case AliQualAss::kESDS: + subDir = fDetectorDir->GetDirectory("ESDs") ; + if (!subDir) + subDir = fDetectorDir->mkdir("ESDs") ; + subDir->cd() ; + InitESDs() ; + break ; + } +} diff --git a/STEER/AliQualAssDataMaker.h b/STEER/AliQualAssDataMaker.h new file mode 100644 index 00000000000..12f37e2f8d9 --- /dev/null +++ b/STEER/AliQualAssDataMaker.h @@ -0,0 +1,66 @@ +#ifndef ALIQUALASSDATAMAKER_H +#define ALIQUALASSDATAMAKER_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + + +/* $Id$ */ + +/* + Base Class: + Produces the data needed to calculate the quality assurance. + All data must be mergeable objects. + Y. Schutz CERN July 2007 +*/ + + +// --- ROOT system --- +#include +class TFile; + +// --- Standard library --- + +// --- AliRoot header files --- +#include "AliQualAss.h" + +class AliQualAssDataMaker: public TNamed { + +public: + + AliQualAssDataMaker(const char * name="", const char * title="") ; // ctor + AliQualAssDataMaker(const AliQualAssDataMaker& qadm) ; + AliQualAssDataMaker& operator = (const AliQualAssDataMaker& qadm) ; + virtual ~AliQualAssDataMaker() {;} // dtor + + virtual void Exec(AliQualAss::TASKINDEX) ; + void Finish(AliQualAss::TASKINDEX task) const ; + static const char * GetDetectorDirName() { return fDetectorDirName.Data() ; } + void Init(AliQualAss::TASKINDEX) ; + void SetData(TObject * obj) { fData = obj ; } + +protected: + + virtual void InitDigits() {AliInfo("To ne implemented by detectors");} + virtual void InitESDs() {AliInfo("To ne implemented by detectors");} + virtual void InitHits() {AliInfo("To ne implemented by detectors");} + virtual void InitRecParticles() {AliInfo("To ne implemented by detectors");} + virtual void InitRecPoints() {AliInfo("To ne implemented by detectors");} + virtual void InitSDigits() {AliInfo("To ne implemented by detectors");} + virtual void InitTrackSegments() {AliInfo("To ne implemented by detectors");} + virtual void MakeESDs() {AliInfo("To ne implemented by detectors");} + virtual void MakeHits() {AliInfo("To ne implemented by detectors");} + virtual void MakeDigits() {AliInfo("To ne implemented by detectors");} + virtual void MakeRecParticles() {AliInfo("To ne implemented by detectors");} + virtual void MakeRecPoints() {AliInfo("To ne implemented by detectors");} + virtual void MakeSDigits() {AliInfo("To ne implemented by detectors");} + virtual void MakeTrackSegments() {AliInfo("To ne implemented by detectors");} + + TFile * fOutput ; //! output root file + TDirectory * fDetectorDir ; //! directory for the given detector in the file + TObject * fData ; //! data container + static TString fDetectorDirName ; //! detector directory name in the quality assurance data file + ClassDef(AliQualAssDataMaker,1) // description + +}; + +#endif // AliQualAssDataMaker_H diff --git a/STEER/STEERLinkDef.h b/STEER/STEERLinkDef.h index 6d25c7bbce5..d725e43cd6b 100644 --- a/STEER/STEERLinkDef.h +++ b/STEER/STEERLinkDef.h @@ -146,4 +146,9 @@ #pragma link C++ class AliCTPRawData+; #pragma link C++ class AliMCEventHandler+; +#pragma link C++ class AliQualAss+; +#pragma link C++ class AliQualAssDataMaker+; +#pragma link C++ class AliQualAssChecker+; +#pragma link C++ class AliQualAssCheckerBase+; + #endif diff --git a/STEER/libSTEER.pkg b/STEER/libSTEER.pkg index 8c35701bed7..a09f8b08eb3 100644 --- a/STEER/libSTEER.pkg +++ b/STEER/libSTEER.pkg @@ -45,7 +45,11 @@ AliSurveyObj.cxx AliSurveyPoint.cxx \ AliCodeTimer.cxx \ AliFstream.cxx \ AliCTPRawData.cxx \ -AliMCEventHandler.cxx +AliMCEventHandler.cxx \ +AliQualAss.cxx \ +AliQualAssDataMaker.cxx \ +AliQualAssChecker.cxx \ +AliQualAssCheckerBase.cxx -- 2.43.0