ATLAS Offline Software
SCT_RODVetoCondAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
14 #include "SCT_RODVetoCondAlg.h"
15 
16 #include "InDetIdentifier/SCT_ID.h"
19 
20 #include <algorithm>
21 #include <ios>
22 
24  ISvcLocator* pSvcLocator) :
25  AthReentrantAlgorithm(name, pSvcLocator)
26 {
27 }
28 
30  ATH_CHECK(m_cabling.retrieve());
31  ATH_CHECK(detStore()->retrieve(m_pHelper, "SCT_ID"));
33 
34  return StatusCode::SUCCESS;
35 }
36 
37 StatusCode SCT_RODVetoCondAlg::execute(const EventContext& ctx) const {
38  ATH_MSG_INFO(m_badRODElementsInput.value().size() <<" RODs were declared bad");
39 
40  std::vector<unsigned int> allRods;
41  m_cabling->getAllRods(allRods, ctx);
42 
44  if (badIds.isValid()) {
45  return StatusCode::SUCCESS;
46  }
47 
48  std::unique_ptr<IdentifierSet> bad_id_set = std::make_unique<IdentifierSet>();
49 
50  for (unsigned int thisRod: m_badRODElementsInput.value()) {
51  ATH_MSG_DEBUG("This rod is " << std::hex << "0x" << thisRod << std::dec);
52 
53  //check whether rod exists
54  if (std::find(allRods.begin(), allRods.end(), thisRod)==allRods.end()) {
55  ATH_MSG_WARNING("Your vetoed selection " << std::hex << "0x" << thisRod << " does not exist." << std::dec);
56  continue;
57  }
58 
59  std::vector<IdentifierHash> listOfHashes;
60  m_cabling->getHashesForRod(listOfHashes, thisRod, ctx);
61  // Two consecutive hashes may produce the same module id, since they will be two sides
62  // of the same module. We avoid invalid inserts by guarding against this.
63  Identifier previousId; //constructor produces an invalid one
64  for (const IdentifierHash& thisHash: listOfHashes) {
65  Identifier wafId{m_pHelper->wafer_id(thisHash)};
66  Identifier modId{m_pHelper->module_id(wafId)};
67  const bool alreadyInserted{modId==previousId};
68  previousId = modId;
69  if (alreadyInserted) continue;
70  ATH_MSG_VERBOSE("This module Id is " << modId);
71  const bool thisInsertionOk{bad_id_set->insert(modId).second};
72  if (not thisInsertionOk) {
73  ATH_MSG_WARNING("Insertion failed for rod " << std::hex << "0x" << thisRod << std::dec << " and module (hash,id): " << thisHash << ", " << modId);
74  }
75  }
76  }
77  ATH_CHECK(badIds.record(IOVInfiniteRange::infiniteRunLB(),std::move(bad_id_set)) );
78 
79  return StatusCode::SUCCESS;
80 }
81 
83  return StatusCode::SUCCESS;
84 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
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
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
SCT_RODVetoCondAlg::initialize
virtual StatusCode initialize() override final
Definition: SCT_RODVetoCondAlg.cxx:29
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SCT_RODVetoCondAlg::SCT_RODVetoCondAlg
SCT_RODVetoCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: SCT_RODVetoCondAlg.cxx:23
SCT_RODVetoCondAlg::m_badIds
SG::WriteCondHandleKey< IdentifierSet > m_badIds
Definition: SCT_RODVetoCondAlg.h:47
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
SCT_RODVetoCondAlg::m_cabling
ToolHandle< ISCT_CablingTool > m_cabling
Definition: SCT_RODVetoCondAlg.h:45
SCT_RODVetoCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: SCT_RODVetoCondAlg.cxx:37
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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
WriteCondHandle.h
IOVInfiniteRange::infiniteRunLB
static EventIDRange infiniteRunLB()
Produces an EventIDRange that is infinite in RunLumi and invalid in Time.
Definition: IOVInfiniteRange.h:39
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SCT_RODVetoCondAlg::finalize
virtual StatusCode finalize() override final
Definition: SCT_RODVetoCondAlg.cxx:82
IOVInfiniteRange.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
SCT_RODVetoCondAlg.h
Header file for the SCT_RODVetoCondAlg class in package SCT_ConditionsAlgorithms.
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
SCT_RODVetoCondAlg::m_pHelper
const SCT_ID * m_pHelper
Definition: SCT_RODVetoCondAlg.h:46
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
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
IdentifierHash
Definition: IdentifierHash.h:38
SCT_RODVetoCondAlg::m_badRODElementsInput
UnsignedIntegerArrayProperty m_badRODElementsInput
Definition: SCT_RODVetoCondAlg.h:48
SG::WriteCondHandle
Definition: WriteCondHandle.h:26