diff --git a/macro/beamtime/mcbm2020/mcbm_build_and_reco_kronos.C b/macro/beamtime/mcbm2020/mcbm_build_and_reco_kronos.C index f97995bd87100f35087049396b4d3cfa63866a70..e0e939d60ff3c871c176b941f31c9422199fa649 100644 --- a/macro/beamtime/mcbm2020/mcbm_build_and_reco_kronos.C +++ b/macro/beamtime/mcbm2020/mcbm_build_and_reco_kronos.C @@ -1,5 +1,13 @@ -void mcbm_build_and_reco_kronos(UInt_t uRunIdx = 0, - Int_t nEvents = 0, +// -------------------------------------------------------------------------- +// +// Macro for reconstruction of mcbm data (2020) +// Combined reconstruction (Event building + cluster + hit finder) for different subsystems. +// +// -------------------------------------------------------------------------- + + +void mcbm_build_and_reco_kronos(UInt_t uRunIdx = 28, + Int_t nEvents = 300, TString outDir = "data/") { UInt_t uRunId = 0; TString fileName = "data/unp_mcbm_0.root"; @@ -49,7 +57,7 @@ void mcbm_build_and_reco_kronos(UInt_t uRunIdx = 0, // MC file TString srcDir = gSystem->Getenv("VMCWORKDIR"); - + TString paramDir = srcDir + "/macro/beamtime/mcbm2020/"; // ----- Timer -------------------------------------------------------- TStopwatch timer; timer.Start(); @@ -149,24 +157,35 @@ void mcbm_build_and_reco_kronos(UInt_t uRunIdx = 0, fRun->AddTask(eventBuilder); // ----- Parameter database -------------------------------------------- - TString parFile = + + TString parFileIn = Form("/lustre/cbm/users/ploizeau/mcbm2020/unp_evt_data_7f229b3f_20201103/" "unp_mcbm_params_%i.root", uRunId); + TString parFileOut = Form("reco_mcbm_params_%i.root", uRunId); + + FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); FairParRootFileIo* parIo1 = new FairParRootFileIo(); - parIo1->open(parFile.Data(), "UPDATE"); + FairParRootFileIo* parIo3 = new FairParRootFileIo(); + parIo1->open(parFileIn.Data(), "READ"); + parIo3->open(parFileOut.Data(), "RECREATE"); rtdb->setFirstInput(parIo1); - // ------------------------------------------------------------------------ + rtdb->setOutput(parIo3); + + //----------------------------------Reconstruction------------------------------------- - TString geoFileSts = - "/lustre/cbm/users/alberica/cbmroot/macro/beamtime/mcbm2020/data/" - "test.geo.root"; // to be created by a simulation run + + + // ------------------------------------------------------------------------ + TString geoFileSts = paramDir + "mcbm2020_reco.geo.root"; + //TString geoFileSts = + // "/lustre/cbm/users/alberica/cbmroot/macro/beamtime/mcbm2020/data/test.geo.root"; // to be created by a simulation run fRun->SetGeomFile(geoFileSts); // ----- Local reconstruction in STS ---------------------------------- CbmRecoSts* recoSts = new CbmRecoSts(); - recoSts->SetMode(kCbmRecoEvent); + // recoSts->SetMode(kCbmRecoEvent); //recoSts->SetTimeCutDigisAbs( 20 );// cluster finder: time cut in ns //recoSts->SetTimeCutClustersAbs(20.); // hit finder: time cut in ns @@ -204,6 +223,20 @@ void mcbm_build_and_reco_kronos(UInt_t uRunIdx = 0, std::cout << "-I- : Added task " << recoSts->GetName() << std::endl; // ------------------------------------------------------------------------ + + // ----- Local reconstruction in MUCH --------------------------------- + Int_t flag = 1; + TString parDir = TString(gSystem->Getenv("VMCWORKDIR")) + TString("/parameters"); + TString muchDigiFile(parDir + "/much/much_v19c_mcbm_digi_sector.root"); // MUCH digi file + CbmMuchFindHitsGem* muchFindHits = new CbmMuchFindHitsGem(muchDigiFile.Data(), flag); + muchFindHits->SetBeamTimeDigi(kTRUE); + fRun->AddTask(muchFindHits); + std::cout << "-I- : Added task " << muchFindHits->GetName() << std::endl; + + //-------------------------------------------------------- + + + // ----- Intialise and run -------------------------------------------- fRun->Init(); diff --git a/macro/beamtime/mcbm2020/mcbm_event_reco.C b/macro/beamtime/mcbm2020/mcbm_event_reco.C new file mode 100644 index 0000000000000000000000000000000000000000..575e6ea955bd1c4536fa3da734a1896ba59d2c4d --- /dev/null +++ b/macro/beamtime/mcbm2020/mcbm_event_reco.C @@ -0,0 +1,194 @@ +// -------------------------------------------------------------------------- +// +// Macro for reconstruction of mcbm data (2020) +// MUCH STS local reconstruction (Event Building (Florian one) + cluster + hit finder) for the time being +// +// -------------------------------------------------------------------------- + +void mcbm_event_reco(Int_t runId = 831, Int_t nTimeslices = 300) { + + // --- Logger settings ---------------------------------------------------- + TString logLevel = "INFO"; + TString logVerbosity = "LOW"; + // ------------------------------------------------------------------------ + + + // ----- Environment -------------------------------------------------- + TString myName = "mcbm_reco"; // this macro's name for screen output + TString srcDir = gSystem->Getenv("VMCWORKDIR"); // top source directory + TString paramDir = srcDir + "/macro/beamtime/mcbm2020/"; + // TString srcDir1 = gSystem->Getenv("SLURM_INDEX"); // ------------------------------------------------------------------------ + + + // ----- In- and output file names ------------------------------------ + TString inFile = Form("./data/unp_mcbm_%i.root", runId); + TString parFile = Form("./data/unp_mcbm_params_%i.root", runId); + TString geoFile = paramDir + "mcbm2020_reco.geo.root"; // Created in sim. run + TString outFile = Form("./data/reco_mcbm_%i.root", runId); + // ------------------------------------------------------------------------ + + + // ------------------------------------------------------------------------ + TString parDir = TString(gSystem->Getenv("VMCWORKDIR")) + TString("/parameters"); + TString muchDigiFile(parDir + "/much/much_v19c_mcbm_digi_sector.root"); // MUCH digi file + + // ----- Timer -------------------------------------------------------- + TStopwatch timer; + timer.Start(); + // ------------------------------------------------------------------------ + + + // ---- Debug option ------------------------------------------------- + gDebug = 0; + // ------------------------------------------------------------------------ + + + // ----- FairRunAna --------------------------------------------------- + FairRunAna* run = new FairRunAna(); + FairFileSource* inputSource = new FairFileSource(inFile); + run->SetSource(inputSource); + + run->SetOutputFile(outFile); + //run->SetGenerateRunInfo(kTRUE); + run->SetGeomFile(geoFile); + + TString monitorFile {outFile}; + monitorFile.ReplaceAll("rec", "rec.monitor"); + FairMonitor::GetMonitor()->EnableMonitor(kTRUE, monitorFile); + // ----------------------------------------------------------------------- + + + // ----- Logger settings ---------------------------------------------- + FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data()); + FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data()); + // ------------------------------------------------------------------------ + + //--------------------event builder-------------------// + CbmMcbm2018EventBuilder* eventBuilder = new CbmMcbm2018EventBuilder(); + // eventBuilder->SetEventBuilderAlgo(EventBuilderAlgo::MaximumTimeGap); + //eventBuilder->SetMaximumTimeGap(50.); + eventBuilder->SetEventBuilderAlgo(EventBuilderAlgo::FixedTimeWindow); + eventBuilder->SetFixedTimeWindow(200.); + eventBuilder->SetTriggerMinNumberT0(1); + //eventBuilder->SetTriggerMinNumberSts(0); + eventBuilder->SetTriggerMinNumberMuch(1); + eventBuilder->SetTriggerMinNumberTof(10); + run->AddTask(eventBuilder); + + // ----- Reconstruction tasks ----------------------------------------- + + // ------------------------------------------------------------------------ + Int_t flag = 1; + CbmMuchFindHitsGem* muchFindHits = new CbmMuchFindHitsGem(muchDigiFile.Data(), flag); + muchFindHits->SetBeamTimeDigi(kTRUE); + run->AddTask(muchFindHits); + std::cout << "-I- : Added task " << muchFindHits->GetName() << std::endl; + //------------------------------------------------------------------------------- + + + // ----- Local reconstruction in STS ---------------------------------- + CbmRecoSts* recoSts = new CbmRecoSts(); + // recoSts->SetMode(kCbmRecoEvent); + + //recoSts->SetTimeCutDigisAbs( 20 );// cluster finder: time cut in ns + //recoSts->SetTimeCutClustersAbs(20.); // hit finder: time cut in ns + + // ASIC params: #ADC channels, dyn. range, threshold, time resol., dead time, + // noise RMS, zero-threshold crossing rate + auto parAsic = + new CbmStsParAsic(32, 75000., 3000., 5., 800., 1000., 3.9789e-3); + + // Module params: number of channels, number of channels per ASIC + auto parMod = new CbmStsParModule(2048, 128); + parMod->SetAllAsics(*parAsic); + recoSts->UseModulePar(parMod); + + // Sensor params + auto sensorPar = new CbmStsParSensor(CbmStsSensorClass::kDssdStereo); + sensorPar->SetPar(0, 6.2092); // Extension in x + sensorPar->SetPar(1, 6.2); // Extension in y + sensorPar->SetPar(2, 0.03); // Extension in z + sensorPar->SetPar(3, 5.9692); // Active size in y + sensorPar->SetPar(4, 1024.); // Number of strips front side + sensorPar->SetPar(5, 1024.); // Number of strips back side + sensorPar->SetPar(6, 0.0058); // Strip pitch front side + sensorPar->SetPar(7, 0.0058); // Strip pitch back side + sensorPar->SetPar(8, 7.5); // Stereo angle front side + sensorPar->SetPar(9, 0.0); // Stereo angle back side + recoSts->UseSensorPar(sensorPar); + + // Sensor conditions: full depletion voltage, bias voltage, temperature, + // coupling capacitance, inter-strip capacitance + auto sensorCond = new CbmStsParSensorCond(70., 140., 268., 17.5, 1.); + recoSts->UseSensorCond(sensorCond); + + fRun->AddTask(recoSts); + std::cout << "-I- : Added task " << recoSts->GetName() << 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); + // ------------------------------------------------------------------------ + + + // ----- 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, nTimeslices); + // ------------------------------------------------------------------------ + + + // ----- Finish ------------------------------------------------------- + timer.Stop(); + FairMonitor::GetMonitor()->Print(); + 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 " << parFileOut << 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; + // ------------------------------------------------------------------------ + + + // ----- Function needed for CTest runtime dependency ----------------- + // RemoveGeoManager(); + // ------------------------------------------------------------------------ +} diff --git a/macro/beamtime/mcbm2020/mcbm_reco.C b/macro/beamtime/mcbm2020/mcbm_reco.C index b4a441da7125f364394a2015c6714a0923d2bba1..dae56157a633b15da928ae7244054bce89a77645 100644 --- a/macro/beamtime/mcbm2020/mcbm_reco.C +++ b/macro/beamtime/mcbm2020/mcbm_reco.C @@ -1,11 +1,12 @@ // -------------------------------------------------------------------------- // -// Macro for reconstruction of mcbm data (2019) -// Only STS local reconstruction (cluster + hit finder) for the time being +// Macro for reconstruction of mcbm data (2020) +// Combined reconstruction (cluster + hit finder) for different subsystems. // // -------------------------------------------------------------------------- -void mcbm_reco(Int_t runId = 812, Int_t nTimeslices = 0) { + +void mcbm_reco(Int_t runId = 831, Int_t nTimeslices = 0) { // --- Logger settings ---------------------------------------------------- TString logLevel = "INFO"; @@ -45,7 +46,7 @@ void mcbm_reco(Int_t runId = 812, Int_t nTimeslices = 0) { run->SetSource(inputSource); run->SetOutputFile(outFile); - run->SetGenerateRunInfo(kTRUE); + // run->SetGenerateRunInfo(kTRUE); run->SetGeomFile(geoFile); TString monitorFile {outFile}; @@ -62,6 +63,15 @@ void mcbm_reco(Int_t runId = 812, Int_t nTimeslices = 0) { // ----- Reconstruction tasks ----------------------------------------- + // ----- Local reconstruction in MUCH --------------------------------- + Int_t flag = 1; + TString parDir = TString(gSystem->Getenv("VMCWORKDIR")) + TString("/parameters"); + TString muchDigiFile(parDir + "/much/much_v19c_mcbm_digi_sector.root"); // MUCH digi file + CbmMuchFindHitsGem* muchFindHits = new CbmMuchFindHitsGem(muchDigiFile.Data(), flag); + muchFindHits->SetBeamTimeDigi(kTRUE); + run->AddTask(muchFindHits); + std::cout << "-I- : Added task " << muchFindHits->GetName() << std::endl; + //-------------------------------------------------------- // ----- Local reconstruction in STS ---------------------------------- CbmRecoSts* recoSts = new CbmRecoSts(); @@ -102,7 +112,6 @@ void mcbm_reco(Int_t runId = 812, Int_t nTimeslices = 0) { // ------------------------------------------------------------------------ - // ----- Local reconstruction in MUCH --------------------------------- // ------------------------------------------------------------------------ @@ -144,6 +153,7 @@ void mcbm_reco(Int_t runId = 812, Int_t nTimeslices = 0) { FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo(); parIo1->open(parFile.Data(), "UPDATE"); rtdb->setFirstInput(parIo1); + // ------------------------------------------------------------------------ @@ -172,7 +182,7 @@ void mcbm_reco(Int_t runId = 812, Int_t nTimeslices = 0) { 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 << "Parameter file is " << parFileOut << std::endl; std::cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << std::endl; std::cout << std::endl; diff --git a/macro/beamtime/mcbm2020/mcbm_reco_kronos.C b/macro/beamtime/mcbm2020/mcbm_reco_kronos.C index 2b8a0fec954c13a4c1a152309dd496cb14782174..4543e66e1ccbef0f76562b13d5e29d562d81e01c 100644 --- a/macro/beamtime/mcbm2020/mcbm_reco_kronos.C +++ b/macro/beamtime/mcbm2020/mcbm_reco_kronos.C @@ -1,11 +1,11 @@ // -------------------------------------------------------------------------- // -// Macro for reconstruction of mcbm data (2019) -// Only STS local reconstruction (cluster + hit finder) for the time being +// Macro for reconstruction of mcbm data (2020) +// Combined reconstruction (cluster + hit finder) for different subsystems. // // -------------------------------------------------------------------------- -void mcbm_reco(Int_t runId = 812, Int_t nTimeslices = 0) { +void mcbm_reco_kronos(Int_t runId = 831, Int_t nTimeslices = 0) { // --- Logger settings ---------------------------------------------------- TString logLevel = "INFO"; @@ -16,18 +16,21 @@ void mcbm_reco(Int_t runId = 812, Int_t nTimeslices = 0) { // ----- Environment -------------------------------------------------- TString myName = "mcbm_reco"; // this macro's name for screen output TString srcDir = gSystem->Getenv("VMCWORKDIR"); // top source directory - // TString srcDir1 = gSystem->Getenv("SLURM_INDEX"); // ------------------------------------------------------------------------ + TString paramDir = srcDir + "/macro/beamtime/mcbm2020/"; + // TString srcDir1 = gSystem->Getenv("SLURM_INDEX"); + // ------------------------------------------------------------------------ // ----- In- and output file names ------------------------------------ TString inFile = Form("/lustre/cbm/users/ploizeau/mcbm2020/" "unp_evt_data_7f229b3f_20201103/unp_mcbm_%i.root", runId); - TString parFile = + TString parFileIn = Form("/lustre/cbm/users/ploizeau/mcbm2020/unp_evt_data_7f229b3f_20201103/" "unp_mcbm_params_%i.root", runId); - TString geoFile = "./mcbm2020_reco.geo.root"; // Created by a simulation run + TString parFileOut = Form("reco_mcbm_params_%i.root", runId); + TString geoFile = paramDir + "mcbm2020_reco.geo.root"; // Created in sim. run TString outFile = Form("./data/reco_mcbm_%i.root", runId); // ------------------------------------------------------------------------ @@ -49,7 +52,7 @@ void mcbm_reco(Int_t runId = 812, Int_t nTimeslices = 0) { run->SetSource(inputSource); run->SetOutputFile(outFile); - run->SetGenerateRunInfo(kTRUE); + //run->SetGenerateRunInfo(kTRUE); run->SetGeomFile(geoFile); TString monitorFile {outFile}; @@ -66,6 +69,16 @@ void mcbm_reco(Int_t runId = 812, Int_t nTimeslices = 0) { // ----- Reconstruction tasks ----------------------------------------- + // ----- Local reconstruction in MUCH --------------------------------- + Int_t flag = 1; + TString parDir = TString(gSystem->Getenv("VMCWORKDIR")) + TString("/parameters"); + TString muchDigiFile(parDir + "/much/much_v19c_mcbm_digi_sector.root"); // MUCH digi file + CbmMuchFindHitsGem* muchFindHits = new CbmMuchFindHitsGem(muchDigiFile.Data(), flag); + muchFindHits->SetBeamTimeDigi(kTRUE); + run->AddTask(muchFindHits); + std::cout << "-I- : Added task " << muchFindHits->GetName() << std::endl; + + //-------------------------------------------------------- // ----- Local reconstruction in STS ---------------------------------- CbmRecoSts* recoSts = new CbmRecoSts(); @@ -106,8 +119,6 @@ void mcbm_reco(Int_t runId = 812, Int_t nTimeslices = 0) { // ------------------------------------------------------------------------ - // ----- Local reconstruction in MUCH --------------------------------- - // ------------------------------------------------------------------------ // ----- Local reconstruction in TRD ---------------------------------- @@ -146,10 +157,15 @@ void mcbm_reco(Int_t runId = 812, Int_t nTimeslices = 0) { FairRuntimeDb* rtdb = run->GetRuntimeDb(); FairParRootFileIo* parIo1 = new FairParRootFileIo(); FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo(); - parIo1->open(parFile.Data(), "UPDATE"); - rtdb->setFirstInput(parIo1); // ------------------------------------------------------------------------ + FairParRootFileIo* parIo3 = new FairParRootFileIo(); + parIo1->open(parFileIn.Data(), "READ"); + parIo3->open(parFileOut.Data(), "RECREATE"); + rtdb->setFirstInput(parIo1); + rtdb->setOutput(parIo3); + + //-------------------------------------------------------------------------- // ----- Run initialisation ------------------------------------------- std::cout << std::endl; @@ -176,7 +192,7 @@ void mcbm_reco(Int_t runId = 812, Int_t nTimeslices = 0) { 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 << "Parameter file is " << parFileOut << std::endl; std::cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << std::endl; std::cout << std::endl;