ATLAS Offline Software
Loading...
Searching...
No Matches
TrigdEdxTrackHypoTool.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, that is aimed at triggering large dEdx tracks
5 * author Kunihiro Nagano <kunihiro.nagano@cern.ch> - KEK
6*/
7
13#include "GaudiKernel/PhysicalConstants.h"
14
15using namespace TrigCompositeUtils;
16
17// ------------------------------------------------------------------------------------------------
18// ------------------------------------------------------------------------------------------------
19
21 const std::string& name,
22 const IInterface* parent )
23 : AthAlgTool( type, name, parent ),
24 m_decisionId( HLT::Identifier::fromToolName( name ) ) {}
25
27
28// ------------------------------------------------------------------------------------------------
29// ------------------------------------------------------------------------------------------------
30
32{
33 ATH_MSG_DEBUG( "Initialization completed successfully:" );
34 ATH_MSG_DEBUG( " cutTrackPtGeV = " << m_cutTrackPtGeV) ;
35 ATH_MSG_DEBUG( " cutTrackEta = " << m_cutTrackEta );
36 ATH_MSG_DEBUG( " cutTrackdEdx = " << m_cutTrackdEdx );
37 ATH_MSG_DEBUG( " cutTrackNhighdEdxHits = " << m_cutTrackNhighdEdxHits );
38 ATH_MSG_DEBUG( " cutTrackHighdEdxDef = " << m_cutTrackHighdEdxDef );
39 ATH_MSG_DEBUG( "Tool configured for chain/id: " << m_decisionId );
40
41 return StatusCode::SUCCESS;
42}
43
44// ------------------------------------------------------------------------------------------------
45// ------------------------------------------------------------------------------------------------
46
47StatusCode TrigdEdxTrackHypoTool::decide( std::vector<dEdxTrkHypoInfo>& toolInputs ) const
48{
49 size_t numTrigger = m_cutTrackPtGeV.size();
50 size_t numdEdxTrks = toolInputs.size();
51
52 ATH_MSG_VERBOSE( "Number of dEdxTrks = " << numdEdxTrks );
53
54 if ( numTrigger == 1 ) {
55 ATH_MSG_VERBOSE( "Applying selection of single for " << m_decisionId );
56 return inclusiveSelection(toolInputs);
57 }
58 else {
59 ATH_MSG_VERBOSE( "Applying selection of multiplicity for " << m_decisionId );
60 return multiplicitySelection(toolInputs);
61 }
62
63 return StatusCode::SUCCESS;
64}
65
66// ------------------------------------------------------------------------------------------------
67// ------------------------------------------------------------------------------------------------
68
69StatusCode TrigdEdxTrackHypoTool::inclusiveSelection(std::vector<dEdxTrkHypoInfo>& toolInputs) const
70{
71 bool isPassed = false;
72 unsigned int idEdxTrk=0;
73 for ( auto& input: toolInputs ) {
74 ATH_MSG_VERBOSE( "--- idEdxTrk=" << idEdxTrk << " ---");
75 if ( TrigCompositeUtils::passed( m_decisionId.numeric(), input.previousDecisionsIDs ) ) {
76 if ( decideOnSingleObject( input, 0 )==true ) {
77 ATH_MSG_VERBOSE( " Passed selection --> adding DecisionID");
78 isPassed = true;
80 }
81 } else {
82 ATH_MSG_VERBOSE( " Not match DecisionID: " << m_decisionId );
83 }
84 ++idEdxTrk;
85 }
86
87 ATH_MSG_VERBOSE( "Inclusive selection isPassed = " << isPassed);
88 return StatusCode::SUCCESS;
89}
90
91// ------------------------------------------------------------------------------------------------
92// ------------------------------------------------------------------------------------------------
93
94StatusCode TrigdEdxTrackHypoTool::multiplicitySelection(std::vector<dEdxTrkHypoInfo>& toolInputs) const
95{
96 HLT::Index2DVec passingSelection( m_cutTrackPtGeV.size() );
97
98 for ( size_t cutIndex=0; cutIndex < m_cutTrackPtGeV.size(); ++cutIndex ) {
99 size_t elementIndex{ 0 };
100 for ( auto& input: toolInputs ) {
101 if ( TrigCompositeUtils::passed( m_decisionId.numeric(), input.previousDecisionsIDs ) ) {
102 if ( decideOnSingleObject( input, cutIndex ) == true ) {
103 ATH_MSG_VERBOSE( "Pass through selection " << m_decisionId << " : Event[" << elementIndex << "]" );
104 passingSelection[cutIndex].push_back( elementIndex );
105 }
106 }
107 else {
108 ATH_MSG_VERBOSE( "Not match DecisionID " << m_decisionId );
109 }
110 elementIndex++;
111 }
112 // If no object passes the selection, multipul selection should stop.
113 if ( passingSelection[cutIndex].empty() ) {
114 ATH_MSG_VERBOSE( "No object passed selection " << cutIndex << " rejecting" );
115 return StatusCode::SUCCESS;
116 }
117 }
118
119 std::set<size_t> passingIndices;
120 HLT::elementsInUniqueCombinations( passingSelection, passingIndices );
121
122 if ( passingIndices.empty() ) {
123 ATH_MSG_VERBOSE( "No track passed through selection " << m_decisionId );
124 return StatusCode::SUCCESS;
125 }
126
127 for ( auto idx: passingIndices ) {
128 ATH_MSG_VERBOSE( "track[" << idx << "] passes through Chain/ID " << m_decisionId << " with pT" );
129 TrigCompositeUtils::addDecisionID( m_decisionId.numeric(), toolInputs[idx].decision );
130 }
131
132 return StatusCode::SUCCESS;
133}
134
135// ------------------------------------------------------------------------------------------------
136// ------------------------------------------------------------------------------------------------
137
139{
140 const xAOD::TrigComposite* trk = input.dedxTrk;
141
142 // pT cut
143 float trackPt = trk->getDetail<float>("HPtdEdxTrk_pt");
144 float trackPtGeV = trackPt / 1000.0;
145 float ptThreshold = m_cutTrackPtGeV[cutIndex];
146 if( trackPtGeV < ptThreshold ) return false;
147
148 // eta cut
149 float trackEta = trk->getDetail<float>("HPtdEdxTrk_eta");
150 float etaThreshold = m_cutTrackEta[cutIndex];
151 if( std::abs(trackEta) > etaThreshold ) return false;
152
153 // a0beam cut
154 float tracka0beam = trk->getDetail<float>("HPtdEdxTrk_a0beam");
155 float a0Threshold = m_cutTracka0beam[cutIndex];
156 if( std::abs(tracka0beam) > a0Threshold ) return false;
157
158 // dEdx cut
159 float trackdEdx = trk->getDetail<float>("HPtdEdxTrk_dedx");
160 float dedxThreshold = m_cutTrackdEdx[cutIndex];
161 if( trackdEdx < dedxThreshold ) return false;
162
163 // nr of high dEdx hits
164 std::string name = "HPtdEdxTrk_n_hdedx_hits_" + m_cutTrackHighdEdxDef[cutIndex];
165 if( ! trk->hasDetail<int16_t>(name) ) ATH_MSG_ERROR( "HPtdEdxTrk container does not have entry for " << name );
166 int n_hdedx_hits = (int)trk->getDetail<int16_t>(name);
167 int n_hdedx_hits_threshold = m_cutTrackNhighdEdxHits[cutIndex];
168 if( n_hdedx_hits < n_hdedx_hits_threshold ) return false;
169
170 //
171 ATH_MSG_VERBOSE( " Selected, cut index / pT / eta / a0 / dEdx / n high dEdx hits = " << cutIndex << " / " << trackPtGeV << " / " << trackEta << " / " << tracka0beam << " / " << trackdEdx << " / " << n_hdedx_hits);
172
173 return true;
174}
175
176// ------------------------------------------------------------------------------------------------
177// ------------------------------------------------------------------------------------------------
#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.
static const Attributes_t empty
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
StatusCode decide(std::vector< dEdxTrkHypoInfo > &) const
decides upon a collection of tracks
Gaudi::Property< std::vector< float > > m_cutTrackEta
Gaudi::Property< std::vector< std::string > > m_cutTrackHighdEdxDef
Gaudi::Property< std::vector< float > > m_cutTrackdEdx
TrigdEdxTrackHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
Gaudi::Property< std::vector< float > > m_cutTracka0beam
virtual StatusCode initialize() override
Gaudi::Property< std::vector< int > > m_cutTrackNhighdEdxHits
Gaudi::Property< std::vector< float > > m_cutTrackPtGeV
StatusCode inclusiveSelection(std::vector< dEdxTrkHypoInfo > &) const
bool decideOnSingleObject(dEdxTrkHypoInfo &, size_t) const
StatusCode multiplicitySelection(std::vector< dEdxTrkHypoInfo > &) const
bool hasDetail(const std::string &name) const
Check if a given type of detail is available.
bool getDetail(const std::string &name, TYPE &value) const
Get an TYPE detail from the object.
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.
TrigComposite_v1 TrigComposite
Declare the latest version of the class.