74 LOG(info) <<
"[HMPID Write Root File From Raw Files - init()]";
77 mOutRootFileName = ic.
options().
get<std::string>(
"out-file");
78 mBaseFileName = ic.
options().
get<std::string>(
"base-file");
79 mInputRawFileName = ic.
options().
get<std::string>(
"in-file");
80 mFastAlgorithm = ic.
options().
get<
bool>(
"fast-decode");
87 mReader.
addFile(mInputRawFileName);
101 std::vector<char> dataBuffer;
111 LOG(info) <<
"nothing left to read after " << tfID <<
" TFs read";
114 for (
int il = 0; il < mReader.
getNLinks(); il++) {
116 LOG(info) <<
"Decoding link " << il;
118 dataBuffer.resize(sz);
119 link.readNextTF(dataBuffer.data());
120 link.rewindToTF(tfID);
121 int nhbf =
link.getNHBFinTF();
122 LOG(
debug) <<
" Number of HBF " << nhbf;
123 for (
int ib = 0; ib < nhbf; ib++) {
124 auto zs =
link.getNextHBFSize();
125 dataBuffer.resize(zs);
126 link.readNextHBF(dataBuffer.data());
129 uint32_t* ptrBufferEnd = ptrBuffer + zs / 4;
131 while (ptrBuffer < ptrBufferEnd) {
133 if (mFastAlgorithm) {
140 LOG(
debug) <<
"End Page decoding !";
142 int first = mAccumulateDigits.size();
143 mAccumulateDigits.insert(mAccumulateDigits.end(), mDecod->
mDigits.begin(), mDecod->
mDigits.end());
144 int last = mAccumulateDigits.size();
147 mDigitsReceived += mDecod->
mDigits.size();
150 LOG(
debug) <<
"run() Digits received =" << mDigitsReceived <<
" frames = " << mFramesReceived <<
" size=" << sz <<
" F-L " <<
first <<
"," << last <<
" " << mDecod->
mIntReco;
157 mTotalDigits += mDigitsReceived;
158 mTotalFrames += mFramesReceived;
172 mExTimer.
logMes(
"Received an End Of Stream !");
176void RawToDigitsTask::parseNoTF()
178 std::vector<char> dataBuffer;
180 for (
int il = 0; il < mReader.
getNLinks(); il++) {
182 LOG(info) <<
"Decoding link " << il;
184 LOG(info) <<
" Size TF " << sz;
185 dataBuffer.resize(sz);
186 link.readNextTF(dataBuffer.data());
189 uint32_t* ptrBufferEnd = ptrBuffer + sz / 4;
191 while (ptrBuffer < ptrBufferEnd) {
193 if (mFastAlgorithm) {
200 LOG(
debug) <<
"End Fast Page decoding !";
202 int first = mAccumulateDigits.size();
203 mAccumulateDigits.insert(mAccumulateDigits.end(), mDecod->
mDigits.begin(), mDecod->
mDigits.end());
204 int last = mAccumulateDigits.size();
207 mDigitsReceived += mDecod->
mDigits.size();
210 LOG(info) <<
"run() Digits received =" << mDigitsReceived <<
" frames = " << mFramesReceived <<
" size=" << sz <<
" F-L " <<
first <<
"," <<
last <<
" " << mDecod->
mIntReco;
217void RawToDigitsTask::writeResults()
220 for (
int i = 0;
i < numEqui;
i++) {
225 if (mEvents.size() == 0) {
226 LOG(info) <<
"There are not Event recorded ! Abort. ";
230 for (
int i = mEvents.size() - 1;
i >= 0;
i--) {
231 if (mEvents[
i].getTriggerID() == 0) {
232 mEvents.erase(mEvents.begin() +
i);
235 sort(mEvents.begin(), mEvents.end());
242 std::vector<o2::hmpid::Digit> digitVec;
243 std::vector<o2::hmpid::Trigger> eventVec;
245 filename = TString::Format(
"%s", mOutRootFileName.c_str());
246 LOG(info) <<
"Create the ROOT file " <<
filename.Data();
247 TFile mfileOut(TString::Format(
"%s",
filename.Data()),
"RECREATE");
248 tit = TString::Format(
"HMPID Raw File Decoding");
249 TTree* theTree =
new TTree(
"o2hmp", tit);
251 theTree->Branch(
"InteractionRecords", &eventVec);
252 theTree->Branch(
"HMPIDDigits", &digitVec);
258 for (
int e = 0;
e < mEvents.size();
e++) {
259 LOG(
debug) <<
"Manage event " << mEvents[
e];
260 if (prevEvent != mEvents[
e]) {
262 theFirstDigit = theLastDigit;
263 prevEvent = mEvents[
e];
265 int first = mEvents[
e].getFirstEntry();
266 int last = mEvents[
e].getLastEntry();
268 digitVec.push_back(mAccumulateDigits[idx]);
276 mExTimer.
logMes(
"Register Tree ! ");
283 float squareOfCharges;
287 filename = TString::Format(
"%s_stat.root", mBaseFileName.c_str());
288 LOG(info) <<
"Create the ROOT file " <<
filename.Data();
289 TFile mfileOutStat(TString::Format(
"%s",
filename.Data()),
"RECREATE");
292 tit = TString::Format(
"HMPID Data Decoding Statistic results Mod=%d",
i);
293 theObj[
i] =
new TTree(
"o2hmp", tit);
294 theObj[
i]->Branch(
"x", &xb,
"s");
295 theObj[
i]->Branch(
"y", &yb,
"s");
296 theObj[
i]->Branch(
"Samples", &numOfSamples,
"i");
297 theObj[
i]->Branch(
"Sum_of_charges", &sumOfCharges,
"l");
298 theObj[
i]->Branch(
"Sum_of_square", &squareOfCharges,
"l");
300 theObj[
Geo::N_MODULES] =
new TTree(
"o2hmp",
"HMPID Data Decoding Statistic results");
301 theObj[
Geo::N_MODULES]->Branch(
"Average_Event_Size", &avgEventSize,
"F");
302 theObj[
Geo::N_MODULES]->Branch(
"Average_Busy_Time", &avgBusyTime,
"F");
304 char summaryFileName[254];
305 snprintf(summaryFileName, 254,
"%s_stat.txt", mBaseFileName.c_str());
307 for (
int e = 0;
e < numEqui;
e++) {
335 std::vector<o2::framework::InputSpec> inputs;
336 std::vector<o2::framework::OutputSpec> outputs;
343 Options{{
"in-file", VariantType::String,
"hmpidRaw.raw", {
"name of the input Raw file"}},
344 {
"fast-decode", VariantType::Bool,
false, {
"Use the fast algorithm. (error 0.8%)"}},
345 {
"out-file", VariantType::String,
"hmpReco.root", {
"name of the output file"}},
346 {
"base-file", VariantType::String,
"hmpDecode", {
"base name for statistical output file"}}}};
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
Configurable generator for RootTreeWriter processor spec.
Reader for (multiple) raw data files.
T get(const char *key) const
ConfigParamRegistry const & options()
ServiceRegistryRef services()
The services registry associated with this processing context.
void stop()
stop : stops the timer
void start()
start : starts the timer
void logMes(std::string const message)
static constexpr int N_XROWS
static constexpr int N_MODULES
static constexpr int N_YCOLS
static constexpr int MAXEQUIPMENTS
float getAverageEventSize(int Equipment)
void decodePageFast(uint32_t **streamBuf)
void init()
Init all the members variables.
std::vector< o2::hmpid::Digit > mDigits
void decodePage(uint32_t **streamBuffer)
o2::InteractionRecord mIntReco
bool setUpStream(void *Buffer, long BufferLen)
void writeSummaryFile(char *summaryFileName)
double getPadSum(int Module, int Row, int Column)
HmpidEquipment * mTheEquipments[Geo::MAXEQUIPMENTS]
int getNumberOfEquipments()
uint16_t getPadSamples(int Module, int Row, int Column)
void updateStatistics(HmpidEquipment *eq)
float getAverageBusyTime(int Equipment)
double getPadSquares(int Module, int Row, int Column)
void init(framework::InitContext &ic) final
void endOfStream(framework::EndOfStreamContext &ec) override
This is invoked whenever we have an EndOfStream event.
void run(framework::ProcessingContext &pc) final
HMPID Trigger declaration.
uint32_t getOrbit() const
uint32_t getNextTFToRead() const
void setNextTFToRead(uint32_t tf)
void setDefaultDataDescription(const std::string &desc)
void setDefaultDataOrigin(const std::string &orig)
uint32_t getNTimeFrames() const
const LinkData & getLink(int i) const
void setDefaultReadoutCardType(ReadoutCardType t=CRU)
bool addFile(const std::string &sname, o2::header::DataOrigin origin, o2::header::DataDescription desc, ReadoutCardType t=CRU)
constexpr o2::header::DataOrigin gDataOriginHMP
constexpr o2::header::DataDescription gDataDescriptionRawData
Defining ITS Vertex explicitly as messageable.
@ Me
Only quit this data processor.
o2::framework::DataProcessorSpec getRawToDigitsSpec(std::string inputSpec="HMP/RAWDATA")
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)
size_t getNextTFSize() const
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"