ATLAS Offline Software
IDCalibHypoTool.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 for IDCalib stream trigger
5  * author Kunihiro Nagano <kunihiro.nagano@cern.ch>
6 */
7 
12 #include "IDCalibHypoTool.h"
13 #include "GaudiKernel/PhysicalConstants.h"
14 
15 using namespace TrigCompositeUtils;
16 
17 // ------------------------------------------------------------------------------------------------
18 // ------------------------------------------------------------------------------------------------
19 
20 IDCalibHypoTool::IDCalibHypoTool( const std::string& type, const std::string& name, const IInterface* parent )
21  : AthAlgTool( type, name, parent ),
22  m_decisionId( HLT::Identifier::fromToolName( name ) ) {}
23 
24 // ------------------------------------------------------------------------------------------------
25 // ------------------------------------------------------------------------------------------------
26 
28 {
29  ATH_MSG_INFO( "Initialization completed successfully:" );
30  ATH_MSG_INFO( " cutTrackPtGeV = " << m_cutTrackPtGeV );
31  ATH_MSG_INFO( "Tool configured for chain/id: " << m_decisionId );
32 
33  return StatusCode::SUCCESS;
34 }
35 
36 // ------------------------------------------------------------------------------------------------
37 // ------------------------------------------------------------------------------------------------
38 
39 StatusCode IDCalibHypoTool::decide( std::vector<IDCalibHypoInfo>& toolInputs ) const
40 {
41  size_t numTrigger = m_cutTrackPtGeV.size();
42  size_t numTrks = toolInputs.size();
43 
44  ATH_MSG_DEBUG( "Number of Tracks = " << numTrks );
45 
46  if ( numTrigger == 1 ) {
47  ATH_MSG_DEBUG( "Applying selection of single for " << m_decisionId );
48  return inclusiveSelection(toolInputs);
49  }
50  else {
51  ATH_MSG_DEBUG( "Applying selection of multiplicity for " << m_decisionId );
52  return multiplicitySelection(toolInputs);
53  }
54 
55  return StatusCode::SUCCESS;
56 }
57 
58 // ------------------------------------------------------------------------------------------------
59 // ------------------------------------------------------------------------------------------------
60 
61 StatusCode IDCalibHypoTool::inclusiveSelection(std::vector<IDCalibHypoInfo>& toolInputs) const
62 {
63  bool isPassed = false;
64  unsigned int iTrk=0;
65  for ( auto& input: toolInputs ) {
66  ATH_MSG_DEBUG( "--- iTrk=" << iTrk << " ---" );
67  if ( TrigCompositeUtils::passed( m_decisionId.numeric(), input.previousDecisionsIDs ) ) {
68  if ( decideOnSingleObject( input, 0 )==true ) {
69  ATH_MSG_DEBUG( " Passed selection --> adding DecisionID" );
70  isPassed = true;
72  }
73  } else {
74  ATH_MSG_DEBUG( " Not match DecisionID: " << m_decisionId );
75  }
76  ++iTrk;
77  }
78 
79  ATH_MSG_DEBUG( "Inclusive selection isPassed = " << isPassed );
80  return StatusCode::SUCCESS;
81 }
82 
83 // ------------------------------------------------------------------------------------------------
84 // ------------------------------------------------------------------------------------------------
85 
86 StatusCode IDCalibHypoTool::multiplicitySelection(std::vector<IDCalibHypoInfo>& toolInputs) const
87 {
88  HLT::Index2DVec passingSelection( m_cutTrackPtGeV.size() );
89 
90  for ( size_t cutIndex=0; cutIndex < m_cutTrackPtGeV.size(); ++cutIndex ) {
91  size_t elementIndex{ 0 };
92  for ( auto& input: toolInputs ) {
93  if ( TrigCompositeUtils::passed( m_decisionId.numeric(), input.previousDecisionsIDs ) ) {
94  if ( decideOnSingleObject( input, cutIndex ) == true ) {
95  ATH_MSG_DEBUG( "Pass through selection " << m_decisionId << " : Event[" << elementIndex << "]" );
96  passingSelection[cutIndex].push_back( elementIndex );
97  }
98  }
99  else {
100  ATH_MSG_DEBUG( "Not match DecisionID " << m_decisionId );
101  }
102  elementIndex++;
103  }
104  // If no object passes the selection, multipul selection should stop.
105  if ( passingSelection[cutIndex].empty() ) {
106  ATH_MSG_DEBUG( "No object passed selection " << cutIndex << " rejecting" );
107  return StatusCode::SUCCESS;
108  }
109  }
110 
111  std::set<size_t> passingIndices;
112  HLT::elementsInUniqueCombinations( passingSelection, passingIndices );
113 
114  if ( passingIndices.empty() ) {
115  ATH_MSG_DEBUG( "No track passed through selection " << m_decisionId );
116  return StatusCode::SUCCESS;
117  }
118 
119  for ( auto idx: passingIndices ) {
120  ATH_MSG_DEBUG( "track[" << idx << "] passes through Chain/ID " << m_decisionId << " with pT" );
121  TrigCompositeUtils::addDecisionID( m_decisionId.numeric(), toolInputs[idx].decision );
122  }
123 
124  return StatusCode::SUCCESS;
125 }
126 
127 // ------------------------------------------------------------------------------------------------
128 // ------------------------------------------------------------------------------------------------
129 
131 {
132  bool is_passed = false;
133 
134  // values
135  float pt = input.track->pt();
137 
138  // pt selection
139  if( pt >= m_cutTrackPtGeV[cutIndex] ) is_passed = true;
140 
141  //
142  ATH_MSG_DEBUG( " isPassed = " << is_passed << ", cut index / pT = " << cutIndex << " / " << pt );
143  return is_passed;
144 }
145 
146 // ------------------------------------------------------------------------------------------------
147 // ------------------------------------------------------------------------------------------------
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
IDCalibHypoTool::decide
StatusCode decide(std::vector< IDCalibHypoInfo > &) const
decides upon a collection of tracks
Definition: IDCalibHypoTool.cxx:39
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
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
HLT::Identifier::numeric
TrigCompositeUtils::DecisionID numeric() const
numeric ID
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:47
TrigCompositeUtils::addDecisionID
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
Definition: TrigCompositeUtilsRoot.cxx:61
IDCalibHypoTool::decideOnSingleObject
bool decideOnSingleObject(IDCalibHypoInfo &, size_t) const
Definition: IDCalibHypoTool.cxx:130
IDCalibHypoTool::m_decisionId
HLT::Identifier m_decisionId
Definition: IDCalibHypoTool.h:42
test_pyathena.pt
pt
Definition: test_pyathena.py:11
empty
bool empty(TH1 *h)
Definition: computils.cxx:295
IDCalibHypoTool::initialize
virtual StatusCode initialize() override
Definition: IDCalibHypoTool.cxx:27
IDCalibHypoTool::IDCalibHypoTool
IDCalibHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: IDCalibHypoTool.cxx:20
TrigCompositeUtils.h
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
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
test_pyathena.parent
parent
Definition: test_pyathena.py:15
IDCalibHypoTool::m_cutTrackPtGeV
Gaudi::Property< std::vector< float > > m_cutTrackPtGeV
Definition: IDCalibHypoTool.h:43
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
IDCalibHypoTool::IDCalibHypoInfo
Definition: IDCalibHypoTool.h:28
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
IDCalibHypoTool::inclusiveSelection
StatusCode inclusiveSelection(std::vector< IDCalibHypoInfo > &) const
Definition: IDCalibHypoTool.cxx:61
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
IDCalibHypoTool::multiplicitySelection
StatusCode multiplicitySelection(std::vector< IDCalibHypoInfo > &) const
Definition: IDCalibHypoTool.cxx:86
IDCalibHypoTool.h
AthAlgTool
Definition: AthAlgTool.h:26
Identifier
Definition: IdentifierFieldParser.cxx:14