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
00066
00067
00068
00069
00070
00071
00072
00073 #ifndef SiPixelTemplate_h
00074 #define SiPixelTemplate_h 1
00075
00076 #include "SiPixelTemplateDefs.h"
00077
00078 #include<vector>
00079 #include<cassert>
00080 #include "boost/multi_array.hpp"
00081
00082 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00083 #include "CondFormats/SiPixelObjects/interface/SiPixelTemplateDBObject.h"
00084 #include "FWCore/Utilities/interface/Exception.h"
00085 #endif
00086
00087 struct SiPixelTemplateEntry {
00088 int runnum;
00089 float alpha;
00090 float cotalpha;
00091 float beta;
00092 float cotbeta;
00093 float costrk[3];
00094 float qavg;
00095 float pixmax;
00096 float symax;
00097 float dyone;
00098 float syone;
00099 float sxmax;
00100 float dxone;
00101 float sxone;
00102 float dytwo;
00103 float sytwo;
00104 float dxtwo;
00105 float sxtwo;
00106 float qmin;
00107 float qmin2;
00108 float clsleny;
00109 float clslenx;
00110 float mpvvav;
00111 float sigmavav;
00112 float kappavav;
00113 float mpvvav2;
00114 float sigmavav2;
00115 float kappavav2;
00116 float ypar[2][5];
00117 float ytemp[9][TYSIZE];
00118 float xpar[2][5];
00119 float xtemp[9][TXSIZE];
00120 float yavg[4];
00121 float yrms[4];
00122 float ygx0[4];
00123 float ygsig[4];
00124 float yflpar[4][6];
00125 float xavg[4];
00126 float xrms[4];
00127 float xgx0[4];
00128 float xgsig[4];
00129 float xflpar[4][6];
00130 float chi2yavg[4];
00131 float chi2ymin[4];
00132 float chi2xavg[4];
00133 float chi2xmin[4];
00134 float chi2yavgone;
00135 float chi2yminone;
00136 float chi2xavgone;
00137 float chi2xminone;
00138 float yavgc2m[4];
00139 float yrmsc2m[4];
00140 float chi2yavgc2m[4];
00141 float chi2yminc2m[4];
00142 float xavgc2m[4];
00143 float xrmsc2m[4];
00144 float chi2xavgc2m[4];
00145 float chi2xminc2m[4];
00146 float yavggen[4];
00147 float yrmsgen[4];
00148 float ygx0gen[4];
00149 float ygsiggen[4];
00150 float xavggen[4];
00151 float xrmsgen[4];
00152 float xgx0gen[4];
00153 float xgsiggen[4];
00154 float qbfrac[3];
00155 float fracyone;
00156 float fracxone;
00157 float fracytwo;
00158 float fracxtwo;
00159 float qavg_avg;
00160 float qavg_spare;
00161 float spare[1];
00162 } ;
00163
00164
00165
00166
00167 struct SiPixelTemplateHeader {
00168 char title[80];
00169 int ID;
00170 int templ_version;
00171 float Bfield;
00172 int NTy;
00173 int NTyx;
00174 int NTxx;
00175 int Dtype;
00176 float Vbias;
00177 float temperature;
00178 float fluence;
00179 float qscale;
00180 float s50;
00181 float lorywidth;
00182 float lorxwidth;
00183 float xsize;
00184 float ysize;
00185 float zsize;
00186 } ;
00187
00188
00189
00190 struct SiPixelTemplateStore {
00191 SiPixelTemplateHeader head;
00192 #ifndef SI_PIXEL_TEMPLATE_USE_BOOST
00193 SiPixelTemplateEntry enty[60];
00194 SiPixelTemplateEntry entx[5][29];
00195 #else
00196 boost::multi_array<SiPixelTemplateEntry,1> enty;
00197 boost::multi_array<SiPixelTemplateEntry,2> entx;
00198 #endif
00199 } ;
00200
00201
00202
00220
00221 class SiPixelTemplate {
00222 public:
00223 SiPixelTemplate() {id_current_ = -1; index_id_ = -1; cota_current_ = 0.; cotb_current_ = 0.;}
00224 bool pushfile(int filenum);
00225
00226
00227 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00228 bool pushfile(const SiPixelTemplateDBObject& dbobject);
00229 #endif
00230
00231
00232
00233 bool interpolate(int id, float cotalpha, float cotbeta, float locBz);
00234
00235
00236 bool interpolate(int id, float cotalpha, float cotbeta);
00237
00238
00239 void ytemp(int fybin, int lybin, float ytemplate[41][BYSIZE]);
00240
00241 void xtemp(int fxbin, int lxbin, float xtemplate[41][BXSIZE]);
00242
00243
00244 int cytemp();
00245
00246
00247 int cxtemp();
00248
00249
00250 void ytemp3d_int(int nypix, int& nybins);
00251
00252 void ytemp3d(int j, int k, std::vector<float>& ytemplate);
00253
00254 void xtemp3d_int(int nxpix, int& nxbins);
00255
00256 void xtemp3d(int j, int k, std::vector<float>& xtemplate);
00257
00258
00259 void ysigma2(int fypix, int lypix, float sythr, float ysum[BYSIZE], float ysig2[BYSIZE]);
00260
00261 void ysigma2(float qpixel, int index, float& ysig2);
00262
00263 void xsigma2(int fxpix, int lxpix, float sxthr, float xsum[BXSIZE], float xsig2[BXSIZE]);
00264
00265
00266 float yflcorr(int binq, float qfly);
00267
00268
00269 float xflcorr(int binq, float qflx);
00270
00271
00272 int qbin(int id, float cotalpha, float cotbeta, float locBz, float qclus, float& pixmx, float& sigmay, float& deltay, float& sigmax, float& deltax,
00273 float& sy1, float& dy1, float& sy2, float& dy2, float& sx1, float& dx1, float& sx2, float& dx2, float& lorywidth, float& lorxwidth);
00274
00275
00276 int qbin(int id, float cotalpha, float cotbeta, float locBz, float qclus, float& pixmx, float& sigmay, float& deltay, float& sigmax, float& deltax,
00277 float& sy1, float& dy1, float& sy2, float& dy2, float& sx1, float& dx1, float& sx2, float& dx2);
00278
00279
00280 int qbin(int id, float cotalpha, float cotbeta, float qclus);
00281
00282
00283 int qbin(int id, float cotbeta, float qclus);
00284
00285
00286 void temperrors(int id, float cotalpha, float cotbeta, int qBin, float& sigmay, float& sigmax, float& sy1, float& sy2, float& sx1, float& sx2);
00287
00288
00289 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);
00290
00291
00292 bool simpletemplate2D(float xhitp, float yhitp, std::vector<bool>& ydouble, std::vector<bool>& xdouble, float template2d[BXM2][BYM2]);
00293
00294
00295 void vavilov_pars(double& mpv, double& sigma, double& kappa);
00296
00297
00298 void vavilov2_pars(double& mpv, double& sigma, double& kappa);
00299
00300
00301 float qavg() {return qavg_;}
00302 float pixmax() {return pixmax_;}
00303 float qscale() {return qscale_;}
00304 float s50() {return s50_;}
00305 float symax() {return symax_;}
00306 float dyone() {return dyone_;}
00307 float syone() {return syone_;}
00308 float dytwo() {return dytwo_;}
00309 float sytwo() {return sytwo_;}
00310 float sxmax() {return sxmax_;}
00311 float dxone() {return dxone_;}
00312 float sxone() {return sxone_;}
00313 float dxtwo() {return dxtwo_;}
00314 float sxtwo() {return sxtwo_;}
00315 float qmin() {return qmin_;}
00316 float qmin(int i) {
00317 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00318 if(i < 0 || i > 1) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::qmin called with illegal index = " << i << std::endl;}
00319 #else
00320 assert(i>=0 && i<2);
00321 #endif
00322 if(i==0){return qmin_;}else{return qmin2_;}}
00323 float clsleny() {return clsleny_;}
00324 float clslenx() {return clslenx_;}
00325 float yratio() {return yratio_;}
00326 float yxratio() {return yxratio_;}
00327 float xxratio() {return xxratio_;}
00328 float yavg(int i) {
00329 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00330 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::yavg called with illegal index = " << i << std::endl;}
00331 #else
00332 assert(i>=0 && i<4);
00333 #endif
00334 return yavg_[i];}
00335 float yrms(int i) {
00336 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00337 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::yrms called with illegal index = " << i << std::endl;}
00338 #else
00339 assert(i>=0 && i<4);
00340 #endif
00341 return yrms_[i];}
00342 float ygx0(int i) {
00343 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00344 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::ygx0 called with illegal index = " << i << std::endl;}
00345 #else
00346 assert(i>=0 && i<4);
00347 #endif
00348 return ygx0_[i];}
00349 float ygsig(int i) {
00350 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00351 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::ygsig called with illegal index = " << i << std::endl;}
00352 #else
00353 assert(i>=0 && i<4);
00354 #endif
00355 return ygsig_[i];}
00356 float xavg(int i) {
00357 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00358 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::xavg called with illegal index = " << i << std::endl;}
00359 #else
00360 assert(i>=0 && i<4);
00361 #endif
00362 return xavg_[i];}
00363 float xrms(int i) {
00364 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00365 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::xrms called with illegal index = " << i << std::endl;}
00366 #else
00367 assert(i>=0 && i<4);
00368 #endif
00369 return xrms_[i];}
00370 float xgx0(int i) {
00371 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00372 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::xgx0 called with illegal index = " << i << std::endl;}
00373 #else
00374 assert(i>=0 && i<4);
00375 #endif
00376 return xgx0_[i];}
00377 float xgsig(int i) {
00378 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00379 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::xgsig called with illegal index = " << i << std::endl;}
00380 #else
00381 assert(i>=0 && i<4);
00382 #endif
00383 return xgsig_[i];}
00384 float chi2yavg(int i) {
00385 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00386 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::chi2yavg called with illegal index = " << i << std::endl;}
00387 #else
00388 assert(i>=0 && i<4);
00389 #endif
00390 return chi2yavg_[i];}
00391 float chi2ymin(int i) {
00392 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00393 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::chi2ymin called with illegal index = " << i << std::endl;}
00394 #else
00395 assert(i>=0 && i<4);
00396 #endif
00397 return chi2ymin_[i];}
00398 float chi2xavg(int i) {
00399 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00400 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::chi2xavg called with illegal index = " << i << std::endl;}
00401 #else
00402 assert(i>=0 && i<4);
00403 #endif
00404 return chi2xavg_[i];}
00405 float chi2xmin(int i) {
00406 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00407 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::chi2xmin called with illegal index = " << i << std::endl;}
00408 #else
00409 assert(i>=0 && i<4);
00410 #endif
00411 return chi2xmin_[i];}
00412 float yavgc2m(int i) {
00413 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00414 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::yavgc2m called with illegal index = " << i << std::endl;}
00415 #else
00416 assert(i>=0 && i<4);
00417 #endif
00418 return yavgc2m_[i];}
00419 float yrmsc2m(int i) {
00420 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00421 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::yrmsc2m called with illegal index = " << i << std::endl;}
00422 #else
00423 assert(i>=0 && i<4);
00424 #endif
00425 return yrmsc2m_[i];}
00426 float chi2yavgc2m(int i) {
00427 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00428 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::chi2yavgc2m called with illegal index = " << i << std::endl;}
00429 #else
00430 assert(i>=0 && i<4);
00431 #endif
00432 return chi2yavgc2m_[i];}
00433 float chi2yminc2m(int i) {
00434 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00435 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::chi2yminc2m called with illegal index = " << i << std::endl;}
00436 #else
00437 assert(i>=0 && i<4);
00438 #endif
00439 return chi2yminc2m_[i];}
00440 float xavgc2m(int i) {
00441 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00442 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::xavgc2m called with illegal index = " << i << std::endl;}
00443 #else
00444 assert(i>=0 && i<4);
00445 #endif
00446 return xavgc2m_[i];}
00447 float xrmsc2m(int i) {
00448 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00449 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::xrmsc2m called with illegal index = " << i << std::endl;}
00450 #else
00451 assert(i>=0 && i<4);
00452 #endif
00453 return xrmsc2m_[i];}
00454 float chi2xavgc2m(int i) {
00455 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00456 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::chi2xavgc2m called with illegal index = " << i << std::endl;}
00457 #else
00458 assert(i>=0 && i<4);
00459 #endif
00460 return chi2xavgc2m_[i];}
00461 float chi2xminc2m(int i) {
00462 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00463 if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate::chi2xminc2m called with illegal index = " << i << std::endl;}
00464 #else
00465 assert(i>=0 && i<4);
00466 #endif
00467 return chi2xminc2m_[i];}
00468 float chi2yavgone() {return chi2yavgone_;}
00469 float chi2yminone() {return chi2yminone_;}
00470 float chi2xavgone() {return chi2xavgone_;}
00471 float chi2xminone() {return chi2xminone_;}
00472 float lorywidth() {return lorywidth_;}
00473 float lorxwidth() {return lorxwidth_;}
00474 float mpvvav() {return mpvvav_;}
00475 float sigmavav() {return sigmavav_;}
00476 float kappavav() {return kappavav_;}
00477 float mpvvav2() {return mpvvav2_;}
00478 float sigmavav2() {return sigmavav2_;}
00479 float kappavav2() {return kappavav2_;}
00480 float xsize() {return xsize_;}
00481 float ysize() {return ysize_;}
00482 float zsize() {return zsize_;}
00483
00484
00485
00486
00487 private:
00488
00489
00490
00491 int id_current_;
00492 int index_id_;
00493 float cota_current_;
00494 float cotb_current_;
00495 float abs_cotb_;
00496 bool success_;
00497
00498
00499
00500
00501 float qavg_;
00502 float pixmax_;
00503 float qscale_;
00504 float s50_;
00505 float symax_;
00506 float syparmax_;
00507 float dyone_;
00508 float syone_;
00509 float dytwo_;
00510 float sytwo_;
00511 float sxmax_;
00512 float sxparmax_;
00513 float dxone_;
00514 float sxone_;
00515 float dxtwo_;
00516 float sxtwo_;
00517 float qmin_;
00518 float clsleny_;
00519 float clslenx_;
00520 float yratio_;
00521 float yparl_[2][5];
00522 float yparh_[2][5];
00523 float xparly0_[2][5];
00524 float xparhy0_[2][5];
00525 float ytemp_[9][BYSIZE];
00526 float yxratio_;
00527 float xxratio_;
00528 float xpar0_[2][5];
00529 float xparl_[2][5];
00530 float xparh_[2][5];
00531 float xtemp_[9][BXSIZE];
00532 float yavg_[4];
00533 float yrms_[4];
00534 float ygx0_[4];
00535 float ygsig_[4];
00536 float yflparl_[4][6];
00537 float yflparh_[4][6];
00538 float xavg_[4];
00539 float xrms_[4];
00540 float xgx0_[4];
00541 float xgsig_[4];
00542 float xflparll_[4][6];
00543 float xflparlh_[4][6];
00544 float xflparhl_[4][6];
00545 float xflparhh_[4][6];
00546 float chi2yavg_[4];
00547 float chi2ymin_[4];
00548 float chi2xavg_[4];
00549 float chi2xmin_[4];
00550 float yavgc2m_[4];
00551 float yrmsc2m_[4];
00552 float chi2yavgc2m_[4];
00553 float chi2yminc2m_[4];
00554 float xavgc2m_[4];
00555 float xrmsc2m_[4];
00556 float chi2xavgc2m_[4];
00557 float chi2xminc2m_[4];
00558 float chi2yavgone_;
00559 float chi2yminone_;
00560 float chi2xavgone_;
00561 float chi2xminone_;
00562 float qmin2_;
00563 float mpvvav_;
00564 float sigmavav_;
00565 float kappavav_;
00566 float mpvvav2_;
00567 float sigmavav2_;
00568 float kappavav2_;
00569 float lorywidth_;
00570 float lorxwidth_;
00571 float xsize_;
00572 float ysize_;
00573 float zsize_;
00574 float qavg_avg_;
00575 float nybins_;
00576 float nxbins_;
00577 boost::multi_array<float,2> temp2dy_;
00578 boost::multi_array<float,2> temp2dx_;
00579
00580
00581
00582
00583 std::vector< SiPixelTemplateStore > thePixelTemp_;
00584 } ;
00585
00586
00587 #endif