ATLAS Offline Software
Loading...
Searching...
No Matches
IDCalibHypoTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
4 * Trigger Hypo Tool for IDCalib stream trigger
5 * author Kunihiro Nagano <kunihiro.nagano@cern.ch>
6*/
7
12#include "IDCalibHypoTool.h"
13#include "GaudiKernel/PhysicalConstants.h"
14
15using namespace TrigCompositeUtils;
16
17// ------------------------------------------------------------------------------------------------
18// ------------------------------------------------------------------------------------------------
19
20IDCalibHypoTool::IDCalibHypoTool( const std::string& type, const std::string& name, const IInterface* parent )
21 : AthAlgTool( type, name, parent ),
22 m_decisionId( HLT::Identifier::fromToolName( name ) ) {}
23
24// ------------------------------------------------------------------------------------------------
25// ------------------------------------------------------------------------------------------------
26
28{
29 ATH_MSG_INFO( "Initialization completed successfully:" );
30 ATH_MSG_INFO( " cutTrackPtGeV = " << m_cutTrackPtGeV );
31 ATH_MSG_INFO( "Tool configured for chain/id: " << m_decisionId );
32
33 return StatusCode::SUCCESS;
34}
35
36// ------------------------------------------------------------------------------------------------
37// ------------------------------------------------------------------------------------------------
38
39StatusCode IDCalibHypoTool::decide( std::vector<IDCalibHypoInfo>& toolInputs ) const
40{
41 size_t numTrigger = m_cutTrackPtGeV.size();
42 size_t numTrks = toolInputs.size();
43
44 ATH_MSG_DEBUG( "Number of Tracks = " << numTrks );
45
46 if ( numTrigger == 1 ) {
47 ATH_MSG_DEBUG( "Applying selection of single for " << m_decisionId );
48 return inclusiveSelection(toolInputs);
49 }
50 else {
51 ATH_MSG_DEBUG( "Applying selection of multiplicity for " << m_decisionId );
52 return multiplicitySelection(toolInputs);
53 }
54
55 return StatusCode::SUCCESS;
56}
57
58// ------------------------------------------------------------------------------------------------
59// ------------------------------------------------------------------------------------------------
60
61StatusCode IDCalibHypoTool::inclusiveSelection(std::vector<IDCalibHypoInfo>& toolInputs) const
62{
63 bool isPassed = false;
64 unsigned int iTrk=0;
65 for ( auto& input: toolInputs ) {
66 ATH_MSG_DEBUG( "--- iTrk=" << iTrk << " ---" );
67 if ( TrigCompositeUtils::passed( m_decisionId.numeric(), input.previousDecisionsIDs ) ) {
68 if ( decideOnSingleObject( input, 0 )==true ) {
69 ATH_MSG_DEBUG( " Passed selection --> adding DecisionID" );
70 isPassed = true;
72 }
73 } else {
74 ATH_MSG_DEBUG( " Not match DecisionID: " << m_decisionId );
75 }
76 ++iTrk;
77 }
78
79 ATH_MSG_DEBUG( "Inclusive selection isPassed = " << isPassed );
80 return StatusCode::SUCCESS;
81}
82
83// ------------------------------------------------------------------------------------------------
84// ------------------------------------------------------------------------------------------------
85
86StatusCode IDCalibHypoTool::multiplicitySelection(std::vector<IDCalibHypoInfo>& toolInputs) const
87{
88 HLT::Index2DVec passingSelection( m_cutTrackPtGeV.size() );
89
90 for ( size_t cutIndex=0; cutIndex < m_cutTrackPtGeV.size(); ++cutIndex ) {
91 size_t elementIndex{ 0 };
92 for ( auto& input: toolInputs ) {
93 if ( TrigCompositeUtils::passed( m_decisionId.numeric(), input.previousDecisionsIDs ) ) {
94 if ( decideOnSingleObject( input, cutIndex ) == true ) {
95 ATH_MSG_DEBUG( "Pass through selection " << m_decisionId << " : Event[" << elementIndex << "]" );
96 passingSelection[cutIndex].push_back( elementIndex );
97 }
98 }
99 else {
100 ATH_MSG_DEBUG( "Not match DecisionID " << m_decisionId );
101 }
102 elementIndex++;
103 }
104 // If no object passes the selection, multipul selection should stop.
105 if ( passingSelection[cutIndex].empty() ) {
106 ATH_MSG_DEBUG( "No object passed selection " << cutIndex << " rejecting" );
107 return StatusCode::SUCCESS;
108 }
109 }
110
111 std::set<size_t> passingIndices;
112 HLT::elementsInUniqueCombinations( passingSelection, passingIndices );
113
114 if ( passingIndices.empty() ) {
115 ATH_MSG_DEBUG( "No track passed through selection " << m_decisionId );
116 return StatusCode::SUCCESS;
117 }
118
119 for ( auto idx: passingIndices ) {
120 ATH_MSG_DEBUG( "track[" << idx << "] passes through Chain/ID " << m_decisionId << " with pT" );
121 TrigCompositeUtils::addDecisionID( m_decisionId.numeric(), toolInputs[idx].decision );
122 }
123
124 return StatusCode::SUCCESS;
125}
126
127// ------------------------------------------------------------------------------------------------
128// ------------------------------------------------------------------------------------------------
129
130bool IDCalibHypoTool::decideOnSingleObject( IDCalibHypoInfo& input, size_t cutIndex ) const
131{
132 bool is_passed = false;
133
134 // values
135 float pt = input.track->pt();
136 pt /= Gaudi::Units::GeV;
137
138 // pt selection
139 if( pt >= m_cutTrackPtGeV[cutIndex] ) is_passed = true;
140
141 //
142 ATH_MSG_DEBUG( " isPassed = " << is_passed << ", cut index / pT = " << cutIndex << " / " << pt );
143 return is_passed;
144}
145
146// ------------------------------------------------------------------------------------------------
147// ------------------------------------------------------------------------------------------------
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Header file to be included by clients of the Monitored infrastructure.
static const Attributes_t empty
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
IDCalibHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
StatusCode multiplicitySelection(std::vector< IDCalibHypoInfo > &) const
Gaudi::Property< std::vector< float > > m_cutTrackPtGeV
StatusCode inclusiveSelection(std::vector< IDCalibHypoInfo > &) const
StatusCode decide(std::vector< IDCalibHypoInfo > &) const
decides upon a collection of tracks
bool decideOnSingleObject(IDCalibHypoInfo &, size_t) const
HLT::Identifier m_decisionId
virtual StatusCode initialize() override
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
void elementsInUniqueCombinations(const Index2DVec &indices, std::set< size_t > &participants, const std::function< bool(const Index1DVec &)> &filter)
std::vector< Index1DVec > Index2DVec
bool passed(DecisionID id, const DecisionIDContainer &idSet)
checks if required decision ID is in the set of IDs in the container
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.