ATLAS Offline Software
Loading...
Searching...
No Matches
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
26
27#include "CaloGeoHelpers/CaloSampling.h"
29
32 P4PtEtaPhiM(0, 0, 0, 0),
34 m_roiID(-1),
35 m_HadEt(0),
37 m_rCore(0),
38 m_dPhi(0),
39 m_dEta(0),
40 // m_cl_energy(0),
45 m_Fside(0),
46 m_Weta2(0),
47 m_valid(false)
48
49{
50 m_cluster.reset();
51}
52
61TrigPhoton::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),
76 m_Fside(0),
77 m_Weta2(0),
78 m_valid(true)
79{
80
87
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
108
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),
189 m_rCore(rCore),
190 m_dPhi(dphi),
191 m_dEta(deta),
196 m_Fside(Fside),
197 m_Weta2(Weta2),
198 m_valid(valid),
200{
201}
202
205 I4Momentum(tp),
206 P4PtEtaPhiMBase(tp),
207 INavigable(tp),
208 IAthenaBarCode(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
250bool operator==( const TrigPhoton& tp1, const TrigPhoton& tp2 ) {
251 return ( tp1.isValid() && tp2.isValid() && tp1.cluster() == tp2.cluster());
252}
253
254
260void 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
284MsgStream& 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}
#define M_PI
if(febId1==febId2)
MsgStream & operator<<(MsgStream &msg, const TrigPhoton &tp)
print TrigPhoton quantities
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...
bool operator==(const TrigPhoton &tp1, const TrigPhoton &tp2)
Two TrigPhoton are the same if they have the same cluster (and if valid)
size_type size() const noexcept
Returns the number of elements in the collection.
I4Momentum is an abstract base class providing 4-momentum behavior.
Definition I4Momentum.h:31
P4PtEtaPhiMBase is a base class for classes with 4-momentum behavior, for which pt,...
P4PtEtaPhiM(const double pt, const double eta, const double phi, const double m)
constructor with all data members
Definition P4PtEtaPhiM.h:29
virtual double pt() const
get pt data member
virtual double eta() const
get eta data member
virtual double phi() const
get phi data member
Class with calibrated variables for egamma clustering.
float HadEt() const
accessor for hadronic energy in 1st hadronic sampling behind cluster
float Fside() const
energy in a 7 strips (around hottest strip) minus energy in 3 strips divided by energy in 3 strips
float rCore() const
cluster energy in 3x7 cells / energy in 7x7 cells in 2nd sampling
float F0() const
accessors for calibrated energy and energy fraction in calo samples
int roiId() const
accessor to get RoI ID (should also introduce roiWord
float energyRatio() const
accessor for fraction difference of EM cluster emaxs1 and e2tsts1
TrigPhoton()
constructors; note: default constructor needed by POOL
float Weta2() const
cluster width (based on a 3x5 cluster - 2nd layer)
ElementLink< TrigEMClusterContainer > m_cluster
const TrigEMCluster * cluster() const
other accessors for shower shapes
MsgStream & msg
Definition testRead.cxx:32