ATLAS Offline Software
Loading...
Searching...
No Matches
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
13
14#include "SCT_RODVetoCondAlg.h"
15
19
20#include <algorithm>
21#include <ios>
22
24 ISvcLocator* pSvcLocator) :
25 AthCondAlgorithm(name, pSvcLocator)
26{
27}
28
30 ATH_CHECK(m_cabling.retrieve());
31 ATH_CHECK(detStore()->retrieve(m_pHelper, "SCT_ID"));
32 ATH_CHECK(m_badIds.initialize());
33
34 return StatusCode::SUCCESS;
35}
36
37StatusCode 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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
This is an Identifier helper class for the SCT subdetector.
Header file for the SCT_RODVetoCondAlg class in package SCT_ConditionsAlgorithms.
const ServiceHandle< StoreGateSvc > & detStore() const
Base class for conditions algorithms.
static EventIDRange infiniteRunLB()
Produces an EventIDRange that is infinite in RunLumi and invalid in Time.
This is a "hash" representation of an Identifier.
virtual StatusCode execute(const EventContext &ctx) const override final
virtual StatusCode finalize() override final
UnsignedIntegerArrayProperty m_badRODElementsInput
virtual StatusCode initialize() override final
ToolHandle< ISCT_CablingTool > m_cabling
SCT_RODVetoCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::WriteCondHandleKey< IdentifierSet > m_badIds
const SCT_ID * m_pHelper
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED