ATLAS Offline Software
SCT_ReadCalibChipNoiseCondAlg.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 <limits>
15 #include <memory>
16 
17 using namespace SCT_ConditionsData;
18 using namespace SCT_ReadCalibChipDefs;
19 
20 SCT_ReadCalibChipNoiseCondAlg::SCT_ReadCalibChipNoiseCondAlg(const std::string& name, ISvcLocator* pSvcLocator)
21  : ::AthReentrantAlgorithm(name, pSvcLocator)
22 {
23 }
24 
26  ATH_MSG_DEBUG("initialize " << name());
27 
28  // Get SCT helper
29  ATH_CHECK(detStore()->retrieve(m_id_sct, "SCT_ID"));
30 
31  // Read Cond Handle
33  // Write Cond Handle
35 
36  return StatusCode::SUCCESS;
37 }
38 
39 StatusCode SCT_ReadCalibChipNoiseCondAlg::execute(const EventContext& ctx) const {
40  ATH_MSG_DEBUG("execute " << name());
41 
42  // Write Cond Handle
44  // Do we have a valid Write Cond Handle for current time?
45  if (writeHandle.isValid()) {
46  ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid."
47  << ". In theory this should not be called, but may happen"
48  << " if multiple concurrent events are being processed out of order.");
49  return StatusCode::SUCCESS;
50  }
51 
52  // Read Cond Handle
54  const CondAttrListCollection* readCdo{*readHandle};
55  if (readCdo==nullptr) {
56  ATH_MSG_FATAL("Null pointer to the read conditions object");
57  return StatusCode::FAILURE;
58  }
59  // Add dependency
60  writeHandle.addDependency(readHandle);
61  ATH_MSG_INFO("Size of CondAttrListCollection " << readHandle.fullKey() << " readCdo->size()= " << readCdo->size());
62  ATH_MSG_INFO("Range of input is " << readHandle.getRange());
63 
64  // Construct the output Cond Object and fill it in
65  std::unique_ptr<SCT_NoiseCalibData> writeCdo{std::make_unique<SCT_NoiseCalibData>()};
66 
67  // Initialization
68  const float errVal{std::numeric_limits<float>::quiet_NaN()};
69  for (unsigned int m{0}; m!=NUMBER_OF_MODULES; ++m) {
70  for (unsigned int p{0}; p!=N_NOISEOCC; ++p) {
71  for (unsigned int c{0}; c!=CHIPS_PER_MODULE; ++c) {
72  (*writeCdo)[m][p][c]=errVal;
73  }
74  }
75  }
76 
77  // loop over collection
78  CondAttrListCollection::const_iterator itLoop{readCdo->begin()};
79  CondAttrListCollection::const_iterator itLoop_end{readCdo->end()};
80  for (; itLoop!=itLoop_end; ++itLoop) {
82  const coral::AttributeList& anAttrList{itLoop->second};
83  // Convert chanNum=offlineID into identifier
84  Identifier32 moduleId{chanNum};
85  //find the corresponding hash
86  const IdentifierHash hashId{m_id_sct->wafer_hash(moduleId)};
87  //find the index to the module (hash is for each side), to use as index into array
88  const unsigned int moduleIdx{hashId/SIDES_PER_MODULE};
89  SCT_ModuleNoiseCalibData& theseCalibData{(*writeCdo)[moduleIdx]};
90  insertNoiseOccFolderData(theseCalibData, anAttrList);
91  }
92 
93  // Record the output cond object
94  if (writeHandle.record(std::move(writeCdo)).isFailure()) {
95  ATH_MSG_FATAL("Could not record SCT_NoiseCalibData " << writeHandle.key()
96  << " with EventRange " << writeHandle.getRange()
97  << " into Conditions Store");
98  return StatusCode::FAILURE;
99  }
100  ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
101 
102  return StatusCode::SUCCESS;
103 }
104 
106  ATH_MSG_DEBUG("finalize " << name());
107  return StatusCode::SUCCESS;
108 }
109 
110 void
112  for (int i{0}; i!=N_NOISEOCC; ++i) {
113  SCT_ModuleCalibParameter& datavec{theseCalibData[i]};
114  std::string dbData{((folderData)[noiseOccDbParameterNames[i]]).data<std::string>()};
115  fillArrayFromString(dbData, datavec);
116  }
117 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
SCT_ReadCalibChipNoiseCondAlg::m_readKey
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey
Definition: SCT_ReadCalibChipNoiseCondAlg.h:38
Identifier32
Definition: Identifier32.h:25
SCT_ModuleNoiseCalibData
std::array< SCT_ModuleCalibParameter, SCT_ConditionsData::N_NOISEOCC > SCT_ModuleNoiseCalibData
Typedef for data object used in SCT_ReadCalibChipNoiseCondAlg and SCT_ReadCalibChipDataTool.
Definition: SCT_ModuleNoiseCalibData.h:26
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_ReadCalibChipNoiseCondAlg::finalize
virtual StatusCode finalize() override final
Definition: SCT_ReadCalibChipNoiseCondAlg.cxx:105
SCT_ReadCalibChipDefs::noiseOccDbParameterNames
const std::array< std::string, SCT_ConditionsData::N_NOISEOCC > noiseOccDbParameterNames
Definition: SCT_ReadCalibChipDefs.h:21
SCT_ReadCalibChipNoiseCondAlg::initialize
virtual StatusCode initialize() override final
Definition: SCT_ReadCalibChipNoiseCondAlg.cxx:25
SCT_ConditionsData::SIDES_PER_MODULE
@ SIDES_PER_MODULE
Definition: SCT_ConditionsParameters.h:18
SCT_ConditionsData::N_NOISEOCC
@ N_NOISEOCC
Definition: SCT_ConditionsParameters.h:22
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_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
SCT_ReadCalibChipNoiseCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: SCT_ReadCalibChipNoiseCondAlg.cxx:39
checkCoolLatestUpdate.chanNum
chanNum
Definition: checkCoolLatestUpdate.py:27
SCT_ConditionsData
Definition: SCT_ConditionsParameters.h:17
lumiFormat.i
int i
Definition: lumiFormat.py:85
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
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
SCT_ReadCalibChipNoiseCondAlg::SCT_ReadCalibChipNoiseCondAlg
SCT_ReadCalibChipNoiseCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: SCT_ReadCalibChipNoiseCondAlg.cxx:20
FillFromStringUtility.h
SCT_ReadCalibChipNoiseCondAlg::m_id_sct
const SCT_ID * m_id_sct
Handle to SCT ID helper.
Definition: SCT_ReadCalibChipNoiseCondAlg.h:40
SCT_ReadCalibChipNoiseCondAlg::m_writeKey
SG::WriteCondHandleKey< SCT_NoiseCalibData > m_writeKey
Definition: SCT_ReadCalibChipNoiseCondAlg.h:39
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SCT_ReadCalibChipNoiseCondAlg::insertNoiseOccFolderData
static void insertNoiseOccFolderData(SCT_ModuleNoiseCalibData &theseCalibData, const coral::AttributeList &folderData)
Definition: SCT_ReadCalibChipNoiseCondAlg.cxx:111
SCT_ID::wafer_hash
IdentifierHash wafer_hash(const Identifier &wafer_id) const
wafer hash from id - optimized
Definition: SCT_ID.h:492
CondAttrListCollection::ChanNum
unsigned int ChanNum
Definition: CondAttrListCollection.h:55
SCT_ReadCalibChipNoiseCondAlg.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
IdentifierHash.h
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_ReadCalibChipDefs.h
python.compressB64.c
def c
Definition: compressB64.py:93
SG::WriteCondHandle
Definition: WriteCondHandle.h:26