ATLAS Offline Software
TrigVSIHypoTool.cxx
Go to the documentation of this file.
1 /*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "TrigVSIHypoTool.h"
6 
10 
11 #include <array>
12 
13 using namespace TrigCompositeUtils;
14 
15 TrigVSIHypoTool::TrigVSIHypoTool( const std::string& type,const std::string& name,const IInterface* parent )
16 : AthAlgTool( type, name, parent ),
17 m_decisionId( HLT::Identifier::fromToolName( name ) ) {}
18 
20  return StatusCode::SUCCESS;
21 }
22 
24  if ( vtxinfo.previousDecisionIDs.count( m_decisionId.numeric() ) == 0 ) {
25  ATH_MSG_DEBUG("Already rejected");
26  return StatusCode::SUCCESS;
27  }
28 
29  bool passNTrkCut = false;
30  bool passRCut = false;
31  bool passPtCut = false;
32  bool passChi2Cut = false;
33  bool passMassCut = false;
34 
35  bool passSelection = false;
36 
37  static const SG::ConstAccessor<float> vsi_massAcc ("vsi_mass");
38  static const SG::ConstAccessor<float> vsi_pTAcc ("vsi_pT");
39 
40  for (auto vertex : vtxinfo.vertices) {
41  passNTrkCut = false;
42  passRCut = false;
43  passPtCut = false;
44  passChi2Cut = false;
45  passMassCut = false;
46 
47  if ( vertex == nullptr ) continue;
48  const size_t ntrk = vertex->nTrackParticles();
49  const float pT = vsi_pTAcc.withDefault(*vertex, 0);
50  const float chi2 = vertex->chiSquared();
51  const float mass = vsi_massAcc.withDefault(*vertex, 0);
52 
53  const float x_ = vertex->position().x();
54  const float y_ = vertex->position().y();
55  const float r = std::sqrt(x_*x_+y_*y_);
56 
57  if ( ntrk >= m_minNTrks
58  && (ntrk <= m_maxNTrks || m_maxNTrks <= m_minNTrks)
59  ) passNTrkCut = true;
60 
61  if ( r >= m_minR
62  && r <= m_maxR
63  ) passRCut = true;
64 
65  if ( pT > m_minPt
66  && pT < m_maxPt
67  ) passPtCut = true;
68 
69  if ( chi2 < m_maxChi2
70  ) passChi2Cut = true;
71 
72  if ( mass > m_minMass
73  && mass < m_maxMass
74  ) passMassCut = true;
75 
76  std::array<bool,5> decisions{ passNTrkCut, passRCut, passPtCut, passChi2Cut, passMassCut };
77 
78  if ( m_logicAnd ) {
79  passSelection = std::all_of( decisions.begin(), decisions.end(), [](bool k ){return k;} );
80  } else {
81  passSelection = std::any_of( decisions.begin(), decisions.end(), [](bool k ){return k;} );
82  }
83 
84  if (passSelection) break;
85  }
86 
87  if ( !passSelection ) {
88  return StatusCode::SUCCESS;
89  } else {
91  ATH_MSG_DEBUG ("REGTEST event accepted");
92  }
93 
94  return StatusCode::SUCCESS;
95 }
TrigVSIHypoTool::eventVtxInfo::vertices
std::vector< const xAOD::Vertex * > vertices
Definition: TrigVSIHypoTool.h:28
beamspotman.r
def r
Definition: beamspotman.py:676
TrigVSIHypoTool::eventVtxInfo::decision
TrigCompositeUtils::Decision * decision
Definition: TrigVSIHypoTool.h:27
TrigVSIHypoTool::m_logicAnd
Gaudi::Property< bool > m_logicAnd
Definition: TrigVSIHypoTool.h:46
CalculateHighPtTerm.pT
pT
Definition: ICHEP2016/CalculateHighPtTerm.py:57
HLT::Identifier::numeric
TrigCompositeUtils::DecisionID numeric() const
numeric ID
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:47
Base_Fragment.mass
mass
Definition: Sherpa_i/share/common/Base_Fragment.py:59
TrigVSIHypoTool::m_decisionId
HLT::Identifier m_decisionId
Definition: TrigVSIHypoTool.h:36
TrigCompositeUtils::addDecisionID
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
Definition: TrigCompositeUtilsRoot.cxx:61
TrigVSIHypoTool::eventVtxInfo
Definition: TrigVSIHypoTool.h:26
TrigVSIHypoTool::m_minR
Gaudi::Property< float > m_minR
Definition: TrigVSIHypoTool.h:39
TrigVSIHypoTool::m_minPt
Gaudi::Property< float > m_minPt
Definition: TrigVSIHypoTool.h:41
SG::ConstAccessor< float >
TrigVSIHypoTool::decide
StatusCode decide(eventVtxInfo &decisions) const
Definition: TrigVSIHypoTool.cxx:23
TrigVSIHypoTool::m_maxPt
Gaudi::Property< float > m_maxPt
Definition: TrigVSIHypoTool.h:42
HLT
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
Definition: HLTResultReader.h:26
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
TrigVSIHypoTool::TrigVSIHypoTool
TrigVSIHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TrigVSIHypoTool.cxx:15
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:523
test_pyathena.parent
parent
Definition: test_pyathena.py:15
TrigVSIHypoTool.h
TrigVSIHypoTool::m_maxR
Gaudi::Property< float > m_maxR
Definition: TrigVSIHypoTool.h:40
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
xAOD::decisions
decisions
Definition: TrigComposite_v1.cxx:101
TrigVSIHypoTool::m_maxMass
Gaudi::Property< float > m_maxMass
Definition: TrigVSIHypoTool.h:45
TrigVSIHypoTool::m_maxNTrks
Gaudi::Property< float > m_maxNTrks
Definition: TrigVSIHypoTool.h:38
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TrigVSIHypoTool::initialize
virtual StatusCode initialize() override
Definition: TrigVSIHypoTool.cxx:19
TrigVSIHypoTool::m_minNTrks
Gaudi::Property< float > m_minNTrks
Definition: TrigVSIHypoTool.h:37
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
TrigVSIHypoTool::m_minMass
Gaudi::Property< float > m_minMass
Definition: TrigVSIHypoTool.h:44
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
HLTIdentifier.h
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
AthAlgTool
Definition: AthAlgTool.h:26
TrigVSIHypoTool::m_maxChi2
Gaudi::Property< float > m_maxChi2
Definition: TrigVSIHypoTool.h:43
TrigVSIHypoTool::eventVtxInfo::previousDecisionIDs
const TrigCompositeUtils::DecisionIDContainer previousDecisionIDs
Definition: TrigVSIHypoTool.h:29
fitman.k
k
Definition: fitman.py:528
SG::ConstAccessor::withDefault
const_reference_type withDefault(const ELT &e, const T &deflt) const
Fetch the variable for one element, as a const reference, with a default.
Identifier
Definition: IdentifierFieldParser.cxx:14