ATLAS Offline Software
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 
10 const int nmax(200);// protection for loop bound
11 
12 // use namespace PixelOfflineCalib;
13 
14 namespace 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 
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 
150 int 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 
165 int 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 
176 void 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 
200 void 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 }
PixelCalib::PixelClusterErrorData::setPixelEndcapRError
int setPixelEndcapRError(int ibin, float error)
Definition: PixelClusterErrorData.cxx:115
run.infile
string infile
Definition: run.py:13
PixelCalib::PixelClusterErrorData::getPixelBarrelEtaError
float getPixelBarrelEtaError(int ibin) const
Definition: PixelClusterErrorData.cxx:89
PixelClusterErrorData.h
PixelCalib::PixelClusterErrorData::m_ibletaerror
std::vector< float > m_ibletaerror
Definition: PixelClusterErrorData.h:73
PlotCalibFromCool.ib
ib
Definition: PlotCalibFromCool.py:419
PixelCalib::PixelClusterErrorData::setPixelBarrelEtaError
int setPixelBarrelEtaError(int ibin, float error)
Definition: PixelClusterErrorData.cxx:129
athena.value
value
Definition: athena.py:124
PixelCalib::PixelClusterErrorData::Initialize
void Initialize()
Definition: PixelClusterErrorData.cxx:23
PixelCalib::PixelClusterErrorData::setPixelIBLPhiError
int setPixelIBLPhiError(int ibin, float error)
Definition: PixelClusterErrorData.cxx:136
PixelCalib::PixelClusterErrorData::m_endcapphierror
std::vector< float > m_endcapphierror
Definition: PixelClusterErrorData.h:70
PixelCalib::PixelClusterErrorData::m_nPhi
int m_nPhi
Definition: PixelClusterErrorData.h:76
PixelCalib::PixelClusterErrorData::getPixelEndcapPhiError
float getPixelEndcapPhiError(int ibin) const
Definition: PixelClusterErrorData.cxx:71
PlotCalibFromCool.ie
ie
Definition: PlotCalibFromCool.py:420
PixelCalib::PixelClusterErrorData::setPixelEndcapPhiError
int setPixelEndcapPhiError(int ibin, float error)
Definition: PixelClusterErrorData.cxx:108
PixelCalib::PixelClusterErrorData::m_nZ
int m_nZ
Definition: PixelClusterErrorData.h:77
PixelCalib::PixelClusterErrorData::getPixelBarrelPhiError
float getPixelBarrelPhiError(int ibin) const
Definition: PixelClusterErrorData.cxx:83
PixelCalib::PixelClusterErrorData::m_endcapetaerror
std::vector< float > m_endcapetaerror
Definition: PixelClusterErrorData.h:71
lumiFormat.i
int i
Definition: lumiFormat.py:85
file
TFile * file
Definition: tile_monitor.h:29
PixelCalib::PixelClusterErrorData::m_barrelphierror
std::vector< float > m_barrelphierror
Definition: PixelClusterErrorData.h:68
PixelCalib
Definition: PixelChargeInterpolationCalibration.h:14
PixelCalib::PixelClusterErrorData::getPixelEndcapRError
float getPixelEndcapRError(int ibin) const
Definition: PixelClusterErrorData.cxx:77
python.SystemOfUnits.micrometer
int micrometer
Definition: SystemOfUnits.py:71
PixelCalib::PixelClusterErrorData::getPixelIBLPhiError
float getPixelIBLPhiError(int ibin) const
Definition: PixelClusterErrorData.cxx:96
PixelCalib::PixelClusterErrorData::m_etaref
std::vector< float > m_etaref
Definition: PixelClusterErrorData.h:80
PixelCalib::PixelClusterErrorData::setPixelIBLEtaError
int setPixelIBLEtaError(int ibin, float error)
Definition: PixelClusterErrorData.cxx:143
PixelCalib::PixelClusterErrorData::setVersion
void setVersion(int version)
Definition: PixelClusterErrorData.cxx:67
PixelCalib::PixelClusterErrorData::getBarrelBin
int getBarrelBin(double eta, int etaClusterSize, int phiClusterSize) const
Definition: PixelClusterErrorData.cxx:150
PixelCalib::PixelClusterErrorData::Load
void Load(const std::string &file)
Definition: PixelClusterErrorData.cxx:200
PixelCalib::PixelClusterErrorData::getPixelIBLEtaError
float getPixelIBLEtaError(int ibin) const
Definition: PixelClusterErrorData.cxx:102
get_generator_info.version
version
Definition: get_generator_info.py:33
PixelCalib::PixelClusterErrorData::getEndcapBin
int getEndcapBin(int etaClusterSize, int phiClusterSize) const
Definition: PixelClusterErrorData.cxx:165
PixelCalib::PixelClusterErrorData::m_version
int m_version
Definition: PixelClusterErrorData.h:78
PixelCalib::PixelClusterErrorData::getVersion
int getVersion() const
Methods to access the calibration data.
Definition: PixelClusterErrorData.cxx:69
nmax
const int nmax(200)
PixelCalib::PixelClusterErrorData::Print
void Print(const std::string &file) const
Definition: PixelClusterErrorData.cxx:176
get_generator_info.error
error
Definition: get_generator_info.py:40
PixelCalib::PixelClusterErrorData::setPixelBarrelPhiError
int setPixelBarrelPhiError(int ibin, float error)
Definition: PixelClusterErrorData.cxx:122
hotSpotInTAG.nb
nb
Definition: hotSpotInTAG.py:164
PixelCalib::PixelClusterErrorData::m_barreletaerror
std::vector< float > m_barreletaerror
Definition: PixelClusterErrorData.h:69
PrepareReferenceFile.outfile
outfile
Definition: PrepareReferenceFile.py:42
error
Definition: IImpactPoint3dEstimator.h:70
PixelCalib::PixelClusterErrorData::m_iblphierror
std::vector< float > m_iblphierror
Definition: PixelClusterErrorData.h:72