]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Updated QA classes (Yves)
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 22 Aug 2007 09:20:50 +0000 (09:20 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 22 Aug 2007 09:20:50 +0000 (09:20 +0000)
21 files changed:
PHOS/AliPHOS.cxx
PHOS/AliPHOS.h
PHOS/AliPHOSClusterizer.cxx
PHOS/AliPHOSClusterizerv1.cxx
PHOS/AliPHOSQualAssChecker.cxx
PHOS/AliPHOSQualAssChecker.h
PHOS/AliPHOSQualAssDataMaker.cxx
PHOS/AliPHOSReconstructor.cxx
PHOS/AliPHOSTrackSegmentMakerv2.cxx
STEER/AliPreprocessor.cxx
STEER/AliPreprocessor.h
STEER/AliQualAss.cxx
STEER/AliQualAss.h
STEER/AliQualAssChecker.cxx
STEER/AliQualAssChecker.h
STEER/AliQualAssCheckerBase.cxx
STEER/AliQualAssCheckerBase.h
STEER/AliQualAssDataMaker.cxx
STEER/AliQualAssDataMaker.h
STEER/AliReconstruction.cxx
STEER/AliReconstruction.h

index 77ea421a601f88c6807aa9777c37a77d52f45d48..ec12ad26aae3f478103975975a3102689be5f07e 100644 (file)
@@ -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; i<sdigits->GetEntries(); 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() ; 
-}
index c366ed45cd01f2602fd254f475662ce0d06e5699..8279b542f703154cb0d203621e715865918958f0 100644 (file)
@@ -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*/);
index 932db7a0dbb2517f66d1a5245823b3a5a6725e52..2adef3868d6d0e467fd376406756b41a6a9e795c 100644 (file)
@@ -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 ; 
 }
 
 
index 7a39728b51122d4348e66826b89727f56b62ef8d..06fa62a32915a8e76d06a7dc9a677b19e1824251 100644 (file)
@@ -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");
index d9d5b531fa40de9e201375c581e1c65b4f289959..99cbbba0c9a7542904ea1e7691d884bb0e1f471c 100644 (file)
 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<TKey *>(next())) ) {
-      TObject * oref = wRefDir->Get(key->GetName()) ; 
-      if ( oref->IsA()->InheritsFrom("TH1") ) {
-       TH1 * href = static_cast<TH1F*>(oref) ; 
-       TH1 * hin  = static_cast<TH1F*>(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 ; 
-}  
index 9c50f27890e8494d20c7e7fe85c766ce93cdbaac..3a5e844b3349eeb239ba9a6281a73230826f3e10 100644 (file)
@@ -34,8 +34,6 @@ public:
 
 private:
   
-  virtual const Double_t Check(const Option_t * opt) ; 
-
   ClassDef(AliPHOSQualAssChecker,1)  // description 
 
 };
index 8cc7e7fefc2664f84c7403d92c2102870e8a07ec..767d8fe31e755850a193ce48bad99b022feffef6 100644 (file)
@@ -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() ;
 }
 
 //____________________________________________________________________________
index 4f36febad8e651ac13367ed44fb53ee2b4dfa987..386a40df1c9e77474168f9b260a26d46852f4a61 100644 (file)
@@ -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()));
 
 
index e976b450dd8144dbc36dc0f304c118a7b48ba5b9..99fe339ef2a28e70f1e0f25e560a70fef36837c2 100644 (file)
@@ -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"
 
index d62f91227082cfd8b5082fcefc907bc01070648a..b3ae32c9fa08c378085fbb5e41b8bd428e8bda05 100644 (file)
@@ -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();
-
-}
index 265085edf3af4c12dc09720d2e9680a692613784..bab0f68b53d79f0bba0346181684a3c7df10f787 100644 (file)
@@ -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
index 16aa20bdb76ba1de75e55392491b39ef00359297..2645248d10ad36470ef3fc76f88bf0b3d7a1783e 100644 (file)
 
 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 )) ;
 }
 
index 51a2cac0886c813ef499e6a2048036bc4133a980..ae95134d624979acb2467becf57c74c9b57a8b24 100644 (file)
@@ -9,8 +9,7 @@
 // Quality Assurance Object
 //
 
-#include <TNamed.h>
-#include "AliLog.h" 
+#include <TNamed.h> 
 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
index 61d703e29d8b8a6ddb6f37da03870f68686bfc2e..2eb88addb93657a85721e32c65801015e2c49298 100644 (file)
 
 #include "AliLog.h"
 #include "AliModule.h" 
-#include "AliRun.h"
-#include "AliRunLoader.h"
 #include "AliQualAss.h"
 #include "AliQualAssChecker.h"
+#include "AliQualAssCheckerBase.h"
 
+#include <TKey.h>
 #include <TObjArray.h>
+#include <TPluginManager.h> 
+#include <TROOT.h>
 #include <TStopwatch.h> 
 #include <TString.h> 
-
+#include <TSystem.h> 
 
 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<TKey *>(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<TKey *>(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:/", "") ; 
 }
 
 
index 84b361131eb2bcdae6edbe2cceb4fc23b21be5e7..93f49d183648bb6b5f24a2cdd6effe0bf5cd3896 100644 (file)
@@ -18,7 +18,7 @@
 #include <TFile.h>  
 
 #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
 };
 
index ef22e98197cd002b8be3ddcf020ef3b30fdd3cf3..9db870b37d3ffa0bb0f2dd5912ddd1ffade2d603 100644 (file)
@@ -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<TKey *>(next())) ) {
+        TObject * odata = fRefSubDir->Get(key->GetName()) ; 
+        if ( odata->IsA()->InheritsFrom("TH1") ) {
+          TH1 * hdata = static_cast<TH1*>(odata) ; 
+          TH1 * href  = static_cast<TH1*>(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() ;  
 }
index 24b0a845a9cae5900ac4dd17e6c524cb6e9a403f..5de42f634a03a6b709c9b0008e7bf8478684af57 100644 (file)
@@ -15,9 +15,9 @@
 
 // --- ROOT system ---
 #include <TNamed.h>
-#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 
 
index c6d69db1d16d10d06a6d623a9374fbe6f983de2a..348233aaa4fb92c5578ab4e131dad96a5dfea3e3 100644 (file)
@@ -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() ; 
 } 
 
index 6ce8b241a817b6892f9658fe3b094f4cf5d315af..12f37e2f8d90f0c9951f2aafd449c4bac018d6a5 100644 (file)
@@ -17,7 +17,7 @@
 // --- ROOT system ---
 #include <TNamed.h>  
 class TFile;  
-class TDirectory;
+
 // --- Standard library ---
 
 // --- AliRoot header files ---
index 20cab24ca670bed2a31b4e6cc409e92495e78550..607ca486a618116cee67c0cd8d30c419e764ee6d 100644 (file)
 #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;
+}
index 1af41fe507c17c26fbb00200f6f172c8f9983474..99dcade92bed5b1ccb24db821ed728cf2f35cce8 100644 (file)
@@ -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
 };