ATLAS Offline Software
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 
12 #include "TrigdEdxTrackHypoTool.h"
13 #include "GaudiKernel/PhysicalConstants.h"
14 
15 using 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 
47 StatusCode 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 
69 StatusCode 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 
94 StatusCode 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 // ------------------------------------------------------------------------------------------------
TrigdEdxTrackHypoTool::m_cutTrackPtGeV
Gaudi::Property< std::vector< float > > m_cutTrackPtGeV
Definition: TrigdEdxTrackHypoTool.h:44
TrigdEdxTrackHypoTool.h
TrigdEdxTrackHypoTool::inclusiveSelection
StatusCode inclusiveSelection(std::vector< dEdxTrkHypoInfo > &) const
Definition: TrigdEdxTrackHypoTool.cxx:69
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
TrigCompositeUtils.h
HLT::Identifier::numeric
TrigCompositeUtils::DecisionID numeric() const
numeric ID
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:47
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
TrigdEdxTrackHypoTool::m_cutTrackEta
Gaudi::Property< std::vector< float > > m_cutTrackEta
Definition: TrigdEdxTrackHypoTool.h:45
TrigCompositeUtils::addDecisionID
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
Definition: TrigCompositeUtilsRoot.cxx:61
xAOD::TrigComposite_v1::hasDetail
bool hasDetail(const std::string &name) const
Check if a given type of detail is available.
TrigdEdxTrackHypoTool::decideOnSingleObject
bool decideOnSingleObject(dEdxTrkHypoInfo &, size_t) const
Definition: TrigdEdxTrackHypoTool.cxx:138
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
TrigdEdxTrackHypoTool::m_decisionId
HLT::Identifier m_decisionId
Definition: TrigdEdxTrackHypoTool.h:43
empty
bool empty(TH1 *h)
Definition: computils.cxx:294
xAOD::int16_t
setScaleOne setStatusOne setSaturated int16_t
Definition: gFexGlobalRoI_v1.cxx:55
TrigdEdxTrackHypoTool::dEdxTrkHypoInfo
Definition: TrigdEdxTrackHypoTool.h:30
TrigdEdxTrackHypoTool::decide
StatusCode decide(std::vector< dEdxTrkHypoInfo > &) const
decides upon a collection of tracks
Definition: TrigdEdxTrackHypoTool.cxx:47
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
TrigdEdxTrackHypoTool::initialize
virtual StatusCode initialize() override
Definition: TrigdEdxTrackHypoTool.cxx:31
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
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:52
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
HLT::elementsInUniqueCombinations
void elementsInUniqueCombinations(const Index2DVec &indices, std::set< size_t > &participants, std::function< bool(const Index1DVec &)> &&filter)
Definition: Combinators.cxx:154
TauGNNUtils::Variables::Track::trackPt
bool trackPt(const xAOD::TauJet &, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:470
TrigdEdxTrackHypoTool::m_cutTrackHighdEdxDef
Gaudi::Property< std::vector< std::string > > m_cutTrackHighdEdxDef
Definition: TrigdEdxTrackHypoTool.h:49
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
TrigdEdxTrackHypoTool::m_cutTrackNhighdEdxHits
Gaudi::Property< std::vector< int > > m_cutTrackNhighdEdxHits
Definition: TrigdEdxTrackHypoTool.h:48
TrigdEdxTrackHypoTool::TrigdEdxTrackHypoTool
TrigdEdxTrackHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TrigdEdxTrackHypoTool.cxx:20
Combinators.h
TrigdEdxTrackHypoTool::multiplicitySelection
StatusCode multiplicitySelection(std::vector< dEdxTrkHypoInfo > &) const
Definition: TrigdEdxTrackHypoTool.cxx:94
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
HLTIdentifier.h
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
HLT::Index2DVec
std::vector< Index1DVec > Index2DVec
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:140
TrigdEdxTrackHypoTool::m_cutTracka0beam
Gaudi::Property< std::vector< float > > m_cutTracka0beam
Definition: TrigdEdxTrackHypoTool.h:46
AthAlgTool
Definition: AthAlgTool.h:26
xAOD::TrigComposite_v1::getDetail
bool getDetail(const std::string &name, TYPE &value) const
Get an TYPE detail from the object.
TrigdEdxTrackHypoTool::m_cutTrackdEdx
Gaudi::Property< std::vector< float > > m_cutTrackdEdx
Definition: TrigdEdxTrackHypoTool.h:47
TauGNNUtils::Variables::Track::trackEta
bool trackEta(const xAOD::TauJet &, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:475
TrigdEdxTrackHypoTool::~TrigdEdxTrackHypoTool
virtual ~TrigdEdxTrackHypoTool()
Definition: TrigdEdxTrackHypoTool.cxx:26