CMS 3D CMS Logo

SiPixelTemplate2D.h
Go to the documentation of this file.
1 //
2 // SiPixelTemplate2D.h (v2.65)
3 //
4 // Full 2-D templates for cluster splitting, simulated cluster reweighting, and improved cluster probability
5 //
6 // Created by Morris Swartz on 12/01/09.
7 // V1.01 - fix qavg_ filling
8 // V1.02 - Add locBz to test if FPix use is out of range
9 // V1.03 - Fix edge checking on final template to increase template size and to properly truncate cluster
10 // v2.00 - Major changes to accommodate 2D reconstruction
11 // v2.10 - Change chi2 and error scaling information to work with partially reconstructed clusters
12 // v2.20 - Add cluster charge probability information, side loading for template generation
13 // v2.21 - Double derivative interval [improves fit convergence]
14 // v2.25 - Resize template store to accommodate FPix Templates
15 // v2.30 - Fix bug found by P. Shuetze that compromises sqlite file loading
16 // v2.35 - Add directory path selection to the ascii pushfile method
17 // v2.50 - Change template storage to dynamically allocated 2D arrays of SiPixelTemplateEntry2D structs
18 // v2.51 - Ensure that the derivative arrays are correctly zeroed between calls
19 // v2.52 - Improve cosmetics for increased style points from judges
20 // v2.60 - Fix FPix multiframe lookup problem [takes +-cotalpha and +-cotbeta]
21 // v2.61a - Code 2.60 fix correctly
22 // v2.65 - change double pixel flags to work with new shifted reco code definition
23 //
24 
25 // Build the template storage structure from several pieces
26 
27 #ifndef SiPixelTemplate2D_h
28 #define SiPixelTemplate2D_h 1
29 
30 #include <vector>
31 #include <cassert>
32 #include "boost/multi_array.hpp"
33 
34 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
38 #else
39 #include "SiPixelTemplateDefs.h"
40 #endif
41 
43  int runnum;
44  float cotalpha;
45  float cotbeta;
46  float costrk[3];
47  float qavg;
48  float pixmax;
49  float sxymax;
50  int iymin;
51  int iymax;
52  int jxmin;
53  int jxmax;
54  float xypar[2][5];
55  float lanpar[2][5];
56  short int xytemp[7][7][T2YSIZE][T2XSIZE];
57  float chi2ppix;
58  float chi2scale;
59  float chi2avgone;
60  float chi2minone;
61  float clsleny;
62  float clslenx;
63  float mpvvav;
64  float sigmavav;
65  float kappavav;
66  float scalexavg;
67  float scaleyavg;
68  float delyavg;
69  float delysig;
70  float scalex[4];
71  float scaley[4];
72  float offsetx[4];
73  float offsety[4];
74  float spare[3];
75 };
76 
78  int ID;
79  int NTy;
80  int NTyx;
81  int NTxx;
82  int Dtype;
83  float qscale;
84  float lorywidth;
85  float lorxwidth;
86  float lorybias;
87  float lorxbias;
88  float Vbias;
89  float temperature;
90  float fluence;
91  float s50;
92  float ss50;
93  char title[80];
95  float Bfield;
96  float fbin[3];
97  float xsize;
98  float ysize;
99  float zsize;
100 };
101 
103 
104  void resize(int ny, int nx) {
105  entry.resize(ny);
106  store.resize(nx * ny);
107  int off = 0;
108  for (int i = 0; i < ny; ++i) {
109  entry[i] = store.data() + off;
110  off += nx;
111  }
112  assert(nx * ny == off);
113  }
114 
116 
118  std::vector<SiPixelTemplateEntry2D*> entry;
119 
120  std::vector<SiPixelTemplateEntry2D> store;
121 };
122 
123 // ******************************************************************************************
141 // ******************************************************************************************
143 public:
144  SiPixelTemplate2D(const std::vector<SiPixelTemplateStore2D>& thePixelTemp) : thePixelTemp_(thePixelTemp) {
145  id_current_ = -1;
146  index_id_ = -1;
147  cota_current_ = 0.;
148  cotb_current_ = 0.;
149  }
150 
151  // load the private store with info from the
152  // file with the index (int) filenum ${dir}template_summary_zp${filenum}.out
153 #ifdef SI_PIXEL_TEMPLATE_STANDALONE
154  static bool pushfile(int filenum, std::vector<SiPixelTemplateStore2D>& pixelTemp, std::string dir = "");
155 
156  // For calibrations only: load precalculated values -- no interpolation.
157  void sideload(SiPixelTemplateEntry2D* entry,
158  int iDtype,
159  float locBx,
160  float locBz,
161  float lorwdy,
162  float lorwdx,
163  float q50,
164  float fbin[3],
165  float xsize,
166  float ysize,
167  float zsize);
168 
169 #else
170  static bool pushfile(int filenum,
171  std::vector<SiPixelTemplateStore2D>& pixelTemp,
172  std::string dir = "CalibTracker/SiPixelESProducers/data/");
173 
174  // Load from the DB (the default in CMSSW):
175  static bool pushfile(const SiPixel2DTemplateDBObject& dbobject, std::vector<SiPixelTemplateStore2D>& pixelTemp);
176 
177 #endif
178 
179  // Initialize things before interpolating
180  bool getid(int id);
181 
182  bool interpolate(int id, float cotalpha, float cotbeta, float locBz, float locBx);
183 
184  // Interpolate input alpha and beta angles to produce a working template for each individual hit.
185 
186  // Works with Phase 0+1
187  bool xytemp(float xhit,
188  float yhit,
189  bool ydouble[BYM2],
190  bool xdouble[BXM2],
191  float template2d[BXM2][BYM2],
192  bool dervatives,
193  float dpdx2d[2][BXM2][BYM2],
194  float& QTemplate);
195 
196  // Overload for backward compatibility
197 
198  bool xytemp(float xhit, float yhit, bool ydouble[BYM2], bool xdouble[BXM2], float template2d[BXM2][BYM2]);
199 
200  // Overload for backward compatibility with re-weighting code
201 
202  bool xytemp(int id,
203  float cotalpha,
204  float cotbeta,
205  float xhit,
206  float yhit,
207  std::vector<bool>& ydouble,
208  std::vector<bool>& xdouble,
209  float template2d[BXM2][BYM2]);
210 
211  void xysigma2(float qpixel, int index, float& xysig2);
212 
213  // Get the interpolated Landau distribution parameters
214 
215  void landau_par(float lanpar[2][5]);
216 
217  float qavg() { return qavg_; }
218  float pixmax() { return pixmax_; }
219  float qscale() { return qscale_; }
220  float s50() { return s50_; }
221  float sxymax() { return sxymax_; }
222  float scalex(int i) {
223  if (checkIllegalIndex("scalex", 3, i)) {
224  return scalex_[i];
225  } else {
226  return 0.f;
227  }
228  }
229  float scaley(int i) {
230  if (checkIllegalIndex("scaley", 3, i)) {
231  return scaley_[i];
232  } else {
233  return 0.f;
234  }
235  }
236  float offsetx(int i) {
237  if (checkIllegalIndex("offsetx", 3, i)) {
238  return offsetx_[i];
239  } else {
240  return 0.f;
241  }
242  }
243  float offsety(int i) {
244  if (checkIllegalIndex("offsety", 3, i)) {
245  return offsety_[i];
246  } else {
247  return 0.f;
248  }
249  }
250  float fbin(int i) {
251  if (checkIllegalIndex("fbin", 2, i)) {
252  return fbin_[i];
253  } else {
254  return 0.f;
255  }
256  }
257  float sizex() { return clslenx_; }
258  float sizey() { return clsleny_; }
259  float chi2ppix() { return chi2ppix_; }
260  float chi2scale() { return chi2scale_; }
261  float chi2avgone() { return chi2avgone_; }
262  float chi2minone() { return chi2minone_; }
263  float mpvvav() { return mpvvav_; }
264  float sigmavav() { return sigmavav_; }
265  float kappavav() { return kappavav_; }
266  float lorydrift() { return lorydrift_; }
267  float lorxdrift() { return lorxdrift_; }
268  float clsleny() { return clsleny_; }
269  float clslenx() { return clslenx_; }
270  float scaleyavg() { return scaleyavg_; }
271  float scalexavg() { return scalexavg_; }
272  float delyavg() {
273  return delyavg_;
274  }
275  float delysig() { return delysig_; }
276  float xsize() { return xsize_; }
277  float ysize() { return ysize_; }
278  float zsize() { return zsize_; }
279  int storesize() {
280  return (int)thePixelTemp_.size();
281  }
282 
283 private:
284  bool checkIllegalIndex(const std::string whichMethod, int indMax, int i) {
285 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
286  if (i < 0 || i > indMax) {
287  throw cms::Exception("DataCorrupt")
288  << "SiPixelTemplate2D::" << whichMethod << " called with illegal index = " << i << std::endl;
289  }
290 #else
291  assert(i >= 0 && i < indMax + 1);
292 
293 #endif
294  return true;
295  }
296 
297  // Keep current template interpolaion parameters
298 
300  int index_id_;
303  int Nyx_;
304  int Nxx_;
305  int Dtype_;
306  float cotbeta0_;
307  float cotbeta1_;
308  float deltacotb_;
309  float cotalpha0_;
310  float cotalpha1_;
311  float deltacota_;
312  int iy0_;
313  int iy1_;
314  float adcotb_;
315  int jx0_;
316  int jx1_;
317  float adcota_;
318  int imin_;
319  int imax_;
320  int jmin_;
321  int jmax_;
322  bool flip_y_;
323  bool flip_x_;
324  bool success_;
325 
326  // Keep results of last interpolation to return through member functions
327 
328  float qavg_;
329  float pixmax_;
330  float qscale_;
331  float s50_;
332  float sxymax_;
333  float xytemp_[BXM2][BYM2];
334  float xypary0x0_[2][5];
335  float xypary1x0_[2][5];
336  float xypary0x1_[2][5];
337  float lanpar_[2][5];
338  float chi2ppix_;
339  float chi2scale_;
340  float chi2avgone_;
341  float chi2minone_;
342  float clsleny_;
343  float clslenx_;
344  float scalexavg_;
345  float scaleyavg_;
346  float delyavg_;
347  float delysig_;
348  float scalex_[4];
349  float scaley_[4];
350  float offsetx_[4];
351  float offsety_[4];
352  float mpvvav_;
353  float sigmavav_;
354  float kappavav_;
355  float lorywidth_;
356  float lorxwidth_;
357  float lorydrift_;
358  float lorxdrift_;
359  float xsize_;
360  float ysize_;
361  float zsize_;
362  float fbin_[3];
363  const SiPixelTemplateEntry2D* entry00_; // Pointer to presently interpolated point [iy,ix]
364  const SiPixelTemplateEntry2D* entry10_; // Pointer to presently interpolated point [iy+1,ix]
365  const SiPixelTemplateEntry2D* entry01_; // Pointer to presently interpolated point [iy,ix+1]
366 
367  // The actual template store is a std::vector container
368  const std::vector<SiPixelTemplateStore2D>& thePixelTemp_;
369 };
370 
371 #endif
float pixmax
maximum charge for individual pixels in cluster
bool checkIllegalIndex(const std::string whichMethod, int indMax, int i)
float adcotb_
fractional pixel distance of cot(beta) from iy0_
float kappavav_
kappa parameter in Vavilov distribution
float deltacota_
cot(alpha) bin size
float qscale
Charge scaling to match cmssw and pixelav.
float delyavg()
average difference between clsleny_ and cluster length [with threshold effects]
float chi2ppix_
average chi^2 per struck pixel
float xsize()
pixel x-size (microns)
float scaley_[4]
y-error scale factor in charge bins
int jx1_
index of next-nearest cot(alpha) bin
float chi2avgone
average y chi^2 for 1 pixel clusters
float qavg
average cluster charge for this set of track angles
float Vbias
detector bias potential in Volts
float lorxwidth
estimate of x-lorentz width for optimal resolution
bool xytemp(float xhit, float yhit, bool ydouble[21+2], bool xdouble[13+2], float template2d[13+2][21+2], bool dervatives, float dpdx2d[2][13+2][21+2], float &QTemplate)
float chi2ppix()
average chi^2 per struck pixel
int runnum
< Basic template entry corresponding to a single set of track angles
int jx0_
index of nearest cot(alpha) bin
float ysize
pixel size (for future use in upgraded geometry)
float deltacotb_
cot(beta) bin size
SiPixelTemplateHeader2D head
Header information.
float qavg_
average cluster charge for this set of track angles
float cotalpha1_
maximum cot(alpha) covered
float xsize_
Pixel x-size.
int Dtype_
flags BPix (=0) or FPix (=1)
float scalexavg()
x-reco error scaling factor
void xysigma2(float qpixel, int index, float &xysig2)
bool flip_y_
flip y sign-sensitive quantities
float clslenx_
projected x-length of cluster
float clsleny
cluster y-length in pixels at signal height symax/2
float sxymax
average pixel signal for use of the error parameterization
float xypar[2][5]
pixel uncertainty parameterization
float fbin_[3]
The QBin definitions in Q_clus/Q_avg.
float xytemp_[13+2][21+2]
template for xy-reconstruction
float chi2avgone_
average chi^2 for 1 pixel clusters
float scaleyavg
average y-error scale factor
float chi2minone
minimum of y chi^2 for 1 pixel clusters
float delyavg_
average difference between clsleny_ and cluster length [with threshold effects]
float xypary0x1_[2][5]
Polynomial error parameterization at ix1,iy0.
float sxymax_
average pixel signal for y-projection of cluster
int Nxx_
number of cot(alpha)-entries (rows) in template
int index_id_
current index
float delyavg
average length difference between template and cluster
float delysig
rms of length difference between template and cluster
float scaleyavg()
y-reco error scaling factor
float scalexavg_
average x-error scale factor
assert(be >=bs)
float chi2scale_
scale factor for chi2 distribution
float s50()
1/2 of the pixel threshold signal in adc units
float lorydrift_
Lorentz y-drift.
const SiPixelTemplateEntry2D * entry01_
float offsetx(int i)
x-offset in 4 charge bins
float cotbeta
cot(beta) is proportional to cluster length in y and is basis of interpolation
#define BXM2
float lorxbias
estimate of x-lorentz bias
float offsetx_[4]
x-offset in charge bins
void resize(int ny, int nx)
< template storage structure
int iymax
the maximum nonzero pixel yindex in template (saves time during interpolation)
float adcota_
fractional pixel distance of cot(alpha) from jx0_
float fbin[3]
The QBin definitions in Q_clus/Q_avg.
float clslenx()
cluster x-size
#define T2XSIZE
float sigmavav_
scale factor in Vavilov distribution
int storesize()
return the size of the template store (the number of stored IDs
float ss50
1/2 of the single hit dcol threshold in electrons
int imin_
min y index of templated cluster
int iymin
the minimum nonzero pixel yindex in template (saves time during interpolation)
short int xytemp[7][7][21][7]
templates for y-reconstruction (binned over 1 central pixel)
float chi2avgone()
average y chi^2 for 1 pixel clusters
int ID
< template header structure
int NTxx
number of Template x-entries in each slice
const SiPixelTemplateEntry2D * entry00_
float mpvvav
most probable charge in Vavilov distribution (not actually for larger kappa)
const std::vector< SiPixelTemplateStore2D > & thePixelTemp_
float s50_
1/2 of the pixel threshold signal in adc units
float cotbeta0_
minimum cot(beta) covered
float scalex[4]
x-error scale factor in 4 charge bins
int jxmax
the maximum nonzero pixel xindex in template (saves time during interpolation)
int imax_
max y index of templated cluster
float lanpar[2][5]
pixel landau distribution parameters
float xsize
pixel size (for future use in upgraded geometry)
float costrk[3]
direction cosines of tracks used to generate this entry
float offsetx[4]
x-offset in 4 charge bins
float chi2minone_
minimum of chi^2 for 1 pixel clusters
#define BYM2
float scalex(int i)
x-error scale factor in 4 charge bins
float lorxdrift_
Lorentz x-drift.
int jxmin
the minimum nonzero pixel xindex in template (saves time during interpolation)
float chi2minone()
minimum of y chi^2 for 1 pixel clusters
float cotalpha0_
minimum cot(alpha) covered
float chi2scale()
scale factor for chi^2 distribution
float sigmavav
"sigma" scale fctor for Vavilov distribution
float cotalpha
cot(alpha) is proportional to cluster length in x and is basis of interpolation
float lorxdrift()
signed lorentz x-width (microns)
bool interpolate(int id, float cotalpha, float cotbeta, float locBz, float locBx)
char title[80]
template title
const SiPixelTemplateEntry2D * entry10_
float mpvvav()
most probable Q in Vavilov distribution
int iy1_
index of next-nearest cot(beta) bin
float clsleny_
projected y-length of cluster
bool flip_x_
flip x sign-sensitive quantities
float zsize
pixel size (for future use in upgraded geometry)
float zsize_
Pixel z-size (thickness)
SiPixelTemplate2D(const std::vector< SiPixelTemplateStore2D > &thePixelTemp)
Default constructor.
float offsety[4]
y-offset in 4 charge bins
int Nyx_
number of cot(beta)-entries (columns) in template
float chi2scale
scale factor for the chi2 distribution
float lorywidth
estimate of y-lorentz width for optimal resolution
float lanpar_[2][5]
Interpolated Landau parameters.
float clslenx
cluster x-length in pixels at signal height sxmax/2
float kappavav()
kappa parameter in Vavilov distribution
float cota_current_
current cot alpha
float pixmax()
maximum pixel charge
float offsety_[4]
y-offset in charge bins
float lorxwidth_
Lorentz x-width.
float lorydrift()
signed lorentz y-width (microns)
int NTy
number of Template y entries
float sxymax()
max pixel signal for pixel error calculation
float pixmax_
maximum pixel charge
float cotbeta1_
maximum cot(beta) covered
float scalexavg
average x-error scale factor
int jmax_
max x index of templated cluster
float mpvvav_
most probable Q in Vavilov distribution
int Dtype
detector type (0=BPix, 1=FPix)
float ysize()
pixel y-size (microns)
float sizex()
return x size of template cluster
float qscale()
charge scaling factor
float sizey()
return y size of template cluster
float xypary1x0_[2][5]
Polynomial error parameterization at ix0,iy1.
float scaley[4]
y-error scale factor in 4 charge bins
float qavg()
average cluster charge for this set of track angles
float fbin(int i)
Return lower bound of Qbin definition.
bool success_
true if cotalpha, cotbeta are inside of the acceptance (dynamically loaded)
float ysize_
Pixel y-size.
float scaleyavg_
average y-error scale factor
void landau_par(float lanpar[2][5])
Return the Landau probability parameters for this set of cot(alpha, cot(beta)
std::vector< SiPixelTemplateEntry2D * > entry
float xypary0x0_[2][5]
Polynomial error parameterization at ix0,iy0.
float cotb_current_
current cot beta
float chi2ppix
average chi^2 per pixel
int templ_version
Version number of the template to ensure code compatibility.
float delysig()
rms difference between clsleny_ and cluster length [with threshold effects]
float zsize()
pixel z-size or thickness (microns)
float scalex_[4]
x-error scale factor in charge bins
float s50
1/2 of the multihit dcol threshold in electrons
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore2D > &pixelTemp, std::string dir="CalibTracker/SiPixelESProducers/data/")
float temperature
detector temperature in deg K
float Bfield
Bfield in Tesla.
float offsety(int i)
y-offset in 4 charge bins
float lorywidth_
Lorentz y-width (sign corrected for fpix frame)
float qscale_
charge scaling factor
#define T2YSIZE
int iy0_
index of nearest cot(beta) bin
float fluence
radiation fluence in n_eq/cm^2
float kappavav
kappa parameter for Vavilov distribution
float clsleny()
cluster y-size
std::vector< SiPixelTemplateEntry2D > store
float lorybias
estimate of y-lorentz bias
int NTyx
number of Template y-slices of x entries
int id_current_
current id
int jmin_
min x index of templated cluster
float delysig_
rms of difference between clsleny_ and cluster length [with threshold effects]
float sigmavav()
scale factor in Vavilov distribution
float scaley(int i)
y-error scale factor in 4 charge bins