ATLAS Offline Software
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 */
7 #include "MuonClusterHypoTool.h"
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 
31 using 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 
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 }
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
get_generator_info.result
result
Definition: get_generator_info.py:21
TrigCompositeUtils::DecisionID
unsigned int DecisionID
Definition: TrigComposite_v1.h:27
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
MuonClusterHypoTool::decide
StatusCode decide(DecisionInfo &input) const
Definition: MuonClusterHypoTool.cxx:51
TrigCompositeUtils.h
HLT::Identifier::numeric
TrigCompositeUtils::DecisionID numeric() const
numeric ID
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:47
LUCID_EventTPCnv_Dict::t3
std::vector< LUCID_RawData_p1 > t3
Definition: LUCID_EventTPCnvDict.h:28
MuonClusterHypoTool::~MuonClusterHypoTool
~MuonClusterHypoTool()
Definition: MuonClusterHypoTool.cxx:49
TrigCompositeUtils::addDecisionID
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
Definition: TrigCompositeUtilsRoot.cxx:61
ALFA_EventTPCnv_Dict::t1
std::vector< ALFA_RawDataCollection_p1 > t1
Definition: ALFA_EventTPCnvDict.h:43
MuonClusterHypoTool.h
MuonClusterHypoTool::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: MuonClusterHypoTool.h:51
MuonClusterHypoTool::MuonClusterHypoTool
MuonClusterHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: MuonClusterHypoTool.cxx:33
MuonClusterHypoTool::m_nRoIEndCap
Gaudi::Property< int > m_nRoIEndCap
Definition: MuonClusterHypoTool.h:53
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
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:52
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
HLT::Identifier
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:20
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
TrigCompositeAuxContainer.h
TrigCompositeContainer.h
MuonClusterHypoTool::m_nRoIBarrel
Gaudi::Property< int > m_nRoIBarrel
Definition: MuonClusterHypoTool.h:54
WriteHandleKey.h
Property holding a SG store/key/clid from which a WriteHandle is made.
MuonClusterHypoTool::DecisionInfo
Definition: MuonClusterHypoTool.h:40
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
MuonClusterHypoTool::m_decisionId
HLT::Identifier m_decisionId
Definition: MuonClusterHypoTool.h:50
ALFA_EventTPCnv_Dict::t2
std::vector< ALFA_RawDataContainer_p1 > t2
Definition: ALFA_EventTPCnvDict.h:44
TrigCompositeUtils::DecisionIDContainer
std::set< DecisionID > DecisionIDContainer
Definition: TrigComposite_v1.h:28
Combinators.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
MuonClusterHypoTool::m_etaMid
Gaudi::Property< float > m_etaMid
Definition: MuonClusterHypoTool.h:56
HLTIdentifier.h
MuonClusterHypoTool::m_acceptAll
Gaudi::Property< bool > m_acceptAll
Definition: MuonClusterHypoTool.h:52
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
MuonClusterHypoTool::initialize
StatusCode initialize()
Definition: MuonClusterHypoTool.cxx:39
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
AthAlgTool
Definition: AthAlgTool.h:26
TrigComposite.h
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
Monitored::Timer
A monitored timer.
Definition: MonitoredTimer.h:32
Identifier
Definition: IdentifierFieldParser.cxx:14
MuonClusterHypoTool::m_etaMax
Gaudi::Property< float > m_etaMax
Definition: MuonClusterHypoTool.h:55