From 556b8fae845599ed359b4681026b216e30e494fe Mon Sep 17 00:00:00 2001 From: jokonig Date: Thu, 4 Apr 2024 16:13:16 +0200 Subject: [PATCH] [EMCAL-1116] Minor improvemts to pedestal calibrator - In case the runnumber is added to the output, also add an end of file marker (0xFFFFFFFF) - Use span instead of vector - Use endl instead of \n --- .../include/EMCALCalibration/EMCALPedestalHelper.h | 3 ++- .../EMCAL/calibration/src/EMCALPedestalHelper.cxx | 13 +++++++------ .../EMCAL/calibration/src/PedestalCalibDevice.cxx | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Detectors/EMCAL/calibration/include/EMCALCalibration/EMCALPedestalHelper.h b/Detectors/EMCAL/calibration/include/EMCALCalibration/EMCALPedestalHelper.h index 174714b9e8dcb..109fa795fd43a 100644 --- a/Detectors/EMCAL/calibration/include/EMCALCalibration/EMCALPedestalHelper.h +++ b/Detectors/EMCAL/calibration/include/EMCALCalibration/EMCALPedestalHelper.h @@ -25,6 +25,7 @@ #include #include #include +#include namespace o2::emcal { @@ -42,7 +43,7 @@ class EMCALPedestalHelper std::vector createPedestalInstruction(const Pedestal& obj, const int runNum = -1); /// \brief print the vector produced by createInstructionString in a textfile - void dumpInstructions(const std::string_view filename, const std::vector data, int mRun); + void dumpInstructions(const std::string_view filename, const gsl::span& data); private: /// \brief initialize fMeanPed with zeros diff --git a/Detectors/EMCAL/calibration/src/EMCALPedestalHelper.cxx b/Detectors/EMCAL/calibration/src/EMCALPedestalHelper.cxx index b25f89be7ace9..ef10423a2c97d 100644 --- a/Detectors/EMCAL/calibration/src/EMCALPedestalHelper.cxx +++ b/Detectors/EMCAL/calibration/src/EMCALPedestalHelper.cxx @@ -109,7 +109,7 @@ std::vector EMCALPedestalHelper::createInstructionString(const int runNum) isect += 3; // skip non-installed sectors } - int activeDTC[kNDTC] = {0}; + std::bitset activeDTC; for (iDTC = 0; iDTC < kNDTC; iDTC++) { if (iDTC == 10 || iDTC == 20 || iDTC == 30) { // skip TRU activeDTC[iDTC] = 0; @@ -180,17 +180,18 @@ std::vector EMCALPedestalHelper::createInstructionString(const int runNum) } // iDTC } // iSM - // std::vector output; - std::string instructionString(fout.str()); - // std::fill(instructionString.begin(), instructionString.end(), std::back_inserter(output)); + if (runNum > 0) { + fout << 0xFFFFFFFF << std::endl; + } + + const std::string instructionString(fout.str()); std::vector output(instructionString.begin(), instructionString.end()); return output; } -void EMCALPedestalHelper::dumpInstructions(const std::string_view filename, const std::vector data, int mRun) +void EMCALPedestalHelper::dumpInstructions(const std::string_view filename, const gsl::span& data) { std::ofstream fout(filename.data()); - fout << mRun << "\n"; fout << data.data(); fout.close(); } \ No newline at end of file diff --git a/Detectors/EMCAL/calibration/src/PedestalCalibDevice.cxx b/Detectors/EMCAL/calibration/src/PedestalCalibDevice.cxx index 83ff921611adf..2f4c6ee204a31 100644 --- a/Detectors/EMCAL/calibration/src/PedestalCalibDevice.cxx +++ b/Detectors/EMCAL/calibration/src/PedestalCalibDevice.cxx @@ -73,7 +73,7 @@ void PedestalCalibDevice::sendData(o2::framework::EndOfStreamContext& ec, const EMCALPedestalHelper helper; std::vector vecPedData = helper.createPedestalInstruction(data, mAddRunNumber ? mRun : -1); if (mDumpToFile) { - helper.dumpInstructions("EMCAL-Pedestals.txt", vecPedData, mRun); + helper.dumpInstructions("EMCAL-Pedestals.txt", vecPedData); } auto clNameDCS = o2::utils::MemFileHelper::getClassName(vecPedData);