]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Allow to enter a triggerList for muon tracker QA. Possibility to run on private produ...
authormartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 9 Sep 2011 15:30:21 +0000 (15:30 +0000)
committermartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 9 Sep 2011 15:30:21 +0000 (15:30 +0000)
PWG3/muon/PlotMuonQApp.C
PWG3/muon/mergeGridFiles.C
PWG3/muon/runQA.sh
PWG3/muon/trigEffQA.C

index 127a7bc3e4d84a849b4f0cfd62d8b69d7b2f4405..d9eb80d088cc876d4a784f854f62596ccc879189 100644 (file)
@@ -122,7 +122,7 @@ void PlotMuonQApp(const char* baseDir, const char* runList = 0x0, const char * t
     // only the ones in the runList
     ifstream inFile(runList);
     if (!inFile.is_open()) {
-      Error("PlotMUONQApp","unable to open file %s", runList);
+      Error("PlotMuonQApp","unable to open file %s", runList);
       return;
     }
     
@@ -131,7 +131,7 @@ void PlotMuonQApp(const char* baseDir, const char* runList = 0x0, const char * t
       currRun.ReadLine(inFile, kTRUE);
       if (currRun.IsNull()) continue;
       if (!currRun.IsDigit()) {
-       Error("PlotMUONQApp","invalid run number: %s", currRun.Data());
+       Error("PlotMuonQApp","invalid run number: %s", currRun.Data());
        return;
       }
       runs.AddLast(new TObjString(Form("%09d", currRun.Atoi())));
@@ -158,23 +158,25 @@ void PlotMuonQApp(const char* baseDir, const char* runList = 0x0, const char * t
   TString selectAllTriggers = "", selectAllTriggersAC = "", selectAllTriggersE = "";
   triggers.SetOwner();
 
-  if (triggerList) {
+  TString sTrigList = triggerList;
+  if ( ! sTrigList.IsNull() ) {
+    
     // only the ones in the triggerList
     ifstream inFile(triggerList);
     if (!inFile.is_open()) {
-      Error("PlotMUONQApp","unable to open file %s", triggerList);
+      Error("PlotMuonQApp","unable to open file %s", triggerList);
       return;
     }
     
-    TString currRun;
+    TString currTrig;
     while (!inFile.eof()) {
-      currRun.ReadLine(inFile, kTRUE);
-      if (currRun.IsNull()) continue;
-      if (!currRun.IsAlnum()) {
-       Error("PlotMUONQApp","invalid trigger name: %s", currRun.Data());
-       return;
+      currTrig.ReadLine(inFile, kTRUE);
+      if (currTrig.IsNull()) continue;
+      if (!currTrig.IsAlnum()) {
+        Error("PlotMuonQApp","invalid trigger name: %s", currTrig.Data());
+        return;
       }
-      triggers.AddLast(new TObjString(Form("%s", currRun.Data())));
+      triggers.AddLast(new TObjString(currTrig));
     }
     inFile.close();
   } else {
@@ -257,7 +259,7 @@ void PlotMuonQApp(const char* baseDir, const char* runList = 0x0, const char * t
   TH1* hPosMatchedB[10], *hNegMatchedB[10], *hAllMatchedB[10];
   TH1 *hACWithPS[10]={}; 
   TH1 *hACNoPS[10]={};
-  TH1 *hEWithPS[10]={};
+  //TH1 *hEWithPS[10]={};
   TH1 *hENoPS[10]={};
   
   if(triggers.GetEntriesFast()>=10){
@@ -907,7 +909,7 @@ void PlotMuonQApp(const char* baseDir, const char* runList = 0x0, const char * t
       command = Form("find %s/ %s/%s", alienBaseDir.Data(), run.Data(), QAFileName);
       res = gGrid->Command(command);
       if (!res) {
-       Error("PlotMUONQApp","no result for the command: %s",command.Data());
+       Error("PlotMuonQApp","no result for the command: %s",command.Data());
        return;
       }
     }
@@ -959,14 +961,14 @@ void PlotMuonQApp(const char* baseDir, const char* runList = 0x0, const char * t
       if(iLoop>iLoopMax) break;
       
       if (!objs || !objs->GetString().Length()) {
-       Error("PlotMUONQApp","turl/obj not found for the run %s... SKIPPING", run.Data());
+       Error("PlotMuonQApp","turl/obj not found for the run %s... SKIPPING", run.Data());
        continue;
       }
       
       // open the outfile for this run
       TFile *runFile = TFile::Open(objs->GetString());
       if (!runFile || ! runFile->IsOpen()) {
-       Error("PlotMUONQApp","failed to open file: %s", objs->GetName());
+       Error("PlotMuonQApp","failed to open file: %s", objs->GetName());
        continue;//return;
       }
       runFile->Cd("MUON_QA");
@@ -977,7 +979,7 @@ void PlotMuonQApp(const char* baseDir, const char* runList = 0x0, const char * t
       TObjArray* expert = static_cast<TObjArray*>(runFile->FindObjectAny("expert"));
       
       if (!general1 || !general2 || !expert){
-       Error("PlotMUONQApp","All objects not here !!! ===> Skipping...for %s",objs->GetName());                
+       Error("PlotMuonQApp","All objects not here !!! ===> Skipping...for %s",objs->GetName());                
        continue;
       }
       
@@ -991,7 +993,7 @@ void PlotMuonQApp(const char* baseDir, const char* runList = 0x0, const char * t
       
       // skip empty runs... not anymore ! cs !
       if (!hNClustersPerCh) {
-       Warning("PlotMUONQApp","File: %s has empty histograms !", objs->GetName());
+       Warning("PlotMuonQApp","File: %s has empty histograms !", objs->GetName());
        hNClustersPerTrackVsRun_Mean->SetBinContent(ibin, 0.);
        hNClustersPerTrackVsRun_Mean->SetBinError(ibin, 1.);
        hNClustersPerTrackVsRun_Sigma->SetBinContent(ibin, 0.);
index 942b4cf97d762e8b6c6f9597bdd69762afa747ea..251261f6d48ac03c2dd1a64f2550b3336607e2f5 100644 (file)
@@ -190,19 +190,19 @@ void completeProd(TString runListName="runList.txt", TString prodDir = "", TStri
 
   ofstream outFile(outFilename.Data());
 
-  if ( outTaskFilename.Contains("QAresults.root") ) {
-    const Int_t kNlibs = 5; // 1
-    //TString loadLibs[kNlibs] = {"libPWG3base.so"};
-    //TString loadLibs[kNlibs] = {"libANALYSIS.so", "libANALYSISalice.so", "libTENDER.so", "libPWG1.so", "libPWG3base.so"};
-    TString loadLibs[kNlibs] = {"libANALYSIS.so", "libOADB.so", "libANALYSISalice.so", "libCORRFW.so", "libPWG3base.so"};
-    for ( Int_t ilib=0; ilib<kNlibs; ilib++ ) {
-      Int_t exitVal = gSystem->Load(loadLibs[ilib].Data());
-      if ( exitVal < 0 ) {
-        printf("Please run with aliroot if you're merging QA objects!\n");
-        return;
-      }
+  // if ( outTaskFilename.Contains("QAresults.root") ) {
+  const Int_t kNlibs = 5; // 1
+  //TString loadLibs[kNlibs] = {"libPWG3base.so"};
+  //TString loadLibs[kNlibs] = {"libANALYSIS.so", "libANALYSISalice.so", "libTENDER.so", "libPWG1.so", "libPWG3base.so"};
+  TString loadLibs[kNlibs] = {"libANALYSIS.so", "libOADB.so", "libANALYSISalice.so", "libCORRFW.so", "libPWG3base.so"};
+  for ( Int_t ilib=0; ilib<kNlibs; ilib++ ) {
+    Int_t exitVal = gSystem->Load(loadLibs[ilib].Data());
+    if ( exitVal < 0 ) {
+      printf("Please run with aliroot if you're merging QA objects!\n");
+      return;
     }
   }
+  //}
 
   if ( ! gGrid )
     TGrid::Connect("alien://");
@@ -217,12 +217,12 @@ void completeProd(TString runListName="runList.txt", TString prodDir = "", TStri
 
     TString localOut = outTaskFilename;
     localOut.ReplaceAll(".root", Form("_%s.root", currRunString.Data()));
-    printf("Searching for %s\n", localOut.Data()); // REMEMBER TO CUT
     if ( ! gSystem->AccessPathName(localOut.Data()) ) {
       if ( overwriteExisting )
         printf("Overwriting existing file %s\n", localOut.Data());
       else {
         printf("Warning: merged file %s already exist: do not overwrite\n", localOut.Data());
+        outFile << gSystem->pwd() << "/" << localOut.Data() << endl;
         continue;
       }
     }
@@ -232,7 +232,7 @@ void completeProd(TString runListName="runList.txt", TString prodDir = "", TStri
     TString mergeFilename = "";
 
     for ( Int_t ipattern=0; ipattern<2; ipattern++ ) {
-      TString command = Form("find %s/*%s %s/%s%s", baseDir.Data(), currRunString.Data(), prodDir.Data(), filePattern[ipattern].Data(), outTaskFilename.Data());
+      TString command = ( prodDir.Contains("private") ) ? Form("find %s/ *%s/%s%s", baseDir.Data(), currRunString.Data(), filePattern[ipattern].Data(), outTaskFilename.Data()) : Form("find %s/*%s %s/%s%s", baseDir.Data(), currRunString.Data(), prodDir.Data(), filePattern[ipattern].Data(), outTaskFilename.Data());
 
       printf("%s\n", command.Data());
 
index 443cbd64fba4b72df3264608a247fe7955f4f6f3..b84dcb107d9cacc6d3760d332cd1cbbe008d36ae 100755 (executable)
@@ -15,7 +15,10 @@ execMergeAll=1
 execTerminate=1
 execTrigQA=1
 execTrackQA=1
-while getopts "matek" option
+isPrivateProd=0
+optList="mateko:pi:"
+inputTriggerList=""
+while getopts $optList option
 do
   case $option in
     m ) execMerge=0;;
@@ -23,6 +26,9 @@ do
     t ) execTerminate=0;;
     e ) execTrigQA=0;;
     k ) execTrackQA=0;;
+    o ) outTaskName=$OPTARG;;
+    p ) isPrivateProd=1;;
+    i ) inputTriggerList=$OPTARG;;
     * ) echo "Unimplemented option chosen."
     EXIT=1
     ;;
@@ -33,12 +39,15 @@ shift $(($OPTIND - 1))
 
 # needs 3 arguments
 if [[ $# -ne 3 || "$EXIT" -eq 1 ]]; then
-    echo "Usage: `basename $0` (-matek) <runList.txt> <QAx> <alien:///alice/data/20XX>/LHCXXy>"
+    echo "Usage: `basename $0` (-$optList) <runList.txt> <QAx> <alien:///alice/data/20XX/LHCXXy>"
     echo "       -m skip merging (default: run)"
     echo "       -a skip final merging (default: run)"
     echo "       -t skip terminate (default: run)"
     echo "       -e skip run trigger efficiency QA (defult: run)"
     echo "       -k skip run muon QA (defult: run)"
+    echo "       -o task output name (default: QAresults.root)"
+    echo "       -p is private production. Use directory structure of the plugin"
+    echo "       -i input trigger list (default: no list)"
     exit 4
 fi
 
@@ -134,14 +143,30 @@ function runTrackQA() {
     lhcPeriod=`echo ${alienBaseDir%"/"} | awk -F "/" ' { print $NF } '`
     aliroot -b <<EOF &> logTrackQA.txt
 ${loadLibs}
-.x $qaMacroDir/PlotMuonQA.C+("${terminateDir}",0x0,$physSel,"$lhcPeriod","${outTaskName}");
+.x $qaMacroDir/PlotMuonQApp.C+("${terminateDir}",0x0,"${inputTriggerList}",${physSel},"${lhcPeriod}","${outTaskName}");
 .q
 EOF
     cd $baseOutDir
 }
 
+# Use absolute path for file inputTriggerList
+if [ "${inputTriggerList}" != "" ]; then
+  inputTriggerDir=`dirname ${inputTriggerList}`
+  if [ "${inputTriggerDir}"="." ]; then
+    inputTriggerList="`pwd`/${inputTriggerList}"
+  fi
+fi
+
+qaProdName="$2"
+if [ $isPrivateProd -eq 1 ]; then
+    tmpName=${qaProdName//"private"/""}
+    if [ "$tmpName" == "$qaProdName" ]; then
+       qaProdName="${qaProdName}_private"
+    fi
+fi
+
 if [ $execMerge -eq 1 ]; then
-    mergePerRun $1 $2 $3
+    mergePerRun $1 $qaProdName $3
 fi
 mergeOut=`grep -A 1 "Output written" ${mergeLog} | grep -v written`
 mergeOutAll=${mergeOut//".txt"/"_merged.txt"}
@@ -163,7 +188,8 @@ fi
 if [ $execTrigQA -eq 1 ]; then
     minRun=`echo ${mergeOut} | cut -d "_" -f 2`
     maxRun=`echo ${mergeOut} | cut -d "_" -f 3 | cut -d "." -f 1`
-    outName="trigEffQA_${minRun}_${maxRun}_$2.root"
+    trigOutSuffix=`echo ${qaProdName} | awk -F "/" '{ print $NF }'`
+    outName="trigEffQA_${minRun}_${maxRun}_${trigOutSuffix}.root"
     runTrigQA "${mergeOut}" "${outName}"
 fi
 
index fa0d52ab883427d0ca14eaed4a5c647e3a321af2..329654f18dfc7cb1eaf9a4950556750bd7e411cb 100644 (file)
@@ -26,6 +26,7 @@
 #endif
 
 const Int_t kNch = 4;
+const Double_t kZero = 1.e-7; // Avoid problems when comparing to 0.
 void SetMyStyle();
 Int_t GetRunNumber(TString);
 //Double_t GetBinomial(Double_t*, Double_t* eff2 = 0x0, Double_t* effBoth = 0x0);
@@ -272,7 +273,7 @@ Int_t GetRunNumber(TString filePath)
 //   }
 //   if ( eff2 ) {
 //     for ( Int_t ich=0; ich<4; ich++ ) {
-//       auxEff[ich] = ( eff1[ich] > 0. ) ? effBoth[ich]/eff1[ich] : 0.;
+//       auxEff[ich] = ( eff1[ich] > kZero ) ? effBoth[ich]/eff1[ich] : 0.;
 //     }
 //     auxBinomial = GetBinomial(auxEff);
 //     eff44 *= auxBinomial;
@@ -292,7 +293,7 @@ Int_t GetRunNumber(TString filePath)
 //           auxEff[jch] = ( eff1[jch] < 1. ) ? ( eff2[jch] - effBoth[jch] ) / ( 1. - eff1[jch]) : 0.;
 //         }
 //         else {
-//           auxEff[jch] = ( eff1[ich] > 0. ) ? effBoth[ich]/eff1[ich] : 0.;
+//           auxEff[jch] = ( eff1[ich] > kZero ) ? effBoth[ich]/eff1[ich] : 0.;
 //         }
 //         auxBinomial = GetBinomial(auxEff);
 //         eff34 *= auxBinomial;
@@ -358,7 +359,7 @@ Double_t* GetProdErr(Double_t* effErr, Int_t exclude, Int_t nFactors)
   for ( Int_t iprod=0; iprod<nFactors; iprod++ ) {
     if ( iprod == exclude ) continue;
     prod *= effErr[iprod];
-    relErr = ( effErr[iprod] > 0. ) ? effErr[iprod+nFactors]/effErr[iprod] : 0.;
+    relErr = ( effErr[iprod] > kZero ) ? effErr[iprod+nFactors]/effErr[iprod] : 0.;
     relProdErrSquare += relErr*relErr;
     //printf("%f +- %f  ", effErr[iprod], effErr[iprod+nFactors]); // REMEMBER TO CUT
   }
@@ -386,9 +387,9 @@ Double_t* GetConditionalEffErr(Double_t* effErr1, Double_t* effErr2, Double_t* e
       }
     }
     else {
-      effErr[ich] = ( effErr1[ich] > 0. ) ? effErrBoth[ich]/effErr1[ich] : 0.;
-      Double_t relErr1 = ( effErr1[ich] > 0. ) ? effErr1[ich+kNch]/effErr1[ich] : 0.;
-      Double_t relErrBoth = ( effErrBoth[ich] > 0. ) ? effErrBoth[ich+kNch]/effErrBoth[ich] : 0.;
+      effErr[ich] = ( effErr1[ich] > kZero ) ? effErrBoth[ich]/effErr1[ich] : 0.;
+      Double_t relErr1 = ( effErr1[ich] > kZero ) ? effErr1[ich+kNch]/effErr1[ich] : 0.;
+      Double_t relErrBoth = ( effErrBoth[ich] > kZero ) ? effErrBoth[ich+kNch]/effErrBoth[ich] : 0.;
       effErr[ich+kNch] = effErr[ich] * TMath::Sqrt(relErr1*relErr1 + relErrBoth*relErrBoth);
     }
     //printf("%f  %f  %f -> %f\n", effErr1[ich], effErr2[ich], effErrBoth[ich], effErr[ich]); // REMEMBER TO CUT