ATLAS Offline Software
SCT_ReadCalibDataTestAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
10 // Include SCT_ReadCalibDataTestAlg
12 
13 // Include Athena stuff
15 #include "InDetIdentifier/SCT_ID.h"
16 
17 // Include STL stuff
18 #include <cstdint>
19 #include <string>
20 #include <vector>
21 
22 //----------------------------------------------------------------------
23 SCT_ReadCalibDataTestAlg::SCT_ReadCalibDataTestAlg(const std::string& name, ISvcLocator* pSvcLocator) :
24  AthReentrantAlgorithm(name, pSvcLocator)
25 {
26 }
27 
28 //----------------------------------------------------------------------
30 {
31  // Print where you are
32  ATH_MSG_DEBUG("in initialize()");
33 
34  // Get SCT ID helper
35  ATH_CHECK(detStore()->retrieve(m_id_sct, "SCT_ID"));
36 
37  // Process jobOption properties
39 
40  // Get the SCT_ReadCaliDataTool
41  ATH_CHECK(m_ReadCalibDataTool.retrieve());
42 
43  // Retrieve SCT Cabling service
44  ATH_CHECK(m_cabling.retrieve());
45 
46  return StatusCode::SUCCESS;
47 } // SCT_ReadCalibDataTestAlg::initialize()
48 
49 //----------------------------------------------------------------------
51 {
52  // Print where you are
53  ATH_MSG_DEBUG("in processProperties()");
54 
55  // Get module position from jobOpt property
56  std::vector<int>::const_iterator itLoop{m_moduleOfflinePosition.value().begin()};
57  int offlineBarrelEC{*itLoop}; ++itLoop;
58  int offlineLayerDisk{*itLoop}; ++itLoop;
59  int offlineEta{*itLoop}; ++itLoop;
60  int offlinePhi{*itLoop}; ++itLoop;
61  int offlineSide{*itLoop}; ++itLoop;
62  int offlineStrip{*itLoop}; ++itLoop;
63 
64  ATH_MSG_DEBUG("Module positions from jobOpt property:");
65  ATH_MSG_DEBUG("B-EC/layer-disk/eta/phi: "
66  << offlineBarrelEC << "/"
67  << offlineLayerDisk << "/"
68  << offlineEta << "/"
69  << offlinePhi << "/"
70  << offlineSide << "/"
71  << offlineStrip);
72 
73  // Create offline Identifier for this module position, wafer,chip and strip
74  m_moduleId = m_id_sct->module_id(offlineBarrelEC, offlineLayerDisk, offlinePhi, offlineEta);
75  m_waferId = m_id_sct->wafer_id(offlineBarrelEC, offlineLayerDisk, offlinePhi, offlineEta, offlineSide);
76  m_stripId = m_id_sct->strip_id(offlineBarrelEC, offlineLayerDisk, offlinePhi, offlineEta, offlineSide, offlineStrip);
77 
78  // Debug output
79  ATH_MSG_DEBUG("id-getString : " << m_moduleId.getString()); // hex format
80  ATH_MSG_DEBUG("id-getCompact: " << m_moduleId.get_compact()); // dec format
81  ATH_MSG_DEBUG("id-getCompact2: " << m_stripId.get_compact()); // dec format
84 
85  return StatusCode::SUCCESS;
86 } // SCT_ReadCalibDataTestAlg::processProperties()
87 
88 //----------------------------------------------------------------------
89 StatusCode SCT_ReadCalibDataTestAlg::execute(const EventContext& ctx) const
90 {
91  //This method is only used to test the summary service, and only used within this package,
92  // so the INFO level messages have no impact on performance of these services when used by clients
93 
94  // Print where you are
95  ATH_MSG_DEBUG("in execute()");
96 
97  //Test ConditionsSummary
99  // Test summmary, ask status of strip in module
100  Identifier IdM{m_moduleId};
101  Identifier IdS{m_stripId};
102  bool Sok{m_ReadCalibDataTool->isGood(IdS, ctx, InDetConditions::SCT_STRIP)};
103  ATH_MSG_INFO("Strip " << IdS << " on module " << IdM << " is " << (Sok?"good":"bad"));
104  }
105 
106  // Loop over all strips and check if good or not using isGood, and print the bad ones
108  int ngood{0};
109  int nbad{0};
110  //Loop over all wafers using hashIds from the cabling service
111  std::vector<std::uint32_t> listOfRODs;
112  m_cabling->getAllRods(listOfRODs, ctx);
113  std::vector<std::uint32_t>::iterator rodIter{listOfRODs.begin()};
114  std::vector<std::uint32_t>::iterator rodEnd{listOfRODs.end()};
115  for (; rodIter != rodEnd; ++rodIter) {
116  std::vector<IdentifierHash> listOfHashes;
117  m_cabling->getHashesForRod(listOfHashes, *rodIter, ctx);
118  std::vector<IdentifierHash>::iterator hashIt{listOfHashes.begin()};
119  std::vector<IdentifierHash>::iterator hashEnd{listOfHashes.end()};
120  for (; hashIt != hashEnd; ++hashIt) {
121  Identifier waferId{m_id_sct->wafer_id(*hashIt)};
122  //loop over all strips and check if good or not
123  for (unsigned int stripIndex{0}; stripIndex<768; ++stripIndex) {
124  Identifier IdS{m_id_sct->strip_id(waferId,stripIndex)};
125  const int stripId{m_id_sct->strip(IdS)};
126  const int side{m_id_sct->side(IdS)};
127  const bool stripOk{m_ReadCalibDataTool->isGood(IdS, ctx, InDetConditions::SCT_STRIP)};
128  if (stripOk) ++ngood;
129  else ++nbad;
130  if (not stripOk) { // Print info on all bad strips
131  ATH_MSG_INFO("ModuleId/side/strip: " << m_id_sct->module_id(waferId) << "/" << side << "/" << stripId << " is bad");
132  }
133  }
134  }
135  }
136  ATH_MSG_INFO("Number of good strips: " << ngood << " number of bad strips: " << nbad);
137  }
138 
139  return StatusCode::SUCCESS;
140 } // SCT_ReadCalibDataTestAlg::execute()
141 
142 //----------------------------------------------------------------------
144 {
145  // Print where you are
146  ATH_MSG_DEBUG("in finalize()");
147 
148  return StatusCode::SUCCESS;
149 } // SCT_ReadCalibDataTestAlg::finalize()
150 
151 //----------------------------------------------------------------------
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SCT_ReadCalibDataTestAlg::finalize
virtual StatusCode finalize() override
Gaudi finaliser.
Definition: SCT_ReadCalibDataTestAlg.cxx:143
SCT_ReadCalibDataTestAlg::m_moduleId
Identifier m_moduleId
Module identifier.
Definition: SCT_ReadCalibDataTestAlg.h:56
Identifier::get_compact
value_type get_compact() const
Get the compact id.
SCT_ReadCalibDataTestAlg::SCT_ReadCalibDataTestAlg
SCT_ReadCalibDataTestAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: SCT_ReadCalibDataTestAlg.cxx:23
SCT_ReadCalibDataTestAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Gaudi executer.
Definition: SCT_ReadCalibDataTestAlg.cxx:89
SCT_ReadCalibDataTestAlg::m_cabling
ToolHandle< ISCT_CablingTool > m_cabling
Definition: SCT_ReadCalibDataTestAlg.h:62
SCT_ReadCalibDataTestAlg.h
SCT_ID::module_id
Identifier module_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
Definition: SCT_ID.h:416
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
TRT::Hit::side
@ side
Definition: HitInfo.h:83
SCT_ReadCalibDataTestAlg::m_doTestmyDefectIsGood
BooleanProperty m_doTestmyDefectIsGood
Definition: SCT_ReadCalibDataTestAlg.h:65
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_ReadCalibDataTestAlg::m_doTestmyConditionsSummary
BooleanProperty m_doTestmyConditionsSummary
Definition: SCT_ReadCalibDataTestAlg.h:64
SCT_ReadCalibDataTestAlg::processProperties
StatusCode processProperties()
Process jobOpt properties.
Definition: SCT_ReadCalibDataTestAlg.cxx:50
SCT_ReadCalibDataTestAlg::m_moduleOfflinePosition
IntegerArrayProperty m_moduleOfflinePosition
Offline pos.
Definition: SCT_ReadCalibDataTestAlg.h:66
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SCT_ReadCalibDataTestAlg::initialize
virtual StatusCode initialize() override
Gaudi initialiser.
Definition: SCT_ReadCalibDataTestAlg.cxx:29
AtlasDetectorID::print_to_string
std::string print_to_string(Identifier id, const IdContext *context=0) const
or provide the printout in string form
Definition: AtlasDetectorID.cxx:655
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
IdentifierHash.h
Identifier::getString
std::string getString() const
Provide a string form of the identifier - hexadecimal.
Definition: Identifier.cxx:25
SCT_ID::strip
int strip(const Identifier &id) const
Definition: SCT_ID.h:764
SCT_ReadCalibDataTestAlg::m_ReadCalibDataTool
ToolHandle< ISCT_ReadCalibDataTool > m_ReadCalibDataTool
Definition: SCT_ReadCalibDataTestAlg.h:61
SCT_ReadCalibDataTestAlg::m_stripId
Identifier m_stripId
Strip identifier.
Definition: SCT_ReadCalibDataTestAlg.h:58
SCT_ID::side
int side(const Identifier &id) const
Definition: SCT_ID.h:752
SCT_ID::wafer_id
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module, int side) const
For a single side of module.
Definition: SCT_ID.h:464
InDetConditions::SCT_STRIP
@ SCT_STRIP
Definition: InDetHierarchy.h:14
SCT_ReadCalibDataTestAlg::m_waferId
Identifier m_waferId
Wafer identifier.
Definition: SCT_ReadCalibDataTestAlg.h:57
SCT_ReadCalibDataTestAlg::m_id_sct
const SCT_ID * m_id_sct
ID helper for SCT.
Definition: SCT_ReadCalibDataTestAlg.h:55
SCT_ID::strip_id
Identifier strip_id(int barrel_ec, int layer_disk, int phi_module, int eta_module, int side, int strip) const
For an individual strip.
Definition: SCT_ID.h:535
Identifier
Definition: IdentifierFieldParser.cxx:14