27 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 40 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 45 #define LOGERROR(x) LogError(x) 46 #define LOGINFO(x) LogInfo(x) 52 #define LOGERROR(x) std::cout << x << ": " 53 #define LOGINFO(x) std::cout << x << ": " 54 #define ENDL std::endl 68 const int code_version={21};
76 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 78 int nzeros = 4-tempfile.length();
83 tempfile = dir +
"template_summary2D_zp" + tempfile +
".out";
89 std::ostringstream tout;
90 tout <<
"template_summary2D_zp" << std::setw(4) << std::setfill(
'0') << std::right << filenum <<
".out" << std::ends;
91 tempfile = tout.str();
97 std::ifstream
in_file(tempfile);
98 if(in_file.is_open() && in_file.good()) {
105 for (
int i=0; (c=in_file.get()) !=
'\n'; ++
i) {
107 else {theCurrentTemp.
head.
title[79] =
'\0';}
109 LOGINFO(
"SiPixelTemplate2D") <<
"Loading Pixel Template File - " << theCurrentTemp.
head.
title <<
ENDL;
116 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 0A, no template load" <<
ENDL;
return false;}
123 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 0B, no template load" 124 <<
ENDL;
return false;}
131 theCurrentTemp.
head.
fbin[1] = 1.00f;
132 theCurrentTemp.
head.
fbin[2] = 0.85f;
136 <<
", NTy = " << theCurrentTemp.
head.
NTy <<
", NTyx = " << theCurrentTemp.
head.
NTyx<<
", NTxx = " << theCurrentTemp.
head.
NTxx <<
", Dtype = " << theCurrentTemp.
head.
Dtype 137 <<
", Bias voltage " << theCurrentTemp.
head.
Vbias <<
", temperature " 139 <<
", 1/2 multi dcol threshold " << theCurrentTemp.
head.
s50 <<
", 1/2 single dcol threshold " << theCurrentTemp.
head.
ss50 142 <<
", Q/Q_avg fractions for Qbin defs " << theCurrentTemp.
head.
fbin[0] <<
", " << theCurrentTemp.
head.
fbin[1]
143 <<
", " << theCurrentTemp.
head.
fbin[2]
146 if(theCurrentTemp.
head.
templ_version < code_version) {
LOGERROR(
"SiPixelTemplate2D") <<
"code expects version " << code_version <<
", no template load" <<
ENDL;
return false;}
148 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;}
158 for (
int iy=0; iy < theCurrentTemp.
head.
NTyx; ++iy) {
159 for(
int jx=0; jx < theCurrentTemp.
head.
NTxx; ++jx) {
165 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 1, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
166 delete [] theCurrentTemp.
entry[0];
167 delete [] theCurrentTemp.
entry;
181 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 2, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
182 delete [] theCurrentTemp.
entry[0];
183 delete [] theCurrentTemp.
entry;
187 for (
int k=0;
k<2; ++
k) {
193 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 3, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
194 delete [] theCurrentTemp.
entry[0];
195 delete [] theCurrentTemp.
entry;
200 for (
int k=0;
k<2; ++
k) {
206 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 4, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
207 delete [] theCurrentTemp.
entry[0];
208 delete [] theCurrentTemp.
entry;
218 for (
int l=0;
l<7; ++
l) {
219 for (
int k=0;
k<7; ++
k) {
220 for (
int j=0; j<
T2XSIZE; ++j) {
225 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 5, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
226 delete [] theCurrentTemp.
entry[0];
227 delete [] theCurrentTemp.
entry;
243 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 6, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
244 delete [] theCurrentTemp.
entry[0];
245 delete [] theCurrentTemp.
entry;
253 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 7, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
254 delete [] theCurrentTemp.
entry[0];
255 delete [] theCurrentTemp.
entry;
264 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 8, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
265 delete [] theCurrentTemp.
entry[0];
266 delete [] theCurrentTemp.
entry;
279 pixelTemp.push_back(theCurrentTemp);
287 LOGERROR(
"SiPixelTemplate2D") <<
"Error opening File" << tempfile <<
ENDL;
295 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 306 const int code_version={21};
321 for (
int i=0;
i<20; ++
i) {
330 LOGINFO(
"SiPixelTemplate2D") <<
"Loading Pixel Template File - " << theCurrentTemp.
head.
title <<
ENDL;
338 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 0A, no template load" <<
ENDL;
return false;}
340 LOGINFO(
"SiPixelTemplate2D") <<
"Loading Pixel Template File - " << theCurrentTemp.
head.
title 341 <<
" code version = "<<code_version
348 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 0B, no template load" 349 <<
ENDL;
return false;}
355 theCurrentTemp.
head.
fbin[0] = 1.50f;
356 theCurrentTemp.
head.
fbin[1] = 1.00f;
357 theCurrentTemp.
head.
fbin[2] = 0.85f;
361 <<
"Template ID = " << theCurrentTemp.
head.
ID <<
", Template Version " 363 << theCurrentTemp.
head.
Bfield<<
", NTy = " << theCurrentTemp.
head.
NTy <<
", NTyx = " 364 << theCurrentTemp.
head.
NTyx<<
", NTxx = " << theCurrentTemp.
head.
NTxx <<
", Dtype = " 365 << theCurrentTemp.
head.
Dtype<<
", Bias voltage " << theCurrentTemp.
head.
Vbias <<
", temperature " 367 <<
", Q-scaling factor " << theCurrentTemp.
head.
qscale 368 <<
", 1/2 multi dcol threshold " << theCurrentTemp.
head.
s50 <<
", 1/2 single dcol threshold " 373 <<
", Q/Q_avg fractions for Qbin defs " << theCurrentTemp.
head.
fbin[0]
374 <<
", " << theCurrentTemp.
head.
fbin[1]
375 <<
", " << theCurrentTemp.
head.
fbin[2]
376 <<
", pixel x-size " << theCurrentTemp.
head.
xsize 380 LOGINFO(
"SiPixelTemplate2D") <<
"code expects version "<< code_version <<
" finds " 384 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;}
395 for (
int iy=0; iy < theCurrentTemp.
head.
NTyx; ++iy) {
396 for(
int jx=0; jx < theCurrentTemp.
head.
NTxx; ++jx) {
402 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 1, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
403 delete [] theCurrentTemp.
entry[0];
404 delete [] theCurrentTemp.
entry;
418 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 2, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
419 delete [] theCurrentTemp.
entry[0];
420 delete [] theCurrentTemp.
entry;
424 for (
int k=0;
k<2; ++
k) {
430 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 3, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
431 delete [] theCurrentTemp.
entry[0];
432 delete [] theCurrentTemp.
entry;
438 for (
int k=0;
k<2; ++
k) {
444 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 4, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
445 delete [] theCurrentTemp.
entry[0];
446 delete [] theCurrentTemp.
entry;
455 for (
int l=0;
l<7; ++
l) {
456 for (
int k=0;
k<7; ++
k) {
457 for (
int j=0; j<
T2XSIZE; ++j) {
462 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 5, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
463 delete [] theCurrentTemp.
entry[0];
464 delete [] theCurrentTemp.
entry;
479 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 6, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
480 delete [] theCurrentTemp.
entry[0];
481 delete [] theCurrentTemp.
entry;
489 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 7, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
490 delete [] theCurrentTemp.
entry[0];
491 delete [] theCurrentTemp.
entry;
500 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 8, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
501 delete [] theCurrentTemp.
entry[0];
502 delete [] theCurrentTemp.
entry;
511 pixelTemp.push_back(theCurrentTemp);
525 if(
id != id_current_) {
530 for(
int i=0;
i<(
int)thePixelTemp_.size(); ++
i) {
532 if(
id == thePixelTemp_[
i].head.ID) {
539 Dtype_ = thePixelTemp_[index_id_].head.Dtype;
543 qscale_ = thePixelTemp_[index_id_].head.qscale;
547 s50_ = thePixelTemp_[index_id_].head.s50;
551 for(
int j=0; j<3; ++j) {fbin_[j] = thePixelTemp_[index_id_].head.fbin[j];}
555 lorywidth_ = thePixelTemp_[index_id_].head.lorywidth;
556 lorxwidth_ = thePixelTemp_[index_id_].head.lorxwidth;
560 xsize_ = thePixelTemp_[index_id_].head.xsize;
561 ysize_ = thePixelTemp_[index_id_].head.ysize;
562 zsize_ = thePixelTemp_[index_id_].head.zsize;
566 Nyx_ = thePixelTemp_[index_id_].head.NTyx;
567 Nxx_ = thePixelTemp_[index_id_].head.NTxx;
568 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 569 if(Nyx_ < 2 || Nxx_ < 2) {
570 throw cms::Exception(
"DataCorrupt") <<
"template ID = " << id_current_ <<
"has too few entries: Nyx/Nxx = " << Nyx_ <<
"/" << Nxx_ << std::endl;
573 assert(Nyx_ > 1 && Nxx_ > 1);
577 cotalpha0_ = thePixelTemp_[index_id_].entry[0][0].cotalpha;
578 cotalpha1_ = thePixelTemp_[index_id_].entry[0][Nxx_-1].cotalpha;
579 deltacota_ = (cotalpha1_-cotalpha0_)/(
float)(Nxx_-1);
581 cotbeta0_ = thePixelTemp_[index_id_].entry[0][imidx].cotbeta;
582 cotbeta1_ = thePixelTemp_[index_id_].entry[Nyx_-1][imidx].cotbeta;
583 deltacotb_ = (cotbeta1_-cotbeta0_)/(
float)(Nyx_-1);
590 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 591 if(index_id_ < 0 || index_id_ >= (
int)thePixelTemp_.size()) {
592 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate2D::interpolate can't find needed template ID = " <<
id 593 <<
", Are you using the correct global tag?" << std::endl;
596 assert(index_id_ >= 0 && index_id_ < (
int)thePixelTemp_.size());
622 float acotb, dcota, dcotb;
626 if(
id != id_current_ || cotalpha != cota_current_ || cotbeta != cotb_current_) {
627 cota_current_ = cotalpha; cotb_current_ = cotbeta;
628 success_ = getid(
id);
631 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 632 if(index_id_ < 0 || index_id_ >= (
int)thePixelTemp_.size()) {
633 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate2D::interpolate can't find needed template ID = " <<
id 634 <<
", Are you using the correct global tag?" << std::endl;
637 assert(index_id_ >= 0 && index_id_ < (
int)thePixelTemp_.size());
642 float cota = cotalpha;
647 if(cotbeta < 0.
f) {flip_y_ =
true;}
650 if(locBz > 0.
f) {flip_y_ =
true;}
656 if(locBx*locBz < 0.
f) {
657 cota = fabs(cotalpha);
660 if(locBx < 0.
f) {flip_y_ =
true;}
663 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 664 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate2D::illegal subdetector ID = " << thePixelTemp_[index_id_].head.Dtype << std::endl;
672 std::cout <<
"SiPixelTemplate:2D:illegal subdetector ID = " << thePixelTemp_[index_id_].head.Dtype << std::endl;
676 if(cota < cotalpha0_) {
681 }
else if(cota > cotalpha1_) {
687 jx0_ = (
int)((cota-cotalpha0_)/deltacota_+0.5f);
688 dcota = (cota - (cotalpha0_ + jx0_*deltacota_))/deltacota_;
689 adcota_ = fabs(dcota);
690 if(dcota > 0.
f) {jx1_ = jx0_ + 1;
if(jx1_ > Nxx_-1) jx1_ = jx0_-1;}
else {jx1_ = jx0_ - 1;
if(jx1_ < 0) jx1_ = jx0_+1;}
695 acotb = fabs(cotbeta);
697 if(acotb < cotbeta0_) {
702 }
else if(acotb > cotbeta1_) {
708 iy0_ = (
int)((acotb-cotbeta0_)/deltacotb_+0.5f);
709 dcotb = (acotb - (cotbeta0_ + iy0_*deltacotb_))/deltacotb_;
710 adcotb_ = fabs(dcotb);
711 if(dcotb > 0.
f) {iy1_ = iy0_ + 1;
if(iy1_ > Nyx_-1) iy1_ = iy0_-1;}
else {iy1_ = iy0_ - 1;
if(iy1_ < 0) iy1_ = iy0_+1;}
716 lorydrift_ = lorywidth_/2.;
717 if(flip_y_) lorydrift_ = -lorydrift_;
718 lorxdrift_ = lorxwidth_/2.;
719 if(flip_x_) lorxdrift_ = -lorxdrift_;
724 entry00_ = &thePixelTemp_[index_id_].entry[iy0_][jx0_];
725 entry10_ = &thePixelTemp_[index_id_].entry[iy1_][jx0_];
726 entry01_ = &thePixelTemp_[index_id_].entry[iy0_][jx1_];
730 qavg_ = entry00_->qavg
731 +adcota_*(entry01_->qavg - entry00_->qavg)
732 +adcotb_*(entry10_->qavg - entry00_->qavg);
734 pixmax_ = entry00_->pixmax
735 +adcota_*(entry01_->pixmax - entry00_->pixmax)
736 +adcotb_*(entry10_->pixmax - entry00_->pixmax);
738 sxymax_ = entry00_->sxymax
739 +adcota_*(entry01_->sxymax - entry00_->sxymax)
740 +adcotb_*(entry10_->sxymax - entry00_->sxymax);
742 chi2avgone_ = entry00_->chi2avgone
743 +adcota_*(entry01_->chi2avgone - entry00_->chi2avgone)
744 +adcotb_*(entry10_->chi2avgone - entry00_->chi2avgone);
746 chi2minone_ = entry00_->chi2minone
747 +adcota_*(entry01_->chi2minone - entry00_->chi2minone)
748 +adcotb_*(entry10_->chi2minone - entry00_->chi2minone);
750 clsleny_ = entry00_->clsleny
751 +adcota_*(entry01_->clsleny - entry00_->clsleny)
752 +adcotb_*(entry10_->clsleny - entry00_->clsleny);
754 clslenx_ = entry00_->clslenx
755 +adcota_*(entry01_->clslenx - entry00_->clslenx)
756 +adcotb_*(entry10_->clslenx - entry00_->clslenx);
759 chi2ppix_ = entry00_->chi2ppix
760 +adcota_*(entry01_->chi2ppix - entry00_->chi2ppix)
761 +adcotb_*(entry10_->chi2ppix - entry00_->chi2ppix);
763 chi2scale_ = entry00_->chi2scale
764 +adcota_*(entry01_->chi2scale - entry00_->chi2scale)
765 +adcotb_*(entry10_->chi2scale - entry00_->chi2scale);
767 scaleyavg_ = entry00_->scaleyavg
768 +adcota_*(entry01_->scaleyavg - entry00_->scaleyavg)
769 +adcotb_*(entry10_->scaleyavg - entry00_->scaleyavg);
771 scalexavg_ = entry00_->scalexavg
772 +adcota_*(entry01_->scalexavg - entry00_->scalexavg)
773 +adcotb_*(entry10_->scalexavg - entry00_->scalexavg);
775 delyavg_ = entry00_->delyavg
776 +adcota_*(entry01_->delyavg - entry00_->delyavg)
777 +adcotb_*(entry10_->delyavg - entry00_->delyavg);
779 delysig_ = entry00_->delysig
780 +adcota_*(entry01_->delysig - entry00_->delysig)
781 +adcotb_*(entry10_->delysig - entry00_->delysig);
783 mpvvav_ = entry00_->mpvvav
784 +adcota_*(entry01_->mpvvav - entry00_->mpvvav)
785 +adcotb_*(entry10_->mpvvav - entry00_->mpvvav);
787 sigmavav_ = entry00_->sigmavav
788 +adcota_*(entry01_->sigmavav - entry00_->sigmavav)
789 +adcotb_*(entry10_->sigmavav - entry00_->sigmavav);
791 kappavav_ = entry00_->kappavav
792 +adcota_*(entry01_->kappavav - entry00_->kappavav)
793 +adcotb_*(entry10_->kappavav - entry00_->kappavav);
795 for(
int i=0;
i<4 ; ++
i) {
796 scalex_[
i] = entry00_->scalex[
i]
797 +adcota_*(entry01_->scalex[
i] - entry00_->scalex[
i])
798 +adcotb_*(entry10_->scalex[
i] - entry00_->scalex[
i]);
800 scaley_[
i] = entry00_->scaley[
i]
801 +adcota_*(entry01_->scaley[
i] - entry00_->scaley[
i])
802 +adcotb_*(entry10_->scaley[
i] - entry00_->scaley[
i]);
804 offsetx_[
i] = entry00_->offsetx[
i]
805 +adcota_*(entry01_->offsetx[
i] - entry00_->offsetx[
i])
806 +adcotb_*(entry10_->offsetx[
i] - entry00_->offsetx[
i]);
807 if(flip_x_) offsetx_[
i] = -offsetx_[
i];
809 offsety_[
i] = entry00_->offsety[
i]
810 +adcota_*(entry01_->offsety[
i] - entry00_->offsety[
i])
811 +adcotb_*(entry10_->offsety[
i] - entry00_->offsety[
i]);
812 if(flip_y_) offsety_[
i] = -offsety_[
i];
815 for(
int i=0;
i<2 ; ++
i) {
816 for(
int j=0; j<5 ; ++j) {
819 xypary0x0_[1-
i][j] = (
float)entry00_->xypar[
i][j];
820 xypary1x0_[1-
i][j] = (
float)entry10_->xypar[
i][j];
821 xypary0x1_[1-
i][j] = (
float)entry01_->xypar[
i][j];
822 lanpar_[1-
i][j] = entry00_->lanpar[
i][j]
823 +adcota_*(entry01_->lanpar[
i][j] - entry00_->lanpar[
i][j])
824 +adcotb_*(entry10_->lanpar[
i][j] - entry00_->lanpar[
i][j]);
826 xypary0x0_[
i][j] = (
float)entry00_->xypar[
i][j];
827 xypary1x0_[
i][j] = (
float)entry10_->xypar[
i][j];
828 xypary0x1_[
i][j] = (
float)entry01_->xypar[
i][j];
829 lanpar_[
i][j] = entry00_->lanpar[
i][j]
830 +adcota_*(entry01_->lanpar[
i][j] - entry00_->lanpar[
i][j])
831 +adcotb_*(entry10_->lanpar[
i][j] - entry00_->lanpar[
i][j]);
848 void SiPixelTemplate2D::sideload(
SiPixelTemplateEntry2D*
entry,
int iDtype,
float locBx,
float locBz,
float lorwdy,
float lorwdx,
float q50,
float fbin[3],
float xsize,
float ysize,
float zsize)
863 for(
int i=0;
i<3; ++
i) {fbin_[
i] = fbin[
i];}
872 qavg_ = entry00_->qavg;
874 pixmax_ = entry00_->pixmax;
876 sxymax_ = entry00_->sxymax;
878 clsleny_ = entry00_->clsleny;
880 clslenx_ = entry00_->clslenx;
890 for(
int i=0;
i<4 ; ++
i) {
901 float cotbeta = entry00_->cotbeta;
904 if(cotbeta < 0.
f) {flip_y_ =
true;}
915 if(locBx*locBz < 0.
f) {
923 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 924 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate2D::illegal subdetector ID = " << iDtype << std::endl;
926 std::cout <<
"SiPixelTemplate:2D:illegal subdetector ID = " << iDtype << std::endl;
932 lorydrift_ = lorywidth_/2.;
933 if(flip_y_) lorydrift_ = -lorydrift_;
934 lorxdrift_ = lorxwidth_/2.;
935 if(flip_x_) lorxdrift_ = -lorxdrift_;
937 for(
int i=0;
i<2 ; ++
i) {
938 for(
int j=0; j<5 ; ++j) {
941 xypary0x0_[1-
i][j] = (
float)entry00_->xypar[
i][j];
942 xypary1x0_[1-
i][j] = (
float)entry00_->xypar[
i][j];
943 xypary0x1_[1-
i][j] = (
float)entry00_->xypar[
i][j];
944 lanpar_[1-
i][j] = entry00_->lanpar[
i][j];
946 xypary0x0_[
i][j] = (
float)entry00_->xypar[
i][j];
947 xypary1x0_[
i][j] = (
float)entry00_->xypar[
i][j];
948 xypary0x1_[
i][j] = (
float)entry00_->xypar[
i][j];
949 lanpar_[
i][j] = entry00_->lanpar[
i][j];
965 bool SiPixelTemplate2D::xytemp(
float xhit,
float yhit,
bool ydouble[
BYM2],
bool xdouble[
BXM2],
float template2d[BXM2][BYM2],
bool derivatives,
float dpdx2d[2][BXM2][BYM2],
float& QTemplate)
970 int pixx, pixy,
k0, k1, l0, l1, deltax, deltay, iflipy, jflipx, imin, imax, jmin, jmax;
972 float dx,
dy, ddx, ddy, adx, ady;
974 const float deltaxy[2] = {16.67f, 25.0f};
984 pixy = (
int)floorf(yhit/ysize_);
985 dy = yhit-(pixy+0.5f)*ysize_;
986 if(flip_y_) {dy = -
dy;}
987 k0 = (
int)(dy/ysize_*6.
f+3.5
f);
990 ddy = 6.f*dy/ysize_ - (k0-3);
992 if(ddy > 0.
f) {k1 = k0 + 1;
if(k1 > 6) k1 = k0-1;}
else {k1 = k0 - 1;
if(k1 < 0) k1 = k0+1;}
993 pixx = (
int)floorf(xhit/xsize_);
994 dx = xhit-(pixx+0.5f)*xsize_;
995 if(flip_x_) {dx = -
dx;}
996 l0 = (
int)(dx/xsize_*6.
f+3.5
f);
999 ddx = 6.f*dx/xsize_ - (l0-3);
1001 if(ddx > 0.
f) {l1 = l0 + 1;
if(l1 > 6) l1 = l0-1;}
else {l1 = l0 - 1;
if(l1 < 0) l1 = l0+1;}
1007 imin =
std::min(entry00_->iymin,entry10_->iymin);
1008 imin_ =
std::min(imin,entry01_->iymin);
1010 jmin =
std::min(entry00_->jxmin,entry10_->jxmin);
1011 jmin_ =
std::min(jmin,entry01_->jxmin);
1013 imax =
std::max(entry00_->iymax,entry10_->iymax);
1014 imax_ =
std::max(imax,entry01_->iymax);
1016 jmax =
std::max(entry00_->jxmax,entry10_->jxmax);
1017 jmax_ =
std::max(jmax,entry01_->jxmax);
1027 deltax = pixx -
T2HX;
1028 deltay = pixy -
T2HY;
1032 for(
int j=0; j<
BXM2; ++j) {
for(
int i=0;
i<
BYM2; ++
i) {xytemp_[j][
i] = 0.f;}}
1036 for(
int j=jmin_; j<=jmax_; ++j) {
1038 if(flip_x_) {jflipx=
T2XSIZE-1-j; m = deltax+jflipx;}
else {m = deltax+j;}
1039 for(
int i=imin_;
i<=imax_; ++
i) {
1040 if(flip_y_) {iflipy=
T2YSIZE-1-
i; n = deltay+iflipy;}
else {n = deltay+
i;}
1041 if(m>=0 && m<=BXM3 && n>=0 && n<=
BYM3) {
1042 xytemp_[
m][
n] = (
float)entry00_->xytemp[k0][l0][
i][j]
1043 + adx*(
float)(entry00_->xytemp[
k0][l1][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1044 + ady*(
float)(entry00_->xytemp[k1][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1045 + adcota_*(
float)(entry01_->xytemp[
k0][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1046 + adcotb_*(
float)(entry10_->xytemp[
k0][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j]);
1053 for(
int n=1; n<
BYM3; ++
n) {
1056 for(
int m=1; m<
BXM3; ++
m) {
1057 xytemp_[
m][
n] += xytemp_[
m][n+1];
1061 for(
int m=1; m<
BXM3; ++
m) {
1062 xytemp_[
m][
i] = xytemp_[
m][
i+1];
1070 for(
int m=1; m<
BXM3; ++
m) {
1073 for(
int n=1; n<
BYM3; ++
n) {
1074 xytemp_[
m][
n] += xytemp_[m+1][
n];
1077 for(
int j=m+1; j<
BXM3; ++j) {
1078 for(n=1; n<
BYM3; ++
n) {
1079 xytemp_[j][
n] = xytemp_[j+1][
n];
1087 float qtemptot = 0.f;
1089 for(
int n=1; n<
BYM3; ++
n) {
1090 for(
int m=1; m<
BXM3; ++
m) {
1091 if(xytemp_[m][n] != 0.
f) {template2d[
m][
n] += xytemp_[
m][
n]; qtemptot += xytemp_[
m][
n];}
1095 QTemplate = qtemptot;
1101 for(
int k = 0;
k<2; ++
k) {
1103 for(
int j = 0; j<
BYM2; ++j) {
1104 dxytempdx[
k][
i][j] = 0.f;
1105 dxytempdy[
k][
i][j] = 0.f;
1106 dpdx2d[
k][
i][j] = 0.f;
1113 pixx = (
int)floorf((xhit+deltaxy[0])/xsize_);
1114 dx = (xhit+deltaxy[0])-(pixx+0.5
f)*xsize_;
1115 if(flip_x_) {dx = -
dx;}
1116 l0 = (
int)(dx/xsize_*6.
f+3.5
f);
1119 ddx = 6.f*dx/xsize_ - (l0-3);
1121 if(ddx > 0.
f) {l1 = l0 + 1;
if(l1 > 6) l1 = l0-1;}
else {l1 = l0 - 1;
if(l1 < 0) l1 = l0+1;}
1133 deltax = pixx -
T2HX;
1137 for(
int j=jmin_; j<=jmax_; ++j) {
1139 if(flip_x_) {jflipx=
T2XSIZE-1-j; m = deltax+jflipx;}
else {m = deltax+j;}
1140 for(
int i=imin_;
i<=imax_; ++
i) {
1141 if(flip_y_) {iflipy=
T2YSIZE-1-
i; n = deltay+iflipy;}
else {n = deltay+
i;}
1142 if(m>=0 && m<=BXM3 && n>=0 && n<=BYM3) {
1143 dxytempdx[1][
m][
n] = (
float)entry00_->xytemp[k0][l0][
i][j]
1144 + adx*(
float)(entry00_->xytemp[
k0][l1][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1145 + ady*(
float)(entry00_->xytemp[k1][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1146 + adcota_*(
float)(entry01_->xytemp[
k0][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1147 + adcotb_*(
float)(entry10_->xytemp[
k0][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j]);
1154 for(
int n=1; n<
BYM3; ++
n) {
1157 for(
int m=1; m<
BXM3; ++
m) {
1158 dxytempdx[1][
m][
n] += dxytempdx[1][
m][n+1];
1162 for(
int m=1; m<
BXM3; ++
m) {
1163 dxytempdx[1][
m][
i] = dxytempdx[1][
m][
i+1];
1171 for(
int m=1; m<
BXM3; ++
m) {
1174 for(
int n=1; n<
BYM3; ++
n) {
1175 dxytempdx[1][
m][
n] += dxytempdx[1][m+1][
n];
1178 for(
int j=m+1; j<
BXM3; ++j) {
1179 for(
int n=1; n<
BYM3; ++
n) {
1180 dxytempdx[1][j][
n] = dxytempdx[1][j+1][
n];
1188 pixx = (
int)floorf((xhit-deltaxy[0])/xsize_);
1189 dx = (xhit-deltaxy[0])-(pixx+0.5
f)*xsize_;
1190 if(flip_x_) {dx = -
dx;}
1191 l0 = (
int)(dx/xsize_*6.
f+3.5
f);
1194 ddx = 6.f*dx/xsize_ - (l0-3);
1196 if(ddx > 0.
f) {l1 = l0 + 1;
if(l1 > 6) l1 = l0-1;}
else {l1 = l0 - 1;
if(l1 < 0) l1 = l0+1;}
1208 deltax = pixx -
T2HX;
1212 for(
int j=jmin_; j<=jmax_; ++j) {
1214 if(flip_x_) {jflipx=
T2XSIZE-1-j; m = deltax+jflipx;}
else {m = deltax+j;}
1215 for(
int i=imin_;
i<=imax_; ++
i) {
1216 if(flip_y_) {iflipy=
T2YSIZE-1-
i; n = deltay+iflipy;}
else {n = deltay+
i;}
1217 if(m>=0 && m<=BXM3 && n>=0 && n<=BYM3) {
1218 dxytempdx[0][
m][
n] = (
float)entry00_->xytemp[k0][l0][
i][j]
1219 + adx*(
float)(entry00_->xytemp[
k0][l1][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1220 + ady*(
float)(entry00_->xytemp[k1][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1221 + adcota_*(
float)(entry01_->xytemp[
k0][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1222 + adcotb_*(
float)(entry10_->xytemp[
k0][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j]);
1229 for(
int n=1; n<
BYM3; ++
n) {
1232 for(
int m=1; m<
BXM3; ++
m) {
1233 dxytempdx[0][
m][
n] += dxytempdx[0][
m][n+1];
1237 for(
int m=1; m<
BXM3; ++
m) {
1238 dxytempdx[0][
m][
i] = dxytempdx[0][
m][
i+1];
1246 for(
int m=1; m<
BXM3; ++
m) {
1249 for(
int n=1; n<
BYM3; ++
n) {
1250 dxytempdx[0][
m][
n] += dxytempdx[0][m+1][
n];
1253 for(
int j=m+1; j<
BXM3; ++j) {
1254 for(
int n=1; n<
BYM3; ++
n) {
1255 dxytempdx[0][j][
n] = dxytempdx[0][j+1][
n];
1264 for(
int n=1; n<
BYM3; ++
n) {
1265 for(
int m=1; m<
BXM3; ++
m) {
1266 dpdx2d[0][
m][
n] = (dxytempdx[1][
m][
n] - dxytempdx[0][
m][
n])/(2.*deltaxy[0]);
1272 pixy = (
int)floorf((yhit+deltaxy[1])/ysize_);
1273 dy = (yhit+deltaxy[1])-(pixy+0.5
f)*ysize_;
1274 if(flip_y_) {dy = -
dy;}
1275 k0 = (
int)(dy/ysize_*6.
f+3.5
f);
1278 ddy = 6.f*dy/ysize_ - (k0-3);
1280 if(ddy > 0.
f) {k1 = k0 + 1;
if(k1 > 6) k1 = k0-1;}
else {k1 = k0 - 1;
if(k1 < 0) k1 = k0+1;}
1281 pixx = (
int)floorf(xhit/xsize_);
1282 dx = xhit-(pixx+0.5f)*xsize_;
1283 if(flip_x_) {dx = -
dx;}
1284 l0 = (
int)(dx/xsize_*6.
f+3.5
f);
1287 ddx = 6.f*dx/xsize_ - (l0-3);
1289 if(ddx > 0.
f) {l1 = l0 + 1;
if(l1 > 6) l1 = l0-1;}
else {l1 = l0 - 1;
if(l1 < 0) l1 = l0+1;}
1301 deltax = pixx -
T2HX;
1302 deltay = pixy -
T2HY;
1306 for(
int j=jmin_; j<=jmax_; ++j) {
1308 if(flip_x_) {jflipx=
T2XSIZE-1-j; m = deltax+jflipx;}
else {m = deltax+j;}
1309 for(
int i=imin_;
i<=imax_; ++
i) {
1310 if(flip_y_) {iflipy=
T2YSIZE-1-
i; n = deltay+iflipy;}
else {n = deltay+
i;}
1311 if(m>=0 && m<=BXM3 && n>=0 && n<=BYM3) {
1312 dxytempdy[1][
m][
n] = (
float)entry00_->xytemp[k0][l0][
i][j]
1313 + adx*(
float)(entry00_->xytemp[
k0][l1][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1314 + ady*(
float)(entry00_->xytemp[k1][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1315 + adcota_*(
float)(entry01_->xytemp[
k0][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1316 + adcotb_*(
float)(entry10_->xytemp[
k0][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j]);
1323 for(
int n=1; n<
BYM3; ++
n) {
1326 for(
int m=1; m<
BXM3; ++
m) {
1327 dxytempdy[1][
m][
n] += dxytempdy[1][
m][n+1];
1331 for(
int m=1; m<
BXM3; ++
m) {
1332 dxytempdy[1][
m][
i] = dxytempdy[1][
m][
i+1];
1340 for(
int m=1; m<
BXM3; ++
m) {
1343 for(
int n=1; n<
BYM3; ++
n) {
1344 dxytempdy[1][
m][
n] += dxytempdy[1][m+1][
n];
1347 for(
int j=m+1; j<
BXM3; ++j) {
1348 for(
int n=1; n<
BYM3; ++
n) {
1349 dxytempdy[1][j][
n] = dxytempdy[1][j+1][
n];
1357 pixy = (
int)floorf((yhit-deltaxy[1])/ysize_);
1358 dy = (yhit-deltaxy[1])-(pixy+0.5
f)*ysize_;
1359 if(flip_y_) {dy = -
dy;}
1360 k0 = (
int)(dy/ysize_*6.
f+3.5
f);
1363 ddy = 6.f*dy/ysize_ - (k0-3);
1365 if(ddy > 0.
f) {k1 = k0 + 1;
if(k1 > 6) k1 = k0-1;}
else {k1 = k0 - 1;
if(k1 < 0) k1 = k0+1;}
1377 deltay = pixy -
T2HY;
1381 for(
int j=jmin_; j<=jmax_; ++j) {
1383 if(flip_x_) {jflipx=
T2XSIZE-1-j; m = deltax+jflipx;}
else {m = deltax+j;}
1384 for(
int i=imin_;
i<=imax_; ++
i) {
1385 if(flip_y_) {iflipy=
T2YSIZE-1-
i; n = deltay+iflipy;}
else {n = deltay+
i;}
1386 if(m>=0 && m<=BXM3 && n>=0 && n<=BYM3) {
1387 dxytempdy[0][
m][
n] = (
float)entry00_->xytemp[k0][l0][
i][j]
1388 + adx*(
float)(entry00_->xytemp[
k0][l1][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1389 + ady*(
float)(entry00_->xytemp[k1][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1390 + adcota_*(
float)(entry01_->xytemp[
k0][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1391 + adcotb_*(
float)(entry10_->xytemp[
k0][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j]);
1398 for(
int n=1; n<
BYM3; ++
n) {
1401 for(
int m=1; m<
BXM3; ++
m) {
1402 dxytempdy[0][
m][
n] += dxytempdy[0][
m][n+1];
1406 for(
int m=1; m<
BXM3; ++
m) {
1407 dxytempdy[0][
m][
i] = dxytempdy[0][
m][
i+1];
1415 for(
int m=1; m<
BXM3; ++
m) {
1418 for(
int n=1; n<
BYM3; ++
n) {
1419 dxytempdy[0][
m][
n] += dxytempdy[0][m+1][
n];
1422 for(
int j=m+1; j<
BXM3; ++j) {
1423 for(
int n=1; n<
BYM3; ++
n) {
1424 dxytempdy[0][j][
n] = dxytempdy[0][j+1][
n];
1432 for(
int n=1; n<
BYM3; ++
n) {
1433 for(
int m=1; m<
BXM3; ++
m) {
1434 dpdx2d[1][
m][
n] = (dxytempdy[1][
m][
n] - dxytempdy[0][
m][
n])/(2.*deltaxy[1]);
1457 bool derivatives =
false;
1484 bool derivatives =
false;
1488 if(cotbeta < 0.
f) {locBx = -1.f;}
1489 float locBz = locBx;
1490 if(cotalpha < 0.
f) {locBz = -locBx;}
1494 yd[0] =
false; yd[BYM2-1] =
false;
1495 for(
int i=0;
i<
TYSIZE; ++
i) { yd[
i+1] = ydouble[
i];}
1496 xd[0] =
false; xd[
BXM2-1] =
false;
1497 for(
int j=0; j<
TXSIZE; ++j) { xd[j+1] = xdouble[j];}
1524 float sigi, sigi2, sigi3, sigi4, qscale, err2, err00;
1528 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 1529 if(index < 1 || index >=
BYM2) {
1530 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate2D::ysigma2 called with index = " << index << std::endl;
1533 assert(index > 0 && index <
BYM2);
1540 if(qpixel < sxymax_) {
1545 qscale = qpixel/sxymax_;
1547 sigi2 = sigi*sigi; sigi3 = sigi2*sigi; sigi4 = sigi3*sigi;
1549 err00 = xypary0x0_[0][0]+xypary0x0_[0][1]*sigi+xypary0x0_[0][2]*sigi2+xypary0x0_[0][3]*sigi3+xypary0x0_[0][4]*sigi4;
1551 +adcota_*(xypary0x1_[0][0]+xypary0x1_[0][1]*sigi+xypary0x1_[0][2]*sigi2+xypary0x1_[0][3]*sigi3+xypary0x1_[0][4]*sigi4 - err00)
1552 +adcotb_*(xypary1x0_[0][0]+xypary1x0_[0][1]*sigi+xypary1x0_[0][2]*sigi2+xypary1x0_[0][3]*sigi3+xypary1x0_[0][4]*sigi4 - err00);
1554 err00 = xypary0x0_[1][0]+xypary0x0_[1][1]*sigi+xypary0x0_[1][2]*sigi2+xypary0x0_[1][3]*sigi3+xypary0x0_[1][4]*sigi4;
1556 +adcota_*(xypary0x1_[1][0]+xypary0x1_[1][1]*sigi+xypary0x1_[1][2]*sigi2+xypary0x1_[1][3]*sigi3+xypary0x1_[1][4]*sigi4 - err00)
1557 +adcotb_*(xypary1x0_[1][0]+xypary1x0_[1][1]*sigi+xypary1x0_[1][2]*sigi2+xypary1x0_[1][3]*sigi3+xypary1x0_[1][4]*sigi4 - err00);
1559 xysig2 =qscale*err2;
1560 if(xysig2 <= 0.
f) {xysig2 = s50_*s50_;}
1575 for(
int i=0;
i<2; ++
i) {
1576 for(
int j=0; j<5; ++j) {
1577 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
constexpr bool isFinite(T x)
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