From a5fa6165b25383aadfa3a33e3fc33113134b814d Mon Sep 17 00:00:00 2001 From: hristov Date: Wed, 22 Aug 2007 09:20:50 +0000 Subject: [PATCH] Updated QA classes (Yves) --- PHOS/AliPHOS.cxx | 29 ++- PHOS/AliPHOS.h | 6 +- PHOS/AliPHOSClusterizer.cxx | 7 +- PHOS/AliPHOSClusterizerv1.cxx | 9 +- PHOS/AliPHOSQualAssChecker.cxx | 37 +--- PHOS/AliPHOSQualAssChecker.h | 2 - PHOS/AliPHOSQualAssDataMaker.cxx | 18 +- PHOS/AliPHOSReconstructor.cxx | 8 +- PHOS/AliPHOSTrackSegmentMakerv2.cxx | 4 + STEER/AliPreprocessor.cxx | 11 -- STEER/AliPreprocessor.h | 1 - STEER/AliQualAss.cxx | 146 ++++++--------- STEER/AliQualAss.h | 29 +-- STEER/AliQualAssChecker.cxx | 271 ++++++++++++++++++---------- STEER/AliQualAssChecker.h | 37 ++-- STEER/AliQualAssCheckerBase.cxx | 100 ++++++---- STEER/AliQualAssCheckerBase.h | 16 +- STEER/AliQualAssDataMaker.cxx | 53 +++--- STEER/AliQualAssDataMaker.h | 2 +- STEER/AliReconstruction.cxx | 147 ++++++++++++++- STEER/AliReconstruction.h | 10 +- 21 files changed, 577 insertions(+), 366 deletions(-) diff --git a/PHOS/AliPHOS.cxx b/PHOS/AliPHOS.cxx index 77ea421a601..ec12ad26aae 100644 --- a/PHOS/AliPHOS.cxx +++ b/PHOS/AliPHOS.cxx @@ -16,6 +16,9 @@ /* History of cvs commits: * * $Log$ + * Revision 1.114 2007/08/07 14:12:03 kharlov + * Quality assurance added (Yves Schutz) + * * Revision 1.113 2007/07/18 16:29:54 policheh * Raw Sdigits energy converted to GeV. * @@ -210,7 +213,8 @@ void AliPHOS::CreateMaterials() Float_t aG10[4] = { 12., 1., 16., 28.} ; Float_t zG10[4] = { 6., 1., 8., 14.} ; Float_t wG10[4] = { .259, .288, .248, .205} ; - Float_t dG10 = 1.7 ; + Float_t dG10 = 1.7 ; + AliMixture(12, "G10$", aG10, zG10, dG10, -4, wG10); @@ -239,7 +243,8 @@ void AliPHOS::CreateMaterials() wArCO[1] = (1-arContent)*1; wArCO[2] = (1-arContent)*2; Float_t dArCO = arContent*dAr + (1-arContent)*dCO ; - AliMixture(16, "ArCO2$", aArCO, zArCO, dArCO, -3, wArCO) ; + AliMixture(16, "ArCO2$", aArCO, zArCO, dArCO, -3, wArCO) ; + // --- Stainless steel (let it be pure iron) --- AliMaterial(17, "Steel$", 55.845, 26, 7.87, 1.76, 0., 0, 0) ; @@ -562,9 +567,11 @@ void AliPHOS::Hits2SDigits() AliPHOSSDigitizer phosDigitizer(fLoader->GetRunLoader()->GetFileName().Data()) ; phosDigitizer.SetEventRange(0, -1) ; // do all the events + phosDigitizer.ExecuteTask("all") ; } + //____________________________________________________________________________ AliLoader* AliPHOS::MakeLoader(const char* topfoldername) { @@ -618,26 +625,12 @@ Bool_t AliPHOS::Raw2SDigits(AliRawReader* rawReader) AliPHOSRawDigiProducer pr; pr.MakeDigits(sdigits,&dc); - //ADC counts -> GeV - for(Int_t i=0; iGetEntries(); i++) { - AliPHOSDigit* sdigit = (AliPHOSDigit*)sdigits->At(i); - sdigit->SetEnergy(sdigit->GetEnergy()/AliPHOSPulseGenerator::GeV2ADC()); - } - Int_t bufferSize = 32000 ; - TBranch * sdigitsBranch = tree->Branch("PHOS",&sdigits,bufferSize); + // TBranch * sdigitsBranch = tree->Branch("PHOS",&sdigits,bufferSize); + tree->Branch("PHOS",&sdigits,bufferSize); tree->Fill(); fLoader->WriteSDigits("OVERWRITE"); return kTRUE; } - -//____________________________________________________________________________ -void AliPHOS::CheckQA() -{ - // check the Quality Assurance data - - AliPHOSQualAssChecker phosQA ; - phosQA.Exec() ; -} diff --git a/PHOS/AliPHOS.h b/PHOS/AliPHOS.h index c366ed45cd0..8279b542f70 100644 --- a/PHOS/AliPHOS.h +++ b/PHOS/AliPHOS.h @@ -7,6 +7,9 @@ /* History of cvs commits: * * $Log$ + * Revision 1.73 2007/08/07 14:12:03 kharlov + * Quality assurance added (Yves Schutz) + * * Revision 1.72 2007/02/13 10:52:08 policheh * Raw2SDigits() implemented * @@ -97,9 +100,6 @@ public: virtual void SetTreeAddress(); virtual const TString Version() const {return TString(" ") ; } - //QA methods - virtual void CheckQA() ; - private: AliPHOS(AliPHOS & phos); AliPHOS & operator = (const AliPHOS & /*rvalue*/); diff --git a/PHOS/AliPHOSClusterizer.cxx b/PHOS/AliPHOSClusterizer.cxx index 932db7a0dbb..2adef3868d6 100644 --- a/PHOS/AliPHOSClusterizer.cxx +++ b/PHOS/AliPHOSClusterizer.cxx @@ -28,6 +28,7 @@ // --- AliRoot header files --- #include "AliPHOSClusterizer.h" #include "AliPHOSGetter.h" +#include "AliPHOSQualAssDataMaker.h" // --- AliRoot header files --- #include "AliPHOSQualAssDataMaker.h" @@ -43,7 +44,7 @@ AliPHOSClusterizer::AliPHOSClusterizer(): fRawReader(0), fQADM(0) { - // ctor + // ctor } //____________________________________________________________________________ @@ -68,9 +69,10 @@ AliPHOSClusterizer::AliPHOSClusterizer(const AliPHOSClusterizer & clusterizer) : fFirstEvent(clusterizer.GetFirstEvent()),fLastEvent(clusterizer.GetLastEvent()), fRawReader(clusterizer.GetRawReader()), fQADM(clusterizer.GetQualAssDataMaker()) - { //Copy constructor + //initiaizes the quality assurance data maker + GetQualAssDataMaker()->Init(AliQualAss::kRECPOINTS) ; } //____________________________________________________________________________ AliPHOSClusterizer::~AliPHOSClusterizer() @@ -80,6 +82,7 @@ AliPHOSClusterizer::~AliPHOSClusterizer() //Remove this from the parental task before destroying if(AliPHOSGetter::Instance()->PhosLoader()) AliPHOSGetter::Instance()->PhosLoader()->CleanReconstructioner(); + delete fQADM ; } diff --git a/PHOS/AliPHOSClusterizerv1.cxx b/PHOS/AliPHOSClusterizerv1.cxx index 7a39728b511..06fa62a3291 100644 --- a/PHOS/AliPHOSClusterizerv1.cxx +++ b/PHOS/AliPHOSClusterizerv1.cxx @@ -18,6 +18,9 @@ /* History of cvs commits: * * $Log$ + * Revision 1.111 2007/08/08 12:11:28 kharlov + * Protection against uninitialized fQADM + * * Revision 1.110 2007/08/07 14:16:00 kharlov * Quality assurance added (Yves Schutz) * @@ -363,10 +366,10 @@ void AliPHOSClusterizerv1::Exec(Option_t *option) //Write the quality assurance data only after the last event if (GetQualAssDataMaker() && fEventCounter == gime->MaxEvent()) - GetQualAssDataMaker()->Finish(AliQualAss::kRECPOINTS) ; + GetQualAssDataMaker()->Finish(AliQualAss::kRECPOINTS) ; - if(fWrite) //do not unload in "on flight" mode - Unload(); + if(fWrite) //do not unload in "on flight" mode + Unload(); if(strstr(option,"tim")){ gBenchmark->Stop("PHOSClusterizer"); diff --git a/PHOS/AliPHOSQualAssChecker.cxx b/PHOS/AliPHOSQualAssChecker.cxx index d9d5b531fa4..99cbbba0c9a 100644 --- a/PHOS/AliPHOSQualAssChecker.cxx +++ b/PHOS/AliPHOSQualAssChecker.cxx @@ -41,44 +41,11 @@ ClassImp(AliPHOSQualAssChecker) //__________________________________________________________________ -AliPHOSQualAssChecker& AliPHOSQualAssChecker::operator = (const AliPHOSQualAssChecker& qadm ) +AliPHOSQualAssChecker& AliPHOSQualAssChecker::operator = (const AliPHOSQualAssChecker& qac ) { // Equal operator. this->~AliPHOSQualAssChecker(); - new(this) AliPHOSQualAssChecker(qadm); + new(this) AliPHOSQualAssChecker(qac); return *this; } -//____________________________________________________________________________ -const Double_t AliPHOSQualAssChecker::Check(const Option_t * opt) -{ - // Performs the checking - - TDirectory * wRefDir = fDetectorDir->GetDirectory(opt) ; - TDirectory * wInDir = fDetectorDir ->GetDirectory(opt) ; - Double_t test = 0.0 ; - - if (!wRefDir || !wInDir) - test = -1. ; - else { - TList * keyList = wRefDir->GetListOfKeys() ; - TIter next(keyList) ; - TKey * key ; - Int_t count = 0 ; - while ( (key = static_cast(next())) ) { - TObject * oref = wRefDir->Get(key->GetName()) ; - if ( oref->IsA()->InheritsFrom("TH1") ) { - TH1 * href = static_cast(oref) ; - TH1 * hin = static_cast(wInDir->Get(key->GetName())) ; - test += DiffK(href, hin) ; - AliInfo(Form("test = %f", test)) ; - count++ ; - } else - AliError(Form("%s is a class name that cannot be processed", key->GetClassName())) ; - } - if (count != 0) - test /= count ; - } - - return test ; -} diff --git a/PHOS/AliPHOSQualAssChecker.h b/PHOS/AliPHOSQualAssChecker.h index 9c50f27890e..3a5e844b334 100644 --- a/PHOS/AliPHOSQualAssChecker.h +++ b/PHOS/AliPHOSQualAssChecker.h @@ -34,8 +34,6 @@ public: private: - virtual const Double_t Check(const Option_t * opt) ; - ClassDef(AliPHOSQualAssChecker,1) // description }; diff --git a/PHOS/AliPHOSQualAssDataMaker.cxx b/PHOS/AliPHOSQualAssDataMaker.cxx index 8cc7e7fefc2..767d8fe31e7 100644 --- a/PHOS/AliPHOSQualAssDataMaker.cxx +++ b/PHOS/AliPHOSQualAssDataMaker.cxx @@ -46,7 +46,7 @@ ClassImp(AliPHOSQualAssDataMaker) //____________________________________________________________________________ AliPHOSQualAssDataMaker::AliPHOSQualAssDataMaker() : - AliQualAssDataMaker("PHOSQA", "PHOS Quality Assurance Data Maker"), + AliQualAssDataMaker(AliQualAss::GetDetName(AliQualAss::kPHOS), "PHOS Quality Assurance Data Maker"), fhHits(0x0), fhHitsMul(0x0), fhDigits(0x0), @@ -109,7 +109,9 @@ void AliPHOSQualAssDataMaker::InitESDs() { //create ESDs histograms in ESDs subdir fhESDs = new TH1F("hPhosESDs", "ESDs energy distribution in PHOS", 100, 0., 100.) ; + fhESDs->Sumw2() ; fhESDsMul = new TH1I("hPhosESDsMul", "ESDs multiplicity distribution in PHOS", 100, 0., 100) ; + fhESDsMul->Sumw2() ; } //____________________________________________________________________________ @@ -117,7 +119,9 @@ void AliPHOSQualAssDataMaker::InitHits() { // create Hits histograms in Hits subdir fhHits = new TH1F("hPhosHits", "Hits energy distribution in PHOS", 100, 0., 100.) ; + fhHits->Sumw2() ; fhHitsMul = new TH1I("hPhosHitsMul", "Hits multiplicity distribution in PHOS", 500, 0., 10000) ; + fhHitsMul->Sumw2() ; } //____________________________________________________________________________ @@ -125,7 +129,9 @@ void AliPHOSQualAssDataMaker::InitDigits() { // create Digits histograms in Digits subdir fhDigits = new TH1I("hPhosDigits", "Digits amplitude distribution in PHOS", 500, 0, 5000) ; + fhDigits->Sumw2() ; fhDigitsMul = new TH1I("hPhosDigitsMul", "Digits multiplicity distribution in PHOS", 500, 0, 1000) ; + fhDigitsMul->Sumw2() ; } //____________________________________________________________________________ @@ -133,7 +139,9 @@ void AliPHOSQualAssDataMaker::InitRecParticles() { // create Reconstructed particles histograms in RecParticles subdir fhRecParticles = new TH1F("hPhosRecParticles", "RecParticles energy distribution in PHOS", 100, 0., 100.) ; + fhRecParticles->Sumw2() ; fhRecParticlesMul = new TH1I("hPhosRecParticlesMul", "RecParticles multiplicity distribution in PHOS", 100, 0, 100) ; + fhRecParticlesMul->Sumw2() ; } //____________________________________________________________________________ @@ -141,10 +149,14 @@ void AliPHOSQualAssDataMaker::InitRecPoints() { // create Reconstructed Points histograms in RecPoints subdir fhEmcRecPoints = new TH1F("hEmcPhosRecPoints", "EMCA RecPoints energy distribution in PHOS", 100, 0., 100.) ; + fhEmcRecPoints->Sumw2() ; fhEmcRecPointsMul = new TH1I("hEmcPhosRecPointsMul", "EMCA RecPoints multiplicity distribution in PHOS", 100, 0, 100) ; + fhEmcRecPointsMul->Sumw2() ; fhCpvRecPoints = new TH1F("hCpvPhosRecPoints", "CPV RecPoints energy distribution in PHOS", 100, 0., 100.) ; + fhCpvRecPoints->Sumw2() ; fhCpvRecPointsMul = new TH1I("hCpvPhosRecPointsMul", "CPV RecPoints multiplicity distribution in PHOS", 100, 0, 100) ; + fhCpvRecPointsMul->Sumw2() ; } //____________________________________________________________________________ @@ -152,7 +164,9 @@ void AliPHOSQualAssDataMaker::InitSDigits() { // create SDigits histograms in SDigits subdir fhSDigits = new TH1F("hPhosSDigits", "SDigits energy distribution in PHOS", 100, 0., 100.) ; + fhSDigits->Sumw2() ; fhSDigitsMul = new TH1I("hPhosSDigitsMul", "SDigits multiplicity distribution in PHOS", 500, 0, 10000) ; + fhSDigitsMul->Sumw2() ; } //____________________________________________________________________________ @@ -160,7 +174,9 @@ void AliPHOSQualAssDataMaker::InitTrackSegments() { // create Track Segments histograms in TrackSegments subdir fhTrackSegments = new TH1F("hPhosTrackSegments", "TrackSegments EMC-CPV distance in PHOS", 500, 0., 5000.) ; + fhTrackSegments->Sumw2() ; fhTrackSegmentsMul = new TH1I("hPhosTrackSegmentsMul", "TrackSegments multiplicity distribution in PHOS", 100, 0, 100) ; + fhTrackSegmentsMul->Sumw2() ; } //____________________________________________________________________________ diff --git a/PHOS/AliPHOSReconstructor.cxx b/PHOS/AliPHOSReconstructor.cxx index 4f36febad8e..386a40df1c9 100644 --- a/PHOS/AliPHOSReconstructor.cxx +++ b/PHOS/AliPHOSReconstructor.cxx @@ -127,14 +127,18 @@ void AliPHOSReconstructor::FillESD(AliRunLoader* runLoader, AliESDEvent* esd) co Int_t eventNumber = runLoader->GetEventNumber() ; + AliPHOSGetter *gime = AliPHOSGetter::Instance(); gime->Event(eventNumber, "DRTP") ; TClonesArray *recParticles = gime->RecParticles(); Int_t nOfRecParticles = recParticles->GetEntries(); - + + esd->SetNumberOfPHOSClusters(nOfRecParticles) ; esd->SetFirstPHOSCluster(esd->GetNumberOfCaloClusters()) ; - + + Int_t maxClu = esd->GetNumberOfPHOSClusters() ; + AliDebug(2,Form("%d digits and %d rec. particles in event %d, option %s",gime->Digits()->GetEntries(),nOfRecParticles,eventNumber,GetOption())); diff --git a/PHOS/AliPHOSTrackSegmentMakerv2.cxx b/PHOS/AliPHOSTrackSegmentMakerv2.cxx index e976b450dd8..99fe339ef2a 100644 --- a/PHOS/AliPHOSTrackSegmentMakerv2.cxx +++ b/PHOS/AliPHOSTrackSegmentMakerv2.cxx @@ -17,6 +17,9 @@ /* History of cvs commits: * * $Log$ + * Revision 1.5 2007/07/11 13:43:30 hristov + * New class AliESDEvent, backward compatibility with the old AliESD (Christian) + * * Revision 1.4 2007/05/04 14:49:29 policheh * AliPHOSRecPoint inheritance from AliCluster * @@ -71,6 +74,7 @@ #include "AliPHOSTrackSegment.h" #include "AliPHOSLink.h" #include "AliPHOSGetter.h" + #include "AliESDEvent.h" #include "AliESDtrack.h" diff --git a/STEER/AliPreprocessor.cxx b/STEER/AliPreprocessor.cxx index d62f9122708..b3ae32c9fa0 100644 --- a/STEER/AliPreprocessor.cxx +++ b/STEER/AliPreprocessor.cxx @@ -315,14 +315,3 @@ const char* AliPreprocessor::GetRunType() return fShuttle->GetRunType(); } - -//______________________________________________________________________________________________ -Bool_t AliPreprocessor::GetHLTStatus() -{ - // Return HLT status (ON or OFF) - // Converts the HLT status from the status string read in the run logbook (not just a bool) - // The call is delegated to AliShuttleInterface - - return fShuttle->GetHLTStatus(); - -} diff --git a/STEER/AliPreprocessor.h b/STEER/AliPreprocessor.h index 265085edf3a..bab0f68b53d 100644 --- a/STEER/AliPreprocessor.h +++ b/STEER/AliPreprocessor.h @@ -49,7 +49,6 @@ class AliPreprocessor : public TNamed const char* GetRunParameter(const char* param); AliCDBEntry* GetFromOCDB(const char* pathLevel2, const char* pathLevel3); const char* GetRunType(); - Bool_t GetHLTStatus(); void Log(const char* message); Int_t fRun; // current run diff --git a/STEER/AliQualAss.cxx b/STEER/AliQualAss.cxx index 16aa20bdb76..2645248d10a 100644 --- a/STEER/AliQualAss.cxx +++ b/STEER/AliQualAss.cxx @@ -43,9 +43,12 @@ ClassImp(AliQualAss) - AliQualAss * AliQualAss::fgQA = 0x0 ; - TFile * AliQualAss::fgOutput = 0x0 ; - TString AliQualAss::fgOutputName = "QA.root" ; + AliQualAss * AliQualAss::fgQA = 0x0 ; + TFile * AliQualAss::fgDataFile = 0x0 ; + TString AliQualAss::fgDataName = "QA.root" ; + TString AliQualAss::fgDetNames[] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", + "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT"} ; + TString AliQualAss::fgTaskNames[] = {"Hits", "SDigits", "Digits", "RecPoints", "TrackSegments", "RecParticles", "ESDs"} ; //____________________________________________________________________________ AliQualAss::AliQualAss() : @@ -81,7 +84,26 @@ AliQualAss& AliQualAss::operator = (const AliQualAss& qa) } //_______________________________________________________________ -AliQualAss::AliQualAss(ALITASK tsk) : +AliQualAss::AliQualAss(const DETECTORINDEX det) : + TNamed("QA", "Quality Assurance status"), + fNdet(12), + fQA(0x0), + fDet(det), + fTask(kNULLTASK) +{ + // constructor to be used + if (! CheckRange(det) ) { + fDet = kNULLDET ; + return ; + } else + fQA = new ULong_t[kNDET] ; + Int_t index ; + for (index = 0; index < kNDET; index++) + fQA[index] = 0 ; +} + +//_______________________________________________________________ +AliQualAss::AliQualAss(const ALITASK tsk) : TNamed("QA", "Quality Assurance status"), fNdet(12), fQA(0x0), @@ -92,12 +114,11 @@ AliQualAss::AliQualAss(ALITASK tsk) : if (! CheckRange(tsk) ) { fTask = kNULLTASK ; return ; - } else { - fQA = new ULong_t[fNdet] ; - Int_t index ; - for ( index = 0 ; index <= fNdet ; index++) - ResetStatus(DETECTORINDEX(index)) ; - } + } else + fQA = new ULong_t[kNDET] ; + Int_t index ; + for (index = 0; index < kNDET; index++) + fQA[index] = 0 ; } //____________________________________________________________________________ @@ -112,7 +133,7 @@ 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 ; + Bool_t rv = ( det < 0 || det > kNDET ) ? kFALSE : kTRUE ; if (!rv) AliFatal(Form("Detector index %d is out of range: 0 <= index <= %d", det, kNDET)) ; return rv ; @@ -139,89 +160,40 @@ const Bool_t AliQualAss::CheckRange(QABIT bit) const 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") ; + if (! fgDataFile ) { + TString opt ; + if (gSystem->AccessPathName(fgDataName.Data())) + opt = "NEW" ; + else + opt = "UPDATE" ; - fgOutput = TFile::Open(fgOutputName.Data(), opt) ; + fgDataFile = TFile::Open(fgDataName.Data(), opt.Data()) ; } - return fgOutput ; + return fgDataFile ; } //_______________________________________________________________ -const char * AliQualAss::GetTaskName(ALITASK tsk) const +const char * AliQualAss::GetDetName(Int_t det) +{ + // returns the detector name corresponding to a given index (needed in a loop) + + if ( det >= 0 && det < kNDET) + return (fgDetNames[det]).Data() ; + else + return NULL ; +} + +//_______________________________________________________________ +const char * AliQualAss::GetAliTaskName(ALITASK tsk) { // returns the char name corresponding to module index - char * tskName = "" ; + TString tskName ; switch (tsk) { case kNULLTASK: break ; @@ -238,10 +210,10 @@ const char * AliQualAss::GetTaskName(ALITASK tsk) const tskName = "ANA" ; break ; default: - AliError(Form("%d is not a valid module index %d <= index <= %d\n", tsk, 0, kNTASK-1)) ; + tsk = kNULLTASK ; break ; } - return tskName ; + return tskName.Data() ; } //_______________________________________________________________ @@ -281,16 +253,18 @@ AliQualAss * AliQualAss::Instance() } //_______________________________________________________________ -AliQualAss * AliQualAss::Instance(DETECTORINDEX det) +AliQualAss * AliQualAss::Instance(const DETECTORINDEX det) { // Get an instance of the singleton. The only authorized way to call the ctor + if ( ! fgQA) + fgQA = new AliQualAss(det) ; fgQA->Set(det) ; return fgQA ; } //_______________________________________________________________ -AliQualAss * AliQualAss::Instance(ALITASK tsk) +AliQualAss * AliQualAss::Instance(const ALITASK tsk) { // get an instance of the singleton. @@ -392,6 +366,6 @@ void AliQualAss::ShowStatus(DETECTORINDEX det) const 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 )) ; + AliInfo(Form("QA Status for %s sim=0x%x, rec=0x%x, esd=0x%x, ana=0x%x\n", GetDetName(det).Data(), simStatus, recStatus, esdStatus, anaStatus )) ; } diff --git a/STEER/AliQualAss.h b/STEER/AliQualAss.h index 51a2cac0886..ae95134d624 100644 --- a/STEER/AliQualAss.h +++ b/STEER/AliQualAss.h @@ -9,8 +9,7 @@ // Quality Assurance Object // -#include -#include "AliLog.h" +#include class TFile ; class AliQualAss : public TNamed { @@ -33,16 +32,21 @@ public: // Creators - destructors AliQualAss(); // beware singleton, not to be used - AliQualAss(ALITASK tsk) ; + AliQualAss(const ALITASK tsk) ; + AliQualAss(const DETECTORINDEX det) ; AliQualAss(const AliQualAss& qa) ; AliQualAss& operator = (const AliQualAss& qa) ; virtual ~AliQualAss(); static AliQualAss * Instance() ; - static AliQualAss * Instance(DETECTORINDEX det) ; - static AliQualAss * Instance(ALITASK tsk) ; + static AliQualAss * Instance(const DETECTORINDEX det) ; + static AliQualAss * Instance(const ALITASK tsk) ; const Bool_t CheckFatal() const ; - static const char * GetOutputName() { return fgOutputName.Data() ; } + static const char * GetAliTaskName(ALITASK tsk) ; + static const char * GetDataName() { return fgDataName.Data() ; } + static const TString GetDetName(DETECTORINDEX det) { return fgDetNames[det] ; } + static const TString GetTaskName(TASKINDEX tsk) { return fgTaskNames[tsk] ; } + static const char * GetDetName(Int_t det) ; static TFile * GetQADMOutFile() ; void Set(QABIT bit) ; void Show() const { ShowStatus(fDet) ; } @@ -53,8 +57,6 @@ 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 ; @@ -63,7 +65,7 @@ private: 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 Set(ALITASK tsk) { fTask = tsk ; AliInfo(Form("Ready to set QA status in %s", GetAliTaskName(tsk) )) ; } void SetStatus(DETECTORINDEX det, UShort_t status) { fQA[det] = status ; } void SetStatusBit(DETECTORINDEX det, ALITASK tsk, QABIT bit) ; @@ -72,9 +74,10 @@ private: 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 + static TFile * fgDataFile ; //! the output file where the quality assurance maker store their results + static TString fgDataName ; //! the name of the file where the quality assurance maker store their results + static TString fgDetNames[] ; //! list of detector names + static TString fgTaskNames[]; //! list of tasks names + ClassDef(AliQualAss,1) //ALICE Quality Assurance Object }; #endif diff --git a/STEER/AliQualAssChecker.cxx b/STEER/AliQualAssChecker.cxx index 61d703e29d8..2eb88addb93 100644 --- a/STEER/AliQualAssChecker.cxx +++ b/STEER/AliQualAssChecker.cxx @@ -23,42 +23,50 @@ #include "AliLog.h" #include "AliModule.h" -#include "AliRun.h" -#include "AliRunLoader.h" #include "AliQualAss.h" #include "AliQualAssChecker.h" +#include "AliQualAssCheckerBase.h" +#include #include +#include +#include #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") ; + TFile * AliQualAssChecker::fgQAResultFile = 0x0 ; + TString AliQualAssChecker::fgQAResultDirName = "local://RUN/"; + TString AliQualAssChecker::fgQAResultFileName = "QA.root" ; //_____________________________________________________________________________ AliQualAssChecker::AliQualAssChecker(const char* name, const char* title) : TNamed(name, title), - fGAliceFileName("galice.root"), - fStopOnError(kFALSE) + fDataFile(0x0), + fRefDirName("/QA/Ref/"), + fRefName("QA.root"), + fFoundDetectors(".") { - // create simulation object with default parameters - - SetGAliceFile("galice.root"); + // ctor: initialise checkers and open the data file + for (Int_t det = 0 ; det < AliQualAss::kNDET ; det++) + fCheckers[det] = NULL ; + + GetDataFile() ; } //_____________________________________________________________________________ AliQualAssChecker::AliQualAssChecker(const AliQualAssChecker& qac) : TNamed(qac), - fGAliceFileName(qac.fGAliceFileName), - fStopOnError(qac.fStopOnError) + fDataFile(qac.fDataFile), + fRefDirName(qac.fRefDirName), + fRefName(qac.fRefName), + fFoundDetectors(qac.fFoundDetectors) { -// copy constructor + // copy constructor + + for (Int_t det = 0 ; det < AliQualAss::kNDET ; det++) + fCheckers[det] = NULL ; } //_____________________________________________________________________________ @@ -75,123 +83,202 @@ AliQualAssChecker& AliQualAssChecker::operator = (const AliQualAssChecker& qac) AliQualAssChecker::~AliQualAssChecker() { // clean up - fgOutFile->Close() ; - delete fgOutFile ; } //_____________________________________________________________________________ -TFile * AliQualAssChecker:: GetOutFile() +TFile * AliQualAssChecker:: GetDataFile() +{ + // Open if necessary the Data file and return its pointer + + if (!fDataFile) + fDataFile = TFile::Open(AliQualAss::GetDataName()) ; + if (!fDataFile) + AliFatal(Form("QA Data File %s does not exist", AliQualAss::GetDataName() )) ; + return fDataFile ; +} + +//_____________________________________________________________________________ +TFile * AliQualAssChecker:: GetQAResultFile() { // Check if file to store QA exists, if not create it - if (fgOutFile) { - if (fgOutFile->IsOpen()){ - fgOutFile->Close() ; - fgOutFile = 0x0 ; + if (fgQAResultFile) { + if (fgQAResultFile->IsOpen()){ + fgQAResultFile->Close() ; + fgQAResultFile = 0x0 ; } } - fgOutName.Prepend(fgOutDir) ; + if ( fgQAResultFileName.Contains("local://")) + fgQAResultFileName.ReplaceAll("local:/", "") ; + TString opt("") ; - if ( !gSystem->AccessPathName(fgOutName) ) + if ( !gSystem->AccessPathName(fgQAResultFileName) ) opt = "UPDATE" ; else opt = "NEW" ; - fgOutFile = TFile::Open(fgOutName, opt) ; - - return fgOutFile ; + fgQAResultFile = TFile::Open(fgQAResultFileName, opt) ; + + return fgQAResultFile ; } //_____________________________________________________________________________ -AliRunLoader* AliQualAssChecker::LoadRun(const char* mode) const + AliQualAssCheckerBase * AliQualAssChecker::GetDetQualAssChecker(Int_t det) { -// 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; + // Gets the Quality Assurance checker for the detector specified by its name + + if (fCheckers[det]) + return fCheckers[det]; + + TString detName(AliQualAss::GetDetName(det)) ; + + AliInfo(Form("Retrieving QA checker for %s", detName.Data())) ; + TPluginManager* pluginManager = gROOT->GetPluginManager() ; + TString qacName = "Ali" + detName + "QualAssChecker" ; + + AliQualAssCheckerBase * qac = NULL ; + // first check if a plugin is defined for the quality assurance checker + TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQualAssChecker", detName.Data()); + // if not, add a plugin for it + if (!pluginHandler) { + //AliInfo(Form("defining plugin for %s", qacName.Data())); + TString libs = gSystem->GetLibraries(); + + if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) + pluginManager->AddHandler("AliQualAssChecker", detName, qacName, detName + "qac", qacName + "()"); + else + pluginManager->AddHandler("AliQualAssChecker", detName, qacName, detName, qacName + "()"); + + pluginHandler = pluginManager->FindHandler("AliQualAssChecker", detName); + + if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) + qac = (AliQualAssCheckerBase *) pluginHandler->ExecPlugin(0); + + if (qac) + fCheckers[det] = qac ; } - return runLoader; + + return qac ; +} + + +//_____________________________________________________________________________ +TDirectory * AliQualAssChecker::GetRefSubDir(const char * det, const char * task) +{ + // Opens and returns the file with the reference data + TFile * f = TFile::Open(fRefDirName, "READ") ; + if (!f) + AliFatal(Form("Cannot find reference file %s", fRefDirName.Data())) ; + TDirectory * rv = NULL ; + rv = f->GetDirectory(det) ; + if (!rv) { + AliWarning(Form("Directory %s not found in %d", det, fRefDirName.Data())) ; + } else { + rv = rv->GetDirectory(task) ; + if (!rv) + AliWarning(Form("Directory %s/%s not found in %s", det, task, fRefDirName.Data())) ; + } + return rv ; } //_____________________________________________________________________________ Bool_t AliQualAssChecker::Run() { - // run the Quality Assurance Checker for all tasks Hits, SDigits, Digits, recpoints, tracksegments, recparticles and ESDs + // 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(); + //search for all detectors QA directories + TList * detKeyList = GetDataFile()->GetListOfKeys() ; + TIter nextd(detKeyList) ; + TKey * detKey ; + while ( (detKey = dynamic_cast(nextd()) ) ) { + AliInfo(Form("Found %s", detKey->GetName())) ; + //Check which detector + TString detName ; + TString detNameQA(detKey->GetName()) ; + Int_t det ; + for ( det = 0; det < AliQualAss::kNDET ; det++) { + detName = AliQualAss::GetDetName(det) ; + if (detNameQA.Contains(detName)) { + fFoundDetectors+=detName ; + fFoundDetectors+="." ; + break ; + } + } + TDirectory * detDir = GetDataFile()->GetDirectory(detKey->GetName()) ; + TList * taskKeyList = detDir->GetListOfKeys() ; + TIter nextt(taskKeyList) ; + TKey * taskKey ; + // now search for the tasks dir + while ( (taskKey = static_cast(nextt()) ) ) { + TString taskName( taskKey->GetName() ) ; + AliInfo(Form("Found %s", taskName.Data())) ; + TDirectory * taskDir = detDir->GetDirectory(taskName.Data()) ; + taskDir->cd() ; + AliQualAssCheckerBase * qac = GetDetQualAssChecker(det) ; + if (qac) + AliInfo(Form("QA checker found for %s", detName.Data())) ; + if (!qac) + AliFatal(Form("QA checker not found for %s", detName.Data())) ; + AliQualAss::ALITASK index = AliQualAss::kNULLTASK ; + if ( taskName == AliQualAss::GetTaskName(AliQualAss::kHITS) ) + index = AliQualAss::kSIM ; + if ( taskName == AliQualAss::GetTaskName(AliQualAss::kSDIGITS) ) + index = AliQualAss::kSIM ; + if ( taskName == AliQualAss::GetTaskName(AliQualAss::kDIGITS) ) + index = AliQualAss::kSIM ; + if ( taskName == AliQualAss::GetTaskName(AliQualAss::kRECPOINTS) ) + index = AliQualAss::kREC ; + if ( taskName == AliQualAss::GetTaskName(AliQualAss::kTRACKSEGMENTS) ) + index = AliQualAss::kREC ; + if ( taskName == AliQualAss::GetTaskName(AliQualAss::kRECPARTICLES) ) + index = AliQualAss::kREC ; + if ( taskName == AliQualAss::GetTaskName(AliQualAss::kESDS) ) + index = AliQualAss::kESD ; + qac->Init(AliQualAss::DETECTORINDEX(det)) ; + qac->SetRefandData(GetRefSubDir(detNameQA.Data(), taskName.Data()), taskDir) ; + qac->Run(index) ; } - - 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; + } + AliInfo("QA performed for following detectors:") ; + for ( Int_t det = 0; det < AliQualAss::kNDET; det++) { + if (fFoundDetectors.Contains(AliQualAss::GetDetName(det))) { + printf("%s, ",AliQualAss::GetDetName(det)) ; + fFoundDetectors.ReplaceAll(AliQualAss::GetDetName(det), "") ; + } } + printf("\n") ; + rv = kTRUE ; - AliDebug(2, Form("galice file name set to %s", fileName)); + return rv ; + } //_____________________________________________________________________________ -void AliQualAssChecker::SetOutDir(const char * outDir) +void AliQualAssChecker::SetQAResultDirName(const char * name) { // 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:/", "") ; + fgQAResultDirName.Prepend(name) ; + AliInfo(Form("QA results are in %s", fgQAResultDirName.Data())) ; + if ( fgQAResultDirName.Contains("local://")) + fgQAResultDirName.ReplaceAll("local:/", "") ; + fgQAResultFileName.Prepend(fgQAResultDirName) ; } //_____________________________________________________________________________ -void AliQualAssChecker::SetRefDir(const char * refDir) +void AliQualAssChecker::SetRefDirName(const char * name) { // 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:/", "") ; + fRefDirName.Prepend(name) ; + fRefDirName.Append(fRefName) ; + AliInfo(Form("Reference data are taken from %s", fRefDirName.Data())) ; + if ( fRefDirName.Contains("local://")) + fRefDirName.ReplaceAll("local:/", "") ; } diff --git a/STEER/AliQualAssChecker.h b/STEER/AliQualAssChecker.h index 84b361131eb..93f49d18364 100644 --- a/STEER/AliQualAssChecker.h +++ b/STEER/AliQualAssChecker.h @@ -18,7 +18,7 @@ #include #include "AliQualAss.h" -class AliRunLoader; +class AliQualAssCheckerBase ; class AliQualAssChecker: public TNamed { public: @@ -28,28 +28,27 @@ public: 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) ; + AliQualAssCheckerBase * GetDetQualAssChecker(Int_t det) ; + TDirectory * GetRefSubDir(const char * det, const char * task) ; + static TFile * GetQAResultFile() ; + static const char * GetQAResultFileName() { return fgQAResultFileName.Data() ; } + void SetQAResultDirName(const char * name) ; + void SetRefDirName(const char * name) ; 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 - +// AliRunLoader* LoadRun(const char* mode = "UPDATE") const; + TFile * GetDataFile() ; + + TFile * fDataFile ; //! Data file to check + static TFile * fgQAResultFile ; //! File where to find the QA result + static TString fgQAResultDirName ; //! directory where to find the QA result + static TString fgQAResultFileName ;//! file name where to find the QA result + TString fRefDirName ; //! name of directory where to find the reference data file + TString fRefName ; //! file name where to find the reference data + TString fFoundDetectors ; //! detectors for which the Quality assurance could be done + AliQualAssCheckerBase * fCheckers[AliQualAss::kNDET] ; //! list of detectors checkers ClassDef(AliQualAssChecker, 1) // class for running generation, simulation and digitization }; diff --git a/STEER/AliQualAssCheckerBase.cxx b/STEER/AliQualAssCheckerBase.cxx index ef22e98197c..9db870b37d3 100644 --- a/STEER/AliQualAssCheckerBase.cxx +++ b/STEER/AliQualAssCheckerBase.cxx @@ -45,20 +45,17 @@ ClassImp(AliQualAssCheckerBase) //____________________________________________________________________________ AliQualAssCheckerBase::AliQualAssCheckerBase(const char * name, const char * title) : TNamed(name, title), - fData(0x0), - fDetectorDir(0x0), - fRef(0x0) + fDataSubDir(0x0), + fRefSubDir(0x0) { // ctor - Init() ; } //____________________________________________________________________________ AliQualAssCheckerBase::AliQualAssCheckerBase(const AliQualAssCheckerBase& qadm) : TNamed(qadm.GetName(), qadm.GetTitle()), - fData(qadm.fData), - fDetectorDir(qadm.fDetectorDir), - fRef(qadm.fRef) + fDataSubDir(qadm.fDataSubDir), + fRefSubDir(qadm.fRefSubDir) { //copy ctor @@ -73,12 +70,56 @@ AliQualAssCheckerBase& AliQualAssCheckerBase::operator = (const AliQualAssChecke return *this; } +//____________________________________________________________________________ +const Double_t AliQualAssCheckerBase::Check() +{ + // Performs a basic checking + // Compares all the histograms stored in the directory + + Double_t test = 0.0 ; + Int_t count = 0 ; + + if (!fDataSubDir) + test = 1. ; // nothing to check + else + if (!fRefSubDir) + test = -1 ; // no reference data + else { + TList * keyList = fDataSubDir->GetListOfKeys() ; + TIter next(keyList) ; + TKey * key ; + count = 0 ; + while ( (key = static_cast(next())) ) { + TObject * odata = fRefSubDir->Get(key->GetName()) ; + if ( odata->IsA()->InheritsFrom("TH1") ) { + TH1 * hdata = static_cast(odata) ; + TH1 * href = static_cast(fRefSubDir->Get(key->GetName())) ; + if (!href) + test = -1 ; // no reference data ; + else { + Double_t rv = DiffK(hdata, href) ; + AliInfo(Form("%s ->Test = %f", hdata->GetName(), rv)) ; + test += rv ; + count++ ; + } + } + else + AliError(Form("%s Is a Classname that cannot be processed", key->GetClassName())) ; + } + + } + if (count != 0) + test /= count ; + + return test ; +} + //____________________________________________________________________________ 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())) ; + AliWarning(Form("Spectrum %s in %s is empty", hin->GetName(), AliQualAss::GetDataName())) ; return 0. ; } @@ -90,7 +131,7 @@ const Double_t AliQualAssCheckerBase::DiffK(const TH1 * href, const TH1 * hin) c { // compares two histograms using the Kolmogorov test if ( hin->Integral() == 0 ) { - AliWarning(Form("Spectrum %s in %s is empty", hin->GetName(), fData->GetName())) ; + AliWarning(Form("Spectrum %s in %s is empty", hin->GetName(), AliQualAss::GetDataName())) ; return 0. ; } @@ -98,36 +139,20 @@ const Double_t AliQualAssCheckerBase::DiffK(const TH1 * href, const TH1 * hin) c } //____________________________________________________________________________ -void AliQualAssCheckerBase::Init() +void AliQualAssCheckerBase::Init(const AliQualAss::DETECTORINDEX det) { - //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) ; + AliQualAss::Instance(det) ; } //____________________________________________________________________________ -void AliQualAssCheckerBase::Exec(const Option_t * opt) +void AliQualAssCheckerBase::Run(AliQualAss::ALITASK index) { - AliInfo(Form("Processing %s", opt)) ; -// loop over detectors - AliQualAss * qa = AliQualAss::Instance(AliQualAss::kPHOS) ; - Double_t rv = Check(opt) ; - if ( rv <= 0.) + AliInfo(Form("Processing %s", AliQualAss::GetAliTaskName(index))) ; + + AliQualAss * qa = AliQualAss::Instance(index) ; + + Double_t rv = Check() ; + if ( rv <= 0.) qa->Set(AliQualAss::kFATAL) ; else if ( rv > 0 && rv <= 0.2 ) qa->Set(AliQualAss::kERROR) ; @@ -135,9 +160,8 @@ void AliQualAssCheckerBase::Exec(const Option_t * opt) qa->Set(AliQualAss::kWARNING) ; else if ( rv > 0.5 && rv < 1 ) qa->Set(AliQualAss::kINFO) ; - AliInfo(Form("Test result of %s in PHOS", opt)) ; + AliInfo(Form("Test result of %s", AliQualAss::GetAliTaskName(index))) ; Finish() ; -// endloop } //____________________________________________________________________________ @@ -147,7 +171,7 @@ void AliQualAssCheckerBase::Finish() const AliQualAss * qa = AliQualAss::Instance() ; qa->Show() ; - AliQualAssChecker::GetOutFile()->cd() ; + AliQualAssChecker::GetQAResultFile()->cd() ; qa->Write(qa->GetName(), kWriteDelete) ; - AliQualAssChecker::GetOutFile()->Close() ; + AliQualAssChecker::GetQAResultFile()->Close() ; } diff --git a/STEER/AliQualAssCheckerBase.h b/STEER/AliQualAssCheckerBase.h index 24b0a845a9c..5de42f634a0 100644 --- a/STEER/AliQualAssCheckerBase.h +++ b/STEER/AliQualAssCheckerBase.h @@ -15,9 +15,9 @@ // --- ROOT system --- #include -#include "AliLog.h" +#include "AliQualAss.h" class TFile ; -class TH1; +class TH1 ; // --- Standard library --- @@ -31,18 +31,18 @@ public: AliQualAssCheckerBase& operator = (const AliQualAssCheckerBase& qac) ; virtual ~AliQualAssCheckerBase() {;} // dtor - void Exec(const Option_t * = ""); + void Run(AliQualAss::ALITASK tsk); + void Init(const AliQualAss::DETECTORINDEX det) ; + void SetRefandData(TDirectory * ref, TDirectory * data) { fRefSubDir = ref ; fDataSubDir = data ; } protected: - void Init() ; - virtual const Double_t Check(const Option_t *) {AliInfo("To be implemented by detectors"); return 0; } + virtual const Double_t Check() ; 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 + TDirectory * fDataSubDir ; //! directory for the current task directory in the current detector directory in the data file + TDirectory * fRefSubDir ; //! directory for the current task directory in the current detector directory in the reference file ClassDef(AliQualAssCheckerBase,1) // description diff --git a/STEER/AliQualAssDataMaker.cxx b/STEER/AliQualAssDataMaker.cxx index c6d69db1d16..348233aaa4f 100644 --- a/STEER/AliQualAssDataMaker.cxx +++ b/STEER/AliQualAssDataMaker.cxx @@ -46,6 +46,9 @@ AliQualAssDataMaker::AliQualAssDataMaker(const char * name, const char * title) fData(0x0) { // ctor + TString tmp(GetName()) ; + tmp.Append("QA") ; + SetName(tmp.Data()) ; fOutput = AliQualAss::GetQADMOutFile() ; fDetectorDirName = GetName() ; } @@ -125,35 +128,35 @@ void AliQualAssDataMaker::Finish(AliQualAss::TASKINDEX task) const 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 ; +// switch (task) { +// case AliQualAss::kHITS: + subDir = fDetectorDir->GetDirectory(AliQualAss::GetTaskName(task)) ; +// 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::kRECPOINTS: +// subDir = fDetectorDir->GetDirectory("RecPoints") ; +// break ; - case AliQualAss::kTRACKSEGMENTS: - subDir = fDetectorDir->GetDirectory("TrackSegments") ; - break ; +// case AliQualAss::kTRACKSEGMENTS: +// subDir = fDetectorDir->GetDirectory("TrackSegments") ; +// break ; - case AliQualAss::kRECPARTICLES: - subDir = fDetectorDir->GetDirectory("RecParticles") ; - break ; +// case AliQualAss::kRECPARTICLES: +// subDir = fDetectorDir->GetDirectory("RecParticles") ; +// break ; - case AliQualAss::kESDS: - subDir = fDetectorDir->GetDirectory("ESDs") ; - break ; - } +// case AliQualAss::kESDS: +// subDir = fDetectorDir->GetDirectory("ESDs") ; +// break ; +// } subDir->Write() ; } diff --git a/STEER/AliQualAssDataMaker.h b/STEER/AliQualAssDataMaker.h index 6ce8b241a81..12f37e2f8d9 100644 --- a/STEER/AliQualAssDataMaker.h +++ b/STEER/AliQualAssDataMaker.h @@ -17,7 +17,7 @@ // --- ROOT system --- #include class TFile; -class TDirectory; + // --- Standard library --- // --- AliRoot header files --- diff --git a/STEER/AliReconstruction.cxx b/STEER/AliReconstruction.cxx index 20cab24ca67..607ca486a61 100644 --- a/STEER/AliReconstruction.cxx +++ b/STEER/AliReconstruction.cxx @@ -170,6 +170,7 @@ #include "AliAODVertex.h" #include "AliAODCluster.h" +#include "AliQualAssDataMaker.h" ClassImp(AliReconstruction) @@ -628,7 +629,19 @@ Bool_t AliReconstruction::Run(const char* input) if(fDiamondProfile) tVertexer.SetVtxStart(fDiamondProfile); // loop over events + if (fRawReader) fRawReader->RewindEvents(); + TString detStr(fFillESD) ; + +// initialises quality assurance for ESDs + for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { + if (!IsSelected(fgkDetectorName[iDet], detStr)) + continue; + AliQualAssDataMaker * qadm = GetQualAssDataMaker(iDet); + if (!qadm) + continue; + qadm->Init(AliQualAss::kESDS) ; + } for (Int_t iEvent = 0; iEvent < fRunLoader->GetNumberOfEvents(); iEvent++) { if (fRawReader) fRawReader->NextEvent(); @@ -723,6 +736,10 @@ Bool_t AliReconstruction::Run(const char* input) if (fStopOnError) {CleanUp(file, fileOld); return kFALSE;} } } + + if (!fFillESD.IsNull()) + RunQualAss(fFillESD.Data(), esd); + // fill Event header information from the RawEventHeader if (fRawReader){FillRawEventHeaderESD(esd);} @@ -794,10 +811,20 @@ Bool_t AliReconstruction::Run(const char* input) } // esdf->Reset(); // delete esdf; esdf = 0; - } - - - + // ESD QA + + } + + detStr = fFillESD ; + // write quality assurance ESDs data (one entry for all events) + for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { + if (!IsSelected(fgkDetectorName[iDet], detStr)) + continue; + AliQualAssDataMaker * qadm = GetQualAssDataMaker(iDet); + if (!qadm) + continue; + qadm->Finish(AliQualAss::kESDS) ; + } tree->GetUserInfo()->Add(esd); hlttree->GetUserInfo()->Add(hltesd); @@ -1704,7 +1731,6 @@ void AliReconstruction::CleanUp(TFile* file, TFile* fileOld) } } - //_____________________________________________________________________________ Bool_t AliReconstruction::ReadESD(AliESDEvent*& esd, const char* recStep) const @@ -2591,3 +2617,114 @@ void AliReconstruction::TNamedToFile(TTree* fTree, TString fName){ } +//_____________________________________________________________________________ +AliQualAssDataMaker * AliReconstruction::GetQualAssDataMaker(Int_t iDet) +{ +// get the quality assurance data maker object and the loader for a detector + + if (fQualAssDataMaker[iDet]) + return fQualAssDataMaker[iDet]; + + // load the QA data maker object + TPluginManager* pluginManager = gROOT->GetPluginManager(); + TString detName = fgkDetectorName[iDet]; + TString qadmName = "Ali" + detName + "QualAssDataMaker"; + if (gAlice && !gAlice->GetDetector(detName) && (detName != "HLT")) + return NULL; + + AliQualAssDataMaker * qadm = NULL; + // first check if a plugin is defined for the quality assurance data maker + TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQualAssDataMaker", detName); + // if not, add a plugin for it + if (!pluginHandler) { + AliDebug(1, Form("defining plugin for %s", qadmName.Data())); + TString libs = gSystem->GetLibraries(); + if (libs.Contains("lib" + detName + "base.so") || + (gSystem->Load("lib" + detName + "base.so") >= 0)) { + pluginManager->AddHandler("AliQualAssDataMaker", detName, + qadmName, detName + "qadm", qadmName + "()"); + } else { + pluginManager->AddHandler("AliQualAssDataMaker", detName, + qadmName, detName, qadmName + "()"); + } + pluginHandler = pluginManager->FindHandler("AliQualAssDataMaker", detName); + } + if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { + qadm = (AliQualAssDataMaker *) pluginHandler->ExecPlugin(0); + } + if (qadm) { + // TObject* obj = fOptions.FindObject(detName.Data()); + // if (obj) reconstructor->SetOption(obj->GetTitle()); + fQualAssDataMaker[iDet] = qadm; + } + + // get or create the loader + fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader"); + if (!fLoader[iDet]) { + AliConfig::Instance() + ->CreateDetectorFolders(fRunLoader->GetEventFolder(), + detName, detName); + // first check if a plugin is defined for the loader + pluginHandler = + pluginManager->FindHandler("AliLoader", detName); + // if not, add a plugin for it + if (!pluginHandler) { + TString loaderName = "Ali" + detName + "Loader"; + AliDebug(1, Form("defining plugin for %s", loaderName.Data())); + pluginManager->AddHandler("AliLoader", detName, + loaderName, detName + "base", + loaderName + "(const char*, TFolder*)"); + pluginHandler = pluginManager->FindHandler("AliLoader", detName); + } + if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { + fLoader[iDet] = + (AliLoader*) pluginHandler->ExecPlugin(2, detName.Data(), + fRunLoader->GetEventFolder()); + } + if (!fLoader[iDet]) { // use default loader + fLoader[iDet] = new AliLoader(detName, fRunLoader->GetEventFolder()); + } + if (!fLoader[iDet]) { + AliWarning(Form("couldn't get loader for %s", detName.Data())); + if (fStopOnError) return NULL; + } else { + fRunLoader->AddLoader(fLoader[iDet]); + fRunLoader->CdGAFile(); + if (gFile && !gFile->IsWritable()) gFile->ReOpen("UPDATE"); + fRunLoader->Write(0, TObject::kOverwrite); + } + } + + return qadm; +} + +//_____________________________________________________________________________ +Bool_t AliReconstruction::RunQualAss(const char* detectors, AliESDEvent *& esd) +{ + // run the Quality Assurance data producer + + AliCodeTimerAuto("") + TString detStr = detectors; + for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) { + if (!IsSelected(fgkDetectorName[iDet], detStr)) + continue; + AliQualAssDataMaker * qadm = GetQualAssDataMaker(iDet); + if (!qadm) + continue; + AliCodeTimerStart(Form("running quality assurance data maker for %s", fgkDetectorName[iDet])); + AliInfo(Form("running quality assurance data maker for %s", fgkDetectorName[iDet])); + + qadm->SetData(esd) ; + qadm->Exec(AliQualAss::kESDS) ; + + AliCodeTimerStop(Form("running quality assurance data maker for %s", fgkDetectorName[iDet])); + } + if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) { + AliError(Form("the following detectors were not found: %s", + detStr.Data())); + if (fStopOnError) + return kFALSE; + } + + return kTRUE; +} diff --git a/STEER/AliReconstruction.h b/STEER/AliReconstruction.h index 1af41fe507c..99dcade92be 100644 --- a/STEER/AliReconstruction.h +++ b/STEER/AliReconstruction.h @@ -31,7 +31,7 @@ class AliESDVertex; class AliESDEvent; class TFile; class TTree; - +class AliQualAssDataMaker; class AliReconstruction: public TNamed { public: @@ -97,6 +97,8 @@ public: virtual Bool_t Run(const char* input = NULL); + // Quality Assurance + virtual Bool_t RunQualAss(const char* detectors, AliESDEvent *& esd); private: Bool_t RunLocalReconstruction(const TString& detectors); @@ -127,6 +129,9 @@ private: void FillRawDataErrorLog(Int_t iEvent, AliESDEvent* esd); + //Quality Assurance + AliQualAssDataMaker* GetQualAssDataMaker(Int_t iDet); + //*** Global reconstruction flags ******************* Bool_t fUniformField; // uniform field tracking flag Bool_t fRunVertexFinder; // run the vertex finder @@ -171,6 +176,9 @@ private: TString fCDBUri; // Uri of the default CDB storage TObjArray fSpecCDBUri; // Array with detector specific CDB storages + //Quality Assurance + AliQualAssDataMaker * fQualAssDataMaker[fgkNDetectors]; //! array of QA data maker objects + ClassDef(AliReconstruction, 12) // class for running the reconstruction }; -- 2.39.3