Macros for raw-data reco and QA at P2
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 3 Mar 2008 17:11:40 +0000 (17:11 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 3 Mar 2008 17:11:40 +0000 (17:11 +0000)
test/cosmic/rawqa.C [new file with mode: 0644]
test/cosmic/rec.C [new file with mode: 0644]

diff --git a/test/cosmic/rawqa.C b/test/cosmic/rawqa.C
new file mode 100644 (file)
index 0000000..3cd17be
--- /dev/null
@@ -0,0 +1,138 @@
+#include <iostream>
+#include <fstream>
+
+#include <TAlienCollection.h>
+#include <TFile.h>
+#include <TGrid.h>
+#include <TGridResult.h>
+#include <TROOT.h>
+#include <TString.h>
+#include <TSystem.h>
+
+#include "AliCDBManager.h"
+#include "AliLog.h"
+#include "AliQA.h"
+#include "AliQADataMakerSteer.h"
+#include "AliRawReader.h"
+#include "AliRawReaderRoot.h"
+#include "AliDAQ.h"
+
+TString ClassName() { return "rawqa" ; } 
+
+//________________________________qa______________________________________
+void rawqa(const Int_t runNumber, const char* year = "08") 
+{      
+
+       AliLog::SetGlobalDebugLevel(0) ; 
+       // connect to the grid 
+       TGrid * grid = 0x0 ; 
+               grid = TGrid::Connect("alien://") ; 
+               
+       Bool_t detIn[AliDAQ::kNDetectors] = {kFALSE} ;
+       char * detNameOff[AliDAQ::kNDetectors] = {"ITS", "ITS", "ITS", "TPC", "TRD", "TOF", "HMPID", "PHOS", "PHOS", "PMD", "MUON", "MUON", "FMD", "T0", "VZERO", "ZDC", "ACORDE", "TRG", "EMCAL", "DAQ_TEST", "HLT"} ; 
+       // make the file name pattern year and run number
+       TString pattern;
+       pattern.Form("%9d",runNumber);
+       pattern.ReplaceAll(" ", "0") ; 
+       pattern.Prepend(year);
+       pattern.Append("*0.root");
+
+       // find the files associated to this run
+       TGridResult * result = 0x0 ; 
+       const UInt_t kMaxFiles = 10 ; 
+       Bool_t local = kFALSE ; 
+       if (grid) { // get the list of files from AliEn directly 
+         TString baseDir; 
+         baseDir.Form("/alice/data/20%s/",year);
+         result = grid->Query(baseDir, pattern) ;  
+       } else {
+         TString collectionFile(pattern) ; 
+         collectionFile.Append(".xml") ; 
+         if ( gSystem->AccessPathName(collectionFile) == 0 ) { // get the list of files from an a-priori created collection file
+           TAlienCollection collection(collectionFile.Data(), kMaxFiles) ; 
+           result = collection.GetGridResult("", 0, 0); 
+         } else { // get the list of files from the local current directory 
+           local = kTRUE ; 
+           char line[100] ; 
+           sprintf(line, ".! ls %s*.root > tempo.txt", pattern.Data()) ; 
+           gROOT->ProcessLine(line) ;
+         }
+       }
+       AliLog::Flush();
+       ifstream in ; 
+       if (local) 
+               in.open("tempo.txt", ifstream::in) ; 
+
+       AliCDBManager* man = AliCDBManager::Instance();
+       man->SetDefaultStorage("alien://folder=/alice/data/2008/LHC08a/OCDB/"); // AliQA::GetQARefDefaultStorage()
+       AliQA::SetQARefStorage("local://../TestCDB") ; 
+       man->SetSpecificStorage(Form("%s/*", AliQA::GetQAOCDBDirName()), AliQA::GetQARefStorage());
+       AliQADataMakerSteer qas ; 
+       TString detectors  = ""; 
+       TString detectorsW = ""; 
+       UShort_t file = 0 ; 
+       for ( file = 0 ; file < kMaxFiles ; file++) {
+               TString fileName ; 
+               if ( local) {
+                       in >> fileName ;
+               } 
+               else 
+                       fileName = result->GetKey(file, "turl");
+               if ( fileName == "" )  
+                       break ;
+               if ( fileName.Contains("tag") )
+                       continue; 
+               char input[200] ; 
+               if (local) 
+                       sprintf(input, "%s", fileName.Data()) ; 
+               else 
+                       sprintf(input, "%s", result->GetKey(file, "turl")); 
+               AliInfo(Form("Proccessing file # %d --> %s", file, input)) ;
+               AliLog::Flush();
+               // check which detectors are present 
+               AliRawReader * rawReader = new AliRawReaderRoot(input);
+               rawReader->NextEvent() ; 
+               man->SetRun(rawReader->GetRunNumber());
+               UChar_t * data ; 
+               while (rawReader->ReadNextData(data)) {
+                       Int_t detID = rawReader->GetDetectorID();
+                       if (detID < 0 || detID >= AliDAQ::kNDetectors) {
+                         AliError("Wrong detector ID! Skipping payload...");
+                         continue;
+                       }
+                       detIn[detID] = kTRUE ; 
+               }
+               for (Int_t detID = 0; detID < AliDAQ::kNDetectors ; detID++) {
+                       if (detIn[detID]) {
+                               if ( ! detectors.Contains(detNameOff[detID]) ) {
+                                       detectors.Append(detNameOff[detID]) ;
+                                       detectors.Append(" ") ;
+                               }
+                       }
+               }
+               // TEMPORARY REMOVAL OF TRD!!!
+               detectors.ReplaceAll("TRD","");
+               // TEMPORARY REMOVAL OF TRD!!!
+               if ( !detectors.IsNull() ) {
+                 detectorsW = qas.Run(detectors, rawReader) ;
+                 qas.Reset() ;
+               } else {
+                 AliError("No valid detectors found") ; 
+               } 
+               delete rawReader;
+       }
+       AliLog::Flush();
+       qas.Merge(runNumber) ; 
+       
+       AliLog::Flush();
+       // The summary 
+       AliInfo(Form("\n\n********** Summary for run %d **********", runNumber)) ; 
+       printf("     detectors present in the run        : %s\n", detectors.Data()) ; 
+       printf("     detectors present in the run with QA: %s\n", detectorsW.Data()) ; 
+       printf("     number of files processed           : %d\n", file) ; 
+       TFile * qaResult = TFile::Open(AliQA::GetQAResultFileName()) ; 
+       AliQA * qa = dynamic_cast<AliQA *>(qaResult->Get("QA")) ; 
+       for (Int_t index = 0 ; index < AliQA::kNDET ; index++)
+               if (detectorsW.Contains(AliQA::GetDetName(AliQA::DETECTORINDEX(index)))) 
+                       qa->ShowStatus(AliQA::DETECTORINDEX(index)) ;
+}
diff --git a/test/cosmic/rec.C b/test/cosmic/rec.C
new file mode 100644 (file)
index 0000000..d426b87
--- /dev/null
@@ -0,0 +1,166 @@
+void rec(Int_t runNumber = 0, const char* year = "08", const char *localFileName = NULL)\r
+{\r
+  // Offline shifter reconstruction macro\r
+\r
+  cout << "Going to run the reconstruction for run: " << runNumber << endl;\r
+\r
+  // connect to the grid \r
+  TGrid * grid = 0x0 ; \r
+  grid = TGrid::Connect("alien://") ; \r
+               \r
+  // make the file name pattern year and run number\r
+  TString pattern;\r
+  pattern.Form("%9d",runNumber);\r
+  pattern.ReplaceAll(" ", "0") ; \r
+  pattern.Prepend(year);\r
+  pattern.Append("*0.root");\r
+\r
+  // find the files associated to this run\r
+  // get the list of files from AliEn directly \r
+  TString baseDir; \r
+  baseDir.Form("/alice/data/20%s/",year);\r
+\r
+  cout << "Looking for raw-data files with pattern " << pattern << " in folder " << baseDir << endl;\r
+\r
+  TGridResult *result = grid->Query(baseDir, pattern);\r
+\r
+  TList *fileList = result->GetFileInfoList();\r
+\r
+  cout << fileList->GetEntries() << " raw-data files found" << endl;\r
+  if ( fileList->GetEntries() == 0) {\r
+    cout << "Exiting..." << endl;\r
+    return;\r
+  }\r
+\r
+  // Take the first (or last?) file...\r
+  TFileInfo *fi =  (TFileInfo *)fileList->At(0); \r
+  //  TFileInfo *fi =  (TFileInfo *)fileList->At(fileList->GetEntries()-1); \r
+\r
+  cout << "Getting the file:" << fi->GetCurrentUrl()->GetUrl() << endl;\r
+  fi->Dump();\r
+\r
+  TString filename(fi->GetCurrentUrl()->GetUrl());\r
+\r
+  AliLog::Flush();\r
+\r
+  /////////////////////////////////////////////////////////////////////////////////////////\r
+  //\r
+  // First version of the reconstruction\r
+  // script for the FDR'08\r
+\r
+  // Set the CDB storage location\r
+  // AliLog::SetModuleDebugLevel("STEER",2);\r
+  AliCDBManager * man = AliCDBManager::Instance();\r
+  //  man->SetDefaultStorage("local://LocalCDB");\r
+  man->SetDefaultStorage("alien://folder=/alice/data/2008/LHC08a/OCDB/");\r
+  \r
+  // Files that we can not read from alien...\r
+  man->SetSpecificStorage("ITS/Calib/MapsAnodeSDD","local://$ALICE_ROOT");\r
+  man->SetSpecificStorage("ITS/Calib/MapsTimeSDD","local://$ALICE_ROOT");\r
+  man->SetSpecificStorage("TPC/Calib/ExB","local://$ALICE_ROOT");\r
+\r
+  // Objects not found if using LHC07w database\r
+  //  man->SetSpecificStorage("ITS/Calib/MapsAnodeSDD","local:///afs/cern.ch/user/c/cheshkov/public/OCDB");\r
+  // man->SetSpecificStorage("GRP/GRP/Data","local://$ALICE_ROOT");\r
+  // man->SetSpecificStorage("ITS/Calib/DDLMapSDD","local://$ALICE_ROOT");\r
+  // man->SetSpecificStorage("MUON/Calib/Mapping","local://$ALICE_ROOT");\r
+  // man->SetSpecificStorage("MUON/Calib/DDLStore","local://$ALICE_ROOT");\r
+\r
+  // ITS settings\r
+  AliITSRecoParam * itsRecoParam = AliITSRecoParam::GetCosmicTestParam();\r
+  itsRecoParam->SetClusterErrorsParam(2);\r
+  itsRecoParam->SetFindV0s(kFALSE);\r
+  itsRecoParam->SetAddVirtualClustersInDeadZone(kFALSE);\r
+  itsRecoParam->SetUseAmplitudeInfo(kFALSE);\r
+  // In case we want to switch off a layer\r
+  //  itsRecoParam->SetLayerToSkip(<N>);\r
+  itsRecoParam->SetLayerToSkip(4);\r
+  itsRecoParam->SetLayerToSkip(5);\r
+  itsRecoParam->SetLayerToSkip(2);\r
+  itsRecoParam->SetLayerToSkip(3);\r
+  AliITSReconstructor::SetRecoParam(itsRecoParam);\r
+\r
+  // TPC settings\r
+  AliLog::SetClassDebugLevel("AliTPCclustererMI",2);\r
+  AliTPCRecoParam * tpcRecoParam = AliTPCRecoParam::GetCosmicTestParam(kTRUE);\r
+  tpcRecoParam->SetTimeInterval(60,940);\r
+  tpcRecoParam->Dump();\r
+  AliTPCReconstructor::SetRecoParam(tpcRecoParam);\r
+  AliTPCReconstructor::SetStreamLevel(1);\r
+\r
+  // PHOS settings\r
+  AliPHOSRecoParam* recEmc = new AliPHOSRecoParamEmc();\r
+  recEmc->SetSubtractPedestals(kTRUE);\r
+  recEmc->SetMinE(0.05);\r
+  recEmc->SetClusteringThreshold(0.10);\r
+  AliPHOSReconstructor::SetRecoParamEmc(recEmc);\r
+\r
+  // T0 settings\r
+  AliLog::SetModuleDebugLevel("T0", 10);\r
+\r
+  // MUON settings\r
+  AliLog::SetClassDebugLevel("AliMUONRawStreamTracker",3);\r
+  AliMUONRecoParam *muonRecoParam = AliMUONRecoParam::GetLowFluxParam();\r
+  muonRecoParam->CombineClusterTrackReco(kTRUE);\r
+  muonRecoParam->SetCalibrationMode("NOGAIN");\r
+  //muonRecoParam->SetClusteringMode("PEAKFIT");\r
+  //muonRecoParam->SetClusteringMode("PEAKCOG");\r
+  muonRecoParam->Print("FULL");\r
+  AliRecoParam::Instance()->RegisterRecoParam(muonRecoParam);\r
\r
+  // Tracking settings\r
+  //  AliMagFMaps* field = new AliMagFMaps("Maps","Maps", 2, 1., 10., 1);\r
+  AliMagFMaps* field = new AliMagFMaps("Maps","Maps", 2, 0., 10., 2);\r
+  AliTracker::SetFieldMap(field,1);\r
+  Double_t mostProbPt=0.35;\r
+  AliExternalTrackParam::SetMostProbablePt(mostProbPt);\r
+\r
+  // AliReconstruction settings\r
+  AliReconstruction rec;\r
+  rec.SetUniformFieldTracking(kFALSE);\r
+  rec.SetWriteESDfriend(kTRUE);\r
+  rec.SetWriteAlignmentData();\r
+  rec.SetInput(filename.Data());\r
+  rec.SetRunReconstruction("ALL");\r
+  rec.SetUseTrackingErrorsForAlignment("ITS");\r
+\r
+  // In case some detectors have to be switched off...\r
+  //  rec.SetRunLocalReconstruction("ALL");\r
+  //  rec.SetRunTracking("ALL");\r
+  //  rec.SetFillESD("ALL");\r
+  // Disable vertex finder for the moment\r
+  rec.SetRunVertexFinder(kFALSE);\r
+\r
+  // To be enabled if some equipment IDs are not set correctly by DAQ\r
+  //  rec.SetEquipmentIdMap("EquipmentIdMap.data");\r
+\r
+  // Detector options if any\r
+  rec.SetOption("ITS","cosmics,onlyITS");\r
+  rec.SetOption("MUON","SAVEDIGITS");\r
+  rec.SetOption("TPC","OldRCUFormat");\r
+  rec.SetOption("PHOS","OldRCUFormat");\r
+\r
+  // To be enabled when CTP readout starts\r
+  rec.SetFillTriggerESD(kFALSE);\r
+\r
+  // all events in one single file\r
+  rec.SetNumberOfEventsPerFile(-1);\r
+\r
+  // switch off cleanESD\r
+  rec.SetCleanESD(kFALSE);\r
+\r
+  // rec.SetEventRange(0,15);\r
+  // AliLog::SetGlobalDebugLevel(2);\r
+\r
+  rec.SetRunQA(kFALSE);\r
+  AliLog::Flush();\r
+  rec.Run();\r
+\r
+  //cout << "-----------------------------------------------------------------" << endl;\r
+  //cout << "-----------------------------------------------------------------" << endl;\r
+  //cout << "--------- Reconstruction Completed. Start merging QAs -----------" << endl;\r
+  //cout << "-----------------------------------------------------------------" << endl;\r
+  //cout << "-----------------------------------------------------------------" << endl;\r
+  //AliQADataMakerSteer qas;\r
+  //qas.Merge();\r
+}\r