ATLAS Offline Software
Loading...
Searching...
No Matches
PixelConfigCondAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
7#include "GaudiKernel/EventIDRange.h"
8#include <memory>
9#include <sstream>
10#include <fstream>
13
14
15PixelConfigCondAlg::PixelConfigCondAlg(const std::string& name, ISvcLocator* pSvcLocator):
16 ::AthCondAlgorithm(name, pSvcLocator)
17{
18}
19
21 ATH_MSG_DEBUG("PixelConfigCondAlg::initialize()");
22
23 ATH_CHECK(m_writeKey.initialize());
24
25 return StatusCode::SUCCESS;
26}
27
28StatusCode PixelConfigCondAlg::execute(const EventContext& ctx) const {
29 ATH_MSG_DEBUG("PixelConfigCondAlg::execute()");
30
32 if (writeHandle.isValid()) {
33 ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid.. In theory this should not be called, but may happen if multiple concurrent events are being processed out of order.");
34 return StatusCode::SUCCESS;
35 }
36
37 // Construct the output Cond Object and fill it in
38 std::unique_ptr<PixelModuleData> writeCdo(std::make_unique<PixelModuleData>());
39
40 const EventIDBase start{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, 0,
41 0, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
42 const EventIDBase stop {EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM-1,
43 EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
44
45 writeCdo -> setDefaultBarrelAnalogThreshold(m_BarrelAnalogThreshold);
46 writeCdo -> setDefaultEndcapAnalogThreshold(m_EndcapAnalogThreshold);
47 writeCdo -> setDefaultDBMAnalogThreshold(m_DBMAnalogThreshold);
48 writeCdo -> setDefaultBarrelAnalogThresholdSigma(m_BarrelAnalogThresholdSigma);
49 writeCdo -> setDefaultEndcapAnalogThresholdSigma(m_EndcapAnalogThresholdSigma);
50 writeCdo -> setDefaultDBMAnalogThresholdSigma(m_DBMAnalogThresholdSigma);
51 writeCdo -> setDefaultBarrelAnalogThresholdNoise(m_BarrelAnalogThresholdNoise);
52 writeCdo -> setDefaultEndcapAnalogThresholdNoise(m_EndcapAnalogThresholdNoise);
53 writeCdo -> setDefaultDBMAnalogThresholdNoise(m_DBMAnalogThresholdNoise);
54 writeCdo -> setDefaultBarrelInTimeThreshold(m_BarrelInTimeThreshold);
55 writeCdo -> setDefaultEndcapInTimeThreshold(m_EndcapInTimeThreshold);
56 writeCdo -> setDefaultDBMInTimeThreshold(m_DBMInTimeThreshold);
57 writeCdo -> setBarrelThermalNoise(m_BarrelThermalNoise);
58 writeCdo -> setEndcapThermalNoise(m_EndcapThermalNoise);
59 writeCdo -> setDBMThermalNoise(m_DBMThermalNoise);
60
61 // Charge calibration parameters
62 writeCdo -> setDefaultQ2TotA(m_CalibrationParameterA);
63 writeCdo -> setDefaultQ2TotE(m_CalibrationParameterE);
64 writeCdo -> setDefaultQ2TotC(m_CalibrationParameterC);
65 writeCdo -> setPIXLinearExtrapolation(m_doPIXLinearExtrapolation);
66
67 // DCS parameters
68 writeCdo -> setDefaultBiasVoltage(m_biasVoltage);
69
70 // Cabling parameters
71 writeCdo -> setCablingMapToFile(m_cablingMapToFile);
72 writeCdo -> setCablingMapFileName(m_cablingMapFileName);
73
74 // Year-dependent conditions
75 int currentRunNumber = ctx.eventID().run_number();
76 std::string filename = getFileName(currentRunNumber);
77 if (filename.empty()) {
78 return StatusCode::FAILURE;
79 }
80 std::ifstream indata(filename.c_str());
81 SoshiFormat formatter(currentRunNumber < m_Run1IOV);
82 //stream through Soshi format to writeCdo
83 indata>> formatter >>(*writeCdo);
84 //=======================
85 // Combine time interval
86 //=======================
87 EventIDRange rangeW{start, stop};
88 if (rangeW.stop().isValid() && rangeW.start()>rangeW.stop()) {
89 ATH_MSG_FATAL("Invalid intersection rangeW: " << rangeW);
90 return StatusCode::FAILURE;
91 }
92
93 if (writeHandle.record(rangeW, std::move(writeCdo)).isFailure()) {
94 ATH_MSG_FATAL("Could not record PixelModuleData " << writeHandle.key() << " with EventRange " << rangeW << " into Conditions Store");
95 return StatusCode::FAILURE;
96 }
97 ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << rangeW << " into Conditions Store");
98
99 return StatusCode::SUCCESS;
100}
101
102std::string
103PixelConfigCondAlg::getFileName(const int currentRunNumber) const {
104 if (m_usePrivateFileName.empty()) {
105 std::string fname = PathResolverFindCalibFile(static_cast<std::string>(m_conditionsFolder)+m_conditionsFileName);
106 if (fname.empty()) {
107 return fname;
108 }
109 std::ifstream indata(fname);
110 int runNumber = 0;
111 std::string subfilename;
112 indata >> runNumber;
113 if (runNumber<0 or runNumber>1'000'000) {
114 ATH_MSG_ERROR("Run number outside sensible range: "<<runNumber);
115 return "";
116 }
117 // coverity[tainted_data]
118 while (currentRunNumber>=runNumber) {
119 indata >> subfilename;
120 if (indata.eof()) { break; }
121 indata >> runNumber;
122 }
123 ATH_MSG_DEBUG("PixelConfigCondAlg::getFileName() RunNumber=" << currentRunNumber << " IOV=" << runNumber << " filename=" << subfilename);
125 } else {
127 }
128}
129
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Stream insertion operator for PixelModuleData.
Base class for conditions algorithms.
Gaudi::Property< std::vector< int > > m_EndcapInTimeThreshold
Gaudi::Property< std::vector< int > > m_EndcapAnalogThresholdNoise
Gaudi::Property< float > m_biasVoltage
Gaudi::Property< std::string > m_conditionsFolder
virtual StatusCode initialize() override final
Gaudi::Property< float > m_CalibrationParameterA
Gaudi::Property< std::vector< int > > m_BarrelAnalogThresholdNoise
Gaudi::Property< std::vector< int > > m_DBMAnalogThreshold
Gaudi::Property< std::vector< int > > m_DBMAnalogThresholdSigma
Gaudi::Property< bool > m_doPIXLinearExtrapolation
Gaudi::Property< std::vector< double > > m_EndcapThermalNoise
Gaudi::Property< std::vector< int > > m_BarrelAnalogThreshold
Gaudi::Property< std::vector< int > > m_BarrelInTimeThreshold
Gaudi::Property< bool > m_cablingMapToFile
virtual StatusCode execute(const EventContext &ctx) const override final
Gaudi::Property< float > m_CalibrationParameterC
SG::WriteCondHandleKey< PixelModuleData > m_writeKey
Gaudi::Property< std::vector< int > > m_DBMAnalogThresholdNoise
std::string getFileName(const int currentRunNumber) const
PixelConfigCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< std::string > m_usePrivateFileName
Gaudi::Property< std::vector< double > > m_DBMThermalNoise
Gaudi::Property< std::vector< int > > m_DBMInTimeThreshold
Gaudi::Property< std::vector< int > > m_EndcapAnalogThreshold
Gaudi::Property< int > m_Run1IOV
Gaudi::Property< std::vector< double > > m_BarrelThermalNoise
Gaudi::Property< std::string > m_conditionsFileName
Gaudi::Property< std::vector< int > > m_BarrelAnalogThresholdSigma
Gaudi::Property< std::vector< int > > m_EndcapAnalogThresholdSigma
Gaudi::Property< std::string > m_cablingMapFileName
Gaudi::Property< float > m_CalibrationParameterE
const std::string & key() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
const DataObjID & fullKey() const