16 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
30 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
34 #define LOGERROR(x) LogError(x)
35 #define LOGINFO(x) LogInfo(x)
41 #define LOGERROR(x) std::cout << x << ": "
42 #define LOGINFO(x) std::cout << x << ": "
43 #define ENDL std::endl
57 int i,
j,
k,
l, iy, jx;
61 const int code_version={16};
67 std::ostringstream tout;
71 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
72 tout <<
"CalibTracker/SiPixelESProducers/data/template_summary2D_zp"
73 << std::setw(4) << std::setfill(
'0') << std::right << filenum <<
".out" << std::ends;
76 tempfile = (
file.fullPath()).c_str();
78 tout <<
"template_summary2D_zp" << std::setw(4) << std::setfill(
'0') << std::right << filenum <<
".out" << std::ends;
80 tempfile = tempf.c_str();
87 if(in_file.is_open()) {
95 for (i=0; (c=in_file.get()) !=
'\n'; ++
i) {
100 LOGINFO(
"SiPixelTemplate2D") <<
"Loading Pixel Template File - " << theCurrentTemp.
head.
title <<
ENDL;
108 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file, no template load" <<
ENDL;
return false;}
111 <<
", NTy = " << theCurrentTemp.
head.
NTy <<
", NTyx = " << theCurrentTemp.
head.
NTyx<<
", NTxx = " << theCurrentTemp.
head.
NTxx <<
", Dtype = " << theCurrentTemp.
head.
Dtype
112 <<
", Bias voltage " << theCurrentTemp.
head.
Vbias <<
", temperature "
114 <<
", 1/2 threshold " << theCurrentTemp.
head.
s50 <<
", y Lorentz Width " << theCurrentTemp.
head.
lorywidth <<
", x Lorentz width " << theCurrentTemp.
head.
lorxwidth
117 if(theCurrentTemp.
head.
templ_version != code_version) {
LOGERROR(
"SiPixelTemplate2D") <<
"code expects version " << code_version <<
", no template load" <<
ENDL;
return false;}
119 if(theCurrentTemp.
head.
NTy != 0) {
LOGERROR(
"SiPixelTemplate2D") <<
"Trying to load 1-d template info into the 2-d template object, check your DB/global tag!" <<
ENDL;
return false;}
127 for (iy=0; iy < theCurrentTemp.
head.
NTyx; ++iy) {
128 for(jx=0; jx < theCurrentTemp.
head.
NTxx; ++jx) {
130 in_file >> theCurrentTemp.
entry[iy][jx].runnum >> theCurrentTemp.
entry[iy][jx].costrk[0]
131 >> theCurrentTemp.
entry[iy][jx].costrk[1] >> theCurrentTemp.
entry[iy][jx].costrk[2];
133 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 1, no template load, run # " << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
return false;}
137 theCurrentTemp.
entry[iy][jx].cotalpha = theCurrentTemp.
entry[iy][jx].costrk[0]/theCurrentTemp.
entry[iy][jx].costrk[2];
139 theCurrentTemp.
entry[iy][jx].cotbeta = theCurrentTemp.
entry[iy][jx].costrk[1]/theCurrentTemp.
entry[iy][jx].costrk[2];
141 in_file >> theCurrentTemp.
entry[iy][jx].qavg >> theCurrentTemp.
entry[iy][jx].pixmax >> theCurrentTemp.
entry[iy][jx].sxymax >> theCurrentTemp.
entry[iy][jx].iymin
142 >> theCurrentTemp.
entry[iy][jx].iymax >> theCurrentTemp.
entry[iy][jx].jxmin >> theCurrentTemp.
entry[iy][jx].jxmax;
144 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 2, no template load, run # " << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
return false;}
146 for (k=0; k<2; ++
k) {
148 in_file >> theCurrentTemp.
entry[iy][jx].xypar[
k][0] >> theCurrentTemp.
entry[iy][jx].xypar[
k][1]
149 >> theCurrentTemp.
entry[iy][jx].xypar[
k][2] >> theCurrentTemp.
entry[iy][jx].xypar[
k][3] >> theCurrentTemp.
entry[iy][jx].xypar[
k][4];
151 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 3, no template load, run # " << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
return false;}
155 for (k=0; k<2; ++
k) {
157 in_file >> theCurrentTemp.
entry[iy][jx].lanpar[
k][0] >> theCurrentTemp.
entry[iy][jx].lanpar[
k][1]
158 >> theCurrentTemp.
entry[iy][jx].lanpar[
k][2] >> theCurrentTemp.
entry[iy][jx].lanpar[
k][3] >> theCurrentTemp.
entry[iy][jx].lanpar[
k][4];
160 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 4, no template load, run # " << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
return false;}
164 for (l=0; l<7; ++
l) {
165 for (k=0; k<7; ++
k) {
168 for (i=0; i<
T2YSIZE; ++
i) {in_file >> theCurrentTemp.
entry[iy][jx].xytemp[
k][
l][
i][
j];}
170 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 5, no template load, run # " << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
return false;}
176 in_file >> theCurrentTemp.
entry[iy][jx].chi2minone >> theCurrentTemp.
entry[iy][jx].chi2avgone >> theCurrentTemp.
entry[iy][jx].chi2min[0] >> theCurrentTemp.
entry[iy][jx].chi2avg[0]
177 >> theCurrentTemp.
entry[iy][jx].chi2min[1] >> theCurrentTemp.
entry[iy][jx].chi2avg[1]>> theCurrentTemp.
entry[iy][jx].chi2min[2] >> theCurrentTemp.
entry[iy][jx].chi2avg[2]
178 >> theCurrentTemp.
entry[iy][jx].chi2min[3] >> theCurrentTemp.
entry[iy][jx].chi2avg[3];
180 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 6, no template load, run # " << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
return false;}
182 in_file >> theCurrentTemp.
entry[iy][jx].spare[0] >> theCurrentTemp.
entry[iy][jx].spare[1] >> theCurrentTemp.
entry[iy][jx].spare[2] >> theCurrentTemp.
entry[iy][jx].spare[3]
183 >> theCurrentTemp.
entry[iy][jx].spare[4] >> theCurrentTemp.
entry[iy][jx].spare[5] >> theCurrentTemp.
entry[iy][jx].spare[6] >> theCurrentTemp.
entry[iy][jx].spare[7]
184 >> theCurrentTemp.
entry[iy][jx].spare[8] >> theCurrentTemp.
entry[iy][jx].spare[9];
186 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 7, no template load, run # " << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
return false;}
188 in_file >> theCurrentTemp.
entry[iy][jx].spare[10] >> theCurrentTemp.
entry[iy][jx].spare[11] >> theCurrentTemp.
entry[iy][jx].spare[12] >> theCurrentTemp.
entry[iy][jx].spare[13]
189 >> theCurrentTemp.
entry[iy][jx].spare[14] >> theCurrentTemp.
entry[iy][jx].spare[15] >> theCurrentTemp.
entry[iy][jx].spare[16] >> theCurrentTemp.
entry[iy][jx].spare[17]
190 >> theCurrentTemp.
entry[iy][jx].spare[18] >> theCurrentTemp.
entry[iy][jx].spare[19];
192 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 8, no template load, run # " << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
return false;}
202 thePixelTemp_.push_back(theCurrentTemp);
210 LOGERROR(
"SiPixelTemplate2D") <<
"Error opening File" << tempfile <<
ENDL;
218 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
230 int i,
j,
k,
l, iy, jx;
232 const int code_version={16};
247 for (i=0; i<20; ++
i) {
256 LOGINFO(
"SiPixelTemplate2D") <<
"Loading Pixel Template File - " << theCurrentTemp.
head.
title <<
ENDL;
264 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file, no template load" <<
ENDL;
return false;}
267 <<
", NTy = " << theCurrentTemp.
head.
NTy <<
", NTyx = " << theCurrentTemp.
head.
NTyx<<
", NTxx = " << theCurrentTemp.
head.
NTxx <<
", Dtype = " << theCurrentTemp.
head.
Dtype
268 <<
", Bias voltage " << theCurrentTemp.
head.
Vbias <<
", temperature "
270 <<
", 1/2 threshold " << theCurrentTemp.
head.
s50 <<
", y Lorentz Width " << theCurrentTemp.
head.
lorywidth <<
", x Lorentz width " << theCurrentTemp.
head.
lorxwidth
273 if(theCurrentTemp.
head.
templ_version != code_version) {
LOGERROR(
"SiPixelTemplate2D") <<
"code expects version " << code_version <<
", no template load" <<
ENDL;
return false;}
275 if(theCurrentTemp.
head.
NTy != 0) {
LOGERROR(
"SiPixelTemplate2D") <<
"Trying to load 1-d template info into the 2-d template object, check your DB/global tag!" <<
ENDL;
return false;}
283 for (iy=0; iy < theCurrentTemp.
head.
NTyx; ++iy) {
284 for(jx=0; jx < theCurrentTemp.
head.
NTxx; ++jx) {
286 db >> theCurrentTemp.
entry[iy][jx].runnum >> theCurrentTemp.
entry[iy][jx].costrk[0]
287 >> theCurrentTemp.
entry[iy][jx].costrk[1] >> theCurrentTemp.
entry[iy][jx].costrk[2];
289 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 1, no template load, run # " << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
return false;}
293 theCurrentTemp.
entry[iy][jx].cotalpha = theCurrentTemp.
entry[iy][jx].costrk[0]/theCurrentTemp.
entry[iy][jx].costrk[2];
295 theCurrentTemp.
entry[iy][jx].cotbeta = theCurrentTemp.
entry[iy][jx].costrk[1]/theCurrentTemp.
entry[iy][jx].costrk[2];
297 db >> theCurrentTemp.
entry[iy][jx].qavg >> theCurrentTemp.
entry[iy][jx].pixmax >> theCurrentTemp.
entry[iy][jx].sxymax >> theCurrentTemp.
entry[iy][jx].iymin
298 >> theCurrentTemp.
entry[iy][jx].iymax >> theCurrentTemp.
entry[iy][jx].jxmin >> theCurrentTemp.
entry[iy][jx].jxmax;
300 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 2, no template load, run # " << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
return false;}
302 for (k=0; k<2; ++
k) {
304 db >> theCurrentTemp.
entry[iy][jx].xypar[
k][0] >> theCurrentTemp.
entry[iy][jx].xypar[
k][1]
305 >> theCurrentTemp.
entry[iy][jx].xypar[
k][2] >> theCurrentTemp.
entry[iy][jx].xypar[
k][3] >> theCurrentTemp.
entry[iy][jx].xypar[
k][4];
307 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 3, no template load, run # " << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
return false;}
311 for (k=0; k<2; ++
k) {
313 db >> theCurrentTemp.
entry[iy][jx].lanpar[
k][0] >> theCurrentTemp.
entry[iy][jx].lanpar[
k][1]
314 >> theCurrentTemp.
entry[iy][jx].lanpar[
k][2] >> theCurrentTemp.
entry[iy][jx].lanpar[
k][3] >> theCurrentTemp.
entry[iy][jx].lanpar[
k][4];
316 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 4, no template load, run # " << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
return false;}
320 for (l=0; l<7; ++
l) {
321 for (k=0; k<7; ++
k) {
324 for (i=0; i<
T2YSIZE; ++
i) {db >> theCurrentTemp.
entry[iy][jx].xytemp[
k][
l][
i][
j];}
326 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 5, no template load, run # " << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
return false;}
332 db >> theCurrentTemp.
entry[iy][jx].chi2minone >> theCurrentTemp.
entry[iy][jx].chi2avgone >> theCurrentTemp.
entry[iy][jx].chi2min[0] >> theCurrentTemp.
entry[iy][jx].chi2avg[0]
333 >> theCurrentTemp.
entry[iy][jx].chi2min[1] >> theCurrentTemp.
entry[iy][jx].chi2avg[1]>> theCurrentTemp.
entry[iy][jx].chi2min[2] >> theCurrentTemp.
entry[iy][jx].chi2avg[2]
334 >> theCurrentTemp.
entry[iy][jx].chi2min[3] >> theCurrentTemp.
entry[iy][jx].chi2avg[3];
336 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 6, no template load, run # " << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
return false;}
338 db >> theCurrentTemp.
entry[iy][jx].spare[0] >> theCurrentTemp.
entry[iy][jx].spare[1] >> theCurrentTemp.
entry[iy][jx].spare[2] >> theCurrentTemp.
entry[iy][jx].spare[3]
339 >> theCurrentTemp.
entry[iy][jx].spare[4] >> theCurrentTemp.
entry[iy][jx].spare[5] >> theCurrentTemp.
entry[iy][jx].spare[6] >> theCurrentTemp.
entry[iy][jx].spare[7]
340 >> theCurrentTemp.
entry[iy][jx].spare[8] >> theCurrentTemp.
entry[iy][jx].spare[9];
342 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 7, no template load, run # " << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
return false;}
344 db >> theCurrentTemp.
entry[iy][jx].spare[10] >> theCurrentTemp.
entry[iy][jx].spare[11] >> theCurrentTemp.
entry[iy][jx].spare[12] >> theCurrentTemp.
entry[iy][jx].spare[13]
345 >> theCurrentTemp.
entry[iy][jx].spare[14] >> theCurrentTemp.
entry[iy][jx].spare[15] >> theCurrentTemp.
entry[iy][jx].spare[16] >> theCurrentTemp.
entry[iy][jx].spare[17]
346 >> theCurrentTemp.
entry[iy][jx].spare[18] >> theCurrentTemp.
entry[iy][jx].spare[19];
348 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 8, no template load, run # " << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
return false;}
358 thePixelTemp_.push_back(theCurrentTemp);
382 bool SiPixelTemplate2D::xytemp(
int id,
float cotalpha,
float cotbeta,
float locBz,
float xhit,
float yhit, std::vector<bool>& ydouble, std::vector<bool>& xdouble,
float template2d[
BXM2][
BYM2])
388 int pixx, pixy,
k0, k1, l0, l1, imidx, deltax, deltay, iflipy, imin, imax, jmin, jmax;
390 float acotb, dcota, dcotb, dx, dy, ddx, ddy, adx, ady, tmpxy;
393 std::vector <float> chi2xavg(4), chi2xmin(4);
398 if(
id != id_current_ || cotalpha != cota_current_ || cotbeta != cotb_current_) {
400 cota_current_ = cotalpha; cotb_current_ = cotbeta; success_ =
true;
402 if(
id != id_current_) {
407 for(i=0; i<(int)thePixelTemp_.size(); ++
i) {
409 if(
id == thePixelTemp_[i].head.ID) {
416 Dtype_ = thePixelTemp_[index_id_].head.Dtype;
420 qscale_ = thePixelTemp_[index_id_].head.qscale;
424 s50_ = thePixelTemp_[index_id_].head.s50;
428 lorywidth_ = thePixelTemp_[index_id_].head.lorywidth;
429 lorxwidth_ = thePixelTemp_[index_id_].head.lorxwidth;
433 xsize_ = thePixelTemp_[index_id_].head.xsize;
434 ysize_ = thePixelTemp_[index_id_].head.ysize;
435 zsize_ = thePixelTemp_[index_id_].head.zsize;
439 Nyx_ = thePixelTemp_[index_id_].head.NTyx;
440 Nxx_ = thePixelTemp_[index_id_].head.NTxx;
441 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
442 if(Nyx_ < 2 || Nxx_ < 2) {
443 throw cms::Exception(
"DataCorrupt") <<
"template ID = " << id_current_ <<
"has too few entries: Nyx/Nxx = " << Nyx_ <<
"/" << Nxx_ << std::endl;
446 assert(Nyx_ > 1 && Nxx_ > 1);
450 cotalpha0_ = thePixelTemp_[index_id_].entry[0][0].cotalpha;
451 cotalpha1_ = thePixelTemp_[index_id_].entry[0][Nxx_-1].cotalpha;
452 deltacota_ = (cotalpha1_-cotalpha0_)/(
float)(Nxx_-1);
454 cotbeta0_ = thePixelTemp_[index_id_].entry[0][imidx].cotbeta;
455 cotbeta1_ = thePixelTemp_[index_id_].entry[Nyx_-1][imidx].cotbeta;
456 deltacotb_ = (cotbeta1_-cotbeta0_)/(
float)(Nyx_-1);
464 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
465 if(index_id_ < 0 || index_id_ >= (
int)thePixelTemp_.size()) {
466 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate2D::interpolate can't find needed template ID = " <<
id
467 <<
", Are you using the correct global tag?" << std::endl;
470 assert(index_id_ >= 0 && index_id_ < (
int)thePixelTemp_.size());
475 if(cotalpha < cotalpha0_) {
480 }
else if(cotalpha > cotalpha1_) {
486 jx0_ = (int)((cotalpha-cotalpha0_)/deltacota_+0.5f);
487 dcota = (cotalpha - (cotalpha0_ + jx0_*deltacota_))/deltacota_;
488 adcota_ = fabs(dcota);
489 if(dcota > 0.
f) {jx1_ = jx0_ + 1;
if(jx1_ > Nxx_-1) jx1_ = jx0_-1;}
else {jx1_ = jx0_ - 1;
if(jx1_ < 0) jx1_ = jx0_+1;}
496 if(acotb < cotbeta0_) {
501 }
else if(acotb > cotbeta1_) {
507 iy0_ = (int)((acotb-cotbeta0_)/deltacotb_+0.5f);
508 dcotb = (acotb - (cotbeta0_ + iy0_*deltacotb_))/deltacotb_;
509 adcotb_ = fabs(dcotb);
510 if(dcotb > 0.
f) {iy1_ = iy0_ + 1;
if(iy1_ > Nyx_-1) iy1_ = iy0_-1;}
else {iy1_ = iy0_ - 1;
if(iy1_ < 0) iy1_ = iy0_+1;}
516 if(cotbeta < 0.
f) {flip_y =
true;}
521 if(cotbeta*locBz > 0.
f) success_ =
false;
526 qavg_ = thePixelTemp_[index_id_].entry[iy0_][jx0_].qavg
527 +adcota_*(thePixelTemp_[index_id_].entry[iy0_][jx1_].qavg - thePixelTemp_[index_id_].entry[iy0_][jx0_].qavg)
528 +adcotb_*(thePixelTemp_[index_id_].entry[iy1_][jx0_].qavg - thePixelTemp_[index_id_].entry[iy0_][jx0_].qavg);
530 pixmax_ = thePixelTemp_[index_id_].entry[iy0_][jx0_].pixmax
531 +adcota_*(thePixelTemp_[index_id_].entry[iy0_][jx1_].pixmax - thePixelTemp_[index_id_].entry[iy0_][jx0_].pixmax)
532 +adcotb_*(thePixelTemp_[index_id_].entry[iy1_][jx0_].pixmax - thePixelTemp_[index_id_].entry[iy0_][jx0_].pixmax);
534 sxymax_ = thePixelTemp_[index_id_].entry[iy0_][jx0_].sxymax
535 +adcota_*(thePixelTemp_[index_id_].entry[iy0_][jx1_].sxymax - thePixelTemp_[index_id_].entry[iy0_][jx0_].sxymax)
536 +adcotb_*(thePixelTemp_[index_id_].entry[iy1_][jx0_].sxymax - thePixelTemp_[index_id_].entry[iy0_][jx0_].sxymax);
538 chi2avgone_ = thePixelTemp_[index_id_].entry[iy0_][jx0_].chi2avgone
539 +adcota_*(thePixelTemp_[index_id_].entry[iy0_][jx1_].chi2avgone - thePixelTemp_[index_id_].entry[iy0_][jx0_].chi2avgone)
540 +adcotb_*(thePixelTemp_[index_id_].entry[iy1_][jx0_].chi2avgone - thePixelTemp_[index_id_].entry[iy0_][jx0_].chi2avgone);
542 chi2minone_ = thePixelTemp_[index_id_].entry[iy0_][jx0_].chi2minone
543 +adcota_*(thePixelTemp_[index_id_].entry[iy0_][jx1_].chi2minone - thePixelTemp_[index_id_].entry[iy0_][jx0_].chi2minone)
544 +adcotb_*(thePixelTemp_[index_id_].entry[iy1_][jx0_].chi2minone - thePixelTemp_[index_id_].entry[iy0_][jx0_].chi2minone);
546 for(i=0; i<4 ; ++
i) {
547 chi2avg_[
i] = thePixelTemp_[index_id_].entry[iy0_][jx0_].chi2avg[
i]
548 +adcota_*(thePixelTemp_[index_id_].entry[iy0_][jx1_].chi2avg[
i] - thePixelTemp_[index_id_].entry[iy0_][jx0_].chi2avg[
i])
549 +adcotb_*(thePixelTemp_[index_id_].entry[iy1_][jx0_].chi2avg[i] - thePixelTemp_[index_id_].entry[iy0_][jx0_].chi2avg[i]);
551 chi2min_[
i] = thePixelTemp_[index_id_].entry[iy0_][jx0_].chi2min[
i]
552 +adcota_*(thePixelTemp_[index_id_].entry[iy0_][jx1_].chi2min[
i] - thePixelTemp_[index_id_].entry[iy0_][jx0_].chi2min[
i])
553 +adcotb_*(thePixelTemp_[index_id_].entry[iy1_][jx0_].chi2min[i] - thePixelTemp_[index_id_].entry[iy0_][jx0_].chi2min[i]);
556 for(i=0; i<2 ; ++
i) {
557 for(j=0; j<5 ; ++
j) {
560 xypary0x0_[1-
i][
j] = thePixelTemp_[index_id_].entry[iy0_][jx0_].xypar[
i][
j];
561 xypary1x0_[1-
i][
j] = thePixelTemp_[index_id_].entry[iy1_][jx0_].xypar[
i][
j];
562 xypary0x1_[1-
i][
j] = thePixelTemp_[index_id_].entry[iy0_][jx1_].xypar[
i][
j];
563 lanpar_[1-
i][
j] = thePixelTemp_[index_id_].entry[iy0_][jx0_].lanpar[
i][
j]
564 +adcota_*(thePixelTemp_[index_id_].entry[iy0_][jx1_].lanpar[
i][
j] - thePixelTemp_[index_id_].entry[iy0_][jx0_].lanpar[
i][
j])
565 +adcotb_*(thePixelTemp_[index_id_].entry[iy1_][jx0_].lanpar[i][j] - thePixelTemp_[index_id_].entry[iy0_][jx0_].lanpar[i][j]);
567 xypary0x0_[
i][
j] = thePixelTemp_[index_id_].entry[iy0_][jx0_].xypar[
i][
j];
568 xypary1x0_[
i][
j] = thePixelTemp_[index_id_].entry[iy1_][jx0_].xypar[
i][
j];
569 xypary0x1_[
i][
j] = thePixelTemp_[index_id_].entry[iy0_][jx1_].xypar[
i][
j];
570 lanpar_[
i][
j] = thePixelTemp_[index_id_].entry[iy0_][jx0_].lanpar[
i][
j]
571 +adcota_*(thePixelTemp_[index_id_].entry[iy0_][jx1_].lanpar[
i][
j] - thePixelTemp_[index_id_].entry[iy0_][jx0_].lanpar[
i][
j])
572 +adcotb_*(thePixelTemp_[index_id_].entry[iy1_][jx0_].lanpar[i][j] - thePixelTemp_[index_id_].entry[iy0_][jx0_].lanpar[i][j]);
582 pixy = (int)floorf(yhit/ysize_);
583 dy = yhit-(pixy+0.5f)*ysize_;
584 if(flip_y) {dy = -dy;}
585 k0 = (int)(dy/ysize_*6.
f+3.5
f);
588 ddy = 6.f*dy/ysize_ - (k0-3);
590 if(ddy > 0.
f) {k1 = k0 + 1;
if(k1 > 6) k1 = k0-1;}
else {k1 = k0 - 1;
if(k1 < 0) k1 = k0+1;}
591 pixx = (int)floorf(xhit/xsize_);
592 dx = xhit-(pixx+0.5f)*xsize_;
593 l0 = (int)(dx/xsize_*6.
f+3.5
f);
596 ddx = 6.f*dx/xsize_ - (l0-3);
598 if(ddx > 0.
f) {l1 = l0 + 1;
if(l1 > 6) l1 = l0-1;}
else {l1 = l0 - 1;
if(l1 < 0) l1 = l0+1;}
604 imin =
std::min(thePixelTemp_[index_id_].entry[iy0_][jx0_].iymin,thePixelTemp_[index_id_].entry[iy1_][jx0_].iymin);
605 imin =
std::min(imin,thePixelTemp_[index_id_].entry[iy0_][jx1_].iymin);
607 jmin =
std::min(thePixelTemp_[index_id_].entry[iy0_][jx0_].jxmin,thePixelTemp_[index_id_].entry[iy1_][jx0_].jxmin);
608 jmin =
std::min(jmin,thePixelTemp_[index_id_].entry[iy0_][jx1_].jxmin);
610 imax =
std::max(thePixelTemp_[index_id_].entry[iy0_][jx0_].iymax,thePixelTemp_[index_id_].entry[iy1_][jx0_].iymax);
611 imax =
std::max(imax,thePixelTemp_[index_id_].entry[iy0_][jx1_].iymax);
613 jmax =
std::max(thePixelTemp_[index_id_].entry[iy0_][jx0_].jxmax,thePixelTemp_[index_id_].entry[iy1_][jx0_].jxmax);
614 jmax =
std::max(jmax,thePixelTemp_[index_id_].entry[iy0_][jx1_].jxmax);
624 deltax = pixx -
T2HX;
625 deltay = pixy -
T2HY;
629 for(j=0; j<
BXM2; ++
j) {
for(i=0; i<
BYM2; ++
i) {xytemp_[
j][
i] = 0.f;}}
633 for(j=jmin; j<=jmax; ++
j) {
634 for(i=imin; i<=imax; ++
i) {
639 if(flip_y) {iflipy=
T2YSIZE-1-
i; n = deltay+iflipy;}
else {n = deltay+
i;}
640 if(m>=0 && m<=BXM3 && n>=0 && n<=
BYM3) {
641 tmpxy = thePixelTemp_[index_id_].entry[iy0_][jx0_].xytemp[
k0][l0][
i][
j]
642 + adx*(thePixelTemp_[index_id_].entry[iy0_][jx0_].xytemp[
k0][l1][
i][
j] - thePixelTemp_[index_id_].entry[iy0_][jx0_].xytemp[
k0][l0][
i][
j])
643 + ady*(thePixelTemp_[index_id_].entry[iy0_][jx0_].xytemp[k1][l0][i][j] - thePixelTemp_[index_id_].entry[iy0_][jx0_].xytemp[k0][l0][i][j])
644 + adcota_*(thePixelTemp_[index_id_].entry[iy0_][jx1_].xytemp[
k0][l0][
i][
j] - thePixelTemp_[index_id_].entry[iy0_][jx0_].xytemp[
k0][l0][
i][
j])
645 + adcotb_*(thePixelTemp_[index_id_].entry[iy1_][jx0_].xytemp[k0][l0][i][j] - thePixelTemp_[index_id_].entry[iy0_][jx0_].xytemp[k0][l0][i][j]);
646 if(tmpxy > 0.
f) {xytemp_[
m][
n] = tmpxy;}
else {xytemp_[
m][
n] = 0.f;}
653 for(n=1; n<
BYM3; ++
n) {
656 for(m=1; m<
BXM3; ++
m) {
657 xytemp_[
m][
n] += xytemp_[
m][n+1];
660 for(i=n+1; i<
BYM3; ++
i) {
661 for(m=1; m<
BXM3; ++
m) {
662 xytemp_[
m][
i] = xytemp_[
m][i+1];
670 for(m=1; m<
BXM3; ++
m) {
673 for(n=1; n<
BYM3; ++
n) {
674 xytemp_[
m][
n] += xytemp_[m+1][
n];
677 for(j=m+1; j<
BXM3; ++
j) {
678 for(n=1; n<
BYM3; ++
n) {
679 xytemp_[
j][
n] = xytemp_[j+1][
n];
687 for(n=1; n<
BYM3; ++
n) {
688 for(m=1; m<
BXM3; ++
m) {
689 if(xytemp_[m][n] > 0.
f) {template2d[
m][
n] += xytemp_[
m][
n];}
710 bool SiPixelTemplate2D::xytemp(
int id,
float cotalpha,
float cotbeta,
float xhit,
float yhit, std::vector<bool>& ydouble, std::vector<bool>& xdouble,
float template2d[
BXM2][
BYM2])
716 if(cotbeta < 0.
f) {locBz = -locBz;}
737 float sigi, sigi2, sigi3, sigi4, qscale, err2, err00;
741 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
742 if(index < 2 || index >=
BYM2) {
743 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate2D::ysigma2 called with index = " << index << std::endl;
753 if(qpixel < sxymax_) {
758 qscale = qpixel/sxymax_;
760 sigi2 = sigi*sigi; sigi3 = sigi2*sigi; sigi4 = sigi3*sigi;
762 err00 = xypary0x0_[0][0]+xypary0x0_[0][1]*sigi+xypary0x0_[0][2]*sigi2+xypary0x0_[0][3]*sigi3+xypary0x0_[0][4]*sigi4;
764 +adcota_*(xypary0x1_[0][0]+xypary0x1_[0][1]*sigi+xypary0x1_[0][2]*sigi2+xypary0x1_[0][3]*sigi3+xypary0x1_[0][4]*sigi4 - err00)
765 +adcotb_*(xypary1x0_[0][0]+xypary1x0_[0][1]*sigi+xypary1x0_[0][2]*sigi2+xypary1x0_[0][3]*sigi3+xypary1x0_[0][4]*sigi4 - err00);
767 err00 = xypary0x0_[1][0]+xypary0x0_[1][1]*sigi+xypary0x0_[1][2]*sigi2+xypary0x0_[1][3]*sigi3+xypary0x0_[1][4]*sigi4;
769 +adcota_*(xypary0x1_[1][0]+xypary0x1_[1][1]*sigi+xypary0x1_[1][2]*sigi2+xypary0x1_[1][3]*sigi3+xypary0x1_[1][4]*sigi4 - err00)
770 +adcotb_*(xypary1x0_[1][0]+xypary1x0_[1][1]*sigi+xypary1x0_[1][2]*sigi2+xypary1x0_[1][3]*sigi3+xypary1x0_[1][4]*sigi4 - err00);
773 if(xysig2 <= 0.
f) {
LOGERROR(
"SiPixelTemplate2D") <<
"neg y-error-squared, id = " << id_current_ <<
", index = " << index_id_ <<
774 ", cot(alpha) = " << cota_current_ <<
", cot(beta) = " << cotb_current_ <<
", sigi = " << sigi <<
ENDL;}
793 lanpar[
i][
j] = lanpar_[
i][
j];
SiPixelTemplateHeader2D head
< template storage structure
void xysigma2(float qpixel, int index, float &xysig2)
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore2D > &thePixelTemp_)
boost::multi_array< SiPixelTemplateEntry2D, 2 > entry
use 2d entry to store [47][5] barrel entries or [5][9] fpix entries
Abs< T >::type abs(const T &t)
void incrementIndex(int i)
bool xytemp(int id, float cotalpha, float cotbeta, float locBz, float xhit, float yhit, std::vector< bool > &ydouble, std::vector< bool > &xdouble, float template2d[13+2][21+2])
void landau_par(float lanpar[2][5])
Return the Landau probability parameters for this set of cot(alpha, cot(beta)
std::vector< float > const & sVector() const