ATLAS Offline Software
TrigDisappearingTrackHypoTool.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 disappearing track candidates
5  * author Kunihiro Nagano <kunihiro.nagano@cern.ch>
6 */
7 
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( "Tool configured for chain/id: " << m_decisionId );
36 
37  return StatusCode::SUCCESS;
38 }
39 
40 // ------------------------------------------------------------------------------------------------
41 // ------------------------------------------------------------------------------------------------
42 
43 StatusCode TrigDisappearingTrackHypoTool::decide( std::vector<DisTrkHypoInfo>& toolInputs ) const
44 {
45  size_t numTrigger = m_cutTrackPtGeV.size();
46  size_t numDisTrks = toolInputs.size();
47 
48  ATH_MSG_VERBOSE( "Number of DisTrks = " << numDisTrks );
49 
50  if ( numTrigger == 1 ) {
51  ATH_MSG_VERBOSE( "Applying selection of single for " << m_decisionId );
52  return inclusiveSelection(toolInputs);
53  }
54  else {
55  ATH_MSG_VERBOSE( "Applying selection of multiplicity for " << m_decisionId );
56  return multiplicitySelection(toolInputs);
57  }
58 
59  return StatusCode::SUCCESS;
60 }
61 
62 // ------------------------------------------------------------------------------------------------
63 // ------------------------------------------------------------------------------------------------
64 
65 StatusCode TrigDisappearingTrackHypoTool::inclusiveSelection(std::vector<DisTrkHypoInfo>& toolInputs) const
66 {
67  bool isPassed = false;
68  unsigned int iDisTrk=0;
69  for ( auto& input: toolInputs ) {
70  ATH_MSG_VERBOSE( "--- iDisTrk=" << iDisTrk << " ---" );
71  if ( TrigCompositeUtils::passed( m_decisionId.numeric(), input.previousDecisionsIDs ) ) {
72  if ( decideOnSingleObject( input, 0 )==true ) {
73  ATH_MSG_VERBOSE( " Passed selection --> adding DecisionID" );
74  isPassed = true;
76  }
77  } else {
78  ATH_MSG_VERBOSE( " Not match DecisionID: " << m_decisionId );
79  }
80  ++iDisTrk;
81  }
82 
83  ATH_MSG_VERBOSE( "Inclusive selection isPassed = " << isPassed );
84  return StatusCode::SUCCESS;
85 }
86 
87 // ------------------------------------------------------------------------------------------------
88 // ------------------------------------------------------------------------------------------------
89 
90 StatusCode TrigDisappearingTrackHypoTool::multiplicitySelection(std::vector<DisTrkHypoInfo>& toolInputs) const
91 {
92  HLT::Index2DVec passingSelection( m_cutTrackPtGeV.size() );
93 
94  for ( size_t cutIndex=0; cutIndex < m_cutTrackPtGeV.size(); ++cutIndex ) {
95  size_t elementIndex{ 0 };
96  for ( auto& input: toolInputs ) {
97  if ( TrigCompositeUtils::passed( m_decisionId.numeric(), input.previousDecisionsIDs ) ) {
98  if ( decideOnSingleObject( input, cutIndex ) == true ) {
99  ATH_MSG_VERBOSE( "Pass through selection " << m_decisionId << " : Event[" << elementIndex << "]" );
100  passingSelection[cutIndex].push_back( elementIndex );
101  }
102  }
103  else {
104  ATH_MSG_VERBOSE( "Not match DecisionID " << m_decisionId );
105  }
106  elementIndex++;
107  }
108  // If no object passes the selection, multipul selection should stop.
109  if ( passingSelection[cutIndex].empty() ) {
110  ATH_MSG_VERBOSE( "No object passed selection " << cutIndex << " rejecting" );
111  return StatusCode::SUCCESS;
112  }
113  }
114 
115  std::set<size_t> passingIndices;
116  HLT::elementsInUniqueCombinations( passingSelection, passingIndices );
117 
118  if ( passingIndices.empty() ) {
119  ATH_MSG_VERBOSE( "No track passed through selection " << m_decisionId );
120  return StatusCode::SUCCESS;
121  }
122 
123  for ( auto idx: passingIndices ) {
124  ATH_MSG_VERBOSE( "track[" << idx << "] passes through Chain/ID " << m_decisionId << " with pT" );
125  TrigCompositeUtils::addDecisionID( m_decisionId.numeric(), toolInputs[idx].decision );
126  }
127 
128  return StatusCode::SUCCESS;
129 }
130 
131 // ------------------------------------------------------------------------------------------------
132 // ------------------------------------------------------------------------------------------------
133 
135 {
136  // values
137  const std::string prefix = "disTrk";
138 
139  auto distrk = input.disTrk;
140 
141  int category = (int)distrk->getDetail<int16_t>(prefix+"_category");
142  float pt = distrk->getDetail<float>(prefix+"_pt");
143  float refit_pt = distrk->getDetail<float>(prefix+"_refit_pt");
144  float bdt_score = distrk->getDetail<float>(prefix+"_bdtscore");
146  refit_pt /= Gaudi::Units::GeV;
147 
148  // selection
149  bool is_passed = false;
150  if( category==1 ) {
151  float bdt_threshold_pix4l_sct0 = m_cutBDTPix4Sct0[cutIndex];
152  float pt_threshold_pix4l_sct0 = m_cutTrackPtGeV[cutIndex];
153  if( pt >= pt_threshold_pix4l_sct0 && bdt_score >= bdt_threshold_pix4l_sct0 ) is_passed = true;
154  }
155  else if( category==2 ) {
156  float bdt_threshold_pix4l_sct1p = m_cutBDTPix4Sct1p[cutIndex];
157  float refit_pt_threshold_pix4l_sct1p = m_cutTrackPtGeV[cutIndex];
158  if( refit_pt >= refit_pt_threshold_pix4l_sct1p && bdt_score >= bdt_threshold_pix4l_sct1p ) is_passed = true;
159  }
160  else if( category==3 ) {
161  float bdt_threshold_pix3l_sct0 = m_cutBDTPix3Sct0[cutIndex];
162  float pt_threshold_pix3l_sct0 = m_cutTrackPtGeV[cutIndex];
163  if( pt >= pt_threshold_pix3l_sct0 && bdt_score >= bdt_threshold_pix3l_sct0 ) is_passed = true;
164  }
165  else if( category==4 ) {
166  float bdt_threshold_pix3l_sct1p = m_cutBDTPix3Sct1p[cutIndex];
167  float refit_pt_threshold_pix3l_sct1p = m_cutTrackPtGeV[cutIndex];
168  if( refit_pt >= refit_pt_threshold_pix3l_sct1p && bdt_score >= bdt_threshold_pix3l_sct1p ) is_passed = true;
169  }
170  else {
171  ATH_MSG_VERBOSE( " category is out of range = " << category );
172  }
173  ATH_MSG_VERBOSE( " isPassed = " << is_passed << ", cut index / pT / refitPt / BDT score = " << cutIndex << " / " << pt << " / " << refit_pt << " / " << bdt_score);
174 
175  //
176  return is_passed;
177 }
178 
179 // ------------------------------------------------------------------------------------------------
180 // ------------------------------------------------------------------------------------------------
TrigDisappearingTrackHypoTool::decideOnSingleObject
bool decideOnSingleObject(DisTrkHypoInfo &, size_t) const
Definition: TrigDisappearingTrackHypoTool.cxx:134
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
TrigDisappearingTrackHypoTool::m_decisionId
HLT::Identifier m_decisionId
Definition: TrigDisappearingTrackHypoTool.h:43
TrigDisappearingTrackHypoTool.h
TrigDisappearingTrackHypoTool::decide
StatusCode decide(std::vector< DisTrkHypoInfo > &) const
decides upon a collection of tracks
Definition: TrigDisappearingTrackHypoTool.cxx:43
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
TrigDisappearingTrackHypoTool::multiplicitySelection
StatusCode multiplicitySelection(std::vector< DisTrkHypoInfo > &) const
Definition: TrigDisappearingTrackHypoTool.cxx:90
TrigCompositeUtils.h
HLT::Identifier::numeric
TrigCompositeUtils::DecisionID numeric() const
numeric ID
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:47
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
TrigCompositeUtils::addDecisionID
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
Definition: TrigCompositeUtilsRoot.cxx:61
test_pyathena.pt
pt
Definition: test_pyathena.py:11
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
TrigDisappearingTrackHypoTool::m_cutBDTPix4Sct0
Gaudi::Property< std::vector< float > > m_cutBDTPix4Sct0
Definition: TrigDisappearingTrackHypoTool.h:45
empty
bool empty(TH1 *h)
Definition: computils.cxx:294
xAOD::int16_t
setScaleOne setStatusOne setSaturated int16_t
Definition: gFexGlobalRoI_v1.cxx:55
TrigDisappearingTrackHypoTool::TrigDisappearingTrackHypoTool
TrigDisappearingTrackHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TrigDisappearingTrackHypoTool.cxx:20
TrigDisappearingTrackHypoTool::~TrigDisappearingTrackHypoTool
virtual ~TrigDisappearingTrackHypoTool()
Definition: TrigDisappearingTrackHypoTool.cxx:26
TrigDisappearingTrackHypoTool::m_cutBDTPix3Sct0
Gaudi::Property< std::vector< float > > m_cutBDTPix3Sct0
Definition: TrigDisappearingTrackHypoTool.h:47
TrigDisappearingTrackHypoTool::DisTrkHypoInfo
Definition: TrigDisappearingTrackHypoTool.h:30
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
ReweightUtils.category
category
Definition: ReweightUtils.py:15
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
test_pyathena.parent
parent
Definition: test_pyathena.py:15
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
TrigDisappearingTrackHypoTool::m_cutTrackPtGeV
Gaudi::Property< std::vector< float > > m_cutTrackPtGeV
Definition: TrigDisappearingTrackHypoTool.h:44
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
TrigDisappearingTrackHypoTool::m_cutBDTPix3Sct1p
Gaudi::Property< std::vector< float > > m_cutBDTPix3Sct1p
Definition: TrigDisappearingTrackHypoTool.h:48
Combinators.h
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
AthAlgTool
Definition: AthAlgTool.h:26
TrigDisappearingTrackHypoTool::initialize
virtual StatusCode initialize() override
Definition: TrigDisappearingTrackHypoTool.cxx:31
TrigDisappearingTrackHypoTool::inclusiveSelection
StatusCode inclusiveSelection(std::vector< DisTrkHypoInfo > &) const
Definition: TrigDisappearingTrackHypoTool.cxx:65
TrigDisappearingTrackHypoTool::m_cutBDTPix4Sct1p
Gaudi::Property< std::vector< float > > m_cutBDTPix4Sct1p
Definition: TrigDisappearingTrackHypoTool.h:46
Identifier
Definition: IdentifierFieldParser.cxx:14