ATLAS Offline Software
TrigEgammaEmulationPrecisionPhotonHypoTool.cxx
Go to the documentation of this file.
2 #include "GaudiKernel/SystemOfUnits.h"
3 
4 
5 using namespace Trig;
6 
7 //**********************************************************************
8 
11 {}
12 
14 
16 {
18  return StatusCode::SUCCESS;
19 }
20 
22 
24  bool &pass) const
25 {
26  pass=false;
27  if( !input.roi ) return false;
28  if( input.photons.empty() ) return false;
29 
30  for ( const auto& ph : input.photons )
31  {
32  if( decide( input, ph ) ){
33  pass=true;
34  return true;
35  }
36  }
37 
38  return true;
39 
40 }
41 
43 
45  const xAOD::Photon *ph
46  ) const
47 
48 {
49 
50  const TrigRoiDescriptor *roi = input.roi;
51  unsigned PassedCuts=0;
52 
53 
54  // when leaving scope it will ship data to monTool
55  PassedCuts = PassedCuts + 1; //got called (data in place)
56 
57  if ( std::abs( roi->eta() ) > 2.6 ) {
58  ATH_MSG_DEBUG( "REJECT The photon had eta coordinates beyond the EM fiducial volume : "
59  << roi->eta() << "; stop the chain now" );
60  return false;
61  }
62 
63  ATH_MSG_DEBUG( "; RoI ID = " << roi->roiId() << ": Eta = " << roi->eta() << ", Phi = " << roi->phi() );
64 
65  // fill local variables for RoI reference position
66  double etaRef = roi->eta();
67  double phiRef = roi->phi();
68  // correct phi the to right range ( probably not needed anymore )
69  if ( std::abs( phiRef ) > M_PI ) phiRef -= 2*M_PI; // correct phi if outside range
70 
71  auto pClus = ph->caloCluster();
72 
73  if(!pClus){
74  ATH_MSG_DEBUG("No calo cluster for this photon");
75  return false;
76  }
77 
78 
79  float absEta = std::abs( pClus->eta() );
80  const int cutIndex = findCutIndex( absEta );
81 
82 
83 
84  float dEta = pClus->eta() - etaRef;
85  // Deal with angle diferences greater than Pi
86  float dPhi = std::abs( pClus->phi() - phiRef );
87  dPhi = ( dPhi < M_PI ? dPhi : 2*M_PI - dPhi ); // TB why only <
88  float ET = pClus->et();
89 
90 
91  // eta range
92  if ( absEta > 2.47) { // VD
93  ATH_MSG_DEBUG( "Photon : " << absEta << " outside eta range " );
94  return false;
95  }
96  PassedCuts = PassedCuts + 1; // passed eta cut
97 
98  // eta range
99  if ( cutIndex == -1 ) { // VD
100  ATH_MSG_DEBUG( "Photon : " << absEta << " outside eta range " << m_etabin[m_etabin.size()-1] );
101  return false;
102  } else {
103  ATH_MSG_DEBUG( "eta bin used for cuts " << cutIndex );
104  }
105  PassedCuts = PassedCuts + 1; // passed eta cut
106 
107  // ET_em
108  ATH_MSG_DEBUG( "Photon: ET_em=" << ET << " cut: >" << m_eTthr[cutIndex] );
109  if ( ET < m_eTthr[cutIndex] ) {
110  ATH_MSG_DEBUG("REJECT et cut failed");
111  return false;
112  }
113  PassedCuts = PassedCuts + 1; // ET_em
114 
115 
116 
117 
118  // apply cuts: DeltaEta( clus-ROI )
119  ATH_MSG_DEBUG( "Photon : eta=" << pClus->eta() << " roi eta=" << etaRef << " DeltaEta=" << dEta
120  << " cut: <" << m_detacluster );
121 
122  if ( std::abs( pClus->eta() - etaRef ) > m_detacluster ) {
123  ATH_MSG_DEBUG("REJECT Photon a cut failed");
124  return false;
125  }
126  PassedCuts = PassedCuts + 1; //Deta
127 
128  // DeltaPhi( clus-ROI )
129  ATH_MSG_DEBUG( ": phi=" << pClus->phi() << " roi phi="<< phiRef << " DeltaPhi="<< dPhi
130  << " cut: <" << m_dphicluster );
131 
132  if( dPhi > m_dphicluster ) {
133  ATH_MSG_DEBUG("REJECT Clsuter dPhi cut failed");
134  return false;
135  }
136  PassedCuts = PassedCuts + 1; //DPhi
137 
138 
139  // Apply phootn offline like selection
140  bool pass = input.isPassed(ph, m_pidName);
141 
142 
143 
144  float Rhad1(0), Rhad(0), Reta(0), Rphi(0), e277(0), weta2c(0), //emax2(0),
145  Eratio(0), DeltaE(0), f1(0), weta1c(0), wtot(0), fracm(0);
146  float ptcone20(999), ptcone30(999), ptcone40(999), etcone20(999), etcone30(999), etcone40(999), topoetcone20(999), topoetcone30(999), topoetcone40(999), reletcone20(999);
147 
148 
149  // variables based on HCAL
150  // transverse energy in 1st scintillator of hadronic calorimeter/ET
152  // transverse energy in hadronic calorimeter/ET
154 
155  // variables based on S2 of EM CAL
156  // E(7*7) in 2nd sampling
158  // E(3*7)/E(7*7) in 2nd sampling
160  // E(3*3)/E(3*7) in 2nd sampling
162  // shower width in 2nd sampling
164 
165  // variables based on S1 of EM CAL
166  // fraction of energy reconstructed in the 1st sampling
168  // shower width in 3 strips in 1st sampling
170  // E of 2nd max between max and min in strips [NOT USED]
171  // eg->showerShapeValue(emax2, xAOD::EgammaParameters::e2tsts1);
172  // (E of 1st max in strips-E of 2nd max)/(E of 1st max+E of 2nd max)
174  // E(2nd max)-E(min) in strips
176  // total shower width in 1st sampling
178  // E(+/-3)-E(+/-1)/E(+/-1)
180 
182 
184 
186 
188 
190 
192 
194 
196 
198 
199  ATH_MSG_DEBUG( " Rhad1 " << Rhad1 ) ;
200  ATH_MSG_DEBUG( " Rhad " << Rhad ) ;
201  ATH_MSG_DEBUG( " e277 " << e277 ) ;
202  ATH_MSG_DEBUG( " Reta " << Reta ) ;
203  ATH_MSG_DEBUG( " Rphi " << Rphi ) ;
204  ATH_MSG_DEBUG( " weta2c " << weta2c ) ;
205  ATH_MSG_DEBUG( " f1 " << f1 ) ;
206  ATH_MSG_DEBUG( " weta1c " << weta1c ) ;
207  ATH_MSG_DEBUG( " Eratio " << Eratio ) ;
208  ATH_MSG_DEBUG( " DeltaE " << DeltaE ) ;
209  ATH_MSG_DEBUG( " wtot " << wtot ) ;
210  ATH_MSG_DEBUG( " fracm " << fracm ) ;
211  ATH_MSG_DEBUG( " ptcone20 " << ptcone20 ) ;
212  ATH_MSG_DEBUG( " ptcone30 " << ptcone30 ) ;
213  ATH_MSG_DEBUG( " ptcone40 " << ptcone40 ) ;
214  ATH_MSG_DEBUG( " etcone20 " << etcone20 ) ;
215  ATH_MSG_DEBUG( " etcone30 " << etcone30 ) ;
216  ATH_MSG_DEBUG( " etcone40 " << etcone40 ) ;
217  ATH_MSG_DEBUG( " topoetcone20 " << topoetcone20 ) ;
218  ATH_MSG_DEBUG( " topoetcone30 " << topoetcone30 ) ;
219  ATH_MSG_DEBUG( " topoetcone40 " << topoetcone40 ) ;
220  // Monitor showershapes
221  reletcone20 = etcone20/ph->caloCluster()->et();
222  ATH_MSG_DEBUG("reletcone20 = " <<reletcone20 );
223  ATH_MSG_DEBUG("m_RelEtConeCut = " << m_RelTopoEtConeCut );
224 
225 
226  // Decode isEM bits of result to see which bits passed and which bits fialed
227  if ( !pass ){
228  ATH_MSG_DEBUG("REJECT isEM failed");
229  return false;
230  } else {
231  ATH_MSG_DEBUG("ACCEPT isEM passed");
232  }
233 
234 
235  // Check if need to apply isolation
236  // First check logic. if cut is very negative, then no isolation cut is defined
237  // if m_RelEtConeCut <-100 then hypo is configured not to apply isolation
238  if (m_RelTopoEtConeCut < -100){
239  ATH_MSG_DEBUG(" not applying isolation. Returning NOW");
240  ATH_MSG_DEBUG("TAccept = " << pass);
241  return true;
242  }
243  // Then, It will pass if reletcone20 is less than cut:
244  pass = (reletcone20 < m_RelTopoEtConeCut);
245  //
246  // Reach this point successfully
247  ATH_MSG_DEBUG( "pass = " << pass );
248 
249  return pass;
250 
251 }
252 
254 
256  const float absEta = std::abs(eta);
257  auto binIterator = std::adjacent_find( m_etabin.begin(), m_etabin.end(), [=](float left, float right){ return left < absEta and absEta < right; } );
258  if ( binIterator == m_etabin.end() ) {
259  return -1;
260  }
261  return binIterator - m_etabin.begin();
262 }
xAOD::Iso::topoetcone20
@ topoetcone20
Topo-cluster ET-sum.
Definition: IsolationType.h:48
TrigEgammaEmulationPrecisionPhotonHypoTool.h
xAOD::EgammaParameters::Reta
@ Reta
e237/e277
Definition: EgammaEnums.h:154
Trig
The common trigger namespace for trigger analysis tools.
Definition: CaloTowerVecMon.h:44
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
xAOD::Egamma_v1::isolationValue
bool isolationValue(float &value, const Iso::IsolationType information) const
old Accessor for Isolation values.
Definition: Egamma_v1.h:257
xAOD::Iso::ptcone30
@ ptcone30
Definition: IsolationType.h:41
Trig::TrigEgammaEmulationPrecisionPhotonHypoTool::emulate
virtual bool emulate(const TrigData &input, bool &pass) const override
==========================================================================
Definition: TrigEgammaEmulationPrecisionPhotonHypoTool.cxx:23
M_PI
#define M_PI
Definition: ActiveFraction.h:11
xAOD::Iso::ptcone20
@ ptcone20
Track isolation.
Definition: IsolationType.h:40
xAOD::Iso::etcone40
@ etcone40
Definition: IsolationType.h:34
xAOD::CaloCluster_v1::et
double et() const
Definition: CaloCluster_v1.h:856
xAOD::Iso::topoetcone30
@ topoetcone30
Definition: IsolationType.h:49
TrigRoiDescriptor
nope - should be used for standalone also, perhaps need to protect the class def bits #ifndef XAOD_AN...
Definition: TrigRoiDescriptor.h:56
xAOD::Iso::etcone30
@ etcone30
Definition: IsolationType.h:33
xAOD::EgammaParameters::Rphi
@ Rphi
e233/e237
Definition: EgammaEnums.h:156
Trig::TrigEgammaEmulationPrecisionPhotonHypoTool::m_detacluster
Gaudi::Property< float > m_detacluster
Definition: TrigEgammaEmulationPrecisionPhotonHypoTool.h:42
xAOD::EgammaParameters::wtots1
@ wtots1
shower width is determined in a window detaxdphi = 0,0625 ×~0,2, corresponding typically to 20 strips...
Definition: EgammaEnums.h:140
xAOD::Egamma_v1::showerShapeValue
bool showerShapeValue(float &value, const EgammaParameters::ShowerShapeType information) const
Accessor for ShowerShape values.
Definition: Egamma_v1.cxx:207
Trig::TrigEgammaEmulationBaseHypoTool
Definition: TrigEgammaEmulationBaseHypoTool.h:22
Trig::TrigEgammaEmulationPrecisionPhotonHypoTool::TrigEgammaEmulationPrecisionPhotonHypoTool
TrigEgammaEmulationPrecisionPhotonHypoTool(const std::string &myname)
Definition: TrigEgammaEmulationPrecisionPhotonHypoTool.cxx:9
Trig::TrigEgammaEmulationPrecisionPhotonHypoTool::m_eTthr
Gaudi::Property< std::vector< float > > m_eTthr
Definition: TrigEgammaEmulationPrecisionPhotonHypoTool.h:46
Trig::TrigEgammaEmulationPrecisionPhotonHypoTool::m_RelTopoEtConeCut
Gaudi::Property< float > m_RelTopoEtConeCut
Definition: TrigEgammaEmulationPrecisionPhotonHypoTool.h:44
xAOD::EgammaParameters::f1
@ f1
E1/E = fraction of energy reconstructed in the first sampling, where E1 is energy in all strips belon...
Definition: EgammaEnums.h:52
Trig::TrigEgammaEmulationBaseHypoTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: TrigEgammaEmulationBaseHypoTool.cxx:17
xAOD::Iso::etcone20
@ etcone20
Calorimeter isolation.
Definition: IsolationType.h:32
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:530
Trig::TrigEgammaEmulationPrecisionPhotonHypoTool::initialize
virtual StatusCode initialize() override
==========================================================================
Definition: TrigEgammaEmulationPrecisionPhotonHypoTool.cxx:15
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
xAOD::Egamma_v1::caloCluster
const xAOD::CaloCluster * caloCluster(size_t index=0) const
Pointer to the xAOD::CaloCluster/s that define the electron candidate.
Definition: Egamma_v1.cxx:388
Trig::TrigEgammaEmulationPrecisionPhotonHypoTool::m_etabin
Gaudi::Property< std::vector< float > > m_etabin
Definition: TrigEgammaEmulationPrecisionPhotonHypoTool.h:45
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Trig::TrigEgammaEmulationPrecisionPhotonHypoTool::findCutIndex
int findCutIndex(float eta) const
==========================================================================
Definition: TrigEgammaEmulationPrecisionPhotonHypoTool.cxx:255
xAOD::EgammaParameters::Rhad1
@ Rhad1
ethad1/et
Definition: EgammaEnums.h:162
TrigRoiDescriptor::roiId
virtual unsigned int roiId() const override final
these quantities probably don't need to be used any more
Definition: TrigRoiDescriptor.h:133
xAOD::Iso::ptcone40
@ ptcone40
Definition: IsolationType.h:42
xAOD::Photon_v1
Definition: Photon_v1.h:37
RoiDescriptor::phi
virtual double phi() const override final
Methods to retrieve data members.
Definition: RoiDescriptor.h:100
Trig::TrigEgammaEmulationPrecisionPhotonHypoTool::m_dphicluster
Gaudi::Property< float > m_dphicluster
Definition: TrigEgammaEmulationPrecisionPhotonHypoTool.h:43
Trig::TrigData
Definition: TrigEgammaEmulationToolMT.h:40
TauGNNUtils::Variables::absEta
bool absEta(const xAOD::TauJet &tau, double &out)
Definition: TauGNNUtils.cxx:232
Trig::TrigEgammaEmulationPrecisionPhotonHypoTool::decide
bool decide(const TrigData &input, const xAOD::Photon *ph) const
==========================================================================
Definition: TrigEgammaEmulationPrecisionPhotonHypoTool.cxx:44
RoiDescriptor::eta
virtual double eta() const override final
Definition: RoiDescriptor.h:101
xAOD::EgammaParameters::e277
@ e277
uncalibrated energy (sum of cells) of the middle sampling in a rectangle of size 7x7
Definition: EgammaEnums.h:80
xAOD::EgammaParameters::weta1
@ weta1
shower width using +/-3 strips around the one with the maximal energy deposit: w3 strips = sqrt{sum(E...
Definition: EgammaEnums.h:97
xAOD::EgammaParameters::Eratio
@ Eratio
(emaxs1-e2tsts1)/(emaxs1+e2tsts1)
Definition: EgammaEnums.h:158
xAOD::Iso::topoetcone40
@ topoetcone40
Definition: IsolationType.h:50
xAOD::EgammaParameters::Rhad
@ Rhad
ethad/et
Definition: EgammaEnums.h:160
TauGNNUtils::Variables::Track::dEta
bool dEta(const xAOD::TauJet &tau, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:525
xAOD::EgammaParameters::DeltaE
@ DeltaE
e2tsts1-emins1
Definition: EgammaEnums.h:164
Trig::TrigEgammaEmulationPrecisionPhotonHypoTool::m_pidName
Gaudi::Property< std::string > m_pidName
Definition: TrigEgammaEmulationPrecisionPhotonHypoTool.h:41
xAOD::EgammaParameters::fracs1
@ fracs1
shower shape in the shower core : [E(+/-3)-E(+/-1)]/E(+/-1), where E(+/-n) is the energy in ± n strip...
Definition: EgammaEnums.h:111
read_hist_ntuple.f1
f1
Definition: read_hist_ntuple.py:4
xAOD::EgammaParameters::weta2
@ weta2
the lateral width is calculated with a window of 3x5 cells using the energy weighted sum over all cel...
Definition: EgammaEnums.h:103