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  // Count unique RoIs
40  bool isUnique = uniqueRoIs.insert(input.roiEL).second;
41  ATH_MSG_DEBUG("RoI eta/phi = " << (*input.roiEL)->eta() << "/" << (*input.roiEL)->phi() << " has "
42  << (isUnique ? "not yet" : "already") << " been processed. So far seen "
43  << uniqueRoIs.size() << " unique RoIs including this one");
44 
45  // Skip processing if max RoIs limit reached
46  bool maxRoIsReached{false};
47  if (m_maxRoIs>=0 && static_cast<int>(uniqueRoIs.size()) > m_maxRoIs) {
48  ATH_MSG_DEBUG("Will attach empty PEB Info to this decision because the number of "
49  << "processed RoIs reached MaxRoIs (" << m_maxRoIs.value() << ")");
50  maxRoIsReached = true;
51  }
52 
53  // Create new PEB Info for this input (empty if max RoIs limit is reached)
54  PEBInfo pebInfo = maxRoIsReached ? PEBInfo{} : createPEBInfo(input);
55 
56  // Merge with previous ROBs
57  std::vector<uint32_t> previousRobs;
58  ATH_CHECK(input.decision->getDetail(robListKey(), previousRobs));
59  pebInfo.robs.insert(previousRobs.begin(), previousRobs.end());
60 
61  // Merge with previous SubDets
62  std::vector<uint32_t> previousSubDets;
63  ATH_CHECK(input.decision->getDetail(subDetListKey(), previousSubDets));
64  pebInfo.subdets.insert(previousSubDets.begin(), previousSubDets.end());
65 
66  // Attach the PEB Info to the decision
67  std::vector<uint32_t> robVec(pebInfo.robs.begin(), pebInfo.robs.end());
68  if (not input.decision->setDetail(robListKey(), robVec)) {
69  ATH_MSG_ERROR("Failed to attach the detail " << robListKey() << " to the decision");
70  return StatusCode::FAILURE;
71  }
72  std::vector<uint32_t> subDetVec(pebInfo.subdets.begin(), pebInfo.subdets.end());
73  if (not input.decision->setDetail(subDetListKey(), subDetVec)) {
74  ATH_MSG_ERROR("Failed to attach the detail " << subDetListKey() << " to the decision");
75  return StatusCode::FAILURE;
76  }
77 
78  ATH_MSG_DEBUG("Attached PEB Info with " << robVec.size() << " ROBs and "
79  << subDetVec.size() << " SubDets to the decision object.");
80  ATH_MSG_DEBUG("PEBInfo: " << pebInfo);
81 
82  // Make an accept decision
84  }
85  return StatusCode::SUCCESS;
86 }
87 
88 // =============================================================================
89 
90 std::ostream& operator<< (std::ostream& str, const PEBInfoWriterToolBase::PEBInfo& pebi) {
91  str << "ROBs = [";
92  size_t i=0;
93  for (const uint32_t robid : pebi.robs) {
94  str << "0x" << std::hex << robid << std::dec;
95  ++i;
96  if (i!=pebi.robs.size()) str << ", ";
97  }
98  str << "], SubDets = [";
99  i=0;
100  for (const uint32_t subdetid : pebi.subdets) {
101  str << "0x" << std::hex << subdetid << std::dec;
102  ++i;
103  if (i!=pebi.subdets.size()) str << ", ";
104  }
105  str << "]";
106  return str;
107 }
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
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:57
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:41
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:92
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
PEBInfoWriterToolBase::m_maxRoIs
Gaudi::Property< int > m_maxRoIs
MaxRoIs property.
Definition: PEBInfoWriterToolBase.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
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:59
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:90
PEBInfoWriterToolBase::PEBInfo::subdets
std::set< uint32_t > subdets
Definition: PEBInfoWriterToolBase.h:42
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
PEBInfoWriterToolBase::m_decisionId
HLT::Identifier m_decisionId
The decision id of the tool instance.
Definition: PEBInfoWriterToolBase.h:71
TrigCompositeUtils::Decision
xAOD::TrigComposite Decision
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:20
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:40
AthAlgTool
Definition: AthAlgTool.h:26