From f2c0e243161e7116163fa53433d5116b0a39c54f Mon Sep 17 00:00:00 2001 From: sawenzel Date: Wed, 17 Jan 2018 12:12:39 +0100 Subject: [PATCH] Initial o2::tof::DigitizerTask shell (#2) Initial layout for the tof digitizer task. It compiles and runs: o2sim -m TOF ... root run_digi_tof.C --- Detectors/TOF/simulation/CMakeLists.txt | 2 + .../include/TOFSimulation/Digitizer.h | 2 + .../TOF/simulation/src/TOFSimulationLinkDef.h | 3 +- macro/run_digi_tof.C | 89 +++++++++++++++++++ 4 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 macro/run_digi_tof.C diff --git a/Detectors/TOF/simulation/CMakeLists.txt b/Detectors/TOF/simulation/CMakeLists.txt index e9e0ff9e8994d..61e83430e927e 100644 --- a/Detectors/TOF/simulation/CMakeLists.txt +++ b/Detectors/TOF/simulation/CMakeLists.txt @@ -5,11 +5,13 @@ O2_SETUP(NAME ${MODULE_NAME}) set(SRCS src/Detector.cxx src/Digitizer.cxx + src/DigitizerTask.cxx ) set(HEADERS include/TOFSimulation/Detector.h include/TOFSimulation/Digitizer.h + include/TOFSimulation/DigitizerTask.h ) SET(LINKDEF src/TOFSimulationLinkDef.h) diff --git a/Detectors/TOF/simulation/include/TOFSimulation/Digitizer.h b/Detectors/TOF/simulation/include/TOFSimulation/Digitizer.h index 38da402a4465c..5a271fd71356d 100644 --- a/Detectors/TOF/simulation/include/TOFSimulation/Digitizer.h +++ b/Detectors/TOF/simulation/include/TOFSimulation/Digitizer.h @@ -48,6 +48,8 @@ class Digitizer : public TObject Int_t getXshift(Int_t idigit) const { return mXshift[idigit]; } Int_t getZshift(Int_t idigit) const { return mZshift[idigit]; } + void setEventTime(double) {}; + void initParameters(); void printParameters(); diff --git a/Detectors/TOF/simulation/src/TOFSimulationLinkDef.h b/Detectors/TOF/simulation/src/TOFSimulationLinkDef.h index a10e6c265bc82..edf61ae814515 100644 --- a/Detectors/TOF/simulation/src/TOFSimulationLinkDef.h +++ b/Detectors/TOF/simulation/src/TOFSimulationLinkDef.h @@ -15,7 +15,8 @@ #pragma link off all functions; #pragma link C++ class o2::tof::Detector+; -#pragma link C++ class o2::tof::Digitizer+; +#pragma link C++ class o2::tof::Digitizer+; +#pragma link C++ class o2::tof::DigitizerTask+; #pragma link C++ class o2::Base::DetImpl+; #endif diff --git a/macro/run_digi_tof.C b/macro/run_digi_tof.C new file mode 100644 index 0000000000000..9178475a764af --- /dev/null +++ b/macro/run_digi_tof.C @@ -0,0 +1,89 @@ +#if !defined(__CLING__) || defined(__ROOTCLING__) +#include + +#include + +#include "FairLogger.h" +#include "FairRunAna.h" +#include "FairFileSource.h" +#include "FairRuntimeDb.h" +#include "FairParRootFileIo.h" +#include "FairSystemInfo.h" + +#include "TOFSimulation/DigitizerTask.h" +#endif + +void run_digi_tof(Int_t nEvents = 10, Float_t rate=50.e3) +{ + // if rate>0 then continuous simulation for this rate will be performed + + // Initialize logger + FairLogger* logger = FairLogger::GetLogger(); + logger->SetLogVerbosityLevel("LOW"); + logger->SetLogScreenLevel("DEBUG"); + + // Input and output file name + std::stringstream inputfile, outputfile, paramfile; + //inputfile << "AliceO2_" << mcEngine << ".mc_" << nEvents << "_event.root"; + //paramfile << "AliceO2_" << mcEngine << ".params_" << nEvents << ".root"; + //outputfile << "AliceO2_" << mcEngine << ".digi_" << nEvents << "_event.root"; + inputfile << "o2sim.root"; + paramfile << "o2sim_par.root"; + outputfile << "o2sim_digi.root"; + + // Setup timer + TStopwatch timer; + + // Setup FairRoot analysis manager + FairRunAna* fRun = new FairRunAna(); + FairFileSource* fFileSource = new FairFileSource(inputfile.str().c_str()); + fRun->SetSource(fFileSource); + fRun->SetOutputFile(outputfile.str().c_str()); + + if (rate > 0) { + fFileSource->SetEventMeanTime(1.e9 / rate); // is in us + } + + // Setup Runtime DB + FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); + FairParRootFileIo* parInput1 = new FairParRootFileIo(); + parInput1->open(paramfile.str().c_str()); + rtdb->setFirstInput(parInput1); + + // Setup digitizer + o2::tof::DigitizerTask* digi = new o2::tof::DigitizerTask(); +// digi->setContinuous(rate > 0); +// digi->setFairTimeUnitInNS(1.0); // tell in which units (wrt nanosecond) FAIT timestamps are + fRun->AddTask(digi); + + fRun->Init(); + + timer.Start(); + fRun->Run(); + + std::cout << std::endl << 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 << ""; + std::cout << maxMemory; + std::cout << "" << std::endl; + + timer.Stop(); + Double_t rtime = timer.RealTime(); + Double_t ctime = timer.CpuTime(); + + Float_t cpuUsage = ctime / rtime; + cout << ""; + cout << cpuUsage; + cout << "" << endl; + cout << endl << endl; + std::cout << "Macro finished succesfully" << std::endl; + + std::cout << endl << std::endl; + std::cout << "Output file is " << outputfile.str() << std::endl; + // std::cout << "Parameter file is " << parFile << std::endl; + std::cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl; +}