00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef SiPixelTemplate_h
00037 #define SiPixelTemplate_h 1
00038
00039 #define TYSIZE 21
00040 #define TYTEN 210 // = 10*TYSIZE
00041 #define BYSIZE TYSIZE+4
00042 #define BHY 12 // = BYSIZE/2
00043 #define BYM1 TYSIZE+3
00044 #define BYM2 TYSIZE+2
00045 #define BYM3 TYSIZE+1
00046 #define TXSIZE 13
00047 #define BXSIZE TXSIZE+4
00048 #define BHX 8 // = BXSIZE/2
00049 #define BXM1 TXSIZE+3
00050 #define BXM2 TXSIZE+2
00051 #define BXM3 TXSIZE+1
00052
00053 #include<vector>
00054 #include<cassert>
00055 #include "boost/multi_array.hpp"
00056
00057 typedef boost::multi_array<float, 3> array_3d;
00058
00059 struct SiPixelTemplateEntry {
00060 int runnum;
00061 float alpha;
00062 float cotalpha;
00063 float beta;
00064 float cotbeta;
00065 float costrk[3];
00066 float qavg;
00067 float pixmax;
00068 float symax;
00069 float dyone;
00070 float syone;
00071 float sxmax;
00072 float dxone;
00073 float sxone;
00074 float dytwo;
00075 float sytwo;
00076 float dxtwo;
00077 float sxtwo;
00078 float qmin;
00079 float clsleny;
00080 float clslenx;
00081 float ypar[2][5];
00082 float ytemp[9][TYSIZE];
00083 float xpar[2][5];
00084 float xtemp[9][TXSIZE];
00085 float yavg[4];
00086 float yrms[4];
00087 float ygx0[4];
00088 float ygsig[4];
00089 float yflpar[4][6];
00090 float xavg[4];
00091 float xrms[4];
00092 float xgx0[4];
00093 float xgsig[4];
00094 float xflpar[4][6];
00095 float chi2yavg[4];
00096 float chi2ymin[4];
00097 float chi2xavg[4];
00098 float chi2xmin[4];
00099 float yavgc2m[4];
00100 float yrmsc2m[4];
00101 float ygx0c2m[4];
00102 float ygsigc2m[4];
00103 float xavgc2m[4];
00104 float xrmsc2m[4];
00105 float xgx0c2m[4];
00106 float xgsigc2m[4];
00107 float yspare[10];
00108 float xspare[10];
00109 } ;
00110
00111
00112
00113
00114 struct SiPixelTemplateHeader {
00115 char title[80];
00116 int ID;
00117 int NBy;
00118 int NByx;
00119 int NBxx;
00120 int NFy;
00121 int NFyx;
00122 int NFxx;
00123 float Bbias;
00124 float Fbias;
00125 float temperature;
00126 float fluence;
00127 float qscale;
00128 float s50;
00129 int templ_version;
00130 } ;
00131
00132
00133
00134
00135
00136 struct SiPixelTemplateStore {
00137 SiPixelTemplateHeader head;
00138 SiPixelTemplateEntry entby[60];
00139 SiPixelTemplateEntry entbx[5][29];
00140 SiPixelTemplateEntry entfy[16];
00141 SiPixelTemplateEntry entfx[3][29];
00142 } ;
00143
00144
00145
00146
00147
00148
00166
00167 class SiPixelTemplate {
00168 public:
00169 SiPixelTemplate() {id_current = -1; index_id = -1; cota_current = 0.; cotb_current = 0.; fpix_current=false;}
00170 bool pushfile(int filenum);
00171
00172
00173
00174 bool interpolate(int id, bool fpix, float cotalpha, float cotbeta);
00175
00176
00177 void ytemp(int fybin, int lybin, float ytemplate[41][BYSIZE]);
00178
00179 void xtemp(int fxbin, int fxbin, float xtemplate[41][BXSIZE]);
00180
00181
00182 void ytemp3d(int nypix, array_3d& ytemplate);
00183
00184 void xtemp3d(int nxpix, array_3d& xtemplate);
00185
00186
00187 void ysigma2(int fypix, int lypix, float sythr, float ysum[BYSIZE], float ysig2[BYSIZE]);
00188
00189 void xsigma2(int fxpix, int lxpix, float sxthr, float xsum[BXSIZE], float xsig2[BXSIZE]);
00190
00191
00192 float yflcorr(int binq, float qfly);
00193
00194
00195 float xflcorr(int binq, float qflx);
00196
00197
00198 int qbin(int id, bool fpix, float cotbeta, float qclus);
00199
00200 float qavg() {return pqavg;}
00201 float pixmax() {return ppixmax;}
00202 float qscale() {return pqscale;}
00203 float s50() {return ps50;}
00204 float symax() {return psymax;}
00205 float dyone() {return pdyone;}
00206 float syone() {return psyone;}
00207 float dytwo() {return pdytwo;}
00208 float sytwo() {return psytwo;}
00209 float sxmax() {return psxmax;}
00210 float dxone() {return pdxone;}
00211 float sxone() {return psxone;}
00212 float dxtwo() {return pdxtwo;}
00213 float sxtwo() {return psxtwo;}
00214 float qmin() {return pqmin;}
00215 float clsleny() {return pclsleny;}
00216 float clslenx() {return pclslenx;}
00217 float yratio() {return pyratio;}
00218 float yxratio() {return pyxratio;}
00219 float xxratio() {return pxxratio;}
00220 float yavg(int i) {assert(i>=0 && i<4); return pyavg[i];}
00221 float yrms(int i) {assert(i>=0 && i<4); return pyrms[i];}
00222 float ygx0(int i) {assert(i>=0 && i<4); return pygx0[i];}
00223 float ygsig(int i) {assert(i>=0 && i<4); return pygsig[i];}
00224 float xavg(int i) {assert(i>=0 && i<4); return pxavg[i];}
00225 float xrms(int i) {assert(i>=0 && i<4); return pxrms[i];}
00226 float xgx0(int i) {assert(i>=0 && i<4); return pxgx0[i];}
00227 float xgsig(int i) {assert(i>=0 && i<4); return pxgsig[i];}
00228 float chi2yavg(int i) {assert(i>=0 && i<4); return pchi2yavg[i];}
00229 float chi2ymin(int i) {assert(i>=0 && i<4); return pchi2ymin[i];}
00230 float chi2xavg(int i) {assert(i>=0 && i<4); return pchi2xavg[i];}
00231 float chi2xmin(int i) {assert(i>=0 && i<4); return pchi2xmin[i];}
00232 float yavgc2m(int i) {assert(i>=0 && i<4); return pyavgc2m[i];}
00233 float yrmsc2m(int i) {assert(i>=0 && i<4); return pyrmsc2m[i];}
00234 float ygx0c2m(int i) {assert(i>=0 && i<4); return pygx0c2m[i];}
00235 float ygsigc2m(int i) {assert(i>=0 && i<4); return pygsigc2m[i];}
00236 float xavgc2m(int i) {assert(i>=0 && i<4); return pxavgc2m[i];}
00237 float xrmsc2m(int i) {assert(i>=0 && i<4); return pxrmsc2m[i];}
00238 float xgx0c2m(int i) {assert(i>=0 && i<4); return pxgx0c2m[i];}
00239 float xgsigc2m(int i) {assert(i>=0 && i<4); return pxgsigc2m[i];}
00240
00241
00242
00243
00244 private:
00245
00246
00247
00248 int id_current;
00249 int index_id;
00250 float cota_current;
00251 float cotb_current;
00252 float abs_cotb;
00253 bool fpix_current;
00254
00255
00256
00257
00258 float pqavg;
00259 float ppixmax;
00260 float pqscale;
00261 float ps50;
00262 float psymax;
00263 float psyparmax;
00264 float pdyone;
00265 float psyone;
00266 float pdytwo;
00267 float psytwo;
00268 float psxmax;
00269 float psxparmax;
00270 float pdxone;
00271 float psxone;
00272 float pdxtwo;
00273 float psxtwo;
00274 float pqmin;
00275 float pclsleny;
00276 float pclslenx;
00277 float pyratio;
00278 float pyparl[2][5];
00279 float pyparh[2][5];
00280 float pxparly0[2][5];
00281 float pxparhy0[2][5];
00282 float pytemp[9][BYSIZE];
00283 float pyxratio;
00284 float pxxratio;
00285 float pxpar0[2][5];
00286 float pxparl[2][5];
00287 float pxparh[2][5];
00288 float pxtemp[9][BXSIZE];
00289 float pyavg[4];
00290 float pyrms[4];
00291 float pygx0[4];
00292 float pygsig[4];
00293 float pyflparl[4][6];
00294 float pyflparh[4][6];
00295 float pxavg[4];
00296 float pxrms[4];
00297 float pxgx0[4];
00298 float pxgsig[4];
00299 float pxflparll[4][6];
00300 float pxflparlh[4][6];
00301 float pxflparhl[4][6];
00302 float pxflparhh[4][6];
00303 float pchi2yavg[4];
00304 float pchi2ymin[4];
00305 float pchi2xavg[4];
00306 float pchi2xmin[4];
00307 float pyavgc2m[4];
00308 float pyrmsc2m[4];
00309 float pygx0c2m[4];
00310 float pygsigc2m[4];
00311 float pxavgc2m[4];
00312 float pxrmsc2m[4];
00313 float pxgx0c2m[4];
00314 float pxgsigc2m[4];
00315 float pyspare[10];
00316 float pxspare[10];
00317
00318
00319
00320 std::vector< SiPixelTemplateStore > thePixelTemp;
00321 } ;
00322
00323
00324 #endif