ATLAS Offline Software
Loading...
Searching...
No Matches
corr_HV_EMBPS.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include <cmath>
7#include <cstdio>
8#include <cstdlib>
9#include <iostream>
10#include <string>
11
12#include <TProfile2D.h>
13#include <TFile.h>
14#include <TSystem.h>
15
17
18
20 std::string filename = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/HVmaps_embps_2012.root");
21 m_file = TFile::Open(filename.c_str());
22 if (not m_file or m_file->IsZombie()) {
23 std::cerr << "FATAL: cannot open " << filename << std::endl;
24 }
25 else {
26 for (int iperiod=0;iperiod<6;iperiod++) {
27 for (int igap=0;igap<2;igap++) {
28 char name[12];
29 snprintf(name,sizeof(name),"h%d%d",iperiod+1,igap);
30 m_hHV[iperiod][igap]=(TProfile2D*) (m_file->Get(name));
31 if (not m_hHV[iperiod][igap]) {
32 std::cerr << "FATAL: cannot find " << name << std::endl;
33 }
34 }
35 }
36 }
37}
38//===============================================================================
43
44//===============================================================================
45float corr_HV_EMBPS::getCorr(int run, float eta,float phi) const
46{
47 if (std::fabs(eta) > 1.5) return 1.;
48 if (run<200804) return 1.;
49 int iperiod;
50 if (run<204932) iperiod=0;
51 else if (run<205112) iperiod=1;
52 else if (run<211670) iperiod=2;
53 else if (run<212619) iperiod=3;
54 else if (run<212809) iperiod=4;
55 else iperiod=5;
56 //std::cout << "period " << iperiod << std::endl;
57
58 int ieta=(int)((eta+1.6)/0.4);
59 if (ieta<0 || ieta>7) return 1.;
60 if (phi<0.) phi=phi+2*M_PI;
61 int iphi=(int)(phi*(32./(2*M_PI)));
62 if (iphi<0) iphi=0;
63 if (iphi>31) iphi=31;
64 //std::cout << " ieta,iphi " << ieta << " " << iphi << std::endl;
65
66 float hv1 = m_hHV[iperiod][0]->GetBinContent(ieta+1,iphi+1);
67 float hv2 = m_hHV[iperiod][1]->GetBinContent(ieta+1,iphi+1);
68
69 float c1= getRecoCorrection(hv1,eta);
70 float c2= getRecoCorrection(hv2,eta);
71 float delta1 = getDataCorrection(hv1,eta);
72 float delta2 = getDataCorrection(hv2,eta);
73
74 float extra1=1.;
75 if (run<211670 && hv1<1300.) extra1 = getExtraScaleFactor();
76 float extra2=1.;
77 if (run<211670 && hv2<1300.) extra2 = getExtraScaleFactor();
78
79 if ((c1+c2)<0.01) return 1.;
80 float oldScale = (c1+c2);
81 float newScale = (c1*delta1*extra1 + c2*delta2*extra2);
82
83 float newCorr = oldScale/newScale;
84
85 //std::cout << " run,eta,phi " << run << " " << eta << " " << phi << " " << " period "<< iperiod << std::endl;
86 //std::cout << " HV values " << hv1 << " " << hv2 << std::endl;
87 //std::cout << " reco scales " << c1 << " " << c2 << std::endl;
88 //std::cout << " delta scale " << delta1 << " " << delta2 << std::endl;
89 //std::cout << " extra " << extra1 << " " << extra2 << std::endl;
90 //std::cout << " old/new scales " << oldScale << " " << newScale << std::endl;
91 //std::cout << " newCorr " << newCorr << std::endl;
92
93 return newCorr;
94
95}
96
97//===============================================================================
98// return scale factor of response vs HV used in reconstruction
100{
101 float nominal = 2000.;
102 float T = 88.37;
103
104 int ieta=(std::fabs(eta)/0.025);
105 float d;
106 if (ieta>=0 && ieta<16) d = 0.196; //cm
107 else if (ieta>=16 && ieta<32) d = 0.193; //cm
108 else if (ieta>=32 && ieta<48) d = 0.2; //cm
109 else d = 0.190; //cm
110
111 if (hv>(nominal-2.)) return 1.;
112 double efield=std::fabs(hv)/(d*1e+3);
113 double enominal=nominal/(d*1e+3);
114 double scale=Respo(efield, enominal,T);
115
116 return scale;
117}
118
119//===============================================================================
120float corr_HV_EMBPS::Respo(float e, float e_nominal,float tempe)
121{
122 if (e < -999.) return 1.;
123 if (e < 0.01) return 0;
124 if ( e > e_nominal ) return 1;
125 float den = InvCharge(e)*vdrift(e_nominal,tempe);
126 float resp = den == 0 ? 0 : (InvCharge(e_nominal)*vdrift(e,tempe))/den;
127 return resp;
128}
129
130//===============================================================================
132{
133 float q = 1.;
134 if ( e > 2.) q=(1.+0.36/e);
135 else if (e>1e-6) q =(1.04+0.25/e);
136 return q;
137}
138
139//===============================================================================
140float corr_HV_EMBPS::vdrift(float e, float tempe)
141{
142 const float T = tempe;
143 static const float P[6] = {-0.01481,-0.0075,0.141,12.4,1.627,0.317};
144 if ( e < -999.) return 0.;
145 float vd = (P[0]*T+1)*( P[2]*e*std::log(1+ (P[3]/e)) + P[4]*std::pow(e,P[5])) + P[1]*T; // vdrift formula walcowialk mm/micro_s
146 return vd;
147}
148
149
150//===============================================================================
152//
153// values are measured 1 + <Eraw0_end of run>-<Eraw0 beginning of run> / <Eraw0> (i.e <Eraw end>/<Eraw begin>)
154// for the sectors with both sides going from 1600->1200V from beginning to end of run
155// as a function of eta (possibly)
156{
157 if (hv>1300.) return 1.;
158 if (hv>1000.) {
159 if (eta<-1.2) return 0.9925;
160 if (eta<-0.8) return 0.9918;
161 if (eta<-0.4) return 0.9889;
162 if (eta<0.) return 0.9935;
163 if (eta<0.4) return 0.9908;
164 if (eta<0.8) return 0.99197;
165 if (eta<1.2) return 0.9974;
166 return 0.9971;
167 }
168 return 1.015;
169}
170
171//===============================================================================
173{
174 return 1.013;
175}
#define M_PI
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
static Double_t P(Double_t *tt, Double_t *par)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
static float Respo(float e, float e_nominal, float tempe)
static float getDataCorrection(float hv, float eta)
static float getRecoCorrection(float hv, float eta)
static float InvCharge(float e)
float getCorr(int run, float eta, float phi) const
get correction factor to apply to raw EMBPS energy : corrected raw EMBPS energy = correction factor *...
TProfile2D * m_hHV[6][2]
static float getExtraScaleFactor()
corr_HV_EMBPS()
constructor (initialization done there reading a root file for the HV maps per period
static float vdrift(float e, float tempe)
int run(int argc, char *argv[])