27 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 39 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 44 #define LOGERROR(x) LogError(x) 45 #define LOGINFO(x) LogInfo(x) 51 #define LOGERROR(x) std::cout << x << ": " 52 #define LOGINFO(x) std::cout << x << ": " 53 #define ENDL std::endl 66 const int code_version = {21};
73 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 75 int nzeros = 4 - tempfile.length();
80 tempfile =
dir +
"template_summary2D_zp" + tempfile +
".out";
82 tempfile =
file.fullPath();
86 std::ostringstream tout;
87 tout <<
"template_summary2D_zp" << std::setw(4) << std::setfill(
'0') << std::right << filenum <<
".out" << std::ends;
88 tempfile = tout.str();
94 std::ifstream
in_file(tempfile);
101 for (
int i = 0; (
c =
in_file.get()) !=
'\n'; ++
i) {
108 LOGINFO(
"SiPixelTemplate2D") <<
"Loading Pixel Template File - " << theCurrentTemp.
head.
title <<
ENDL;
119 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 0A, no template load" <<
ENDL;
128 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 0B, no template load" <<
ENDL;
137 theCurrentTemp.
head.
fbin[1] = 1.00f;
138 theCurrentTemp.
head.
fbin[2] = 0.85f;
141 LOGINFO(
"SiPixelTemplate2D") <<
"Template ID = " << theCurrentTemp.
head.
ID <<
", Template Version " 143 <<
", NTy = " << theCurrentTemp.
head.
NTy <<
", NTyx = " << theCurrentTemp.
head.
NTyx 144 <<
", NTxx = " << theCurrentTemp.
head.
NTxx <<
", Dtype = " << theCurrentTemp.
head.
Dtype 145 <<
", Bias voltage " << theCurrentTemp.
head.
Vbias <<
", temperature " 147 <<
", Q-scaling factor " << theCurrentTemp.
head.
qscale <<
", 1/2 multi dcol threshold " 148 << theCurrentTemp.
head.
s50 <<
", 1/2 single dcol threshold " 150 <<
", y Lorentz Bias " << theCurrentTemp.
head.
lorybias <<
", x Lorentz width " 152 <<
", Q/Q_avg fractions for Qbin defs " << theCurrentTemp.
head.
fbin[0] <<
", " 154 <<
", pixel x-size " << theCurrentTemp.
head.
xsize <<
", y-size " 158 LOGERROR(
"SiPixelTemplate2D") <<
"code expects version " << code_version <<
", no template load" <<
ENDL;
162 if (theCurrentTemp.
head.
NTy != 0) {
164 <<
"Trying to load 1-d template info into the 2-d template object, check your DB/global tag!" <<
ENDL;
176 for (
int iy = 0; iy < theCurrentTemp.
head.
NTyx; ++iy) {
177 for (
int jx = 0; jx < theCurrentTemp.
head.
NTxx; ++jx) {
178 in_file >> theCurrentTemp.
entry[iy][jx].runnum >> theCurrentTemp.
entry[iy][jx].costrk[0] >>
179 theCurrentTemp.
entry[iy][jx].costrk[1] >> theCurrentTemp.
entry[iy][jx].costrk[2];
182 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 1, no template load, run # " 183 << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
189 theCurrentTemp.
entry[iy][jx].cotalpha =
190 theCurrentTemp.
entry[iy][jx].costrk[0] / theCurrentTemp.
entry[iy][jx].costrk[2];
192 theCurrentTemp.
entry[iy][jx].cotbeta =
193 theCurrentTemp.
entry[iy][jx].costrk[1] / theCurrentTemp.
entry[iy][jx].costrk[2];
195 in_file >> theCurrentTemp.
entry[iy][jx].qavg >> theCurrentTemp.
entry[iy][jx].pixmax >>
196 theCurrentTemp.
entry[iy][jx].sxymax >> theCurrentTemp.
entry[iy][jx].iymin >>
197 theCurrentTemp.
entry[iy][jx].iymax >> theCurrentTemp.
entry[iy][jx].jxmin >>
198 theCurrentTemp.
entry[iy][jx].jxmax;
201 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 2, no template load, run # " 202 << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
206 for (
int k = 0;
k < 2; ++
k) {
207 in_file >> theCurrentTemp.
entry[iy][jx].xypar[
k][0] >> theCurrentTemp.
entry[iy][jx].xypar[
k][1] >>
208 theCurrentTemp.
entry[iy][jx].xypar[
k][2] >> theCurrentTemp.
entry[iy][jx].xypar[
k][3] >>
209 theCurrentTemp.
entry[iy][jx].xypar[
k][4];
213 <<
"Error reading file 3, no template load, run # " << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
218 for (
int k = 0;
k < 2; ++
k) {
219 in_file >> theCurrentTemp.
entry[iy][jx].lanpar[
k][0] >> theCurrentTemp.
entry[iy][jx].lanpar[
k][1] >>
220 theCurrentTemp.
entry[iy][jx].lanpar[
k][2] >> theCurrentTemp.
entry[iy][jx].lanpar[
k][3] >>
221 theCurrentTemp.
entry[iy][jx].lanpar[
k][4];
225 <<
"Error reading file 4, no template load, run # " << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
233 for (
int l = 0;
l < 7; ++
l) {
234 for (
int k = 0;
k < 7; ++
k) {
241 <<
"Error reading file 5, no template load, run # " << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
251 in_file >> theCurrentTemp.
entry[iy][jx].chi2ppix >> theCurrentTemp.
entry[iy][jx].chi2scale >>
252 theCurrentTemp.
entry[iy][jx].offsetx[0] >> theCurrentTemp.
entry[iy][jx].offsetx[1] >>
253 theCurrentTemp.
entry[iy][jx].offsetx[2] >> theCurrentTemp.
entry[iy][jx].offsetx[3] >>
254 theCurrentTemp.
entry[iy][jx].offsety[0] >> theCurrentTemp.
entry[iy][jx].offsety[1] >>
255 theCurrentTemp.
entry[iy][jx].offsety[2] >> theCurrentTemp.
entry[iy][jx].offsety[3];
258 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 6, no template load, run # " 259 << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
263 in_file >> theCurrentTemp.
entry[iy][jx].clsleny >> theCurrentTemp.
entry[iy][jx].clslenx >>
264 theCurrentTemp.
entry[iy][jx].mpvvav >> theCurrentTemp.
entry[iy][jx].sigmavav >>
265 theCurrentTemp.
entry[iy][jx].kappavav >> theCurrentTemp.
entry[iy][jx].scalexavg >>
266 theCurrentTemp.
entry[iy][jx].scaleyavg >> theCurrentTemp.
entry[iy][jx].delyavg >>
267 theCurrentTemp.
entry[iy][jx].delysig >> theCurrentTemp.
entry[iy][jx].spare[0];
270 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 7, no template load, run # " 271 << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
275 in_file >> theCurrentTemp.
entry[iy][jx].scalex[0] >> theCurrentTemp.
entry[iy][jx].scalex[1] >>
276 theCurrentTemp.
entry[iy][jx].scalex[2] >> theCurrentTemp.
entry[iy][jx].scalex[3] >>
277 theCurrentTemp.
entry[iy][jx].scaley[0] >> theCurrentTemp.
entry[iy][jx].scaley[1] >>
278 theCurrentTemp.
entry[iy][jx].scaley[2] >> theCurrentTemp.
entry[iy][jx].scaley[3] >>
279 theCurrentTemp.
entry[iy][jx].spare[1] >> theCurrentTemp.
entry[iy][jx].spare[2];
282 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 8, no template load, run # " 283 << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
293 pixelTemp.push_back(theCurrentTemp);
300 LOGERROR(
"SiPixelTemplate2D") <<
"Error opening File" << tempfile <<
ENDL;
306 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 314 std::vector<SiPixelTemplateStore2D>& pixelTemp) {
317 const int code_version = {21};
326 for (
int m = 0;
m <
db.numOfTempl(); ++
m) {
330 for (
int i = 0;
i < 20; ++
i) {
336 db.incrementIndex(1);
339 LOGINFO(
"SiPixelTemplate2D") <<
"Loading Pixel Template File - " << theCurrentTemp.
head.
title <<
ENDL;
351 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 0A, no template load" <<
ENDL;
355 LOGINFO(
"SiPixelTemplate2D") <<
"Loading Pixel Template File - " << theCurrentTemp.
head.
title 356 <<
" code version = " << code_version <<
" object version " 364 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 0B, no template load" <<
ENDL;
372 theCurrentTemp.
head.
fbin[0] = 1.50f;
373 theCurrentTemp.
head.
fbin[1] = 1.00f;
374 theCurrentTemp.
head.
fbin[2] = 0.85f;
377 LOGINFO(
"SiPixelTemplate2D") <<
"Template ID = " << theCurrentTemp.
head.
ID <<
", Template Version " 379 <<
", NTy = " << theCurrentTemp.
head.
NTy <<
", NTyx = " << theCurrentTemp.
head.
NTyx 380 <<
", NTxx = " << theCurrentTemp.
head.
NTxx <<
", Dtype = " << theCurrentTemp.
head.
Dtype 381 <<
", Bias voltage " << theCurrentTemp.
head.
Vbias <<
", temperature " 383 <<
", Q-scaling factor " << theCurrentTemp.
head.
qscale <<
", 1/2 multi dcol threshold " 384 << theCurrentTemp.
head.
s50 <<
", 1/2 single dcol threshold " 386 <<
", y Lorentz Bias " << theCurrentTemp.
head.
lorybias <<
", x Lorentz width " 388 <<
", Q/Q_avg fractions for Qbin defs " << theCurrentTemp.
head.
fbin[0] <<
", " 390 <<
", pixel x-size " << theCurrentTemp.
head.
xsize <<
", y-size " 394 LOGINFO(
"SiPixelTemplate2D") <<
"code expects version " << code_version <<
" finds " 398 if (theCurrentTemp.
head.
NTy != 0) {
400 <<
"Trying to load 1-d template info into the 2-d template object, check your DB/global tag!" <<
ENDL;
412 for (
int iy = 0; iy < theCurrentTemp.
head.
NTyx; ++iy) {
413 for (
int jx = 0; jx < theCurrentTemp.
head.
NTxx; ++jx) {
414 db >> theCurrentTemp.
entry[iy][jx].runnum >> theCurrentTemp.
entry[iy][jx].costrk[0] >>
415 theCurrentTemp.
entry[iy][jx].costrk[1] >> theCurrentTemp.
entry[iy][jx].costrk[2];
418 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 1, no template load, run # " 419 << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
425 theCurrentTemp.
entry[iy][jx].cotalpha =
426 theCurrentTemp.
entry[iy][jx].costrk[0] / theCurrentTemp.
entry[iy][jx].costrk[2];
428 theCurrentTemp.
entry[iy][jx].cotbeta =
429 theCurrentTemp.
entry[iy][jx].costrk[1] / theCurrentTemp.
entry[iy][jx].costrk[2];
431 db >> theCurrentTemp.
entry[iy][jx].qavg >> theCurrentTemp.
entry[iy][jx].pixmax >>
432 theCurrentTemp.
entry[iy][jx].sxymax >> theCurrentTemp.
entry[iy][jx].iymin >>
433 theCurrentTemp.
entry[iy][jx].iymax >> theCurrentTemp.
entry[iy][jx].jxmin >>
434 theCurrentTemp.
entry[iy][jx].jxmax;
437 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 2, no template load, run # " 438 << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
442 for (
int k = 0;
k < 2; ++
k) {
443 db >> theCurrentTemp.
entry[iy][jx].xypar[
k][0] >> theCurrentTemp.
entry[iy][jx].xypar[
k][1] >>
444 theCurrentTemp.
entry[iy][jx].xypar[
k][2] >> theCurrentTemp.
entry[iy][jx].xypar[
k][3] >>
445 theCurrentTemp.
entry[iy][jx].xypar[
k][4];
449 <<
"Error reading file 3, no template load, run # " << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
454 for (
int k = 0;
k < 2; ++
k) {
455 db >> theCurrentTemp.
entry[iy][jx].lanpar[
k][0] >> theCurrentTemp.
entry[iy][jx].lanpar[
k][1] >>
456 theCurrentTemp.
entry[iy][jx].lanpar[
k][2] >> theCurrentTemp.
entry[iy][jx].lanpar[
k][3] >>
457 theCurrentTemp.
entry[iy][jx].lanpar[
k][4];
461 <<
"Error reading file 4, no template load, run # " << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
469 for (
int l = 0;
l < 7; ++
l) {
470 for (
int k = 0;
k < 7; ++
k) {
477 <<
"Error reading file 5, no template load, run # " << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
487 db >> theCurrentTemp.
entry[iy][jx].chi2ppix >> theCurrentTemp.
entry[iy][jx].chi2scale >>
488 theCurrentTemp.
entry[iy][jx].offsetx[0] >> theCurrentTemp.
entry[iy][jx].offsetx[1] >>
489 theCurrentTemp.
entry[iy][jx].offsetx[2] >> theCurrentTemp.
entry[iy][jx].offsetx[3] >>
490 theCurrentTemp.
entry[iy][jx].offsety[0] >> theCurrentTemp.
entry[iy][jx].offsety[1] >>
491 theCurrentTemp.
entry[iy][jx].offsety[2] >> theCurrentTemp.
entry[iy][jx].offsety[3];
494 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 6, no template load, run # " 495 << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
499 db >> theCurrentTemp.
entry[iy][jx].clsleny >> theCurrentTemp.
entry[iy][jx].clslenx >>
500 theCurrentTemp.
entry[iy][jx].mpvvav >> theCurrentTemp.
entry[iy][jx].sigmavav >>
501 theCurrentTemp.
entry[iy][jx].kappavav >> theCurrentTemp.
entry[iy][jx].scalexavg >>
502 theCurrentTemp.
entry[iy][jx].scaleyavg >> theCurrentTemp.
entry[iy][jx].delyavg >>
503 theCurrentTemp.
entry[iy][jx].delysig >> theCurrentTemp.
entry[iy][jx].spare[0];
506 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 7, no template load, run # " 507 << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
511 db >> theCurrentTemp.
entry[iy][jx].scalex[0] >> theCurrentTemp.
entry[iy][jx].scalex[1] >>
512 theCurrentTemp.
entry[iy][jx].scalex[2] >> theCurrentTemp.
entry[iy][jx].scalex[3] >>
513 theCurrentTemp.
entry[iy][jx].scaley[0] >> theCurrentTemp.
entry[iy][jx].scaley[1] >>
514 theCurrentTemp.
entry[iy][jx].scaley[2] >> theCurrentTemp.
entry[iy][jx].scaley[3] >>
515 theCurrentTemp.
entry[iy][jx].spare[1] >> theCurrentTemp.
entry[iy][jx].spare[2];
518 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 8, no template load, run # " 519 << theCurrentTemp.
entry[iy][jx].runnum <<
ENDL;
527 pixelTemp.push_back(theCurrentTemp);
537 if (
id != id_current_) {
541 for (
int i = 0;
i < (
int)thePixelTemp_.size(); ++
i) {
542 if (
id == thePixelTemp_[
i].head.ID) {
548 Dtype_ = thePixelTemp_[index_id_].head.Dtype;
552 qscale_ = thePixelTemp_[index_id_].head.qscale;
556 s50_ = thePixelTemp_[index_id_].head.s50;
560 for (
int j = 0;
j < 3; ++
j) {
561 fbin_[
j] = thePixelTemp_[index_id_].head.fbin[
j];
566 lorywidth_ = thePixelTemp_[index_id_].head.lorywidth;
567 lorxwidth_ = thePixelTemp_[index_id_].head.lorxwidth;
571 xsize_ = thePixelTemp_[index_id_].head.xsize;
572 ysize_ = thePixelTemp_[index_id_].head.ysize;
573 zsize_ = thePixelTemp_[index_id_].head.zsize;
577 Nyx_ = thePixelTemp_[index_id_].head.NTyx;
578 Nxx_ = thePixelTemp_[index_id_].head.NTxx;
579 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 580 if (Nyx_ < 2 || Nxx_ < 2) {
581 throw cms::Exception(
"DataCorrupt") <<
"template ID = " << id_current_
582 <<
"has too few entries: Nyx/Nxx = " << Nyx_ <<
"/" << Nxx_ << std::endl;
585 assert(Nyx_ > 1 && Nxx_ > 1);
587 int imidx = Nxx_ / 2;
589 cotalpha0_ = thePixelTemp_[index_id_].entry[0][0].cotalpha;
590 cotalpha1_ = thePixelTemp_[index_id_].entry[0][Nxx_ - 1].cotalpha;
591 deltacota_ = (cotalpha1_ - cotalpha0_) / (
float)(Nxx_ - 1);
593 cotbeta0_ = thePixelTemp_[index_id_].entry[0][imidx].cotbeta;
594 cotbeta1_ = thePixelTemp_[index_id_].entry[Nyx_ - 1][imidx].cotbeta;
595 deltacotb_ = (cotbeta1_ - cotbeta0_) / (
float)(Nyx_ - 1);
602 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 603 if (index_id_ < 0 || index_id_ >= (
int)thePixelTemp_.size()) {
604 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate2D::interpolate can't find needed template ID = " <<
id 605 <<
", Are you using the correct global tag?" << std::endl;
608 assert(index_id_ >= 0 && index_id_ < (
int)thePixelTemp_.size());
637 float acotb, dcota, dcotb;
641 if (
id != id_current_ || cotalpha != cota_current_ || cotbeta != cotb_current_) {
642 cota_current_ = cotalpha;
643 cotb_current_ = cotbeta;
645 success_ = getid(
id);
648 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 649 if (index_id_ < 0 || index_id_ >= (
int)thePixelTemp_.size()) {
650 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate2D::interpolate can't find needed template ID = " <<
id 651 <<
", Are you using the correct global tag?" << std::endl;
654 assert(index_id_ >= 0 && index_id_ < (
int)thePixelTemp_.size());
659 float cota = cotalpha;
677 if (locBx * locBz < 0.
f) {
686 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 688 <<
"SiPixelTemplate2D::illegal subdetector ID = " << thePixelTemp_[index_id_].head.Dtype << std::endl;
690 std::cout <<
"SiPixelTemplate:2D:illegal subdetector ID = " << thePixelTemp_[index_id_].head.Dtype << std::endl;
694 if (cota < cotalpha0_) {
699 }
else if (cota > cotalpha1_) {
705 jx0_ = (
int)((cota - cotalpha0_) / deltacota_ + 0.5f);
706 dcota = (cota - (cotalpha0_ + jx0_ * deltacota_)) / deltacota_;
707 adcota_ = fabs(dcota);
723 if (acotb < cotbeta0_) {
728 }
else if (acotb > cotbeta1_) {
734 iy0_ = (
int)((acotb - cotbeta0_) / deltacotb_ + 0.5f);
735 dcotb = (acotb - (cotbeta0_ + iy0_ * deltacotb_)) / deltacotb_;
736 adcotb_ = fabs(dcotb);
750 lorydrift_ = lorywidth_ / 2.;
752 lorydrift_ = -lorydrift_;
753 lorxdrift_ = lorxwidth_ / 2.;
755 lorxdrift_ = -lorxdrift_;
759 entry00_ = &thePixelTemp_[index_id_].entry[iy0_][jx0_];
760 entry10_ = &thePixelTemp_[index_id_].entry[iy1_][jx0_];
761 entry01_ = &thePixelTemp_[index_id_].entry[iy0_][jx1_];
765 qavg_ = entry00_->qavg + adcota_ * (entry01_->qavg - entry00_->qavg) + adcotb_ * (entry10_->qavg - entry00_->qavg);
767 pixmax_ = entry00_->pixmax + adcota_ * (entry01_->pixmax - entry00_->pixmax) +
768 adcotb_ * (entry10_->pixmax - entry00_->pixmax);
770 sxymax_ = entry00_->sxymax + adcota_ * (entry01_->sxymax - entry00_->sxymax) +
771 adcotb_ * (entry10_->sxymax - entry00_->sxymax);
773 chi2avgone_ = entry00_->chi2avgone + adcota_ * (entry01_->chi2avgone - entry00_->chi2avgone) +
774 adcotb_ * (entry10_->chi2avgone - entry00_->chi2avgone);
776 chi2minone_ = entry00_->chi2minone + adcota_ * (entry01_->chi2minone - entry00_->chi2minone) +
777 adcotb_ * (entry10_->chi2minone - entry00_->chi2minone);
779 clsleny_ = entry00_->clsleny + adcota_ * (entry01_->clsleny - entry00_->clsleny) +
780 adcotb_ * (entry10_->clsleny - entry00_->clsleny);
782 clslenx_ = entry00_->clslenx + adcota_ * (entry01_->clslenx - entry00_->clslenx) +
783 adcotb_ * (entry10_->clslenx - entry00_->clslenx);
785 chi2ppix_ = entry00_->chi2ppix + adcota_ * (entry01_->chi2ppix - entry00_->chi2ppix) +
786 adcotb_ * (entry10_->chi2ppix - entry00_->chi2ppix);
788 chi2scale_ = entry00_->chi2scale + adcota_ * (entry01_->chi2scale - entry00_->chi2scale) +
789 adcotb_ * (entry10_->chi2scale - entry00_->chi2scale);
791 scaleyavg_ = entry00_->scaleyavg + adcota_ * (entry01_->scaleyavg - entry00_->scaleyavg) +
792 adcotb_ * (entry10_->scaleyavg - entry00_->scaleyavg);
794 scalexavg_ = entry00_->scalexavg + adcota_ * (entry01_->scalexavg - entry00_->scalexavg) +
795 adcotb_ * (entry10_->scalexavg - entry00_->scalexavg);
797 delyavg_ = entry00_->delyavg + adcota_ * (entry01_->delyavg - entry00_->delyavg) +
798 adcotb_ * (entry10_->delyavg - entry00_->delyavg);
800 delysig_ = entry00_->delysig + adcota_ * (entry01_->delysig - entry00_->delysig) +
801 adcotb_ * (entry10_->delysig - entry00_->delysig);
803 mpvvav_ = entry00_->mpvvav + adcota_ * (entry01_->mpvvav - entry00_->mpvvav) +
804 adcotb_ * (entry10_->mpvvav - entry00_->mpvvav);
806 sigmavav_ = entry00_->sigmavav + adcota_ * (entry01_->sigmavav - entry00_->sigmavav) +
807 adcotb_ * (entry10_->sigmavav - entry00_->sigmavav);
809 kappavav_ = entry00_->kappavav + adcota_ * (entry01_->kappavav - entry00_->kappavav) +
810 adcotb_ * (entry10_->kappavav - entry00_->kappavav);
812 for (
int i = 0;
i < 4; ++
i) {
813 scalex_[
i] = entry00_->scalex[
i] + adcota_ * (entry01_->scalex[
i] - entry00_->scalex[
i]) +
814 adcotb_ * (entry10_->scalex[
i] - entry00_->scalex[
i]);
816 scaley_[
i] = entry00_->scaley[
i] + adcota_ * (entry01_->scaley[
i] - entry00_->scaley[
i]) +
817 adcotb_ * (entry10_->scaley[
i] - entry00_->scaley[
i]);
819 offsetx_[
i] = entry00_->offsetx[
i] + adcota_ * (entry01_->offsetx[
i] - entry00_->offsetx[
i]) +
820 adcotb_ * (entry10_->offsetx[
i] - entry00_->offsetx[
i]);
822 offsetx_[
i] = -offsetx_[
i];
824 offsety_[
i] = entry00_->offsety[
i] + adcota_ * (entry01_->offsety[
i] - entry00_->offsety[
i]) +
825 adcotb_ * (entry10_->offsety[
i] - entry00_->offsety[
i]);
827 offsety_[
i] = -offsety_[
i];
830 for (
int i = 0;
i < 2; ++
i) {
831 for (
int j = 0;
j < 5; ++
j) {
834 xypary0x0_[1 -
i][
j] = (
float)entry00_->xypar[
i][
j];
835 xypary1x0_[1 -
i][
j] = (
float)entry10_->xypar[
i][
j];
836 xypary0x1_[1 -
i][
j] = (
float)entry01_->xypar[
i][
j];
837 lanpar_[1 -
i][
j] = entry00_->lanpar[
i][
j] + adcota_ * (entry01_->lanpar[
i][
j] - entry00_->lanpar[
i][
j]) +
838 adcotb_ * (entry10_->lanpar[
i][
j] - entry00_->lanpar[
i][
j]);
840 xypary0x0_[
i][
j] = (
float)entry00_->xypar[
i][
j];
841 xypary1x0_[
i][
j] = (
float)entry10_->xypar[
i][
j];
842 xypary0x1_[
i][
j] = (
float)entry01_->xypar[
i][
j];
843 lanpar_[
i][
j] = entry00_->lanpar[
i][
j] + adcota_ * (entry01_->lanpar[
i][
j] - entry00_->lanpar[
i][
j]) +
844 adcotb_ * (entry10_->lanpar[
i][
j] - entry00_->lanpar[
i][
j]);
860 #ifdef SI_PIXEL_TEMPLATE_STANDALONE 885 for (
int i = 0;
i < 3; ++
i) {
896 qavg_ = entry00_->qavg;
898 pixmax_ = entry00_->pixmax;
900 sxymax_ = entry00_->sxymax;
902 clsleny_ = entry00_->clsleny;
904 clslenx_ = entry00_->clslenx;
914 for (
int i = 0;
i < 4; ++
i) {
925 float cotbeta = entry00_->cotbeta;
941 if (locBx * locBz < 0.
f) {
949 std::cout <<
"SiPixelTemplate:2D:illegal subdetector ID = " << iDtype << std::endl;
954 lorydrift_ = lorywidth_ / 2.;
956 lorydrift_ = -lorydrift_;
957 lorxdrift_ = lorxwidth_ / 2.;
959 lorxdrift_ = -lorxdrift_;
961 for (
int i = 0;
i < 2; ++
i) {
962 for (
int j = 0;
j < 5; ++
j) {
965 xypary0x0_[1 -
i][
j] = (
float)entry00_->xypar[
i][
j];
966 xypary1x0_[1 -
i][
j] = (
float)entry00_->xypar[
i][
j];
967 xypary0x1_[1 -
i][
j] = (
float)entry00_->xypar[
i][
j];
968 lanpar_[1 -
i][
j] = entry00_->lanpar[
i][
j];
970 xypary0x0_[
i][
j] = (
float)entry00_->xypar[
i][
j];
971 xypary1x0_[
i][
j] = (
float)entry00_->xypar[
i][
j];
972 xypary0x1_[
i][
j] = (
float)entry00_->xypar[
i][
j];
973 lanpar_[
i][
j] = entry00_->lanpar[
i][
j];
1000 int pixx, pixy,
k0, k1, l0, l1, deltax, deltay, iflipy, jflipx, imin, imax, jmin, jmax;
1002 float dx,
dy, ddx, ddy, adx, ady;
1004 const float deltaxy[2] = {16.67f, 25.0f};
1013 pixy = (
int)floorf(yhit / ysize_);
1014 dy = yhit - (pixy + 0.5f) * ysize_;
1023 ddy = 6.f *
dy / ysize_ - (
k0 - 3);
1034 pixx = (
int)floorf(xhit / xsize_);
1035 dx = xhit - (pixx + 0.5f) * xsize_;
1039 l0 = (
int)(
dx / xsize_ * 6.
f + 3.5
f);
1044 ddx = 6.f *
dx / xsize_ - (l0 - 3);
1060 imin =
std::min(entry00_->iymin, entry10_->iymin);
1061 imin_ =
std::min(imin, entry01_->iymin);
1063 jmin =
std::min(entry00_->jxmin, entry10_->jxmin);
1064 jmin_ =
std::min(jmin, entry01_->jxmin);
1066 imax =
std::max(entry00_->iymax, entry10_->iymax);
1067 imax_ =
std::max(imax, entry01_->iymax);
1069 jmax =
std::max(entry00_->jxmax, entry10_->jxmax);
1070 jmax_ =
std::max(jmax, entry01_->jxmax);
1081 deltax = pixx -
T2HX;
1082 deltay = pixy -
T2HY;
1086 for (
int j = 0;
j <
BXM2; ++
j) {
1087 for (
int i = 0;
i <
BYM2; ++
i) {
1088 xytemp_[
j][
i] = 0.f;
1094 for (
int j = jmin_;
j <= jmax_; ++
j) {
1098 m = deltax + jflipx;
1102 for (
int i = imin_;
i <= imax_; ++
i) {
1105 n = deltay + iflipy;
1109 if (
m >= 0 && m <= BXM3 && n >= 0 &&
n <=
BYM3) {
1110 xytemp_[
m][
n] = (
float)entry00_->xytemp[
k0][l0][
i][
j] +
1111 adx * (
float)(entry00_->xytemp[
k0][l1][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1112 ady * (
float)(entry00_->xytemp[k1][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1113 adcota_ * (
float)(entry01_->xytemp[
k0][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1114 adcotb_ * (
float)(entry10_->xytemp[
k0][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]);
1121 for (
int n = 1;
n <
BYM3; ++
n) {
1124 for (
int m = 1;
m <
BXM3; ++
m) {
1125 xytemp_[
m][
n] += xytemp_[
m][
n + 1];
1128 for (
int i =
n + 1;
i <
BYM3; ++
i) {
1129 for (
int m = 1;
m <
BXM3; ++
m) {
1130 xytemp_[
m][
i] = xytemp_[
m][
i + 1];
1138 for (
int m = 1;
m <
BXM3; ++
m) {
1141 for (
int n = 1;
n <
BYM3; ++
n) {
1142 xytemp_[
m][
n] += xytemp_[
m + 1][
n];
1145 for (
int j =
m + 1;
j <
BXM3; ++
j) {
1147 xytemp_[
j][
n] = xytemp_[
j + 1][
n];
1155 float qtemptot = 0.f;
1157 for (
int n = 1;
n <
BYM3; ++
n) {
1158 for (
int m = 1;
m <
BXM3; ++
m) {
1159 if (xytemp_[
m][
n] != 0.
f) {
1160 template2d[
m][
n] += xytemp_[
m][
n];
1161 qtemptot += xytemp_[
m][
n];
1166 QTemplate = qtemptot;
1171 for (
int k = 0;
k < 2; ++
k) {
1172 for (
int i = 0;
i <
BXM2; ++
i) {
1173 for (
int j = 0;
j <
BYM2; ++
j) {
1174 dxytempdx[
k][
i][
j] = 0.f;
1175 dxytempdy[
k][
i][
j] = 0.f;
1176 dpdx2d[
k][
i][
j] = 0.f;
1183 pixx = (
int)floorf((xhit + deltaxy[0]) / xsize_);
1184 dx = (xhit + deltaxy[0]) - (pixx + 0.5
f) * xsize_;
1188 l0 = (
int)(
dx / xsize_ * 6.
f + 3.5
f);
1193 ddx = 6.f *
dx / xsize_ - (l0 - 3);
1215 deltax = pixx -
T2HX;
1219 for (
int j = jmin_;
j <= jmax_; ++
j) {
1223 m = deltax + jflipx;
1227 for (
int i = imin_;
i <= imax_; ++
i) {
1230 n = deltay + iflipy;
1234 if (
m >= 0 && m <= BXM3 && n >= 0 &&
n <=
BYM3) {
1235 dxytempdx[1][
m][
n] = (
float)entry00_->xytemp[
k0][l0][
i][
j] +
1236 adx * (
float)(entry00_->xytemp[
k0][l1][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1237 ady * (
float)(entry00_->xytemp[k1][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1238 adcota_ * (
float)(entry01_->xytemp[
k0][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1239 adcotb_ * (
float)(entry10_->xytemp[
k0][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]);
1246 for (
int n = 1;
n <
BYM3; ++
n) {
1249 for (
int m = 1;
m <
BXM3; ++
m) {
1250 dxytempdx[1][
m][
n] += dxytempdx[1][
m][
n + 1];
1253 for (
int i =
n + 1;
i <
BYM3; ++
i) {
1254 for (
int m = 1;
m <
BXM3; ++
m) {
1255 dxytempdx[1][
m][
i] = dxytempdx[1][
m][
i + 1];
1263 for (
int m = 1;
m <
BXM3; ++
m) {
1266 for (
int n = 1;
n <
BYM3; ++
n) {
1267 dxytempdx[1][
m][
n] += dxytempdx[1][
m + 1][
n];
1270 for (
int j =
m + 1;
j <
BXM3; ++
j) {
1271 for (
int n = 1;
n <
BYM3; ++
n) {
1272 dxytempdx[1][
j][
n] = dxytempdx[1][
j + 1][
n];
1280 pixx = (
int)floorf((xhit - deltaxy[0]) / xsize_);
1281 dx = (xhit - deltaxy[0]) - (pixx + 0.5
f) * xsize_;
1285 l0 = (
int)(
dx / xsize_ * 6.
f + 3.5
f);
1290 ddx = 6.f *
dx / xsize_ - (l0 - 3);
1312 deltax = pixx -
T2HX;
1316 for (
int j = jmin_;
j <= jmax_; ++
j) {
1320 m = deltax + jflipx;
1324 for (
int i = imin_;
i <= imax_; ++
i) {
1327 n = deltay + iflipy;
1331 if (
m >= 0 && m <= BXM3 && n >= 0 &&
n <=
BYM3) {
1332 dxytempdx[0][
m][
n] = (
float)entry00_->xytemp[
k0][l0][
i][
j] +
1333 adx * (
float)(entry00_->xytemp[
k0][l1][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1334 ady * (
float)(entry00_->xytemp[k1][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1335 adcota_ * (
float)(entry01_->xytemp[
k0][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1336 adcotb_ * (
float)(entry10_->xytemp[
k0][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]);
1343 for (
int n = 1;
n <
BYM3; ++
n) {
1346 for (
int m = 1;
m <
BXM3; ++
m) {
1347 dxytempdx[0][
m][
n] += dxytempdx[0][
m][
n + 1];
1350 for (
int i =
n + 1;
i <
BYM3; ++
i) {
1351 for (
int m = 1;
m <
BXM3; ++
m) {
1352 dxytempdx[0][
m][
i] = dxytempdx[0][
m][
i + 1];
1360 for (
int m = 1;
m <
BXM3; ++
m) {
1363 for (
int n = 1;
n <
BYM3; ++
n) {
1364 dxytempdx[0][
m][
n] += dxytempdx[0][
m + 1][
n];
1367 for (
int j =
m + 1;
j <
BXM3; ++
j) {
1368 for (
int n = 1;
n <
BYM3; ++
n) {
1369 dxytempdx[0][
j][
n] = dxytempdx[0][
j + 1][
n];
1377 for (
int n = 1;
n <
BYM3; ++
n) {
1378 for (
int m = 1;
m <
BXM3; ++
m) {
1379 dpdx2d[0][
m][
n] = (dxytempdx[1][
m][
n] - dxytempdx[0][
m][
n]) / (2. * deltaxy[0]);
1385 pixy = (
int)floorf((yhit + deltaxy[1]) / ysize_);
1386 dy = (yhit + deltaxy[1]) - (pixy + 0.5
f) * ysize_;
1395 ddy = 6.f *
dy / ysize_ - (
k0 - 3);
1406 pixx = (
int)floorf(xhit / xsize_);
1407 dx = xhit - (pixx + 0.5f) * xsize_;
1411 l0 = (
int)(
dx / xsize_ * 6.
f + 3.5
f);
1416 ddx = 6.f *
dx / xsize_ - (l0 - 3);
1439 deltax = pixx -
T2HX;
1440 deltay = pixy -
T2HY;
1444 for (
int j = jmin_;
j <= jmax_; ++
j) {
1448 m = deltax + jflipx;
1452 for (
int i = imin_;
i <= imax_; ++
i) {
1455 n = deltay + iflipy;
1459 if (
m >= 0 && m <= BXM3 && n >= 0 &&
n <=
BYM3) {
1460 dxytempdy[1][
m][
n] = (
float)entry00_->xytemp[
k0][l0][
i][
j] +
1461 adx * (
float)(entry00_->xytemp[
k0][l1][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1462 ady * (
float)(entry00_->xytemp[k1][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1463 adcota_ * (
float)(entry01_->xytemp[
k0][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1464 adcotb_ * (
float)(entry10_->xytemp[
k0][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]);
1471 for (
int n = 1;
n <
BYM3; ++
n) {
1474 for (
int m = 1;
m <
BXM3; ++
m) {
1475 dxytempdy[1][
m][
n] += dxytempdy[1][
m][
n + 1];
1478 for (
int i =
n + 1;
i <
BYM3; ++
i) {
1479 for (
int m = 1;
m <
BXM3; ++
m) {
1480 dxytempdy[1][
m][
i] = dxytempdy[1][
m][
i + 1];
1488 for (
int m = 1;
m <
BXM3; ++
m) {
1491 for (
int n = 1;
n <
BYM3; ++
n) {
1492 dxytempdy[1][
m][
n] += dxytempdy[1][
m + 1][
n];
1495 for (
int j =
m + 1;
j <
BXM3; ++
j) {
1496 for (
int n = 1;
n <
BYM3; ++
n) {
1497 dxytempdy[1][
j][
n] = dxytempdy[1][
j + 1][
n];
1505 pixy = (
int)floorf((yhit - deltaxy[1]) / ysize_);
1506 dy = (yhit - deltaxy[1]) - (pixy + 0.5
f) * ysize_;
1515 ddy = 6.f *
dy / ysize_ - (
k0 - 3);
1537 deltay = pixy -
T2HY;
1541 for (
int j = jmin_;
j <= jmax_; ++
j) {
1545 m = deltax + jflipx;
1549 for (
int i = imin_;
i <= imax_; ++
i) {
1552 n = deltay + iflipy;
1556 if (
m >= 0 && m <= BXM3 && n >= 0 &&
n <=
BYM3) {
1557 dxytempdy[0][
m][
n] = (
float)entry00_->xytemp[
k0][l0][
i][
j] +
1558 adx * (
float)(entry00_->xytemp[
k0][l1][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1559 ady * (
float)(entry00_->xytemp[k1][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1560 adcota_ * (
float)(entry01_->xytemp[
k0][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1561 adcotb_ * (
float)(entry10_->xytemp[
k0][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]);
1568 for (
int n = 1;
n <
BYM3; ++
n) {
1571 for (
int m = 1;
m <
BXM3; ++
m) {
1572 dxytempdy[0][
m][
n] += dxytempdy[0][
m][
n + 1];
1575 for (
int i =
n + 1;
i <
BYM3; ++
i) {
1576 for (
int m = 1;
m <
BXM3; ++
m) {
1577 dxytempdy[0][
m][
i] = dxytempdy[0][
m][
i + 1];
1585 for (
int m = 1;
m <
BXM3; ++
m) {
1588 for (
int n = 1;
n <
BYM3; ++
n) {
1589 dxytempdy[0][
m][
n] += dxytempdy[0][
m + 1][
n];
1592 for (
int j =
m + 1;
j <
BXM3; ++
j) {
1593 for (
int n = 1;
n <
BYM3; ++
n) {
1594 dxytempdy[0][
j][
n] = dxytempdy[0][
j + 1][
n];
1602 for (
int n = 1;
n <
BYM3; ++
n) {
1603 for (
int m = 1;
m <
BXM3; ++
m) {
1604 dpdx2d[1][
m][
n] = (dxytempdy[1][
m][
n] - dxytempdy[0][
m][
n]) / (2. * deltaxy[1]);
1622 float xhit,
float yhit,
bool ydouble[
BYM2],
bool xdouble[
BXM2],
float template2d[
BXM2][
BYM2]) {
1625 bool derivatives =
false;
1650 std::vector<bool>& ydouble,
1651 std::vector<bool>& xdouble,
1655 bool derivatives =
false;
1659 if (cotbeta < 0.
f) {
1662 float locBz = locBx;
1663 if (cotalpha < 0.
f) {
1670 yd[
BYM2 - 1] =
false;
1672 yd[
i + 1] = ydouble[
i];
1675 xd[
BXM2 - 1] =
false;
1677 xd[
j + 1] = xdouble[
j];
1703 float sigi, sigi2, sigi3, sigi4, qscale, err2, err00;
1707 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 1708 if (index < 1 || index >=
BYM2) {
1709 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate2D::ysigma2 called with index = " <<
index << std::endl;
1719 if (qpixel < sxymax_) {
1724 qscale = qpixel / sxymax_;
1726 sigi2 = sigi * sigi;
1727 sigi3 = sigi2 * sigi;
1728 sigi4 = sigi3 * sigi;
1730 err00 = xypary0x0_[0][0] + xypary0x0_[0][1] * sigi + xypary0x0_[0][2] * sigi2 + xypary0x0_[0][3] * sigi3 +
1731 xypary0x0_[0][4] * sigi4;
1733 adcota_ * (xypary0x1_[0][0] + xypary0x1_[0][1] * sigi + xypary0x1_[0][2] * sigi2 + xypary0x1_[0][3] * sigi3 +
1734 xypary0x1_[0][4] * sigi4 - err00) +
1735 adcotb_ * (xypary1x0_[0][0] + xypary1x0_[0][1] * sigi + xypary1x0_[0][2] * sigi2 + xypary1x0_[0][3] * sigi3 +
1736 xypary1x0_[0][4] * sigi4 - err00);
1738 err00 = xypary0x0_[1][0] + xypary0x0_[1][1] * sigi + xypary0x0_[1][2] * sigi2 + xypary0x0_[1][3] * sigi3 +
1739 xypary0x0_[1][4] * sigi4;
1741 adcota_ * (xypary0x1_[1][0] + xypary0x1_[1][1] * sigi + xypary0x1_[1][2] * sigi2 + xypary0x1_[1][3] * sigi3 +
1742 xypary0x1_[1][4] * sigi4 - err00) +
1743 adcotb_ * (xypary1x0_[1][0] + xypary1x0_[1][1] * sigi + xypary1x0_[1][2] * sigi2 + xypary1x0_[1][3] * sigi3 +
1744 xypary1x0_[1][4] * sigi4 - err00);
1746 xysig2 = qscale * err2;
1747 if (xysig2 <= 0.
f) {
1748 xysig2 = s50_ * s50_;
1763 for (
int i = 0;
i < 2; ++
i) {
1764 for (
int j = 0;
j < 5; ++
j) {
1765 lanpar[
i][
j] = lanpar_[
i][
j];
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)
SiPixelTemplateHeader2D head
< template storage structure
void xysigma2(float qpixel, int index, float &xysig2)
std::string to_string(const V &value)
constexpr bool isFinite(T x)
Abs< T >::type abs(const T &t)
bool interpolate(int id, float cotalpha, float cotbeta, float locBz, float locBx)
std::vector< std::vector< SiPixelTemplateEntry2D > > entry
void landau_par(float lanpar[2][5])
Return the Landau probability parameters for this set of cot(alpha, cot(beta)
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore2D > &pixelTemp, std::string dir="CalibTracker/SiPixelESProducers/data/")