ATLAS Offline Software
TrigEgammaPrecisionCaloHypoTool.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>
11 
13 
14 
15 namespace TCU = TrigCompositeUtils;
16 
18  const std::string& name,
19  const IInterface* parent )
20  : base_class( type, name, parent ),
21  m_decisionId( HLT::Identifier::fromToolName( name ) ) {}
22 
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 #define CHECK_SIZE( __n) if ( m_##__n.size() != (nEtaBin - 1) ) \
37  { ATH_MSG_DEBUG(" __n size is " << m_##__n.size() << " but needs to be " << (nEtaBin - 1) ); return StatusCode::FAILURE; }
38 
39  CHECK_SIZE( eTthr );
40  CHECK_SIZE( eT2thr );
41 #undef CHECK_SIZE
42 
43 
44 
45  ATH_MSG_DEBUG( "Tool configured for chain/id: " << m_decisionId );
46 
47  if ( not m_monTool.name().empty() )
48  CHECK( m_monTool.retrieve() );
49 
50  return StatusCode::SUCCESS;
51 }
52 
53 
55 
56  bool pass = false;
57 
58  auto mon_dEta = Monitored::Scalar( "dEta", -1. );
59  auto mon_dPhi = Monitored::Scalar( "dPhi", -1. );
60  auto mon_eta = Monitored::Scalar( "Eta", -99. );
61  auto mon_phi = Monitored::Scalar( "Phi", -99. );
62  auto mon_eT_Cluster = Monitored::Scalar( "Et_em" , -1.0 );
63  auto PassedCuts = Monitored::Scalar<int>( "CutCounter", -1 );
64  auto monitorIt = Monitored::Group( m_monTool, mon_dEta, mon_dPhi, mon_eta, mon_phi, mon_eT_Cluster,PassedCuts );
65 
66  // when leaving scope it will ship data to monTool
67  PassedCuts = PassedCuts + 1; //got called (data in place)
68 
69  float dEta(0), dPhi(0), eta(0), phi(0), eT_Cluster(0);
70 
71  auto roiDescriptor = input.roi;
72 
73 
74  if ( fabs( 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_DEBUG( "; 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 
88  // correct phi the to right range ( probably not needed anymore )
89  if ( fabs( phiRef ) > M_PI ) phiRef -= 2*M_PI; // correct phi if outside range
90 
91 
92  auto pClus = input.cluster;
93  eta = pClus->eta();
94  phi = pClus->phi();
95 
96  float absEta = fabs( pClus->eta() );
97  const int cutIndex = findCutIndex( absEta );
98 
99  dEta = pClus->eta() - etaRef;
100  // Deal with angle diferences greater than Pi
101  dPhi = fabs( pClus->phi() - phiRef );
102  dPhi = ( dPhi < M_PI ? dPhi : 2*M_PI - dPhi ); // TB why only <
103  eT_Cluster = pClus->et();
104  // apply cuts: DeltaEta( clus-ROI )
105  ATH_MSG_DEBUG( "CaloCluster: eta=" << pClus->eta()
106  << " roi eta=" << etaRef << " DeltaEta=" << dEta
107  << " cut: <" << m_detacluster );
108 
109  if ( fabs(dEta) > m_detacluster ) {
110  ATH_MSG_DEBUG("REJECT Cluster dEta cut failed");
111  return pass;
112  }
113  mon_eta = eta;
114  mon_dEta = dEta;
115  PassedCuts = PassedCuts + 1; //Deta
116 
117  // DeltaPhi( clus-ROI )
118  ATH_MSG_DEBUG( ": phi=" << pClus->phi()
119  << " roi phi="<< phiRef << " DeltaPhi="<< dPhi
120  << " cut: <" << m_dphicluster );
121 
122  if( dPhi > m_dphicluster ) {
123  ATH_MSG_DEBUG("REJECT Clsuter dPhi cut failed");
124  return pass;
125  }
126  mon_dPhi = dPhi;
127  mon_phi = phi;
128  PassedCuts = PassedCuts + 1; //DPhi
129 
130  // eta range
131  if ( cutIndex == -1 ) { // VD
132  ATH_MSG_DEBUG( "Cluster eta: " << absEta << " outside eta range " << m_etabin[m_etabin.size()-1] );
133  return pass;
134  } else {
135  ATH_MSG_DEBUG( "eta bin used for cuts " << cutIndex );
136  }
137  PassedCuts = PassedCuts + 1; // passed eta cut
138 
139  // ET_em
140  ATH_MSG_DEBUG( "PrecisionCaloCluster: ET_em=" << eT_Cluster << " cut: >" << m_eTthr[cutIndex] );
141  if ( eT_Cluster < m_eTthr[cutIndex] ) {
142  ATH_MSG_DEBUG("REJECT et cut failed");
143  return pass;
144  }
145  mon_eT_Cluster = eT_Cluster;
146 
147  // got this far => passed!
148  pass = true;
149 
150  // Reach this point successfully
151  ATH_MSG_DEBUG( "pass = " << pass );
152 
153  return pass;
154 
155 }
156 
158  const float absEta = std::abs(eta);
159 
160  auto binIterator = std::adjacent_find( m_etabin.begin(), m_etabin.end(), [=](float left, float right){ return left < absEta and absEta < right; } );
161  if ( binIterator == m_etabin.end() ) {
162  return -1;
163  }
164  return binIterator - m_etabin.begin();
165 }
166 
167 
168 StatusCode TrigEgammaPrecisionCaloHypoTool::decide( std::vector<ClusterInfo>& input ) const {
169  for ( auto& i: input ) {
170  if ( TCU::passed ( m_decisionId.numeric(), i.previousDecisionIDs ) ) {
171  if ( decide( i ) ) {
172  TCU::addDecisionID( m_decisionId, i.decision );
173  }
174  }
175  }
176  return StatusCode::SUCCESS;
177 }
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
TrigEgammaPrecisionCaloHypoTool::m_decisionId
HLT::Identifier m_decisionId
Definition: TrigEgammaPrecisionCaloHypoTool.h:31
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
HLT::Identifier::numeric
TrigCompositeUtils::DecisionID numeric() const
numeric ID
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:47
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
TrigEgammaPrecisionCaloHypoTool::m_eTthr
Gaudi::Property< std::vector< float > > m_eTthr
Definition: TrigEgammaPrecisionCaloHypoTool.h:35
CHECK_SIZE
#define CHECK_SIZE(__n)
M_PI
#define M_PI
Definition: ActiveFraction.h:11
TrigEgammaPrecisionCaloHypoTool::TrigEgammaPrecisionCaloHypoTool
TrigEgammaPrecisionCaloHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TrigEgammaPrecisionCaloHypoTool.cxx:17
TrigEgammaPrecisionCaloHypoTool::findCutIndex
int findCutIndex(float eta) const
Definition: TrigEgammaPrecisionCaloHypoTool.cxx:157
TrigEgammaPrecisionCaloHypoTool::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: TrigEgammaPrecisionCaloHypoTool.h:40
TrigEgammaPrecisionCaloHypoTool::m_etabin
Gaudi::Property< std::vector< float > > m_etabin
selection variable for PRECISION calo selection:eta bins
Definition: TrigEgammaPrecisionCaloHypoTool.h:34
TrigEgammaPrecisionCaloHypoTool::m_dphicluster
Gaudi::Property< float > m_dphicluster
Definition: TrigEgammaPrecisionCaloHypoTool.h:38
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TrigEgammaPrecisionCaloHypoTool::initialize
virtual StatusCode initialize() override
Definition: TrigEgammaPrecisionCaloHypoTool.cxx:23
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
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
ITrigEgammaPrecisionCaloHypoTool::ClusterInfo
Definition: ITrigEgammaPrecisionCaloHypoTool.h:25
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
TrigEgammaPrecisionCaloHypoTool::decide
virtual StatusCode decide(std::vector< ITrigEgammaPrecisionCaloHypoTool::ClusterInfo > &input) const override
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
Combinators.h
TrigEgammaPrecisionCaloHypoTool::m_detacluster
Gaudi::Property< float > m_detacluster
Definition: TrigEgammaPrecisionCaloHypoTool.h:37
TrigEgammaPrecisionCaloHypoTool.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
HLTIdentifier.h
TrigEgammaPrecisionCaloHypoTool::m_eT2thr
Gaudi::Property< std::vector< float > > m_eT2thr
Definition: TrigEgammaPrecisionCaloHypoTool.h:36
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
TauGNNUtils::Variables::Track::dEta
bool dEta(const xAOD::TauJet &tau, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:527
TrigRoiDescriptorCollection.h
Identifier
Definition: IdentifierFieldParser.cxx:14