27 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 39 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 43 #define LOGERROR(x) LogError(x) 44 #define LOGINFO(x) LogInfo(x) 50 #define LOGERROR(x) std::cout << x << ": " 51 #define LOGINFO(x) std::cout << x << ": " 52 #define ENDL std::endl 65 const int code_version = {21};
72 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 74 int nzeros = 4 - tempfile.length();
79 tempfile = dir +
"template_summary2D_zp" + tempfile +
".out";
85 std::ostringstream tout;
86 tout <<
"template_summary2D_zp" << std::setw(4) << std::setfill(
'0') << std::right << filenum <<
".out" << std::ends;
87 tempfile = tout.str();
93 std::ifstream in_file(tempfile);
94 if (in_file.is_open() && in_file.good()) {
100 for (
int i = 0; (c = in_file.get()) !=
'\n'; ++
i) {
107 LOGINFO(
"SiPixelTemplate2D") <<
"Loading Pixel Template File - " << theCurrentTemp.
head.
title <<
ENDL;
117 if (in_file.fail()) {
118 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 0A, no template load" <<
ENDL;
126 if (in_file.fail()) {
127 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 0B, no template load" <<
ENDL;
136 theCurrentTemp.
head.
fbin[1] = 1.00f;
137 theCurrentTemp.
head.
fbin[2] = 0.85f;
140 LOGINFO(
"SiPixelTemplate2D") <<
"Template ID = " << theCurrentTemp.
head.
ID <<
", Template Version " 142 <<
", NTy = " << theCurrentTemp.
head.
NTy <<
", NTyx = " << theCurrentTemp.
head.
NTyx 143 <<
", NTxx = " << theCurrentTemp.
head.
NTxx <<
", Dtype = " << theCurrentTemp.
head.
Dtype 144 <<
", Bias voltage " << theCurrentTemp.
head.
Vbias <<
", temperature " 146 <<
", Q-scaling factor " << theCurrentTemp.
head.
qscale <<
", 1/2 multi dcol threshold " 147 << theCurrentTemp.
head.
s50 <<
", 1/2 single dcol threshold " 149 <<
", y Lorentz Bias " << theCurrentTemp.
head.
lorybias <<
", x Lorentz width " 151 <<
", Q/Q_avg fractions for Qbin defs " << theCurrentTemp.
head.
fbin[0] <<
", " 153 <<
", pixel x-size " << theCurrentTemp.
head.
xsize <<
", y-size " 157 LOGERROR(
"SiPixelTemplate2D") <<
"code expects version " << code_version <<
", no template load" <<
ENDL;
161 if (theCurrentTemp.
head.
NTy != 0) {
163 <<
"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) {
181 if (in_file.fail()) {
182 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 1, no template load, run # " 184 delete[] theCurrentTemp.
entry[0];
185 delete[] theCurrentTemp.
entry;
202 if (in_file.fail()) {
203 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 2, no template load, run # " 205 delete[] theCurrentTemp.
entry[0];
206 delete[] theCurrentTemp.
entry;
210 for (
int k = 0;
k < 2; ++
k) {
215 if (in_file.fail()) {
217 <<
"Error reading file 3, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
218 delete[] theCurrentTemp.
entry[0];
219 delete[] theCurrentTemp.
entry;
224 for (
int k = 0;
k < 2; ++
k) {
229 if (in_file.fail()) {
231 <<
"Error reading file 4, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
232 delete[] theCurrentTemp.
entry[0];
233 delete[] theCurrentTemp.
entry;
241 for (
int l = 0;
l < 7; ++
l) {
242 for (
int k = 0;
k < 7; ++
k) {
247 if (in_file.fail()) {
249 <<
"Error reading file 5, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
250 delete[] theCurrentTemp.
entry[0];
251 delete[] theCurrentTemp.
entry;
267 if (in_file.fail()) {
268 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 6, no template load, run # " 270 delete[] theCurrentTemp.
entry[0];
271 delete[] theCurrentTemp.
entry;
281 if (in_file.fail()) {
282 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 7, no template load, run # " 284 delete[] theCurrentTemp.
entry[0];
285 delete[] theCurrentTemp.
entry;
295 if (in_file.fail()) {
296 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 8, no template load, run # " 298 delete[] theCurrentTemp.
entry[0];
299 delete[] theCurrentTemp.
entry;
309 pixelTemp.push_back(theCurrentTemp);
316 LOGERROR(
"SiPixelTemplate2D") <<
"Error opening File" << tempfile <<
ENDL;
322 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 330 std::vector<SiPixelTemplateStore2D>& pixelTemp) {
333 const int code_version = {21};
346 for (
int i = 0;
i < 20; ++
i) {
355 LOGINFO(
"SiPixelTemplate2D") <<
"Loading Pixel Template File - " << theCurrentTemp.
head.
title <<
ENDL;
367 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 0A, no template load" <<
ENDL;
371 LOGINFO(
"SiPixelTemplate2D") <<
"Loading Pixel Template File - " << theCurrentTemp.
head.
title 372 <<
" code version = " << code_version <<
" object version " 380 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 0B, no template load" <<
ENDL;
388 theCurrentTemp.
head.
fbin[0] = 1.50f;
389 theCurrentTemp.
head.
fbin[1] = 1.00f;
390 theCurrentTemp.
head.
fbin[2] = 0.85f;
393 LOGINFO(
"SiPixelTemplate2D") <<
"Template ID = " << theCurrentTemp.
head.
ID <<
", Template Version " 395 <<
", NTy = " << theCurrentTemp.
head.
NTy <<
", NTyx = " << theCurrentTemp.
head.
NTyx 396 <<
", NTxx = " << theCurrentTemp.
head.
NTxx <<
", Dtype = " << theCurrentTemp.
head.
Dtype 397 <<
", Bias voltage " << theCurrentTemp.
head.
Vbias <<
", temperature " 399 <<
", Q-scaling factor " << theCurrentTemp.
head.
qscale <<
", 1/2 multi dcol threshold " 400 << theCurrentTemp.
head.
s50 <<
", 1/2 single dcol threshold " 402 <<
", y Lorentz Bias " << theCurrentTemp.
head.
lorybias <<
", x Lorentz width " 404 <<
", Q/Q_avg fractions for Qbin defs " << theCurrentTemp.
head.
fbin[0] <<
", " 406 <<
", pixel x-size " << theCurrentTemp.
head.
xsize <<
", y-size " 410 LOGINFO(
"SiPixelTemplate2D") <<
"code expects version " << code_version <<
" finds " 414 if (theCurrentTemp.
head.
NTy != 0) {
416 <<
"Trying to load 1-d template info into the 2-d template object, check your DB/global tag!" <<
ENDL;
429 for (
int iy = 0; iy < theCurrentTemp.
head.
NTyx; ++iy) {
430 for (
int jx = 0; jx < theCurrentTemp.
head.
NTxx; ++jx) {
435 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 1, no template load, run # " 437 delete[] theCurrentTemp.
entry[0];
438 delete[] theCurrentTemp.
entry;
456 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 2, no template load, run # " 458 delete[] theCurrentTemp.
entry[0];
459 delete[] theCurrentTemp.
entry;
463 for (
int k = 0;
k < 2; ++
k) {
470 <<
"Error reading file 3, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
471 delete[] theCurrentTemp.
entry[0];
472 delete[] theCurrentTemp.
entry;
477 for (
int k = 0;
k < 2; ++
k) {
484 <<
"Error reading file 4, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
485 delete[] theCurrentTemp.
entry[0];
486 delete[] theCurrentTemp.
entry;
494 for (
int l = 0;
l < 7; ++
l) {
495 for (
int k = 0;
k < 7; ++
k) {
502 <<
"Error reading file 5, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
503 delete[] theCurrentTemp.
entry[0];
504 delete[] theCurrentTemp.
entry;
521 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 6, no template load, run # " 523 delete[] theCurrentTemp.
entry[0];
524 delete[] theCurrentTemp.
entry;
535 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 7, no template load, run # " 537 delete[] theCurrentTemp.
entry[0];
538 delete[] theCurrentTemp.
entry;
549 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 8, no template load, run # " 551 delete[] theCurrentTemp.
entry[0];
552 delete[] theCurrentTemp.
entry;
560 pixelTemp.push_back(theCurrentTemp);
570 if (
id != id_current_) {
574 for (
int i = 0;
i < (
int)thePixelTemp_.size(); ++
i) {
575 if (
id == thePixelTemp_[
i].head.ID) {
581 Dtype_ = thePixelTemp_[index_id_].head.Dtype;
585 qscale_ = thePixelTemp_[index_id_].head.qscale;
589 s50_ = thePixelTemp_[index_id_].head.s50;
593 for (
int j = 0;
j < 3; ++
j) {
594 fbin_[
j] = thePixelTemp_[index_id_].head.fbin[
j];
599 lorywidth_ = thePixelTemp_[index_id_].head.lorywidth;
600 lorxwidth_ = thePixelTemp_[index_id_].head.lorxwidth;
604 xsize_ = thePixelTemp_[index_id_].head.xsize;
605 ysize_ = thePixelTemp_[index_id_].head.ysize;
606 zsize_ = thePixelTemp_[index_id_].head.zsize;
610 Nyx_ = thePixelTemp_[index_id_].head.NTyx;
611 Nxx_ = thePixelTemp_[index_id_].head.NTxx;
612 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 613 if (Nyx_ < 2 || Nxx_ < 2) {
614 throw cms::Exception(
"DataCorrupt") <<
"template ID = " << id_current_
615 <<
"has too few entries: Nyx/Nxx = " << Nyx_ <<
"/" << Nxx_ << std::endl;
618 assert(Nyx_ > 1 && Nxx_ > 1);
620 int imidx = Nxx_ / 2;
622 cotalpha0_ = thePixelTemp_[index_id_].entry[0][0].cotalpha;
623 cotalpha1_ = thePixelTemp_[index_id_].entry[0][Nxx_ - 1].cotalpha;
624 deltacota_ = (cotalpha1_ - cotalpha0_) / (
float)(Nxx_ - 1);
626 cotbeta0_ = thePixelTemp_[index_id_].entry[0][imidx].cotbeta;
627 cotbeta1_ = thePixelTemp_[index_id_].entry[Nyx_ - 1][imidx].cotbeta;
628 deltacotb_ = (cotbeta1_ - cotbeta0_) / (
float)(Nyx_ - 1);
635 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 636 if (index_id_ < 0 || index_id_ >= (
int)thePixelTemp_.size()) {
637 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate2D::interpolate can't find needed template ID = " <<
id 638 <<
", Are you using the correct global tag?" << std::endl;
641 assert(index_id_ >= 0 && index_id_ < (
int)thePixelTemp_.size());
664 float acotb, dcota, dcotb;
668 if (
id != id_current_ || cotalpha != cota_current_ || cotbeta != cotb_current_) {
669 cota_current_ = cotalpha;
670 cotb_current_ = cotbeta;
671 success_ = getid(
id);
674 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 675 if (index_id_ < 0 || index_id_ >= (
int)thePixelTemp_.size()) {
676 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate2D::interpolate can't find needed template ID = " <<
id 677 <<
", Are you using the correct global tag?" << std::endl;
680 assert(index_id_ >= 0 && index_id_ < (
int)thePixelTemp_.size());
685 float cota = cotalpha;
703 if (locBx * locBz < 0.
f) {
704 cota = fabs(cotalpha);
712 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 714 <<
"SiPixelTemplate2D::illegal subdetector ID = " << thePixelTemp_[index_id_].head.Dtype << std::endl;
716 std::cout <<
"SiPixelTemplate:2D:illegal subdetector ID = " << thePixelTemp_[index_id_].head.Dtype << std::endl;
720 if (cota < cotalpha0_) {
725 }
else if (cota > cotalpha1_) {
731 jx0_ = (
int)((cota - cotalpha0_) / deltacota_ + 0.5f);
732 dcota = (cota - (cotalpha0_ + jx0_ * deltacota_)) / deltacota_;
733 adcota_ = fabs(dcota);
747 acotb = fabs(cotbeta);
749 if (acotb < cotbeta0_) {
754 }
else if (acotb > cotbeta1_) {
760 iy0_ = (
int)((acotb - cotbeta0_) / deltacotb_ + 0.5f);
761 dcotb = (acotb - (cotbeta0_ + iy0_ * deltacotb_)) / deltacotb_;
762 adcotb_ = fabs(dcotb);
776 lorydrift_ = lorywidth_ / 2.;
778 lorydrift_ = -lorydrift_;
779 lorxdrift_ = lorxwidth_ / 2.;
781 lorxdrift_ = -lorxdrift_;
785 entry00_ = &thePixelTemp_[index_id_].entry[iy0_][jx0_];
786 entry10_ = &thePixelTemp_[index_id_].entry[iy1_][jx0_];
787 entry01_ = &thePixelTemp_[index_id_].entry[iy0_][jx1_];
791 qavg_ = entry00_->qavg + adcota_ * (entry01_->qavg - entry00_->qavg) + adcotb_ * (entry10_->qavg - entry00_->qavg);
793 pixmax_ = entry00_->pixmax + adcota_ * (entry01_->pixmax - entry00_->pixmax) +
794 adcotb_ * (entry10_->pixmax - entry00_->pixmax);
796 sxymax_ = entry00_->sxymax + adcota_ * (entry01_->sxymax - entry00_->sxymax) +
797 adcotb_ * (entry10_->sxymax - entry00_->sxymax);
799 chi2avgone_ = entry00_->chi2avgone + adcota_ * (entry01_->chi2avgone - entry00_->chi2avgone) +
800 adcotb_ * (entry10_->chi2avgone - entry00_->chi2avgone);
802 chi2minone_ = entry00_->chi2minone + adcota_ * (entry01_->chi2minone - entry00_->chi2minone) +
803 adcotb_ * (entry10_->chi2minone - entry00_->chi2minone);
805 clsleny_ = entry00_->clsleny + adcota_ * (entry01_->clsleny - entry00_->clsleny) +
806 adcotb_ * (entry10_->clsleny - entry00_->clsleny);
808 clslenx_ = entry00_->clslenx + adcota_ * (entry01_->clslenx - entry00_->clslenx) +
809 adcotb_ * (entry10_->clslenx - entry00_->clslenx);
811 chi2ppix_ = entry00_->chi2ppix + adcota_ * (entry01_->chi2ppix - entry00_->chi2ppix) +
812 adcotb_ * (entry10_->chi2ppix - entry00_->chi2ppix);
814 chi2scale_ = entry00_->chi2scale + adcota_ * (entry01_->chi2scale - entry00_->chi2scale) +
815 adcotb_ * (entry10_->chi2scale - entry00_->chi2scale);
817 scaleyavg_ = entry00_->scaleyavg + adcota_ * (entry01_->scaleyavg - entry00_->scaleyavg) +
818 adcotb_ * (entry10_->scaleyavg - entry00_->scaleyavg);
820 scalexavg_ = entry00_->scalexavg + adcota_ * (entry01_->scalexavg - entry00_->scalexavg) +
821 adcotb_ * (entry10_->scalexavg - entry00_->scalexavg);
823 delyavg_ = entry00_->delyavg + adcota_ * (entry01_->delyavg - entry00_->delyavg) +
824 adcotb_ * (entry10_->delyavg - entry00_->delyavg);
826 delysig_ = entry00_->delysig + adcota_ * (entry01_->delysig - entry00_->delysig) +
827 adcotb_ * (entry10_->delysig - entry00_->delysig);
829 mpvvav_ = entry00_->mpvvav + adcota_ * (entry01_->mpvvav - entry00_->mpvvav) +
830 adcotb_ * (entry10_->mpvvav - entry00_->mpvvav);
832 sigmavav_ = entry00_->sigmavav + adcota_ * (entry01_->sigmavav - entry00_->sigmavav) +
833 adcotb_ * (entry10_->sigmavav - entry00_->sigmavav);
835 kappavav_ = entry00_->kappavav + adcota_ * (entry01_->kappavav - entry00_->kappavav) +
836 adcotb_ * (entry10_->kappavav - entry00_->kappavav);
838 for (
int i = 0;
i < 4; ++
i) {
839 scalex_[
i] = entry00_->scalex[
i] + adcota_ * (entry01_->scalex[
i] - entry00_->scalex[
i]) +
840 adcotb_ * (entry10_->scalex[
i] - entry00_->scalex[
i]);
842 scaley_[
i] = entry00_->scaley[
i] + adcota_ * (entry01_->scaley[
i] - entry00_->scaley[
i]) +
843 adcotb_ * (entry10_->scaley[
i] - entry00_->scaley[
i]);
845 offsetx_[
i] = entry00_->offsetx[
i] + adcota_ * (entry01_->offsetx[
i] - entry00_->offsetx[
i]) +
846 adcotb_ * (entry10_->offsetx[
i] - entry00_->offsetx[
i]);
848 offsetx_[
i] = -offsetx_[
i];
850 offsety_[
i] = entry00_->offsety[
i] + adcota_ * (entry01_->offsety[
i] - entry00_->offsety[
i]) +
851 adcotb_ * (entry10_->offsety[
i] - entry00_->offsety[
i]);
853 offsety_[
i] = -offsety_[
i];
856 for (
int i = 0;
i < 2; ++
i) {
857 for (
int j = 0;
j < 5; ++
j) {
860 xypary0x0_[1 -
i][
j] = (
float)entry00_->xypar[
i][
j];
861 xypary1x0_[1 -
i][
j] = (
float)entry10_->xypar[
i][
j];
862 xypary0x1_[1 -
i][
j] = (
float)entry01_->xypar[
i][
j];
863 lanpar_[1 -
i][
j] = entry00_->lanpar[
i][
j] + adcota_ * (entry01_->lanpar[
i][
j] - entry00_->lanpar[
i][
j]) +
864 adcotb_ * (entry10_->lanpar[
i][
j] - entry00_->lanpar[
i][
j]);
866 xypary0x0_[
i][
j] = (
float)entry00_->xypar[
i][
j];
867 xypary1x0_[
i][
j] = (
float)entry10_->xypar[
i][
j];
868 xypary0x1_[
i][
j] = (
float)entry01_->xypar[
i][
j];
869 lanpar_[
i][
j] = entry00_->lanpar[
i][
j] + adcota_ * (entry01_->lanpar[
i][
j] - entry00_->lanpar[
i][
j]) +
870 adcotb_ * (entry10_->lanpar[
i][
j] - entry00_->lanpar[
i][
j]);
910 for (
int i = 0;
i < 3; ++
i) {
921 qavg_ = entry00_->qavg;
923 pixmax_ = entry00_->pixmax;
925 sxymax_ = entry00_->sxymax;
927 clsleny_ = entry00_->clsleny;
929 clslenx_ = entry00_->clslenx;
939 for (
int i = 0;
i < 4; ++
i) {
950 float cotbeta = entry00_->cotbeta;
966 if (locBx * locBz < 0.
f) {
974 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 975 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate2D::illegal subdetector ID = " << iDtype << std::endl;
977 std::cout <<
"SiPixelTemplate:2D:illegal subdetector ID = " << iDtype << std::endl;
983 lorydrift_ = lorywidth_ / 2.;
985 lorydrift_ = -lorydrift_;
986 lorxdrift_ = lorxwidth_ / 2.;
988 lorxdrift_ = -lorxdrift_;
990 for (
int i = 0;
i < 2; ++
i) {
991 for (
int j = 0;
j < 5; ++
j) {
994 xypary0x0_[1 -
i][
j] = (
float)entry00_->xypar[
i][
j];
995 xypary1x0_[1 -
i][
j] = (
float)entry00_->xypar[
i][
j];
996 xypary0x1_[1 -
i][
j] = (
float)entry00_->xypar[
i][
j];
997 lanpar_[1 -
i][
j] = entry00_->lanpar[
i][
j];
999 xypary0x0_[
i][
j] = (
float)entry00_->xypar[
i][
j];
1000 xypary1x0_[
i][
j] = (
float)entry00_->xypar[
i][
j];
1001 xypary0x1_[
i][
j] = (
float)entry00_->xypar[
i][
j];
1002 lanpar_[
i][
j] = entry00_->lanpar[
i][
j];
1021 float template2d[BXM2][BYM2],
1023 float dpdx2d[2][BXM2][BYM2],
1028 int pixx, pixy,
k0, k1, l0, l1, deltax, deltay, iflipy, jflipx, imin, imax, jmin, jmax;
1030 float dx,
dy, ddx, ddy, adx, ady;
1032 const float deltaxy[2] = {16.67f, 25.0f};
1041 pixy = (
int)floorf(yhit / ysize_);
1042 dy = yhit - (pixy + 0.5f) * ysize_;
1046 k0 = (
int)(dy / ysize_ * 6.
f + 3.5
f);
1051 ddy = 6.f * dy / ysize_ - (k0 - 3);
1062 pixx = (
int)floorf(xhit / xsize_);
1063 dx = xhit - (pixx + 0.5f) * xsize_;
1067 l0 = (
int)(dx / xsize_ * 6.
f + 3.5
f);
1072 ddx = 6.f * dx / xsize_ - (l0 - 3);
1088 imin =
std::min(entry00_->iymin, entry10_->iymin);
1089 imin_ =
std::min(imin, entry01_->iymin);
1091 jmin =
std::min(entry00_->jxmin, entry10_->jxmin);
1092 jmin_ =
std::min(jmin, entry01_->jxmin);
1094 imax =
std::max(entry00_->iymax, entry10_->iymax);
1095 imax_ =
std::max(imax, entry01_->iymax);
1097 jmax =
std::max(entry00_->jxmax, entry10_->jxmax);
1098 jmax_ =
std::max(jmax, entry01_->jxmax);
1109 deltax = pixx -
T2HX;
1110 deltay = pixy -
T2HY;
1114 for (
int j = 0;
j <
BXM2; ++
j) {
1115 for (
int i = 0;
i <
BYM2; ++
i) {
1116 xytemp_[
j][
i] = 0.f;
1122 for (
int j = jmin_;
j <= jmax_; ++
j) {
1126 m = deltax + jflipx;
1130 for (
int i = imin_;
i <= imax_; ++
i) {
1133 n = deltay + iflipy;
1137 if (m >= 0 && m <= BXM3 && n >= 0 && n <=
BYM3) {
1138 xytemp_[
m][
n] = (
float)entry00_->xytemp[k0][l0][
i][
j] +
1139 adx * (
float)(entry00_->xytemp[
k0][l1][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1140 ady * (
float)(entry00_->xytemp[k1][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1141 adcota_ * (
float)(entry01_->xytemp[
k0][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1142 adcotb_ * (
float)(entry10_->xytemp[
k0][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]);
1149 for (
int n = 1; n <
BYM3; ++
n) {
1152 for (
int m = 1; m <
BXM3; ++
m) {
1153 xytemp_[
m][
n] += xytemp_[
m][n + 1];
1156 for (
int i = n + 1;
i <
BYM3; ++
i) {
1157 for (
int m = 1; m <
BXM3; ++
m) {
1158 xytemp_[
m][
i] = xytemp_[
m][
i + 1];
1166 for (
int m = 1; m <
BXM3; ++
m) {
1169 for (
int n = 1; n <
BYM3; ++
n) {
1170 xytemp_[
m][
n] += xytemp_[m + 1][
n];
1173 for (
int j = m + 1;
j <
BXM3; ++
j) {
1174 for (n = 1; n <
BYM3; ++
n) {
1175 xytemp_[
j][
n] = xytemp_[
j + 1][
n];
1183 float qtemptot = 0.f;
1185 for (
int n = 1; n <
BYM3; ++
n) {
1186 for (
int m = 1; m <
BXM3; ++
m) {
1187 if (xytemp_[m][n] != 0.
f) {
1188 template2d[
m][
n] += xytemp_[
m][
n];
1189 qtemptot += xytemp_[
m][
n];
1194 QTemplate = qtemptot;
1199 for (
int k = 0;
k < 2; ++
k) {
1200 for (
int i = 0;
i <
BXM2; ++
i) {
1201 for (
int j = 0;
j <
BYM2; ++
j) {
1202 dxytempdx[
k][
i][
j] = 0.f;
1203 dxytempdy[
k][
i][
j] = 0.f;
1204 dpdx2d[
k][
i][
j] = 0.f;
1211 pixx = (
int)floorf((xhit + deltaxy[0]) / xsize_);
1212 dx = (xhit + deltaxy[0]) - (pixx + 0.5
f) * xsize_;
1216 l0 = (
int)(dx / xsize_ * 6.
f + 3.5
f);
1221 ddx = 6.f * dx / xsize_ - (l0 - 3);
1243 deltax = pixx -
T2HX;
1247 for (
int j = jmin_;
j <= jmax_; ++
j) {
1251 m = deltax + jflipx;
1255 for (
int i = imin_;
i <= imax_; ++
i) {
1258 n = deltay + iflipy;
1262 if (m >= 0 && m <= BXM3 && n >= 0 && n <= BYM3) {
1263 dxytempdx[1][
m][
n] = (
float)entry00_->xytemp[k0][l0][
i][
j] +
1264 adx * (
float)(entry00_->xytemp[
k0][l1][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1265 ady * (
float)(entry00_->xytemp[k1][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1266 adcota_ * (
float)(entry01_->xytemp[
k0][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1267 adcotb_ * (
float)(entry10_->xytemp[
k0][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]);
1274 for (
int n = 1; n <
BYM3; ++
n) {
1277 for (
int m = 1; m <
BXM3; ++
m) {
1278 dxytempdx[1][
m][
n] += dxytempdx[1][
m][n + 1];
1281 for (
int i = n + 1;
i <
BYM3; ++
i) {
1282 for (
int m = 1; m <
BXM3; ++
m) {
1283 dxytempdx[1][
m][
i] = dxytempdx[1][
m][
i + 1];
1291 for (
int m = 1; m <
BXM3; ++
m) {
1294 for (
int n = 1; n <
BYM3; ++
n) {
1295 dxytempdx[1][
m][
n] += dxytempdx[1][m + 1][
n];
1298 for (
int j = m + 1;
j <
BXM3; ++
j) {
1299 for (
int n = 1; n <
BYM3; ++
n) {
1300 dxytempdx[1][
j][
n] = dxytempdx[1][
j + 1][
n];
1308 pixx = (
int)floorf((xhit - deltaxy[0]) / xsize_);
1309 dx = (xhit - deltaxy[0]) - (pixx + 0.5
f) * xsize_;
1313 l0 = (
int)(dx / xsize_ * 6.
f + 3.5
f);
1318 ddx = 6.f * dx / xsize_ - (l0 - 3);
1340 deltax = pixx -
T2HX;
1344 for (
int j = jmin_;
j <= jmax_; ++
j) {
1348 m = deltax + jflipx;
1352 for (
int i = imin_;
i <= imax_; ++
i) {
1355 n = deltay + iflipy;
1359 if (m >= 0 && m <= BXM3 && n >= 0 && n <= BYM3) {
1360 dxytempdx[0][
m][
n] = (
float)entry00_->xytemp[k0][l0][
i][
j] +
1361 adx * (
float)(entry00_->xytemp[
k0][l1][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1362 ady * (
float)(entry00_->xytemp[k1][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1363 adcota_ * (
float)(entry01_->xytemp[
k0][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1364 adcotb_ * (
float)(entry10_->xytemp[
k0][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]);
1371 for (
int n = 1; n <
BYM3; ++
n) {
1374 for (
int m = 1; m <
BXM3; ++
m) {
1375 dxytempdx[0][
m][
n] += dxytempdx[0][
m][n + 1];
1378 for (
int i = n + 1;
i <
BYM3; ++
i) {
1379 for (
int m = 1; m <
BXM3; ++
m) {
1380 dxytempdx[0][
m][
i] = dxytempdx[0][
m][
i + 1];
1388 for (
int m = 1; m <
BXM3; ++
m) {
1391 for (
int n = 1; n <
BYM3; ++
n) {
1392 dxytempdx[0][
m][
n] += dxytempdx[0][m + 1][
n];
1395 for (
int j = m + 1;
j <
BXM3; ++
j) {
1396 for (
int n = 1; n <
BYM3; ++
n) {
1397 dxytempdx[0][
j][
n] = dxytempdx[0][
j + 1][
n];
1405 for (
int n = 1; n <
BYM3; ++
n) {
1406 for (
int m = 1; m <
BXM3; ++
m) {
1407 dpdx2d[0][
m][
n] = (dxytempdx[1][
m][
n] - dxytempdx[0][
m][
n]) / (2. * deltaxy[0]);
1413 pixy = (
int)floorf((yhit + deltaxy[1]) / ysize_);
1414 dy = (yhit + deltaxy[1]) - (pixy + 0.5
f) * ysize_;
1418 k0 = (
int)(dy / ysize_ * 6.
f + 3.5
f);
1423 ddy = 6.f * dy / ysize_ - (k0 - 3);
1434 pixx = (
int)floorf(xhit / xsize_);
1435 dx = xhit - (pixx + 0.5f) * xsize_;
1439 l0 = (
int)(dx / xsize_ * 6.
f + 3.5
f);
1444 ddx = 6.f * dx / xsize_ - (l0 - 3);
1467 deltax = pixx -
T2HX;
1468 deltay = pixy -
T2HY;
1472 for (
int j = jmin_;
j <= jmax_; ++
j) {
1476 m = deltax + jflipx;
1480 for (
int i = imin_;
i <= imax_; ++
i) {
1483 n = deltay + iflipy;
1487 if (m >= 0 && m <= BXM3 && n >= 0 && n <= BYM3) {
1488 dxytempdy[1][
m][
n] = (
float)entry00_->xytemp[k0][l0][
i][
j] +
1489 adx * (
float)(entry00_->xytemp[
k0][l1][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1490 ady * (
float)(entry00_->xytemp[k1][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1491 adcota_ * (
float)(entry01_->xytemp[
k0][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1492 adcotb_ * (
float)(entry10_->xytemp[
k0][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]);
1499 for (
int n = 1; n <
BYM3; ++
n) {
1502 for (
int m = 1; m <
BXM3; ++
m) {
1503 dxytempdy[1][
m][
n] += dxytempdy[1][
m][n + 1];
1506 for (
int i = n + 1;
i <
BYM3; ++
i) {
1507 for (
int m = 1; m <
BXM3; ++
m) {
1508 dxytempdy[1][
m][
i] = dxytempdy[1][
m][
i + 1];
1516 for (
int m = 1; m <
BXM3; ++
m) {
1519 for (
int n = 1; n <
BYM3; ++
n) {
1520 dxytempdy[1][
m][
n] += dxytempdy[1][m + 1][
n];
1523 for (
int j = m + 1;
j <
BXM3; ++
j) {
1524 for (
int n = 1; n <
BYM3; ++
n) {
1525 dxytempdy[1][
j][
n] = dxytempdy[1][
j + 1][
n];
1533 pixy = (
int)floorf((yhit - deltaxy[1]) / ysize_);
1534 dy = (yhit - deltaxy[1]) - (pixy + 0.5
f) * ysize_;
1538 k0 = (
int)(dy / ysize_ * 6.
f + 3.5
f);
1543 ddy = 6.f * dy / ysize_ - (k0 - 3);
1565 deltay = pixy -
T2HY;
1569 for (
int j = jmin_;
j <= jmax_; ++
j) {
1573 m = deltax + jflipx;
1577 for (
int i = imin_;
i <= imax_; ++
i) {
1580 n = deltay + iflipy;
1584 if (m >= 0 && m <= BXM3 && n >= 0 && n <= BYM3) {
1585 dxytempdy[0][
m][
n] = (
float)entry00_->xytemp[k0][l0][
i][
j] +
1586 adx * (
float)(entry00_->xytemp[
k0][l1][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1587 ady * (
float)(entry00_->xytemp[k1][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1588 adcota_ * (
float)(entry01_->xytemp[
k0][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]) +
1589 adcotb_ * (
float)(entry10_->xytemp[
k0][l0][
i][
j] - entry00_->xytemp[
k0][l0][
i][
j]);
1596 for (
int n = 1; n <
BYM3; ++
n) {
1599 for (
int m = 1; m <
BXM3; ++
m) {
1600 dxytempdy[0][
m][
n] += dxytempdy[0][
m][n + 1];
1603 for (
int i = n + 1;
i <
BYM3; ++
i) {
1604 for (
int m = 1; m <
BXM3; ++
m) {
1605 dxytempdy[0][
m][
i] = dxytempdy[0][
m][
i + 1];
1613 for (
int m = 1; m <
BXM3; ++
m) {
1616 for (
int n = 1; n <
BYM3; ++
n) {
1617 dxytempdy[0][
m][
n] += dxytempdy[0][m + 1][
n];
1620 for (
int j = m + 1;
j <
BXM3; ++
j) {
1621 for (
int n = 1; n <
BYM3; ++
n) {
1622 dxytempdy[0][
j][
n] = dxytempdy[0][
j + 1][
n];
1630 for (
int n = 1; n <
BYM3; ++
n) {
1631 for (
int m = 1; m <
BXM3; ++
m) {
1632 dpdx2d[1][
m][
n] = (dxytempdy[1][
m][
n] - dxytempdy[0][
m][
n]) / (2. * deltaxy[1]);
1650 float xhit,
float yhit,
bool ydouble[
BYM2],
bool xdouble[
BXM2],
float template2d[BXM2][BYM2]) {
1653 bool derivatives =
false;
1678 std::vector<bool>& ydouble,
1679 std::vector<bool>& xdouble,
1683 bool derivatives =
false;
1687 if (cotbeta < 0.
f) {
1690 float locBz = locBx;
1691 if (cotalpha < 0.
f) {
1698 yd[BYM2 - 1] =
false;
1700 yd[
i + 1] = ydouble[
i];
1703 xd[
BXM2 - 1] =
false;
1705 xd[
j + 1] = xdouble[
j];
1731 float sigi, sigi2, sigi3, sigi4, qscale, err2, err00;
1735 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 1736 if (index < 1 || index >=
BYM2) {
1737 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate2D::ysigma2 called with index = " << index << std::endl;
1740 assert(index > 0 && index <
BYM2);
1747 if (qpixel < sxymax_) {
1752 qscale = qpixel / sxymax_;
1754 sigi2 = sigi * sigi;
1755 sigi3 = sigi2 * sigi;
1756 sigi4 = sigi3 * sigi;
1758 err00 = xypary0x0_[0][0] + xypary0x0_[0][1] * sigi + xypary0x0_[0][2] * sigi2 + xypary0x0_[0][3] * sigi3 +
1759 xypary0x0_[0][4] * sigi4;
1761 adcota_ * (xypary0x1_[0][0] + xypary0x1_[0][1] * sigi + xypary0x1_[0][2] * sigi2 + xypary0x1_[0][3] * sigi3 +
1762 xypary0x1_[0][4] * sigi4 - err00) +
1763 adcotb_ * (xypary1x0_[0][0] + xypary1x0_[0][1] * sigi + xypary1x0_[0][2] * sigi2 + xypary1x0_[0][3] * sigi3 +
1764 xypary1x0_[0][4] * sigi4 - err00);
1766 err00 = xypary0x0_[1][0] + xypary0x0_[1][1] * sigi + xypary0x0_[1][2] * sigi2 + xypary0x0_[1][3] * sigi3 +
1767 xypary0x0_[1][4] * sigi4;
1769 adcota_ * (xypary0x1_[1][0] + xypary0x1_[1][1] * sigi + xypary0x1_[1][2] * sigi2 + xypary0x1_[1][3] * sigi3 +
1770 xypary0x1_[1][4] * sigi4 - err00) +
1771 adcotb_ * (xypary1x0_[1][0] + xypary1x0_[1][1] * sigi + xypary1x0_[1][2] * sigi2 + xypary1x0_[1][3] * sigi3 +
1772 xypary1x0_[1][4] * sigi4 - err00);
1774 xysig2 = qscale * err2;
1775 if (xysig2 <= 0.
f) {
1776 xysig2 = s50_ * s50_;
1791 for (
int i = 0;
i < 2; ++
i) {
1792 for (
int j = 0;
j < 5; ++
j) {
1793 lanpar[
i][
j] = lanpar_[
i][
j];
float pixmax
maximum charge for individual pixels in cluster
float qavg
average cluster charge for this set of track angles
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)
int runnum
< Basic template entry corresponding to a single set of track angles
SiPixelTemplateHeader2D head
< template storage structure
void xysigma2(float qpixel, int index, float &xysig2)
float clsleny
cluster y-length in pixels at signal height symax/2
float sxymax
average pixel signal for use of the error parameterization
float xypar[2][5]
pixel uncertainty parameterization
std::vector< float > sVector() const
float scaleyavg
average y-error scale factor
float delyavg
average length difference between template and cluster
float delysig
rms of length difference between template and cluster
SiPixelTemplateEntry2D ** entry
use 2d entry to store BPix and FPix entries [dynamically allocated]
float cotbeta
cot(beta) is proportional to cluster length in y and is basis of interpolation
int iymax
the maximum nonzero pixel yindex in template (saves time during interpolation)
int iymin
the minimum nonzero pixel yindex in template (saves time during interpolation)
short int xytemp[7][7][21][7]
templates for y-reconstruction (binned over 1 central pixel)
float mpvvav
most probable charge in Vavilov distribution (not actually for larger kappa)
float scalex[4]
x-error scale factor in 4 charge bins
int jxmax
the maximum nonzero pixel xindex in template (saves time during interpolation)
float lanpar[2][5]
pixel landau distribution parameters
float costrk[3]
direction cosines of tracks used to generate this entry
float offsetx[4]
x-offset in 4 charge bins
int jxmin
the minimum nonzero pixel xindex in template (saves time during interpolation)
float sigmavav
"sigma" scale fctor for Vavilov distribution
float cotalpha
cot(alpha) is proportional to cluster length in x and is basis of interpolation
bool interpolate(int id, float cotalpha, float cotbeta, float locBz, float locBx)
float offsety[4]
y-offset in 4 charge bins
float chi2scale
scale factor for the chi2 distribution
float clslenx
cluster x-length in pixels at signal height sxmax/2
void incrementIndex(int i)
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore2D > &pixelTemp, std::string dir="")
float scalexavg
average x-error scale factor
float scaley[4]
y-error scale factor in 4 charge bins
void landau_par(float lanpar[2][5])
Return the Landau probability parameters for this set of cot(alpha, cot(beta)
std::string fullPath() const
float chi2ppix
average chi^2 per pixel
void sideload(SiPixelTemplateEntry2D *entry, int iDtype, float locBx, float locBz, float lorwdy, float lorwdx, float q50, float fbin[3], float xsize, float ysize, float zsize)
float kappavav
kappa parameter for Vavilov distribution