ATLAS Offline Software
SCTCalibWriteTool.h
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 /*
8  * @file SCTCalibWriteTool.h
9  *
10  * @brief Header file for the SCTCalibWriteTool class
11  *
12  * @author Jose E. Garcia
13  **/
14 
15 #ifndef SCTCalibWriteTool_H
16 #define SCTCalibWriteTool_H
17 
18 // Athena includes
20 #include "AthenaKernel/IOVTime.h"
21 #include "AthenaKernel/IIOVDbSvc.h"
24 
29 
30 #include "CoralBase/AttributeListSpecification.h"
31 
32 // Gaudi includes
33 #include "GaudiKernel/IInterface.h"
34 #include "GaudiKernel/IAlgTool.h"
35 #include "GaudiKernel/ToolHandle.h"
36 #include "GaudiKernel/ServiceHandle.h"
37 #include "GaudiKernel/StatusCode.h"
38 #include "GaudiKernel/ClassID.h"
39 
40 //STL
41 #include <list>
42 #include <map>
43 #include <memory>
44 #include <mutex>
45 #include <set>
46 #include <string>
47 
48 //forward declarations
49 class IdentifierHash;
50 class Identifier;
51 class SCT_ID;
53 
57 class SCTCalibWriteTool : public AthAlgTool {
58 
59  public:
60  // Constructor
61  SCTCalibWriteTool(const std::string& type, const std::string& name, const IInterface* parent);
62  // Destructor
63  virtual ~SCTCalibWriteTool();
64 
65  // overloading functions
66  virtual StatusCode initialize();
67  virtual StatusCode finalize();
68  static const InterfaceID& interfaceID();
69  virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvIF);
70 
71  std::string
72  addDefect(const std::string& defectlist,const int defectBeginChannel,const int defectEndChannel) const;
73 
74  std::string
75  addNumber(const std::string& numStr,const unsigned long long number) const;
76 
77  std::string
78  createDefectString(const int defectBeginChannel,const int defectEndChannel) const;
79 
80  StatusCode createCondObjects ATLAS_NOT_THREAD_SAFE // Thread unsafe CondAttrListCollection::add is used.
81  (const Identifier& wafer_id,
82  const SCT_ID* m_sctId,
83  const int samplesize,
84  const std::string& defectType,
85  const float threshold,
86  const std::string& defectList) const;
87 
88  StatusCode createListStrip ATLAS_NOT_THREAD_SAFE // Thread unsafe CondAttrListCollection::add is used.
89  (const Identifier& wafer_id,
90  const SCT_ID* m_sctId,
91  const int samplesize,
92  const std::string& defectType,
93  const float threshold,
94  const std::string& defectList) const;
95 
96  StatusCode createListChip ATLAS_NOT_THREAD_SAFE // Thread unsafe CondAttrListCollection::add is used.
97  (const Identifier& wafer_id,
98  const SCT_ID* m_sctId,
99  const int samplesize,
100  const std::string& defectType,
101  const float threshold,
102  const std::string& defectList) const;
103 
104  StatusCode createListEff ATLAS_NOT_THREAD_SAFE // Thread unsafe CondAttrListCollection::add is used.
105  (const Identifier& wafer_id,
106  const SCT_ID* m_sctId,
107  const int samplesize,
108  const float eff) const;
109 
110  StatusCode createListNO ATLAS_NOT_THREAD_SAFE // Thread unsafe CondAttrListCollection::add is used.
111  (const Identifier& wafer_id,
112  const SCT_ID* m_sctId,
113  const int samplesize,
114  const float noise_occ) const;
115 
116  StatusCode createListRawOccu ATLAS_NOT_THREAD_SAFE // Thread unsafe CondAttrListCollection::add is used.
117  (const Identifier& wafer_id,
118  const SCT_ID* m_sctId,
119  const int samplesize,
120  const float raw_occu) const;
121 
122  StatusCode createListBSErr ATLAS_NOT_THREAD_SAFE // Thread unsafe CondAttrListCollection::add is used.
123  (const Identifier& wafer_id,
124  const SCT_ID* m_sctId,
125  const int samplesize,
126  const std::string& errorList,
127  const std::string& probList) const ;
128 
129  StatusCode createListLA ATLAS_NOT_THREAD_SAFE // Thread unsafe CondAttrListCollection::add is used.
130  (const Identifier& wafer_id,
131  const SCT_ID* m_sctId,
132  const int samplesize,
133  const int module,
134  const float lorentz,
135  const float err_lorentz,
136  const float chisq,
137  const float fitParam_a,
138  const float err_a,
139  const float fitParam_b,
140  const float err_b,
141  const float fitParam_sigma,
142  const float err_sigma,
143  const float MCW,
144  const float err_MCW) const;
145 
154 
155  private:
156  int stringToInt(const std::string& s) const;
157 
158  StatusCode streamOutCondObjects(const std::string& foldername);
160 
161  StatusCode registerCondObjects(const std::string& foldername,const std::string& tagname) const;
162  StatusCode recordAndStream(std::unique_ptr<CondAttrListCollection> pCollection,const std::string& foldername, bool& flag);
163  StatusCode registerCondObjectsWithErrMsg(const std::string& foldername,const std::string& tagname) const;
164 
165  coral::AttributeListSpecification* createBasicDbSpec(const bool capsFormat) const;
166  void setBasicValues(coral::AttributeList& attrList, const Identifier& wafer_id, const int samplesize,const SCT_ID* m_sctId, const bool capsFormat) const;
167  // small helper function
168  unsigned int computeIstrip4moncond(const Identifier& elementId) const;
169 
170  const CondAttrListCollection* getAttrListCollectionByFolder(const std::string&) const;
171 
172  // would it make sense to change the strings to properties?
173  // that would be a fairly simple fix
174  static const std::string s_separator;
175  static const std::string s_defectFolderName;
176  static const std::string s_deadStripFolderName;
177  static const std::string s_deadChipFolderName;
178  static const std::string s_effFolderName;
179  static const std::string s_noFolderName;
180  static const std::string s_RawOccuFolderName;
181  static const std::string s_BSErrFolderName;
182  static const std::string s_LAFolderName;
183 
184  // cache for the Collections, access by foldername
185  mutable std::mutex m_mutex{};
186  mutable std::map<const std::string, const CondAttrListCollection*> m_attrListCollectionMap ATLAS_THREAD_SAFE; // Guarded by m_mutex
187  std::unique_ptr<CondAttrListCollection> m_attrListColl;
188  std::unique_ptr<CondAttrListCollection> m_attrListColl_deadStrip;
189  std::unique_ptr<CondAttrListCollection> m_attrListColl_deadChip;
190  std::unique_ptr<CondAttrListCollection> m_attrListColl_eff;
191  std::unique_ptr<CondAttrListCollection> m_attrListColl_no;
192  std::unique_ptr<CondAttrListCollection> m_attrListColl_RawOccu;
193  std::unique_ptr<CondAttrListCollection> m_attrListColl_BSErr;
194  std::unique_ptr<CondAttrListCollection> m_attrListColl_LA;
195  BooleanProperty m_writeCondObjs{this, "WriteCondObjs", true};
196  BooleanProperty m_regIOV{this, "RegisterIOV", true};
197  BooleanProperty m_readWriteCool{this, "ReadWriteCool", true};
198  BooleanProperty m_twoStepWriteReg{this, "TwoStepWriteReg", false};
199  BooleanProperty m_manualiov{this, "ManualIOV", true};
200  IntegerProperty m_version{this, "Version", 0};
201  IntegerProperty m_beginRun{this, "BeginRun", IOVTime::MINRUN};
202  IntegerProperty m_endRun{this, "EndRun", IOVTime::MAXRUN};
203  StringProperty m_streamName{this, "StreamName", "SCTCalibStream"};
204  StringProperty m_tagID4NoisyStrips{this, "TagID4NoisyStrips", ""};
205  StringProperty m_tagID4DeadStrips{this, "TagID4DeadStrips", ""};
206  StringProperty m_tagID4DeadChips{this, "TagID4DeadChips", ""};
207  StringProperty m_tagID4Efficiency{this, "TagID4Efficiency", ""};
208  StringProperty m_tagID4NoiseOccupancy{this, "TagID4NoiseOccupancy", ""};
209  StringProperty m_tagID4RawOccupancy{this, "TagID4RawOccupancy", ""};
210  StringProperty m_tagID4BSErrors{this, "TagID4BSErrors", ""};
211  StringProperty m_tagID4LorentzAngle{this, "TagID4LorentzAngle", ""};
212 
214  ToolHandle<IAthenaOutputStreamTool> m_streamer{nullptr};
216 
217  bool m_defectRecorded{false};
218  bool m_deadStripRecorded{false};
219  bool m_deadChipRecorded{false};
220  bool m_effRecorded{false};
221  bool m_noRecorded{false};
222  bool m_RawOccuRecorded{false};
223  bool m_BSErrRecorded{false};
224  bool m_LARecorded{false};
225  const SCT_ID* m_pHelper{nullptr};
226 
227 };
228 
229 inline const InterfaceID& SCTCalibWriteTool::interfaceID() {
230  static const InterfaceID IID{"SCTCalibWriteTool", 1, 0};
231  return IID;
232 }
233 
234 #endif // SCTCalibWriteTool.h
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
SCTCalibWriteTool::m_BSErrRecorded
bool m_BSErrRecorded
Definition: SCTCalibWriteTool.h:223
SCTCalibWriteTool::m_mutex
std::mutex m_mutex
Definition: SCTCalibWriteTool.h:185
SCTCalibWriteTool::m_effRecorded
bool m_effRecorded
Definition: SCTCalibWriteTool.h:220
SCTCalibWriteTool::s_LAFolderName
static const std::string s_LAFolderName
Definition: SCTCalibWriteTool.h:182
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
SCTCalibWriteTool::m_RawOccuRecorded
bool m_RawOccuRecorded
Definition: SCTCalibWriteTool.h:222
SCTCalibWriteTool::m_regSvc
ServiceHandle< IIOVRegistrationSvc > m_regSvc
Definition: SCTCalibWriteTool.h:213
IOVTime::MAXRUN
static constexpr uint32_t MAXRUN
Definition: IOVTime.h:48
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
SCTCalibWriteTool::finalize
virtual StatusCode finalize()
Definition: SCTCalibWriteTool.cxx:114
SCTCalibWriteTool::wrapUpLorentzAngle
StatusCode wrapUpLorentzAngle()
Definition: SCTCalibWriteTool.cxx:542
SCTCalibWriteTool::wrapUpBSErrors
StatusCode wrapUpBSErrors()
Definition: SCTCalibWriteTool.cxx:533
SCTCalibWriteTool::m_IOVDbSvc
ServiceHandle< IIOVDbSvc > m_IOVDbSvc
Definition: SCTCalibWriteTool.h:215
SCTCalibWriteTool::createBasicDbSpec
coral::AttributeListSpecification * createBasicDbSpec(const bool capsFormat) const
Definition: SCTCalibWriteTool.cxx:673
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
SCTCalibWriteTool::m_attrListColl_RawOccu
std::unique_ptr< CondAttrListCollection > m_attrListColl_RawOccu
Definition: SCTCalibWriteTool.h:192
SCTCalibWriteTool
Algorithm to test writing conditions data and reading them back.
Definition: SCTCalibWriteTool.h:57
SCTCalibWriteTool::stringToInt
int stringToInt(const std::string &s) const
Definition: SCTCalibWriteTool.cxx:472
SCTCalibWriteTool::m_deadChipRecorded
bool m_deadChipRecorded
Definition: SCTCalibWriteTool.h:219
SCTCalibWriteTool::s_RawOccuFolderName
static const std::string s_RawOccuFolderName
Definition: SCTCalibWriteTool.h:180
SCTCalibWriteTool::m_tagID4Efficiency
StringProperty m_tagID4Efficiency
Definition: SCTCalibWriteTool.h:207
IAthenaOutputStreamTool
This is a tool that allows streaming out of DataObjects. This has been factorized out from AthenaOutp...
Definition: IAthenaOutputStreamTool.h:69
SCTCalibWriteTool::createDefectString
std::string createDefectString(const int defectBeginChannel, const int defectEndChannel) const
Definition: SCTCalibWriteTool.cxx:161
python.checkUPD1.foldername
foldername
Definition: checkUPD1.py:77
SCTCalibWriteTool::m_attrListColl_eff
std::unique_ptr< CondAttrListCollection > m_attrListColl_eff
Definition: SCTCalibWriteTool.h:190
SCTCalibWriteTool::m_beginRun
IntegerProperty m_beginRun
Definition: SCTCalibWriteTool.h:201
IIOVRegistrationSvc.h
This is an interface to a tool used to register conditions objects in the Interval of Validity (IOV) ...
SCTCalibWriteTool::setBasicValues
void setBasicValues(coral::AttributeList &attrList, const Identifier &wafer_id, const int samplesize, const SCT_ID *m_sctId, const bool capsFormat) const
Definition: SCTCalibWriteTool.cxx:687
SCTCalibWriteTool::m_pHelper
const SCT_ID * m_pHelper
Definition: SCTCalibWriteTool.h:225
SCTCalibWriteTool::~SCTCalibWriteTool
virtual ~SCTCalibWriteTool()
Definition: SCTCalibWriteTool.cxx:60
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
SCTCalibWriteTool::m_attrListColl_no
std::unique_ptr< CondAttrListCollection > m_attrListColl_no
Definition: SCTCalibWriteTool.h:191
SCTCalibWriteTool::wrapUpNoiseOccupancy
StatusCode wrapUpNoiseOccupancy()
Definition: SCTCalibWriteTool.cxx:515
IIOVDbSvc.h
Abstract interface to IOVDbSvc to access IOVRange and tag information.
SCTCalibWriteTool::m_tagID4DeadStrips
StringProperty m_tagID4DeadStrips
Definition: SCTCalibWriteTool.h:205
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
SCTCalibWriteTool::wrapUpEfficiency
StatusCode wrapUpEfficiency()
Definition: SCTCalibWriteTool.cxx:506
SCTCalibWriteTool::ATLAS_NOT_THREAD_SAFE
StatusCode createCondObjects ATLAS_NOT_THREAD_SAFE(const Identifier &wafer_id, const SCT_ID *m_sctId, const int samplesize, const std::string &defectType, const float threshold, const std::string &defectList) const
SCTCalibWriteTool::m_attrListColl
std::unique_ptr< CondAttrListCollection > m_attrListColl
Definition: SCTCalibWriteTool.h:187
SCTCalibWriteTool::s_noFolderName
static const std::string s_noFolderName
Definition: SCTCalibWriteTool.h:179
IOVTime.h
Basic time unit for IOVSvc. Hold time as a combination of run and event numbers.
IOVTime::MINRUN
static constexpr uint32_t MINRUN
Definition: IOVTime.h:44
SCTCalibWriteTool::m_tagID4LorentzAngle
StringProperty m_tagID4LorentzAngle
Definition: SCTCalibWriteTool.h:211
IAthenaOutputStreamTool.h
Interface to an output stream tool.
SCTCalibWriteTool::m_tagID4NoisyStrips
StringProperty m_tagID4NoisyStrips
Definition: SCTCalibWriteTool.h:204
python.PyAthena.module
module
Definition: PyAthena.py:131
SCTCalibWriteTool::m_endRun
IntegerProperty m_endRun
Definition: SCTCalibWriteTool.h:202
SCTCalibWriteTool::m_streamer
ToolHandle< IAthenaOutputStreamTool > m_streamer
Definition: SCTCalibWriteTool.h:214
SCTCalibWriteTool::m_twoStepWriteReg
BooleanProperty m_twoStepWriteReg
Definition: SCTCalibWriteTool.h:198
SCTCalibWriteTool::m_tagID4DeadChips
StringProperty m_tagID4DeadChips
Definition: SCTCalibWriteTool.h:206
SCTCalibWriteTool::computeIstrip4moncond
unsigned int computeIstrip4moncond(const Identifier &elementId) const
Definition: SCTCalibWriteTool.cxx:129
SCTCalibWriteTool::s_deadChipFolderName
static const std::string s_deadChipFolderName
Definition: SCTCalibWriteTool.h:177
SCTCalibWriteTool::m_defectRecorded
bool m_defectRecorded
Definition: SCTCalibWriteTool.h:217
SCTCalibWriteTool::m_regIOV
BooleanProperty m_regIOV
Definition: SCTCalibWriteTool.h:196
SCTCalibWriteTool::s_effFolderName
static const std::string s_effFolderName
Definition: SCTCalibWriteTool.h:178
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
WriteCondHandle.h
master.flag
bool flag
Definition: master.py:29
AthAlgTool.h
SCTCalibWriteTool::wrapUpDeadStrips
StatusCode wrapUpDeadStrips()
Definition: SCTCalibWriteTool.cxx:488
test_pyathena.parent
parent
Definition: test_pyathena.py:15
SCTCalibWriteTool::m_attrListColl_deadStrip
std::unique_ptr< CondAttrListCollection > m_attrListColl_deadStrip
Definition: SCTCalibWriteTool.h:188
SCTCalibWriteTool::getAttrListCollectionByFolder
const CondAttrListCollection * getAttrListCollectionByFolder(const std::string &) const
Definition: SCTCalibWriteTool.cxx:452
InDetHierarchy.h
SCTCalibWriteTool::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvIF)
Definition: SCTCalibWriteTool.cxx:67
SCTCalibWriteTool::wrapUpRawOccupancy
StatusCode wrapUpRawOccupancy()
Definition: SCTCalibWriteTool.cxx:524
SCTCalibWriteTool::initialize
virtual StatusCode initialize()
Definition: SCTCalibWriteTool.cxx:80
SCTCalibWriteTool::streamOutCondObjectsWithErrMsg
StatusCode streamOutCondObjectsWithErrMsg(const std::string &foldername)
Definition: SCTCalibWriteTool.cxx:578
SCTCalibWriteTool::addNumber
std::string addNumber(const std::string &numStr, const unsigned long long number) const
Definition: SCTCalibWriteTool.cxx:175
SCTCalibWriteTool::m_tagID4RawOccupancy
StringProperty m_tagID4RawOccupancy
Definition: SCTCalibWriteTool.h:209
SCTCalibWriteTool::m_attrListColl_BSErr
std::unique_ptr< CondAttrListCollection > m_attrListColl_BSErr
Definition: SCTCalibWriteTool.h:193
python.selection.number
number
Definition: selection.py:20
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SCTCalibWriteTool::m_LARecorded
bool m_LARecorded
Definition: SCTCalibWriteTool.h:224
SCTCalibWriteTool::addDefect
std::string addDefect(const std::string &defectlist, const int defectBeginChannel, const int defectEndChannel) const
Definition: SCTCalibWriteTool.cxx:142
SCTCalibWriteTool::interfaceID
static const InterfaceID & interfaceID()
Definition: SCTCalibWriteTool.h:229
SCTCalibWriteTool::s_BSErrFolderName
static const std::string s_BSErrFolderName
Definition: SCTCalibWriteTool.h:181
SCTCalibWriteTool::s_defectFolderName
static const std::string s_defectFolderName
Definition: SCTCalibWriteTool.h:175
SCTCalibWriteTool::recordAndStream
StatusCode recordAndStream(std::unique_ptr< CondAttrListCollection > pCollection, const std::string &foldername, bool &flag)
Definition: SCTCalibWriteTool.cxx:657
SCT_ID
Definition: SCT_ID.h:68
SCTCalibWriteTool::wrapUpNoisyChannel
StatusCode wrapUpNoisyChannel()
Definition: SCTCalibWriteTool.cxx:479
SCTCalibWriteTool::m_writeCondObjs
BooleanProperty m_writeCondObjs
Definition: SCTCalibWriteTool.h:195
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
SCTCalibWriteTool::ATLAS_THREAD_SAFE
std::map< const std::string, const CondAttrListCollection * > m_attrListCollectionMap ATLAS_THREAD_SAFE
Definition: SCTCalibWriteTool.h:186
SCTCalibWriteTool::registerCondObjects
StatusCode registerCondObjects(const std::string &foldername, const std::string &tagname) const
Definition: SCTCalibWriteTool.cxx:590
SCTCalibWriteTool::m_attrListColl_deadChip
std::unique_ptr< CondAttrListCollection > m_attrListColl_deadChip
Definition: SCTCalibWriteTool.h:189
SCTCalibWriteTool::m_version
IntegerProperty m_version
Definition: SCTCalibWriteTool.h:200
SCTCalibWriteTool::m_tagID4NoiseOccupancy
StringProperty m_tagID4NoiseOccupancy
Definition: SCTCalibWriteTool.h:208
tagname
Definition: tagname.h:29
dqt_zlumi_alleff_HIST.eff
int eff
Definition: dqt_zlumi_alleff_HIST.py:113
SCTCalibWriteTool::m_noRecorded
bool m_noRecorded
Definition: SCTCalibWriteTool.h:221
SCTCalibWriteTool::SCTCalibWriteTool
SCTCalibWriteTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: SCTCalibWriteTool.cxx:50
SCTCalibWriteTool::registerCondObjectsWithErrMsg
StatusCode registerCondObjectsWithErrMsg(const std::string &foldername, const std::string &tagname) const
Definition: SCTCalibWriteTool.cxx:644
AthAlgTool
Definition: AthAlgTool.h:26
SCTCalibWriteTool::wrapUpDeadChips
StatusCode wrapUpDeadChips()
Definition: SCTCalibWriteTool.cxx:497
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
SCTCalibWriteTool::m_streamName
StringProperty m_streamName
Definition: SCTCalibWriteTool.h:203
SCTCalibWriteTool::m_tagID4BSErrors
StringProperty m_tagID4BSErrors
Definition: SCTCalibWriteTool.h:210
SCTCalibWriteTool::m_readWriteCool
BooleanProperty m_readWriteCool
Definition: SCTCalibWriteTool.h:197
SCTCalibWriteTool::m_manualiov
BooleanProperty m_manualiov
Definition: SCTCalibWriteTool.h:199
SCTCalibWriteTool::streamOutCondObjects
StatusCode streamOutCondObjects(const std::string &foldername)
Definition: SCTCalibWriteTool.cxx:551
dumpTgcDigiThreshold.threshold
list threshold
Definition: dumpTgcDigiThreshold.py:34
SCTCalibWriteTool::s_separator
static const std::string s_separator
Definition: SCTCalibWriteTool.h:174
SCTCalibWriteTool::m_deadStripRecorded
bool m_deadStripRecorded
Definition: SCTCalibWriteTool.h:218
ServiceHandle< IIOVRegistrationSvc >
SCTCalibWriteTool::m_attrListColl_LA
std::unique_ptr< CondAttrListCollection > m_attrListColl_LA
Definition: SCTCalibWriteTool.h:194
SCTCalibWriteTool::s_deadStripFolderName
static const std::string s_deadStripFolderName
Definition: SCTCalibWriteTool.h:176
Identifier
Definition: IdentifierFieldParser.cxx:14