ATLAS Offline Software
Loading...
Searching...
No Matches
PixelClusterOnTrackErrorData.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include "CLHEP/Units/SystemOfUnits.h"
7#include <cmath>
8#include <fstream>
9#include <string>
10
11const int nmax(200); // protection for loop bound
12// use namespace PixelOfflineCalib;
13
14
15namespace PixelCalib{
16
20
22
23// Load defaults, will be used if reading from DB does not work
25
26 // Bins of cluster size parametrizations
27 m_version = 0;
28 m_csx.reserve(3);
29 m_csx.push_back(0.5);
30 m_csx.push_back(1.5);
31 m_csx.push_back(2.5);
32 m_csy.reserve(4);
33 m_csy.push_back(0.5);
34 m_csy.push_back(1.5);
35 m_csy.push_back(2.5);
36 m_csy.push_back(3.5);
37
38 // Bins of eta parametrization for barrel
39 m_etaref.reserve(5);
40 m_etaref.push_back(0.00);
41 m_etaref.push_back(0.55);
42 m_etaref.push_back(0.87);
43 m_etaref.push_back(1.32);
44 m_etaref.push_back(2.00);
45
46 // alfa (Rphi incidence angle) bins: [-6., -4., ... ,14]
47 int nphibins = 10;
48 for(int i=0; i<nphibins+1; i++){
49 m_phibins.push_back(-6+2*i);
50 }
51
52 // load defaults
53 int nbiny = m_csx.size()*m_csy.size()*m_etaref.size();
54 m_barreletaerror.reserve(nbiny);
55 for(int i = 0; i<nbiny; i++){
56 m_barreletaerror.push_back(115.4*CLHEP::micrometer);
57 }
58
59 int nbinx = m_csx.size()*m_phibins.size();
60 m_barrelphierror.reserve(nbinx);
61 for(int i = 0; i<nbinx; i++){
62 m_barrelphierror.push_back(14.4*CLHEP::micrometer);
63 }
64 // IBL
65 m_csxbinsibl = 0;
66 m_csybinsibl = 0;
67 m_etabinsibl = 0;
68 m_phibinsibl = 0;
69}
70
74
78
80 if(m_version>-2) return -1;
81 return m_iblphierror.size();
82}
83
85 if(m_version>-2) return -1;
86 return m_ibletaerror.size();
87}
88
90 int deltax) {
91 double errphi=50*CLHEP::micrometer/std::pow(12,0.5);
92 // error on phi coordinate
93 if(deltax == 1){
94 // 1-row hit not expected - return conservative error estimate.
95 if(ang>12){ errphi = 50*CLHEP::micrometer/std::sqrt(12.); }
96 else{
97 // probability to get a 1-row cluster. Error basically proportional
98 // to this.
99 double frac = 0.8-0.6*ang/12;
100 errphi = frac*50*CLHEP::micrometer/std::sqrt(12.);
101 // Now account for some smearing w.r.t. ideal case
102 // tuned so that pulls turns out ok
103 // also some overall rescaling
104 double delta = 3*CLHEP::micrometer;
105 errphi = 1.1*std::sqrt(errphi*errphi+delta*delta);
106 }
107 }
108 else if(deltax == 2){
109 // Charge interpolation: good precision, weakly dependent on angle.
110 // Have not studied resolution yet for large angles (CTB, or very low
111 // pt tracks) - I put a conservative estimate here.
112 if(ang > 14){ errphi = 25*CLHEP::micrometer/std::sqrt(12); }
113 else{ errphi = 3*CLHEP::micrometer+2.5*CLHEP::micrometer*ang/14; }
114 }
115 else{
116 // Have not studied resolution yet for large angles (CTB, or very low
117 // pt tracks) - I put a conservative estimate here.
118 if(ang > 14){ errphi = 25*CLHEP::micrometer/std::sqrt(12); }
119 // at low angles do not expect large clusters - maybe a delta ray?
120 else{ errphi = deltax*50*CLHEP::micrometer/std::sqrt(12); }
121 }
122 return errphi;
123}
124
126 if(ibin < 0) return -1;
127 if(static_cast<unsigned int>(ibin) >= m_barreletaerror.size()) return -2;
128 return m_barreletaerror[ibin];
129}
130
132 if(ibin < 0){ return -1; }
133 if(static_cast<unsigned int>(ibin) >= m_barrelphierror.size()){ return -2;}
134 return m_barrelphierror[ibin];
135}
136
138 if(ibin < 0||m_version>-2) return -1;
139 if(static_cast<unsigned int>(ibin) >= m_ibletaerror.size()) return -2;
140 return m_ibletaerror[ibin];
141}
142
144 if(ibin < 0||m_version>-2){ return -1; }
145 if(static_cast<unsigned int>(ibin) >= m_iblphierror.size()){ return -2;}
146 return m_iblphierror[ibin];
147}
148
150 int phiClusterSize) const {
151
152 int iang =0;
153 int nang = m_phibins.size();
154 for(int i=0; i<nang; i++){
155 if(angle > m_phibins[i]) iang=i;
156 }
157 int iphi=0;
158 int nphi = m_csx.size();
159 for(int i=0; i<nphi; i++){
160 if(phiClusterSize>m_csx[i]) iphi=i;
161 }
162
163 return nphi*iang+iphi;
164}
165
167 int phiClusterSize) const {
168
169 int ieta=0;
170 int neta = m_etaref.size();
171 for(int i=0; i<neta; i++){
172 if(eta>m_etaref[i]) ieta=i;
173 }
174 int iphi=0;
175 int nphi = m_csx.size();
176 for(int i=0; i<nphi; i++){
177 if(phiClusterSize>m_csx[i]) iphi=i;
178 }
179
180 int iz=0;
181 int nz = m_csy.size();
182 for(int i=0; i<nz; i++){
183 if(etaClusterSize>m_csy[i]) iz=i;
184 }
185
186 return nz*nphi*ieta+nz*iphi+iz;
187}
188
190 int phiClusterSize) const {
191 if(m_version>-2) return -1;
192 int iang =0;
193 int nang = m_iblphibins.size();
194 for(int i=0; i<nang; i++){
195 if(angle > m_iblphibins[i]) iang=i;
196 }
197 int iphi=0;
198 for(int i=0; i<m_csxbinsibl; i++){
199 if(phiClusterSize>m_csx[i]) iphi=i;
200 }
201 return m_csxbinsibl*iang+iphi;
202}
203
204int PixelClusterOnTrackErrorData::getIBLBinEta(double eta, int etaClusterSize) const {
205
206 if(m_version>-2) return -1;
207 int ieta=0;
208 int neta = m_ibletaref.size();
209 for(int i=0; i<neta; i++){
210 if(eta>m_ibletaref[i]) ieta=i;
211 }
212 int iz=0;
213 for(int i=0; i<m_csybinsibl; i++){
214 if(etaClusterSize>m_csy[i]) iz=i;
215 }
216 return m_csybinsibl*ieta+iz;
217}
218
219void PixelClusterOnTrackErrorData::setParameters(const int n1, // number of cluster size bins (x-direction)
220 const int n2, // number of cluster size bins (y-direction)
221 const int n3, // number of eta bins
222 const int n4, // number of incidence angle bins
223 int offset, // start from c[offset]
224 const std::vector<float> & c){ // vector with bin values
225
226 m_csx.clear();
227 m_csy.clear();
228 m_etaref.clear();
229 m_phibins.clear();
230 m_csx.reserve(n1);
231 m_csy.reserve(n2);
232 m_etaref.reserve(n3);
233 m_phibins.reserve(n4);
234 for(int i=0; i<n1; i++){
235 m_csx.push_back(c.at(i+offset));
236 }
237 offset += n1;
238 for(int i=0; i<n2; i++){
239 m_csy.push_back(c.at(i+offset));
240 }
241 offset += n2;
242 if(m_etabinsibl>0){ // IBL eta
243 m_ibletaref.reserve(m_etabinsibl+1);
244 for(int i = 0; i<m_etabinsibl+1; i++){
245 m_ibletaref.push_back(c.at(i+offset));
246 }
247 offset +=m_etabinsibl+1;
248 }
249 if(m_phibinsibl>0){ // IBL phi
250 m_iblphibins.reserve(m_phibinsibl+1);
251 for(int i = 0; i<m_phibinsibl+1; i++){
252 m_iblphibins.push_back(c.at(i+offset));
253 }
254 offset +=m_phibinsibl+1;
255 }
256 for(int i=0; i<n3; i++){
257 m_etaref.push_back(c.at(i+offset));
258 }
259 offset += n3;
260 for(int i=0; i<n4; i++){
261 m_phibins.push_back(c.at(i+offset));
262 }
263 offset +=n4;
264 int nxbinsibl = m_csxbinsibl*m_phibinsibl;
265 if(nxbinsibl>0){ // IBL
266 m_iblphierror.clear();
267 m_iblphierror.reserve(nxbinsibl);
268 for(int i = 0; i<nxbinsibl; i++){
269 m_iblphierror.push_back(50.0/std::sqrt(12)*CLHEP::micrometer);
270 }
271 }
272 int nybinsibl = m_csybinsibl*m_etabinsibl;
273 if(nybinsibl>0){ // IBL
274 m_ibletaerror.clear();
275 m_ibletaerror.reserve(nybinsibl);
276 for(int ib1=0; ib1<nybinsibl; ib1++){
277 m_ibletaerror.push_back(250./std::sqrt(12)*CLHEP::micrometer);
278 }
279 }
280 int nbiny = m_csx.size()*m_csy.size()*m_etaref.size();
281 m_barreletaerror.clear();
282 m_barreletaerror.reserve(nbiny);
283 for(int i = 0; i<nbiny; i++){
284 m_barreletaerror.push_back(400./std::sqrt(12)*CLHEP::micrometer);
285 }
286 int nbinx = m_csx.size()*m_phibins.size();
287 m_barrelphierror.clear();
288 m_barrelphierror.reserve(nbinx);
289 for(int i = 0; i<nbinx; i++){
290 m_barrelphierror.push_back(50./std::sqrt(12)*CLHEP::micrometer);
291 }
292 }
293
295
297
299// save all costants to file
300//
301void PixelClusterOnTrackErrorData::Print(const std::string& file) const {
302
303 std::ofstream* outfile = new std::ofstream(file.c_str());
304
305 if(m_version<0)*outfile << m_version << std::endl;
306
307 int ncsx = m_csx.size(); // number of cluster size (x-direction) bins
308 int ncsy = m_csy.size(); // number of cluster size (x-direction) bins
309 int neta = m_etaref.size(); // number of eta values bins
310 int nalpha = m_phibins.size(); // number of incidence angle bins
311 if(m_version<-1){
312 *outfile <<ncsx<<" "<<ncsy<<" "<<neta<<" "<<nalpha<<" "<<m_csxbinsibl<<
313 " "<<m_csybinsibl<<" "<<m_etabinsibl<<" "<<m_phibinsibl<<std::endl;
314 }
315 else{
316 *outfile << ncsx << " " << ncsy << " " << neta << " " << nalpha << std::endl;
317 }
318
319 for(int i=0; i<ncsx; i++){
320 *outfile << m_csx[i] << " ";
321 }
322 *outfile << std::endl;
323 for(int i=0; i<ncsy; i++){
324 *outfile << m_csy[i] << " ";
325 }
326 *outfile << std::endl;
327 if(m_etabinsibl>0 && m_phibinsibl >0 ){ // IBL
328 for(float i : m_ibletaref){
329 *outfile << i << " ";
330 }
331 *outfile << std::endl;
332 for(float iblphibin : m_iblphibins){
333 *outfile << iblphibin << " ";
334 }
335 *outfile << std::endl;
336 }
337 for(int i=0; i<neta; i++){
338 *outfile << m_etaref[i] << " ";
339 }
340 *outfile << std::endl;
341 for(int i=0; i<nalpha; i++){
342 *outfile << m_phibins[i] << " ";
343 }
344 *outfile << std::endl;
345 int nxbinsibl = m_csxbinsibl*m_phibinsibl;
346 if(nxbinsibl>0){ // IBL
347 for(int ib1=0; ib1<nxbinsibl; ib1++){
348 *outfile <<m_iblphierror[ib1]<<std::endl;
349 }
350 }
351 int nb1=ncsx*nalpha; // number of barrel phi bins
352 int nb2=ncsx*ncsy*neta; // number of barrel eta bins
353 for(int ib1=0; ib1<nb1; ib1++){
354 *outfile << m_barrelphierror[ib1] << std::endl;
355 }
356 int nybinsibl = m_csybinsibl*m_etabinsibl;
357 if(nybinsibl>0){ // IBL
358 for(int ib1=0; ib1<nybinsibl; ib1++){
359 *outfile <<m_ibletaerror[ib1]<<std::endl;
360 }
361 }
362 for(int ib2=0; ib2<nb2; ib2++){
363 *outfile << m_barreletaerror[ib2] << std::endl;
364 }
365 outfile->close();
366 delete outfile;
367}
368
369
371
372
373// Load costants from file
375 std::ifstream infile(file.c_str());
376
377 // number of bins of parametrization
378 int ncsx; // cluster size in x
379 int ncsy; // cluster size in y
380 int neta = 0; // pseudorapidity
381 int nalpha; // incidence angle
382 m_csxbinsibl = 0;
383 m_csybinsibl = 0;
384 m_etabinsibl = 0;
385 m_phibinsibl = 0;
386 int nxbinsibl(0);
387 int nybinsibl(0);
388
389 infile >> m_version;
390 if(m_version >= 0){ // very first format, without version number in file
391 ncsx = m_version;
392 m_version = 0;
393 infile >> ncsy >> neta >> nalpha;
394 }
395 else{
396 if(m_version<-1){ // IBL version
397 infile>> ncsx >> ncsy >> neta >> nalpha>>m_csxbinsibl>>m_csybinsibl>>m_etabinsibl>>m_phibinsibl;
398 nxbinsibl = m_csxbinsibl*m_phibinsibl;
399 nybinsibl = m_csybinsibl*m_etabinsibl;
400 }
401 else{
402 infile >> ncsx >> ncsy >> neta >> nalpha;
403 }
404 }
405
406 // read bins of parametrization
407
408 float value;
409 if(ncsx<0)ncsx = 0;
410 if(ncsx>nmax) ncsx=nmax;
411 m_csx.clear();
412 m_csx.reserve(ncsx);
413 for(int i=0; i<ncsx && !infile.eof(); i++){
414 infile >> value;
415 m_csx.push_back(value);
416 }
417 if(ncsy<0)ncsy=0;
418 if(ncsy>nmax) ncsy=nmax;
419 m_csy.clear();
420 m_csy.reserve(ncsy);
421 for(int i=0; i<ncsy && !infile.eof(); i++){
422 infile >> value;
423 m_csy.push_back(value);
424 }
425 if(m_etabinsibl>0 && m_phibinsibl >0 ){ // IBL
426 m_ibletaref.clear();
428 m_ibletaref.reserve(m_etabinsibl+1);
429 for(int i=0; i<m_etabinsibl+1; i++){
430 infile >> value;
431 m_ibletaref.push_back(value);
432 }
433 m_iblphibins.clear();
435 m_iblphibins.reserve(m_phibinsibl+1);
436 for(int i=0; i<m_phibinsibl+1; i++){
437 infile >> value;
438 m_iblphibins.push_back(value);
439 }
440 }
441 if(neta<0)neta=0;
442 if(neta>nmax) neta=nmax;
443 m_etaref.clear();
444 m_etaref.reserve(neta);
445 for(int i=0; i<neta && !infile.eof(); i++){
446 infile >> value;
447 m_etaref.push_back(value);
448 }
449 if(nalpha<0)nalpha = 0;
450 if(nalpha>nmax) nalpha=nmax;
451 m_phibins.clear();
452 m_phibins.reserve(nalpha);
453 for(int i=0; i<nalpha && !infile.eof(); i++){
454 infile >> value;
455 m_phibins.push_back(value);
456 }
457 if(nxbinsibl>0){ // IBL
458 if(nxbinsibl>nmax) nxbinsibl=nmax;
459 m_iblphierror.clear();
460 m_iblphierror.reserve(nxbinsibl);
461 for(int ib1=0; ib1<nxbinsibl; ib1++){
462 infile >> value;
463 m_iblphierror.push_back(value);
464 }
465 }
466 int nb1=ncsx*nalpha; // number of barrel phi bins
467 int nb2=ncsx*ncsy*neta; // number of barrel eta bins
468 m_barrelphierror.clear();
469 m_barreletaerror.clear();
470 m_barrelphierror.reserve(nb1);
471 m_barreletaerror.reserve(nb2);
472 for(int ib1=0; ib1<nb1; ib1++){
473 infile >> value;
474 m_barrelphierror.push_back(value);
475 }
476 if(nybinsibl>0){ // IBL
477 if(nybinsibl>nmax) nybinsibl=nmax;
478 m_ibletaerror.clear();
479 m_ibletaerror.reserve(nybinsibl);
480 for(int ib1=0; ib1<nybinsibl; ib1++){
481 infile >> value;
482 m_ibletaerror.push_back(value);
483 }
484 }
485 for(int ib2=0; ib2<nb2; ib2++){
486 infile >> value;
487 m_barreletaerror.push_back(value);
488 }
489 infile.close();
490}
491
492}
493
Scalar eta() const
pseudorapidity method
const int nmax(200)
const int nmax(200)
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
int getBarrelBinPhi(double angle, int phiClusterSize) const
int getIBLBinPhi(double angle, int phiClusterSize) const
static double getPixelBarrelPhiError(double ang, int phiClusterSize)
int getBarrelBinEta(double eta, int etaClusterSize, int phiClusterSize) const
void setParameters(const int ncsx, const int ncsy, const int neta, const int nalpha, int offset, const std::vector< float > &constants)
int getVersion() const
Methods to access the calibration data.
int getIBLBinEta(double eta, int etaClusterSize) const
TFile * file