70 std::string dataType(
"");
75 std::string simType(
"");
88 TFile *
file = TFile::Open(filepath.c_str(),
"READ");
90 if (
file ==
nullptr) {
91 ATH_MSG_WARNING(
"Couldn't find file for z-correction: " << filepath.c_str());
93 return StatusCode::FAILURE;
97 file->GetObject(
"dz_trk_pointing_vs_etas2", temp);
99 if (temp ==
nullptr) {
100 ATH_MSG_WARNING(
"Couldn't find 'dz_trk_pointing_vs_etas2' histogram in file: " << filepath.c_str());
102 return StatusCode::FAILURE;
105 bool status = TH1::AddDirectoryStatus();
106 TH1::AddDirectory(
false);
107 m_zCorrection =
dynamic_cast<TH1F*
>(temp->Clone(
"zCorrection"));
109 TH1::AddDirectory(status);
111 return StatusCode::SUCCESS;
117 const EventContext& ctx = Gaudi::Hive::currentContext();
128 std::pair<float, float>
result;
129 for (
const auto *
egamma: egammas) {
138 if(isDecorAvailable){
139 ATH_MSG_DEBUG(
"Called updatePointingAuxdata but decoration is already available");
156 if(!isDecorAvailable){
163 return StatusCode::SUCCESS;
169 if (fabs(etas2) < 1.37)
return zPointing;
178 return std::make_pair(0,0);
184 ATH_MSG_WARNING(
"Couldn't retrieve EventInfo from TEvent, egamma won't be decorated.");
185 return std::make_pair(0, 0);
189 double d_beamSpot = hypot(eventInfo->beamPosY(), eventInfo->beamPosX());
190 double phi_beamSpot = atan2(eventInfo->beamPosY(), eventInfo->beamPosX());
194 if (cluster ==
nullptr) {
195 ATH_MSG_WARNING(
"Couldn't retrieve CaloCluster from Photon, egammas won't be decorated.");
196 return std::make_pair(0, 0);
199 float cl_e = cluster->
e();
200 float etas1 = cluster->
etaBE(1);
201 float etas2 = cluster->
etaBE(2);
202 float phis2 = cluster->
phiBE(2);
203 float cl_theta = 2.0*atan(exp(-1.0*cluster->
eta()));
210 double r0_with_beamSpot = d_beamSpot*cos(phis2 - phi_beamSpot);
212 float s_zvertex = 0, s_errz = 0;
213 s_zvertex = (RZ1.second * (RZ2.first - r0_with_beamSpot) -
214 RZ2.second * (RZ1.first - r0_with_beamSpot)) /
215 (RZ2.first - RZ1.first);
218 s_errz = 0.5 * (RZ2.first + RZ1.first) * (0.060 / sqrt(cl_e * 0.001)) /
219 (sin(cl_theta) * sin(cl_theta));
221 return std::make_pair(s_zvertex, s_errz);
229 return std::make_pair(0,0);
235 ATH_MSG_WARNING(
"Couldn't retrieve EventInfo from TEvent, photons won't be decorated.");
236 return std::make_pair(0, 0);
240 double d_beamSpot = hypot(eventInfo->beamPosY(), eventInfo->beamPosX());
241 double phi_beamSpot = atan2(eventInfo->beamPosY(), eventInfo->beamPosX());
245 if (cluster ==
nullptr) {
246 ATH_MSG_WARNING(
"Couldn't retrieve CaloCluster from Photon, photons won't be decorated.");
247 return std::make_pair(0, 0);
250 float etas1 = cluster->
etaBE(1);
251 float phis2 = cluster->
phiBE(2);
254 if (cluster ==
nullptr) {
255 ATH_MSG_WARNING(
"Couldn't retrieve conversion Vertex from Photon, photons won't be decorated.");
256 return std::make_pair(0, 0);
259 float conv_x = conv->x();
260 float conv_y = conv->y();
261 float conv_z = conv->z();
267 double conv_r = hypot(conv_x, conv_y);
270 double phi_Calo = atan2(sin(phis2), cos(phis2));
271 double r0_with_beamSpot = d_beamSpot*cos(phi_Calo - phi_beamSpot);
273 float s_zvertex = (RZ1.second*(conv_r - r0_with_beamSpot) - conv_z*(RZ1.first - r0_with_beamSpot)) / (conv_r - RZ1.first);
275 float dist_vtx_to_conv = hypot(conv_r - r0_with_beamSpot, conv_z - s_zvertex);
276 float dist_conv_to_s1 = hypot(RZ1.first - conv_r, RZ1.second - conv_z);
278 float error_etaS1 = 0.001;
284 float error_Z_Calo_1st_Sampling_barrel = error_etaS1*RZ1.first*fabs(cosh(etas1));
285 s_errz = error_Z_Calo_1st_Sampling_barrel*dist_vtx_to_conv/dist_conv_to_s1;
288 float error_R_Calo_1st_Sampling_endcap = error_etaS1*cosh(etas1)*RZ1.first*RZ1.first/fabs(RZ1.second);
289 s_errz = error_R_Calo_1st_Sampling_endcap*fabs(sinh(etas1))*dist_vtx_to_conv/dist_conv_to_s1;
292 return std::make_pair(s_zvertex, s_errz);
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
static std::pair< float, float > getRZ(float eta, int sampling)
Shower depth in R,Z for the given sampling.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Handle class for adding a decoration to an object.
bool isAvailable()
Test to see if this variable exists in the store, for the referenced object.
float phiBE(const unsigned layer) const
Get the phi in one layer of the EM Calo.
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double e() const
The total energy of the particle.
bool inBarrel() const
Returns true if at least one clustered cell in the barrel.
float eSample(const CaloSample sampling) const
bool inEndcap() const
Returns true if at least one clustered cell in the endcap.
float etaBE(const unsigned layer) const
Get the eta in one layer of the EM Calo.
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
Select isolated Photons, Electrons and Muons.
@ Photon
The object is a photon.
std::size_t numberOfSiTracks(const xAOD::Photon *eg)
return the number of Si tracks in the conversion
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Vertex_v1 Vertex
Define the latest version of the vertex class.
Egamma_v1 Egamma
Definition of the current "egamma version".
Photon_v1 Photon
Definition of the current "egamma version".
FileMetaData_v1 FileMetaData
Declare the latest version of the class.
EgammaContainer_v1 EgammaContainer
Definition of the current "egamma container version".