ATLAS Offline Software
SCT_ReadCalibChipGainCondAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
8 
10 #include "InDetIdentifier/SCT_ID.h"
13 
14 #include <memory>
15 
16 using namespace SCT_ConditionsData;
17 using namespace SCT_ReadCalibChipDefs;
18 
19 SCT_ReadCalibChipGainCondAlg::SCT_ReadCalibChipGainCondAlg(const std::string& name, ISvcLocator* pSvcLocator)
20  : ::AthReentrantAlgorithm(name, pSvcLocator)
21 {
22 }
23 
25  ATH_MSG_DEBUG("initialize " << name());
26 
27  // Get SCT helper
28  ATH_CHECK(detStore()->retrieve(m_id_sct, "SCT_ID"));
29 
30  // Read Cond Handle
32  // Write Cond Handle
34 
35  return StatusCode::SUCCESS;
36 }
37 
38 StatusCode SCT_ReadCalibChipGainCondAlg::execute(const EventContext& ctx) const {
39  ATH_MSG_DEBUG("execute " << name());
40 
41  // Write Cond Handle
43  // Do we have a valid Write Cond Handle for current time?
44  if (writeHandle.isValid()) {
45  ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid."
46  << ". In theory this should not be called, but may happen"
47  << " if multiple concurrent events are being processed out of order.");
48  return StatusCode::SUCCESS;
49  }
50 
51  // Read Cond Handle
53  const CondAttrListCollection* readCdo{*readHandle};
54  if (readCdo==nullptr) {
55  ATH_MSG_FATAL("Null pointer to the read conditions object");
56  return StatusCode::FAILURE;
57  }
58  // Add dependency
59  writeHandle.addDependency(readHandle);
60  ATH_MSG_INFO("Size of CondAttrListCollection " << readHandle.fullKey() << " readCdo->size()= " << readCdo->size());
61  ATH_MSG_INFO("Range of input is " << readHandle.getRange());
62 
63  // Construct the output Cond Object and fill it in
64  std::unique_ptr<SCT_GainCalibData> writeCdo{std::make_unique<SCT_GainCalibData>()};
65 
66  // Initialization
67  const float errVal{std::numeric_limits<float>::quiet_NaN()};
68  for (int m{0}; m!=NUMBER_OF_MODULES; ++m) {
69  for (int p{0}; p!=N_NPTGAIN; ++p) {
70  for (int c{0}; c!=CHIPS_PER_MODULE; ++c) {
71  (*writeCdo)[m][p][c]=errVal;
72  }
73  }
74  }
75 
76  // loop over collection
77  CondAttrListCollection::const_iterator itLoop{readCdo->begin()};
78  CondAttrListCollection::const_iterator itLoop_end{readCdo->end()};
79  for (; itLoop!=itLoop_end; ++itLoop) {
81  const coral::AttributeList &anAttrList{itLoop->second};
82  // Convert chanNum=offlineID into identifier
83  Identifier32 moduleId{chanNum};
84  //find the corresponding hash
85  const IdentifierHash hashId{m_id_sct->wafer_hash(moduleId)};
86  //find the index to the module (hash is for each side), to use as index into array
87  const unsigned int moduleIdx{hashId/SIDES_PER_MODULE};
88  SCT_ModuleGainCalibData& theseCalibData{(*writeCdo)[moduleIdx]};
89  insertNptGainFolderData(theseCalibData, anAttrList);
90  }
91 
92  // Record the output cond object
93  if (writeHandle.record(std::move(writeCdo)).isFailure()) {
94  ATH_MSG_FATAL("Could not record SCT_GainCalibData " << writeHandle.key()
95  << " with EventRange " << writeHandle.getRange()
96  << " into Conditions Store");
97  return StatusCode::FAILURE;
98  }
99  ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
100 
101  return StatusCode::SUCCESS;
102 }
103 
105  ATH_MSG_DEBUG("finalize " << name());
106  return StatusCode::SUCCESS;
107 }
108 
109 void
111  for (int i{0}; i!=N_NPTGAIN; ++i) {
112  SCT_ModuleCalibParameter& datavec{theseCalibData[i]};
113  const std::string &dbData{((folderData)[nPtGainDbParameterNames[i]]).data<std::string>()};
114  fillArrayFromString(dbData, datavec);
115  }
116 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
Identifier32
Definition: Identifier32.h:25
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SCT_ConditionsData::NUMBER_OF_MODULES
@ NUMBER_OF_MODULES
Definition: SCT_ConditionsParameters.h:19
SCT_ReadCalibChipDefs::nPtGainDbParameterNames
const std::array< std::string, SCT_ConditionsData::N_NPTGAIN > nPtGainDbParameterNames
Definition: SCT_ReadCalibChipDefs.h:15
SCT_ConditionsData::SIDES_PER_MODULE
@ SIDES_PER_MODULE
Definition: SCT_ConditionsParameters.h:18
SCT_ConditionsData::N_NPTGAIN
@ N_NPTGAIN
Definition: SCT_ConditionsParameters.h:22
SCT_ReadCalibChipGainCondAlg.h
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
SCT_ReadCalibChipGainCondAlg::m_id_sct
const SCT_ID * m_id_sct
Handle to SCT ID helper.
Definition: SCT_ReadCalibChipGainCondAlg.h:40
SCT_ConditionsParameters.h
header file containing the number of elements and enumerated type of parameters which may be retrieve...
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
checkCoolLatestUpdate.chanNum
chanNum
Definition: checkCoolLatestUpdate.py:27
SCT_ConditionsData
Definition: SCT_ConditionsParameters.h:17
lumiFormat.i
int i
Definition: lumiFormat.py:85
SCT_ReadCalibChipGainCondAlg::m_readKey
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey
Definition: SCT_ReadCalibChipGainCondAlg.h:38
SCT_ModuleCalibParameter
std::array< float, SCT_ConditionsData::CHIPS_PER_MODULE > SCT_ModuleCalibParameter
typedef for SCT_ReadCalibChipGainCondAlg, SCT_ReadCalibChipNoiseCondAlg, SCT_ReadCalibChipDataTool.
Definition: SCT_ModuleCalibParameter.h:27
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SCT_ReadCalibChipGainCondAlg::insertNptGainFolderData
static void insertNptGainFolderData(SCT_ModuleGainCalibData &theseCalibData, const coral::AttributeList &folderData)
Definition: SCT_ReadCalibChipGainCondAlg.cxx:110
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
SCT_ReadCalibChipGainCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: SCT_ReadCalibChipGainCondAlg.cxx:38
FillFromStringUtility.h
SCT_ModuleGainCalibData
std::array< SCT_ModuleCalibParameter, SCT_ConditionsData::N_NPTGAIN > SCT_ModuleGainCalibData
Typedef for data object used in SCT_ReadCalibChipGainCondAlg and SCT_ReadCalibChipDataTool.
Definition: SCT_ModuleGainCalibData.h:26
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SCT_ID::wafer_hash
IdentifierHash wafer_hash(const Identifier &wafer_id) const
wafer hash from id - optimized
Definition: SCT_ID.h:492
SCT_ReadCalibChipGainCondAlg::finalize
virtual StatusCode finalize() override final
Definition: SCT_ReadCalibChipGainCondAlg.cxx:104
CondAttrListCollection::ChanNum
unsigned int ChanNum
Definition: CondAttrListCollection.h:55
SCT_ReadCalibChipGainCondAlg::initialize
virtual StatusCode initialize() override final
Definition: SCT_ReadCalibChipGainCondAlg.cxx:24
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
IdentifierHash.h
SCT_ReadCalibChipGainCondAlg::m_writeKey
SG::WriteCondHandleKey< SCT_GainCalibData > m_writeKey
Definition: SCT_ReadCalibChipGainCondAlg.h:39
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition: CondAttrListCollection.h:63
SCT_ConditionsData::CHIPS_PER_MODULE
@ CHIPS_PER_MODULE
Definition: SCT_ConditionsParameters.h:20
SCT_ReadCalibChipDefs
Definition: SCT_ReadCalibChipDefs.h:14
SCT_ReadCalibChipGainCondAlg::SCT_ReadCalibChipGainCondAlg
SCT_ReadCalibChipGainCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: SCT_ReadCalibChipGainCondAlg.cxx:19
SCT_ReadCalibChipDefs.h
python.compressB64.c
def c
Definition: compressB64.py:93
SG::WriteCondHandle
Definition: WriteCondHandle.h:26