ATLAS Offline Software
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 
9 using 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 
22 }
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 
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 
153 StatusCode 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 
172 StatusCode 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 
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
get_generator_info.result
result
Definition: get_generator_info.py:21
TrigMuonEFTrackIsolationHypoTool.h
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
TrigMuonEFTrackIsolationHypoTool::decide
virtual StatusCode decide(std::vector< TrigMuonEFTrackIsolationHypoTool::EFIsolationMuonInfo > &toolInput) const
Definition: TrigMuonEFTrackIsolationHypoTool.cxx:153
HLT::Identifier::numeric
TrigCompositeUtils::DecisionID numeric() const
numeric ID
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:47
TrigMuonEFTrackIsolationHypoTool::m_ptcone02_cut
Gaudi::Property< float > m_ptcone02_cut
Definition: TrigMuonEFTrackIsolationHypoTool.h:67
TrigMuonEFTrackIsolationHypoTool::m_ptcone03_cut
Gaudi::Property< float > m_ptcone03_cut
Definition: TrigMuonEFTrackIsolationHypoTool.h:69
TrigCompositeUtils::addDecisionID
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
Definition: TrigCompositeUtilsRoot.cxx:61
xAOD::Iso::ptcone30
@ ptcone30
Definition: IsolationType.h:41
xAOD::Iso::ptcone20
@ ptcone20
Track isolation.
Definition: IsolationType.h:40
TrigMuonEFTrackIsolationHypoTool::m_acceptAll
Gaudi::Property< bool > m_acceptAll
Definition: TrigMuonEFTrackIsolationHypoTool.h:65
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
TrigMuonEFTrackIsolationHypoTool::TrigMuonEFTrackIsolationHypoTool
TrigMuonEFTrackIsolationHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TrigMuonEFTrackIsolationHypoTool.cxx:13
TrigMuonEFTrackIsolationHypoTool::m_requireCombined
Gaudi::Property< bool > m_requireCombined
Definition: TrigMuonEFTrackIsolationHypoTool.h:75
TrigMuonEFTrackIsolationHypoTool::~TrigMuonEFTrackIsolationHypoTool
virtual ~TrigMuonEFTrackIsolationHypoTool()
Definition: TrigMuonEFTrackIsolationHypoTool.cxx:21
TrigMuonEFTrackIsolationHypoTool::m_abscut
Gaudi::Property< bool > m_abscut
Definition: TrigMuonEFTrackIsolationHypoTool.h:71
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
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
TrigMuonEFTrackIsolationHypoTool::decideOnSingleObject
bool decideOnSingleObject(TrigMuonEFTrackIsolationHypoTool::EFIsolationMuonInfo &input, size_t cutIndex) const
Definition: TrigMuonEFTrackIsolationHypoTool.cxx:68
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
TrigMuonEFTrackIsolationHypoTool::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: TrigMuonEFTrackIsolationHypoTool.h:77
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TrigMuonEFTrackIsolationHypoTool::EFIsolationMuonInfo
Definition: TrigMuonEFTrackIsolationHypoTool.h:30
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
Trk::Combined
@ Combined
Definition: TrackSummaryTool.h:32
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
TrigMuonEFTrackIsolationHypoTool::initialize
virtual StatusCode initialize() override
Definition: TrigMuonEFTrackIsolationHypoTool.cxx:27
TrigMuonEFTrackIsolationHypoTool::inclusiveSelection
StatusCode inclusiveSelection(std::vector< TrigMuonEFTrackIsolationHypoTool::EFIsolationMuonInfo > &toolInput) const
Definition: TrigMuonEFTrackIsolationHypoTool.cxx:172
TrigMuonEFTrackIsolationHypoTool::m_decisionId
HLT::Identifier m_decisionId
Definition: TrigMuonEFTrackIsolationHypoTool.h:63
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
AthAlgTool
Definition: AthAlgTool.h:26