11#include <unordered_set>
14 const std::string s_expressStreamName{
"express"};
29 for (
auto& collection: collections ) {
31 ATH_MSG_DEBUG(
"Final decision of the chain " << chain <<
" will be read from " << collection );
40 return StatusCode::SUCCESS;
49 std::vector<std::string> streams = chain.streams();
50 streams.erase(
std::remove(streams.begin(),streams.end(),s_expressStreamName), streams.end());
54 return StatusCode::SUCCESS;
58 return StatusCode::SUCCESS;
77 if ( not handle.isValid() ) {
78 ATH_MSG_DEBUG(
"Input " << key.key() <<
" not present, did not run in this event.");
83 ATH_MSG_WARNING(
"The collection " << key.key() <<
" is not configured to contain any final decision,"
84 <<
"remove it from the configuration of " << name() <<
" to save time" );
88 for (
const Decision* decisionObject: *handle ) {
92 if (passingFinalIDs.empty()) {
109 allPassingFinalIDs.insert( passingFinalIDs.begin(), passingFinalIDs.end() );
115 allPassingFinalIDs.begin(), allPassingFinalIDs.end() );
118 ATH_MSG_DEBUG(
"Number of positive decisions " << allPassingFinalIDs.size() <<
" passing chains");
119 for (
auto d: allPassingFinalIDs ) {
129 const Decision* l1SeededChains =
nullptr;
130 const Decision* activeChains =
nullptr;
131 const Decision* prescaledChains =
nullptr;
132 for (
const Decision* d : *hltSeedingSummary) {
133 if (d->name() ==
"l1seeded") {
135 }
else if (d->name() ==
"unprescaled") {
137 }
else if (d->name() ==
"prescaled") {
140 ATH_MSG_ERROR(
"DecisionSummaryMakerAlg encountered an unknown set of decisions from the HLTSeeding, name '" << d->name() <<
"'");
141 return StatusCode::FAILURE;
145 if (l1SeededChains ==
nullptr || activeChains ==
nullptr || prescaledChains ==
nullptr) {
146 ATH_MSG_ERROR(
"Unable to read in the summary from the HLTSeeding. Cannot write to the HLT output summary the prescale status of HLT chains.");
147 return StatusCode::FAILURE;
158 prescaledIDs.begin(), prescaledIDs.end() );
162 HLT::IDVec allPassingFinalIDsVec{allPassingFinalIDs.begin(),allPassingFinalIDs.end()};
167 expressIDs.insert(
id.numeric());
174 std::unordered_set<std::string> passStreamsSet;
175 for (
const DecisionID chainID : allPassingFinalIDs) {
177 for (
const std::string& streamName : it->second) {
178 passStreamsSet.insert(streamName);
185 if (!expressIDs.empty()) {
186 passStreamsSet.insert(s_expressStreamName);
189 ATH_CHECK(passStreams.
record(std::make_unique<std::vector<std::string>>(passStreamsSet.begin(),passStreamsSet.end())));
192 std::ostringstream streamNames;
194 for (
const std::string& s : passStreamsSet) {
195 if (first) {first=
false;}
196 else {streamNames <<
", ";}
199 ATH_MSG_DEBUG(
"This event is accepted to " << passStreamsSet.size() <<
" streams: " << streamNames.str());
204 bool filterStatus =
true;
206 filterStatus = (not allPassingFinalIDs.empty());
210 return StatusCode::SUCCESS;
215 using RoILinkVec = std::vector<LinkInfo<TrigRoiDescriptorCollection>>;
217 auto printDecision = [
this](
const Decision* d){
230 for (
const auto& finalRoILink : allFinalRoIs) {
232 if (!finalRoILink.isValid() || *(finalRoILink.link)==
nullptr) {
234 printDecision(finalRoILink.source);
246 if (initialRoIs.empty()) {
248 printDecisionAndRoI(finalRoILink.source, finalRoI);
251 if (initialRoIs.size()>1) {
252 ATH_MSG_WARNING(
"Encountered decision node with multiple (" << initialRoIs.size() <<
") "
254 printDecisionAndRoI(finalRoILink.source, finalRoI);
258 const auto& initialRoILink = initialRoIs.front();
259 if (!initialRoILink.isValid() || *(initialRoILink.link)==
nullptr) {
261 printDecisionAndRoI(finalRoILink.source, finalRoI);
277 if (std::abs(dEta) > 1.0 || std::abs(dPhi) > 1.0 || std::abs(dZed) > 200) {
279 <<
"dEta=" << dEta <<
", dPhi=" << dPhi <<
", dZed=" << dZed
280 <<
"initialRoI: " << initialRoI <<
", finalRoI: " << finalRoI);
281 printDecision(finalRoILink.source);
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
xAOD::TrigComposite Decision
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.
std::set< DecisionID > DecisionIDContainer
SG::WriteHandle< DecisionContainer > createAndStore(const SG::WriteHandleKey< DecisionContainer > &key, const EventContext &ctx)
Creates and right away records the DecisionContainer with the key.
void decisionIDs(const Decision *d, DecisionIDContainer &id)
Extracts DecisionIDs stored in the Decision object.
void linkToPrevious(Decision *d, const std::string &previousCollectionKey, size_t previousIndex)
Links to the previous object, location of previous 'seed' decision supplied by hand.
const std::string & roiString()
DecisionIDContainer passedDecisionIDs(const Decision *d, const T &required)
return DecisionIDs in Decision object that match the required ones
void renounceArray(SG::VarHandleKeyArray &handlesArray)
bool msgLvl(const MSG::Level lvl) const
virtual void setFilterPassed(bool state, const EventContext &ctx) const
An algorithm that can be simultaneously executed in multiple threads.
Gaudi::Property< bool > m_warnOnLargeRoIUpdates
SG::WriteHandleKey< TrigCompositeUtils::DecisionContainer > m_summaryKey
Gaudi::Property< bool > m_setFilterStatus
SG::WriteHandleKey< std::vector< std::string > > m_streamsSummaryKey
virtual StatusCode initialize() override
void monitorRoIs(const TrigCompositeUtils::Decision *terminusNode) const
Monitor RoI updates between initial and final RoI.
ToolHandle< IPrescalingTool > m_prescaler
std::unordered_map< TrigCompositeUtils::DecisionID, std::vector< std::string > > m_chainToStreamsMap
Chain to streams map filled from the HLT Menu JSON.
virtual StatusCode start() override
DecisionSummaryMakerAlg(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< std::map< std::string, std::vector< std::string > > > m_lastStepForChain
virtual StatusCode execute(const EventContext &context) const override
ToolHandle< GenericMonitoringTool > m_monTool
SG::ReadHandleKey< xAOD::TrigCompositeContainer > m_hltSeedingSummaryKey
virtual StatusCode finalize() override
std::map< std::string, TrigCompositeUtils::DecisionIDContainer > m_collectionFilter
SG::ReadHandleKeyArray< TrigCompositeUtils::DecisionContainer > m_finalDecisionKeys
SG::ReadHandleKey< TrigConf::HLTMenu > m_hltMenuKey
TrigCompositeUtils::DecisionID numeric() const
numeric ID
Group of local monitoring quantities and retain correlation when filling histograms
Declare a monitored scalar variable.
virtual double zed() const override final
virtual bool isFullscan() const override final
is this a full scan RoI?
virtual double phi() const override final
Methods to retrieve data members.
virtual double eta() const override final
virtual bool composite() const override final
SuperRoI compatability methods.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...
T deltaPhi(T phiA, T phiB)
Return difference phiA - phiB in range [-pi, pi].
std::vector< HLT::Identifier > IDVec
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
const std::string & summaryPrescaledNodeName()
const std::string & summaryFilterNodeName()
xAOD::TrigComposite Decision
void findLinks(const Decision *start, const std::string &linkName, std::vector< LinkInfo< T > > &links, unsigned int behaviour=TrigDefs::allFeaturesOfType, std::set< const xAOD::TrigComposite * > *fullyExploredFrom=nullptr)
search back the TC links for the object of type T linked to the one of TC (recursively) Populates pro...
const std::string & initialRoIString()
const std::string & summaryPassNodeName()
const std::string & summaryPassExpressNodeName()
static const unsigned int lastFeatureOfType
Run 3 "enum". Only return the final feature along each route through the navigation.
DataModel_detail::iterator< DVL > remove(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end, const T &value)
Specialization of remove for DataVector/List.
Helper for azimuthal angle calculations.