ATLAS Offline Software
TrigEgammaPrecisionPhotonCaloIsoHypoTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /*
6  * =====================================================================================
7  *
8  * Filename: TrigEgammaPrecisionPhotonCaloIsoHypoTool.cxx
9  *
10  * Description: Hypo tool for Calorimeter isolation applied HLT precision step for photon triggers
11  *
12  * Created: 08/09/2022 11:19:55 AM
13  *
14  * Author: Fernando Monticelli (), Fernando.Monticelli@cern.ch
15  * Organization: UNLP/IFLP/CONICET
16  *
17  * =====================================================================================
18  */
19 #include <algorithm>
24 #include "xAODEgamma/Photon.h"
27 
29 
30 namespace TCU = TrigCompositeUtils;
31 
33  const std::string& name,
34  const IInterface* parent )
35  : base_class( type, name, parent ),
36  m_decisionId( HLT::Identifier::fromToolName( name ) ) {
37 }
38 
39 
41 {
42  ATH_MSG_DEBUG( "Initialization completed successfully" );
43  ATH_MSG_DEBUG( "EtaBins = " << m_etabin );
44 
45  if ( m_etabin.empty() ) {
46  ATH_MSG_ERROR( " There are no cuts set (EtaBins property is an empty list)" );
47  return StatusCode::FAILURE;
48  }
49 
50  // Now we try to retrieve the ElectronPhotonSelectorTools that we will use to apply the photon Identification. This is a *must*
51 
52 
53  // Retrieving Luminosity info
54  ATH_MSG_DEBUG( "Retrieving luminosityCondData..." );
55  ATH_CHECK( m_avgMuKey.initialize() );
56 
57  ATH_MSG_DEBUG( "Tool configured for chain/id: " << m_decisionId );
58 
59  if ( not m_monTool.name().empty() )
60  CHECK( m_monTool.retrieve() );
61 
62  return StatusCode::SUCCESS;
63 }
64 
65 
67 {
68 
69  bool pass = false;
70 
71  auto mon_ET = Monitored::Scalar( "Et_em", -1.0 );
72  auto mon_etaBin = Monitored::Scalar( "EtaBin", -1.0 );
73  auto mon_Eta = Monitored::Scalar( "Eta", -99. );
74  auto mon_Phi = Monitored::Scalar( "Phi", -99. );
75  auto mon_mu = Monitored::Scalar("mu", -1.);
76  auto mon_etcone20 = Monitored::Scalar("etcone20", -99.);
77  auto mon_topoetcone20 = Monitored::Scalar("topoetcone20", -99.);
78  auto mon_reletcone20 = Monitored::Scalar("reletcone20", -99.);
79  auto mon_reltopoetcone20 = Monitored::Scalar("reltopoetcone20", -99.);
80 
81  auto mon_etcone30 = Monitored::Scalar("etcone30", -99.);
82  auto mon_topoetcone30 = Monitored::Scalar("topoetcone30", -99.);
83  auto mon_reletcone30 = Monitored::Scalar("reletcone30", -99.);
84  auto mon_reltopoetcone30 = Monitored::Scalar("reltopoetcone30", -99.);
85 
86  auto mon_etcone40 = Monitored::Scalar("etcone40", -99.);
87  auto mon_topoetcone40 = Monitored::Scalar("topoetcone40", -99.);
88  auto mon_reletcone40 = Monitored::Scalar("reletcone40", -99.);
89  auto mon_reltopoetcone40 = Monitored::Scalar("reltopoetcone40", -99.);
90 
91  auto PassedCuts = Monitored::Scalar<int>( "CutCounter", -1 );
92  auto monitorIt = Monitored::Group( m_monTool,
93  mon_etaBin, mon_Eta, mon_Phi, mon_mu,
94  mon_etcone20, mon_topoetcone20, mon_reletcone20, mon_reltopoetcone20,
95  mon_etcone30, mon_topoetcone30, mon_reletcone30, mon_reltopoetcone30,
96  mon_etcone40, mon_topoetcone40, mon_reletcone40, mon_reltopoetcone40,
97  PassedCuts );
98 
99  // when leaving scope it will ship data to monTool
100  PassedCuts = PassedCuts + 1; //got called (data in place)
101 
102  float ET(0);
103 
104  auto roiDescriptor = input.roi;
105 
106  if ( fabs( roiDescriptor->eta() ) > 2.6 ) {
107  ATH_MSG_DEBUG( "REJECT The photon had eta coordinates beyond the EM fiducial volume : "
108  << roiDescriptor->eta() << "; stop the chain now" );
109  pass=false; // special case
110  return pass;
111  }
112 
113  ATH_MSG_DEBUG( "; RoI ID = " << roiDescriptor->roiId()
114  << ": Eta = " << roiDescriptor->eta()
115  << ", Phi = " << roiDescriptor->phi() );
116 
117 
118  auto pClus = input.photon->caloCluster();
119 
120  float absEta = fabs( pClus->eta() );
121  const int cutIndex = findCutIndex( absEta );
122 
123  ET = pClus->et();
124  // eta = pClus->eta();
125  // phi = pClus->phi();
126 
127  // eta range
128  if ( !m_acceptAll && cutIndex == -1 ) { // VD
129  ATH_MSG_DEBUG( "Photon : " << absEta << " outside eta range " << m_etabin[m_etabin.size()-1] );
130  return pass;
131  } else {
132  ATH_MSG_DEBUG( "eta bin used for cuts " << cutIndex << " AcceptAll = " << m_acceptAll );
133  }
134  mon_etaBin = m_etabin[cutIndex];
135  PassedCuts = PassedCuts + 1; // passed eta cut
136 
137  mon_ET = ET;
138 
139  // get average luminosity information to calculate LH
140  float avg_mu = 0;
142  if(eventInfoDecor.isPresent()) {
143  avg_mu = eventInfoDecor(0);
144  ATH_MSG_DEBUG("Average mu " << avg_mu);
145  }
146  mon_mu = avg_mu;
147 
148  float ptcone20(999), ptcone30(999), ptcone40(999),
149  etcone20(999), etcone30(999), etcone40(999),
150  topoetcone20(999), topoetcone30(999), topoetcone40(999),
151  reletcone20(999), reletcone30(999), reletcone40(999),
152  reltopoetcone20(999), reltopoetcone30(999), reltopoetcone40(999);
153 
154 
155  // isolation variables
156  input.photon->isolationValue(ptcone20, xAOD::Iso::ptcone20);
157 
158  input.photon->isolationValue(ptcone30, xAOD::Iso::ptcone30);
159 
160  input.photon->isolationValue(ptcone40, xAOD::Iso::ptcone40);
161 
162  input.photon->isolationValue(etcone20, xAOD::Iso::etcone20);
163 
164  input.photon->isolationValue(etcone30, xAOD::Iso::etcone30);
165 
166  input.photon->isolationValue(etcone40, xAOD::Iso::etcone40);
167 
168  input.photon->isolationValue(topoetcone20, xAOD::Iso::topoetcone20);
169 
170  input.photon->isolationValue(topoetcone30, xAOD::Iso::topoetcone30);
171 
172  input.photon->isolationValue(topoetcone40, xAOD::Iso::topoetcone40);
173 
174  ATH_MSG_DEBUG( " ptcone20 = " << ptcone20 ) ;
175  ATH_MSG_DEBUG( " ptcone30 = " << ptcone30 ) ;
176  ATH_MSG_DEBUG( " ptcone40 = " << ptcone40 ) ;
177  ATH_MSG_DEBUG( " etcone20 = " << etcone20 ) ;
178  ATH_MSG_DEBUG( " etcone30 = " << etcone30 ) ;
179  ATH_MSG_DEBUG( " etcone40 = " << etcone40 ) ;
180  ATH_MSG_DEBUG( " topoetcone20 = " << topoetcone20 ) ;
181  ATH_MSG_DEBUG( " topoetcone30 = " << topoetcone30 ) ;
182  ATH_MSG_DEBUG( " topoetcone40 = " << topoetcone40 ) ;
183 
184  // Monitor showershapes
185  float photon_eT = input.photon->caloCluster()->et();
186  mon_etcone20 = etcone20;
187  reletcone20 = etcone20/photon_eT;
188  ATH_MSG_DEBUG("reletcone20 = " <<reletcone20 );
189  mon_reletcone20 = reletcone20;
190 
191  mon_topoetcone20 = topoetcone20;
192  reltopoetcone20 = topoetcone20/photon_eT;
193  ATH_MSG_DEBUG("reltopoetcone20 = " <<reltopoetcone20 );
194  mon_reltopoetcone20 = reltopoetcone20;
195 
196  mon_etcone30 = etcone30;
197  reletcone30 = etcone30/photon_eT;
198  ATH_MSG_DEBUG("reletcone30 = " <<reletcone30 );
199  mon_reletcone30 = reletcone30;
200 
201  mon_topoetcone30 = topoetcone30;
202  reltopoetcone30 = topoetcone30/photon_eT;
203  ATH_MSG_DEBUG("reltopoetcone30 = " <<reltopoetcone30 );
204  mon_reltopoetcone30 = reltopoetcone30;
205 
206  mon_etcone40 = etcone40;
207  reletcone40 = etcone40/photon_eT;
208  ATH_MSG_DEBUG("reletcone40 = " <<reletcone40 );
209  mon_reletcone40 = reletcone40;
210 
211  mon_topoetcone40 = topoetcone40;
212  reltopoetcone40 = topoetcone40/photon_eT;
213  ATH_MSG_DEBUG("reltopoetcone40 = " <<reltopoetcone40 );
214  mon_reltopoetcone40 = reltopoetcone40;
215 
216  // Place here all etcone variables to apply the cuts within the loop on cone sizes
217  std::vector<float> reltopoetcone;
218  reltopoetcone.push_back(reltopoetcone20);
219  reltopoetcone.push_back(reltopoetcone30);
220  reltopoetcone.push_back(reltopoetcone40);
221 
222  std::vector<float> reletcone;
223  reletcone.push_back(etcone20);
224  reletcone.push_back(etcone30);
225  reletcone.push_back(etcone40);
226 
227 
228  bool pass_reletcone = true; // If cut is not succeeded, this will be "AND"ed with a False result
229  bool pass_reltopoetcone = true;
230 
231  // Loop over three indices 0,1 and 2, each referring to cones 20 30 and 40 and checking whether it passes or not
232  for (unsigned int conesize=0; conesize<3; conesize++){
233  ATH_MSG_DEBUG("m_RelEtConeCut[" << conesize << "] = " << m_RelEtConeCut[conesize] );
234  ATH_MSG_DEBUG("m_RelTopoEtConeCut[" << conesize << "] = " << m_RelTopoEtConeCut[conesize] );
235  ATH_MSG_DEBUG("m_CutOffset[" << conesize << "] = " << m_CutOffset[conesize] );
236 
237  // Check if need to apply isolation
238  // First check logic. if cut is very big, then no isolation cut is defined
239  // Applies to both reletcone[20,30,40] and reltopoetcone[20,30,40]
240  if (m_RelEtConeCut[conesize] > 900){ // I guess we want to deprecate this?
241  ATH_MSG_DEBUG(" not applying etcone[" << conesize << "] isolation.");
242  }
243  if (m_RelTopoEtConeCut[conesize] > 900){ // I guess we want to deprecate this?
244  ATH_MSG_DEBUG(" not applying topoetcone[" << conesize << "] isolation.");
245  }
246  bool pass_this_reletcone = ( m_RelEtConeCut[conesize] > 900 || ( reletcone[conesize] - m_CutOffset[conesize]/photon_eT < m_RelEtConeCut[conesize]));
247  bool pass_this_reltopoetcone = ( m_RelTopoEtConeCut[conesize] > 900 || ( reltopoetcone[conesize] - m_CutOffset[conesize]/photon_eT < m_RelTopoEtConeCut[conesize]));
248 
249  ATH_MSG_DEBUG(" pass_reletcone[" << conesize << "] = " << reletcone[conesize] << " - " << m_CutOffset[conesize] << "/" << photon_eT << " < " << m_RelEtConeCut[conesize] << " = " << pass_reletcone);
250  ATH_MSG_DEBUG(" pass_reltopoetcone[" << conesize << "] = " << reltopoetcone[conesize] << " - " << m_CutOffset[conesize] << "/" << photon_eT << " < " << m_RelEtConeCut[conesize] << " = " << pass_reltopoetcone);
251 
252  pass_reletcone = pass_reletcone && pass_this_reletcone ;
253  pass_reltopoetcone = pass_reltopoetcone && pass_this_reltopoetcone ;
254  }
255  // Reach this point successfully
256  pass = m_acceptAll || (pass_reletcone && pass_reltopoetcone);
257  ATH_MSG_DEBUG( "AcceptAll = " << m_acceptAll );
258  ATH_MSG_DEBUG( "pass_reletcone = " << pass_reletcone );
259  ATH_MSG_DEBUG( "pass_reltopoetcone = " << pass_reltopoetcone );
260  ATH_MSG_DEBUG( "pass = " << pass );
261 
262  return pass;
263 
264 }
265 
267  const float absEta = std::abs(eta);
268 
269  auto binIterator = std::adjacent_find( m_etabin.begin(), m_etabin.end(), [=](float left, float right){ return left < absEta and absEta < right; } );
270  if ( binIterator == m_etabin.end() ) {
271  return -1;
272  }
273  return binIterator - m_etabin.begin();
274 }
275 
276 
277 StatusCode TrigEgammaPrecisionPhotonCaloIsoHypoTool::decide( std::vector<PhotonInfo>& input ) const {
278  for ( auto& i: input ) {
279  if ( TCU::passed ( m_decisionId.numeric(), i.previousDecisionIDs ) ) {
280  if ( decide( i ) ) {
281  TCU::addDecisionID( m_decisionId, i.decision );
282  }
283  }
284  }
285  return StatusCode::SUCCESS;
286 }
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
xAOD::Iso::topoetcone20
@ topoetcone20
Topo-cluster ET-sum.
Definition: IsolationType.h:48
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
TrigCompositeUtils.h
HLT::Identifier::numeric
TrigCompositeUtils::DecisionID numeric() const
numeric ID
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:47
TrigEgammaPrecisionPhotonCaloIsoHypoTool::m_acceptAll
Gaudi::Property< bool > m_acceptAll
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.h:56
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
TrigCompositeUtils::addDecisionID
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
Definition: TrigCompositeUtilsRoot.cxx:61
xAOD::Iso::ptcone30
@ ptcone30
Definition: IsolationType.h:41
xAOD::Iso::ptcone20
@ ptcone20
Track isolation.
Definition: IsolationType.h:40
SG::ReadDecorHandle::isPresent
bool isPresent() const
Is the referenced container present in SG?
xAOD::Iso::etcone40
@ etcone40
Definition: IsolationType.h:34
TrigEgammaPrecisionPhotonCaloIsoHypoTool::decide
virtual StatusCode decide(std::vector< ITrigEgammaPrecisionPhotonCaloIsoHypoTool::PhotonInfo > &input) const override
xAOD::Iso::topoetcone30
@ topoetcone30
Definition: IsolationType.h:49
TrigEgammaPrecisionPhotonCaloIsoHypoTool::initialize
virtual StatusCode initialize() override
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.cxx:40
xAOD::Iso::etcone30
@ etcone30
Definition: IsolationType.h:33
TrigEgammaPrecisionPhotonCaloIsoHypoTool::m_RelEtConeCut
Gaudi::Property< std::vector< float > > m_RelEtConeCut
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.h:50
TrigEgammaPrecisionPhotonCaloIsoHypoTool::m_decisionId
HLT::Identifier m_decisionId
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.h:46
TrigEgammaPrecisionPhotonCaloIsoHypoTool::findCutIndex
int findCutIndex(float eta) const
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.cxx:266
TrigEgammaPrecisionPhotonCaloIsoHypoTool::m_etabin
Gaudi::Property< std::vector< float > > m_etabin
selection variable for PRECISION calo selection:eta bins
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.h:49
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition: StoreGate/StoreGate/ReadDecorHandle.h:94
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:92
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
xAOD::Iso::etcone20
@ etcone20
Calorimeter isolation.
Definition: IsolationType.h:32
Photon.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
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
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
TrigEgammaPrecisionPhotonCaloIsoHypoTool::m_RelTopoEtConeCut
Gaudi::Property< std::vector< float > > m_RelTopoEtConeCut
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.h:51
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
TrigEgammaPrecisionPhotonCaloIsoHypoTool.h
TrigEgammaPrecisionPhotonCaloIsoHypoTool::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.h:58
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
xAOD::Iso::ptcone40
@ ptcone40
Definition: IsolationType.h:42
TrigEgammaPrecisionPhotonCaloIsoHypoTool::m_CutOffset
Gaudi::Property< std::vector< float > > m_CutOffset
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.h:52
Combinators.h
TrigEgammaPrecisionPhotonCaloIsoHypoTool::TrigEgammaPrecisionPhotonCaloIsoHypoTool
TrigEgammaPrecisionPhotonCaloIsoHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.cxx:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
HLTIdentifier.h
TauGNNUtils::Variables::absEta
bool absEta(const xAOD::TauJet &tau, double &out)
Definition: TauGNNUtils.cxx:232
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
ITrigEgammaPrecisionPhotonCaloIsoHypoTool::PhotonInfo
Definition: ITrigEgammaPrecisionPhotonCaloIsoHypoTool.h:25
TrigRoiDescriptor.h
xAOD::Iso::topoetcone40
@ topoetcone40
Definition: IsolationType.h:50
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
TrigEgammaPrecisionPhotonCaloIsoHypoTool::m_avgMuKey
SG::ReadDecorHandleKey< xAOD::EventInfo > m_avgMuKey
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.h:61
PhotonContainer.h