ATLAS Offline Software
TrigEgammaForwardPrecisionCaloHypoTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include <algorithm>
12 
13 
14 namespace TCU = TrigCompositeUtils;
15 
17  const std::string& name,
18  const IInterface* parent )
19  : base_class( type, name, parent ),
20  m_decisionId( HLT::Identifier::fromToolName( name ) ) {}
21 
23 {
24  ATH_MSG_DEBUG( "Initialization completed successfully" );
25  ATH_MSG_DEBUG( "EtaBins = " << m_etabin );
26  ATH_MSG_DEBUG( "ETthr = " << m_eTthr << "( lo )/" << m_eT2thr << "( hi )" );
27  ATH_MSG_DEBUG( "dPHICLUSTERthr = " << m_dphicluster );
28  ATH_MSG_DEBUG( "dETACLUSTERthr = " << m_detacluster );
29 
30  if ( m_etabin.size() == 0 ) {
31  ATH_MSG_ERROR( " There are no cuts set (EtaBins property is an empty list)" );
32  return StatusCode::FAILURE;
33  }
34 
35  unsigned int nEtaBin = m_etabin.size();
36 
37 #define CHECK_SIZE( __n) if ( m_##__n.size() != (nEtaBin - 1) ) \
38  { ATH_MSG_DEBUG(" __n size is " << m_##__n.size() << " but needs to be " << (nEtaBin - 1) ); return StatusCode::FAILURE; }
39 
40  CHECK_SIZE( eTthr );
41  CHECK_SIZE( eT2thr );
42 #undef CHECK_SIZE
43 
44 
45 
46  ATH_MSG_DEBUG( "Tool configured for chain/id: " << m_decisionId );
47 
48  if ( not m_monTool.name().empty() )
49  CHECK( m_monTool.retrieve() );
50 
51  return StatusCode::SUCCESS;
52 }
53 
54 
56 
57  bool pass = false;
58 
59  auto dEta = Monitored::Scalar( "dEta", -1. );
60  auto dPhi = Monitored::Scalar( "dPhi", -1. );
61  auto eT_Cluster = Monitored::Scalar( "Et_em" , -1.0 );
62  auto etaBin = Monitored::Scalar( "EtaBin", -1. );
63  auto monEta = Monitored::Scalar( "Eta", -99. );
64  auto monPhi = Monitored::Scalar( "Phi", -99. );
65  auto PassedCuts = Monitored::Scalar<int>( "CutCounter", -1 );
66  auto monitorIt = Monitored::Group( m_monTool,dEta, dPhi, eT_Cluster,
67  etaBin, monEta,monPhi,PassedCuts );
68  // when leaving scope it will ship data to monTool
69  PassedCuts = PassedCuts + 1; //got called (data in place)
70 
71  auto roiDescriptor = input.roi;
72 
73 
74  if ( std::abs( roiDescriptor->eta() ) > 2.6 ) {
75  ATH_MSG_DEBUG( "REJECT The cluster had eta coordinates beyond the EM fiducial volume : " << roiDescriptor->eta() << "; stop the chain now" );
76  pass=false; // special case
77  return pass;
78  }
79 
80  ATH_MSG_INFO( "; RoI ID = " << roiDescriptor->roiId()
81  << ": Eta = " << roiDescriptor->eta()
82  << ", Phi = " << roiDescriptor->phi() );
83 
84  // fill local variables for RoI reference position
85  double etaRef = roiDescriptor->eta();
86  double phiRef = roiDescriptor->phi();
87  // correct phi the to right range ( probably not needed anymore )
88  if ( std::abs( phiRef ) > M_PI ) phiRef -= 2*M_PI; // correct phi if outside range
89 
90 
91  auto pClus = input.cluster;
92 
93  float absEta = std::abs( pClus->eta() );
94  const int cutIndex = findCutIndex( absEta );
95 
96 
97 
98  dEta = pClus->eta() - etaRef;
99  // Deal with angle diferences greater than Pi
100  dPhi = std::abs( pClus->phi() - phiRef );
101  dPhi = ( dPhi < M_PI ? dPhi : 2*M_PI - dPhi ); // TB why only <
102  eT_Cluster = pClus->et();
103  // apply cuts: DeltaEta( clus-ROI )
104  ATH_MSG_INFO( "CaloCluster: eta=" << pClus->eta()
105  << " roi eta=" << etaRef << " DeltaEta=" << dEta
106  << " cut: <" << m_detacluster );
107 
108  if ( std::abs( pClus->eta() - etaRef ) > m_detacluster ) {
109  ATH_MSG_DEBUG("REJECT Cluster dEta cut failed");
110  return pass;
111  }
112  PassedCuts = PassedCuts + 1; //Deta
113 
114  // DeltaPhi( clus-ROI )
115  ATH_MSG_DEBUG( ": phi=" << pClus->phi()
116  << " roi phi="<< phiRef << " DeltaPhi="<< dPhi
117  << " cut: <" << m_dphicluster );
118 
119  if( dPhi > m_dphicluster ) {
120  ATH_MSG_DEBUG("REJECT Clsuter dPhi cut failed");
121  return pass;
122  }
123  PassedCuts = PassedCuts + 1; //DPhi
124 
125  // eta range
126  if ( cutIndex == -1 ) { // VD
127  ATH_MSG_DEBUG( "Cluster eta: " << absEta << " outside eta range " << m_etabin[m_etabin.size()-1] );
128  return pass;
129  } else {
130  ATH_MSG_DEBUG( "eta bin used for cuts " << cutIndex );
131  }
132  PassedCuts = PassedCuts + 1; // passed eta cut
133 
134  // ET_em
135  ATH_MSG_DEBUG( "CaloCluster: ET_em=" << eT_Cluster << " cut: >" << m_eTthr[cutIndex] );
136  if ( eT_Cluster < m_eTthr[cutIndex] ) {
137  ATH_MSG_DEBUG("REJECT et cut failed");
138  return pass;
139  }
140  PassedCuts = PassedCuts + 1; // ET_em
141 
142  // got this far => passed!
143  pass = true;
144 
145  // Reach this point successfully
146  ATH_MSG_DEBUG( "pass = " << pass );
147 
148  return pass;
149 
150 }
151 
153  const float absEta = std::abs(eta);
154 
155  auto binIterator = std::adjacent_find( m_etabin.begin(), m_etabin.end(), [=](float left, float right){ return left < absEta and absEta < right; } );
156  if ( binIterator == m_etabin.end() ) {
157  return -1;
158  }
159  return binIterator - m_etabin.begin();
160 }
161 
162 
163 StatusCode TrigEgammaForwardPrecisionCaloHypoTool::decide( std::vector<ClusterInfo>& input ) const {
164  for ( auto& i: input ) {
165  if ( TCU::passed ( m_decisionId.numeric(), i.previousDecisionIDs ) ) {
166  if ( decide( i ) ) {
167  TCU::addDecisionID( m_decisionId, i.decision );
168  }
169  }
170  }
171  return StatusCode::SUCCESS;
172 }
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
TrigEgammaForwardPrecisionCaloHypoTool::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: TrigEgammaForwardPrecisionCaloHypoTool.h:40
TrigEgammaForwardPrecisionCaloHypoTool::decide
virtual StatusCode decide(std::vector< ITrigEgammaForwardPrecisionCaloHypoTool::ClusterInfo > &input) const override
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
TrigEgammaForwardPrecisionCaloHypoTool::m_eT2thr
Gaudi::Property< std::vector< float > > m_eT2thr
Definition: TrigEgammaForwardPrecisionCaloHypoTool.h:36
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
TrigCompositeUtils::addDecisionID
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
Definition: TrigCompositeUtilsRoot.cxx:61
M_PI
#define M_PI
Definition: ActiveFraction.h:11
TrigEgammaForwardPrecisionCaloHypoTool::m_etabin
Gaudi::Property< std::vector< float > > m_etabin
selection variable for PRECISION calo selection:eta bins
Definition: TrigEgammaForwardPrecisionCaloHypoTool.h:34
TrigEgammaForwardPrecisionCaloHypoTool::m_dphicluster
Gaudi::Property< float > m_dphicluster
Definition: TrigEgammaForwardPrecisionCaloHypoTool.h:38
TrigEgammaForwardPrecisionCaloHypoTool::m_eTthr
Gaudi::Property< std::vector< float > > m_eTthr
Definition: TrigEgammaForwardPrecisionCaloHypoTool.h:35
CHECK_SIZE
#define CHECK_SIZE(__n)
xAOD::etaBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin
Definition: L2StandAloneMuon_v1.cxx:148
TrigEgammaForwardPrecisionCaloHypoTool::TrigEgammaForwardPrecisionCaloHypoTool
TrigEgammaForwardPrecisionCaloHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TrigEgammaForwardPrecisionCaloHypoTool.cxx:16
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
lumiFormat.i
int i
Definition: lumiFormat.py:85
CaloCluster.h
TrigEgammaForwardPrecisionCaloHypoTool::m_detacluster
Gaudi::Property< float > m_detacluster
Definition: TrigEgammaForwardPrecisionCaloHypoTool.h:37
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
TauGNNUtils::Variables::Track::dPhi
bool dPhi(const xAOD::TauJet &tau, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:538
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
test_pyathena.parent
parent
Definition: test_pyathena.py:15
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
ITrigEgammaForwardPrecisionCaloHypoTool::ClusterInfo
Definition: ITrigEgammaForwardPrecisionCaloHypoTool.h:25
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TrigEgammaForwardPrecisionCaloHypoTool.h
Combinators.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
HLTIdentifier.h
TauGNNUtils::Variables::absEta
bool absEta(const xAOD::TauJet &tau, double &out)
Definition: TauGNNUtils.cxx:234
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
TrigEgammaForwardPrecisionCaloHypoTool::m_decisionId
HLT::Identifier m_decisionId
Definition: TrigEgammaForwardPrecisionCaloHypoTool.h:31
TrigEgammaForwardPrecisionCaloHypoTool::findCutIndex
int findCutIndex(float eta) const
Definition: TrigEgammaForwardPrecisionCaloHypoTool.cxx:152
TauGNNUtils::Variables::Track::dEta
bool dEta(const xAOD::TauJet &tau, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:527
TrigRoiDescriptorCollection.h
TrigEgammaForwardPrecisionCaloHypoTool::initialize
virtual StatusCode initialize() override
Definition: TrigEgammaForwardPrecisionCaloHypoTool.cxx:22
Identifier
Definition: IdentifierFieldParser.cxx:14