ATLAS Offline Software
TrigPhoton.cxx
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 
27 #include "CaloGeoHelpers/CaloSampling.h"
29 
32  P4PtEtaPhiM(0, 0, 0, 0),
34  m_roiID(-1),
35  m_HadEt(0),
36  m_energyRatio(0),
37  m_rCore(0),
38  m_dPhi(0),
39  m_dEta(0),
40  // m_cl_energy(0),
41  m_cl_e_frac_S0(0),
42  m_cl_e_frac_S1(0),
43  m_cl_e_frac_S2(0),
44  m_cl_e_frac_S3(0),
45  m_Fside(0),
46  m_Weta2(0),
47  m_valid(false)
48 
49 {
50  m_cluster.reset();
51 }
52 
61 TrigPhoton::TrigPhoton(int roi, float dphi, float deta,
62  const TrigEMClusterContainer* cluster_cont,
63  unsigned int cluster_index ) :
64  P4PtEtaPhiM(0, 0, 0, 0),
66  m_roiID(roi),
67  m_HadEt(0),
68  m_energyRatio(0),
69  m_rCore(0),
70  m_dPhi(dphi),
71  m_dEta(deta),
72  m_cl_e_frac_S0(0),
73  m_cl_e_frac_S1(0),
74  m_cl_e_frac_S2(0),
75  m_cl_e_frac_S3(0),
76  m_Fside(0),
77  m_Weta2(0),
78  m_valid(true)
79 {
80 
88  if (cluster_cont != NULL && cluster_cont->size() > cluster_index) {
89 
95  m_cluster.toIndexedElement(*cluster_cont, cluster_index);
96 
97 
99  const TrigEMCluster* cl_ptr = (*cluster_cont)[cluster_index];
100 
101 
103  this->setPt(cl_ptr->et());
104  this->setEta(cl_ptr->eta());
105  this->setPhi(cl_ptr->phi());
106 
109  // EThad
110  if (cl_ptr->eta() != 0) {
111  m_HadEt = cl_ptr->ehad1()/cosh(fabs(cl_ptr->eta())); // Ehad1/cosh(fabs(eta)
112  } else {
113  m_HadEt = cl_ptr->ehad1(); // Ehad1 (=EThad1)
114  }
115 
116  // Rcore (test for positive energy to avoid zeros)
117  if (cl_ptr->e277() != 0) { // (VD) before it was '>'
118  m_rCore = cl_ptr->e237()/cl_ptr->e277();
119  } else {
120  m_rCore = 0;
121  m_valid = false;
122  }
123 
124  // Eratio (test for positive energy to avoid zeros)
125  if (cl_ptr->emaxs1()+cl_ptr->e2tsts1() > 0) {
126  m_energyRatio = (cl_ptr->emaxs1()-cl_ptr->e2tsts1()) / (cl_ptr->emaxs1()+cl_ptr->e2tsts1());
127  } else {
128  m_energyRatio = 0;
129  m_valid = false;
130  }
131 
132  // energy and energy fraction per sample
133  float tmp_cl_energy = cl_ptr->energy();
134  if (fabs(tmp_cl_energy) > 0.00001) { // avoid floating-point exceptions
135  m_cl_e_frac_S0 = ( cl_ptr->energy(CaloSampling::PreSamplerB) + cl_ptr->energy(CaloSampling::PreSamplerE)) / tmp_cl_energy;
136  m_cl_e_frac_S1 = ( cl_ptr->energy(CaloSampling::EMB1) + cl_ptr->energy(CaloSampling::EME1)) / tmp_cl_energy;
137  m_cl_e_frac_S2 = ( cl_ptr->energy(CaloSampling::EMB2) + cl_ptr->energy(CaloSampling::EME2)) / tmp_cl_energy;
138  m_cl_e_frac_S3 = ( cl_ptr->energy(CaloSampling::EMB3) + cl_ptr->energy(CaloSampling::EME3)) / tmp_cl_energy;
139  m_Fside = cl_ptr->fracs1();
140  m_Weta2 = cl_ptr->weta2();
141  }
142  }
143  else {
144  m_cluster.reset();
145  m_valid = false;
146  // m_cl_energy = 0;
147  m_cl_e_frac_S0 = 0;
148  m_cl_e_frac_S1 = 0;
149  m_cl_e_frac_S2 = 0;
150  m_cl_e_frac_S3 = 0;
151  }
152 
153 
155  if (!m_cluster.isValid()) {
156  m_cluster.reset();
157  m_valid = false;
158  }
159 
160 }
161 
162 
165  float eta,
166  float phi,
167 
168  // roi word
169  unsigned int roi,
170  bool valid,
171 
172  // Cluster
174  float HadEt,
175  float energyRatio,
176  float rCore,
177  float deta,
178  float dphi,
179  float Fside,
180  float Weta2,
181  float F0,
182  float F1,
183  float F2,
184  float F3)
185  : P4PtEtaPhiM(pt, eta, phi, 0),
186  m_roiID(roi),
187  m_HadEt(HadEt),
188  m_energyRatio(energyRatio),
189  m_rCore(rCore),
190  m_dPhi(dphi),
191  m_dEta(deta),
192  m_cl_e_frac_S0(F0),
193  m_cl_e_frac_S1(F1),
194  m_cl_e_frac_S2(F2),
195  m_cl_e_frac_S3(F3),
196  m_Fside(Fside),
197  m_Weta2(Weta2),
198  m_valid(valid),
199  m_cluster(cluster)
200 {
201 }
202 
205  I4Momentum(tp),
207  INavigable(tp),
210  P4PtEtaPhiM(tp),
212 {
213  m_roiID = tp.m_roiID;
214  m_HadEt = tp.m_HadEt;
215  m_energyRatio = tp.m_energyRatio;
216  m_rCore = tp.m_rCore;
217  m_dPhi = tp.m_dPhi;
218  m_dEta = tp.m_dEta;
219  // m_cl_energy = tp.m_cl_energy;
220  m_cl_e_frac_S0 = tp.m_cl_e_frac_S0;
221  m_cl_e_frac_S1 = tp.m_cl_e_frac_S1;
222  m_cl_e_frac_S2 = tp.m_cl_e_frac_S2;
223  m_cl_e_frac_S3 = tp.m_cl_e_frac_S3;
224  m_Fside = tp.m_Fside;
225  m_Weta2 = tp.m_Weta2;
226  m_valid = tp.m_valid;
227 
228  //set ElementLink to cluster
229  if( m_cluster.isValid() ){
230  m_cluster.toIndexedElement( tp.m_cluster.getStorableObjectRef(), tp.m_cluster.index() );
231  }
232  else {
233  m_cluster.reset();
234  }
235 }
236 
238 {
239  if( m_cluster.isValid() ){
240  return (*m_cluster);
241  }
242  else{
243  return NULL;
244  }
245 }
246 
247 
248 // comparison operators
250 bool operator==( const TrigPhoton& tp1, const TrigPhoton& tp2 ) {
251  return ( tp1.isValid() && tp2.isValid() && tp1.cluster() == tp2.cluster());
252 }
253 
254 
260 void diff( const TrigPhoton& tp1, const TrigPhoton& tp2, std::map< std::string, double >& v_diff ) {
261 
262  v_diff["RoIword"] = tp1.roiId() - tp2.roiId();
263  v_diff["Et"] = 0;
264  if(fabs(tp1.Et())+fabs(tp2.Et()) !=0)
265  v_diff["Et"] = 2 * fabs( ( fabs(tp1.Et()) - fabs(tp2.Et() )) / ( fabs(tp1.Et())+fabs(tp2.Et()) ) );
266  v_diff["HadEt1"] = 0;
267  if(fabs(tp1.HadEt1())+fabs(tp2.HadEt1()) !=0)
268  v_diff["HadEt1"] = 2 * fabs( ( fabs(tp1.HadEt1()) - fabs(tp2.HadEt1() )) / ( fabs(tp1.HadEt1())+fabs(tp2.HadEt1()) ) );
269  v_diff["Eratio"] = fabs(tp1.Eratio() - tp2.Eratio());
270  v_diff["rCore"] = fabs(tp1.Reta() - tp2.Reta());
271  v_diff["Eta"] = fabs( tp1.eta() - tp2.eta() );
272  double d_phi = fabs( tp1.phi() - tp2.phi() );
273  v_diff["Phi"] = (d_phi < M_PI ? d_phi : 2*M_PI - d_phi);
274  // v_diff["E"] = fabs(tp1.E() - tp2.E());
275  v_diff["F0"] = fabs(tp1.F0() - tp2.F0());
276  v_diff["F1"] = fabs(tp1.F1() - tp2.F1());
277  v_diff["F2"] = fabs(tp1.F2() - tp2.F2());
278  v_diff["F3"] = fabs(tp1.F3() - tp2.F3());
279  return;
280 }
281 
282 
284 MsgStream& operator<< ( MsgStream& msg, const TrigPhoton& tp ) {
285  return ( msg << "TrigPhoton " << (tp.isValid() ? "(valid)" : "(not valid)")
286  << ": RoI = " << tp.roiWord()
287  << "; Et = " << tp.Et()
288  << "; eta = " << tp.eta()
289  << "; phi = " << tp.phi()
290  << "; Delta_eta = " << tp.dEta() << "; Delta_phi = " << tp.dPhi()
291  << "; Eratio = " << tp.Eratio() << "; Rcore = " << tp.Reta()
292  // << "; E = "<<tp.E()
293  <<"; F0 = "<<tp.F0()<<"; F1 = "<<tp.F1()<<"; F2 = "<<tp.F2()<<"; F3 = "<<tp.F3() );
294 }
I4Momentum
Definition: I4Momentum.h:31
TrigPhoton::m_cl_e_frac_S0
float m_cl_e_frac_S0
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:150
TrigPhoton::m_cl_e_frac_S2
float m_cl_e_frac_S2
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:152
TrigPhoton.h
constants.EMB1
int EMB1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:53
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
TrigPhoton::Et
float Et() const
accessor EM cluster et
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:100
TrigPhoton::F0
float F0() const
accessors for calibrated energy and energy fraction in calo samples
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:129
TrigPhoton::m_Weta2
float m_Weta2
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:155
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
TrigEMCluster::e2tsts1
float e2tsts1() const
get second maximum energy in sampling 1 (strip layer)
Definition: Trigger/TrigEvent/TrigCaloEvent/TrigCaloEvent/TrigEMCluster.h:133
TrigPhoton::roiId
int roiId() const
accessor to get RoI ID (should also introduce roiWord
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:96
TrigPhoton::m_dPhi
float m_dPhi
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:147
TrigEMCluster::phi
float phi() const
get Phi (calibrated)
Definition: Trigger/TrigEvent/TrigCaloEvent/TrigCaloEvent/TrigEMCluster.h:116
test_pyathena.pt
pt
Definition: test_pyathena.py:11
TrigPhoton::m_energyRatio
float m_energyRatio
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:145
NavigableTerminalNode
Dummy type needed fro specialized implementation.
Definition: NavigableTerminalNode.h:19
M_PI
#define M_PI
Definition: ActiveFraction.h:11
ParticleTest.tp
tp
Definition: ParticleTest.py:25
TrigPhoton::m_roiID
int m_roiID
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:143
TrigEMCluster
Class with calibrated variables for egamma clustering.
Definition: Trigger/TrigEvent/TrigCaloEvent/TrigCaloEvent/TrigEMCluster.h:31
TrigPhoton::m_cl_e_frac_S3
float m_cl_e_frac_S3
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:153
TrigEMClusterContainer
Container from TrigEMCluster type objects.
Definition: Trigger/TrigEvent/TrigCaloEvent/TrigCaloEvent/TrigEMClusterContainer.h:32
TrigPhoton::m_cluster
ElementLink< TrigEMClusterContainer > m_cluster
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:158
TrigEMCluster::e277
float e277() const
get Energy in a 7x7 cluster (no calibration) around hottest cell
Definition: Trigger/TrigEvent/TrigCaloEvent/TrigCaloEvent/TrigEMCluster.h:120
TrigEMCluster::weta2
float weta2() const
get cluster width (based on a 3x5 cluster - 2nd layer)
Definition: Trigger/TrigEvent/TrigCaloEvent/TrigCaloEvent/TrigEMCluster.h:125
TrigEMCluster::fracs1
float fracs1() const
get Energy in a 7 strips (around hottest strip) minus energy in 3 strips divided by energy in 3 strip...
Definition: Trigger/TrigEvent/TrigCaloEvent/TrigCaloEvent/TrigEMCluster.h:123
calibdata.valid
list valid
Definition: calibdata.py:45
P4PtEtaPhiM::phi
virtual double phi() const
get phi data member
Definition: P4PtEtaPhiM.h:109
TrigPhoton::F1
float F1() const
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:130
P4PtEtaPhiM::setPt
virtual void setPt(double thePt)
set pt data member
Definition: P4PtEtaPhiM.h:115
TrigEMCluster::e237
float e237() const
get Energy in a 3x7 cluster (no calibration) around hottest cell
Definition: Trigger/TrigEvent/TrigCaloEvent/TrigCaloEvent/TrigEMCluster.h:118
operator==
bool operator==(const TrigPhoton &tp1, const TrigPhoton &tp2)
Two TrigPhoton are the same if they have the same cluster (and if valid)
Definition: TrigPhoton.cxx:250
constants.EMB2
int EMB2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:54
TrigPhoton::m_dEta
float m_dEta
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:148
TrigPhoton::Eratio
float Eratio() const
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:108
TrigPhoton::F2
float F2() const
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:131
P4PtEtaPhiM::setPhi
virtual void setPhi(double thePhi)
set phi data member
Definition: P4PtEtaPhiM.h:121
TrigPhoton::m_cl_e_frac_S1
float m_cl_e_frac_S1
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:151
TrigPhoton::m_Fside
float m_Fside
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:154
TrigPhoton::m_rCore
float m_rCore
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:146
constants.EME1
int EME1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:55
INavigable
Definition: INavigable.h:18
P4PtEtaPhiM::setEta
virtual void setEta(double theEta)
set eta data member
Definition: P4PtEtaPhiM.h:118
IAthenaBarCode
Definition: AthenaKernel/AthenaKernel/IAthenaBarCode.h:48
TrigEMCluster::eta
float eta() const
get Eta (calibrated)
Definition: Trigger/TrigEvent/TrigCaloEvent/TrigCaloEvent/TrigEMCluster.h:114
TrigPhoton::m_HadEt
float m_HadEt
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:144
TrigPhoton::TrigPhoton
TrigPhoton()
constructors; note: default constructor needed by POOL
Definition: TrigPhoton.cxx:31
TrigPhoton::F3
float F3() const
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:132
TrigEMCluster::ehad1
float ehad1() const
get hadronic Energy (first hadronic layer)
Definition: Trigger/TrigEvent/TrigCaloEvent/TrigCaloEvent/TrigEMCluster.h:127
TrigEMCluster::energy
float energy() const
get Energy (calibrated)
Definition: Trigger/TrigEvent/TrigCaloEvent/TrigCaloEvent/TrigEMCluster.h:102
P4PtEtaPhiMBase
Definition: P4PtEtaPhiMBase.h:26
CaloCell_ID_FCS::EME3
@ EME3
Definition: FastCaloSim_CaloCell_ID.h:26
TrigPhoton::HadEt1
float HadEt1() const
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:104
P4PtEtaPhiM::eta
virtual double eta() const
get eta data member
Definition: P4PtEtaPhiM.h:106
diff
void diff(const TrigPhoton &tp1, const TrigPhoton &tp2, std::map< std::string, double > &v_diff)
Function compares two objects and returns "semi verbose" output in the form of map v_diff where varai...
Definition: TrigPhoton.cxx:260
TrigPhoton::cluster
const TrigEMCluster * cluster() const
other accessors for shower shapes
Definition: TrigPhoton.cxx:237
operator<<
MsgStream & operator<<(MsgStream &msg, const TrigPhoton &tp)
print TrigPhoton quantities
Definition: TrigPhoton.cxx:284
TrigPhoton::m_valid
bool m_valid
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:156
TrigPhoton::isValid
bool isValid() const
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:93
TrigEMCluster::emaxs1
float emaxs1() const
get maximum energy in sampling 1 (strip layer)
Definition: Trigger/TrigEvent/TrigCaloEvent/TrigCaloEvent/TrigEMCluster.h:131
CaloCell_ID_FCS::PreSamplerE
@ PreSamplerE
Definition: FastCaloSim_CaloCell_ID.h:23
CaloCell_ID_FCS::PreSamplerB
@ PreSamplerB
Definition: FastCaloSim_CaloCell_ID.h:19
INavigable4Momentum
Definition: INavigable4Momentum.h:21
P4PtEtaPhiM
Definition: P4PtEtaPhiM.h:25
TrigPhoton
File: TrigPhoton.h.
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:44
CaloCell_ID_FCS::EMB3
@ EMB3
Definition: FastCaloSim_CaloCell_ID.h:22
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56
TrigPhoton::Reta
float Reta() const
Definition: Trigger/TrigEvent/TrigParticle/TrigParticle/TrigPhoton.h:112
TrigEMCluster::et
float et() const
get Et (calibrated)
Definition: Trigger/TrigEvent/TrigCaloEvent/TrigCaloEvent/TrigEMCluster.h:106