ATLAS Offline Software
Loading...
Searching...
No Matches
PixelClusterErrorData.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include "CLHEP/Units/SystemOfUnits.h"
7#include <fstream>
8#include <string>
9
10const int nmax(200);// protection for loop bound
11
12// use namespace PixelOfflineCalib;
13
14namespace PixelCalib{
15
16 //PixelClusterErrorData::PixelClusterErrorData(){
17 // Initialize();
18 //}
19
20// Load defaults - real values to be loaded from database
21// the number of bins is still hardwired however
22
24
25 m_version = 1;
26 // number of bins of parametrizations
27 m_nPhi=3; m_nZ=4;
28 // Bins of eta parametrization for barrel
29 // m_etaref = 0;
30 m_etaref.reserve(6);
31 m_etaref.push_back(0.00);
32 m_etaref.push_back(0.55);
33 m_etaref.push_back(0.87);
34 m_etaref.push_back(1.32);
35 m_etaref.push_back(2.00);
36 m_etaref.push_back(2.95);
37
38 // m_barrelphierror = 0;
39 // m_barreletaerror = 0;
40 m_barrelphierror.reserve(60);
41 m_barreletaerror.reserve(60);
42 for(int i = 0; i<60; i++){
43 m_barrelphierror.push_back(14.43*CLHEP::micrometer);
44 m_barreletaerror.push_back(115.5*CLHEP::micrometer);
45 }
46
47 // m_endcapphierror = 0;
48 // m_endcapetaerror = 0;
49 m_endcapphierror.reserve(12);
50 m_endcapetaerror.reserve(12);
51 for(int i=0; i<12; i++){
52 m_endcapphierror.push_back(14.43*CLHEP::micrometer);
53 m_endcapetaerror.push_back(115.5*CLHEP::micrometer);
54 }
55
56 // IBL
57 // m_iblphierror = 0;
58 // m_ibletaerror = 0;
59 m_iblphierror.reserve(60);
60 m_ibletaerror.reserve(60);
61 for(int i = 0; i<60; i++){
62 m_iblphierror.push_back(14.43*CLHEP::micrometer);
63 m_ibletaerror.push_back(72.2*CLHEP::micrometer);
64 }
65 }
66
67void PixelClusterErrorData::setVersion(int version){ m_version = version; }
68
70
72 if(ibin < 0) return -1;
73 if(static_cast<unsigned int>(ibin) > m_endcapphierror.size()) return -1;
74 return m_endcapphierror[ibin];
75}
76
78 if(ibin < 0) return -1;
79 if(static_cast<unsigned int>(ibin) > m_endcapetaerror.size()) return -1;
80 return m_endcapetaerror[ibin];
81}
82
84 if(ibin < 0) return -1;
85 if(static_cast<unsigned int>(ibin) > m_barrelphierror.size()) return -1;
86 return m_barrelphierror[ibin];
87}
88
90 if(ibin < 0) return -1;
91 if(static_cast<unsigned int>(ibin) > m_barreletaerror.size()) return -1;
92 return m_barreletaerror[ibin];
93}
94
95
97 if(ibin < 0||m_version>-2) return -1;
98 if(static_cast<unsigned int>(ibin) > m_iblphierror.size()) return -1;
99 return m_iblphierror[ibin];
100}
101
103 if(ibin < 0||m_version>-2) return -1;
104 if(static_cast<unsigned int>(ibin) > m_ibletaerror.size()) return -1;
105 return m_ibletaerror[ibin];
106}
107
109 if(ibin<0) return 0;
110 if(static_cast<unsigned int>(ibin)>m_endcapphierror.size()) return 0;
111 m_endcapphierror[ibin] = error;
112 return 1;
113}
114
116 if(ibin<0) return 0;
117 if(static_cast<unsigned int>(ibin)>m_endcapetaerror.size()) return 0;
118 m_endcapetaerror[ibin] = error;
119 return 1;
120}
121
123 if(ibin<0) return 0;
124 if(static_cast<unsigned int>(ibin)>m_barrelphierror.size()) return 0;
125 m_barrelphierror[ibin] = error;
126 return 1;
127}
128
130 if(ibin<0) return 0;
131 if(static_cast<unsigned int>(ibin)>m_barreletaerror.size()) return 0;
132 m_barreletaerror[ibin] = error;
133 return 1;
134}
135
137 if(ibin<0||m_version>-2) return 0;
138 if(static_cast<unsigned int>(ibin)>m_iblphierror.size()) return 0;
139 m_iblphierror[ibin] = error;
140 return 1;
141}
142
144 if(ibin<0||m_version>-2) return 0;
145 if(static_cast<unsigned int>(ibin)>m_ibletaerror.size()) return 0;
146 m_ibletaerror[ibin] = error;
147 return 1;
148}
149
150int PixelClusterErrorData::getBarrelBin(double eta, int etaClusterSize, int phiClusterSize) const {
151
152 int ieta=0;
153 int neta = m_etaref.size();
154 for(int i=0; i<neta; i++){ if(eta>m_etaref[i]) ieta=i; }
155 // phi cluster size bin
156 int iphi = phiClusterSize-1;
157 if(iphi > m_nPhi-1) iphi = m_nPhi-1;
158 // z cluster size bin
159 int iz = etaClusterSize-1;
160 if(iz > m_nZ-1) iz = m_nZ-1;
161
162 return m_nZ*m_nPhi*ieta+m_nZ*iphi+iz;
163}
164
165int PixelClusterErrorData::getEndcapBin(int etaClusterSize, int phiClusterSize) const {
166
167 // std::cout << "getting bin..." << std::endl;
168 int iphi = phiClusterSize-1;
169 if(iphi > m_nPhi-1) iphi = m_nPhi-1;
170 int iz = etaClusterSize-1;
171 if(iz > m_nZ-1) iz = m_nZ-1;
172 // std::cout << "returning" << m_nZ*iphi+iz << std::endl;
173 return m_nZ*iphi+iz;
174}
175
176void PixelClusterErrorData::Print(const std::string& file) const {
177
178 std::ofstream* outfile = new std::ofstream(file.c_str());
179
180 if(m_version < 0) *outfile << m_version << std::endl;
181 *outfile << m_barrelphierror.size() << std::endl;
182 *outfile << m_endcapphierror.size() << std::endl;
183 for(unsigned int ib=0; ib<m_barrelphierror.size(); ib++){
184 *outfile << m_barrelphierror[ib] << " " << m_barreletaerror[ib] << std::endl;
185 }
186 for(unsigned int ie=0; ie<m_endcapphierror.size(); ie++){
187 *outfile << m_endcapphierror[ie] << " " << m_endcapetaerror[ie] << std::endl;
188 }
189 // IBL ?
190 if(m_version<-1){
191 for(unsigned int ib=0; ib<m_iblphierror.size(); ib++){
192 *outfile << m_iblphierror[ib] << " " << m_ibletaerror[ib] << std::endl;
193 }
194 }
195
196 outfile->close();
197 delete outfile;
198}
199
200void PixelClusterErrorData::Load(const std::string& file) {
201 std::ifstream infile(file.c_str());
202
203 // number of bins for barrel and endcap
204 int nb = 0;
205 int ne = 0;
206
207 infile >> m_version;
208 if(m_version >= 0){ // very first format, without version number in file
209 nb = m_version;
210 m_version = 0;
211 infile >> ne;
212 }
213 else{
214 infile >> nb >> ne;
215 }
216
217 m_barrelphierror.clear();
218 m_barreletaerror.clear();
219 m_endcapphierror.clear();
220 m_endcapetaerror.clear();
221 m_iblphierror.clear();
222 m_ibletaerror.clear();
223
224 float value;
225 if(nb<0) nb=0;
226 else if(nb>nmax) nb=nmax;
227 if(ne<0) ne=0;
228 else if(ne>nmax) ne=nmax;
229 for(int ib=0; ib<nb && !infile.eof(); ib++){
230 infile >> value;
231 m_barrelphierror.push_back(value);
232 infile >> value;
233 m_barreletaerror.push_back(value);
234 }
235 for(int ie=0; ie<ne && !infile.eof(); ie++){
236 infile >> value;
237 m_endcapphierror.push_back(value);
238 infile >> value;
239 m_endcapetaerror.push_back(value);
240 }
241 // there is more data for IBL some version number ?
242 if(m_version<-1){
243 for(int ib=0; ib<nb; ib++){
244 infile >> value;
245 m_iblphierror.push_back(value);
246 infile >> value;
247 m_ibletaerror.push_back(value);
248 }
249 }
250
251 infile.close();
252}
253
254}
Scalar eta() const
pseudorapidity method
const int nmax(200)
const int nmax(200)
int setPixelIBLPhiError(int ibin, float error)
int setPixelIBLEtaError(int ibin, float error)
int getBarrelBin(double eta, int etaClusterSize, int phiClusterSize) const
int setPixelBarrelPhiError(int ibin, float error)
int getEndcapBin(int etaClusterSize, int phiClusterSize) const
void Print(const std::string &file) const
int setPixelEndcapRError(int ibin, float error)
int setPixelBarrelEtaError(int ibin, float error)
int getVersion() const
Methods to access the calibration data.
int setPixelEndcapPhiError(int ibin, float error)
TFile * file