ATLAS Offline Software
PEBInfoWriterToolBase.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 // TrigCompositeUtils types used here
12 
13 // TrigCompositeUtils methods used here
17 
18 // =============================================================================
19 
20 PEBInfoWriterToolBase::PEBInfoWriterToolBase(const std::string& type, const std::string& name, const IInterface* parent)
22  m_decisionId(HLT::Identifier::fromToolName(name)) {}
23 
24 // =============================================================================
25 
27 
28 // =============================================================================
29 
30 StatusCode PEBInfoWriterToolBase::decide(std::vector<Input>& inputs) const {
31  std::set<ElementLink<TrigRoiDescriptorCollection>> uniqueRoIs;
32  for (Input& input : inputs) {
33  // Skip if previous step for this chain didn't pass
34  if (not TrigCompositeUtils::passed(m_decisionId.numeric(), input.previousDecisionIDs)) {
35  ATH_MSG_DEBUG("Skipping chain because previous step didn't pass");
36  continue;
37  }
38 
39  if (!m_matchTriggerType.empty()) {
40  if (std::none_of(
41  m_matchTriggerType.begin(),
42  m_matchTriggerType.end(),
43  [&input](uint8_t test_tt) { return (test_tt & input.tt) == test_tt; }
44  )){
45  continue;
46  }
47  }
48 
49  // Count unique RoIs
50  bool isUnique = uniqueRoIs.insert(input.roiEL).second;
51  ATH_MSG_DEBUG("RoI eta/phi = " << (*input.roiEL)->eta() << "/" << (*input.roiEL)->phi() << " has "
52  << (isUnique ? "not yet" : "already") << " been processed. So far seen "
53  << uniqueRoIs.size() << " unique RoIs including this one");
54 
55  // Skip processing if max RoIs limit reached
56  bool maxRoIsReached{false};
57  if (m_maxRoIs>=0 && static_cast<int>(uniqueRoIs.size()) > m_maxRoIs) {
58  ATH_MSG_DEBUG("Will attach empty PEB Info to this decision because the number of "
59  << "processed RoIs reached MaxRoIs (" << m_maxRoIs.value() << ")");
60  maxRoIsReached = true;
61  }
62 
63  // Create new PEB Info for this input (empty if max RoIs limit is reached)
64  PEBInfo pebInfo = maxRoIsReached ? PEBInfo{} : createPEBInfo(input);
65 
66  // Merge with previous ROBs
67  std::vector<uint32_t> previousRobs;
68  ATH_CHECK(input.decision->getDetail(robListKey(), previousRobs));
69  pebInfo.robs.insert(previousRobs.begin(), previousRobs.end());
70 
71  // Merge with previous SubDets
72  std::vector<uint32_t> previousSubDets;
73  ATH_CHECK(input.decision->getDetail(subDetListKey(), previousSubDets));
74  pebInfo.subdets.insert(previousSubDets.begin(), previousSubDets.end());
75 
76  // Attach the PEB Info to the decision
77  std::vector<uint32_t> robVec(pebInfo.robs.begin(), pebInfo.robs.end());
78  if (not input.decision->setDetail(robListKey(), robVec)) {
79  ATH_MSG_ERROR("Failed to attach the detail " << robListKey() << " to the decision");
80  return StatusCode::FAILURE;
81  }
82  std::vector<uint32_t> subDetVec(pebInfo.subdets.begin(), pebInfo.subdets.end());
83  if (not input.decision->setDetail(subDetListKey(), subDetVec)) {
84  ATH_MSG_ERROR("Failed to attach the detail " << subDetListKey() << " to the decision");
85  return StatusCode::FAILURE;
86  }
87 
88  ATH_MSG_DEBUG("Attached PEB Info with " << robVec.size() << " ROBs and "
89  << subDetVec.size() << " SubDets to the decision object.");
90  ATH_MSG_DEBUG("PEBInfo: " << pebInfo);
91 
92  // Make an accept decision
94  }
95  return StatusCode::SUCCESS;
96 }
97 
98 // =============================================================================
99 
100 std::ostream& operator<< (std::ostream& str, const PEBInfoWriterToolBase::PEBInfo& pebi) {
101  str << "ROBs = [";
102  size_t i=0;
103  for (const uint32_t robid : pebi.robs) {
104  str << "0x" << std::hex << robid << std::dec;
105  ++i;
106  if (i!=pebi.robs.size()) str << ", ";
107  }
108  str << "], SubDets = [";
109  i=0;
110  for (const uint32_t subdetid : pebi.subdets) {
111  str << "0x" << std::hex << subdetid << std::dec;
112  ++i;
113  if (i!=pebi.subdets.size()) str << ", ";
114  }
115  str << "]";
116  return str;
117 }
TrigCompositeUtils::uniqueRoIs
bool uniqueRoIs(const std::vector< LinkInfo< xAOD::IParticleContainer >> &links)
Helper function that returns true if no objects share a final RoI.
Definition: IPartCombItr.cxx:56
TrigCompositeUtils::DecisionID
unsigned int DecisionID
Definition: TrigComposite_v1.h:27
TrigCompositeUtils::DecisionContainer
xAOD::TrigCompositeContainer DecisionContainer
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigCompositeContainer.h:21
TrigCompositeUtils::passed
bool passed(DecisionID id, const DecisionIDContainer &idSet)
checks if required decision ID is in the set of IDs in the container
Definition: TrigCompositeUtilsRoot.cxx:117
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
HLT::Identifier::numeric
TrigCompositeUtils::DecisionID numeric() const
numeric ID
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:47
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
TrigCompositeUtils::newDecisionIn
Decision * newDecisionIn(DecisionContainer *dc, const std::string &name)
Helper method to create a Decision object, place it in the container and return a pointer to it.
Definition: TrigCompositeUtilsRoot.cxx:46
TrigCompositeUtils::addDecisionID
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
Definition: TrigCompositeUtilsRoot.cxx:61
PEBInfoWriterToolBase::robListKey
static std::string robListKey()
Returns the key used to record/retrieve the ROB list.
Definition: PEBInfoWriterToolBase.h:61
TrigCompositeUtils::createAndStore
SG::WriteHandle< DecisionContainer > createAndStore(const SG::WriteHandleKey< DecisionContainer > &key, const EventContext &ctx)
Creates and right away records the DecisionContainer with the key.
Definition: TrigCompositeUtilsRoot.cxx:30
PEBInfoWriterToolBase::~PEBInfoWriterToolBase
virtual ~PEBInfoWriterToolBase()
Standard destructor.
Definition: PEBInfoWriterToolBase.cxx:26
postInclude.inputs
inputs
Definition: postInclude.SortInput.py:15
PEBInfoWriterToolBase.h
PEBInfoWriterToolBase::PEBInfo::robs
std::set< uint32_t > robs
Definition: PEBInfoWriterToolBase.h:45
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
PEBInfoWriterToolBase::decide
StatusCode decide(std::vector< Input > &inputs) const
Adds a pass-through decision with attached PEB information created by createPEBInfo for each input.
Definition: PEBInfoWriterToolBase.cxx:30
HLT
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
Definition: HLTResultReader.h:26
lumiFormat.i
int i
Definition: lumiFormat.py:85
PEBInfoWriterToolBase::m_maxRoIs
Gaudi::Property< int > m_maxRoIs
MaxRoIs property.
Definition: PEBInfoWriterToolBase.h:69
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
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
test_pyathena.parent
parent
Definition: test_pyathena.py:15
PEBInfoWriterToolBase::subDetListKey
static std::string subDetListKey()
Returns the key used to record/retrieve the SubDet list.
Definition: PEBInfoWriterToolBase.h:63
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
PEBInfoWriterToolBase::createPEBInfo
virtual PEBInfo createPEBInfo(const Input &input) const =0
Creates the PEBInfo which is attached to the decision in decide. Has to be implemented by the derived...
operator<<
std::ostream & operator<<(std::ostream &str, const PEBInfoWriterToolBase::PEBInfo &pebi)
Definition: PEBInfoWriterToolBase.cxx:100
PEBInfoWriterToolBase::PEBInfo::subdets
std::set< uint32_t > subdets
Definition: PEBInfoWriterToolBase.h:46
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
PEBInfoWriterToolBase::m_decisionId
HLT::Identifier m_decisionId
The decision id of the tool instance.
Definition: PEBInfoWriterToolBase.h:79
TrigCompositeUtils::Decision
xAOD::TrigComposite Decision
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:20
PEBInfoWriterToolBase::m_matchTriggerType
Gaudi::Property< std::vector< unsigned int > > m_matchTriggerType
Definition: PEBInfoWriterToolBase.h:73
TrigCompositeUtils::DecisionIDContainer
std::set< DecisionID > DecisionIDContainer
Definition: TrigComposite_v1.h:28
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TrigCompositeUtils::decisionIDs
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
Definition: TrigCompositeUtilsRoot.cxx:67
PEBInfoWriterToolBase::PEBInfoWriterToolBase
PEBInfoWriterToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
Definition: PEBInfoWriterToolBase.cxx:20
PEBInfoWriterToolBase::Input
Input to the tool's decide method.
Definition: PEBInfoWriterToolBase.h:25
str
Definition: BTagTrackIpAccessor.cxx:11
PEBInfoWriterToolBase::PEBInfo
Structure holding the list of ROBs and SubDets.
Definition: PEBInfoWriterToolBase.h:44
AthAlgTool
Definition: AthAlgTool.h:26
Identifier
Definition: IdentifierFieldParser.cxx:14