ATLAS Offline Software
Loading...
Searching...
No Matches
TrigVSIHypoTool.cxx
Go to the documentation of this file.
1/*
2Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "TrigVSIHypoTool.h"
6
10
11#include <array>
12
13using namespace TrigCompositeUtils;
14
15TrigVSIHypoTool::TrigVSIHypoTool( const std::string& type,const std::string& name,const IInterface* parent )
16: AthAlgTool( type, name, parent ),
17m_decisionId( HLT::Identifier::fromToolName( name ) ) {}
18
20 return StatusCode::SUCCESS;
21}
22
23StatusCode TrigVSIHypoTool::decide( eventVtxInfo& vtxinfo ) const {
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 {
90 addDecisionID( m_decisionId.numeric(), vtxinfo.decision );
91 ATH_MSG_DEBUG ("REGTEST event accepted");
92 }
93
94 return StatusCode::SUCCESS;
95}
#define ATH_MSG_DEBUG(x)
Helper class to provide constant type-safe access to aux data.
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:
Helper class to provide constant type-safe access to aux data.
const_reference_type withDefault(const ELT &e, const T &deflt) const
Fetch the variable for one element, as a const reference, with a default.
StatusCode decide(eventVtxInfo &decisions) const
virtual StatusCode initialize() override
Gaudi::Property< float > m_maxPt
Gaudi::Property< float > m_minNTrks
Gaudi::Property< float > m_minMass
HLT::Identifier m_decisionId
Gaudi::Property< bool > m_logicAnd
Gaudi::Property< float > m_minPt
Gaudi::Property< float > m_maxNTrks
Gaudi::Property< float > m_maxMass
Gaudi::Property< float > m_maxR
TrigVSIHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
Gaudi::Property< float > m_minR
Gaudi::Property< float > m_maxChi2
double chi2(TH1 *h0, TH1 *h1)
int r
Definition globals.cxx:22
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
std::vector< const xAOD::Vertex * > vertices
TrigCompositeUtils::Decision * decision
const TrigCompositeUtils::DecisionIDContainer previousDecisionIDs