Skip to content

Commit 9146d71

Browse files
jokonigjokonig
andauthored
[EMCAL-1116] Minor improvemts to pedestal calibrator (#12985)
- 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 Co-authored-by: jokonig <jokonig@cern.ch>
1 parent 3ff0678 commit 9146d71

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

Detectors/EMCAL/calibration/include/EMCALCalibration/EMCALPedestalHelper.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <fstream>
2626
#include <iostream>
2727
#include <sstream>
28+
#include <bitset>
2829

2930
namespace o2::emcal
3031
{
@@ -42,7 +43,7 @@ class EMCALPedestalHelper
4243
std::vector<char> createPedestalInstruction(const Pedestal& obj, const int runNum = -1);
4344

4445
/// \brief print the vector produced by createInstructionString in a textfile
45-
void dumpInstructions(const std::string_view filename, const std::vector<char> data, int mRun);
46+
void dumpInstructions(const std::string_view filename, const gsl::span<char>& data);
4647

4748
private:
4849
/// \brief initialize fMeanPed with zeros

Detectors/EMCAL/calibration/src/EMCALPedestalHelper.cxx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ std::vector<char> EMCALPedestalHelper::createInstructionString(const int runNum)
109109
isect += 3; // skip non-installed sectors
110110
}
111111

112-
int activeDTC[kNDTC] = {0};
112+
std::bitset<kNDTC> activeDTC;
113113
for (iDTC = 0; iDTC < kNDTC; iDTC++) {
114114
if (iDTC == 10 || iDTC == 20 || iDTC == 30) { // skip TRU
115115
activeDTC[iDTC] = 0;
@@ -180,17 +180,18 @@ std::vector<char> EMCALPedestalHelper::createInstructionString(const int runNum)
180180
} // iDTC
181181
} // iSM
182182

183-
// std::vector<char> output;
184-
std::string instructionString(fout.str());
185-
// std::fill(instructionString.begin(), instructionString.end(), std::back_inserter(output));
183+
if (runNum > 0) {
184+
fout << 0xFFFFFFFF << std::endl;
185+
}
186+
187+
const std::string instructionString(fout.str());
186188
std::vector<char> output(instructionString.begin(), instructionString.end());
187189
return output;
188190
}
189191

190-
void EMCALPedestalHelper::dumpInstructions(const std::string_view filename, const std::vector<char> data, int mRun)
192+
void EMCALPedestalHelper::dumpInstructions(const std::string_view filename, const gsl::span<char>& data)
191193
{
192194
std::ofstream fout(filename.data());
193-
fout << mRun << "\n";
194195
fout << data.data();
195196
fout.close();
196197
}

Detectors/EMCAL/calibration/src/PedestalCalibDevice.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void PedestalCalibDevice::sendData(o2::framework::EndOfStreamContext& ec, const
7373
EMCALPedestalHelper helper;
7474
std::vector<char> vecPedData = helper.createPedestalInstruction(data, mAddRunNumber ? mRun : -1);
7575
if (mDumpToFile) {
76-
helper.dumpInstructions("EMCAL-Pedestals.txt", vecPedData, mRun);
76+
helper.dumpInstructions("EMCAL-Pedestals.txt", vecPedData);
7777
}
7878

7979
auto clNameDCS = o2::utils::MemFileHelper::getClassName(vecPedData);

0 commit comments

Comments
 (0)