27 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 40 #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 67 const int code_version={21};
75 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 77 int nzeros = 4-tempfile.length();
82 tempfile = dir +
"template_summary2D_zp" + tempfile +
".out";
88 std::ostringstream tout;
89 tout <<
"template_summary2D_zp" << std::setw(4) << std::setfill(
'0') << std::right << filenum <<
".out" << std::ends;
90 tempfile = tout.str();
96 std::ifstream
in_file(tempfile);
97 if(in_file.is_open() && in_file.good()) {
104 for (
int i=0; (c=in_file.get()) !=
'\n'; ++
i) {
106 else {theCurrentTemp.
head.
title[79] =
'\0';}
108 LOGINFO(
"SiPixelTemplate2D") <<
"Loading Pixel Template File - " << theCurrentTemp.
head.
title <<
ENDL;
115 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 0A, no template load" <<
ENDL;
return false;}
122 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 0B, no template load" 123 <<
ENDL;
return false;}
130 theCurrentTemp.
head.
fbin[1] = 1.00f;
131 theCurrentTemp.
head.
fbin[2] = 0.85f;
135 <<
", NTy = " << theCurrentTemp.
head.
NTy <<
", NTyx = " << theCurrentTemp.
head.
NTyx<<
", NTxx = " << theCurrentTemp.
head.
NTxx <<
", Dtype = " << theCurrentTemp.
head.
Dtype 136 <<
", Bias voltage " << theCurrentTemp.
head.
Vbias <<
", temperature " 138 <<
", 1/2 multi dcol threshold " << theCurrentTemp.
head.
s50 <<
", 1/2 single dcol threshold " << theCurrentTemp.
head.
ss50 141 <<
", Q/Q_avg fractions for Qbin defs " << theCurrentTemp.
head.
fbin[0] <<
", " << theCurrentTemp.
head.
fbin[1]
142 <<
", " << theCurrentTemp.
head.
fbin[2]
145 if(theCurrentTemp.
head.
templ_version < code_version) {
LOGERROR(
"SiPixelTemplate2D") <<
"code expects version " << code_version <<
", no template load" <<
ENDL;
return false;}
147 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;}
157 for (
int iy=0; iy < theCurrentTemp.
head.
NTyx; ++iy) {
158 for(
int jx=0; jx < theCurrentTemp.
head.
NTxx; ++jx) {
164 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 1, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
165 delete [] theCurrentTemp.
entry[0];
166 delete [] theCurrentTemp.
entry;
180 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 2, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
181 delete [] theCurrentTemp.
entry[0];
182 delete [] theCurrentTemp.
entry;
186 for (
int k=0;
k<2; ++
k) {
192 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 3, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
193 delete [] theCurrentTemp.
entry[0];
194 delete [] theCurrentTemp.
entry;
199 for (
int k=0;
k<2; ++
k) {
205 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 4, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
206 delete [] theCurrentTemp.
entry[0];
207 delete [] theCurrentTemp.
entry;
217 for (
int l=0;
l<7; ++
l) {
218 for (
int k=0;
k<7; ++
k) {
219 for (
int j=0; j<
T2XSIZE; ++j) {
224 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 5, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
225 delete [] theCurrentTemp.
entry[0];
226 delete [] theCurrentTemp.
entry;
242 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 6, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
243 delete [] theCurrentTemp.
entry[0];
244 delete [] theCurrentTemp.
entry;
252 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 7, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
253 delete [] theCurrentTemp.
entry[0];
254 delete [] theCurrentTemp.
entry;
263 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 8, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
264 delete [] theCurrentTemp.
entry[0];
265 delete [] theCurrentTemp.
entry;
278 pixelTemp.push_back(theCurrentTemp);
286 LOGERROR(
"SiPixelTemplate2D") <<
"Error opening File" << tempfile <<
ENDL;
294 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 305 const int code_version={21};
320 for (
int i=0;
i<20; ++
i) {
329 LOGINFO(
"SiPixelTemplate2D") <<
"Loading Pixel Template File - " << theCurrentTemp.
head.
title <<
ENDL;
337 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 0A, no template load" <<
ENDL;
return false;}
339 LOGINFO(
"SiPixelTemplate2D") <<
"Loading Pixel Template File - " << theCurrentTemp.
head.
title 340 <<
" code version = "<<code_version
347 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 0B, no template load" 348 <<
ENDL;
return false;}
354 theCurrentTemp.
head.
fbin[0] = 1.50f;
355 theCurrentTemp.
head.
fbin[1] = 1.00f;
356 theCurrentTemp.
head.
fbin[2] = 0.85f;
360 <<
"Template ID = " << theCurrentTemp.
head.
ID <<
", Template Version " 362 << theCurrentTemp.
head.
Bfield<<
", NTy = " << theCurrentTemp.
head.
NTy <<
", NTyx = " 363 << theCurrentTemp.
head.
NTyx<<
", NTxx = " << theCurrentTemp.
head.
NTxx <<
", Dtype = " 364 << theCurrentTemp.
head.
Dtype<<
", Bias voltage " << theCurrentTemp.
head.
Vbias <<
", temperature " 366 <<
", Q-scaling factor " << theCurrentTemp.
head.
qscale 367 <<
", 1/2 multi dcol threshold " << theCurrentTemp.
head.
s50 <<
", 1/2 single dcol threshold " 372 <<
", Q/Q_avg fractions for Qbin defs " << theCurrentTemp.
head.
fbin[0]
373 <<
", " << theCurrentTemp.
head.
fbin[1]
374 <<
", " << theCurrentTemp.
head.
fbin[2]
375 <<
", pixel x-size " << theCurrentTemp.
head.
xsize 379 LOGINFO(
"SiPixelTemplate2D") <<
"code expects version "<< code_version <<
" finds " 383 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;}
394 for (
int iy=0; iy < theCurrentTemp.
head.
NTyx; ++iy) {
395 for(
int jx=0; jx < theCurrentTemp.
head.
NTxx; ++jx) {
401 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 1, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
402 delete [] theCurrentTemp.
entry[0];
403 delete [] theCurrentTemp.
entry;
417 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 2, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
418 delete [] theCurrentTemp.
entry[0];
419 delete [] theCurrentTemp.
entry;
423 for (
int k=0;
k<2; ++
k) {
429 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 3, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
430 delete [] theCurrentTemp.
entry[0];
431 delete [] theCurrentTemp.
entry;
437 for (
int k=0;
k<2; ++
k) {
443 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 4, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
444 delete [] theCurrentTemp.
entry[0];
445 delete [] theCurrentTemp.
entry;
454 for (
int l=0;
l<7; ++
l) {
455 for (
int k=0;
k<7; ++
k) {
456 for (
int j=0; j<
T2XSIZE; ++j) {
461 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 5, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
462 delete [] theCurrentTemp.
entry[0];
463 delete [] theCurrentTemp.
entry;
478 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 6, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
479 delete [] theCurrentTemp.
entry[0];
480 delete [] theCurrentTemp.
entry;
488 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 7, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
489 delete [] theCurrentTemp.
entry[0];
490 delete [] theCurrentTemp.
entry;
499 LOGERROR(
"SiPixelTemplate2D") <<
"Error reading file 8, no template load, run # " << theCurrentTemp.
entry[iy][jx].
runnum <<
ENDL;
500 delete [] theCurrentTemp.
entry[0];
501 delete [] theCurrentTemp.
entry;
510 pixelTemp.push_back(theCurrentTemp);
524 if(
id != id_current_) {
529 for(
int i=0;
i<(
int)thePixelTemp_.size(); ++
i) {
531 if(
id == thePixelTemp_[
i].head.ID) {
538 Dtype_ = thePixelTemp_[index_id_].head.Dtype;
542 qscale_ = thePixelTemp_[index_id_].head.qscale;
546 s50_ = thePixelTemp_[index_id_].head.s50;
550 for(
int j=0; j<3; ++j) {fbin_[j] = thePixelTemp_[index_id_].head.fbin[j];}
554 lorywidth_ = thePixelTemp_[index_id_].head.lorywidth;
555 lorxwidth_ = thePixelTemp_[index_id_].head.lorxwidth;
559 xsize_ = thePixelTemp_[index_id_].head.xsize;
560 ysize_ = thePixelTemp_[index_id_].head.ysize;
561 zsize_ = thePixelTemp_[index_id_].head.zsize;
565 Nyx_ = thePixelTemp_[index_id_].head.NTyx;
566 Nxx_ = thePixelTemp_[index_id_].head.NTxx;
567 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 568 if(Nyx_ < 2 || Nxx_ < 2) {
569 throw cms::Exception(
"DataCorrupt") <<
"template ID = " << id_current_ <<
"has too few entries: Nyx/Nxx = " << Nyx_ <<
"/" << Nxx_ << std::endl;
572 assert(Nyx_ > 1 && Nxx_ > 1);
576 cotalpha0_ = thePixelTemp_[index_id_].entry[0][0].cotalpha;
577 cotalpha1_ = thePixelTemp_[index_id_].entry[0][Nxx_-1].cotalpha;
578 deltacota_ = (cotalpha1_-cotalpha0_)/(
float)(Nxx_-1);
580 cotbeta0_ = thePixelTemp_[index_id_].entry[0][imidx].cotbeta;
581 cotbeta1_ = thePixelTemp_[index_id_].entry[Nyx_-1][imidx].cotbeta;
582 deltacotb_ = (cotbeta1_-cotbeta0_)/(
float)(Nyx_-1);
589 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 590 if(index_id_ < 0 || index_id_ >= (
int)thePixelTemp_.size()) {
591 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate2D::interpolate can't find needed template ID = " <<
id 592 <<
", Are you using the correct global tag?" << std::endl;
595 assert(index_id_ >= 0 && index_id_ < (
int)thePixelTemp_.size());
621 float acotb, dcota, dcotb;
625 if(
id != id_current_ || cotalpha != cota_current_ || cotbeta != cotb_current_) {
626 cota_current_ = cotalpha; cotb_current_ = cotbeta;
627 success_ = getid(
id);
630 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 631 if(index_id_ < 0 || index_id_ >= (
int)thePixelTemp_.size()) {
632 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate2D::interpolate can't find needed template ID = " <<
id 633 <<
", Are you using the correct global tag?" << std::endl;
636 assert(index_id_ >= 0 && index_id_ < (
int)thePixelTemp_.size());
641 float cota = cotalpha;
646 if(cotbeta < 0.
f) {flip_y_ =
true;}
649 if(locBz > 0.
f) {flip_y_ =
true;}
655 if(locBx*locBz < 0.
f) {
656 cota = fabs(cotalpha);
659 if(locBx < 0.
f) {flip_y_ =
true;}
662 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 663 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate2D::illegal subdetector ID = " << thePixelTemp_[index_id_].head.Dtype << std::endl;
665 std::cout <<
"SiPixelTemplate:2D:illegal subdetector ID = " << thePixelTemp_[index_id_].head.Dtype << std::endl;
669 if(cota < cotalpha0_) {
674 }
else if(cota > cotalpha1_) {
680 jx0_ = (
int)((cota-cotalpha0_)/deltacota_+0.5f);
681 dcota = (cota - (cotalpha0_ + jx0_*deltacota_))/deltacota_;
682 adcota_ = fabs(dcota);
683 if(dcota > 0.
f) {jx1_ = jx0_ + 1;
if(jx1_ > Nxx_-1) jx1_ = jx0_-1;}
else {jx1_ = jx0_ - 1;
if(jx1_ < 0) jx1_ = jx0_+1;}
688 acotb = fabs(cotbeta);
690 if(acotb < cotbeta0_) {
695 }
else if(acotb > cotbeta1_) {
701 iy0_ = (
int)((acotb-cotbeta0_)/deltacotb_+0.5f);
702 dcotb = (acotb - (cotbeta0_ + iy0_*deltacotb_))/deltacotb_;
703 adcotb_ = fabs(dcotb);
704 if(dcotb > 0.
f) {iy1_ = iy0_ + 1;
if(iy1_ > Nyx_-1) iy1_ = iy0_-1;}
else {iy1_ = iy0_ - 1;
if(iy1_ < 0) iy1_ = iy0_+1;}
709 lorydrift_ = lorywidth_/2.;
710 if(flip_y_) lorydrift_ = -lorydrift_;
711 lorxdrift_ = lorxwidth_/2.;
712 if(flip_x_) lorxdrift_ = -lorxdrift_;
717 entry00_ = &thePixelTemp_[index_id_].entry[iy0_][jx0_];
718 entry10_ = &thePixelTemp_[index_id_].entry[iy1_][jx0_];
719 entry01_ = &thePixelTemp_[index_id_].entry[iy0_][jx1_];
723 qavg_ = entry00_->qavg
724 +adcota_*(entry01_->qavg - entry00_->qavg)
725 +adcotb_*(entry10_->qavg - entry00_->qavg);
727 pixmax_ = entry00_->pixmax
728 +adcota_*(entry01_->pixmax - entry00_->pixmax)
729 +adcotb_*(entry10_->pixmax - entry00_->pixmax);
731 sxymax_ = entry00_->sxymax
732 +adcota_*(entry01_->sxymax - entry00_->sxymax)
733 +adcotb_*(entry10_->sxymax - entry00_->sxymax);
735 chi2avgone_ = entry00_->chi2avgone
736 +adcota_*(entry01_->chi2avgone - entry00_->chi2avgone)
737 +adcotb_*(entry10_->chi2avgone - entry00_->chi2avgone);
739 chi2minone_ = entry00_->chi2minone
740 +adcota_*(entry01_->chi2minone - entry00_->chi2minone)
741 +adcotb_*(entry10_->chi2minone - entry00_->chi2minone);
743 clsleny_ = entry00_->clsleny
744 +adcota_*(entry01_->clsleny - entry00_->clsleny)
745 +adcotb_*(entry10_->clsleny - entry00_->clsleny);
747 clslenx_ = entry00_->clslenx
748 +adcota_*(entry01_->clslenx - entry00_->clslenx)
749 +adcotb_*(entry10_->clslenx - entry00_->clslenx);
752 chi2ppix_ = entry00_->chi2ppix
753 +adcota_*(entry01_->chi2ppix - entry00_->chi2ppix)
754 +adcotb_*(entry10_->chi2ppix - entry00_->chi2ppix);
756 chi2scale_ = entry00_->chi2scale
757 +adcota_*(entry01_->chi2scale - entry00_->chi2scale)
758 +adcotb_*(entry10_->chi2scale - entry00_->chi2scale);
760 scaleyavg_ = entry00_->scaleyavg
761 +adcota_*(entry01_->scaleyavg - entry00_->scaleyavg)
762 +adcotb_*(entry10_->scaleyavg - entry00_->scaleyavg);
764 scalexavg_ = entry00_->scalexavg
765 +adcota_*(entry01_->scalexavg - entry00_->scalexavg)
766 +adcotb_*(entry10_->scalexavg - entry00_->scalexavg);
768 delyavg_ = entry00_->delyavg
769 +adcota_*(entry01_->delyavg - entry00_->delyavg)
770 +adcotb_*(entry10_->delyavg - entry00_->delyavg);
772 delysig_ = entry00_->delysig
773 +adcota_*(entry01_->delysig - entry00_->delysig)
774 +adcotb_*(entry10_->delysig - entry00_->delysig);
776 mpvvav_ = entry00_->mpvvav
777 +adcota_*(entry01_->mpvvav - entry00_->mpvvav)
778 +adcotb_*(entry10_->mpvvav - entry00_->mpvvav);
780 sigmavav_ = entry00_->sigmavav
781 +adcota_*(entry01_->sigmavav - entry00_->sigmavav)
782 +adcotb_*(entry10_->sigmavav - entry00_->sigmavav);
784 kappavav_ = entry00_->kappavav
785 +adcota_*(entry01_->kappavav - entry00_->kappavav)
786 +adcotb_*(entry10_->kappavav - entry00_->kappavav);
788 for(
int i=0;
i<4 ; ++
i) {
789 scalex_[
i] = entry00_->scalex[
i]
790 +adcota_*(entry01_->scalex[
i] - entry00_->scalex[
i])
791 +adcotb_*(entry10_->scalex[
i] - entry00_->scalex[
i]);
793 scaley_[
i] = entry00_->scaley[
i]
794 +adcota_*(entry01_->scaley[
i] - entry00_->scaley[
i])
795 +adcotb_*(entry10_->scaley[
i] - entry00_->scaley[
i]);
797 offsetx_[
i] = entry00_->offsetx[
i]
798 +adcota_*(entry01_->offsetx[
i] - entry00_->offsetx[
i])
799 +adcotb_*(entry10_->offsetx[
i] - entry00_->offsetx[
i]);
800 if(flip_x_) offsetx_[
i] = -offsetx_[
i];
802 offsety_[
i] = entry00_->offsety[
i]
803 +adcota_*(entry01_->offsety[
i] - entry00_->offsety[
i])
804 +adcotb_*(entry10_->offsety[
i] - entry00_->offsety[
i]);
805 if(flip_y_) offsety_[
i] = -offsety_[
i];
808 for(
int i=0;
i<2 ; ++
i) {
809 for(
int j=0; j<5 ; ++j) {
812 xypary0x0_[1-
i][j] = (
float)entry00_->xypar[
i][j];
813 xypary1x0_[1-
i][j] = (
float)entry10_->xypar[
i][j];
814 xypary0x1_[1-
i][j] = (
float)entry01_->xypar[
i][j];
815 lanpar_[1-
i][j] = entry00_->lanpar[
i][j]
816 +adcota_*(entry01_->lanpar[
i][j] - entry00_->lanpar[
i][j])
817 +adcotb_*(entry10_->lanpar[
i][j] - entry00_->lanpar[
i][j]);
819 xypary0x0_[
i][j] = (
float)entry00_->xypar[
i][j];
820 xypary1x0_[
i][j] = (
float)entry10_->xypar[
i][j];
821 xypary0x1_[
i][j] = (
float)entry01_->xypar[
i][j];
822 lanpar_[
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]);
841 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)
856 for(
int i=0;
i<3; ++
i) {fbin_[
i] = fbin[
i];}
865 qavg_ = entry00_->qavg;
867 pixmax_ = entry00_->pixmax;
869 sxymax_ = entry00_->sxymax;
871 clsleny_ = entry00_->clsleny;
873 clslenx_ = entry00_->clslenx;
883 for(
int i=0;
i<4 ; ++
i) {
894 float cotbeta = entry00_->cotbeta;
897 if(cotbeta < 0.
f) {flip_y_ =
true;}
908 if(locBx*locBz < 0.
f) {
916 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 917 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate2D::illegal subdetector ID = " << iDtype << std::endl;
919 std::cout <<
"SiPixelTemplate:2D:illegal subdetector ID = " << iDtype << std::endl;
925 lorydrift_ = lorywidth_/2.;
926 if(flip_y_) lorydrift_ = -lorydrift_;
927 lorxdrift_ = lorxwidth_/2.;
928 if(flip_x_) lorxdrift_ = -lorxdrift_;
930 for(
int i=0;
i<2 ; ++
i) {
931 for(
int j=0; j<5 ; ++j) {
934 xypary0x0_[1-
i][j] = (
float)entry00_->xypar[
i][j];
935 xypary1x0_[1-
i][j] = (
float)entry00_->xypar[
i][j];
936 xypary0x1_[1-
i][j] = (
float)entry00_->xypar[
i][j];
937 lanpar_[1-
i][j] = entry00_->lanpar[
i][j];
939 xypary0x0_[
i][j] = (
float)entry00_->xypar[
i][j];
940 xypary1x0_[
i][j] = (
float)entry00_->xypar[
i][j];
941 xypary0x1_[
i][j] = (
float)entry00_->xypar[
i][j];
942 lanpar_[
i][j] = entry00_->lanpar[
i][j];
958 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)
963 int pixx, pixy,
k0, k1, l0, l1, deltax, deltay, iflipy, jflipx, imin, imax, jmin, jmax;
965 float dx,
dy, ddx, ddy, adx, ady;
967 const float deltaxy[2] = {16.67f, 25.0f};
977 pixy = (
int)floorf(yhit/ysize_);
978 dy = yhit-(pixy+0.5f)*ysize_;
979 if(flip_y_) {dy = -
dy;}
980 k0 = (
int)(dy/ysize_*6.
f+3.5
f);
983 ddy = 6.f*dy/ysize_ - (k0-3);
985 if(ddy > 0.
f) {k1 = k0 + 1;
if(k1 > 6) k1 = k0-1;}
else {k1 = k0 - 1;
if(k1 < 0) k1 = k0+1;}
986 pixx = (
int)floorf(xhit/xsize_);
987 dx = xhit-(pixx+0.5f)*xsize_;
988 if(flip_x_) {dx = -
dx;}
989 l0 = (
int)(dx/xsize_*6.
f+3.5
f);
992 ddx = 6.f*dx/xsize_ - (l0-3);
994 if(ddx > 0.
f) {l1 = l0 + 1;
if(l1 > 6) l1 = l0-1;}
else {l1 = l0 - 1;
if(l1 < 0) l1 = l0+1;}
1000 imin =
std::min(entry00_->iymin,entry10_->iymin);
1001 imin_ =
std::min(imin,entry01_->iymin);
1003 jmin =
std::min(entry00_->jxmin,entry10_->jxmin);
1004 jmin_ =
std::min(jmin,entry01_->jxmin);
1006 imax =
std::max(entry00_->iymax,entry10_->iymax);
1007 imax_ =
std::max(imax,entry01_->iymax);
1009 jmax =
std::max(entry00_->jxmax,entry10_->jxmax);
1010 jmax_ =
std::max(jmax,entry01_->jxmax);
1020 deltax = pixx -
T2HX;
1021 deltay = pixy -
T2HY;
1025 for(
int j=0; j<
BXM2; ++j) {
for(
int i=0;
i<
BYM2; ++
i) {xytemp_[j][
i] = 0.f;}}
1029 for(
int j=jmin_; j<=jmax_; ++j) {
1031 if(flip_x_) {jflipx=
T2XSIZE-1-j; m = deltax+jflipx;}
else {m = deltax+j;}
1032 for(
int i=imin_;
i<=imax_; ++
i) {
1033 if(flip_y_) {iflipy=
T2YSIZE-1-
i; n = deltay+iflipy;}
else {n = deltay+
i;}
1034 if(m>=0 && m<=BXM3 && n>=0 && n<=
BYM3) {
1035 xytemp_[
m][
n] = (
float)entry00_->xytemp[k0][l0][
i][j]
1036 + adx*(
float)(entry00_->xytemp[
k0][l1][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1037 + ady*(
float)(entry00_->xytemp[k1][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1038 + adcota_*(
float)(entry01_->xytemp[
k0][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1039 + adcotb_*(
float)(entry10_->xytemp[
k0][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j]);
1046 for(
int n=1; n<
BYM3; ++
n) {
1049 for(
int m=1; m<
BXM3; ++
m) {
1050 xytemp_[
m][
n] += xytemp_[
m][n+1];
1054 for(
int m=1; m<
BXM3; ++
m) {
1055 xytemp_[
m][
i] = xytemp_[
m][
i+1];
1063 for(
int m=1; m<
BXM3; ++
m) {
1066 for(
int n=1; n<
BYM3; ++
n) {
1067 xytemp_[
m][
n] += xytemp_[m+1][
n];
1070 for(
int j=m+1; j<
BXM3; ++j) {
1071 for(n=1; n<
BYM3; ++
n) {
1072 xytemp_[j][
n] = xytemp_[j+1][
n];
1080 float qtemptot = 0.f;
1082 for(
int n=1; n<
BYM3; ++
n) {
1083 for(
int m=1; m<
BXM3; ++
m) {
1084 if(xytemp_[m][n] != 0.
f) {template2d[
m][
n] += xytemp_[
m][
n]; qtemptot += xytemp_[
m][
n];}
1088 QTemplate = qtemptot;
1094 for(
int k = 0;
k<2; ++
k) {
1096 for(
int j = 0; j<
BYM2; ++j) {
1097 dxytempdx[
k][
i][j] = 0.f;
1098 dxytempdy[
k][
i][j] = 0.f;
1099 dpdx2d[
k][
i][j] = 0.f;
1106 pixx = (
int)floorf((xhit+deltaxy[0])/xsize_);
1107 dx = (xhit+deltaxy[0])-(pixx+0.5
f)*xsize_;
1108 if(flip_x_) {dx = -
dx;}
1109 l0 = (
int)(dx/xsize_*6.
f+3.5
f);
1112 ddx = 6.f*dx/xsize_ - (l0-3);
1114 if(ddx > 0.
f) {l1 = l0 + 1;
if(l1 > 6) l1 = l0-1;}
else {l1 = l0 - 1;
if(l1 < 0) l1 = l0+1;}
1126 deltax = pixx -
T2HX;
1130 for(
int j=jmin_; j<=jmax_; ++j) {
1132 if(flip_x_) {jflipx=
T2XSIZE-1-j; m = deltax+jflipx;}
else {m = deltax+j;}
1133 for(
int i=imin_;
i<=imax_; ++
i) {
1134 if(flip_y_) {iflipy=
T2YSIZE-1-
i; n = deltay+iflipy;}
else {n = deltay+
i;}
1135 if(m>=0 && m<=BXM3 && n>=0 && n<=BYM3) {
1136 dxytempdx[1][
m][
n] = (
float)entry00_->xytemp[k0][l0][
i][j]
1137 + adx*(
float)(entry00_->xytemp[
k0][l1][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1138 + ady*(
float)(entry00_->xytemp[k1][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1139 + adcota_*(
float)(entry01_->xytemp[
k0][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1140 + adcotb_*(
float)(entry10_->xytemp[
k0][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j]);
1147 for(
int n=1; n<
BYM3; ++
n) {
1150 for(
int m=1; m<
BXM3; ++
m) {
1151 dxytempdx[1][
m][
n] += dxytempdx[1][
m][n+1];
1155 for(
int m=1; m<
BXM3; ++
m) {
1156 dxytempdx[1][
m][
i] = dxytempdx[1][
m][
i+1];
1164 for(
int m=1; m<
BXM3; ++
m) {
1167 for(
int n=1; n<
BYM3; ++
n) {
1168 dxytempdx[1][
m][
n] += dxytempdx[1][m+1][
n];
1171 for(
int j=m+1; j<
BXM3; ++j) {
1172 for(
int n=1; n<
BYM3; ++
n) {
1173 dxytempdx[1][j][
n] = dxytempdx[1][j+1][
n];
1181 pixx = (
int)floorf((xhit-deltaxy[0])/xsize_);
1182 dx = (xhit-deltaxy[0])-(pixx+0.5
f)*xsize_;
1183 if(flip_x_) {dx = -
dx;}
1184 l0 = (
int)(dx/xsize_*6.
f+3.5
f);
1187 ddx = 6.f*dx/xsize_ - (l0-3);
1189 if(ddx > 0.
f) {l1 = l0 + 1;
if(l1 > 6) l1 = l0-1;}
else {l1 = l0 - 1;
if(l1 < 0) l1 = l0+1;}
1201 deltax = pixx -
T2HX;
1205 for(
int j=jmin_; j<=jmax_; ++j) {
1207 if(flip_x_) {jflipx=
T2XSIZE-1-j; m = deltax+jflipx;}
else {m = deltax+j;}
1208 for(
int i=imin_;
i<=imax_; ++
i) {
1209 if(flip_y_) {iflipy=
T2YSIZE-1-
i; n = deltay+iflipy;}
else {n = deltay+
i;}
1210 if(m>=0 && m<=BXM3 && n>=0 && n<=BYM3) {
1211 dxytempdx[0][
m][
n] = (
float)entry00_->xytemp[k0][l0][
i][j]
1212 + adx*(
float)(entry00_->xytemp[
k0][l1][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1213 + ady*(
float)(entry00_->xytemp[k1][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1214 + adcota_*(
float)(entry01_->xytemp[
k0][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1215 + adcotb_*(
float)(entry10_->xytemp[
k0][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j]);
1222 for(
int n=1; n<
BYM3; ++
n) {
1225 for(
int m=1; m<
BXM3; ++
m) {
1226 dxytempdx[0][
m][
n] += dxytempdx[0][
m][n+1];
1230 for(
int m=1; m<
BXM3; ++
m) {
1231 dxytempdx[0][
m][
i] = dxytempdx[0][
m][
i+1];
1239 for(
int m=1; m<
BXM3; ++
m) {
1242 for(
int n=1; n<
BYM3; ++
n) {
1243 dxytempdx[0][
m][
n] += dxytempdx[0][m+1][
n];
1246 for(
int j=m+1; j<
BXM3; ++j) {
1247 for(
int n=1; n<
BYM3; ++
n) {
1248 dxytempdx[0][j][
n] = dxytempdx[0][j+1][
n];
1257 for(
int n=1; n<
BYM3; ++
n) {
1258 for(
int m=1; m<
BXM3; ++
m) {
1259 dpdx2d[0][
m][
n] = (dxytempdx[1][
m][
n] - dxytempdx[0][
m][
n])/(2.*deltaxy[0]);
1265 pixy = (
int)floorf((yhit+deltaxy[1])/ysize_);
1266 dy = (yhit+deltaxy[1])-(pixy+0.5
f)*ysize_;
1267 if(flip_y_) {dy = -
dy;}
1268 k0 = (
int)(dy/ysize_*6.
f+3.5
f);
1271 ddy = 6.f*dy/ysize_ - (k0-3);
1273 if(ddy > 0.
f) {k1 = k0 + 1;
if(k1 > 6) k1 = k0-1;}
else {k1 = k0 - 1;
if(k1 < 0) k1 = k0+1;}
1274 pixx = (
int)floorf(xhit/xsize_);
1275 dx = xhit-(pixx+0.5f)*xsize_;
1276 if(flip_x_) {dx = -
dx;}
1277 l0 = (
int)(dx/xsize_*6.
f+3.5
f);
1280 ddx = 6.f*dx/xsize_ - (l0-3);
1282 if(ddx > 0.
f) {l1 = l0 + 1;
if(l1 > 6) l1 = l0-1;}
else {l1 = l0 - 1;
if(l1 < 0) l1 = l0+1;}
1294 deltax = pixx -
T2HX;
1295 deltay = pixy -
T2HY;
1299 for(
int j=jmin_; j<=jmax_; ++j) {
1301 if(flip_x_) {jflipx=
T2XSIZE-1-j; m = deltax+jflipx;}
else {m = deltax+j;}
1302 for(
int i=imin_;
i<=imax_; ++
i) {
1303 if(flip_y_) {iflipy=
T2YSIZE-1-
i; n = deltay+iflipy;}
else {n = deltay+
i;}
1304 if(m>=0 && m<=BXM3 && n>=0 && n<=BYM3) {
1305 dxytempdy[1][
m][
n] = (
float)entry00_->xytemp[k0][l0][
i][j]
1306 + adx*(
float)(entry00_->xytemp[
k0][l1][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1307 + ady*(
float)(entry00_->xytemp[k1][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1308 + adcota_*(
float)(entry01_->xytemp[
k0][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1309 + adcotb_*(
float)(entry10_->xytemp[
k0][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j]);
1316 for(
int n=1; n<
BYM3; ++
n) {
1319 for(
int m=1; m<
BXM3; ++
m) {
1320 dxytempdy[1][
m][
n] += dxytempdy[1][
m][n+1];
1324 for(
int m=1; m<
BXM3; ++
m) {
1325 dxytempdy[1][
m][
i] = dxytempdy[1][
m][
i+1];
1333 for(
int m=1; m<
BXM3; ++
m) {
1336 for(
int n=1; n<
BYM3; ++
n) {
1337 dxytempdy[1][
m][
n] += dxytempdy[1][m+1][
n];
1340 for(
int j=m+1; j<
BXM3; ++j) {
1341 for(
int n=1; n<
BYM3; ++
n) {
1342 dxytempdy[1][j][
n] = dxytempdy[1][j+1][
n];
1350 pixy = (
int)floorf((yhit-deltaxy[1])/ysize_);
1351 dy = (yhit-deltaxy[1])-(pixy+0.5
f)*ysize_;
1352 if(flip_y_) {dy = -
dy;}
1353 k0 = (
int)(dy/ysize_*6.
f+3.5
f);
1356 ddy = 6.f*dy/ysize_ - (k0-3);
1358 if(ddy > 0.
f) {k1 = k0 + 1;
if(k1 > 6) k1 = k0-1;}
else {k1 = k0 - 1;
if(k1 < 0) k1 = k0+1;}
1370 deltay = pixy -
T2HY;
1374 for(
int j=jmin_; j<=jmax_; ++j) {
1376 if(flip_x_) {jflipx=
T2XSIZE-1-j; m = deltax+jflipx;}
else {m = deltax+j;}
1377 for(
int i=imin_;
i<=imax_; ++
i) {
1378 if(flip_y_) {iflipy=
T2YSIZE-1-
i; n = deltay+iflipy;}
else {n = deltay+
i;}
1379 if(m>=0 && m<=BXM3 && n>=0 && n<=BYM3) {
1380 dxytempdy[0][
m][
n] = (
float)entry00_->xytemp[k0][l0][
i][j]
1381 + adx*(
float)(entry00_->xytemp[
k0][l1][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1382 + ady*(
float)(entry00_->xytemp[k1][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1383 + adcota_*(
float)(entry01_->xytemp[
k0][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j])
1384 + adcotb_*(
float)(entry10_->xytemp[
k0][l0][
i][j] - entry00_->xytemp[
k0][l0][
i][j]);
1391 for(
int n=1; n<
BYM3; ++
n) {
1394 for(
int m=1; m<
BXM3; ++
m) {
1395 dxytempdy[0][
m][
n] += dxytempdy[0][
m][n+1];
1399 for(
int m=1; m<
BXM3; ++
m) {
1400 dxytempdy[0][
m][
i] = dxytempdy[0][
m][
i+1];
1408 for(
int m=1; m<
BXM3; ++
m) {
1411 for(
int n=1; n<
BYM3; ++
n) {
1412 dxytempdy[0][
m][
n] += dxytempdy[0][m+1][
n];
1415 for(
int j=m+1; j<
BXM3; ++j) {
1416 for(
int n=1; n<
BYM3; ++
n) {
1417 dxytempdy[0][j][
n] = dxytempdy[0][j+1][
n];
1425 for(
int n=1; n<
BYM3; ++
n) {
1426 for(
int m=1; m<
BXM3; ++
m) {
1427 dpdx2d[1][
m][
n] = (dxytempdy[1][
m][
n] - dxytempdy[0][
m][
n])/(2.*deltaxy[1]);
1450 bool derivatives =
false;
1477 bool derivatives =
false;
1481 if(cotbeta < 0.
f) {locBx = -1.f;}
1482 float locBz = locBx;
1483 if(cotalpha < 0.
f) {locBz = -locBx;}
1487 yd[0] =
false; yd[BYM2-1] =
false;
1488 for(
int i=0;
i<
TYSIZE; ++
i) { yd[
i+1] = ydouble[
i];}
1489 xd[0] =
false; xd[
BXM2-1] =
false;
1490 for(
int j=0; j<
TXSIZE; ++j) { xd[j+1] = xdouble[j];}
1517 float sigi, sigi2, sigi3, sigi4, qscale, err2, err00;
1521 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 1522 if(index < 1 || index >=
BYM2) {
1523 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate2D::ysigma2 called with index = " << index << std::endl;
1526 assert(index > 0 && index <
BYM2);
1533 if(qpixel < sxymax_) {
1538 qscale = qpixel/sxymax_;
1540 sigi2 = sigi*sigi; sigi3 = sigi2*sigi; sigi4 = sigi3*sigi;
1542 err00 = xypary0x0_[0][0]+xypary0x0_[0][1]*sigi+xypary0x0_[0][2]*sigi2+xypary0x0_[0][3]*sigi3+xypary0x0_[0][4]*sigi4;
1544 +adcota_*(xypary0x1_[0][0]+xypary0x1_[0][1]*sigi+xypary0x1_[0][2]*sigi2+xypary0x1_[0][3]*sigi3+xypary0x1_[0][4]*sigi4 - err00)
1545 +adcotb_*(xypary1x0_[0][0]+xypary1x0_[0][1]*sigi+xypary1x0_[0][2]*sigi2+xypary1x0_[0][3]*sigi3+xypary1x0_[0][4]*sigi4 - err00);
1547 err00 = xypary0x0_[1][0]+xypary0x0_[1][1]*sigi+xypary0x0_[1][2]*sigi2+xypary0x0_[1][3]*sigi3+xypary0x0_[1][4]*sigi4;
1549 +adcota_*(xypary0x1_[1][0]+xypary0x1_[1][1]*sigi+xypary0x1_[1][2]*sigi2+xypary0x1_[1][3]*sigi3+xypary0x1_[1][4]*sigi4 - err00)
1550 +adcotb_*(xypary1x0_[1][0]+xypary1x0_[1][1]*sigi+xypary1x0_[1][2]*sigi2+xypary1x0_[1][3]*sigi3+xypary1x0_[1][4]*sigi4 - err00);
1552 xysig2 =qscale*err2;
1553 if(xysig2 <= 0.
f) {xysig2 = s50_*s50_;}
1568 for(
int i=0;
i<2; ++
i) {
1569 for(
int j=0; j<5; ++j) {
1570 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