Updated macros for SDD QA checks (M. Siciliano)
authorprino <prino@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 17 Nov 2010 00:25:36 +0000 (00:25 +0000)
committerprino <prino@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 17 Nov 2010 00:25:36 +0000 (00:25 +0000)
ITS/macrosSDD/ITSQArecoparam.C [new file with mode: 0644]
ITS/macrosSDD/PlotQASDD.C
ITS/macrosSDD/ReadQASDD.C
ITS/macrosSDD/RunQAonSingleChunk.sh [new file with mode: 0755]
ITS/macrosSDD/ShowSDDQA.sh

diff --git a/ITS/macrosSDD/ITSQArecoparam.C b/ITS/macrosSDD/ITSQArecoparam.C
new file mode 100644 (file)
index 0000000..3ae1d39
--- /dev/null
@@ -0,0 +1,242 @@
+#if !defined(__CINT__) || defined(__MAKECINT__)
+#include <TFile.h>
+#include <TAlienFile.h>
+#include <TSystem.h>
+#include <TGrid.h>
+#include <TGridResult.h>
+#include <Riostream.h>
+#include <TObjArray.h>
+#include <TKey.h>
+#include <TStyle.h>
+#include <TTree.h>
+#include <TROOT.h>
+#include <TPluginManager.h>
+#include <TClass.h>
+#include <iostream>
+#include <stdio.h>
+#include "AliRawReader.h"
+#include "AliRawReaderRoot.h"
+#include "AliRawReaderDate.h"
+#include "AliITSQADataMakerRec.h"
+#include "AliITSQASDDDataMakerRec.h"
+#include "AliITSQAChecker.h"
+#include "AliQAChecker.h"
+#include "AliITSQASDDChecker.h"
+#include "AliReconstructor.h"
+#include "AliCDBManager.h"
+#include "AliQAv1.h"
+#include "AliGeomManager.h"
+#include "AliITSInitGeometry.h"
+#include "AliITSgeom.h"
+#include "AliRecoParam.h"
+#include "AliCDBPath.h"
+#include "AliCDBEntry.h"
+#include "AliRecoParam.h"
+#include "AliDetectorRecoParam.h"
+#include "AliITSReconstructor.h"
+#include "AliITSRecPointContainer.h"
+#include "AliLog.h"
+#endif
+void ITSQArecoparam(char *iFile,Int_t idet=2,Int_t FirstEvt=0, Int_t MaxEvts=1000000)
+{
+  TString namefile(iFile);
+  if(namefile.Contains("alien"))
+    {
+      TGrid::Connect("alien://"); 
+      if(!gGrid) {
+       printf("gGrid not found! exit macro\n");
+       return;
+      }
+    }
+  gStyle->SetPalette(1);
+  Int_t ic=0;
+  AliRawReader *rd=NULL; 
+  if(strstr(iFile,".root")!=0){rd = new AliRawReaderRoot(iFile,FirstEvt);}
+  else{rd=new AliRawReaderDate(iFile,FirstEvt);}
+  Int_t runNumber = rd->GetRunNumber();
+  cout << "ITS Quality Assurance Prototype" << endl; 
+  //TStopwatch mytimer;
+  //TString namefile(iFile);
+  // Set OCDB if needed
+  AliCDBManager* man = AliCDBManager::Instance();
+  if (!man->IsDefaultStorageSet()) {
+    printf("Setting a local default storage and run number \n");
+    if(namefile.Contains("alien")){
+      man->SetDefaultStorage("raw://");
+    }
+    else{man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");}
+    man->SetRun(runNumber);
+    AliQAv1::SetQARefStorage("local://$ALICE_ROOT/QARef") ;
+  }
+
+  AliITSQADataMakerRec *itsQAdm = new AliITSQADataMakerRec(kTRUE,idet,0); //online kTRUE
+  itsQAdm->SetWriteExpert() ;
+  itsQAdm->SetRunNumber(runNumber);  
+  //________________________For the RecPoints____________________________________
+  /************************************************/
+  TPluginManager* pluginManager=NULL;
+  TPluginHandler* pluginHandler=NULL; 
+  AliReconstructor* reconstructor = NULL;
+  AliITSRecPointContainer* rpcont=NULL;
+  AliGeomManager::LoadGeometry("geometry.root");
+  AliGeomManager::ApplyAlignObjsFromCDB("ITS");
+  //   ITS initializations
+  
+  AliITSInitGeometry initgeom;
+  AliITSgeom *geom = initgeom.CreateAliITSgeom();
+  printf("Geometry name: %s\n",(initgeom.GetGeometryName()).Data());
+  
+  printf("Loading reconstruction parameter objects for detector ITS\n");
+  AliRecoParam fRecoParam; 
+  AliCDBPath path("ITS","Calib","RecoParam");
+  AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
+  Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
+  if(!entry){printf("Couldn't find RecoParam entry in OCDB for detector ITS");entry=NULL;}
+  else {
+    TObject *recoParamObj = entry->GetObject();
+    if (dynamic_cast<TObjArray*>(recoParamObj)) {
+      printf("RecoParam TObjArray\n");
+      fRecoParam.AddDetRecoParamArray(0,dynamic_cast<TObjArray*>(recoParamObj));
+    }
+    else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
+      printf("RecoParam AliDetectorRecoParam\n");
+      printf("Single set of reconstruction parameters found for detector ITS");
+      (dynamic_cast<AliDetectorRecoParam*>(recoParamObj))->SetAsDefault();
+      fRecoParam.AddDetRecoParam(0,(dynamic_cast<AliDetectorRecoParam*>(recoParamObj)));
+    }
+    else {printf("Error: No valid RecoParam object found in the OCDB for detector ITS");}
+    entry->SetOwner(0);
+  }
+  if(!cacheStatus)entry->SetObject(NULL);
+  if(!cacheStatus){ delete entry;}
+  
+  // load the reconstructor object
+ pluginManager = gROOT->GetPluginManager();
+  TString detName = "ITS";
+  TString recName = "Ali" + detName + "Reconstructor";  
+  
+pluginHandler = pluginManager->FindHandler("AliReconstructor", "ITS");
+  // if not, add a plugin for it
+  if (!pluginHandler) {
+    printf("defining plugin for ITS\n");
+    TString libs = gSystem->GetLibraries();
+    if (libs.Contains("lib" + detName + "base.so") ||
+       (gSystem->Load("lib" + detName + "base.so") >= 0)) {pluginManager->AddHandler("AliReconstructor", detName,recName, detName + "rec", recName + "()");}
+    else {pluginManager->AddHandler("AliReconstructor", detName,recName, detName, recName + "()");}
+    pluginHandler = pluginManager->FindHandler("AliReconstructor", detName);
+  }
+  if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {reconstructor = (AliReconstructor*) pluginHandler->ExecPlugin(0);}
+  if (fRecoParam.GetDetRecoParamArray(0) && !AliReconstructor::GetRecoParam(0)) {
+    const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(0);
+    reconstructor->Init();
+    reconstructor->SetRecoParam(par);
+  }
+  
+  /*AliITSRecPointContainer**/ rpcont=AliITSRecPointContainer::Instance();
+  rpcont->PrepareToRead();
+
+  Int_t cycleLength = 5;  
+  //cout << "Processing Run " << runNumber << endl;
+  cout << "Init: " << AliQAv1::kRAWS << endl;
+  
+  TObjArray **objArray= itsQAdm->Init(AliQAv1::kRAWS, cycleLength);
+  cout<<"raw tobjarray :"<<objArray<<"\n"<<endl;
+  for(Int_t spec = 0 ; spec < 5 ; spec++){
+    if(spec==1){
+      itsQAdm->SetEventSpecie(AliRecoParam::kLowMult);
+      AliQAv1::Instance()->SetEventSpecie(AliRecoParam::kLowMult);
+      itsQAdm->InitRaws();
+    }
+    else{continue;}
+  }
+  itsQAdm->StartOfCycle(AliQAv1::kRAWS,runNumber,kFALSE);
+  /*********************************************************************/
+
+    cout << "Init: " << AliQAv1::kRECPOINTS << endl;
+    TObjArray **objArray1=  itsQAdm->Init(AliQAv1::kRECPOINTS, cycleLength);
+    cout<<"recpoint tobjarray :"<<objArray1<<"\n"<<endl;
+    for(Int_t spec = 0 ; spec < 5 ; spec++){
+      if(spec==1){
+       itsQAdm->SetEventSpecie(AliRecoParam::kLowMult);
+       AliQAv1::Instance()->SetEventSpecie(AliRecoParam::kLowMult);
+       itsQAdm->InitRecPoints();
+      }
+      else{continue;}
+    }
+    itsQAdm->StartOfCycle(AliQAv1::kRECPOINTS,runNumber,kTRUE);
+
+  /*********************************************************************/
+  Int_t iev = 0;
+  while(rd->NextEvent() && iev < MaxEvts ) {
+    cout<<">>>>>>>   Processing event number: "<<++iev<<endl;
+    /*******************************************************/
+    if(itsQAdm->IsCycleDone()) {
+      cout << "end of cycle" << endl;
+      AliQAChecker::Instance()->SetRunNumber(AliCDBManager::Instance()->GetRun());     
+      itsQAdm->EndOfCycle(AliQAv1::kRAWS);
+      itsQAdm->StartOfCycle(AliQAv1::kRAWS,ic++,kFALSE);
+    }
+    /******************************************************/
+    /*************************************************/
+
+      if(itsQAdm->IsCycleDone()) {
+       cout << "end of cycle" << endl;
+       AliQAChecker::Instance()->SetRunNumber(AliCDBManager::Instance()->GetRun());
+       itsQAdm->EndOfCycle(AliQAv1::kRECPOINTS);
+       itsQAdm->StartOfCycle(AliQAv1::kRECPOINTS,ic,kTRUE);
+      } 
+    /*************************************************/
+    cout<<"Beginning Exec"<<endl;
+    cout<<"AliQAv1::kRAWS   "<<AliQAv1::kRAWS<<endl;
+    itsQAdm->SetEventSpecie(AliRecoParam::kLowMult);
+    AliQAv1::Instance()->SetEventSpecie(AliRecoParam::kLowMult);
+    itsQAdm->Exec(AliQAv1::kRAWS,rd);
+    /***************************************************/
+    //  if(kRecPoints){
+      cout<<"AliQAv1::kRECPOINTS   "<<AliQAv1::kRECPOINTS<<endl;
+      cout << "DigitsToRecPoints" << endl;
+      TTree* fTreeR = new TTree("TreeR", "Reconstructed Points Container"); //make a tree
+      Char_t option[5];
+
+      if(idet==0)sprintf(option,"ALL");
+      else if(idet==1)sprintf(option,"SPD");
+      else if(idet==2)sprintf(option,"SDD");
+      else if(idet==3)sprintf(option,"SSD");
+      printf("\t\t===========>option is %s\n",option);
+
+      rpcont->PrepareToRead();
+      reconstructor->Reconstruct(rd,fTreeR);
+
+      itsQAdm->SetEventSpecie(AliRecoParam::kLowMult);
+      AliQAv1::Instance()->SetEventSpecie(AliRecoParam::kLowMult)  ; 
+      itsQAdm->Exec(AliQAv1::kRECPOINTS,fTreeR);
+      cout<<"Finishing Exec"<<endl;
+    
+      ((AliITSReconstructor*)reconstructor)->ResetRecPoints();
+      delete fTreeR; 
+      fTreeR=NULL; 
+      /*****************************************************/
+    }
+
+  cout << "end RAWS cycle: " << AliQAv1::kRAWS << endl;
+  cout << "refStorage: " << AliQAv1::GetQARefStorage() << endl;
+  cout << "end of cycle 2" << endl;
+  AliQAChecker::Instance()->SetRunNumber(AliCDBManager::Instance()->GetRun());
+  itsQAdm->EndOfCycle(AliQAv1::kRAWS);   
+  cout << "Raws QA completed for " << iev << " events" << endl;
+  /*******************************************************************/
+
+    AliQAChecker::Instance()->SetRunNumber(AliCDBManager::Instance()->GetRun());
+    itsQAdm->EndOfCycle(AliQAv1::kRECPOINTS);
+    cout << "RecPoints QA completed for " << iev << " events" << endl;
+
+  /*******************************************************************/
+  itsQAdm->Finish(); // write to the output File
+
+  cout << "Call AliITSQASDDDataMakerRec destructor" << endl;
+  delete itsQAdm;
+  itsQAdm=NULL;
+
+}
+
index e4a95ea..0403d36 100644 (file)
@@ -94,8 +94,12 @@ void PlotQASDD(Char_t fileName[100]="File.QA.111333.2010.LHC09b.pass2.root",Char
   // -------------This part is to read the number of chunks that were merged
   Float_t fChnknmbr=0.;
   FILE * pChunkNumber = fopen ("ChunkNumber.txt","r");
-  fscanf(pChunkNumber, "%f", &fChnknmbr);
+  if(pChunkNumber){
+  Int_t rv=fscanf(pChunkNumber, "%f", &fChnknmbr);
   fclose (pChunkNumber);
+  }
+  else fChnknmbr=1.;
+
   gStyle->SetPalette(1);
   float fCNinv=1./fChnknmbr;
   //   printf("\n====================>%f\n\n", fCNinv);
@@ -607,6 +611,7 @@ void PlotQASDD(Char_t fileName[100]="File.QA.111333.2010.LHC09b.pass2.root",Char
            printf("...Found\n");
            historaw2->GetYaxis()->SetRangeUser(0,fmaxmargin);
            historaw2->SetTitle("Charge");
+           historaw2->SetFillColor(0);
            if (irrpp==4) {historaw2->SetStats(0);historaw2->SetLineColor(2);historaw2->DrawCopy();}
            if (irrpp!=4) {historaw2->SetStats(0);historaw2->SetLineColor(4);historaw2->DrawCopy("same");}
            legend->AddEntry(historaw2,layer,"l");
@@ -656,6 +661,7 @@ void PlotQASDD(Char_t fileName[100]="File.QA.111333.2010.LHC09b.pass2.root",Char
            printf("...Found\n");
            historaw2->GetYaxis()->SetRangeUser(0,fmaxmargin);
            historaw2->SetTitle("Drift Time");
+           historaw2->SetFillColor(0);
            if (irrpp==6) {historaw2->SetStats(0); historaw2->SetLineColor(2);historaw2->DrawCopy();}
            if (irrpp!=6) {historaw2->SetStats(0); historaw2->SetLineColor(4);historaw2->DrawCopy("same");}
            legend->AddEntry(historaw2,layer,"l");
index ec487ab..1795300 100644 (file)
@@ -10,7 +10,7 @@
 #include <TObjArray.h>
 #include <TClass.h>
 #endif
-void ReadQASDD(Int_t runNb = 101498,Int_t year=2009,Char_t period[10]="LHC09c",Char_t pass[8]="pass1",Char_t filetosearch[50]="Merged.QA.Data.root",Char_t initfileout[50]="File.QA")
+void ReadQASDD(Int_t runNb = 101498,Int_t year=2009,Char_t period[10]="LHC09c",Char_t pass[8]="pass1",Int_t maxfiles=300,Char_t filetosearch[50]="Merged.QA.Data.root",Char_t initfileout[50]="File.QA")
 {
 
   //****************** Connection to alien *****************************************
@@ -44,8 +44,8 @@ void ReadQASDD(Int_t runNb = 101498,Int_t year=2009,Char_t period[10]="LHC09c",C
 
   Int_t mergedFiles = 0;
   Int_t nFiles = gr->GetEntries();
-  if(nFiles>600) nFiles=600; 
-  for (Int_t i = 0; i <nFiles ; i++) { 
+  if(nFiles>maxfiles) nFiles=maxfiles; 
+  for (Int_t i = 3; i <nFiles ; i++) { 
     printf("File %i/%i\n",i+1,nFiles); 
     sprintf(directory,"%s",gr->GetKey(i,"turl"));
     printf("%s\n\n", directory);
diff --git a/ITS/macrosSDD/RunQAonSingleChunk.sh b/ITS/macrosSDD/RunQAonSingleChunk.sh
new file mode 100755 (executable)
index 0000000..47cfbf9
--- /dev/null
@@ -0,0 +1,96 @@
+#!/bin/bash
+RUN='123456'
+PERIOD='LHC10a'
+PASS='pass1'
+YEAR='2010'
+ALICE_ITS='$ALICE_ROOT/ITS'
+TMPPLACE='/tmp'
+TMPFOLDER='1'
+EXECFOLDER='$HOME/macroQAshifter'
+MAXFILES='300'
+FILENAME='10000137137031.300.root'
+FULLNAME='$PWD/$FILENAME'
+echo "Run Number   :[${RUN}]"
+read
+if [ "$REPLY" != "" ]; then
+RUN=$REPLY
+echo "Run   $RUN"
+fi
+echo "Period        :[${PERIOD}]"
+read
+if [ "$REPLY" != "" ]; then 
+PERIOD=$REPLY
+echo "Period  $PERIOD"
+fi
+echo "Pass           : [${PASS}]"
+read
+if [ "$REPLY" != "" ]; then
+PASS=$REPLY
+echo "Pass       $PASS "
+fi
+echo "Year      :[${YEAR}]"
+read
+if [ "$REPLY" != "" ]; then
+YEAR=$REPLY
+echo "Year    $YEAR"
+fi
+echo "FileName (if it is a LOCAL file, please insert the full path)      :  [${FILENAME}]"
+read
+if [ "$REPLY" != "" ]; then
+FILENAME=$REPLY
+fi
+echo "FileName    ${FILENAME}"
+echo "folder with macros     :[${EXECFOLDER}]"
+read
+if [ "$REPLY" != "" ]; then
+EXECFOLDER=$REPLY
+echo "Folder:    $EXECFOLDER"
+fi
+echo "local file or alienfile (1=local 2=alien)   :[${TMPFOLDER}]"
+read
+if [ "$REPLY" != "" ]; then
+TMPFOLDER=$REPLY
+fi
+if [ "$TMPFOLDER" == "1" ]; then
+FULLNAME=$FILENAME
+else
+FULLNAME=alien:///alice/data/${YEAR}/${PERIOD}/000${RUN}/raw/${FILENAME}
+fi
+echo "FullName   ${FULLNAME}"
+if [ ls -l "run$RUN" >/dev/null 2>&1 ]; then
+echo "directory run$RUN exists "
+else
+mkdir "run$RUN"
+fi
+cd "run$RUN"
+if [ ls -l $PASS > /dev/null 2>&1 ]; then
+echo "directory $PASS exixsts"
+else
+mkdir $PASS
+cd $PASS
+fi
+time aliroot -l <<EOI|tee execQA$RUN.log
+EOF
+.L $EXECFOLDER/ITSQArecoparam.C++
+ ITSQArecoparam("${FULLNAME}",2,30); 
+.q
+EOI
+time aliroot -l <<EOI|tee plot$RUN.log
+.x $EXECFOLDER/PlotQASDD.C("ITS.QA.${RUN}.root");
+.q
+EOI
+if [ls -l "images" >/dev/null 2>&1 ]; then
+echo "directory images exists"
+else
+mkdir images
+fi
+mv *.ps images/.
+cd images
+for i in  *.ps;
+do
+gv $i & 
+sleep 2
+done
+echo "Plots Done!!"
+rm -rf $TMPPLACE/*.root
+cd ../../../
index ec54fd8..6673be2 100755 (executable)
@@ -7,45 +7,62 @@ ALICE_ITS='$ALICE_ROOT/ITS'
 TMPPLACE='/tmp'
 TMPFOLDER='1'
 EXECFOLDER='$HOME/macroQAshifter'
+MAXFILES='300'
 echo "Run Number   :[${RUN}]"
 read
 if [ "$REPLY" != "" ]; then
-export RUN=$REPLY
+RUN=$REPLY
 echo "Run   $RUN"
 fi
 echo "Period        :[${PERIOD}]"
 read
 if [ "$REPLY" != "" ]; then 
-export PERIOD=$REPLY
+PERIOD=$REPLY
 echo "Period  $PERIOD"
 fi
 echo "Pass           : [${PASS}]"
 read
 if [ "$REPLY" != "" ]; then
-export PASS=$REPLY
+PASS=$REPLY
 echo "Pass       $PASS "
 fi
 echo "Year      :[${YEAR}]"
 read
 if [ "$REPLY" != "" ]; then
-export YEAR=$REPLY
+YEAR=$REPLY
 echo "Year    $YEAR"
 fi
 echo "folder with macros     :[${EXECFOLDER}]"
 read
 if [ "$REPLY" != "" ]; then
-export EXECFOLDER=$REPLY
+EXECFOLDER=$REPLY
 echo "Folder:    $EXECFOLDER"
 fi
 echo "local or lxplus (1=local 2=lxplus)   :[${TMPFOLDER}]"
 read
 if [ "$REPLY" != "" ]; then
-export TMPFOLDER=$REPLY
+TMPFOLDER=$REPLY
 fi
 if [ "$TMPFOLDER" == "1" ]; then
-export TMPPLACE='/tmp'
+TMPPLACE='/tmp'
 else
-export TMPPLACE='/tmp/$USERNAME'
+TMPPLACE='/tmp/$USERNAME'
+fi
+GOOD=130
+echo "Max number of files (Insert a number >0)   :[${MAXFILES}]"
+read
+#case $REPLY in
+#      *[a-zA-Z]*|*[!0-9]*|*[-]*)
+#                                  echo "Wrong: it is not a number > 0";;   
+#                        *[0-9]*)
+#                                 MAXFILES=$REPLY
+#                                 echo "Max number of files:    $MAXFILES" 
+#                                 export GOOD=0
+#                      ;;
+#esac  
+if [ "$REPLY" != "" ]; then
+MAXFILES=$REPLY
+echo "Max number of files:    $MAXFILES"
 fi
 if [ ls -l "run$RUN" >/dev/null 2>&1 ]; then
 echo "directory run$RUN exists "
@@ -59,12 +76,12 @@ else
 mkdir $PASS
 cd $PASS
 fi
-time aliroot -l <<EOI|tee merge.log
+time aliroot -l <<EOI|tee merge$RUN.log
 EOF
-.x $EXECFOLDER/ReadQASDD.C($RUN,$YEAR,"${PERIOD}","${PASS}" ); 
+.x $EXECFOLDER/ReadQASDD.C($RUN,$YEAR,"${PERIOD}","${PASS}",$MAXFILES); 
 .q
 EOI
-time aliroot -l <<EOI|tee plot.log
+time aliroot -l <<EOI|tee plot$RUN.log
 .x $EXECFOLDER/PlotQASDD.C("File.QA.${YEAR}.${PERIOD}.${PASS}.Run.${RUN}.root");
 .q
 EOI
@@ -74,7 +91,7 @@ echo "directory images exists"
 else
 mkdir images
 fi
-mv *.ps *.eps images/.
+mv *.ps images/.
 cd images
 for i in  *.ps;
 do
@@ -83,4 +100,4 @@ sleep 2
 done
 echo "Plots Done!!"
 rm -rf $TMPPLACE/*.root
-cd ../../../
\ No newline at end of file
+cd ../../../