From 9d0c62897a1479d703ce04395ac6e908ce6b833a Mon Sep 17 00:00:00 2001 From: richterm Date: Mon, 14 Dec 2009 13:44:15 +0000 Subject: [PATCH] updating and adding macros for HLT TRD evaluation (Theodor) --- HLT/TRD/macros/aliHLTTRDrun.cxx | 148 ++++++++++++++++ HLT/TRD/macros/initGRP.h | 176 +++++++++++++++++++ HLT/TRD/macros/rec-hlt-trd-digits.cxx | 107 ++++++++++++ HLT/TRD/macros/rec-hlt-trd.cxx | 241 +++++++++++++++++++++----- 4 files changed, 624 insertions(+), 48 deletions(-) create mode 100644 HLT/TRD/macros/aliHLTTRDrun.cxx create mode 100644 HLT/TRD/macros/initGRP.h create mode 100644 HLT/TRD/macros/rec-hlt-trd-digits.cxx diff --git a/HLT/TRD/macros/aliHLTTRDrun.cxx b/HLT/TRD/macros/aliHLTTRDrun.cxx new file mode 100644 index 00000000000..f4fea223d87 --- /dev/null +++ b/HLT/TRD/macros/aliHLTTRDrun.cxx @@ -0,0 +1,148 @@ +// This macro is used to profile the HLT::TRD code +// usage: aliroot aliHLTTRDrun.cxx("/data/sim/") reconstruct raw ddls, /data/run/ must contain subfolders rawX + +#if !defined (__CINT__) || defined (__MAKECINT__) + +#include +#include +#include + +#include "TString.h" +#include "TMath.h" + +#include "AliHLTSystem.h" +#include "AliLog.h" +#include "AliHLTDataTypes.h" +#include "AliHLTConfiguration.h" + +#include +#include +#endif + +#include "initGRP.h" + +void aliHLTTRDrun(const TString inDir = gSystem->pwd()); +int main(int argc, char** argv) +{ + if(argc==2) aliHLTTRDrun(argv[1]); + else aliHLTTRDrun(); +} + +void aliHLTTRDrun(const TString inDir) +{ + + // Is the TRD full? + Bool_t fullTRD=kFALSE; + + // If not use these SMs: + Int_t TRDmodules[18] = {0,1,7,8,9,10,17,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; + + // Use custom arguments for components? i.e.: not reading OCDB arguments + Bool_t customArgs=kTRUE; + + // Disable HLT flag? + Bool_t disableHLTflag=kTRUE; + + + + ///////////////////////////////////// + + Int_t usedModules=0; + if(fullTRD){ + usedModules = 18; + for(int i=0; i<18; i++) + TRDmodules[i]=i; + }else{ + std::sort((UInt_t*)TRDmodules, ((UInt_t*)TRDmodules) + 18); + for(int i=0; i<18; i++) + if(TRDmodules[i]>-1)usedModules++; + } + + AliHLTSystem gHLT; + AliLog::SetGlobalDebugLevel(1); + //AliLog::SetClassDebugLevel("AliTRDrawStream", 11); + /* enum ETpye {kFatal=0, kError, kWarning, kInfo, kDebug, kMaxType}; */ + gHLT.SetGlobalLoggingLevel((AliHLTComponentLogSeverity)0x7f); + /* enum AliHLTComponentLogSeverity { + kHLTLogNone = 0, + kHLTLogBenchmark = 0x1, + kHLTLogDebug = 0x2, + kHLTLogInfo = 0x4, + kHLTLogWarning = 0x8, + kHLTLogError = 0x10, + kHLTLogFatal = 0x20, + few important messages not to be filtered out. + redirected to kHLTLogInfo in AliRoot + kHLTLogImportant = 0x40, + special value to enable all messages + kHLTLogAll = 0x7f, + the default logging filter + kHLTLogDefault = 0x79 + useful = 0x45 + */ + + gHLT.LoadComponentLibraries("libAliHLTUtil.so libAliHLTTRD.so libAliHLTMUON.so libAliHLTGlobal.so libAliHLTTrigger.so"); + + InitGRP("local://$ALICE_ROOT/OCDB","/software/data/ppbench"/*inDir.Data()*/); + //TString sGeomPath = " -geometry "+inDir+"/geometry.root"; + TString inFolder = inDir+"/raw", inFile = "/TRD_", inExt = ".ddl"; + TString sinput = " -datatype 'DDL_RAW ' 'TRD '"; + TString temp1, temp2; + Int_t spec, startEvent=10, nEvents=30, ddl; //KR: start=10, nEvents=20; + for(Int_t Event=startEvent; Event<(nEvents+startEvent); Event++){ + temp1=inFolder; + temp1+=Event; + temp1+=inFile; + for(int module=0; moduleSetDefaultStorage(OCDBpath.Data()); + AliCDBManager::Instance()->SetSpecificStorage("GRP/GRP/Data", Form("local://%s",GRPpath.Data())); + AliCDBManager::Instance()->SetRun(0); + + AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data"); + AliGRPObject* GRPData; + + if (entry) { + + TMap* m = dynamic_cast(entry->GetObject()); // old GRP entry + + if (m) { + printf("Found a TMap in GRP/GRP/Data, converting it into an AliGRPObject"); + m->Print(); + GRPData = new AliGRPObject(); + GRPData->ReadValuesFromMap(m); + } + + else { + printf("Found an AliGRPObject in GRP/GRP/Data, reading it"); + GRPData = dynamic_cast(entry->GetObject()); // new GRP entry + entry->SetOwner(0); + } + + // FIX ME: The unloading of GRP entry is temporarily disabled + // because ZDC and VZERO are using it in order to initialize + // their reconstructor objects. In the future one has to think + // of propagating AliRunInfo to the reconstructors. + // AliCDBManager::Instance()->UnloadFromCache("GRP/GRP/Data"); + } + + if (!GRPData) { + printf("No GRP entry found in OCDB!"); + return kFALSE; + } + + TString lhcState = GRPData->GetLHCState(); + if (lhcState==AliGRPObject::GetInvalidString()) { + printf("GRP/GRP/Data entry: missing value for the LHC state ! Using UNKNOWN"); + lhcState = "UNKNOWN"; + } + + TString beamType = GRPData->GetBeamType(); + if (beamType==AliGRPObject::GetInvalidString()) { + printf("GRP/GRP/Data entry: missing value for the beam type ! Using UNKNOWN"); + beamType = "UNKNOWN"; + } + + Float_t beamEnergy = GRPData->GetBeamEnergy(); + if (beamEnergy==AliGRPObject::GetInvalidFloat()) { + printf("GRP/GRP/Data entry: missing value for the beam energy ! Using 0"); + beamEnergy = 0; + } + // LHC: "multiply by 120 to get the energy in MeV" + beamEnergy *= 0.120; + + TString runType = GRPData->GetRunType(); + if (runType==AliGRPObject::GetInvalidString()) { + printf("GRP/GRP/Data entry: missing value for the run type ! Using UNKNOWN"); + runType = "UNKNOWN"; + } + + Int_t activeDetectors = GRPData->GetDetectorMask(); + if (activeDetectors==AliGRPObject::GetInvalidUInt()) { + printf("GRP/GRP/Data entry: missing value for the detector mask ! Using 1074790399"); + activeDetectors = 1074790399; + } + + //*** Dealing with the magnetic field map + if ( TGeoGlobalMagField::Instance()->IsLocked() ) { + if (TGeoGlobalMagField::Instance()->GetField()->TestBit(AliMagF::kOverrideGRP)) { + printf("ExpertMode!!! GRP information will be ignored !"); + printf("ExpertMode!!! Running with the externally locked B field !"); + } + else { + printf("Destroying existing B field instance!"); + delete TGeoGlobalMagField::Instance(); + } + } + if ( !TGeoGlobalMagField::Instance()->IsLocked() ) { + // Construct the field map out of the information retrieved from GRP. + Bool_t ok = kTRUE; + // L3 + Float_t l3Current = GRPData->GetL3Current((AliGRPObject::Stats)0); + if (l3Current == AliGRPObject::GetInvalidFloat()) { + printf("GRP/GRP/Data entry: missing value for the L3 current !"); + ok = kFALSE; + } + + Char_t l3Polarity = GRPData->GetL3Polarity(); + if (l3Polarity == AliGRPObject::GetInvalidChar()) { + printf("GRP/GRP/Data entry: missing value for the L3 polarity !"); + ok = kFALSE; + } + + // Dipole + Float_t diCurrent = GRPData->GetDipoleCurrent((AliGRPObject::Stats)0); + if (diCurrent == AliGRPObject::GetInvalidFloat()) { + printf("GRP/GRP/Data entry: missing value for the dipole current !"); + ok = kFALSE; + } + + Char_t diPolarity = GRPData->GetDipolePolarity(); + if (diPolarity == AliGRPObject::GetInvalidChar()) { + printf("GRP/GRP/Data entry: missing value for the dipole polarity !"); + ok = kFALSE; + } + + // read special bits for the polarity convention and map type + Int_t polConvention = GRPData->IsPolarityConventionLHC() ? AliMagF::kConvLHC : AliMagF::kConvDCS2008; + Bool_t uniformB = GRPData->IsUniformBMap(); + + if (ok) { + AliMagF* fld = AliMagF::CreateFieldMap(TMath::Abs(l3Current) * (l3Polarity ? -1:1), + TMath::Abs(diCurrent) * (diPolarity ? -1:1), + polConvention,uniformB,beamEnergy, beamType.Data()); + if (fld) { + TGeoGlobalMagField::Instance()->SetField( fld ); + TGeoGlobalMagField::Instance()->Lock(); + printf("Running with the B field constructed out of GRP !"); + } + else printf("Failed to create a B field map !"); + } + else printf("B field is neither set nor constructed from GRP ! Exitig..."); + } + + //*** Get the diamond profiles from OCDB + // entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexSPD"); + // if (entry) { + // fDiamondProfileSPD = dynamic_cast (entry->GetObject()); + // } else { + // printf("No SPD diamond profile found in OCDB!"); + // } + + // entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertex"); + // if (entry) { + // fDiamondProfile = dynamic_cast (entry->GetObject()); + // } else { + // printf("No diamond profile found in OCDB!"); + // } + + // entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexTPC"); + // if (entry) { + // fDiamondProfileTPC = dynamic_cast (entry->GetObject()); + // } else { + // printf("No TPC diamond profile found in OCDB!"); + // } + + // entry = AliCDBManager::Instance()->Get("GRP/Calib/CosmicTriggers"); + // if (entry) { + // fListOfCosmicTriggers = dynamic_cast(entry->GetObject()); + // entry->SetOwner(0); + // AliCDBManager::Instance()->UnloadFromCache("GRP/Calib/CosmicTriggers"); + // } + + // if (!fListOfCosmicTriggers) { + // AliWarning("Can not get list of cosmic triggers from OCDB! Cosmic event specie will be effectively disabled!"); + // } + + return kTRUE; +} diff --git a/HLT/TRD/macros/rec-hlt-trd-digits.cxx b/HLT/TRD/macros/rec-hlt-trd-digits.cxx new file mode 100644 index 00000000000..2e758072c0d --- /dev/null +++ b/HLT/TRD/macros/rec-hlt-trd-digits.cxx @@ -0,0 +1,107 @@ +// This macro is used to make performace studies with MC info +// usage: aliroot rec-hlt-trd-digits.cxx("/data/run/raw.root") reconstruct local digits file +// or copy into folder and aliroot rec-hlt-trd.cxx reconstruct local digits file in pwd + +#if !defined (__CINT__) || defined (__MAKECINT__) + +#include +#include +#include + +#include "TString.h" +#include "TMath.h" + +#include "AliHLTSystem.h" +#include "AliLog.h" +#include "AliHLTDataTypes.h" +#include "AliHLTConfiguration.h" + +#include +#include +#include "TSystem.h" +#include "AliHLTOfflineInterface.h" +#include "AliRunLoader.h" +#include "AliReconstructor.h" +#endif + +#include "initGRP.h" + +int rec_hlt_trd_digits(const TString input = gSystem->pwd()); +int main(int argc, char** argv) +{ + if(argc==2) return rec_hlt_trd_digits(argv[1]); + else return rec_hlt_trd_digits(); +} + +int rec_hlt_trd_digits(const TString input){ + + // Use custom arguments for components? i.e.: not reading OCDB arguments + Bool_t customArgs=kTRUE; + + // Disable HLT flag? + Bool_t disableHLTflag=kTRUE; + + + + //////////////////////////////// + + gSystem->ChangeDirectory(input.Data()); + + InitGRP("local://$ALICE_ROOT/OCDB",gSystem->pwd()); + + AliRunLoader* runLoader = AliRunLoader::Open("galice.root"); + AliHLTOfflineInterface::SetParamsToComponents(runLoader, NULL); + + AliHLTSystem gHLT; + AliLog::SetGlobalDebugLevel(1); + //AliLog::SetClassDebugLevel("AliTRDrawStream", 11); + /* enum ETpye {kFatal=0, kError, kWarning, kInfo, kDebug, kMaxType}; */ + gHLT.SetGlobalLoggingLevel((AliHLTComponentLogSeverity)0x7f); + /* enum AliHLTComponentLogSeverity { + kHLTLogNone = 0, + kHLTLogBenchmark = 0x1, + kHLTLogDebug = 0x2, + kHLTLogInfo = 0x4, + kHLTLogWarning = 0x8, + kHLTLogError = 0x10, + kHLTLogFatal = 0x20, + few important messages not to be filtered out. + redirected to kHLTLogInfo in AliRoot + kHLTLogImportant = 0x40, + special value to enable all messages + kHLTLogAll = 0x7f, + the default logging filter + kHLTLogDefault = 0x79 + useful = 0x45 + */ + + gHLT.LoadComponentLibraries("libAliHLTUtil.so libAliHLTTRD.so libAliHLTMUON.so libAliHLTGlobal.so libAliHLTTrigger.so"); + + // digits publisher + AliHLTConfiguration pubDigiConf("TRD-DigiP", "AliLoaderPublisher", NULL , "-loader TRDLoader -tree digits -datatype 'ALITREED' 'TRD '"); + + TString arg=""; + if(customArgs || disableHLTflag){ + arg="output_percentage 700 -lowflux -experiment -tailcancellation -faststreamer -yPosMethod LUT -highLevelOutput yes -emulateHLTClusters yes"; + if(disableHLTflag) + arg+=" -HLTflag no"; + } + // clusterizer which processes digits + AliHLTConfiguration cfDigiConf("TRD-DigiCF", "TRDOfflineClusterizer", "TRD-DigiP", arg.Data()); + + arg=""; + if(customArgs || disableHLTflag){ + arg="output_percentage 100 -lowflux -PIDmethod NN -highLevelOutput yes -emulateHLTTracks yes"; + if(disableHLTflag) + arg+=" -HLTflag no"; + } + // tracker reading the output from the clusterizer which processes the digits + AliHLTConfiguration trDigiConf("TRD-DigiTR", "TRDOfflineTrackerV1", "TRD-DigiCF", arg.Data()); + + // root file writer (with esd friends and MC) + AliHLTConfiguration writerDigiConf("TRD-DigiEsdFile", "TRDEsdWriter", "TRD-DigiTR", "-concatenate-events -concatenate-blocks"); + + gHLT.BuildTaskList(&writerDigiConf); + gHLT.Run(runLoader->GetNumberOfEvents()); +} + diff --git a/HLT/TRD/macros/rec-hlt-trd.cxx b/HLT/TRD/macros/rec-hlt-trd.cxx index d70e0cc989d..e29eff8e2fe 100644 --- a/HLT/TRD/macros/rec-hlt-trd.cxx +++ b/HLT/TRD/macros/rec-hlt-trd.cxx @@ -1,9 +1,9 @@ -// usage: aliroot rec-hlt-trd.cxx("/data/real_runXXX/raw_input.root") -// or: aliroot rec-hlt-trd.cxx("/data/sim_run/raw.root") -// or: aliroot rec-hlt-trd.cxx("/data/sim_run/") * -// or copy into folder and aliroot rec-hlt-trd.cxx +// This macro is used to simulate the HLT reconstruction +// usage: aliroot rec-hlt-trd.cxx("/data/run/raw.root") reconstruct local raw root file (you might add "alien://" to reconstruct remotely) +// or: aliroot rec-hlt-trd.cxx("/data/run/") reconstruct local raw ddls *1 +// or copy into folder and aliroot rec-hlt-trd.cxx reconstruct raw.root in pwd // -// (*) here sim_run has as subfolders rawX (be sure to have the last "/" !!) +// (*1) here /data/run/ must contain subfolders rawX (be sure to have the last "/" !!) #if !defined (__CINT__) || defined (__MAKECINT__) @@ -24,19 +24,27 @@ #include #include #include "TSystem.h" +#include "TFile.h" +#include "TGrid.h" +#include "TGridResult.h" +#include "AliCDBManager.h" +#include "AliCDBEntry.h" +#include "AliTriggerConfiguration.h" +#include "AliTriggerClass.h" +#include "AliExternalTrackParam.h" #endif -const Bool_t fullTRD=kTRUE; - -void rec_hlt_trd(const char* input ="./raw.root"); +int rec_hlt_trd(const TString input ="raw.root", TString outPath=gSystem->pwd()); +Int_t ExtractRunNumber(const TString str); int main(int argc, char** argv) { - if(argc>1) rec_hlt_trd(argv[1]); - else rec_hlt_trd(); + if(argc==2) return rec_hlt_trd(argv[1]); + else if(argc==3) return rec_hlt_trd(argv[1],argv[2]); + else return rec_hlt_trd(); } -void rec_hlt_trd(const char* input) +int rec_hlt_trd(const TString filename, TString outPath) { /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -44,93 +52,222 @@ void rec_hlt_trd(const char* input) // define the analysis chain to be run // - // Is the TRD full? - Bool_t fullTRD=kFALSE; + // What chains should be run? (usually would be: TRD-OffEsdFile) + TString chains="TRD-CalibFile"; + + // cosmics or not + Bool_t bCosmics=kFALSE; + + // look only in data containing TRD triggers? + Bool_t useOnlyTRDtrigger=kFALSE; + + // Is the TRD full? (this is only important if ddl files should be read) + Bool_t fullTRD=kTRUE; // If not use these SMs: Int_t TRDmodules[18] = {0,1,7,8,9,10,17,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; - // What chains should be run? - TString chains="TRD-OffEsdFile"; + // Use custom arguments for components? i.e.: not reading OCDB arguments + Bool_t customArgs=kTRUE; + + // Disable HLT flag? + Bool_t disableHLTflag=kFALSE; /////////////////////////////////////////////////////////////////////////////////////////////////// // - // init the HLT system in order to define the analysis chain below + // init the HLT system // - AliHLTSystem* gHLT=AliHLTPluginBase::GetInstance(); - + TString dataPath = outPath; + dataPath.Resize(dataPath.Last('/')+1); + if(!dataPath.Length()){ + dataPath=gSystem->pwd(); + dataPath+="/"; + outPath.Prepend(dataPath); + } + + TString extInput = filename; + dataPath = filename; + dataPath.Resize(dataPath.Last('/')+1); + if(!dataPath.Length()){ + dataPath=gSystem->pwd(); + dataPath+="/"; + extInput.Prepend(dataPath); + } + + printf("File path %s\n",dataPath.Data()); + printf("Processing file %s\n",extInput.Data()); + printf("Output to %s\n",outPath.Data()); + if(!gSystem->AccessPathName("galice.root")){ cerr << "please delete the galice.root or run at different place." << endl; - return; + return -1; } - TString GRPDir=input; - GRPDir.Resize(GRPDir.Last('/')+1); - if(GRPDir.Length()==0)GRPDir=gSystem->pwd(); - printf("GRP dir: %s\n",GRPDir.Data()); + Bool_t bRealData=kFALSE; + if(filename.Contains(".root") && !filename.Contains("raw.root")){ + bRealData = kTRUE; + printf("processing real data\n"); + }else{ + bRealData = kFALSE; + printf("processing simulated data\n"); + } + + if(filename.Contains("alien://") || bRealData){ + TGrid::Connect("alien://"); + } + + if(filename.Contains(".root") && !TFile::Open(filename))return -1; + gSystem->mkdir(outPath.Data()); + gSystem->ChangeDirectory(outPath.Data()); + + AliHLTSystem* gHLT=AliHLTPluginBase::GetInstance(); + Int_t usedModules=0; if(fullTRD){ usedModules = 18; for(int i=0; i<18; i++) TRDmodules[i]=i; }else{ + std::sort((UInt_t*)TRDmodules, ((UInt_t*)TRDmodules) + 18); for(int i=0; i<18; i++) - if(TRDmodules[i]>0)usedModules++; + if(TRDmodules[i]>-1)usedModules++; } - TString option="libAliHLTUtil.so libAliHLTTRD.so libAliHLTGlobal.so libAliHLTTrigger.so loglevel=0x7f chains="; + TString option="libAliHLTUtil.so libAliHLTTRD.so libAliHLTMUON.so libAliHLTGlobal.so libAliHLTTrigger.so loglevel=0x7f chains="; option+=chains; - TString nextInput, nextOffInput; + TString afterTr, afterTrOff, afterCf; for (int module = 0; module < usedModules; module++) { TString arg, publisher, cf, tr, trOff; // raw data publisher components - publisher.Form("TRD-RP_%02d", module); - arg.Form("-minid %d -datatype 'DDL_RAW ' 'TRD ' -dataspec %i -verbose", module+1024, (int)TMath::Power(2,module)); + publisher.Form("TRD-RP_%02d", TRDmodules[module]); + arg.Form("-minid %d -datatype 'DDL_RAW ' 'TRD ' -dataspec %i -verbose", TRDmodules[module]+1024, (int)TMath::Power(2,TRDmodules[module])); AliHLTConfiguration pubConf(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data()); // Clusterizer - cf.Form("TRD-CF_%02d", module); - AliHLTConfiguration cfConf(cf.Data(), "TRDClusterizer", publisher.Data(), "output_percentage 700 -lowflux -simulation -yPosMethod LUT"); + arg = ""; + if(customArgs || disableHLTflag){ + arg="output_percentage 700 -lowflux -experiment -tailcancellation -faststreamer -yPosMethod LUT"; + if(disableHLTflag) + arg+=" -HLTflag no"; + } + + cf.Form("TRD-CF_%02d", TRDmodules[module]); + AliHLTConfiguration cfConf(cf.Data(), "TRDClusterizer", publisher.Data(), arg.Data()); + + if (afterCf.Length()>0) afterCf+=" "; + afterCf+=cf; // Tracker - tr.Form("TRD-TR_%02d", module); - arg.Form("output_percentage 100 -lowflux -PIDmethod NN"); + arg=""; + if(customArgs || disableHLTflag){ + arg="output_percentage 100 -lowflux -PIDmethod NN"; + if(disableHLTflag) + arg+=" -HLTflag no"; + } + + tr.Form("TRD-TR_%02d", TRDmodules[module]); AliHLTConfiguration trConf(tr.Data(), "TRDTrackerV1", cf.Data(), arg.Data()); - if (nextInput.Length()>0) nextInput+=" "; - nextInput+=tr; + if (afterTr.Length()>0) afterTr+=" "; + afterTr+=tr; + + // Offline Tracker (for debug purposes only) + arg=""; + if(customArgs || disableHLTflag){ + arg="output_percentage 100 -lowflux -PIDmethod NN -highLevelOutput yes -emulateHLTTracks yes"; + if(disableHLTflag) + arg+=" -HLTflag no"; + } - trOff.Form("TRD-TROFF_%02d", module); + trOff.Form("TRD-TROFF_%02d", TRDmodules[module]); AliHLTConfiguration trOffConf(trOff.Data(), "TRDOfflineTrackerV1", cf.Data(), arg.Data()); - if (nextOffInput.Length()>0) nextOffInput+=" "; - nextOffInput+=trOff; + if (afterTrOff.Length()>0) afterTrOff+=" "; + afterTrOff+=trOff; } - // calibration - AliHLTConfiguration calibConf("TRD-Calib", "TRDCalibration", nextInput.Data(), ""); - AliHLTConfiguration writerCalibConf( "TRD-CalibFile", "ROOTFileWriter", "TRD-Calib", "-directory hlt-trd-calib/ -datafile calib.root"); + // cluster histogramm + AliHLTConfiguration histoConf("TRD-ClHisto", "TRDClusterHisto", afterCf.Data(), ""); + AliHLTConfiguration writerHistoConf( "TRD-ClHistoFile", "ROOTFileWriter", "TRD-ClHisto", "-directory hlt-trd-histo/ -datafile histo.root -concatenate-events -concatenate-blocks"); + + // calibration (you may use tr or trOff here) + AliHLTConfiguration calibConf("TRD-Calib", "TRDCalibration", afterTr.Data(), "-TrgStr hi -rejectTrgStr"); + AliHLTConfiguration writerCalibConf( "TRD-CalibFile", "ROOTFileWriter", "TRD-Calib", "-directory hlt-trd-calib/ -datafile calib.root -concatenate-events -concatenate-blocks -write-all-events"); // esd converter - AliHLTConfiguration esdConf("TRD-Esd", "GlobalEsdConverter", nextInput.Data(), "-notree"); + AliHLTConfiguration esdConf("TRD-Esd", "GlobalEsdConverter", afterTr.Data(), "-notree"); // root file writer AliHLTConfiguration writerConf("TRD-EsdFile", "EsdCollector", "TRD-Esd", "-directory hlt-trd-esd/"); - // root file writer (with esd friends and some day perhaps MC) - AliHLTConfiguration writerOffConf("TRD-OffEsdFile", "TRDEsdWriter", nextOffInput.Data(), "-datafile AliHLTTRDESDs.root -concatenate-events -concatenate-blocks"); + // root file writer (with esd friends) (you may use tr or trOff here) + AliHLTConfiguration writerOffConf("TRD-OffEsdFile", "TRDEsdWriter", afterTr.Data(), "-concatenate-events -concatenate-blocks"); + + + /////////////////////////////////////////////////////////////////////////////////////////////////// + // + // Init CDBManager and trigger + // + AliCDBManager * man = AliCDBManager::Instance(); + Int_t run = ExtractRunNumber(filename); + if(bRealData){ + man->SetDefaultStorage("alien://folder=/alice/data/2009/OCDB"); + }else{ + man->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); + man->SetSpecificStorage("GRP/GRP/Data", Form("local://%s",dataPath.Data())); + //rec.SetSpecificStorage("GRP/GRP/Data", Form("local://%s",gSystem->pwd())); + } + man->SetRun(run); + + if(bCosmics){ + // no magnetic field + AliExternalTrackParam::SetMostProbablePt(8.); + } + + // Find TRD triggers + TString filestring = filename; + if(useOnlyTRDtrigger){ + AliCDBEntry *grp_ctp = man->Get("GRP/CTP/Config"); + AliTriggerConfiguration *trg_conf = (AliTriggerConfiguration *)grp_ctp->GetObject(); + trg_conf->Print(); + TObjArray trg_masks = trg_conf->GetClasses(); // Reference!!! + std::vector triggerconfs; + for(Int_t iobj = 0; iobj < trg_masks.GetEntriesFast(); iobj++){ + + AliTriggerClass * trg_class = (AliTriggerClass*)trg_masks.UncheckedAt(iobj); + AliTriggerCluster * trg_clust = (AliTriggerCluster *)trg_class->GetCluster(); + + printf("ioj[%d]\n", iobj); trg_class->Print(0x0); + + if(TString(trg_class->GetName()).Contains("TRD")){ // cosmic run 2009 + triggerconfs.push_back(trg_class->GetMask()); + } + } + + Int_t itrg = 0; + printf("Number of Trigger Clusters including TRD: %d\n", (Int_t)triggerconfs.size()); + for(std::vector::iterator it = triggerconfs.begin(); it < triggerconfs.end(); it++) + printf("Trigger Mask %d for TRD: %d\n", itrg++, *it); + filestring += "?EventType=7"; + char triggerbuf[256]; + Int_t triggerval = 0; + for(std::vector::iterator it = triggerconfs.begin(); it < triggerconfs.end(); it++) + triggerval += *it; + sprintf(triggerbuf, "?Trigger=%d", triggerval); + filestring += triggerbuf; // This line does the trigger selection. It has to be uncommented if one wants to apply trigger selection + } + printf("Filename: %s\n", filestring.Data()); /////////////////////////////////////////////////////////////////////////////////////////////////// // // Init and run the reconstruction - // All but HLT reconstructio is switched off // AliReconstruction rec; - rec.SetInput(input); + rec.SetInput(filestring.Data()); rec.SetRunVertexFinder(kFALSE); rec.SetRunLocalReconstruction("HLT"); rec.SetRunTracking(":"); @@ -139,10 +276,18 @@ void rec_hlt_trd(const char* input) rec.SetRunQA(":"); rec.SetRunGlobalQA(kFALSE); rec.SetFillTriggerESD(kFALSE); - rec.SetDefaultStorage("local://$ALICE_ROOT/OCDB"); - rec.SetSpecificStorage("GRP/GRP/Data", Form("local://%s",GRPDir.Data())); - //rec.SetSpecificStorage("GRP/GRP/Data", Form("local://%s",gSystem->pwd())); rec.SetOption("HLT", option); rec.Run(); + + return 0; +} + +Int_t ExtractRunNumber(const TString str){ + TObjArray *ptoks = (TObjArray *)str.Tokenize("?"); + TString path = ((TObjString *)ptoks->UncheckedAt(0))->String(); + TObjArray *toks = (TObjArray *)path.Tokenize("/"); + TString fname = ((TObjString *)(toks->UncheckedAt(toks->GetEntriesFast() - 1)))->String(); + TString rstr = fname(2,9); + return rstr.Atoi(); } -- 2.31.1