Skip to content

Commit 6b6074f

Browse files
committed
Get MID HV values within the run limits
1 parent c8d0251 commit 6b6074f

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

Detectors/MUON/MID/Simulation/include/MIDSimulation/ChamberHV.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define O2_MID_CHAMBERHV_H
1818

1919
#include <array>
20+
#include <limits>
2021
#include <vector>
2122
#include <unordered_map>
2223

@@ -43,7 +44,7 @@ class ChamberHV
4344

4445
/// \brief Sets the HV from the DCS data points
4546
/// \param dpMap Map with DCS data points
46-
void setHV(const std::unordered_map<o2::dcs::DataPointIdentifier, std::vector<o2::dcs::DataPointValue>>& dpMap);
47+
void setHV(const std::unordered_map<o2::dcs::DataPointIdentifier, std::vector<o2::dcs::DataPointValue>>& dpMap, uint64_t startTS = 0, uint64_t endTS = std::numeric_limits<uint64_t>::max());
4748

4849
private:
4950
std::array<double, detparams::NDetectionElements> mHV; ///< High voltage values

Detectors/MUON/MID/Simulation/include/MIDSimulation/ChamberResponse.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifndef O2_MID_CHAMBERRESPONSE_H
1818
#define O2_MID_CHAMBERRESPONSE_H
1919

20+
#include <limits>
2021
#include <unordered_map>
2122

2223
#include "DetectorsDCS/DataPointIdentifier.h"
@@ -70,7 +71,7 @@ class ChamberResponse
7071

7172
/// @brief Sets the HV from the DCS data points
7273
/// @param dpMap Map with DCS data points
73-
inline void setHV(const std::unordered_map<o2::dcs::DataPointIdentifier, std::vector<o2::dcs::DataPointValue>>& dpMap) { mHV.setHV(dpMap); }
74+
inline void setHV(const std::unordered_map<o2::dcs::DataPointIdentifier, std::vector<o2::dcs::DataPointValue>>& dpMap, uint64_t startTS = 0, uint64_t endTS = std::numeric_limits<uint64_t>::max()) { mHV.setHV(dpMap, startTS, endTS); }
7475

7576
private:
7677
ChamberResponseParams mParams; ///< Chamber response parameters

Detectors/MUON/MID/Simulation/src/ChamberHV.cxx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,27 @@ std::vector<std::pair<uint64_t, double>> getValues(const std::unordered_map<o2::
4141
return values;
4242
}
4343

44-
double getAverage(std::vector<std::pair<uint64_t, double>>& values)
44+
double getAverage(std::vector<std::pair<uint64_t, double>>& values, uint64_t startTS, uint64_t endTS)
4545
{
4646
double num = 0., den = 0.;
4747
for (size_t ival = 1; ival < values.size(); ++ival) {
48-
double delta = values[ival].first - values[ival - 1].first;
48+
auto ts = values[ival - 1].first;
49+
if (ts < startTS || ts > endTS) {
50+
continue;
51+
}
52+
double delta = values[ival].first - ts;
4953
num += values[ival - 1].second * delta;
5054
den += delta;
5155
}
5256
return (den > 0.) ? num / den : num;
5357
}
5458

55-
void ChamberHV::setHV(const std::unordered_map<o2::dcs::DataPointIdentifier, std::vector<o2::dcs::DataPointValue>>& dpMap)
59+
void ChamberHV::setHV(const std::unordered_map<o2::dcs::DataPointIdentifier, std::vector<o2::dcs::DataPointValue>>& dpMap, uint64_t startTS, uint64_t endTS)
5660
{
5761
for (int deId = 0; deId < detparams::NDetectionElements; ++deId) {
5862
auto alias = detElemId2DCSAlias(deId, dcs::MeasurementType::HV_V);
5963
auto values = getValues(dpMap, alias);
60-
auto hv = getAverage(values);
64+
auto hv = getAverage(values, startTS, endTS);
6165
setHV(deId, hv);
6266
}
6367
}

Steer/DigitizerWorkflow/src/MIDDigitizerSpec.cxx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
// or submit itself to any jurisdiction.
1111

1212
#include "MIDDigitizerSpec.h"
13+
14+
#include <limits>
1315
#include "TChain.h"
1416
#include "Framework/CCDBParamSpec.h"
1517
#include "Framework/ConfigParamRegistry.h"
@@ -64,7 +66,8 @@ class MIDDPLDigitizerTask : public o2::base::BaseDPLDigitizer
6466
}
6567
if (matcher == ConcreteDataMatcher(header::gDataOriginMID, "CHAMBER_HV", 0)) {
6668
auto* dpMap = static_cast<DPMAP*>(obj);
67-
mDigitizer->getChamberResponse().setHV(*dpMap);
69+
LOG(debug) << "Setting HV with startTS: " << mStartTS << " endTS: " << mEndTS;
70+
mDigitizer->getChamberResponse().setHV(*dpMap, mStartTS, mEndTS);
6871
return;
6972
}
7073
}
@@ -79,6 +82,8 @@ class MIDDPLDigitizerTask : public o2::base::BaseDPLDigitizer
7982

8083
// read collision context from input
8184
auto context = pc.inputs().get<o2::steer::DigitizationContext*>("collisioncontext");
85+
mStartTS = context->getGRP().getTimeStart();
86+
mEndTS = context->getGRP().getTimeEnd();
8287
// Triggers reading from CCDB
8388
pc.inputs().get<std::vector<ChEffCounter>*>("mid_ch_eff");
8489
pc.inputs().get<DPMAP*>("mid_ch_hv");
@@ -148,6 +153,8 @@ class MIDDPLDigitizerTask : public o2::base::BaseDPLDigitizer
148153
// RS: at the moment using hardcoded flag for continuos readout
149154
o2::parameters::GRPObject::ROMode mROMode = o2::parameters::GRPObject::CONTINUOUS; // readout mode
150155
ElectronicsDelay mElectronicsDelay; // Electronics delay
156+
uint64_t mStartTS = 0; // Start timestamp of run
157+
uint64_t mEndTS = std::numeric_limits<uint64_t>::max(); // End timestamp of run
151158
};
152159

153160
o2::framework::DataProcessorSpec getMIDDigitizerSpec(int channel, bool mctruth)

0 commit comments

Comments
 (0)