Skip to content

Commit

Permalink
[EMCAL-1116] Fix in mapping for pedestal calibration (AliceO2Group#12983
Browse files Browse the repository at this point in the history
)

* [EMCAL-1116] Fix in mapping for pedestal calibration

- As discussed on https://its.cern.ch/jira/browse/EMCAL-1120

* [EMCAL-1116] Add option to add runnumber to ccdb output string

- For debugging purposes, the runnumber is added to the string stored in the ccdb
- Can be enabled with workflow argument --addRunNumber
- Off by default

---------

Co-authored-by: jokonig <[email protected]>
  • Loading branch information
jokonig and jokonig authored Apr 4, 2024
1 parent d093072 commit a54ee7f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class EMCALPedestalHelper

/// \brief Encodes the pedestal object into a string. This function fills fMeanPed which is then converted to a string in createInstructionString
/// \param obj pedestal object as stored in production ccdb
std::vector<char> createPedestalInstruction(const Pedestal& obj);
/// \param runNum current runnumber. If -1, will not be added to string that goes in the ccdb, otherwise runNum is the first entrey in the string
std::vector<char> 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<char> data, int mRun);
Expand All @@ -48,7 +49,8 @@ class EMCALPedestalHelper
void setZero();

/// \brief converts fMeanPed to a vector of char
std::vector<char> createInstructionString();
/// \param runNum current runnumber. If -1, will not be added to string that goes in the ccdb, otherwise runNum is the first entrey in the string
std::vector<char> createInstructionString(const int runNum = -1);

static constexpr short kNSM = 20; ///< number of SuperModules
static constexpr short kNRCU = 2; ///< number of readout crates (and DDLs) per SM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace o2::emcal
class PedestalCalibDevice : o2::framework::Task
{
public:
PedestalCalibDevice(bool dumpToFile) : mDumpToFile(dumpToFile){};
PedestalCalibDevice(bool dumpToFile, bool addRunNum) : mDumpToFile(dumpToFile), mAddRunNumber(addRunNum){};
~PedestalCalibDevice() final = default;

void init(framework::InitContext& ctx) final;
Expand All @@ -51,9 +51,10 @@ class PedestalCalibDevice : o2::framework::Task
long int mStartTS = 0; ///< timestamp at the start of run used for the object in the ccdb
bool mDumpToFile; ///< if output of pedestal calib (DCS ccdb) should be written to text file
int mRun = 0; ///< current run number
bool mAddRunNumber = false; ///< if true, runNumber will be added to ccdb string
};

o2::framework::DataProcessorSpec getPedestalCalibDevice(bool dumpToFile);
o2::framework::DataProcessorSpec getPedestalCalibDevice(bool dumpToFile, bool addRunNum);

} // end namespace o2::emcal

Expand Down
12 changes: 8 additions & 4 deletions Detectors/EMCAL/calibration/src/EMCALPedestalHelper.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "EMCALCalibration/EMCALPedestalHelper.h"
using namespace o2::emcal;

std::vector<char> EMCALPedestalHelper::createPedestalInstruction(const Pedestal& obj)
std::vector<char> EMCALPedestalHelper::createPedestalInstruction(const Pedestal& obj, const int runNum)
{

setZero();
Expand Down Expand Up @@ -41,7 +41,7 @@ std::vector<char> EMCALPedestalHelper::createPedestalInstruction(const Pedestal&

for (int iledmon = 0; iledmon < 480; iledmon++) {
int sm = iledmon / 24,
col = sm % 24,
col = iledmon % 24,
ircu = 0, // LEDMONS always on RCU 0
iddl = 2 * sm + ircu;
const auto& mapping = mapper.getMappingForDDL(iddl);
Expand All @@ -59,7 +59,7 @@ std::vector<char> EMCALPedestalHelper::createPedestalInstruction(const Pedestal&
fMeanPed[sm][ircu][branchLG][fecLG][chipLG][channelLG] = obj.getPedestalValue(iledmon, true, true);
}

return createInstructionString();
return createInstructionString(runNum);
}

void EMCALPedestalHelper::setZero()
Expand All @@ -79,10 +79,14 @@ void EMCALPedestalHelper::setZero()
}
}

std::vector<char> EMCALPedestalHelper::createInstructionString()
std::vector<char> EMCALPedestalHelper::createInstructionString(const int runNum)
{
std::stringstream fout;

if (runNum > 0) {
fout << runNum << "\n";
}

unsigned int lineValue = 0;

const unsigned int FECheaderCode = 0xC0000000;
Expand Down
6 changes: 3 additions & 3 deletions Detectors/EMCAL/calibration/src/PedestalCalibDevice.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void PedestalCalibDevice::sendData(o2::framework::EndOfStreamContext& ec, const

// the following goes to the DCS ccdb
EMCALPedestalHelper helper;
std::vector<char> vecPedData = helper.createPedestalInstruction(data);
std::vector<char> vecPedData = helper.createPedestalInstruction(data, mAddRunNumber ? mRun : -1);
if (mDumpToFile) {
helper.dumpInstructions("EMCAL-Pedestals.txt", vecPedData, mRun);
}
Expand All @@ -95,7 +95,7 @@ void PedestalCalibDevice::endOfStream(o2::framework::EndOfStreamContext& ec)
resetStartTS();
}

o2::framework::DataProcessorSpec o2::emcal::getPedestalCalibDevice(bool dumpToFile)
o2::framework::DataProcessorSpec o2::emcal::getPedestalCalibDevice(bool dumpToFile, bool addRunNum)
{

std::vector<o2::framework::InputSpec> inputs;
Expand All @@ -111,6 +111,6 @@ o2::framework::DataProcessorSpec o2::emcal::getPedestalCalibDevice(bool dumpToFi
"PedestalCalibrator",
inputs,
outputs,
o2::framework::AlgorithmSpec{o2::framework::adaptFromTask<o2::emcal::PedestalCalibDevice>(dumpToFile)},
o2::framework::AlgorithmSpec{o2::framework::adaptFromTask<o2::emcal::PedestalCalibDevice>(dumpToFile, addRunNum)},
o2::framework::Options{}};
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ void customize(std::vector<ConfigParamSpec>& workflowOptions)
{
std::vector<ConfigParamSpec> options{
{"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings"}},
{"dumpToFile", VariantType::Bool, false, {"if output (that goes to DCS ccdb) should be stored in txt file for local debugging"}}};
{"dumpToFile", VariantType::Bool, false, {"if output (that goes to DCS ccdb) should be stored in txt file for local debugging"}},
{"addRunNumber", VariantType::Bool, false, {"if true, run number will be added to ccdb file as first element of the string"}}};
std::swap(workflowOptions, options);
}

Expand All @@ -43,9 +44,10 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)

o2::conf::ConfigurableParam::updateFromString(cfgc.options().get<std::string>("configKeyValues"));
bool dumpToFile = cfgc.options().get<bool>("dumpToFile");
bool addRunNumber = cfgc.options().get<bool>("addRunNumber");

WorkflowSpec specs;
specs.emplace_back(o2::emcal::getPedestalCalibDevice(dumpToFile));
specs.emplace_back(o2::emcal::getPedestalCalibDevice(dumpToFile, addRunNumber));

return specs;
}

0 comments on commit a54ee7f

Please sign in to comment.