Commit 35281016 authored by Volker Friese's avatar Volker Friese
Browse files

Update run_reco.C and remove obsolete reco macros in macro/run. Refs #1874.

parent 7a120e0c
......@@ -9,6 +9,7 @@
#if !defined(__CLING__)
#include "CbmBuildEventsFromTracksReal.h"
#include "CbmBuildEventsIdeal.h"
#include "CbmBuildEventsQa.h"
#include "CbmDefs.h"
#include "CbmFindPrimaryVertex.h"
#include "CbmKF.h"
......@@ -16,6 +17,7 @@
#include "CbmL1StsTrackFinder.h"
#include "CbmLitFindGlobalTracks.h"
#include "CbmMCDataManager.h"
#include "CbmMatchRecoToMC.h"
#include "CbmMuchFindHitsGem.h"
#include "CbmMvdClusterfinder.h"
#include "CbmMvdHitfinder.h"
......@@ -29,6 +31,7 @@
#include "CbmStsFindTracks.h"
#include "CbmStsFindTracksEvents.h"
#include "CbmStsTrackFinder.h"
#include "CbmTaskBuildRawEvents.h"
#include "CbmTofSimpClusterizer.h"
#include "CbmTrdClusterFinder.h"
#include "CbmTrdHitProducer.h"
......@@ -198,50 +201,6 @@ void run_reco(TString input = "", Int_t nTimeSlices = -1, Int_t firstTimeSlice =
std::cout << "-I- " << myName << ": Added task " << evBuildRaw->GetName() << std::endl;
eventBased = kTRUE;
} //? Ideal raw event building
else if (sEvBuildRaw.EqualTo("Real2018", TString::ECaseCompare::kIgnoreCase)) {
CbmMcbm2018EventBuilder* evBuildRaw = new CbmMcbm2018EventBuilder();
evBuildRaw->SetFixedTimeWindow(500.);
evBuildRaw->SetTriggerMinNumberSts(1000);
evBuildRaw->SetUseBaseMuchDigi(kTRUE);
run->AddTask(evBuildRaw);
std::cout << "-I- " << myName << ": Added task " << evBuildRaw->GetName() << std::endl;
eventBased = kTRUE;
}
else if (sEvBuildRaw.EqualTo("Real2019", TString::ECaseCompare::kIgnoreCase)) {
CbmMcbm2019TimeWinEventBuilderTask* evBuildRaw = new CbmMcbm2019TimeWinEventBuilderTask();
//Choose between NoOverlap, MergeOverlap, AllowOverlap
evBuildRaw->SetEventOverlapMode(EOverlapMode::AllowOverlap);
// Remove detectors where digis not found
if (!useRich) evBuildRaw->RemoveDetector(kEventBuilderDetRich);
if (!useMuch) evBuildRaw->RemoveDetector(kEventBuilderDetMuch);
if (!usePsd) evBuildRaw->RemoveDetector(kEventBuilderDetPsd);
if (!useTof) evBuildRaw->RemoveDetector(kEventBuilderDetTof);
if (!useTrd) evBuildRaw->RemoveDetector(kEventBuilderDetTrd);
if (!useSts) {
std::cerr << "-E- " << myName << ": Sts must be present for raw event "
<< "building using ``Real2019'' option. Terminating macro." << std::endl;
return;
}
// Set STS as reference detector
evBuildRaw->SetReferenceDetector(kEventBuilderDetSts);
evBuildRaw->SetTsParameters(0.0, 1.e7, 0.0);
// Use CbmMuchDigi instead of CbmMuchBeamtimeDigi
evBuildRaw->ChangeMuchBeamtimeDigiFlag(kFALSE);
evBuildRaw->SetTriggerMinNumber(ECbmModuleId::kSts, 1000);
evBuildRaw->SetTriggerMaxNumber(ECbmModuleId::kSts, -1);
evBuildRaw->SetTriggerWindow(ECbmModuleId::kSts, -500, 500);
run->AddTask(evBuildRaw);
std::cout << "-I- " << myName << ": Added task " << evBuildRaw->GetName() << std::endl;
eventBased = kTRUE;
}
else if (sEvBuildRaw.EqualTo("Real", TString::ECaseCompare::kIgnoreCase)) {
CbmTaskBuildRawEvents* evBuildRaw = new CbmTaskBuildRawEvents();
......@@ -282,6 +241,7 @@ void run_reco(TString input = "", Int_t nTimeSlices = -1, Int_t firstTimeSlice =
} //? event-based reco
// ------------------------------------------------------------------------
// ----------- QA for raw event builder -----------------------------------
if (eventBased && useMC) {
CbmBuildEventsQA* evBuildQA = new CbmBuildEventsQA();
......
// --------------------------------------------------------------------------
//
// Macro for reconstruction of simulated raw data with L1 QA
//
// Default event-by-event reconstruction chain,
// defined in macro/run/modules/reconstruct.C
//
// The following naming conventions are assumed:
// Transport file: [dataset].tra.root
// Raw data file: [dataset].event.raw.root
// Parameter file: [dataset].par.root
// Output file: [dataset].rec.root
//
// V. Friese 10/06/2018
//
// --------------------------------------------------------------------------
void run_reco_event_qa(Int_t nEvents = 2,
TString dataset = "test",
TString setup = "sis100_electron") {
// ========================================================================
// Adjust this part according to your requirements
// --- Logger settings ----------------------------------------------------
TString logLevel = "INFO";
TString logVerbosity = "LOW";
// ------------------------------------------------------------------------
// ----- Environment --------------------------------------------------
TString myName = "run_reco_event"; // this macro's name for screen output
TString srcDir = gSystem->Getenv("VMCWORKDIR"); // top source directory
// ------------------------------------------------------------------------
// ----- In- and output file names ------------------------------------
TString traFile = dataset + ".tra.root";
TString rawFile = dataset + ".event.raw.root";
TString parFile = dataset + ".par.root";
TString outFile = dataset + ".rec.root";
// ------------------------------------------------------------------------
// ----- Load the geometry setup -------------------------------------
std::cout << std::endl;
std::cout << "-I- " << myName << ": Loading setup " << setup << std::endl;
CbmSetup::Instance()->LoadSetup(setup);
// You can modify the pre-defined setup by using
// CbmSetup::Instance()->RemoveModule(ESystemId) or
// CbmSetup::Instance()->SetModule(ESystemId, const char*, Bool_t) or
// CbmSetup::Instance()->SetActive(ESystemId, Bool_t)
// See the class documentation of CbmSetup.
// ------------------------------------------------------------------------
// ----- Parameter files as input to the runtime database -------------
std::cout << std::endl;
std::cout << "-I- " << myName << ": Defining parameter files " << std::endl;
TList* parFileList = new TList();
TString geoTag;
// - TRD digitisation parameters
if (CbmSetup::Instance()->GetGeoTag(kTrd, geoTag)) {
TObjString* trdFile =
new TObjString(srcDir + "/parameters/trd/trd_" + geoTag + ".digi.par");
parFileList->Add(trdFile);
std::cout << "-I- " << myName << ": Using parameter file "
<< trdFile->GetString() << std::endl;
}
// - TOF digitisation parameters
if (CbmSetup::Instance()->GetGeoTag(kTof, geoTag)) {
TObjString* tofBdfFile =
new TObjString(srcDir + "/parameters/tof/tof_" + geoTag + ".digibdf.par");
parFileList->Add(tofBdfFile);
std::cout << "-I- " << myName << ": Using parameter file "
<< tofBdfFile->GetString() << std::endl;
}
// ------------------------------------------------------------------------
// In general, the following parts need not be touched
// ========================================================================
// ----- Timer --------------------------------------------------------
TStopwatch timer;
timer.Start();
// ------------------------------------------------------------------------
// ---- Debug option -------------------------------------------------
gDebug = 0;
// ------------------------------------------------------------------------
// ----- FairRunAna ---------------------------------------------------
FairRunAna* run = new FairRunAna();
FairFileSource* inputSource = new FairFileSource(rawFile);
inputSource->AddFriend(traFile);
run->SetSource(inputSource);
run->SetOutputFile(outFile);
run->SetGenerateRunInfo(kTRUE);
run->SetGenerateRunInfo(kTRUE);
Bool_t hasFairMonitor = Has_Fair_Monitor();
if (hasFairMonitor) FairMonitor::GetMonitor()->EnableMonitor(kTRUE);
// ------------------------------------------------------------------------
// ----- Logger settings ----------------------------------------------
FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data());
// ------------------------------------------------------------------------
// ----- Mc Data Manager ------------------------------------------------
CbmMCDataManager* mcManager = new CbmMCDataManager("MCManager", 1);
mcManager->AddFile(traFile);
run->AddTask(mcManager);
// ------------------------------------------------------------------------
// ----- Reconstruction tasks -----------------------------------------
std::cout << std::endl;
TString macroName = srcDir + "/macro/run/modules/reconstruct.C";
std::cout << "Loading macro " << macroName << std::endl;
gROOT->LoadMacro(macroName);
Bool_t recoSuccess = gROOT->ProcessLine("reconstruct(kTRUE)");
if (!recoSuccess) {
std::cerr << "-E-" << myName << ": error in executing " << macroName
<< std::endl;
return;
}
std::cout << "-I-" << myName << ": " << macroName << " excuted successfully"
<< std::endl;
// ------------------------------------------------------------------------
// ----- Parameter database --------------------------------------------
std::cout << std::endl << std::endl;
std::cout << "-I- " << myName << ": Set runtime DB" << std::endl;
FairRuntimeDb* rtdb = run->GetRuntimeDb();
FairParRootFileIo* parIo1 = new FairParRootFileIo();
FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo();
parIo1->open(parFile.Data(), "UPDATE");
rtdb->setFirstInput(parIo1);
if (!parFileList->IsEmpty()) {
parIo2->open(parFileList, "in");
rtdb->setSecondInput(parIo2);
}
// ------------------------------------------------------------------------
// ----- Run initialisation -------------------------------------------
std::cout << std::endl;
std::cout << "-I- " << myName << ": Initialise run" << std::endl;
run->Init();
// ------------------------------------------------------------------------
rtdb->setOutput(parIo1);
rtdb->saveOutput();
rtdb->print();
// ----- Start run ----------------------------------------------------
std::cout << std::endl << std::endl;
std::cout << "-I- " << myName << ": Starting run" << std::endl;
run->Run(0, nEvents);
// ------------------------------------------------------------------------
// ----- Finish -------------------------------------------------------
timer.Stop();
Double_t rtime = timer.RealTime();
Double_t ctime = timer.CpuTime();
std::cout << std::endl << std::endl;
std::cout << "Macro finished successfully." << std::endl;
std::cout << "Output file is " << outFile << std::endl;
std::cout << "Parameter file is " << parFile << std::endl;
std::cout << "Real time " << rtime << " s, CPU time " << ctime << " s"
<< std::endl;
std::cout << std::endl;
std::cout << " Test passed" << std::endl;
std::cout << " All ok " << std::endl;
// ------------------------------------------------------------------------
// Extract the maximal used memory an add is as Dart measurement
// This line is filtered by CTest and the value send to CDash
FairSystemInfo sysInfo;
Float_t maxMemory = sysInfo.GetMaxMemory();
std::cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">";
std::cout << maxMemory;
std::cout << "</DartMeasurement>" << std::endl;
Float_t cpuUsage = ctime / rtime;
std::cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">";
std::cout << cpuUsage;
std::cout << "</DartMeasurement>" << std::endl;
RemoveGeoManager();
}
// --------------------------------------------------------------------------
//
// Macro for reconstruction of simulated events with standard settings
//
// HitProducers in MVD, RICH, TRD, TOF, ECAL
// Digitizer and HitFinder in STS
// FAST MC for ECAL
// STS track finding and fitting (L1 / KF)
// TRD track finding and fitting (L1 / KF)
// RICH ring finding (ideal) and fitting
// Global track finding (ideal), rich assignment
// Primary vertex finding (ideal)
// Matching of reconstructed and MC tracks in STS, RICH and TRD
//
// V. Friese 24/02/2006
// Version 24/04/2007 (V. Friese)
//
// --------------------------------------------------------------------------
void run_reco_new(
Int_t nEvents = 2,
const char* setupName = "sis100_electron",
// const char* setupName = "sis100_debug",
// const char* setupName = "sis100_hadron",
// const char* setupName = "sis100_muon_jpsi",
// const char* setupName = "sis100_muon_lmvm",
const char* inputFile = "") {
// ========================================================================
// Adjust this part according to your requirements
// --- Logger settings ----------------------------------------------------
TString logLevel = "INFO";
TString logVerbosity = "LOW";
// ------------------------------------------------------------------------
// ----- Environment --------------------------------------------------
TString myName = "run_reco_new"; // this macro's name for screen output
TString srcDir = gSystem->Getenv("VMCWORKDIR"); // top source directory
// ------------------------------------------------------------------------
// ----- In- and output file names ------------------------------------
TString inFile = ""; // give here or as argument; otherwise default is taken
TString outDir = "data/";
TString outFile =
outDir + setupName + "_test.eds.root"; // Output file (reco)
TString parFile = outDir + setupName + "_params.root"; // Parameter file
// ------------------------------------------------------------------------
// ----- Load the geometry setup -------------------------------------
std::cout << std::endl;
std::cout << "-I- " << myName << ": Loading setup " << setup << std::endl;
CbmSetup::Instance()->LoadSetup(setup);
CbmSetup* setup = CbmSetup::Instance();
// ------------------------------------------------------------------------
// ----- Parameter files as input to the runtime database -------------
std::cout << std::endl;
std::cout << "-I- " << myName << ": Defining parameter files " << std::endl;
TList* parFileList = new TList();
TString geoTag;
// - TRD digitisation parameters
if (setup->GetGeoTag(kTrd, geoTag)) {
TObjString* trdFile =
new TObjString(srcDir + "/parameters/trd/trd_" + geoTag + ".digi.par");
parFileList->Add(trdFile);
std::cout << "-I- " << myName << ": Using parameter file "
<< trdFile->GetString() << std::endl;
}
// - TOF digitisation parameters
if (setup->GetGeoTag(kTof, geoTag)) {
TObjString* tofBdfFile =
new TObjString(srcDir + "/parameters/tof/tof_" + geoTag + ".digibdf.par");
parFileList->Add(tofBdfFile);
std::cout << "-I- " << myName << ": Using parameter file "
<< tofBdfFile->GetString() << std::endl;
}
// ------------------------------------------------------------------------
// In general, the following parts need not be touched
// ========================================================================
// ----- Timer --------------------------------------------------------
TStopwatch timer;
timer.Start();
// ------------------------------------------------------------------------
// ---- Debug option -------------------------------------------------
gDebug = 0;
// ------------------------------------------------------------------------
// ----- Input file ---------------------------------------------------
std::cout << std::endl;
TString defaultInputFile = "data/";
defaultInputFile = defaultInputFile + setupName + "_test.mc.root";
if (inFile.IsNull()) { // Not defined in the macro explicitly
if (strcmp(inputFile, "") == 0) { // not given as argument to the macro
inFile = defaultInputFile;
} else
inFile = inputFile;
}
std::cout << "-I- " << myName << ": Using input file " << inFile << std::endl;
// ------------------------------------------------------------------------
// ----- FairRunAna ---------------------------------------------------
FairRunAna* run = new FairRunAna();
FairFileSource* inputSource = new FairFileSource(inFile);
run->SetSource(inputSource);
run->SetOutputFile(outFile);
run->SetGenerateRunInfo(kTRUE);
// Define output file for FairMonitor histograms
TString monitorFile {outFile};
monitorFile.ReplaceAll("eds", "eds.monitor");
FairMonitor::GetMonitor()->EnableMonitor(kTRUE, monitorFile);
// ------------------------------------------------------------------------
// ----- Logger settings ----------------------------------------------
FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data());
// ------------------------------------------------------------------------
// ----- Mc Data Manager ------------------------------------------------
CbmMCDataManager* mcManager = new CbmMCDataManager("MCManager", 1);
mcManager->AddFile(inFile);
run->AddTask(mcManager);
// ------------------------------------------------------------------------
// ----- Digitisers ---------------------------------------------------
std::cout << std::endl;
TString macroName = gSystem->Getenv("VMCWORKDIR");
macroName += "/macro/run/modules/digitize.C";
std::cout << "Loading macro " << macroName << std::endl;
gROOT->LoadMacro(macroName);
gROOT->ProcessLine("digitize()");
// ------------------------------------------------------------------------
// ----- Reconstruction tasks -----------------------------------------
std::cout << std::endl;
macroName = srcDir + "/macro/run/modules/reconstruct.C";
std::cout << "Loading macro " << macroName << std::endl;
gROOT->LoadMacro(macroName);
Bool_t recoSuccess = gROOT->ProcessLine("reconstruct()");
if (!recoSuccess) {
std::cerr << "-E-" << myName << ": error in executing " << macroName
<< std::endl;
return;
}
std::cout << "-I-" << myName << ": " << macroName << " excuted successfully"
<< std::endl;
// ------------------------------------------------------------------------
// ----- Parameter database --------------------------------------------
std::cout << std::endl << std::endl;
std::cout << "-I- " << myName << ": Set runtime DB" << std::endl;
FairRuntimeDb* rtdb = run->GetRuntimeDb();
FairParRootFileIo* parIo1 = new FairParRootFileIo();
FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo();
parIo1->open(parFile.Data());
parIo2->open(parFileList, "in");
rtdb->setFirstInput(parIo1);
rtdb->setSecondInput(parIo2);
rtdb->setOutput(parIo1);
rtdb->saveOutput();
rtdb->print();
// ------------------------------------------------------------------------
// ----- Run initialisation -------------------------------------------
std::cout << std::endl;
std::cout << "-I- " << myName << ": Initialise run" << std::endl;
run->Init();
// ------------------------------------------------------------------------
// ----- Start run ----------------------------------------------------
std::cout << std::endl << std::endl;
std::cout << "-I- " << myName << ": Starting run" << std::endl;
run->Run(0, nEvents);
// ------------------------------------------------------------------------
// ----- Finish -------------------------------------------------------
timer.Stop();
Double_t rtime = timer.RealTime();
Double_t ctime = timer.CpuTime();
std::cout << std::endl << std::endl;
std::cout << "Macro finished succesfully." << std::endl;
std::cout << "Output file is " << outFile << std::endl;
std::cout << "Parameter file is " << parFile << std::endl;
std::cout << "Real time " << rtime << " s, CPU time " << ctime << " s"
<< std::endl;
std::cout << std::endl;
std::cout << " Test passed" << std::endl;
std::cout << " All ok " << std::endl;
// ------------------------------------------------------------------------
// ----- Resource monitoring ------------------------------------------
// Extract the maximal used memory an add is as Dart measurement
// This line is filtered by CTest and the value send to CDash
FairSystemInfo sysInfo;
Float_t maxMemory = sysInfo.GetMaxMemory();
std::cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">";
std::cout << maxMemory;
std::cout << "</DartMeasurement>" << std::endl;
Float_t cpuUsage = ctime / rtime;
std::cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">";
std::cout << cpuUsage;
std::cout << "</DartMeasurement>" << std::endl;
FairMonitor* tempMon = FairMonitor::GetMonitor();
tempMon->Print();
RemoveGeoManager();
}
// --------------------------------------------------------------------------
//
// Macro for reconstruction of simulated time slices
// Using event building from STS digis and event-based reconstruction chain
//
// STS chain only:
// Event building from STS digis
// STS cluster finder (event-based)
// STS hit finder (event-based)
// STS track finder (L1)
// Simple QA
//
// Run the macro run_digi_tb.C before to generate the input file .raw.root.
//
// V. Friese 14/03/2017
//
// --------------------------------------------------------------------------
using std::cout;
using std::endl;
void run_reco_tb_digi(TString dataSet = "test", Int_t nSlices = -1) {
// =========================================================================
// === Settings ===
// =========================================================================
// --- File names
TString inFile = dataSet + ".raw.root"; // Input file (MC events)
TString parFile = dataSet + ".par.root"; // Parameter file
TString outFile = dataSet + ".rec.root"; // Output file
// Log level
TString logLevel = "INFO"; // switch to DEBUG or DEBUG1,... for more info
TString logVerbosity = "LOW"; // switch to MEDIUM or HIGH for more info
// ---- Debug option -------------------------------------------------
gDebug = 0;
// ========================================================================
// ----- Timer --------------------------------------------------------
TStopwatch timer;
timer.Start();
// ------------------------------------------------------------------------
// ----- Reconstruction run -------------------------------------------
FairRunAna* run = new FairRunAna();
FairFileSource* inputSource = new FairFileSource(inFile);
run->SetSource(inputSource);
run->SetOutputFile(outFile);
run->SetGenerateRunInfo(kTRUE);
TString monitorFile {outFile};
monitorFile.ReplaceAll("rec", "rec.monitor");
FairMonitor::GetMonitor()->EnableMonitor(kTRUE, monitorFile);
// ------------------------------------------------------------------------
// ---- Set the log level
FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data());
// =========================================================================
// === Reconstruction chain ===
// =========================================================================
// --- Event builder (from digis)
// --- In order to perform event-by-event reconstruction, use the
// --- ideal event builder (CbmBuildEventsIdeal) instead.
run->AddTask(new CbmBuildEventsSimple());
// --- STS reconstruction (event mode)
CbmStsReco* stsReco = new CbmStsReco();
stsReco->SetMode(kCbmEvent);
run->AddTask(stsReco);
// --- STS track finder (event-based)
run->AddTask(new CbmKF());
run->AddTask(new CbmL1());
CbmStsTrackFinder* stsTrackFinder = new CbmL1StsTrackFinder();
FairTask* stsFindTracks = new CbmStsFindTracksEvents(stsTrackFinder);
run->AddTask(stsFindTracks);
// --- Simple QA task to check basics
run->AddTask(new CbmStsRecoQa());
// ----- Parameter database --------------------------------------------
FairRuntimeDb* rtdb = run->GetRuntimeDb();
FairParRootFileIo* parIo1 = new FairParRootFileIo();
parIo1->open(parFile.Data(), "UPDATE");
rtdb->setFirstInput(parIo1);
// ------------------------------------------------------------------------