ATLAS Offline Software
PixelConfigCondAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "PixelConfigCondAlg.h"
7 #include "GaudiKernel/EventIDRange.h"
8 #include <memory>
9 #include <sstream>
10 #include <fstream>
13 
14 
15 PixelConfigCondAlg::PixelConfigCondAlg(const std::string& name, ISvcLocator* pSvcLocator):
16  ::AthReentrantAlgorithm(name, pSvcLocator)
17 {
18 }
19 
21  ATH_MSG_DEBUG("PixelConfigCondAlg::initialize()");
22 
24 
25  return StatusCode::SUCCESS;
26 }
27 
28 StatusCode 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 
102 std::string
103 PixelConfigCondAlg::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  while (currentRunNumber>=runNumber) {
114  indata >> subfilename;
115  if (indata.eof()) { break; }
116  indata >> runNumber;
117  }
118  ATH_MSG_DEBUG("PixelConfigCondAlg::getFileName() RunNumber=" << currentRunNumber << " IOV=" << runNumber << " filename=" << subfilename);
119  return PathResolverFindCalibFile(m_conditionsFolder+subfilename);
120  } else {
121  return m_usePrivateFileName;
122  }
123 }
124 
PixelConfigCondAlg::m_doPIXLinearExtrapolation
Gaudi::Property< bool > m_doPIXLinearExtrapolation
Definition: PixelConfigCondAlg.h:256
PixelConfigCondAlg::m_CalibrationParameterC
Gaudi::Property< float > m_CalibrationParameterC
Definition: PixelConfigCondAlg.h:253
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
PixelConfigCondAlg::initialize
virtual StatusCode initialize() override final
Definition: PixelConfigCondAlg.cxx:20
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
PixelConfigCondAlg::m_BarrelInTimeThreshold
Gaudi::Property< std::vector< int > > m_BarrelInTimeThreshold
Definition: PixelConfigCondAlg.h:213
PixelConfigCondAlg::m_BarrelAnalogThresholdNoise
Gaudi::Property< std::vector< int > > m_BarrelAnalogThresholdNoise
Definition: PixelConfigCondAlg.h:204
PixelConfigCondAlg::m_DBMAnalogThresholdNoise
Gaudi::Property< std::vector< int > > m_DBMAnalogThresholdNoise
Definition: PixelConfigCondAlg.h:210
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
PixelConfigCondAlg::m_EndcapAnalogThresholdNoise
Gaudi::Property< std::vector< int > > m_EndcapAnalogThresholdNoise
Definition: PixelConfigCondAlg.h:207
PixelConfigCondAlg::PixelConfigCondAlg
PixelConfigCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: PixelConfigCondAlg.cxx:15
PixelConfigCondAlg::m_DBMThermalNoise
Gaudi::Property< std::vector< double > > m_DBMThermalNoise
Definition: PixelConfigCondAlg.h:228
PixelModuleFeMask_create_db.stop
int stop
Definition: PixelModuleFeMask_create_db.py:76
SG::WriteCondHandle::record
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
Definition: WriteCondHandle.h:157
PixelConfigCondAlg::m_Run1IOV
Gaudi::Property< int > m_Run1IOV
Definition: PixelConfigCondAlg.h:169
PixelConfigCondAlg::m_EndcapAnalogThresholdSigma
Gaudi::Property< std::vector< int > > m_EndcapAnalogThresholdSigma
Definition: PixelConfigCondAlg.h:198
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
PixelConfigCondAlg::m_conditionsFolder
Gaudi::Property< std::string > m_conditionsFolder
Definition: PixelConfigCondAlg.h:172
SG::WriteCondHandle::fullKey
const DataObjID & fullKey() const
Definition: WriteCondHandle.h:41
PixelConfigCondAlg::m_EndcapAnalogThreshold
Gaudi::Property< std::vector< int > > m_EndcapAnalogThreshold
Definition: PixelConfigCondAlg.h:189
PixelConfigCondAlg::m_CalibrationParameterA
Gaudi::Property< float > m_CalibrationParameterA
Definition: PixelConfigCondAlg.h:247
PixelConfigCondAlg::getFileName
std::string getFileName(const int currentRunNumber) const
Definition: PixelConfigCondAlg.cxx:103
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
PixelConfigCondAlg::m_EndcapInTimeThreshold
Gaudi::Property< std::vector< int > > m_EndcapInTimeThreshold
Definition: PixelConfigCondAlg.h:216
PixelConfigCondAlg::m_conditionsFileName
Gaudi::Property< std::string > m_conditionsFileName
Definition: PixelConfigCondAlg.h:175
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
PixelConfigCondAlg::m_writeKey
SG::WriteCondHandleKey< PixelModuleData > m_writeKey
Definition: PixelConfigCondAlg.h:37
PixelModuleDataStream.h
Stream insertion operator for PixelModuleData.
PixelConfigCondAlg::m_CalibrationParameterE
Gaudi::Property< float > m_CalibrationParameterE
Definition: PixelConfigCondAlg.h:250
PathResolver.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
SG::WriteCondHandle::key
const std::string & key() const
Definition: WriteCondHandle.h:40
IdentifierHash.h
vtune_athena.formatter
formatter
Definition: vtune_athena.py:19
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
PixelConfigCondAlg::m_EndcapThermalNoise
Gaudi::Property< std::vector< double > > m_EndcapThermalNoise
Definition: PixelConfigCondAlg.h:225
PixelConfigCondAlg.h
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:431
PixelConfigCondAlg::m_cablingMapFileName
Gaudi::Property< std::string > m_cablingMapFileName
Definition: PixelConfigCondAlg.h:270
python.AthDsoLogger.fname
string fname
Definition: AthDsoLogger.py:67
PixelConfigCondAlg::m_usePrivateFileName
Gaudi::Property< std::string > m_usePrivateFileName
Definition: PixelConfigCondAlg.h:178
DeMoAtlasDataLoss.runNumber
string runNumber
Definition: DeMoAtlasDataLoss.py:64
PixelConfigCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: PixelConfigCondAlg.cxx:28
PixelConfigCondAlg::m_DBMAnalogThreshold
Gaudi::Property< std::vector< int > > m_DBMAnalogThreshold
Definition: PixelConfigCondAlg.h:192
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
SG::WriteCondHandle::isValid
bool isValid() const
Definition: WriteCondHandle.h:248
PixelConfigCondAlg::m_biasVoltage
Gaudi::Property< float > m_biasVoltage
Definition: PixelConfigCondAlg.h:260
PixelConfigCondAlg::m_BarrelAnalogThreshold
Gaudi::Property< std::vector< int > > m_BarrelAnalogThreshold
Definition: PixelConfigCondAlg.h:186
PixelConfigCondAlg::m_DBMAnalogThresholdSigma
Gaudi::Property< std::vector< int > > m_DBMAnalogThresholdSigma
Definition: PixelConfigCondAlg.h:201
SoshiFormat
Definition: PixelModuleDataStream.h:20
PixelConfigCondAlg::m_BarrelAnalogThresholdSigma
Gaudi::Property< std::vector< int > > m_BarrelAnalogThresholdSigma
Definition: PixelConfigCondAlg.h:195
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
PixelConfigCondAlg::m_BarrelThermalNoise
Gaudi::Property< std::vector< double > > m_BarrelThermalNoise
Definition: PixelConfigCondAlg.h:222
PixelConfigCondAlg::m_cablingMapToFile
Gaudi::Property< bool > m_cablingMapToFile
Definition: PixelConfigCondAlg.h:267
PixelConfigCondAlg::m_DBMInTimeThreshold
Gaudi::Property< std::vector< int > > m_DBMInTimeThreshold
Definition: PixelConfigCondAlg.h:219