ATLAS Offline Software
Loading...
Searching...
No Matches
MuonClusterHypoTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
4 * Trigger Hypo Tool, that is aimed at triggering clusters of muon RoIs
5 * author Michael Schott <michael.louis.schott@cern.ch>
6*/
8
9#include <cmath>
10#include <algorithm>
11#include <sstream>
12#include <string>
13
14#include "GaudiKernel/MsgStream.h"
15#include "GaudiKernel/StatusCode.h"
16#include "GaudiKernel/ITHistSvc.h"
17#include "GaudiKernel/PhysicalConstants.h"
18
24
28
30
31using namespace TrigCompositeUtils;
32
34 const std::string& name,
35 const IInterface* parent )
36 : AthAlgTool( type, name, parent ),
37 m_decisionId( HLT::Identifier::fromToolName( name ) ) {}
38
40{
41 if ( !m_monTool.empty() ) ATH_CHECK( m_monTool.retrieve() );
42
43 ATH_MSG_INFO("Initialization completed successfully:");
44 ATH_MSG_INFO("Tool configured for chain/id: " << m_decisionId);
45
46 return StatusCode::SUCCESS;
47}
48
50
51StatusCode MuonClusterHypoTool::decide( DecisionInfo& input ) const
52{
53 auto monNumberRoI = Monitored::Scalar<int>( "numberRoI", -99 );
54
55 auto monEtaClust = Monitored::Scalar<float>( "etaClust", -99 );
56 auto monPhiClust = Monitored::Scalar<float>( "phiClust", -99 );
57 auto monEtaClustPass = Monitored::Scalar<float>( "etaClustPass", -99 );
58 auto monPhiClustPass = Monitored::Scalar<float>( "phiClustPass", -99 );
59
60 auto monNumRoIB = Monitored::Scalar<int>( "nRoIBarrel", -99 );
61 auto monNumRoIE = Monitored::Scalar<int>( "nRoIEndcap", -99 );
62 auto monNumRoIBPass = Monitored::Scalar<int>( "nRoIBarrelPass", -99 );
63 auto monNumRoIEPass = Monitored::Scalar<int>( "nRoIEndcapPass", -99 );
64
65 auto result = Monitored::Scalar<Bool_t>( "result", false );
66 auto chainActive = Monitored::Scalar<Bool_t>( "chainActive", false );
67
68 auto t1 = Monitored::Timer("TIME_HypoTool"); // microseconds
69 auto t2 = Monitored::Timer("TIME_HypoTool_GetCluster");
70 auto t3 = Monitored::Timer("TIME_HypoTool_Selection");
71
72 auto monitorIt = Monitored::Group( m_monTool, monNumberRoI, monEtaClust, monPhiClust,
73 monNumRoIB, monNumRoIE, monEtaClustPass, monPhiClustPass,
74 result, monNumRoIBPass, monNumRoIEPass, chainActive,
75 t1, t2, t3 );
76
77 const xAOD::TrigCompositeContainer *compCont = input.Composites;
78 TrigCompositeUtils::DecisionIDContainer prev = input.activeChainIDs;
79
80 // Exctracting MuonClusterRoI info
81 ATH_MSG_DEBUG("Found " << compCont->size() << " TrigComposite objects");
82
83 int numberRoI = 0;
84 float etaClust = -99;
85 float phiClust = -99;
86
87 bool foundMuonRoICluster = false;
88
89 t2.start();
90 for(const xAOD::TrigComposite *compObj : *compCont) {
91 ATH_MSG_DEBUG("TrigComposite ptr = " << compObj);
92 ATH_MSG_DEBUG("Found object named Cluster : " << (compObj->name()== "Cluster" ? "yes":"no"));
93 if(compObj->name() == "Cluster" ) {
94 foundMuonRoICluster = true;
95 //if we can't access all the variables necessary for the trigger hypothesis,
96 //return FAILURE, because it means the variables are missing
97 if(!compObj->getDetail("nRoIs", numberRoI)) { return StatusCode::FAILURE; }
98 if(!compObj->getDetail("ClusterEta", etaClust)) { return StatusCode::FAILURE; }
99 if(!compObj->getDetail("ClusterPhi", phiClust)) { return StatusCode::FAILURE; }
100 }
101 }
102 t2.stop();
103 if( !foundMuonRoICluster ) { return StatusCode::FAILURE;}
104
105 // Updating Monitoring values
106 monNumberRoI = numberRoI;
107 monEtaClust = etaClust;
108 monPhiClust = phiClust;
109
110 // Monitor ALL muonRoICluster multiplicities
111 if(fabs(etaClust)< m_etaMid){
112 monNumRoIB = numberRoI;
113 } else if((fabs(etaClust)>= m_etaMid && fabs(etaClust)<= m_etaMax)){
114 monNumRoIE = numberRoI;
115 }
116
117 // Bool as to whether we passed.
118 result = false;
119
120 // acceptAll can be enabled for testing
121 if(m_acceptAll) {
122 t3.start();
123 result = true;
124 ATH_MSG_DEBUG("Accept property is set: taking all the events");
125 t3.stop();
126
127 } else {
128
129 t3.start();
130 result = true; //set result to true in case of errors for safety
131
132 ATH_MSG_DEBUG("Cluster has " << numberRoI << " muon RoIs, at (eta, phi) = (" << etaClust << ", " << phiClust << ")");
133
134 // Cut on number of RoIs in the cluster
135 if(fabs(etaClust)<=m_etaMax) {
136
137 if(fabs(etaClust)< m_etaMid && numberRoI >= m_nRoIBarrel) {
138
139 ATH_MSG_DEBUG("Cluster passes barrel selection > " << m_nRoIBarrel << " RoIs");
140
141 // monitored variables
142 monNumRoIBPass = numberRoI;
143 monEtaClustPass = etaClust;
144 monPhiClustPass = phiClust;
145 result = true;
146
147 } else if((fabs(etaClust)>= m_etaMid && fabs(etaClust)<= m_etaMax) && numberRoI >= m_nRoIEndCap) {
148
149 ATH_MSG_DEBUG("Cluster passes endcap selection > " << m_nRoIEndCap << " RoIs");
150
151 // monitored variables
152 monNumRoIEPass = numberRoI;
153 monEtaClustPass = etaClust;
154 monPhiClustPass = phiClust;
155 result = true;
156
157 } else {
158 ATH_MSG_DEBUG("Cluster does not satisfy all the conditions... event not accepted");
159 result = false;
160 }
161
162 } else {
163 ATH_MSG_DEBUG("Cluster location past maximum permitted eta... event not accepted");
164 result = false;
165 }
166
167 t3.stop();
168
169 }
170
171 ATH_MSG_DEBUG( "Writing out active chains:" );
172 for (DecisionID activeChain : prev)
173 {
174 ATH_MSG_DEBUG( HLT::Identifier( activeChain ) );
175 }
176
177 // Checking if this HypoTool's chain is active in this event...
178 chainActive = prev.count(m_decisionId.numeric()) > 0;
179 if( (prev.count(m_decisionId.numeric()) > 0 ) )
180 {
181 // If it's active, then check selection. ie nothing should pass if its not active.
182 if( result ) {
183 addDecisionID( m_decisionId.numeric(), input.decision );
184 ATH_MSG_DEBUG("event accepted");
185
186 return StatusCode::SUCCESS;
187 }
188 else {
189 return StatusCode::SUCCESS;
190 }
191 } else {
192 return StatusCode::SUCCESS;
193 }
194}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Header file to be included by clients of the Monitored infrastructure.
Property holding a SG store/key/clid from which a ReadHandle is made.
Property holding a SG store/key/clid from which a WriteHandle is made.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
size_type size() const noexcept
Returns the number of elements in the collection.
Group of local monitoring quantities and retain correlation when filling histograms
Declare a monitored scalar variable.
A monitored timer.
StatusCode decide(DecisionInfo &input) const
Gaudi::Property< int > m_nRoIEndCap
ToolHandle< GenericMonitoringTool > m_monTool
Gaudi::Property< float > m_etaMax
Gaudi::Property< float > m_etaMid
Gaudi::Property< bool > m_acceptAll
MuonClusterHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
HLT::Identifier m_decisionId
Gaudi::Property< int > m_nRoIBarrel
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
unsigned int DecisionID
std::set< DecisionID > DecisionIDContainer
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
TrigCompositeContainer_v1 TrigCompositeContainer
Declare the latest version of the container.
TrigComposite_v1 TrigComposite
Declare the latest version of the class.