ATLAS Offline Software
Loading...
Searching...
No Matches
TrigMuonEFTrackIsolationHypoTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
7
8
9using namespace TrigCompositeUtils;
10// --------------------------------------------------------------------------------
11// --------------------------------------------------------------------------------
12
14 const std::string & name,
15 const IInterface* parent )
16 : AthAlgTool( type, name, parent ),
17 m_decisionId( HLT::Identifier::fromToolName( name ) )
18{
19}
20
23
24// --------------------------------------------------------------------------------
25// --------------------------------------------------------------------------------
26
28{
29 ATH_MSG_DEBUG("Initializing " << name());
30
31 if ( m_acceptAll ) {
32 ATH_MSG_DEBUG("AcceptAll = True");
33 ATH_MSG_DEBUG("Accepting all the events!");
34 }
35 else {
36 ATH_MSG_DEBUG("AcceptAll = False");
37 if ( m_ptcone02_cut < 0.0 && m_ptcone03_cut < 0.0 ) {
38 ATH_MSG_ERROR("Configured to apply cuts, but not cut was specified");
39 return StatusCode::SUCCESS;
40 }
41 if ( m_ptcone02_cut > 0.0 ) {
42 if ( m_abscut ) {
43 ATH_MSG_DEBUG("Requiring sum pT in 0.2 cone < " << m_ptcone02_cut.value() << " MeV");
44 } else {
45 ATH_MSG_DEBUG("Requiring sum pT in 0.2 cone / muon pT < " << m_ptcone02_cut.value());
46 }
47 }
48 if ( m_ptcone03_cut > 0.0 ) {
49 if ( m_abscut ) {
50 ATH_MSG_DEBUG("Requiring sum pT in 0.3 cone < " << m_ptcone03_cut.value() << " MeV");
51 } else {
52 ATH_MSG_DEBUG("Requiring sum pT in 0.3 cone / muon pT < " << m_ptcone03_cut.value());
53 }
54 }
55 }
56
57 if ( not m_monTool.name().empty() ) {
58 ATH_CHECK( m_monTool.retrieve() );
59 ATH_MSG_DEBUG("MonTool name: " << m_monTool);
60 }
61
62 return StatusCode::SUCCESS;
63}
64
65// --------------------------------------------------------------------------------
66// --------------------------------------------------------------------------------
67
69{
70 ATH_MSG_DEBUG("Decision ...");
71
72 float ptcone20(-1), ptcone30(-1);
73 auto fex_ptcone03 = Monitored::Scalar("PtCone03", 0.0);
74 auto fex_ptconeRel03 = Monitored::Scalar("PtConeRel03", 0.0);
75
76 auto monitorIt = Monitored::Group( m_monTool, fex_ptcone03, fex_ptconeRel03 );
77
78 ATH_MSG_VERBOSE( "Cut index " << cutIndex );
79
80 bool result = false;
81
82 if( m_acceptAll ) {
83 result = true;
84 ATH_MSG_DEBUG("Accept property is set: taking all the events");
85 return result;
86 }
87
88 auto pMuon = input.muEFIso;
89 if ( !pMuon ) {
90 result = false;
91 ATH_MSG_ERROR("Retrieval of L2StandAloneMuon from vector failed");
92 return result;
93 }
94
95 const xAOD::Muon::MuonType muontype = pMuon->muonType();
96
97 if ( m_requireCombined && muontype != xAOD::Muon::MuonType::Combined ) {
98 result = false;
99 ATH_MSG_DEBUG("Require combined muon, but this muon is not combined. -> false");
100 return result;
101 } else if ( muontype != xAOD::Muon::MuonType::MuonStandAlone && muontype != xAOD::Muon::MuonType::Combined ) {
102 result = false;
103 ATH_MSG_DEBUG("This muon type is neither standalone nor combined. -> false");
104 return result;
105 }
106
107
108 bool goodmu=true;
109 ptcone20 = input.ptcone20;
110 ptcone30 = input.ptcone30;
111
112 fex_ptcone03=ptcone30/1000;
113 if ( m_abscut ) { //absolute cut
114 if ( m_ptcone02_cut > 0.0 ) {
115 if ( ptcone20 >= m_ptcone02_cut ) goodmu=false;
116 }
117 if ( m_ptcone03_cut > 0.0 ) {
118 if ( ptcone30 >= m_ptcone03_cut ) goodmu=false;
119 }
120
121 ATH_MSG_DEBUG("Muon with pT cone 0.2 = " << ptcone20 << ", pT cone 0.3 = " << ptcone30
122 << " so result for this muon is " << (goodmu?"true":"false") );
123 } else { //relative cut
124
125 const double mupt = pMuon->pt();
126 fex_ptconeRel03 = ptcone30/mupt;
127 ATH_MSG_DEBUG("Muon with pT " << mupt);
128
129 // now we can make the cut(s)
130 if ( m_ptcone02_cut > 0.0 ) {
131 if( ptcone20/mupt >= m_ptcone02_cut ) goodmu=false;
132 }
133 if ( m_ptcone03_cut > 0.0 ) {
134 if ( ptcone30/mupt >= m_ptcone03_cut ) goodmu=false;
135 }
136
137 ATH_MSG_DEBUG("Muon with pT cone 0.2 / pt = " << ptcone20/mupt << ", pT cone 0.3 / pt = " << ptcone30/mupt
138 << " so result for this muon is " << (goodmu?"true":"false") );
139 }
140
141 if ( goodmu ) {
142 result = true;
143 }
144
145 ATH_MSG_DEBUG("Algo result = " << (result?"true":"false") );
146
147 return result;
148}
149
150// --------------------------------------------------------------------------------
151// --------------------------------------------------------------------------------
152
153StatusCode TrigMuonEFTrackIsolationHypoTool::decide(std::vector<EFIsolationMuonInfo>& toolInput) const
154{
155 ATH_MSG_DEBUG("Deciding ...");
156
157 size_t numMuon = toolInput.size();
158 ATH_MSG_DEBUG("Number of muon event = " << numMuon);
159
160 if ( numMuon==0 ) {
161 ATH_MSG_DEBUG("The event has no muon, so No applying selection " << m_decisionId);
162 return StatusCode::SUCCESS;
163 } else {
164 ATH_MSG_DEBUG("Applying selection of single" << m_decisionId);
165 return inclusiveSelection(toolInput);
166 }
167
168 return StatusCode::SUCCESS;
169}
170
171
172StatusCode TrigMuonEFTrackIsolationHypoTool::inclusiveSelection(std::vector<TrigMuonEFTrackIsolationHypoTool::EFIsolationMuonInfo>& toolInput) const
173{
174 ATH_MSG_DEBUG("Inclusive ...");
175
176 for ( auto&i : toolInput ) {
177 // If muon event has defference DecisionID, it shouldn't apply.
178 if ( TrigCompositeUtils::passed( m_decisionId.numeric(), i.previousDecisionIDs ) ) {
179 if ( decideOnSingleObject( i, 0 )==true ) {
180 ATH_MSG_DEBUG("Pass through selection " << m_decisionId );
182 } else {
183 ATH_MSG_DEBUG("Not pass through selection " << m_decisionId );
184 }
185 } else {
186 ATH_MSG_DEBUG("Not match DecisionID:" << m_decisionId );
187 }
188 }
189 return StatusCode::SUCCESS;
190}
191
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
Header file to be included by clients of the Monitored infrastructure.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Group of local monitoring quantities and retain correlation when filling histograms
Declare a monitored scalar variable.
ToolHandle< GenericMonitoringTool > m_monTool
virtual StatusCode decide(std::vector< TrigMuonEFTrackIsolationHypoTool::EFIsolationMuonInfo > &toolInput) const
StatusCode inclusiveSelection(std::vector< TrigMuonEFTrackIsolationHypoTool::EFIsolationMuonInfo > &toolInput) const
bool decideOnSingleObject(TrigMuonEFTrackIsolationHypoTool::EFIsolationMuonInfo &input, size_t cutIndex) const
TrigMuonEFTrackIsolationHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
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.