38#include <fairlogger/Logger.h>
70 LOG(info) <<
"HMPID Write Raw File From Root sim Digits vector - init()";
73 mBaseRootFileName = ic.
options().
get<std::string>(
"in-file");
74 mBaseFileName = ic.
options().
get<std::string>(
"outfile");
75 mDirectoryName = ic.
options().
get<std::string>(
"outdir");
76 mFileFor = ic.
options().
get<std::string>(
"file-for");
77 mDumpDigits = ic.
options().
get<
bool>(
"dump-digits");
78 mSkipEmpty = ic.
options().
get<
bool>(
"skip-empty");
81 if (!std::filesystem::exists(mDirectoryName)) {
82 if (!std::filesystem::create_directories(mDirectoryName)) {
83 LOG(fatal) <<
"could not create output directory " << mDirectoryName;
85 LOG(info) <<
"created output directory " << mDirectoryName;
100 TFile* fdig = TFile::Open(mBaseRootFileName.data());
101 assert(fdig !=
nullptr);
102 LOG(info) <<
"Open Root digits file " << mBaseRootFileName.data();
103 mDigTree = (TTree*)fdig->Get(
"o2sim");
110void DigitsToRawSpec::readRootFile()
112 std::vector<o2::hmpid::Digit> digitsPerEvent;
113 std::vector<o2::hmpid::Digit>
digits, *hmpBCDataPtr = &
digits;
114 std::vector<o2::hmpid::Trigger> interactions, *interactionsPtr = &interactions;
117 mDigTree->SetBranchAddress(
"InteractionRecords", &interactionsPtr);
118 LOG(info) <<
"Number of Interaction Records vectors in the simulation file :" << mDigTree->GetEntries();
119 for (
int ient = 0; ient < mDigTree->GetEntries(); ient++) {
120 mDigTree->GetEntry(ient);
121 LOG(info) <<
"Interactions records in simulation :" << interactions.size();
122 for (
auto a : interactions) {
127 mDigTree->SetBranchAddress(
"HMPDigit", &hmpBCDataPtr);
128 LOG(
debug) <<
"Number of entries in the simulation file :" << mDigTree->GetEntries();
131 for (
int ient = 0; ient < mDigTree->GetEntries(); ient++) {
132 mDigTree->GetEntry(ient);
135 LOG(info) <<
"The Entry :" << ient <<
" doesn't have digits !";
139 std::ofstream dumpfile;
140 dumpfile.open(
"/tmp/hmpDumpDigits.dat");
142 dumpfile <<
"Trigger Orbit=" <<
e.getOrbit() <<
" BC=" <<
e.getBc() << std::endl;
143 for (
int i =
e.getFirstEntry();
i <=
e.getLastEntry();
i++) {
144 dumpfile <<
digits.at(
i) << std::endl;
150 LOG(info) <<
"For the entry = " << ient <<
" there are " << nbc <<
" DIGITS stored.";
153 digitsPerEvent.clear();
154 for (
int i =
e.getFirstEntry();
i <=
e.getLastEntry();
i++) {
155 digitsPerEvent.push_back(
digits[
i]);
157 LOG(
debug) <<
"Orbit =" <<
e.getOrbit() <<
" BC =" <<
e.getBc() <<
" Digits =" << digitsPerEvent.size();
158 if (digitsPerEvent.size() == 0) {
159 LOG(info) <<
"Empty event !" <<
e;
162 mDigitsReceived += digitsPerEvent.size();
164 if (mDigitsReceived !=
digits.size()) {
165 LOG(warning) <<
"Digits outside the events defined !";
168 mExTimer.
logMes(
"End of Write raw file Job !");
191 std::vector<o2::framework::InputSpec> inputs;
192 std::vector<o2::framework::OutputSpec> outputs;
199 Options{{
"outdir", VariantType::String,
"./", {
"base dir for output file"}},
200 {
"file-for", VariantType::String,
"all", {
"single file per: all,flp,link,crorcendpoint"}},
201 {
"outfile", VariantType::String,
"HMP", {
"base name for output file"}},
202 {
"in-file", VariantType::String,
"hmpiddigits.root", {
"name of the input sim root file"}},
203 {
"dump-digits", VariantType::Bool,
false, {
"out the digits file in /tmp/hmpDumpDigits.dat"}},
204 {
"skip-empty", VariantType::Bool,
false, {
"skip empty events"}}}};
A raw page parser for DPL input.
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char e
Header of the General Run Parameters object.
Definition of the Names Generator class.
static std::string getGRPFileName(const std::string_view prefix=STANDARDSIMPREFIX)
T get(const char *key) const
ConfigParamRegistry const & options()
ServiceRegistryRef services()
The services registry associated with this processing context.
void endOfStream(framework::EndOfStreamContext &ec) override
This is invoked whenever we have an EndOfStream event.
void run(framework::ProcessingContext &pc) final
void init(framework::InitContext &ic) final
void stop()
stop : stops the timer
void start()
start : starts the timer
void logMes(std::string const message)
static constexpr int MAXEQUIPMENTS
void codeEventChunkDigits(std::vector< o2::hmpid::Digit > &digits, InteractionRecord ir)
o2::raw::RawFileWriter & getWriter()
void dumpResults(const std::string &outputFileName)
Dumps the results of the last coding.
void setSkipEmptyEvents(bool Skip)
void openOutputStream(const std::string &outputFileName, const std::string &fileFor)
void closeOutputStream()
Close and flush the output streams.
HMPID Trigger declaration.
static GRPObject * loadFrom(const std::string &grpFileName="")
void setContinuousReadout()
void writeConfFile(std::string_view origin="FLP", std::string_view description="RAWDATA", std::string_view cfgname="raw.cfg", bool fullPath=true) const
GLboolean GLboolean GLboolean GLboolean a
Defining ITS Vertex explicitly as messageable.
@ Me
Only quit this data processor.
o2::framework::DataProcessorSpec getDigitsToRawSpec()
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string to_string(gsl::span< T, Size > span)
static std::string concat_string(Ts const &... ts)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Digit > digits