ATLAS Offline Software
TrigEgammaFastPhotonHypoTool.cxx
Go to the documentation of this file.
1 
2 /*
3  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
4 */
5 
6 
11 
12 namespace TCU = TrigCompositeUtils;
13 
15  const std::string& name,
16  const IInterface* parent )
17  : AthAlgTool( type, name, parent ),
18  m_decisionId( HLT::Identifier::fromToolName( name ) ) {}
19 
20 
21 
23 
24  if ( !m_monTool.empty() )
25  ATH_CHECK( m_monTool.retrieve() );
26 
27  ATH_MSG_DEBUG( "Initialization completed successfully:" );
28  ATH_MSG_DEBUG( "AcceptAll = " << ( m_acceptAll==true ? "True" : "False" ) );
29  ATH_MSG_DEBUG( "EtaBins = " << m_etabin );
30  ATH_MSG_DEBUG( "ETthr = " << m_eTthr << "(lo)/" << m_eT2thr << "(hi)" );
31  ATH_MSG_DEBUG( "HADETthr = " << m_hadeTthr << "(lo)/" << m_hadeT2thr << "(hi)" );
32  ATH_MSG_DEBUG( "CARCOREthr = " << m_carcorethr );
33  ATH_MSG_DEBUG( "CAERATIOthr = " << m_caeratiothr );
34 
35 
36  std::vector<size_t> sizes( {m_eTthr.size(), m_eT2thr.size(),
37  m_hadeTthr.size(), m_hadeT2thr.size(),
38  m_carcorethr.size(), m_caeratiothr.size() } );
39 
40  if ( *std::min_element( sizes.begin(), sizes.end() ) != *std::max_element( sizes.begin(), sizes.end() ) ) {
41  ATH_MSG_ERROR( "Missconfiguration, cut properties listed above ( when DEBUG ) have different dimensions shortest: "
42  << *std::min_element( sizes.begin(), sizes.end() ) << " longest "
43  << *std::max_element( sizes.begin(), sizes.end() ) );
44  return StatusCode::FAILURE;
45  }
46 
47  return StatusCode::SUCCESS;
48 }
49 
50 //==================================================================
51 
52 StatusCode TrigEgammaFastPhotonHypoTool::decide( std::vector<PhotonInfo>& input) const {
53  for ( auto& i: input ) {
54  if ( TCU::passed ( m_decisionId.numeric(), i.previousDecisionIDs ) ) {
55  if ( decide( i.photon ) ) {
56  TCU::addDecisionID( m_decisionId, i.decision );
57  }
58  }
59  }
60  return StatusCode::SUCCESS;
61 }
62 
63 //==================================================================
64 
66 
67  auto cutCounter = Monitored::Scalar<int>( "CutCounter", -1 );
68  auto mon_Et = Monitored::Scalar( "Et", -99. );
69  auto mon_Eta = Monitored::Scalar( "Eta", -99. );
70  auto mon_Phi = Monitored::Scalar( "Phi", -99. );
71  auto mon_Rcore = Monitored::Scalar( "Rcore", -99. );
72  auto mon_Eratio = Monitored::Scalar( "Eratio", -99. );
73  auto mon_HadEt = Monitored::Scalar( "Et_had", -99. );
74  auto mon_F1 = Monitored::Scalar( "F1", -99. );
75  auto mon_HadEmRatio = Monitored::Scalar( "HadEmRatio", -99. );
76  auto monitorIt = Monitored::Group( m_monTool,
77  cutCounter,
78  mon_Et,
79  mon_Eta, mon_Phi,
80  mon_Rcore, mon_Eratio,
81  mon_HadEt, mon_F1,mon_HadEmRatio );
82 
83  float EmET = -99.0;
84  float HadEmRatio = -99.0;
85  float Reta = -99.0;
86  float Eratio = -99.0;
87  float f1 = -99.0;
88  float HadET = -99.0;
89 
90  if(!photon) return false;
91 
92  cutCounter++;
93 
94  // Determine which eta bin to apply the cuts
95  float absEta = std::abs( photon->eta() );
96 
97  int etaBin = findCutIndex(absEta);
98 
99  // getting photon variable
100  Eratio = photon->eratio();
101  Reta = photon->rcore();
102  EmET = photon->pt();
103  HadET = photon->etHad();
104  f1 = photon->f1();
105 
106  if(m_acceptAll) {
107  ATH_MSG_DEBUG ( "Accept all property is set: TrigPhoton: ET_em=" << EmET << " cut in etaBin "
108  << etaBin << " is ET_em >= " << m_eTthr[0] );
109  return true;
110  }
111 
112  // eta range
113  if ( etaBin==-1 ) {
114  ATH_MSG_DEBUG( "Photon FAILS eta: " << absEta << " outside eta range " << m_etabin[m_etabin.size()-1] );
115  return false;
116  } else {
117  ATH_MSG_DEBUG( "eta bin used for cuts " << etaBin );
118  }
119  cutCounter++; // passed eta cut
120  mon_Eta = photon->eta();
121  mon_Phi = photon->phi();
122 
123  // ET_em
124  if ( EmET < m_eTthr[etaBin]) {
125  ATH_MSG_DEBUG( "TrigPhoton FAILS ET_em=" << EmET
126  << " not in etaBin " << etaBin << " is ET_em < " << m_eTthr[etaBin] );
127  return false;
128  }
129  mon_Et = EmET;
130  cutCounter++; // passed ET threshold cut
131 
132  // Reta (was previously called Rcore)
133  if ( Reta < m_carcorethr[etaBin] ){
134  ATH_MSG_DEBUG( "FastPhoton FAILS Reta=" << Reta << " cut in etaBin "
135  << etaBin << " is Reta >= " << m_carcorethr[etaBin] );
136  return false;
137  }
138  mon_Rcore = Reta;
139  cutCounter++;
140 
141 
142  // // Eratio
143  bool inCrack = ( absEta > 2.37 || ( absEta > 1.37 && absEta < 1.52) );
144  if ( inCrack || f1<m_F1thr[etaBin] ) {
145  ATH_MSG_DEBUG( "FastPhoton: InCrack= " << inCrack << " F1=" << f1
146  << " Eratio cut not being applied" );
147  } else {
148  if ( Eratio < m_caeratiothr[etaBin] ) {
149  ATH_MSG_DEBUG( "FastPhoton FAILS Eratio=" << Eratio << " cut in etaBin "
150  << etaBin << " is Eratio >= " << m_caeratiothr[etaBin] );
151  return false;
152  }
153  }
154  cutCounter++;
155  if(inCrack) Eratio = -1; //Set default value in crack for monitoring.
156  mon_Eratio = Eratio;
157  mon_F1 = f1;
158  // ET_had
159  // find which ET_had to apply : this depends on the ET_em and the eta bin
160  float hadET_cut=-1;
161 
162  if ( EmET > m_eT2thr[etaBin] ) {
163  hadET_cut = m_hadeT2thr[etaBin] ;
164  ATH_MSG_DEBUG( "ET_em>" << m_eT2thr[etaBin] );
165  } else {
166  hadET_cut = m_hadeTthr[etaBin];
167  ATH_MSG_DEBUG( "ET_em<" << m_eT2thr[etaBin] );
168  }
169 
170  HadEmRatio = (EmET!=0) ? HadET/EmET : -1.0;
171 
172  if ( HadEmRatio > hadET_cut ){
173  ATH_MSG_DEBUG( "FastPhoton FAILS ET_had=" << HadEmRatio << " cut in etaBin "
174  << etaBin << " is ERatio >= " << hadET_cut );
175  return false;
176 
177  }
178  mon_HadEt = HadET;
179  mon_HadEmRatio = HadEmRatio;
180  cutCounter++;
181  ATH_MSG_DEBUG( "FastPhoton PASS");
182 
183  return true;
184 
185 }
186 
187 //==================================================================
188 
190  const float absEta = std::abs(eta);
191  auto binIterator = std::adjacent_find( m_etabin.begin(), m_etabin.end(), [=](float left, float right){ return left < absEta and absEta < right; } );
192  if ( binIterator == m_etabin.end() ) {
193  return -1;
194  }
195  return binIterator - m_etabin.begin();
196 }
197 
198 
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
TrigEgammaFastPhotonHypoTool::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: TrigEgammaFastPhotonHypoTool.h:60
TrigEgammaFastPhotonHypoTool::decide
StatusCode decide(std::vector< PhotonInfo > &decisions) const
Definition: TrigEgammaFastPhotonHypoTool.cxx:52
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
xAOD::EgammaParameters::Reta
@ Reta
e237/e277
Definition: EgammaEnums.h:154
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
TrigEgammaFastPhotonHypoTool::findCutIndex
int findCutIndex(float eta) const
Definition: TrigEgammaFastPhotonHypoTool.cxx:189
TrigEgammaFastPhotonHypoTool::m_hadeT2thr
Gaudi::Property< std::vector< float > > m_hadeT2thr
Definition: TrigEgammaFastPhotonHypoTool.h:56
TrigCompositeUtils::addDecisionID
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
Definition: TrigCompositeUtilsRoot.cxx:61
TrigEgammaFastPhotonHypoTool::m_carcorethr
Gaudi::Property< std::vector< float > > m_carcorethr
Definition: TrigEgammaFastPhotonHypoTool.h:57
TrigEgammaFastPhotonHypoTool::m_eTthr
Gaudi::Property< std::vector< float > > m_eTthr
Definition: TrigEgammaFastPhotonHypoTool.h:53
TrigEgammaFastPhotonHypoTool::initialize
virtual StatusCode initialize() override
Definition: TrigEgammaFastPhotonHypoTool.cxx:22
TrigEgammaFastPhotonHypoTool::m_F1thr
Gaudi::Property< std::vector< float > > m_F1thr
Definition: TrigEgammaFastPhotonHypoTool.h:52
TrigEgammaFastPhotonHypoTool::m_eT2thr
Gaudi::Property< std::vector< float > > m_eT2thr
Definition: TrigEgammaFastPhotonHypoTool.h:54
TrigEgammaFastPhotonHypoTool::m_decisionId
HLT::Identifier m_decisionId
Definition: TrigEgammaFastPhotonHypoTool.h:48
TrigEgammaFastPhotonHypoTool.h
xAOD::etaBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin
Definition: L2StandAloneMuon_v1.cxx:148
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
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
TrigEgammaFastPhotonHypoTool::m_caeratiothr
Gaudi::Property< std::vector< float > > m_caeratiothr
Definition: TrigEgammaFastPhotonHypoTool.h:58
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
xAOD::TrigPhoton_v1
Class describing a photon reconstructed in the HLT.
Definition: TrigPhoton_v1.h:38
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TrigEgammaFastPhotonHypoTool::m_acceptAll
Gaudi::Property< bool > m_acceptAll
Definition: TrigEgammaFastPhotonHypoTool.h:50
xAOD::photon
@ photon
Definition: TrackingPrimitives.h:199
Combinators.h
TrigEgammaFastPhotonHypoTool::m_hadeTthr
Gaudi::Property< std::vector< float > > m_hadeTthr
Definition: TrigEgammaFastPhotonHypoTool.h:55
TrigEgammaFastPhotonHypoTool::m_etabin
Gaudi::Property< std::vector< float > > m_etabin
Definition: TrigEgammaFastPhotonHypoTool.h:51
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
xAOD::EgammaParameters::Eratio
@ Eratio
(emaxs1-e2tsts1)/(emaxs1+e2tsts1)
Definition: EgammaEnums.h:158
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
AthAlgTool
Definition: AthAlgTool.h:26
TrigEgammaFastPhotonHypoTool::TrigEgammaFastPhotonHypoTool
TrigEgammaFastPhotonHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TrigEgammaFastPhotonHypoTool.cxx:14
read_hist_ntuple.f1
f1
Definition: read_hist_ntuple.py:4
Identifier
Definition: IdentifierFieldParser.cxx:14