Option to select detector and QA task duringreconstruction
authorschutz <schutz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 6 Jun 2008 17:03:12 +0000 (17:03 +0000)
committerschutz <schutz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 6 Jun 2008 17:03:12 +0000 (17:03 +0000)
STEER/AliReconstruction.cxx
STEER/AliReconstruction.h
test/QA/rec.C

index 72f35db..3ad6380 100644 (file)
@@ -253,6 +253,8 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename,
   fSpecCDBUri(), 
   fInitCDBCalled(kFALSE),
   fSetRunNumberFromDataCalled(kFALSE),
+  fQADetectors("ALL"), 
+  fQATasks("ALL"), 
   fRunQA(kTRUE),  
   fRunGlobalQA(kTRUE),
   fInLoopQA(kFALSE),
@@ -342,6 +344,8 @@ AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
   fSpecCDBUri(), 
   fInitCDBCalled(rec.fInitCDBCalled),
   fSetRunNumberFromDataCalled(rec.fSetRunNumberFromDataCalled),
+  fQADetectors(rec.fQADetectors), 
+  fQATasks(rec.fQATasks), 
   fRunQA(rec.fRunQA),  
   fRunGlobalQA(rec.fRunGlobalQA),
   fInLoopQA(rec.fInLoopQA),
@@ -646,7 +650,6 @@ Bool_t AliReconstruction::Run(const char* input)
   AliCodeTimerAuto("");
 
   if (!InitRun(input)) return kFALSE;
-
   //******* The loop over events
   Int_t iEvent = 0;
   while ((iEvent < fRunLoader->GetNumberOfEvents()) ||
@@ -876,43 +879,61 @@ Bool_t AliReconstruction::InitRun(const char* input)
   gSystem->GetProcInfo(&ProcInfo);
   AliInfo(Form("Current memory usage %d %d", ProcInfo.fMemResident, ProcInfo.fMemVirtual));
   
-
   //QA
-  AliQADataMakerSteer qas ; 
-  if (fRunQA && fRawReader) { 
-    qas.Run(fRunLocalReconstruction, fRawReader) ; 
-       fSameQACycle = kTRUE ; 
+  if (fRunQA && fRawReader && fQATasks.Contains(Form("%d", AliQA::kRAWS))) { 
+               AliQADataMakerSteer qas ; 
+               qas.Run(fRunLocalReconstruction, fRawReader) ; 
+               fSameQACycle = kTRUE ; 
   }
   //Initialize the QA and start of cycle for out-of-cycle QA
   if (fRunQA) {
-//      TString detStr(fFillESD); 
-//      for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
-//         if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
-//         AliQADataMakerRec *qadm = GetQADataMaker(iDet);  
-//         if (!qadm) continue;
-//         AliInfo(Form("Initializing the QA data maker for %s", 
-//                fgkDetectorName[iDet]));
-//         qadm->Init(AliQA::kRECPOINTS, AliCDBManager::Instance()->GetRun());
-//         qadm->Init(AliQA::kESDS, AliCDBManager::Instance()->GetRun());
-//         if (!fInLoopQA) {
-//                     qadm->StartOfCycle(AliQA::kRECPOINTS, fSameQACycle);
-//                     qadm->StartOfCycle(AliQA::kESDS,"same");
-//         }
-//      }
+         TString detStr(fQADetectors) ; 
+      for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
+         if (!IsSelected(fgkDetectorName[iDet], detStr)) 
+                        continue;
+         AliQADataMakerRec *qadm = GetQADataMaker(iDet);  
+         if (!qadm) 
+                        continue;
+         AliInfo(Form("Initializing the QA data maker for %s", 
+                fgkDetectorName[iDet]));
+                if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS))) 
+                        qadm->Init(AliQA::kRECPOINTS, AliCDBManager::Instance()->GetRun());
+                if (fQATasks.Contains(Form("%d", AliQA::kESDS)))  
+                        qadm->Init(AliQA::kESDS, AliCDBManager::Instance()->GetRun());
+         if (!fInLoopQA) {
+                        if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS))) {
+                                qadm->StartOfCycle(AliQA::kRECPOINTS, fSameQACycle);
+                                fSameQACycle = kTRUE;
+                        }
+                        if (fQATasks.Contains(Form("%d", AliQA::kESDS))) {  
+                                qadm->StartOfCycle(AliQA::kESDS, fSameQACycle);
+                                fSameQACycle = kTRUE;
+                        }
+                }
+      }
          if (fRunGlobalQA) {
                  AliQADataMakerRec *qadm = GetQADataMaker(AliQA::kGLOBAL);
                  AliInfo(Form("Initializing the global QA data maker"));
-                 TObjArray *arr=
-                       qadm->Init(AliQA::kRECPOINTS, AliCDBManager::Instance()->GetRun());
-                 AliTracker::SetResidualsArray(arr);
-                 qadm->Init(AliQA::kESDS, AliCDBManager::Instance()->GetRun());
+                 if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS))) {
+                         TObjArray *arr=
+                               qadm->Init(AliQA::kRECPOINTS, AliCDBManager::Instance()->GetRun());
+                         AliTracker::SetResidualsArray(arr);
+                 }
+                 if (fQATasks.Contains(Form("%d", AliQA::kESDS))) {
+                         qadm->Init(AliQA::kESDS, AliCDBManager::Instance()->GetRun());
+                 }
                  if (!fInLoopQA) {
-                         qadm->StartOfCycle(AliQA::kRECPOINTS, fSameQACycle);
-                         qadm->StartOfCycle(AliQA::kESDS, "same");
+                         fSameQACycle = kFALSE;
+                         if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS))) {                                 
+                                 qadm->StartOfCycle(AliQA::kRECPOINTS, fSameQACycle);
+                                 fSameQACycle = kTRUE;
+                         }
+                         if (fQATasks.Contains(Form("%d", AliQA::kESDS))) { 
+                                 qadm->StartOfCycle(AliQA::kESDS, fSameQACycle);
+                                 fSameQACycle = kTRUE; 
+                         }
                  }
          }
-         if (!fInLoopQA) 
-                 fSameQACycle = kTRUE; 
   }
 
   //Initialize the Plane Efficiency framework
@@ -962,20 +983,34 @@ Bool_t AliReconstruction::RunEvent(Int_t iEvent)
     //Start of cycle for the in-loop QA
     if (fInLoopQA) {
        if (fRunQA) {
-          TString detStr(fFillESD); 
+                 fSameQACycle = kFALSE ;
+          TString detStr(fQADetectors); 
           for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
              if (!IsSelected(fgkDetectorName[iDet], detStr)) 
                                 continue;
              AliQADataMakerRec *qadm = GetQADataMaker(iDet);  
              if (!qadm) 
                                 continue;
-             qadm->StartOfCycle(AliQA::kRECPOINTS, fSameQACycle);
-             qadm->StartOfCycle(AliQA::kESDS, "same") ;        
+                         if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS))) {
+                                 qadm->StartOfCycle(AliQA::kRECPOINTS, fSameQACycle);
+                                 fSameQACycle = kTRUE;
+                         }
+                         if (fQATasks.Contains(Form("%d", AliQA::kESDS))) {
+                                 qadm->StartOfCycle(AliQA::kESDS, fSameQACycle) ;
+                                 fSameQACycle = kTRUE;
+                         }
           }
                   if (fRunGlobalQA) {
+                          fSameQACycle = kFALSE;
                           AliQADataMakerRec *qadm = GetQADataMaker(AliQA::kGLOBAL);
-                          qadm->StartOfCycle(AliQA::kRECPOINTS, fSameQACycle);
-                          qadm->StartOfCycle(AliQA::kESDS, "same");
+                          if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS))) {
+                                  qadm->StartOfCycle(AliQA::kRECPOINTS, fSameQACycle);
+                                  fSameQACycle = kTRUE;
+                          }
+                          if (fQATasks.Contains(Form("%d", AliQA::kESDS))) {
+                                  qadm->StartOfCycle(AliQA::kESDS, fSameQACycle);
+                                  fSameQACycle = kTRUE;
+                          }
                   }               
           }
     }
@@ -1202,7 +1237,8 @@ Bool_t AliReconstruction::RunEvent(Int_t iEvent)
        if (fRunQA) {
                if (fRunGlobalQA) {
                        AliQADataMakerRec *qadm = GetQADataMaker(AliQA::kGLOBAL);
-                       if (qadm) qadm->Exec(AliQA::kESDS, fesd);
+                       if (qadm && fQATasks.Contains(Form("%d", AliQA::kESDS)))
+                               qadm->Exec(AliQA::kESDS, fesd);
                }
        }
 
@@ -1232,29 +1268,32 @@ Bool_t AliReconstruction::RunEvent(Int_t iEvent)
     AliInfo(Form("Event %d -> Current memory usage %d %d",iEvent, ProcInfo.fMemResident, ProcInfo.fMemVirtual));
   
 
-  // End of cycle for the in-loop QA
+  // End of cycle for the in-loop  
      if (fInLoopQA) {
         if (fRunQA) {
-           RunQA(fFillESD.Data(), fesd);
-           TString detStr(fFillESD); 
+           RunQA(fesd);
            for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
-                          if (!IsSelected(fgkDetectorName[iDet], detStr)) 
+                          if (!IsSelected(fgkDetectorName[iDet], fQADetectors)) 
                                   continue;
                           AliQADataMakerRec * qadm = GetQADataMaker(iDet);
-                          if (!qadm) 
+                          if (!qadm)
                                   continue;
-                          qadm->EndOfCycle(AliQA::kRECPOINTS);
-                          qadm->EndOfCycle(AliQA::kESDS);
+                          if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS))) 
+                                  qadm->EndOfCycle(AliQA::kRECPOINTS);
+                          if (fQATasks.Contains(Form("%d", AliQA::kESDS))) 
+                                  qadm->EndOfCycle(AliQA::kESDS);
                           qadm->Finish();
                   }
         }
         if (fRunGlobalQA) {
            AliQADataMakerRec *qadm = GetQADataMaker(AliQA::kGLOBAL);
            if (qadm) {
-             qadm->EndOfCycle(AliQA::kRECPOINTS);
-             qadm->EndOfCycle(AliQA::kESDS);
-             qadm->Finish();
-          }
+                          if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS))) 
+                                  qadm->EndOfCycle(AliQA::kRECPOINTS);
+                          if (fQATasks.Contains(Form("%d", AliQA::kESDS))) 
+                                  qadm->EndOfCycle(AliQA::kESDS);
+                          qadm->Finish();
+                  }
         }
      }
 
@@ -1347,14 +1386,18 @@ Bool_t AliReconstruction::FinishRun()
   if (!fInLoopQA) {
          if (fRunQA) {
                  AliQADataMakerSteer qas;
-                 qas.Run(fRunLocalReconstruction.Data(), AliQA::kRECPOINTS, fSameQACycle);
+                 if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS))) 
+                         qas.Run(fRunLocalReconstruction.Data(), AliQA::kRECPOINTS, fSameQACycle);
                  //qas.Reset() ;
-                 qas.Run(fRunLocalReconstruction.Data(), AliQA::kESDS, fSameQACycle);
+                 if (fQATasks.Contains(Form("%d", AliQA::kESDS))) 
+                         qas.Run(fRunLocalReconstruction.Data(), AliQA::kESDS, fSameQACycle);
                  if (fRunGlobalQA) {
                         AliQADataMakerRec *qadm = GetQADataMaker(AliQA::kGLOBAL);
                          if (qadm) {
-                                 qadm->EndOfCycle(AliQA::kRECPOINTS);
-                                 qadm->EndOfCycle(AliQA::kESDS);
+                                 if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS))) 
+                                         qadm->EndOfCycle(AliQA::kRECPOINTS);
+                                 if (fQATasks.Contains(Form("%d", AliQA::kESDS))) 
+                                         qadm->EndOfCycle(AliQA::kESDS);
                                  qadm->Finish();
                          }
                  }
@@ -1497,8 +1540,8 @@ Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors)
          //AliInfo
           //(Form("Running QA data maker for %s", fgkDetectorName[iDet]));
 
-         qadm->Exec(AliQA::kRECPOINTS, clustersTree) ;
+                  if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS))) 
+                          qadm->Exec(AliQA::kRECPOINTS, clustersTree) ;
          //AliCodeTimerStop
           //(Form("Running QA data maker for %s", fgkDetectorName[iDet]));
        }
@@ -2518,12 +2561,12 @@ AliQADataMakerRec * AliReconstruction::GetQADataMaker(Int_t iDet)
 }
 
 //_____________________________________________________________________________
-Bool_t AliReconstruction::RunQA(const char* detectors, AliESDEvent *& esd)
+Bool_t AliReconstruction::RunQA(AliESDEvent *& esd)
 {
   // run the Quality Assurance data producer
 
   AliCodeTimerAuto("")
-  TString detStr = detectors;
+  TString detStr = fQADetectors ;
   for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
    if (!IsSelected(fgkDetectorName[iDet], detStr)) 
      continue;
@@ -2533,9 +2576,10 @@ Bool_t AliReconstruction::RunQA(const char* detectors, AliESDEvent *& esd)
    AliCodeTimerStart(Form("running quality assurance data maker for %s", fgkDetectorName[iDet]));
    AliInfo(Form("running quality assurance data maker for %s", fgkDetectorName[iDet]));
     
-   qadm->Exec(AliQA::kESDS, esd) ; 
-   qadm->Increment() ; 
-
+   if (fQATasks.Contains(Form("%d", AliQA::kESDS))) {
+          qadm->Exec(AliQA::kESDS, esd) ; 
+          qadm->Increment() ; 
+   }
    AliCodeTimerStop(Form("running quality assurance data maker for %s", fgkDetectorName[iDet]));
  }
  if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
@@ -2682,3 +2726,49 @@ void AliReconstruction::RunAliEVE()
   gROOT->ProcessLine("gAliEveEvent->StartStopAutoLoadTimer();");
   gSystem->Run();
 }
+
+//_____________________________________________________________________________
+Bool_t AliReconstruction::SetRunQA(TString detAndAction) 
+{
+       // Allows to run QA for a selected set of detectors
+       // and a selected set of tasks among RAWS, RECPOINTS and ESDS
+       // all selected detectors run the same selected tasks
+       
+       if (!detAndAction.Contains(":")) {
+               AliError( Form("%s is a wrong syntax, use \"DetectorList:ActionList\" \n", detAndAction.Data()) ) ;
+               fRunQA = kFALSE ;
+               return kFALSE ;                 
+       }
+       Int_t colon = detAndAction.Index(":") ; 
+       fQADetectors = detAndAction(0, colon) ; 
+       if (fQADetectors.Contains("ALL") )
+               fQADetectors = fFillESD ; 
+       fQATasks   = detAndAction(colon+1, detAndAction.Sizeof() ) ; 
+       if (fQATasks.Contains("ALL") ) {
+               fQATasks = Form("%d %d %d", AliQA::kRAWS, AliQA::kRECPOINTS, AliQA::kESDS) ; 
+       } else {
+               fQATasks.ToUpper() ; 
+               TString tempo("") ; 
+               if ( fQATasks.Contains("RAW") ) 
+                       tempo = Form("%d ", AliQA::kRAWS) ; 
+               if ( fQATasks.Contains("RECPOINT") ) 
+                       tempo += Form("%d ", AliQA::kRECPOINTS) ; 
+               if ( fQATasks.Contains("ESD") ) 
+                       tempo += Form("%d ", AliQA::kESDS) ; 
+               fQATasks = tempo ; 
+               if (fQATasks.IsNull()) {
+                       AliInfo("No QA requested\n")  ;
+                       fRunQA = kFALSE ;
+                       return kTRUE ; 
+               }
+       }       
+       TString tempo(fQATasks) ; 
+    tempo.ReplaceAll(Form("%d", AliQA::kRAWS), AliQA::GetTaskName(AliQA::kRAWS))       ;
+    tempo.ReplaceAll(Form("%d", AliQA::kRECPOINTS), AliQA::GetTaskName(AliQA::kRECPOINTS)) ;   
+    tempo.ReplaceAll(Form("%d", AliQA::kESDS), AliQA::GetTaskName(AliQA::kESDS)) ;     
+       AliInfo( Form("QA will be done on \"%s\" for \"%s\"\n", fQADetectors.Data(), tempo.Data()) ) ;  
+       fRunQA = kTRUE ;
+       return kTRUE; 
+} 
+
+       
index 3a88ccb..2bac1c9 100644 (file)
@@ -125,9 +125,9 @@ public:
   void        ImportRunLoader(AliRunLoader* rl) { fRunLoader = rl; }
 
   // Quality Assurance 
-  virtual Bool_t RunQA(const char* detectors, AliESDEvent *& esd);
+  virtual Bool_t RunQA(AliESDEvent *& esd);
   void    SetQACycles(const char * detector, const Int_t cycles) { fQACycles[GetDetIndex(detector)] = cycles ; }
-  void    SetRunQA(Bool_t flag=kTRUE)      {fRunQA = flag ;} 
+  Bool_t  SetRunQA(TString detAndAction="ALL:ALL") ; 
   void    SetRunGlobalQA(Bool_t flag=kTRUE){fRunGlobalQA = flag;}
   void    SetInLoopQA(Bool_t flag=kTRUE)   {fInLoopQA    = flag;} 
 
@@ -240,10 +240,12 @@ private:
   //Quality Assurance
   AliQADataMakerRec *fQADataMaker[fgkNDetectors+1];  //! array of QA data makers
   Int_t fQACycles[   fgkNDetectors];// # events over which QA data are accumulated
+  TString            fQADetectors ;  // list of detectors to be QA'ed  
+  TString            fQATasks ;      // list of QA tasks to be performed       
   Bool_t             fRunQA ;        // Run QA flag
   Bool_t             fRunGlobalQA;   // Run global QA flag
   Bool_t             fInLoopQA;      // In-loop QA flag
-  Bool_t             fSameQACycle;   //! open a vew QA data file or not
+  Bool_t             fSameQACycle;   //! open a new QA data file or not
   // Plane Efficiency Evaluation
   Bool_t         fRunPlaneEff ;      // Evaluate Plane Efficiency
 
index ba738fe..d1a1d6e 100644 (file)
@@ -18,7 +18,12 @@ void rec() {
   //AliPHOSRecoParam* recEmc = new AliPHOSRecoParamEmc();
   //   recEmc->SetSubtractPedestals(kFALSE);
   //   AliPHOSReconstructor::SetRecoParamEmc(recEmc);  
-  reco.SetRunQA(kTRUE) ; 
+       if (! reco.SetRunQA("PHOS:ESD") ) {
+               printf("SetRunQA ERROR\n") ; 
+               exit ; 
+       }
+       reco.SetInLoopQA() ; 
+         
   AliQA::SetQARefStorage(Form("%s%s/", AliQA::GetQARefDefaultStorage(), kYear)) ;
   AliQA::SetQARefDataDirName("Sim") ; //Data, Pedestals, BlackEvent, .....