full working chain for tasks RES and DET
authorabercuci <abercuci@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 16 Sep 2008 12:52:39 +0000 (12:52 +0000)
committerabercuci <abercuci@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 16 Sep 2008 12:52:39 +0000 (12:52 +0000)
TRD/qaRec/AliTRDcheckDetector.cxx
TRD/qaRec/makeResults.C
TRD/qaRec/run.C
TRD/qaRec/run.h

index ec7c87fd583b32371ecf95e2da7394c8227cb0ec..c598adffc19944eb8fa28ba9fbb6f94673ab1484 100644 (file)
@@ -197,8 +197,9 @@ Bool_t AliTRDcheckDetector::PostProcess(){
        histo->GetXaxis()->SetTitle("Number of Tracks");
        histo->GetYaxis()->SetTitle("Events");
        // Calculate percentage of events containing tracks
-       Float_t percTracks = histo->Integral(histo->FindBin(1),histo->GetNbinsX())/histo->Integral(histo->FindBin(0),histo->GetNbinsX());
-       printf("Percentage of Events containing TRD Tracks: %f\n", percTracks);
+       Int_t entries = (Int_t)histo->GetEntries();
+  Float_t percTracks = entries > 0 ? (entries - histo->GetBinContent(1))/Float_t(entries) : 0.;
+       printf("Percentage of Events containing TRD Tracks: %6.3f %%\n", 1.E2*percTracks);
        histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNclustersHist));
        histo->GetXaxis()->SetTitle("Number of Clusters");
        histo->GetYaxis()->SetTitle("Entries");
index 176a776d9942371274bde9ded2ab5064b935e0e1..962352a72edb8c5eeb0a2bf419417e85650e969e 100644 (file)
+#if ! defined (__CINT__) || defined (__MAKECINT__)
+#include <TClass.h>
+#include <TFileMerger.h>
+#include <TPad.h>
+#include <TH1.h>
+#include <TGraph.h>
+#include <TObjArray.h>
+#include <TObjString.h>
+#include <TPython.h>
+#include <TString.h>
+#include <TROOT.h>
+#include <TSystem.h>
+
+#include "qaRec/AliTRDrecoTask.h"
+
+// #include <string>
+// #include <iostream>
+// #include <cstdio>
+
+#endif
+
 #include "run.h"
-#define BIT(n)        (1 << (n))
-#define TESTBIT(n,i)  ((Bool_t)(((n) & BIT(i)) != 0))
-
-
-const Int_t fSteerTask = 0xffffffff;
-Char_t *fTaskClass[fknTasks] = {
-  "AliTRDtrackInfoGen"
-  ,"AliTRDtrackingEfficiency"
-  ,"AliTRDtrackingEfficiencyCombined"
-  ,"AliTRDtrackingResolution"
-  ,"AliTRDcalibration"
-  ,"AliTRDpidChecker"
-  ,"AliTRDcheckDetector"
-};
-
-const Int_t nlibs = 3;
-Char_t *libs[] = {"libProofPlayer.so", "libANALYSIS.so", "libTRDqaRec.so"};
-void makeResults(Char_t *dir=".")
+
+Char_t *libs[] = {"libProofPlayer.so", "libANALYSIS.so", "libTRDqaRec.so", "libPyROOT"};
+
+void makeResults(Char_t* dir=0x0, Char_t *tasks = "ALL")
 {
+       // Load Libraries in interactive mode
+//#ifndef __CINT__
+  Int_t nlibs = static_cast<Int_t>(sizeof(libs)/sizeof(Char_t *));
   for(Int_t ilib=0; ilib<nlibs; ilib++){
     if(!gSystem->Load(libs[ilib])) continue;
     printf("Failed to load %s.\n", libs[ilib]);
     return;
   }
+  //gSystem->Setenv("PYTHONPATH", "$ROOTSYS/lib:$PYTHONPATH");
+//#endif
+
+
+  //printf("dir[%s] tasks[%s]\n", dir, tasks);
   gStyle->SetOptStat(0);
+  Bool_t mc      = kTRUE;
+  Bool_t friends = kTRUE;
+
+  // select tasks to process; we should move it to an 
+  // individual function and move the task identifiers 
+  // outside the const space
+  TObjArray *tasksArray = TString(tasks).Tokenize(" ");
+  Int_t fSteerTask = 0;
+  for(Int_t isel = 0; isel < tasksArray->GetEntriesFast(); isel++){
+    TString s = (dynamic_cast<TObjString *>(tasksArray->UncheckedAt(isel)))->String();
+    if(s.CompareTo("ALL") == 0){
+      for(Int_t itask = 1; itask < fknTasks; itask++) SETBIT(fSteerTask, itask);
+      continue;
+    } else if(s.CompareTo("EFF") == 0){
+      SETBIT(fSteerTask, kTrackingEfficiency);
+      continue;
+    } else if(s.CompareTo("EFFC") == 0){
+      SETBIT(fSteerTask, kTrackingCombinedEfficiency);
+      continue;
+    } else if(s.CompareTo("RES") == 0){
+      SETBIT(fSteerTask, kTrackingResolution);
+      continue;
+    } else if(s.CompareTo("CAL" ) == 0){
+      SETBIT(fSteerTask, kCalibration);
+      continue;
+    } else if(s.CompareTo("PID" ) == 0){
+      SETBIT(fSteerTask, kPIDChecker);
+      continue;
+    } else if(s.CompareTo("DET" ) == 0){
+       SETBIT(fSteerTask, kCheckDetector);
+       continue;
+    } else{
+      std::cout << "E-makeResults.C: Task "<< s.Data() << " %s not implemented (yet).\n";
+      continue;
+    }
+  }
 
-  Int_t ndir = 1;
+  // catch the list of files using the ROOT Python Interface
+  TPython *pyshell = new TPython();
+  pyshell->Exec("import commands");
 
   // file merger object
-  TFileMerger *fFM = 0x0;
+  TFileMerger *fFM = new TFileMerger();
   TClass *ctask = 0x0;
   TObject *o = 0x0;
   TObjArray *fContainer = 0x0;
   AliTRDrecoTask *task = 0x0;
 
-  printf("\n\tPROCESSING DATA FOR TASKS:\n");
-  for(Int_t itask = 3; itask <4/*fknTasks*/ ; itask++){
+  printf("\n\tPROCESSING DATA FOR TASKS [%d]:\n", fSteerTask);
+  for(Int_t itask = 1; itask <fknTasks; itask++){
     if(!TESTBIT(fSteerTask, itask)) continue;
 
     ctask = new TClass(fTaskClass[itask]);
     task = (AliTRDrecoTask*)ctask->New();
     task->SetDebugLevel(2);
+    task->SetMCdata(mc);
+    task->SetFriends(friends);
     printf("\t%s [%s]\n", task->GetTitle(), task->GetName());
 
-    fFM = new TFileMerger(kTRUE);
-    fFM->OutputFile(Form("merge/TRD.Task%s.root",  task->GetName()));
-    
-    Int_t idir = 0;
-    while(idir<ndir){
-      fFM->AddFile(Form("./TRD.Task%s.root",  task->GetName()));
-      idir++;
+     // setup filelist
+    TString pathname(dir ? "." : gSystem->ExpandPathName("$PWD"));
+    TString filestring((const Char_t*) pyshell->Eval(Form("commands.getstatusoutput(\"find %s | grep TRD.Task%s.root\")[1]", pathname.Data(), task->GetName())));
+    TObjArray *filenames = filestring.Tokenize("\n");
+    Int_t nFiles = filenames->GetEntriesFast();
+    if(!nFiles){
+      printf("No Files found for Task %s\n", task->GetName());
+      delete task;
+      delete ctask;
+      continue;
     }
-    fFM->Merge();
-    delete fFM;
-    task->Load(Form("merge/TRD.Task%s.root", task->GetName()));
-    task->PostProcess();
+
+    if(nFiles>1){
+      fFM = new(fFM) TFileMerger(kTRUE);
+      fFM->OutputFile(Form("merge/TRD.Task%s.root",  task->GetName()));
+      for(Int_t ifile = 0; ifile < nFiles; ifile++){
+        TString filename = (dynamic_cast<TObjString *>(filenames->UncheckedAt(ifile)))->String();
+        if(filename.Contains("merge")) continue;
+        printf("\tProcessing %s ...\n", filename.Data());
+        fFM->AddFile(filename.Data());
+      }
+      fFM->Merge();
+      fFM->~TFileMerger();
+      task->Load(Form("%s/merge/TRD.Task%s.root",gSystem->ExpandPathName("$PWD"), task->GetName()));
+    } else task->Load((dynamic_cast<TObjString *>(filenames->UncheckedAt(0)))->String().Data());
+
+
     if(!(fContainer = task->Container())) {
       delete task;
       delete ctask;
       continue;
     } 
+    
+    task->PostProcess();
     for(Int_t ipic=0; ipic<task->GetNRefFigures(); ipic++){
+      TCanvas *c = new TCanvas("c", "", 500, 500);
       Int_t ifirst, ilast;
+      TH1 *h = 0x0; TGraph *g = 0x0;
       task->GetRefFigure(ipic, ifirst, ilast);
       if(!(o = fContainer->At(ifirst))) continue;
       
@@ -87,9 +161,12 @@ void makeResults(Char_t *dir=".")
           g->Draw("pl");
         }
       }
-      if(gPad) gPad->SaveAs(Form("%s_fig%d.gif", task->GetName(), ipic));
+      c->SaveAs(Form("%s_fig%d.gif", task->GetName(), ipic));
+      delete c;
     }
     delete task;
     delete ctask;
   }
-}
\ No newline at end of file
+  delete pyshell;
+}
+
index 1128c21e3e773b88025549baa5d0b2bf709d9de2..c8d02a67bb306404d2b8ae401b2a3b2eaf5c05f6 100644 (file)
 #include "TRD/qaRec/AliTRDcheckDetector.h"
 #endif
 
-#define BIT(n)        (1 << (n))
-#define SETBIT(n,i)   ((n) |= BIT(i))
-#define TESTBIT(n,i)  ((Bool_t)(((n) & BIT(i)) != 0))
-#define CLEARBIT(n,i) ((n) &= ~BIT(i))
-
 #include "run.h"
 
 Bool_t MEM = kFALSE;
@@ -190,7 +185,7 @@ void run(const Char_t *files=0x0, Char_t *tasks="ALL", Int_t nmax=-1)
     taskPtr[(Int_t)kTrackingResolution] = task;
     task->SetMCdata(fHasMCdata);
     task->SetPostProcess(kFALSE);
-    task->SetDebugLevel(0);
+    task->SetDebugLevel(2);
     
     // Create containers for input/output
     AliAnalysisDataContainer *coutput4 = mgr->CreateContainer(task->GetName(), TObjArray::Class(), AliAnalysisManager::kOutputContainer, Form("TRD.Task%s.root", task->GetName()));
index e57ba1f4098fa3711ccc7cb7483e11cab67df1a3..1e9821d0eaa008d779d91628e9997ef731a91463 100644 (file)
@@ -1,6 +1,11 @@
 #ifndef TRDRECONSTRUCTIONTRAIN_H
 #define TRDRECONSTRUCTIONTRAIN_H
 
+#define BIT(n)        (1 << (n))
+#define SETBIT(n,i)   ((n) |= BIT(i))
+#define TESTBIT(n,i)  ((Bool_t)(((n) & BIT(i)) != 0))
+#define CLEARBIT(n,i) ((n) &= ~BIT(i))
+
 const Int_t fknTasks = 7;
 enum AliTRDrecoTasks{
   kInfoGen = 0
@@ -12,6 +17,15 @@ enum AliTRDrecoTasks{
   ,kCheckDetector = 6
 };
 
+Char_t *fTaskClass[fknTasks] = {
+  "AliTRDtrackInfoGen"
+  ,"AliTRDtrackingEfficiency"
+  ,"AliTRDtrackingEfficiencyCombined"
+  ,"AliTRDtrackingResolution"
+  ,"AliTRDcalibration"
+  ,"AliTRDpidChecker"
+  ,"AliTRDcheckDetector"
+};
 
 #endif