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
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 #ifndef SiPixelTemplate_h
00066 #define SiPixelTemplate_h 1
00067
00068 #include "SiPixelTemplateDefs.h"
00069
00070 #include<vector>
00071 #include<cassert>
00072 #include "boost/multi_array.hpp"
00073
00074 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00075 #include "CondFormats/SiPixelObjects/interface/SiPixelTemplateDBObject.h"
00076 #include "FWCore/Utilities/interface/Exception.h"
00077 #endif
00078
00079 typedef boost::multi_array<float, 3> array_3d;
00080
00081 struct SiPixelTemplateEntry {
00082 int runnum;
00083 float alpha;
00084 float cotalpha;
00085 float beta;
00086 float cotbeta;
00087 float costrk[3];
00088 float qavg;
00089 float pixmax;
00090 float symax;
00091 float dyone;
00092 float syone;
00093 float sxmax;
00094 float dxone;
00095 float sxone;
00096 float dytwo;
00097 float sytwo;
00098 float dxtwo;
00099 float sxtwo;
00100 float qmin;
00101 float qmin2;
00102 float clsleny;
00103 float clslenx;
00104 float mpvvav;
00105 float sigmavav;
00106 float kappavav;
00107 float ypar[2][5];
00108 float ytemp[9][TYSIZE];
00109 float xpar[2][5];
00110 float xtemp[9][TXSIZE];
00111 float yavg[4];
00112 float yrms[4];
00113 float ygx0[4];
00114 float ygsig[4];
00115 float yflpar[4][6];
00116 float xavg[4];
00117 float xrms[4];
00118 float xgx0[4];
00119 float xgsig[4];
00120 float xflpar[4][6];
00121 float chi2yavg[4];
00122 float chi2ymin[4];
00123 float chi2xavg[4];
00124 float chi2xmin[4];
00125 float chi2yavgone;
00126 float chi2yminone;
00127 float chi2xavgone;
00128 float chi2xminone;
00129 float yavgc2m[4];
00130 float yrmsc2m[4];
00131 float ygx0c2m[4];
00132 float ygsigc2m[4];
00133 float xavgc2m[4];
00134 float xrmsc2m[4];
00135 float xgx0c2m[4];
00136 float xgsigc2m[4];
00137 float yavggen[4];
00138 float yrmsgen[4];
00139 float ygx0gen[4];
00140 float ygsiggen[4];
00141 float xavggen[4];
00142 float xrmsgen[4];
00143 float xgx0gen[4];
00144 float xgsiggen[4];
00145 float qbfrac[3];
00146 float fracyone;
00147 float fracxone;
00148 float fracytwo;
00149 float fracxtwo;
00150 float qavg_avg;
00151 float qavg_spare;
00152 float spare[4];
00153 } ;
00154
00155
00156
00157
00158 struct SiPixelTemplateHeader {
00159 char title[80];
00160 int ID;
00161 int templ_version;
00162 float Bfield;
00163 int NTy;
00164 int NTyx;
00165 int NTxx;
00166 int Dtype;
00167 float Vbias;
00168 float temperature;
00169 float fluence;
00170 float qscale;
00171 float s50;
00172 float lorywidth;
00173 float lorxwidth;
00174 float xsize;
00175 float ysize;
00176 float zsize;
00177 } ;
00178
00179
00180
00181 struct SiPixelTemplateStore {
00182 SiPixelTemplateHeader head;
00183 SiPixelTemplateEntry enty[60];
00184 SiPixelTemplateEntry entx[5][29];
00185 } ;
00186
00187
00188
00206
00207 class SiPixelTemplate {
00208 public:
00209 SiPixelTemplate() {id_current = -1; index_id = -1; cota_current = 0.; cotb_current = 0.;}
00210 bool pushfile(int filenum);
00211
00212
00213 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00214 bool pushfile(const SiPixelTemplateDBObject& dbobject);
00215 #endif
00216
00217
00218
00219 bool interpolate(int id, float cotalpha, float cotbeta, float locBz);
00220
00221
00222 bool interpolate(int id, float cotalpha, float cotbeta);
00223
00224
00225 void ytemp(int fybin, int lybin, float ytemplate[41][BYSIZE]);
00226
00227 void xtemp(int fxbin, int lxbin, float xtemplate[41][BXSIZE]);
00228
00229
00230 void ytemp3d(int nypix, array_3d& ytemplate);
00231
00232 void xtemp3d(int nxpix, array_3d& xtemplate);
00233
00234
00235 void ysigma2(int fypix, int lypix, float sythr, float ysum[BYSIZE], float ysig2[BYSIZE]);
00236
00237 void ysigma2(float qpixel, int index, float& ysig2);
00238
00239 void xsigma2(int fxpix, int lxpix, float sxthr, float xsum[BXSIZE], float xsig2[BXSIZE]);
00240
00241
00242 float yflcorr(int binq, float qfly);
00243
00244
00245 float xflcorr(int binq, float qflx);
00246
00247
00248 int qbin(int id, float cotalpha, float cotbeta, float locBz, float qclus, float& pixmx, float& sigmay, float& deltay, float& sigmax, float& deltax,
00249 float& sy1, float& dy1, float& sy2, float& dy2, float& sx1, float& dx1, float& sx2, float& dx2, float& lorywidth, float& lorxwidth);
00250
00251
00252 int qbin(int id, float cotalpha, float cotbeta, float locBz, float qclus, float& pixmx, float& sigmay, float& deltay, float& sigmax, float& deltax,
00253 float& sy1, float& dy1, float& sy2, float& dy2, float& sx1, float& dx1, float& sx2, float& dx2);
00254
00255
00256 int qbin(int id, float cotbeta, float qclus);
00257
00258
00259 void temperrors(int id, float cotalpha, float cotbeta, int qBin, float& sigmay, float& sigmax, float& sy1, float& sy2, float& sx1, float& sx2);
00260
00261
00262 void qbin_dist(int id, float cotalpha, float cotbeta, float qbin_frac[4], float& ny1_frac, float& ny2_frac, float& nx1_frac, float& nx2_frac);
00263
00264
00265 bool simpletemplate2D(float xhitp, float yhitp, std::vector<bool>& ydouble, std::vector<bool>& xdouble, float template2d[BXM2][BYM2]);
00266
00267
00268 void vavilov_pars(double& mpv, double& sigma, double& kappa);
00269
00270
00271 float qavg() {return pqavg;}
00272 float pixmax() {return ppixmax;}
00273 float qscale() {return pqscale;}
00274 float s50() {return ps50;}
00275 float symax() {return psymax;}
00276 float dyone() {return pdyone;}
00277 float syone() {return psyone;}
00278 float dytwo() {return pdytwo;}
00279 float sytwo() {return psytwo;}
00280 float sxmax() {return psxmax;}
00281 float dxone() {return pdxone;}
00282 float sxone() {return psxone;}
00283 float dxtwo() {return pdxtwo;}
00284 float sxtwo() {return psxtwo;}
00285 float qmin() {return pqmin;}
00286 float qmin(int i) {
00287 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00288 if(i < 0 || i > 1) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::qmin called with illegal index = " << i << std::endl;}
00289 #else
00290 assert(i>=0 && i<2);
00291 #endif
00292 if(i==0){return pqmin;}else{return pqmin2;}}
00293 float clsleny() {return pclsleny;}
00294 float clslenx() {return pclslenx;}
00295 float yratio() {return pyratio;}
00296 float yxratio() {return pyxratio;}
00297 float xxratio() {return pxxratio;}
00298 float yavg(int i) {
00299 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00300 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::yavg called with illegal index = " << i << std::endl;}
00301 #else
00302 assert(i>=0 && i<4);
00303 #endif
00304 return pyavg[i];}
00305 float yrms(int i) {
00306 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00307 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::yrms called with illegal index = " << i << std::endl;}
00308 #else
00309 assert(i>=0 && i<4);
00310 #endif
00311 return pyrms[i];}
00312 float ygx0(int i) {
00313 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00314 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::ygx0 called with illegal index = " << i << std::endl;}
00315 #else
00316 assert(i>=0 && i<4);
00317 #endif
00318 return pygx0[i];}
00319 float ygsig(int i) {
00320 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00321 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::ygsig called with illegal index = " << i << std::endl;}
00322 #else
00323 assert(i>=0 && i<4);
00324 #endif
00325 return pygsig[i];}
00326 float xavg(int i) {
00327 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00328 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::xavg called with illegal index = " << i << std::endl;}
00329 #else
00330 assert(i>=0 && i<4);
00331 #endif
00332 return pxavg[i];}
00333 float xrms(int i) {
00334 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00335 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::xrms called with illegal index = " << i << std::endl;}
00336 #else
00337 assert(i>=0 && i<4);
00338 #endif
00339 return pxrms[i];}
00340 float xgx0(int i) {
00341 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00342 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::xgx0 called with illegal index = " << i << std::endl;}
00343 #else
00344 assert(i>=0 && i<4);
00345 #endif
00346 return pxgx0[i];}
00347 float xgsig(int i) {
00348 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00349 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::xgsig called with illegal index = " << i << std::endl;}
00350 #else
00351 assert(i>=0 && i<4);
00352 #endif
00353 return pxgsig[i];}
00354 float chi2yavg(int i) {
00355 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00356 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::chi2yavg called with illegal index = " << i << std::endl;}
00357 #else
00358 assert(i>=0 && i<4);
00359 #endif
00360 return pchi2yavg[i];}
00361 float chi2ymin(int i) {
00362 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00363 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::chi2ymin called with illegal index = " << i << std::endl;}
00364 #else
00365 assert(i>=0 && i<4);
00366 #endif
00367 return pchi2ymin[i];}
00368 float chi2xavg(int i) {
00369 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00370 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::chi2xavg called with illegal index = " << i << std::endl;}
00371 #else
00372 assert(i>=0 && i<4);
00373 #endif
00374 return pchi2xavg[i];}
00375 float chi2xmin(int i) {
00376 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00377 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::chi2xmin called with illegal index = " << i << std::endl;}
00378 #else
00379 assert(i>=0 && i<4);
00380 #endif
00381 return pchi2xmin[i];}
00382 float yavgc2m(int i) {
00383 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00384 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::yavgc2m called with illegal index = " << i << std::endl;}
00385 #else
00386 assert(i>=0 && i<4);
00387 #endif
00388 return pyavgc2m[i];}
00389 float yrmsc2m(int i) {
00390 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00391 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::yrmsc2m called with illegal index = " << i << std::endl;}
00392 #else
00393 assert(i>=0 && i<4);
00394 #endif
00395 return pyrmsc2m[i];}
00396 float ygx0c2m(int i) {
00397 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00398 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::ygx0c2m called with illegal index = " << i << std::endl;}
00399 #else
00400 assert(i>=0 && i<4);
00401 #endif
00402 return pygx0c2m[i];}
00403 float ygsigc2m(int i) {
00404 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00405 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::ygsigc2m called with illegal index = " << i << std::endl;}
00406 #else
00407 assert(i>=0 && i<4);
00408 #endif
00409 return pygsigc2m[i];}
00410 float xavgc2m(int i) {
00411 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00412 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::xavgc2m called with illegal index = " << i << std::endl;}
00413 #else
00414 assert(i>=0 && i<4);
00415 #endif
00416 return pxavgc2m[i];}
00417 float xrmsc2m(int i) {
00418 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00419 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::xrmsc2m called with illegal index = " << i << std::endl;}
00420 #else
00421 assert(i>=0 && i<4);
00422 #endif
00423 return pxrmsc2m[i];}
00424 float xgx0c2m(int i) {
00425 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00426 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::xgx0cm2 called with illegal index = " << i << std::endl;}
00427 #else
00428 assert(i>=0 && i<4);
00429 #endif
00430 return pxgx0c2m[i];}
00431 float xgsigc2m(int i) {
00432 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00433 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::xgsigc2m called with illegal index = " << i << std::endl;}
00434 #else
00435 assert(i>=0 && i<4);
00436 #endif
00437 return pxgsigc2m[i];}
00438 float chi2yavgone() {return pchi2yavgone;}
00439 float chi2yminone() {return pchi2yminone;}
00440 float chi2xavgone() {return pchi2xavgone;}
00441 float chi2xminone() {return pchi2xminone;}
00442 float lorywidth() {return plorywidth;}
00443 float lorxwidth() {return plorxwidth;}
00444 float mpvvav() {return pmpvvav;}
00445 float sigmavav() {return psigmavav;}
00446 float kappavav() {return pkappavav;}
00447 float xsize() {return pxsize;}
00448 float ysize() {return pysize;}
00449 float zsize() {return pzsize;}
00450
00451
00452
00453
00454 private:
00455
00456
00457
00458 int id_current;
00459 int index_id;
00460 float cota_current;
00461 float cotb_current;
00462 float abs_cotb;
00463 bool success;
00464
00465
00466
00467
00468 float pqavg;
00469 float ppixmax;
00470 float pqscale;
00471 float ps50;
00472 float psymax;
00473 float psyparmax;
00474 float pdyone;
00475 float psyone;
00476 float pdytwo;
00477 float psytwo;
00478 float psxmax;
00479 float psxparmax;
00480 float pdxone;
00481 float psxone;
00482 float pdxtwo;
00483 float psxtwo;
00484 float pqmin;
00485 float pclsleny;
00486 float pclslenx;
00487 float pyratio;
00488 float pyparl[2][5];
00489 float pyparh[2][5];
00490 float pxparly0[2][5];
00491 float pxparhy0[2][5];
00492 float pytemp[9][BYSIZE];
00493 float pyxratio;
00494 float pxxratio;
00495 float pxpar0[2][5];
00496 float pxparl[2][5];
00497 float pxparh[2][5];
00498 float pxtemp[9][BXSIZE];
00499 float pyavg[4];
00500 float pyrms[4];
00501 float pygx0[4];
00502 float pygsig[4];
00503 float pyflparl[4][6];
00504 float pyflparh[4][6];
00505 float pxavg[4];
00506 float pxrms[4];
00507 float pxgx0[4];
00508 float pxgsig[4];
00509 float pxflparll[4][6];
00510 float pxflparlh[4][6];
00511 float pxflparhl[4][6];
00512 float pxflparhh[4][6];
00513 float pchi2yavg[4];
00514 float pchi2ymin[4];
00515 float pchi2xavg[4];
00516 float pchi2xmin[4];
00517 float pyavgc2m[4];
00518 float pyrmsc2m[4];
00519 float pygx0c2m[4];
00520 float pygsigc2m[4];
00521 float pxavgc2m[4];
00522 float pxrmsc2m[4];
00523 float pxgx0c2m[4];
00524 float pxgsigc2m[4];
00525 float pchi2yavgone;
00526 float pchi2yminone;
00527 float pchi2xavgone;
00528 float pchi2xminone;
00529 float pqmin2;
00530 float pmpvvav;
00531 float psigmavav;
00532 float pkappavav;
00533 float plorywidth;
00534 float plorxwidth;
00535 float pxsize;
00536 float pysize;
00537 float pzsize;
00538 float pqavg_avg;
00539
00540
00541
00542
00543 std::vector< SiPixelTemplateStore > thePixelTemp;
00544 } ;
00545
00546
00547 #endif