79 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
84 #define LOGERROR(x) LogError(x)
85 #define LOGINFO(x) LogInfo(x)
92 #define LOGERROR(x) std::cout << x << ": "
93 #define LOGINFO(x) std::cout << x << ": "
94 #define ENDL std::endl
110 const char *tempfile;
113 const int code_version={16};
119 std::ostringstream tout;
123 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
124 tout <<
"CalibTracker/SiPixelESProducers/data/template_summary_zp"
125 << std::setw(4) << std::setfill(
'0') << std::right << filenum <<
".out" << std::ends;
126 std::string tempf = tout.str();
128 tempfile = (
file.fullPath()).c_str();
130 tout <<
"template_summary_zp" << std::setw(4) << std::setfill(
'0') << std::right << filenum <<
".out" << std::ends;
131 std::string tempf = tout.str();
132 tempfile = tempf.c_str();
139 if(in_file.is_open()) {
147 for (i=0; (c=in_file.get()) !=
'\n'; ++
i) {
152 LOGINFO(
"SiPixelTemplate") <<
"Loading Pixel Template File - " << theCurrentTemp.
head.
title <<
ENDL;
160 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file, no template load" <<
ENDL;
return false;}
163 <<
", NTy = " << theCurrentTemp.
head.
NTy <<
", NTyx = " << theCurrentTemp.
head.
NTyx<<
", NTxx = " << theCurrentTemp.
head.
NTxx <<
", Dtype = " << theCurrentTemp.
head.
Dtype
164 <<
", Bias voltage " << theCurrentTemp.
head.
Vbias <<
", temperature "
166 <<
", 1/2 threshold " << theCurrentTemp.
head.
s50 <<
", y Lorentz Width " << theCurrentTemp.
head.
lorywidth <<
", x Lorentz width " << theCurrentTemp.
head.
lorxwidth
169 if(theCurrentTemp.
head.
templ_version < code_version) {
LOGERROR(
"SiPixelTemplate") <<
"code expects version " << code_version <<
", no template load" <<
ENDL;
return false;}
173 for (i=0; i < theCurrentTemp.
head.
NTy; ++
i) {
178 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 1, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
193 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 2, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
198 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 3, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
200 for (j=0; j<2; ++
j) {
205 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 4, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
209 for (j=0; j<9; ++
j) {
213 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 5, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
216 for (j=0; j<2; ++
j) {
221 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 6, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
226 for (j=0; j<9; ++
j) {
230 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 7, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
234 for (j=0; j<4; ++
j) {
238 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 8, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
241 for (j=0; j<4; ++
j) {
246 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 9, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
249 for (j=0; j<4; ++
j) {
253 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 10, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
256 for (j=0; j<4; ++
j) {
261 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 11, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
264 for (j=0; j<4; ++
j) {
268 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 12, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
271 for (j=0; j<4; ++
j) {
275 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 13, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
278 for (j=0; j<4; ++
j) {
282 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 14, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
285 for (j=0; j<4; ++
j) {
289 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 14a, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
292 for (j=0; j<4; ++
j) {
296 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 14b, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
302 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 15, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
308 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 16, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
314 for (k=0; k < theCurrentTemp.
head.
NTyx; ++
k) {
316 for (i=0; i < theCurrentTemp.
head.
NTxx; ++
i) {
321 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 17, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
329 theCurrentTemp.
entx[
k][
i].
beta =
static_cast<float>(atan2((
double)theCurrentTemp.
entx[k][i].
costrk[2], (
double)theCurrentTemp.
entx[k][i].
costrk[1]));
336 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 18, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
342 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 19, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
344 for (j=0; j<2; ++
j) {
349 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 20, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
352 for (j=0; j<9; ++
j) {
356 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 21, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
359 for (j=0; j<2; ++
j) {
365 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 22, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
369 for (j=0; j<9; ++
j) {
373 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 23, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
377 for (j=0; j<4; ++
j) {
381 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 24, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
384 for (j=0; j<4; ++
j) {
389 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 25, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
392 for (j=0; j<4; ++
j) {
396 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 26, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
399 for (j=0; j<4; ++
j) {
404 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 27, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
407 for (j=0; j<4; ++
j) {
411 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 28, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
414 for (j=0; j<4; ++
j) {
418 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 29, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
421 for (j=0; j<4; ++
j) {
425 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 30, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
428 for (j=0; j<4; ++
j) {
432 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 30a, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
435 for (j=0; j<4; ++
j) {
439 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 30b, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
445 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 31, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
451 if(in_file.fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 32, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
461 thePixelTemp.push_back(theCurrentTemp);
469 LOGERROR(
"SiPixelTemplate") <<
"Error opening File" << tempfile <<
ENDL;
477 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
492 const int code_version={16};
507 for (i=0; i<20; ++
i) {
516 LOGINFO(
"SiPixelTemplate") <<
"Loading Pixel Template File - " << theCurrentTemp.
head.
title <<
ENDL;
524 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file, no template load" <<
ENDL;
return false;}
527 <<
", NTy = " << theCurrentTemp.
head.
NTy <<
", NTyx = " << theCurrentTemp.
head.
NTyx<<
", NTxx = " << theCurrentTemp.
head.
NTxx <<
", Dtype = " << theCurrentTemp.
head.
Dtype
528 <<
", Bias voltage " << theCurrentTemp.
head.
Vbias <<
", temperature "
530 <<
", 1/2 threshold " << theCurrentTemp.
head.
s50 <<
", y Lorentz Width " << theCurrentTemp.
head.
lorywidth <<
", x Lorentz width " << theCurrentTemp.
head.
lorxwidth
533 if(theCurrentTemp.
head.
templ_version < code_version) {
LOGERROR(
"SiPixelTemplate") <<
"code expects version " << code_version <<
", no template load" <<
ENDL;
return false;}
537 for (i=0; i < theCurrentTemp.
head.
NTy; ++
i) {
542 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 1, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
557 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 2, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
563 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 3, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
565 for (j=0; j<2; ++
j) {
570 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 4, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
574 for (j=0; j<9; ++
j) {
578 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 5, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
581 for (j=0; j<2; ++
j) {
586 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 6, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
591 for (j=0; j<9; ++
j) {
595 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 7, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
599 for (j=0; j<4; ++
j) {
603 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 8, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
606 for (j=0; j<4; ++
j) {
611 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 9, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
614 for (j=0; j<4; ++
j) {
618 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 10, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
621 for (j=0; j<4; ++
j) {
626 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 11, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
629 for (j=0; j<4; ++
j) {
633 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 12, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
636 for (j=0; j<4; ++
j) {
640 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 13, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
643 for (j=0; j<4; ++
j) {
647 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 14, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
650 for (j=0; j<4; ++
j) {
654 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 14a, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
657 for (j=0; j<4; ++
j) {
661 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 14b, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
668 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 15, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
674 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 16, no template load, run # " << theCurrentTemp.
enty[
i].
runnum <<
ENDL;
return false;}
680 for (k=0; k < theCurrentTemp.
head.
NTyx; ++
k) {
682 for (i=0; i < theCurrentTemp.
head.
NTxx; ++
i) {
687 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 17, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
695 theCurrentTemp.
entx[
k][
i].
beta =
static_cast<float>(atan2((
double)theCurrentTemp.
entx[k][i].
costrk[2], (
double)theCurrentTemp.
entx[k][i].
costrk[1]));
702 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 18, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
708 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 19, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
710 for (j=0; j<2; ++
j) {
715 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 20, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
718 for (j=0; j<9; ++
j) {
722 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 21, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
725 for (j=0; j<2; ++
j) {
731 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 22, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
735 for (j=0; j<9; ++
j) {
739 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 23, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
743 for (j=0; j<4; ++
j) {
747 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 24, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
750 for (j=0; j<4; ++
j) {
755 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 25, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
758 for (j=0; j<4; ++
j) {
762 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 26, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
765 for (j=0; j<4; ++
j) {
770 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 27, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
773 for (j=0; j<4; ++
j) {
777 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 28, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
780 for (j=0; j<4; ++
j) {
784 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 29, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
787 for (j=0; j<4; ++
j) {
791 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 30, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
794 for (j=0; j<4; ++
j) {
798 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 30a, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
801 for (j=0; j<4; ++
j) {
805 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 30b, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
812 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 31, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
818 if(db.
fail()) {
LOGERROR(
"SiPixelTemplate") <<
"Error reading file 32, no template load, run # " << theCurrentTemp.
entx[
k][
i].
runnum <<
ENDL;
return false;}
826 thePixelTemp.push_back(theCurrentTemp);
849 int ilow, ihigh, iylow, iyhigh, Ny, Nxx, Nyx, imidy, imaxx;
850 float yratio, yxratio, xxratio, sxmax, qcorrect, qxtempcor, symax, chi2xavgone, chi2xminone, cotb, cotalpha0, cotbeta0;
853 float chi2xavg[4], chi2xmin[4];
858 if(
id != id_current || cotalpha != cota_current || cotbeta != cotb_current) {
860 cota_current = cotalpha; cotb_current = cotbeta;
success =
true;
862 if(
id != id_current) {
867 for(i=0; i<(int)thePixelTemp.size(); ++
i) {
869 if(
id == thePixelTemp[i].head.ID) {
876 pqscale = thePixelTemp[index_id].head.qscale;
880 ps50 = thePixelTemp[index_id].head.s50;
884 pxsize = thePixelTemp[index_id].head.xsize;
885 pysize = thePixelTemp[index_id].head.ysize;
886 pzsize = thePixelTemp[index_id].head.zsize;
893 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
894 if(index_id < 0 || index_id >= (
int)thePixelTemp.size()) {
895 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate::interpolate can't find needed template ID = " <<
id << std::endl;
898 assert(index_id >= 0 && index_id < (
int)thePixelTemp.size());
907 cotalpha0 = thePixelTemp[index_id].enty[0].cotalpha;
908 qcorrect=
std::sqrt((1.
f+cotbeta*cotbeta+cotalpha*cotalpha)/(1.
f+cotbeta*cotbeta+cotalpha0*cotalpha0));
911 if(thePixelTemp[index_id].head.Dtype == 0) {
914 if(cotbeta < 0.) {flip_y =
true;}
925 Ny = thePixelTemp[index_id].head.NTy;
926 Nyx = thePixelTemp[index_id].head.NTyx;
927 Nxx = thePixelTemp[index_id].head.NTxx;
929 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
930 if(Ny < 2 || Nyx < 1 || Nxx < 2) {
931 throw cms::Exception(
"DataCorrupt") <<
"template ID = " << id_current <<
"has too few entries: Ny/Nyx/Nxx = " << Ny <<
"/" << Nyx <<
"/" << Nxx << std::endl;
934 assert(Ny > 1 && Nyx > 0 && Nxx > 1);
944 if(cotb >= thePixelTemp[index_id].enty[Ny-1].cotbeta) {
952 if(cotb >= thePixelTemp[index_id].enty[0].cotbeta) {
954 for (i=0; i<Ny-1; ++
i) {
956 if( thePixelTemp[index_id].enty[i].cotbeta <= cotb && cotb < thePixelTemp[index_id].enty[i+1].cotbeta) {
959 yratio = (cotb - thePixelTemp[index_id].enty[
i].cotbeta)/(thePixelTemp[index_id].enty[i+1].cotbeta - thePixelTemp[index_id].enty[i].cotbeta);
971 pqavg = (1.f - yratio)*thePixelTemp[index_id].enty[ilow].qavg + yratio*thePixelTemp[index_id].enty[ihigh].qavg;
973 symax = (1.f - yratio)*thePixelTemp[index_id].enty[ilow].symax + yratio*thePixelTemp[index_id].enty[ihigh].symax;
975 sxmax = (1.f - yratio)*thePixelTemp[index_id].enty[ilow].sxmax + yratio*thePixelTemp[index_id].enty[ihigh].sxmax;
976 pdyone = (1.f - yratio)*thePixelTemp[index_id].enty[ilow].dyone + yratio*thePixelTemp[index_id].enty[ihigh].dyone;
977 if(flip_y) {pdyone = -pdyone;}
978 psyone = (1.f - yratio)*thePixelTemp[index_id].enty[ilow].syone + yratio*thePixelTemp[index_id].enty[ihigh].syone;
979 pdytwo = (1.f - yratio)*thePixelTemp[index_id].enty[ilow].dytwo + yratio*thePixelTemp[index_id].enty[ihigh].dytwo;
980 if(flip_y) {pdytwo = -pdytwo;}
981 psytwo = (1.f - yratio)*thePixelTemp[index_id].enty[ilow].sytwo + yratio*thePixelTemp[index_id].enty[ihigh].sytwo;
982 pqmin = (1.f - yratio)*thePixelTemp[index_id].enty[ilow].qmin + yratio*thePixelTemp[index_id].enty[ihigh].qmin;
984 pqmin2 = (1.f - yratio)*thePixelTemp[index_id].enty[ilow].qmin2 + yratio*thePixelTemp[index_id].enty[ihigh].qmin2;
986 pmpvvav = (1.f - yratio)*thePixelTemp[index_id].enty[ilow].mpvvav + yratio*thePixelTemp[index_id].enty[ihigh].mpvvav;
988 psigmavav = (1.f - yratio)*thePixelTemp[index_id].enty[ilow].sigmavav + yratio*thePixelTemp[index_id].enty[ihigh].sigmavav;
989 pkappavav = (1.f - yratio)*thePixelTemp[index_id].enty[ilow].kappavav + yratio*thePixelTemp[index_id].enty[ihigh].kappavav;
990 pclsleny = fminf(thePixelTemp[index_id].enty[ilow].clsleny, thePixelTemp[index_id].enty[ihigh].clsleny);
991 pqavg_avg = (1.f - yratio)*thePixelTemp[index_id].enty[ilow].qavg_avg + yratio*thePixelTemp[index_id].enty[ihigh].qavg_avg;
992 pqavg_avg *= qcorrect;
993 for(i=0; i<2 ; ++
i) {
994 for(j=0; j<5 ; ++
j) {
997 pyparl[1-
i][
j] = thePixelTemp[index_id].enty[ilow].ypar[
i][
j];
998 pyparh[1-
i][
j] = thePixelTemp[index_id].enty[ihigh].ypar[
i][
j];
1000 pyparl[
i][
j] = thePixelTemp[index_id].enty[ilow].ypar[
i][
j];
1001 pyparh[
i][
j] = thePixelTemp[index_id].enty[ihigh].ypar[
i][
j];
1003 pxparly0[
i][
j] = thePixelTemp[index_id].enty[ilow].xpar[
i][
j];
1004 pxparhy0[
i][
j] = thePixelTemp[index_id].enty[ihigh].xpar[
i][
j];
1007 for(i=0; i<4; ++
i) {
1008 pyavg[
i]=(1.f - yratio)*thePixelTemp[index_id].enty[ilow].yavg[i] + yratio*thePixelTemp[index_id].enty[ihigh].yavg[i];
1009 if(flip_y) {pyavg[
i] = -pyavg[
i];}
1010 pyrms[
i]=(1.f - yratio)*thePixelTemp[index_id].enty[ilow].yrms[i] + yratio*thePixelTemp[index_id].enty[ihigh].yrms[i];
1016 pchi2yavg[
i]=(1.f - yratio)*thePixelTemp[index_id].enty[ilow].chi2yavg[i] + yratio*thePixelTemp[index_id].enty[ihigh].chi2yavg[i];
1017 pchi2ymin[
i]=(1.f - yratio)*thePixelTemp[index_id].enty[ilow].chi2ymin[i] + yratio*thePixelTemp[index_id].enty[ihigh].chi2ymin[i];
1018 chi2xavg[
i]=(1.f - yratio)*thePixelTemp[index_id].enty[ilow].chi2xavg[i] + yratio*thePixelTemp[index_id].enty[ihigh].chi2xavg[i];
1019 chi2xmin[
i]=(1.f - yratio)*thePixelTemp[index_id].enty[ilow].chi2xmin[i] + yratio*thePixelTemp[index_id].enty[ihigh].chi2xmin[i];
1020 pyavgc2m[
i]=(1.f - yratio)*thePixelTemp[index_id].enty[ilow].yavgc2m[i] + yratio*thePixelTemp[index_id].enty[ihigh].yavgc2m[i];
1021 if(flip_y) {pyavgc2m[
i] = -pyavgc2m[
i];}
1022 pyrmsc2m[
i]=(1.f - yratio)*thePixelTemp[index_id].enty[ilow].yrmsc2m[i] + yratio*thePixelTemp[index_id].enty[ihigh].yrmsc2m[i];
1028 for(j=0; j<6 ; ++
j) {
1029 pyflparl[
i][
j] = thePixelTemp[index_id].enty[ilow].yflpar[
i][
j];
1030 pyflparh[
i][
j] = thePixelTemp[index_id].enty[ihigh].yflpar[
i][
j];
1034 if(flip_y && (j == 0 || j == 2 || j == 4)) {
1035 pyflparl[
i][
j] = - pyflparl[
i][
j];
1036 pyflparh[
i][
j] = - pyflparh[
i][
j];
1043 pchi2yavgone=(1.f - yratio)*thePixelTemp[index_id].enty[ilow].chi2yavgone + yratio*thePixelTemp[index_id].enty[ihigh].chi2yavgone;
1044 pchi2yminone=(1.f - yratio)*thePixelTemp[index_id].enty[ilow].chi2yminone + yratio*thePixelTemp[index_id].enty[ihigh].chi2yminone;
1045 chi2xavgone=(1.f - yratio)*thePixelTemp[index_id].enty[ilow].chi2xavgone + yratio*thePixelTemp[index_id].enty[ihigh].chi2xavgone;
1046 chi2xminone=(1.f - yratio)*thePixelTemp[index_id].enty[ilow].chi2xminone + yratio*thePixelTemp[index_id].enty[ihigh].chi2xminone;
1053 for(i=0; i<9; ++
i) {
1056 pytemp[
i][
BYM2] = 0.f;
1057 pytemp[
i][
BYM1] = 0.f;
1063 pytemp[8-
i][
BYM3-
j]=(1.f - yratio)*thePixelTemp[index_id].enty[ilow].ytemp[i][j] + yratio*thePixelTemp[index_id].enty[ihigh].ytemp[i][j];
1065 pytemp[
i][j+2]=(1.f - yratio)*thePixelTemp[index_id].enty[ilow].ytemp[i][j] + yratio*thePixelTemp[index_id].enty[ihigh].ytemp[i][j];
1075 if(abs_cotb >= thePixelTemp[index_id].entx[Nyx-1][0].cotbeta) {
1080 }
else if(abs_cotb >= thePixelTemp[index_id].entx[0][0].cotbeta) {
1082 for (i=0; i<Nyx-1; ++
i) {
1084 if( thePixelTemp[index_id].entx[i][0].cotbeta <= abs_cotb && abs_cotb < thePixelTemp[index_id].entx[i+1][0].cotbeta) {
1087 yxratio = (abs_cotb - thePixelTemp[index_id].entx[
i][0].cotbeta)/(thePixelTemp[index_id].entx[i+1][0].cotbeta - thePixelTemp[index_id].entx[i][0].cotbeta);
1098 if(cotalpha >= thePixelTemp[index_id].entx[0][Nxx-1].cotalpha) {
1106 if(cotalpha >= thePixelTemp[index_id].entx[0][0].cotalpha) {
1108 for (i=0; i<Nxx-1; ++
i) {
1110 if( thePixelTemp[index_id].entx[0][i].cotalpha <= cotalpha && cotalpha < thePixelTemp[index_id].entx[0][i+1].cotalpha) {
1113 xxratio = (cotalpha - thePixelTemp[index_id].entx[0][
i].cotalpha)/(thePixelTemp[index_id].entx[0][i+1].cotalpha - thePixelTemp[index_id].entx[0][i].cotalpha);
1129 psxparmax = (1.f - xxratio)*thePixelTemp[index_id].entx[imaxx][ilow].sxmax + xxratio*thePixelTemp[index_id].entx[imaxx][ihigh].sxmax;
1131 if(thePixelTemp[index_id].entx[imaxx][imidy].sxmax != 0.
f) {psxmax=psxmax/thePixelTemp[index_id].entx[imaxx][imidy].sxmax*sxmax;}
1132 psymax = (1.f - xxratio)*thePixelTemp[index_id].entx[imaxx][ilow].symax + xxratio*thePixelTemp[index_id].entx[imaxx][ihigh].symax;
1133 if(thePixelTemp[index_id].entx[imaxx][imidy].symax != 0.) {psymax=psymax/thePixelTemp[index_id].entx[imaxx][imidy].symax*symax;}
1134 pdxone = (1.f - xxratio)*thePixelTemp[index_id].entx[0][ilow].dxone + xxratio*thePixelTemp[index_id].entx[0][ihigh].dxone;
1135 psxone = (1.f - xxratio)*thePixelTemp[index_id].entx[0][ilow].sxone + xxratio*thePixelTemp[index_id].entx[0][ihigh].sxone;
1136 pdxtwo = (1.f - xxratio)*thePixelTemp[index_id].entx[0][ilow].dxtwo + xxratio*thePixelTemp[index_id].entx[0][ihigh].dxtwo;
1137 psxtwo = (1.f - xxratio)*thePixelTemp[index_id].entx[0][ilow].sxtwo + xxratio*thePixelTemp[index_id].entx[0][ihigh].sxtwo;
1138 pclslenx = fminf(thePixelTemp[index_id].entx[0][ilow].clslenx, thePixelTemp[index_id].entx[0][ihigh].clslenx);
1139 for(i=0; i<2 ; ++
i) {
1140 for(j=0; j<5 ; ++
j) {
1141 pxpar0[
i][
j] = thePixelTemp[index_id].entx[imaxx][imidy].xpar[
i][
j];
1142 pxparl[
i][
j] = thePixelTemp[index_id].entx[imaxx][ilow].xpar[
i][
j];
1143 pxparh[
i][
j] = thePixelTemp[index_id].entx[imaxx][ihigh].xpar[
i][
j];
1149 ppixmax=(1.f - yxratio)*((1.
f - xxratio)*thePixelTemp[index_id].entx[iylow][ilow].pixmax + xxratio*thePixelTemp[index_id].entx[iylow][ihigh].pixmax)
1150 +yxratio*((1.
f - xxratio)*thePixelTemp[index_id].entx[iyhigh][ilow].pixmax + xxratio*thePixelTemp[index_id].entx[iyhigh][ihigh].pixmax);
1152 for(i=0; i<4; ++
i) {
1153 pxavg[
i]=(1.f - yxratio)*((1.
f - xxratio)*thePixelTemp[index_id].entx[iylow][ilow].xavg[
i] + xxratio*thePixelTemp[index_id].entx[iylow][ihigh].xavg[
i])
1154 +yxratio*((1.
f - xxratio)*thePixelTemp[index_id].entx[iyhigh][ilow].xavg[
i] + xxratio*thePixelTemp[index_id].entx[iyhigh][ihigh].xavg[
i]);
1156 pxrms[
i]=(1.f - yxratio)*((1.
f - xxratio)*thePixelTemp[index_id].entx[iylow][ilow].xrms[
i] + xxratio*thePixelTemp[index_id].entx[iylow][ihigh].xrms[
i])
1157 +yxratio*((1.
f - xxratio)*thePixelTemp[index_id].entx[iyhigh][ilow].xrms[
i] + xxratio*thePixelTemp[index_id].entx[iyhigh][ihigh].xrms[
i]);
1165 pxavgc2m[
i]=(1.f - yxratio)*((1.
f - xxratio)*thePixelTemp[index_id].entx[iylow][ilow].xavgc2m[
i] + xxratio*thePixelTemp[index_id].entx[iylow][ihigh].xavgc2m[
i])
1166 +yxratio*((1.
f - xxratio)*thePixelTemp[index_id].entx[iyhigh][ilow].xavgc2m[
i] + xxratio*thePixelTemp[index_id].entx[iyhigh][ihigh].xavgc2m[
i]);
1168 pxrmsc2m[
i]=(1.f - yxratio)*((1.
f - xxratio)*thePixelTemp[index_id].entx[iylow][ilow].xrmsc2m[
i] + xxratio*thePixelTemp[index_id].entx[iylow][ihigh].xrmsc2m[
i])
1169 +yxratio*((1.
f - xxratio)*thePixelTemp[index_id].entx[iyhigh][ilow].xrmsc2m[
i] + xxratio*thePixelTemp[index_id].entx[iyhigh][ihigh].xrmsc2m[
i]);
1185 pchi2xavg[
i]=((1.f - xxratio)*thePixelTemp[index_id].entx[iyhigh][ilow].chi2xavg[i] + xxratio*thePixelTemp[index_id].entx[iyhigh][ihigh].chi2xavg[i]);
1186 if(thePixelTemp[index_id].entx[iyhigh][imidy].chi2xavg[i] != 0.
f) {pchi2xavg[
i]=pchi2xavg[
i]/thePixelTemp[index_id].entx[iyhigh][imidy].chi2xavg[
i]*chi2xavg[
i];}
1188 pchi2xmin[
i]=((1.f - xxratio)*thePixelTemp[index_id].entx[iyhigh][ilow].chi2xmin[i] + xxratio*thePixelTemp[index_id].entx[iyhigh][ihigh].chi2xmin[i]);
1189 if(thePixelTemp[index_id].entx[iyhigh][imidy].chi2xmin[i] != 0.
f) {pchi2xmin[
i]=pchi2xmin[
i]/thePixelTemp[index_id].entx[iyhigh][imidy].chi2xmin[
i]*chi2xmin[
i];}
1191 for(j=0; j<6 ; ++
j) {
1192 pxflparll[
i][
j] = thePixelTemp[index_id].entx[iylow][ilow].xflpar[
i][
j];
1193 pxflparlh[
i][
j] = thePixelTemp[index_id].entx[iylow][ihigh].xflpar[
i][
j];
1194 pxflparhl[
i][
j] = thePixelTemp[index_id].entx[iyhigh][ilow].xflpar[
i][
j];
1195 pxflparhh[
i][
j] = thePixelTemp[index_id].entx[iyhigh][ihigh].xflpar[
i][
j];
1201 pchi2xavgone=((1.f - xxratio)*thePixelTemp[index_id].entx[iyhigh][ilow].chi2xavgone + xxratio*thePixelTemp[index_id].entx[iyhigh][ihigh].chi2xavgone);
1202 if(thePixelTemp[index_id].entx[iyhigh][imidy].chi2xavgone != 0.
f) {pchi2xavgone=pchi2xavgone/thePixelTemp[index_id].entx[iyhigh][imidy].chi2xavgone*chi2xavgone;}
1204 pchi2xminone=((1.f - xxratio)*thePixelTemp[index_id].entx[iyhigh][ilow].chi2xminone + xxratio*thePixelTemp[index_id].entx[iyhigh][ihigh].chi2xminone);
1205 if(thePixelTemp[index_id].entx[iyhigh][imidy].chi2xminone != 0.
f) {pchi2xminone=pchi2xminone/thePixelTemp[index_id].entx[iyhigh][imidy].chi2xminone*chi2xminone;}
1215 cotbeta0 = thePixelTemp[index_id].entx[iyhigh][0].cotbeta;
1216 qxtempcor=
std::sqrt((1.
f+cotbeta*cotbeta+cotalpha*cotalpha)/(1.
f+cotbeta0*cotbeta0+cotalpha*cotalpha));
1218 for(i=0; i<9; ++
i) {
1221 pxtemp[
i][
BXM2] = 0.f;
1222 pxtemp[
i][
BXM1] = 0.f;
1227 pxtemp[
i][j+2]=qxtempcor*((1.f - xxratio)*thePixelTemp[index_id].entx[iyhigh][ilow].xtemp[i][j] + xxratio*thePixelTemp[index_id].entx[iyhigh][ihigh].xtemp[i][j]);
1231 plorywidth = thePixelTemp[index_id].head.lorywidth;
1232 if(locBz > 0.
f) {plorywidth = -plorywidth;}
1233 plorxwidth = thePixelTemp[index_id].head.lorxwidth;
1257 if(cotbeta < 0.) {locBz = -locBz;}
1278 float sigi, sigi2, sigi3, sigi4, symax, qscale;
1282 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
1283 if(fypix < 2 || fypix >=
BYM2) {
1284 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate::ysigma2 called with fypix = " << fypix << std::endl;
1287 assert(fypix > 1 && fypix <
BYM2);
1289 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
1290 if(lypix < fypix || lypix >=
BYM2) {
1291 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate::ysigma2 called with lypix/fypix = " << lypix <<
"/" << fypix << std::endl;
1294 assert(lypix >= fypix && lypix <
BYM2);
1300 if(psymax > psyparmax) {symax = psyparmax;}
1304 for(i=fypix-2; i<=lypix+2; ++
i) {
1305 if(i < fypix || i > lypix) {
1309 ysig2[
i] = ps50*ps50;
1311 if(ysum[i] < symax) {
1316 qscale = ysum[
i]/symax;
1318 sigi2 = sigi*sigi; sigi3 = sigi2*sigi; sigi4 = sigi3*sigi;
1320 ysig2[
i] = (1.-pyratio)*
1321 (pyparl[0][0]+pyparl[0][1]*sigi+pyparl[0][2]*sigi2+pyparl[0][3]*sigi3+pyparl[0][4]*sigi4)
1323 (pyparh[0][0]+pyparh[0][1]*sigi+pyparh[0][2]*sigi2+pyparh[0][3]*sigi3+pyparh[0][4]*sigi4);
1325 ysig2[
i] = (1.-pyratio)*
1326 (pyparl[1][0]+pyparl[1][1]*sigi+pyparl[1][2]*sigi2+pyparl[1][3]*sigi3+pyparl[1][4]*sigi4)
1328 (pyparh[1][0]+pyparh[1][1]*sigi+pyparh[1][2]*sigi2+pyparh[1][3]*sigi3+pyparh[1][4]*sigi4);
1331 if(ysum[i] > sythr) {ysig2[
i] = 1.e8;}
1332 if(ysig2[i] <= 0.) {
LOGERROR(
"SiPixelTemplate") <<
"neg y-error-squared, id = " << id_current <<
", index = " << index_id <<
1333 ", cot(alpha) = " << cota_current <<
", cot(beta) = " << cotb_current <<
", sigi = " << sigi <<
ENDL;}
1355 float sigi, sigi2, sigi3, sigi4, symax, qscale, err2;
1359 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
1360 if(index < 2 || index >=
BYM2) {
1361 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate::ysigma2 called with index = " << index << std::endl;
1364 assert(index > 1 && index <
BYM2);
1370 if(psymax > psyparmax) {symax = psyparmax;}
1374 if(qpixel < symax) {
1379 qscale = qpixel/symax;
1381 sigi2 = sigi*sigi; sigi3 = sigi2*sigi; sigi4 = sigi3*sigi;
1383 err2 = (1.-pyratio)*
1384 (pyparl[0][0]+pyparl[0][1]*sigi+pyparl[0][2]*sigi2+pyparl[0][3]*sigi3+pyparl[0][4]*sigi4)
1386 (pyparh[0][0]+pyparh[0][1]*sigi+pyparh[0][2]*sigi2+pyparh[0][3]*sigi3+pyparh[0][4]*sigi4);
1388 err2 = (1.-pyratio)*
1389 (pyparl[1][0]+pyparl[1][1]*sigi+pyparl[1][2]*sigi2+pyparl[1][3]*sigi3+pyparl[1][4]*sigi4)
1391 (pyparh[1][0]+pyparh[1][1]*sigi+pyparh[1][2]*sigi2+pyparh[1][3]*sigi3+pyparh[1][4]*sigi4);
1394 if(ysig2 <= 0.) {
LOGERROR(
"SiPixelTemplate") <<
"neg y-error-squared, id = " << id_current <<
", index = " << index_id <<
1395 ", cot(alpha) = " << cota_current <<
", cot(beta) = " << cotb_current <<
", sigi = " << sigi <<
ENDL;}
1419 float sigi, sigi2, sigi3, sigi4, yint, sxmax, x0, qscale;
1423 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
1424 if(fxpix < 2 || fxpix >=
BXM2) {
1425 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate::xsigma2 called with fxpix = " << fxpix << std::endl;
1428 assert(fxpix > 1 && fxpix <
BXM2);
1430 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
1431 if(lxpix < fxpix || lxpix >=
BXM2) {
1432 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate::xsigma2 called with lxpix/fxpix = " << lxpix <<
"/" << fxpix << std::endl;
1435 assert(lxpix >= fxpix && lxpix <
BXM2);
1441 if(psxmax > psxparmax) {sxmax = psxparmax;}
1445 for(i=fxpix-2; i<=lxpix+2; ++
i) {
1446 if(i < fxpix || i > lxpix) {
1450 xsig2[
i] = ps50*ps50;
1452 if(xsum[i] < sxmax) {
1457 qscale = xsum[
i]/sxmax;
1459 sigi2 = sigi*sigi; sigi3 = sigi2*sigi; sigi4 = sigi3*sigi;
1464 yint = (1.-pyratio)*
1465 (pxparly0[0][0]+pxparly0[0][1]*sigi+pxparly0[0][2]*sigi2+pxparly0[0][3]*sigi3+pxparly0[0][4]*sigi4)
1467 (pxparhy0[0][0]+pxparhy0[0][1]*sigi+pxparhy0[0][2]*sigi2+pxparhy0[0][3]*sigi3+pxparhy0[0][4]*sigi4);
1469 yint = (1.-pyratio)*
1470 (pxparly0[1][0]+pxparly0[1][1]*sigi+pxparly0[1][2]*sigi2+pxparly0[1][3]*sigi3+pxparly0[1][4]*sigi4)
1472 (pxparhy0[1][0]+pxparhy0[1][1]*sigi+pxparhy0[1][2]*sigi2+pxparhy0[1][3]*sigi3+pxparhy0[1][4]*sigi4);
1478 xsig2[
i] = (1.-pxxratio)*
1479 (pxparl[0][0]+pxparl[0][1]*sigi+pxparl[0][2]*sigi2+pxparl[0][3]*sigi3+pxparl[0][4]*sigi4)
1481 (pxparh[0][0]+pxparh[0][1]*sigi+pxparh[0][2]*sigi2+pxparh[0][3]*sigi3+pxparh[0][4]*sigi4);
1483 xsig2[
i] = (1.-pxxratio)*
1484 (pxparl[1][0]+pxparl[1][1]*sigi+pxparl[1][2]*sigi2+pxparl[1][3]*sigi3+pxparl[1][4]*sigi4)
1486 (pxparh[1][0]+pxparh[1][1]*sigi+pxparh[1][2]*sigi2+pxparh[1][3]*sigi3+pxparh[1][4]*sigi4);
1492 x0 = pxpar0[0][0]+pxpar0[0][1]*sigi+pxpar0[0][2]*sigi2+pxpar0[0][3]*sigi3+pxpar0[0][4]*sigi4;
1494 x0 = pxpar0[1][0]+pxpar0[1][1]*sigi+pxpar0[1][2]*sigi2+pxpar0[1][3]*sigi3+pxpar0[1][4]*sigi4;
1499 if(x0 != 0.) {xsig2[
i] = xsig2[
i]/x0 * yint;}
1501 if(xsum[i] > sxthr) {xsig2[
i] = 1.e8;}
1502 if(xsig2[i] <= 0.) {
LOGERROR(
"SiPixelTemplate") <<
"neg x-error-squared, id = " << id_current <<
", index = " << index_id <<
1503 ", cot(alpha) = " << cota_current <<
", cot(beta) = " << cotb_current <<
", sigi = " << sigi <<
ENDL;}
1527 float qfl, qfl2, qfl3, qfl4, qfl5, dy;
1531 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
1532 if(binq < 0 || binq > 3) {
1533 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate::yflcorr called with binq = " << binq << std::endl;
1536 assert(binq >= 0 && binq < 4);
1538 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
1539 if(fabs((
double)qfly) > 1.) {
1540 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate::yflcorr called with qfly = " << qfly << std::endl;
1543 assert(fabs((
double)qfly) <= 1.);
1550 if(qfl < -0.9) {qfl = -0.9;}
1551 if(qfl > 0.9) {qfl = 0.9;}
1555 qfl2 = qfl*qfl; qfl3 = qfl2*qfl; qfl4 = qfl3*qfl; qfl5 = qfl4*qfl;
1556 dy = (1.-pyratio)*(pyflparl[binq][0]+pyflparl[binq][1]*qfl+pyflparl[binq][2]*qfl2+pyflparl[binq][3]*qfl3+pyflparl[binq][4]*qfl4+pyflparl[binq][5]*qfl5)
1557 + pyratio*(pyflparh[binq][0]+pyflparh[binq][1]*qfl+pyflparh[binq][2]*qfl2+pyflparh[binq][3]*qfl3+pyflparh[binq][4]*qfl4+pyflparh[binq][5]*qfl5);
1579 float qfl, qfl2, qfl3, qfl4, qfl5, dx;
1583 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
1584 if(binq < 0 || binq > 3) {
1585 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate::xflcorr called with binq = " << binq << std::endl;
1588 assert(binq >= 0 && binq < 4);
1590 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
1591 if(fabs((
double)qflx) > 1.) {
1592 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate::xflcorr called with qflx = " << qflx << std::endl;
1595 assert(fabs((
double)qflx) <= 1.);
1602 if(qfl < -0.9) {qfl = -0.9;}
1603 if(qfl > 0.9) {qfl = 0.9;}
1607 qfl2 = qfl*qfl; qfl3 = qfl2*qfl; qfl4 = qfl3*qfl; qfl5 = qfl4*qfl;
1608 dx = (1. - pyxratio)*((1.-pxxratio)*(pxflparll[binq][0]+pxflparll[binq][1]*qfl+pxflparll[binq][2]*qfl2+pxflparll[binq][3]*qfl3+pxflparll[binq][4]*qfl4+pxflparll[binq][5]*qfl5)
1609 + pxxratio*(pxflparlh[binq][0]+pxflparlh[binq][1]*qfl+pxflparlh[binq][2]*qfl2+pxflparlh[binq][3]*qfl3+pxflparlh[binq][4]*qfl4+pxflparlh[binq][5]*qfl5))
1610 + pyxratio*((1.-pxxratio)*(pxflparhl[binq][0]+pxflparhl[binq][1]*qfl+pxflparhl[binq][2]*qfl2+pxflparhl[binq][3]*qfl3+pxflparhl[binq][4]*qfl4+pxflparhl[binq][5]*qfl5)
1611 + pxxratio*(pxflparhh[binq][0]+pxflparhh[binq][1]*qfl+pxflparhh[binq][2]*qfl2+pxflparhh[binq][3]*qfl3+pxflparhh[binq][4]*qfl4+pxflparhh[binq][5]*qfl5));
1635 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
1636 if(fybin < 0 || fybin > 40) {
1637 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate::ytemp called with fybin = " << fybin << std::endl;
1640 assert(fybin >= 0 && fybin < 41);
1642 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
1643 if(lybin < 0 || lybin > 40) {
1644 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate::ytemp called with lybin = " << lybin << std::endl;
1647 assert(lybin >= 0 && lybin < 41);
1652 for(i=0; i<9; ++
i) {
1654 ytemplate[i+16][
j]=pytemp[
i][
j];
1657 for(i=0; i<8; ++
i) {
1658 ytemplate[i+8][
BYM1] = 0.;
1659 for(j=0; j<
BYM1; ++
j) {
1660 ytemplate[i+8][
j]=pytemp[
i][j+1];
1663 for(i=1; i<9; ++
i) {
1664 ytemplate[i+24][0] = 0.;
1665 for(j=0; j<
BYM1; ++
j) {
1666 ytemplate[i+24][j+1]=pytemp[
i][
j];
1673 for(i=0; i<8; ++
i) {
1674 ytemplate[
i][
BYM2] = 0.;
1675 ytemplate[
i][
BYM1] = 0.;
1676 for(j=0; j<
BYM2; ++
j) {
1677 ytemplate[
i][
j]=pytemp[
i][j+2];
1682 for(i=1; i<9; ++
i) {
1683 ytemplate[i+32][0] = 0.;
1684 ytemplate[i+32][1] = 0.;
1685 for(j=0; j<
BYM2; ++
j) {
1686 ytemplate[i+32][j+2]=pytemp[
i][
j];
1713 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
1714 if(fxbin < 0 || fxbin > 40) {
1715 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate::xtemp called with fxbin = " << fxbin << std::endl;
1718 assert(fxbin >= 0 && fxbin < 41);
1720 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
1721 if(lxbin < 0 || lxbin > 40) {
1722 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate::xtemp called with lxbin = " << lxbin << std::endl;
1725 assert(lxbin >= 0 && lxbin < 41);
1730 for(i=0; i<9; ++
i) {
1732 xtemplate[i+16][
j]=pxtemp[
i][
j];
1735 for(i=0; i<8; ++
i) {
1736 xtemplate[i+8][
BXM1] = 0.;
1737 for(j=0; j<
BXM1; ++
j) {
1738 xtemplate[i+8][
j]=pxtemp[
i][j+1];
1741 for(i=1; i<9; ++
i) {
1742 xtemplate[i+24][0] = 0.;
1743 for(j=0; j<
BXM1; ++
j) {
1744 xtemplate[i+24][j+1]=pxtemp[
i][
j];
1751 for(i=0; i<8; ++
i) {
1752 xtemplate[
i][
BXM2] = 0.;
1753 xtemplate[
i][
BXM1] = 0.;
1754 for(j=0; j<
BXM2; ++
j) {
1755 xtemplate[
i][
j]=pxtemp[
i][j+2];
1760 for(i=1; i<9; ++
i) {
1761 xtemplate[i+32][0] = 0.;
1762 xtemplate[i+32][1] = 0.;
1763 for(j=0; j<
BXM2; ++
j) {
1764 xtemplate[i+32][j+2]=pxtemp[
i][
j];
1782 typedef boost::multi_array<float, 2>
array_2d;
1788 int ioff0, ioffp, ioffm;
1792 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
1793 if(nypix < 1 || nypix >=
BYM3) {
1794 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate::ytemp3d called with nypix = " << nypix << std::endl;
1797 assert(nypix > 0 && nypix <
BYM3);
1802 float diff = fabsf(nypix - pclsleny)/2. + 1.;
1803 int nshift = (int)diff;
1804 if((diff - nshift) > 0.5) {++nshift;}
1808 int nbins = 9 + 16*nshift;
1812 array_2d temp2d(boost::extents[nbins][
BYSIZE]);
1818 for(i=0; i<9; ++
i) {
1820 temp2d[i+ioff0][
j]=pytemp[
i][
j];
1826 for(k=1; k<=nshift; ++
k) {
1828 for(i=0; i<8; ++
i) {
1829 for(j=0; j<
k; ++
j) {
1830 temp2d[i+ioffm][
BYM1-
j] = 0.;
1832 for(j=0; j<BYSIZE-
k; ++
j) {
1833 temp2d[i+ioffm][
j]=pytemp[
i][j+
k];
1837 for(i=1; i<9; ++
i) {
1838 for(j=0; j<
k; ++
j) {
1839 temp2d[i+ioffp][
j] = 0.;
1841 for(j=0; j<BYSIZE-
k; ++
j) {
1842 temp2d[i+ioffp][j+
k]=pytemp[
i][
j];
1849 ytemplate.resize(boost::extents[nbins][nbins][BYSIZE]);
1854 for(j=0; j<=
i; ++
j) {
1856 ytemplate[
i][
j][
k]=temp2d[
i][
k]+temp2d[
j][
k];
1874 typedef boost::multi_array<float, 2>
array_2d;
1880 int ioff0, ioffp, ioffm;
1884 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
1885 if(nxpix < 1 || nxpix >=
BXM3) {
1886 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate::xtemp3d called with nxpix = " << nxpix << std::endl;
1889 assert(nxpix > 0 && nxpix <
BXM3);
1894 float diff = fabsf(nxpix - pclslenx)/2. + 1.;
1895 int nshift = (int)diff;
1896 if((diff - nshift) > 0.5) {++nshift;}
1900 int nbins = 9 + 16*nshift;
1904 array_2d temp2d(boost::extents[nbins][
BXSIZE]);
1910 for(i=0; i<9; ++
i) {
1912 temp2d[i+ioff0][
j]=pxtemp[
i][
j];
1918 for(k=1; k<=nshift; ++
k) {
1920 for(i=0; i<8; ++
i) {
1921 for(j=0; j<
k; ++
j) {
1922 temp2d[i+ioffm][
BXM1-
j] = 0.;
1924 for(j=0; j<BXSIZE-
k; ++
j) {
1925 temp2d[i+ioffm][
j]=pxtemp[
i][j+
k];
1929 for(i=1; i<9; ++
i) {
1930 for(j=0; j<
k; ++
j) {
1931 temp2d[i+ioffp][
j] = 0.;
1933 for(j=0; j<BXSIZE-
k; ++
j) {
1934 temp2d[i+ioffp][j+
k]=pxtemp[
i][
j];
1941 xtemplate.resize(boost::extents[nbins][nbins][BXSIZE]);
1946 for(j=0; j<=
i; ++
j) {
1948 xtemplate[
i][
j][
k]=temp2d[
i][
k]+temp2d[
j][
k];
1984 int SiPixelTemplate::qbin(
int id,
float cotalpha,
float cotbeta,
float locBz,
float qclus,
float& pixmx,
float& sigmay,
float& deltay,
float& sigmax,
float& deltax,
1985 float& sy1,
float& dy1,
float& sy2,
float& dy2,
float& sx1,
float& dx1,
float& sx2,
float& dx2,
float& lorywidth,
float& lorxwidth)
1992 int ilow, ihigh, iylow, iyhigh, Ny, Nxx, Nyx, imidy, imaxx,
index;
1993 float yratio, yxratio, xxratio;
1994 float acotb, qscale, qavg, qmin, qmin2, fq, qtotal, qcorrect, cotb, cotalpha0;
1995 float yavggen[4], yrmsgen[4], xavggen[4], xrmsgen[4];
2002 for(i=0; i<(int)thePixelTemp.size(); ++
i) {
2004 if(
id == thePixelTemp[i].head.ID) {
2011 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
2012 if(index < 0 || index >= (
int)thePixelTemp.size()) {
2013 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate::qbin can't find needed template ID = " <<
id << std::endl;
2016 assert(index >= 0 && index < (
int)thePixelTemp.size());
2023 acotb = fabs((
double)cotbeta);
2029 cotalpha0 = thePixelTemp[
index].enty[0].cotalpha;
2030 qcorrect=(float)
sqrt((
double)((1.+cotbeta*cotbeta+cotalpha*cotalpha)/(1.+cotbeta*cotbeta+cotalpha0*cotalpha0)));
2034 if(thePixelTemp[index].head.Dtype == 0) {
2037 if(cotbeta < 0.) {flip_y =
true;}
2050 qscale = thePixelTemp[
index].head.qscale;
2052 Ny = thePixelTemp[
index].head.NTy;
2053 Nyx = thePixelTemp[
index].head.NTyx;
2054 Nxx = thePixelTemp[
index].head.NTxx;
2056 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
2057 if(Ny < 2 || Nyx < 1 || Nxx < 2) {
2058 throw cms::Exception(
"DataCorrupt") <<
"template ID = " << id_current <<
"has too few entries: Ny/Nyx/Nxx = " << Ny <<
"/" << Nyx <<
"/" << Nxx << std::endl;
2061 assert(Ny > 1 && Nyx > 0 && Nxx > 1);
2071 if(cotb >= thePixelTemp[index].enty[Ny-1].cotbeta) {
2078 if(cotb >= thePixelTemp[index].enty[0].cotbeta) {
2080 for (i=0; i<Ny-1; ++
i) {
2082 if( thePixelTemp[index].enty[i].cotbeta <= cotb && cotb < thePixelTemp[index].enty[i+1].cotbeta) {
2085 yratio = (cotb - thePixelTemp[
index].enty[
i].cotbeta)/(thePixelTemp[index].enty[i+1].cotbeta - thePixelTemp[index].enty[i].cotbeta);
2096 qavg = (1. - yratio)*thePixelTemp[index].enty[ilow].qavg + yratio*thePixelTemp[index].enty[ihigh].qavg;
2098 dy1 = (1. - yratio)*thePixelTemp[index].enty[ilow].dyone + yratio*thePixelTemp[index].enty[ihigh].dyone;
2099 if(flip_y) {dy1 = -dy1;}
2100 sy1 = (1. - yratio)*thePixelTemp[index].enty[ilow].syone + yratio*thePixelTemp[index].enty[ihigh].syone;
2101 dy2 = (1. - yratio)*thePixelTemp[index].enty[ilow].dytwo + yratio*thePixelTemp[index].enty[ihigh].dytwo;
2102 if(flip_y) {dy2 = -dy2;}
2103 sy2 = (1. - yratio)*thePixelTemp[index].enty[ilow].sytwo + yratio*thePixelTemp[index].enty[ihigh].sytwo;
2104 qmin = (1. - yratio)*thePixelTemp[index].enty[ilow].qmin + yratio*thePixelTemp[index].enty[ihigh].qmin;
2106 qmin2 = (1. - yratio)*thePixelTemp[index].enty[ilow].qmin2 + yratio*thePixelTemp[index].enty[ihigh].qmin2;
2108 for(i=0; i<4; ++
i) {
2109 yavggen[
i]=(1. - yratio)*thePixelTemp[index].enty[ilow].yavggen[i] + yratio*thePixelTemp[index].enty[ihigh].yavggen[i];
2110 if(flip_y) {yavggen[
i] = -yavggen[
i];}
2111 yrmsgen[
i]=(1. - yratio)*thePixelTemp[index].enty[ilow].yrmsgen[i] + yratio*thePixelTemp[index].enty[ihigh].yrmsgen[i];
2120 if(acotb >= thePixelTemp[index].entx[Nyx-1][0].cotbeta) {
2125 }
else if(acotb >= thePixelTemp[index].entx[0][0].cotbeta) {
2127 for (i=0; i<Nyx-1; ++
i) {
2129 if( thePixelTemp[index].entx[i][0].cotbeta <= acotb && acotb < thePixelTemp[index].entx[i+1][0].cotbeta) {
2132 yxratio = (acotb - thePixelTemp[
index].entx[
i][0].cotbeta)/(thePixelTemp[index].entx[i+1][0].cotbeta - thePixelTemp[index].entx[i][0].cotbeta);
2143 if(cotalpha >= thePixelTemp[index].entx[0][Nxx-1].cotalpha) {
2150 if(cotalpha >= thePixelTemp[index].entx[0][0].cotalpha) {
2152 for (i=0; i<Nxx-1; ++
i) {
2154 if( thePixelTemp[index].entx[0][i].cotalpha <= cotalpha && cotalpha < thePixelTemp[index].entx[0][i+1].cotalpha) {
2157 xxratio = (cotalpha - thePixelTemp[
index].entx[0][
i].cotalpha)/(thePixelTemp[index].entx[0][i+1].cotalpha - thePixelTemp[index].entx[0][i].cotalpha);
2166 dx1 = (1. - xxratio)*thePixelTemp[index].entx[0][ilow].dxone + xxratio*thePixelTemp[index].entx[0][ihigh].dxone;
2167 sx1 = (1. - xxratio)*thePixelTemp[index].entx[0][ilow].sxone + xxratio*thePixelTemp[index].entx[0][ihigh].sxone;
2168 dx2 = (1. - xxratio)*thePixelTemp[index].entx[0][ilow].dxtwo + xxratio*thePixelTemp[index].entx[0][ihigh].dxtwo;
2169 sx2 = (1. - xxratio)*thePixelTemp[index].entx[0][ilow].sxtwo + xxratio*thePixelTemp[index].entx[0][ihigh].sxtwo;
2173 pixmx=(1. - yxratio)*((1. - xxratio)*thePixelTemp[
index].entx[iylow][ilow].pixmax + xxratio*thePixelTemp[
index].entx[iylow][ihigh].pixmax)
2174 +yxratio*((1. - xxratio)*thePixelTemp[
index].entx[iyhigh][ilow].pixmax + xxratio*thePixelTemp[
index].entx[iyhigh][ihigh].pixmax);
2176 for(i=0; i<4; ++
i) {
2178 xavggen[
i]=(1. - yxratio)*((1. - xxratio)*thePixelTemp[
index].entx[iylow][ilow].xavggen[
i] + xxratio*thePixelTemp[
index].entx[iylow][ihigh].xavggen[
i])
2179 +yxratio*((1. - xxratio)*thePixelTemp[
index].entx[iyhigh][ilow].xavggen[
i] + xxratio*thePixelTemp[
index].entx[iyhigh][ihigh].xavggen[
i]);
2181 xrmsgen[
i]=(1. - yxratio)*((1. - xxratio)*thePixelTemp[
index].entx[iylow][ilow].xrmsgen[
i] + xxratio*thePixelTemp[
index].entx[iylow][ihigh].xrmsgen[
i])
2182 +yxratio*((1. - xxratio)*thePixelTemp[
index].entx[iyhigh][ilow].xrmsgen[
i] + xxratio*thePixelTemp[
index].entx[iyhigh][ihigh].xrmsgen[
i]);
2185 lorywidth = thePixelTemp[
index].head.lorywidth;
2186 if(locBz > 0.) {lorywidth = -lorywidth;}
2187 lorxwidth = thePixelTemp[
index].head.lorxwidth;
2191 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
2192 if(qavg <= 0. || qmin <= 0.) {
2193 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate::qbin, qavg or qmin <= 0,"
2194 <<
" Probably someone called the generic pixel reconstruction with an illegal trajectory state" << std::endl;
2197 assert(qavg > 0. && qmin > 0.);
2202 qtotal = qscale*qclus;
2223 sigmay = yrmsgen[binq]; deltay = yavggen[binq];
2225 sigmax = xrmsgen[binq]; deltax = xavggen[binq];
2229 if(qtotal < 0.95*qmin) {binq = 5;}
else {
if(qtotal < 0.95*qmin2) {binq = 4;}}
2258 int SiPixelTemplate::qbin(
int id,
float cotalpha,
float cotbeta,
float locBz,
float qclus,
float& pixmx,
float& sigmay,
float& deltay,
float& sigmax,
float& deltax,
2259 float& sy1,
float& dy1,
float& sy2,
float& dy2,
float& sx1,
float& dx1,
float& sx2,
float& dx2)
2262 float lorywidth, lorxwidth;
2263 return SiPixelTemplate::qbin(
id, cotalpha, cotbeta, locBz, qclus, pixmx, sigmay, deltay, sigmax, deltax,
2264 sy1, dy1, sy2, dy2, sx1, dx1, sx2, dx2, lorywidth, lorxwidth);
2280 float pixmx, sigmay, deltay, sigmax, deltax, sy1, dy1, sy2, dy2, sx1, dx1, sx2, dx2, locBz, lorywidth, lorxwidth;
2281 const float cotalpha = 0.;
2283 if(cotbeta < 0.) {locBz = -locBz;}
2284 return SiPixelTemplate::qbin(
id, cotalpha, cotbeta, locBz, qclus, pixmx, sigmay, deltay, sigmax, deltax,
2285 sy1, dy1, sy2, dy2, sx1, dx1, sx2, dx2, lorywidth, lorxwidth);
2304 void SiPixelTemplate::temperrors(
int id,
float cotalpha,
float cotbeta,
int qBin,
float& sigmay,
float& sigmax,
float& sy1,
float& sy2,
float& sx1,
float& sx2)
2311 int ilow, ihigh, iylow, iyhigh, Ny, Nxx, Nyx, imidy, imaxx,
index;
2312 float yratio, yxratio, xxratio;
2321 for(i=0; i<(int)thePixelTemp.size(); ++
i) {
2323 if(
id == thePixelTemp[i].head.ID) {
2330 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
2331 if(index < 0 || index >= (
int)thePixelTemp.size()) {
2332 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate::temperrors can't find needed template ID = " <<
id << std::endl;
2335 assert(index >= 0 && index < (
int)thePixelTemp.size());
2339 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
2340 if(qBin < 0 || qBin > 5) {
2341 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate::temperrors called with illegal qBin = " << qBin << std::endl;
2344 assert(qBin >= 0 && qBin < 6);
2349 if(qBin > 3) {qBin = 3;}
2354 acotb = fabs((
double)cotbeta);
2362 if(cotbeta < 0.) {flip_y =
true;}
2375 Ny = thePixelTemp[
index].head.NTy;
2376 Nyx = thePixelTemp[
index].head.NTyx;
2377 Nxx = thePixelTemp[
index].head.NTxx;
2379 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
2380 if(Ny < 2 || Nyx < 1 || Nxx < 2) {
2381 throw cms::Exception(
"DataCorrupt") <<
"template ID = " << id_current <<
"has too few entries: Ny/Nyx/Nxx = " << Ny <<
"/" << Nyx <<
"/" << Nxx << std::endl;
2384 assert(Ny > 1 && Nyx > 0 && Nxx > 1);
2394 if(cotb >= thePixelTemp[index].enty[Ny-1].cotbeta) {
2401 if(cotb >= thePixelTemp[index].enty[0].cotbeta) {
2403 for (i=0; i<Ny-1; ++
i) {
2405 if( thePixelTemp[index].enty[i].cotbeta <= cotb && cotb < thePixelTemp[index].enty[i+1].cotbeta) {
2408 yratio = (cotb - thePixelTemp[
index].enty[
i].cotbeta)/(thePixelTemp[index].enty[i+1].cotbeta - thePixelTemp[index].enty[i].cotbeta);
2419 sy1 = (1. - yratio)*thePixelTemp[index].enty[ilow].syone + yratio*thePixelTemp[index].enty[ihigh].syone;
2420 sy2 = (1. - yratio)*thePixelTemp[index].enty[ilow].sytwo + yratio*thePixelTemp[index].enty[ihigh].sytwo;
2421 yrms=(1. - yratio)*thePixelTemp[index].enty[ilow].yrms[qBin] + yratio*thePixelTemp[index].enty[ihigh].yrms[qBin];
2429 if(acotb >= thePixelTemp[index].entx[Nyx-1][0].cotbeta) {
2434 }
else if(acotb >= thePixelTemp[index].entx[0][0].cotbeta) {
2436 for (i=0; i<Nyx-1; ++
i) {
2438 if( thePixelTemp[index].entx[i][0].cotbeta <= acotb && acotb < thePixelTemp[index].entx[i+1][0].cotbeta) {
2441 yxratio = (acotb - thePixelTemp[
index].entx[
i][0].cotbeta)/(thePixelTemp[index].entx[i+1][0].cotbeta - thePixelTemp[index].entx[i][0].cotbeta);
2452 if(cotalpha >= thePixelTemp[index].entx[0][Nxx-1].cotalpha) {
2459 if(cotalpha >= thePixelTemp[index].entx[0][0].cotalpha) {
2461 for (i=0; i<Nxx-1; ++
i) {
2463 if( thePixelTemp[index].entx[0][i].cotalpha <= cotalpha && cotalpha < thePixelTemp[index].entx[0][i+1].cotalpha) {
2466 xxratio = (cotalpha - thePixelTemp[
index].entx[0][
i].cotalpha)/(thePixelTemp[index].entx[0][i+1].cotalpha - thePixelTemp[index].entx[0][i].cotalpha);
2475 sx1 = (1. - xxratio)*thePixelTemp[index].entx[0][ilow].sxone + xxratio*thePixelTemp[index].entx[0][ihigh].sxone;
2476 sx2 = (1. - xxratio)*thePixelTemp[index].entx[0][ilow].sxtwo + xxratio*thePixelTemp[index].entx[0][ihigh].sxtwo;
2478 xrms=(1. - yxratio)*((1. - xxratio)*thePixelTemp[
index].entx[iylow][ilow].xrms[qBin] + xxratio*thePixelTemp[
index].entx[iylow][ihigh].xrms[qBin])
2479 +yxratio*((1. - xxratio)*thePixelTemp[
index].entx[iyhigh][ilow].xrms[qBin] + xxratio*thePixelTemp[
index].entx[iyhigh][ihigh].xrms[qBin]);
2505 void SiPixelTemplate::qbin_dist(
int id,
float cotalpha,
float cotbeta,
float qbin_frac[4],
float& ny1_frac,
float& ny2_frac,
float& nx1_frac,
float& nx2_frac)
2512 int ilow, ihigh, iylow, iyhigh, Ny, Nxx, Nyx, imidy, imaxx,
index;
2513 float yratio, yxratio, xxratio;
2521 for(i=0; i<(int)thePixelTemp.size(); ++
i) {
2523 if(
id == thePixelTemp[i].head.ID) {
2531 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
2532 if(index < 0 || index >= (
int)thePixelTemp.size()) {
2533 throw cms::Exception(
"DataCorrupt") <<
"SiPixelTemplate::temperrors can't find needed template ID = " <<
id << std::endl;
2536 assert(index >= 0 && index < (
int)thePixelTemp.size());
2543 acotb = fabs((
double)cotbeta);
2552 if(cotbeta < 0.) {flip_y =
true;}
2565 Ny = thePixelTemp[
index].head.NTy;
2566 Nyx = thePixelTemp[
index].head.NTyx;
2567 Nxx = thePixelTemp[
index].head.NTxx;
2569 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
2570 if(Ny < 2 || Nyx < 1 || Nxx < 2) {
2571 throw cms::Exception(
"DataCorrupt") <<
"template ID = " << id_current <<
"has too few entries: Ny/Nyx/Nxx = " << Ny <<
"/" << Nyx <<
"/" << Nxx << std::endl;
2574 assert(Ny > 1 && Nyx > 0 && Nxx > 1);
2584 if(cotb >= thePixelTemp[index].enty[Ny-1].cotbeta) {
2591 if(cotb >= thePixelTemp[index].enty[0].cotbeta) {
2593 for (i=0; i<Ny-1; ++
i) {
2595 if( thePixelTemp[index].enty[i].cotbeta <= cotb && cotb < thePixelTemp[index].enty[i+1].cotbeta) {
2598 yratio = (cotb - thePixelTemp[
index].enty[
i].cotbeta)/(thePixelTemp[index].enty[i+1].cotbeta - thePixelTemp[index].enty[i].cotbeta);
2608 ny1_frac = (1. - yratio)*thePixelTemp[index].enty[ilow].fracyone + yratio*thePixelTemp[index].enty[ihigh].fracyone;
2609 ny2_frac = (1. - yratio)*thePixelTemp[index].enty[ilow].fracytwo + yratio*thePixelTemp[index].enty[ihigh].fracytwo;
2616 if(acotb >= thePixelTemp[index].entx[Nyx-1][0].cotbeta) {
2621 }
else if(acotb >= thePixelTemp[index].entx[0][0].cotbeta) {
2623 for (i=0; i<Nyx-1; ++
i) {
2625 if( thePixelTemp[index].entx[i][0].cotbeta <= acotb && acotb < thePixelTemp[index].entx[i+1][0].cotbeta) {
2628 yxratio = (acotb - thePixelTemp[
index].entx[
i][0].cotbeta)/(thePixelTemp[index].entx[i+1][0].cotbeta - thePixelTemp[index].entx[i][0].cotbeta);
2639 if(cotalpha >= thePixelTemp[index].entx[0][Nxx-1].cotalpha) {
2646 if(cotalpha >= thePixelTemp[index].entx[0][0].cotalpha) {
2648 for (i=0; i<Nxx-1; ++
i) {
2650 if( thePixelTemp[index].entx[0][i].cotalpha <= cotalpha && cotalpha < thePixelTemp[index].entx[0][i+1].cotalpha) {
2653 xxratio = (cotalpha - thePixelTemp[
index].entx[0][
i].cotalpha)/(thePixelTemp[index].entx[0][i+1].cotalpha - thePixelTemp[index].entx[0][i].cotalpha);
2662 for(i=0; i<3; ++
i) {
2663 qfrac[
i]=(1. - yxratio)*((1. - xxratio)*thePixelTemp[
index].entx[iylow][ilow].qbfrac[
i] + xxratio*thePixelTemp[
index].entx[iylow][ihigh].qbfrac[
i])
2664 +yxratio*((1. - xxratio)*thePixelTemp[
index].entx[iyhigh][ilow].qbfrac[
i] + xxratio*thePixelTemp[
index].entx[iyhigh][ihigh].qbfrac[
i]);
2666 nx1_frac = (1. - yxratio)*((1. - xxratio)*thePixelTemp[
index].entx[iylow][ilow].fracxone + xxratio*thePixelTemp[
index].entx[iylow][ihigh].fracxone)
2667 +yxratio*((1. - xxratio)*thePixelTemp[
index].entx[iyhigh][ilow].fracxone + xxratio*thePixelTemp[
index].entx[iyhigh][ihigh].fracxone);
2668 nx2_frac = (1. - yxratio)*((1. - xxratio)*thePixelTemp[
index].entx[iylow][ilow].fracxtwo + xxratio*thePixelTemp[
index].entx[iylow][ihigh].fracxtwo)
2669 +yxratio*((1. - xxratio)*thePixelTemp[
index].entx[iyhigh][ilow].fracxtwo + xxratio*thePixelTemp[
index].entx[iyhigh][ihigh].fracxtwo);
2673 qbin_frac[0] = qfrac[0];
2674 qbin_frac[1] = qbin_frac[0] + qfrac[1];
2675 qbin_frac[2] = qbin_frac[1] + qfrac[2];
2696 float x0, y0, xf, yf, xi, yi, sf, si, s0, qpix, slopey, slopex, ds;
2697 int i,
j, jpix0, ipix0, jpixf, ipixf, jpix, ipix, nx, ny, anx,
any, jmax, imax;
2700 std::list<SimplePixel>
list;
2701 std::list<SimplePixel>::iterator listIter, listEnd;
2705 x0 = xhit - 0.5*pzsize*cota_current;
2706 y0 = yhit - 0.5*pzsize*cotb_current;
2708 jpix0 = floor(x0/pxsize)+1;
2709 ipix0 = floor(y0/pysize)+1;
2711 if(jpix0 < 0 || jpix0 >
BXM3) {
return false;}
2712 if(ipix0 < 0 || ipix0 >
BYM3) {
return false;}
2714 xf = xhit + 0.5*pzsize*cota_current + plorxwidth;
2715 yf = yhit + 0.5*pzsize*cotb_current + plorywidth;
2717 jpixf = floor(xf/pxsize)+1;
2718 ipixf = floor(yf/pysize)+1;
2720 if(jpixf < 0 || jpixf > BXM3) {
return false;}
2721 if(ipixf < 0 || ipixf > BYM3) {
return false;}
2725 sf =
sqrt((xf-x0)*(xf-x0) + (yf-y0)*(yf-y0));
2726 if((xf-x0) != 0.) {slopey = (yf-y0)/(xf-x0);}
else { slopey = 1.e10;}
2727 if((yf-y0) != 0.) {slopex = (xf-x0)/(yf-y0);}
else { slopex = 1.e10;}
2740 list.push_back(element);
2748 for(j=jpix0; j<jpixf; ++
j) {
2750 yi = slopey*(xi-x0) + y0;
2751 ipix = (int)(yi/pysize)+1;
2752 si =
sqrt((xi-x0)*(xi-x0) + (yi-y0)*(yi-y0));
2759 list.push_back(element);
2762 for(j=jpix0; j>jpixf; --
j) {
2764 yi = slopey*(xi-x0) + y0;
2765 ipix = (int)(yi/pysize)+1;
2766 si =
sqrt((xi-x0)*(xi-x0) + (yi-y0)*(yi-y0));
2773 list.push_back(element);
2782 for(i=ipix0; i<ipixf; ++
i) {
2784 xi = slopex*(yi-y0) + x0;
2785 jpix = (int)(xi/pxsize)+1;
2786 si =
sqrt((xi-x0)*(xi-x0) + (yi-y0)*(yi-y0));
2793 list.push_back(element);
2796 for(i=ipix0; i>ipixf; --
i) {
2798 xi = slopex*(yi-y0) + x0;
2799 jpix = (int)(xi/pxsize)+1;
2800 si =
sqrt((xi-x0)*(xi-x0) + (yi-y0)*(yi-y0));
2807 list.push_back(element);
2821 for(i=1; i<imax; ++
i) {
2823 listIter = list.begin();
2825 while(listIter != list.end()) {
2826 if(listIter->i == i && listIter->btype == 2) {
2827 listIter = list.erase(listIter);
2830 if(listIter->i > i) {
2836 while(listIter != list.end()) {
2837 if(listIter->i == i+1 && listIter->btype == 2) {
2838 listIter = list.erase(listIter);
2841 if(listIter->i > i+1) {
2850 for(j=1; j<jmax; ++
j) {
2852 listIter = list.begin();
2854 while(listIter != list.end()) {
2855 if(listIter->j == j && listIter->btype == 1) {
2856 listIter = list.erase(listIter);
2859 if(listIter->j > j) {
2865 while(listIter != list.end()) {
2866 if(listIter->j == j+1 && listIter->btype == 1) {
2867 listIter = list.erase(listIter);
2870 if(listIter->j > j+1) {
2882 listIter = list.begin();
2883 listEnd = list.end();
2884 for( ;listIter != listEnd; ++listIter) {
2890 if(sf > 0.) { qpix = qtotal*ds/sf;}
else {qpix = qtotal;}
2891 template2d[
j][
i] += qpix;
2910 int ilow, ihigh, Ny;
2915 cotb =
sqrt(cotb_current*cotb_current + cota_current*cota_current);
2919 Ny = thePixelTemp[index_id].head.NTy;
2921 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
2923 throw cms::Exception(
"DataCorrupt") <<
"template ID = " << id_current <<
"has too few entries: Ny = " << Ny << std::endl;
2934 if(cotb >= thePixelTemp[index_id].enty[Ny-1].cotbeta) {
2941 if(cotb >= thePixelTemp[index_id].enty[0].cotbeta) {
2943 for (i=0; i<Ny-1; ++
i) {
2945 if( thePixelTemp[index_id].enty[i].cotbeta <= cotb && cotb < thePixelTemp[index_id].enty[i+1].cotbeta) {
2948 yratio = (cotb - thePixelTemp[index_id].enty[
i].cotbeta)/(thePixelTemp[index_id].enty[i+1].cotbeta - thePixelTemp[index_id].enty[i].cotbeta);
2959 pmpvvav = (1. - yratio)*thePixelTemp[index_id].enty[ilow].mpvvav + yratio*thePixelTemp[index_id].enty[ihigh].mpvvav;
2960 psigmavav = (1. - yratio)*thePixelTemp[index_id].enty[ilow].sigmavav + yratio*thePixelTemp[index_id].enty[ihigh].sigmavav;
2961 pkappavav = (1. - yratio)*thePixelTemp[index_id].enty[ilow].kappavav + yratio*thePixelTemp[index_id].enty[ihigh].kappavav;
2966 mpv = (double)pmpvvav;
2967 sigma = (double)psigmavav;
2968 kappa = (double)pkappavav;
float qavg_avg
average cluster charge of clusters that are less than qavg (normalize 2-D simple templates) ...
int runnum
< Basic template entry corresponding to a single set of track angles
float xflpar[4][6]
Aqfl-parameterized x-correction in 4 charge bins.
float xrms[4]
average x-rms of reconstruction binned in 4 charge bins
float clslenx
cluster x-length in pixels at signal height sxmax/2
int qbin(int id, float cotalpha, float cotbeta, float locBz, float qclus, float &pixmx, float &sigmay, float &deltay, float &sigmax, float &deltax, float &sy1, float &dy1, float &sy2, float &dy2, float &sx1, float &dx1, float &sx2, float &dx2, float &lorywidth, float &lorxwidth)
float xtemp[9][TXSIZE]
templates for x-reconstruction (binned over 1 central pixel)
float qavg
average cluster charge for this set of track angles (now includes threshold effects) ...
void ytemp3d(int nypix, array_3d &ytemplate)
float syone
rms for one pixel y-clusters
float chi2yavgone
average y chi^2 for 1 pixel clusters
float dyone
mean offset/correction for one pixel y-clusters
float sigmavav
"sigma" scale fctor for Vavilov distribution
float fracxtwo
fraction of double pixel sample with xsize = 1
float yavggen[4]
generic algorithm: average y-bias of reconstruction binned in 4 charge bins
float sxmax
average pixel signal for x-projection of cluster
int btype
type of boundary (0=end, 1 = x-boundary, 2 = y-boundary)
float xavgc2m[4]
1st pass chi2 min search: average x-bias of reconstruction binned in 4 charge bins ...
float chi2xavgone
average x chi^2 for 1 pixel clusters
float fracytwo
fraction of double pixel sample with ysize = 1
float yrms[4]
average y-rms of reconstruction binned in 4 charge bins
float ytemp[9][TYSIZE]
templates for y-reconstruction (binned over 1 central pixel)
float ygx0c2m[4]
1st pass chi2 min search: average y0 from Gaussian fit binned in 4 charge bins
float ygx0gen[4]
generic algorithm: average y0 from Gaussian fit binned in 4 charge bins
float xavg[4]
average x-bias of reconstruction binned in 4 charge bins
float y
y coordinate of boundary intersection
float dytwo
mean offset/correction for one double-pixel y-clusters
float dxone
mean offset/correction for one pixel x-clusters
float pixmax
maximum charge for individual pixels in cluster
float qmin
minimum cluster charge for valid hit (keeps 99.9% of simulated hits)
float xflcorr(int binq, float qflx)
float xgsiggen[4]
generic algorithm: average sigma_x from Gaussian fit binned in 4 charge bins
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 yrmsc2m[4]
1st pass chi2 min search: average y-rms of reconstruction binned in 4 charge bins ...
boost::multi_array< float, 2 > array_2d
float xpar[2][5]
projected x-pixel uncertainty parameterization
float ygx0[4]
average y0 from Gaussian fit binned in 4 charge bins
bool simpletemplate2D(float xhitp, float yhitp, std::vector< bool > &ydouble, std::vector< bool > &xdouble, float template2d[BXM2][BYM2])
Make simple 2-D templates from track angles set in interpolate and hit position.
float xgx0gen[4]
generic algorithm: average x0 from Gaussian fit binned in 4 charge bins
void xtemp3d(int nxpix, array_3d &xtemplate)
float symax
average pixel signal for y-projection of cluster
float xgsig[4]
average sigma_x from Gaussian fit binned in 4 charge bins
const T & max(const T &a, const T &b)
float cotbeta
cot(beta) is proportional to cluster length in y and is basis of interpolation
float beta
beta track angle (defined in CMS CMS IN 2004/014)
void vavilov_pars(double &mpv, double &sigma, double &kappa)
void xtemp(int fxbin, int lxbin, float xtemplate[41][BXSIZE])
float yflcorr(int binq, float qfly)
float s
distance from track entry
float xrmsc2m[4]
1st pass chi2 min search: average x-rms of reconstruction binned in 4 charge bins ...
void temperrors(int id, float cotalpha, float cotbeta, int qBin, float &sigmay, float &sigmax, float &sy1, float &sy2, float &sx1, float &sx2)
float xgx0[4]
average x0 from Gaussian fit binned in 4 charge bins
float ygsigc2m[4]
1st pass chi2 min search: average sigma_y from Gaussian fit binned in 4 charge bins ...
int j
y index of traversed pixel
void ytemp(int fybin, int lybin, float ytemplate[41][BYSIZE])
void incrementIndex(int i)
float ygsiggen[4]
generic algorithm: average sigma_y from Gaussian fit binned in 4 charge bins
float xgsigc2m[4]
1st pass chi2 min search: average sigma_x from Gaussian fit binned in 4 charge bins ...
float fracxone
fraction of sample with xsize = 1
float mpvvav
most probable charge in Vavilov distribution (not actually for larger kappa)
float sxtwo
rms for one double-pixel x-clusters
std::vector< float > sVector() const
float chi2yavg[4]
average y chi^2 in 4 charge bins
float alpha
alpha track angle (defined in CMS CMS IN 2004/014)
SiPixelTemplateHeader head
< template storage structure
float chi2xminone
minimum of x chi^2 for 1 pixel clusters
float ypar[2][5]
projected y-pixel uncertainty parameterization
float qavg_spare
spare cluster charge
bool pushfile(int filenum)
void qbin_dist(int id, float cotalpha, float cotbeta, float qbin_frac[4], float &ny1_frac, float &ny2_frac, float &nx1_frac, float &nx2_frac)
float qbfrac[3]
fraction of sample in qbin = 0-2 (>=3 is the complement)
float fracyone
fraction of sample with ysize = 1
float qmin2
tighter minimum cluster charge for valid hit (keeps 99.8% of simulated hits)
float xgx0c2m[4]
1st pass chi2 min search: average x0 from Gaussian fit binned in 4 charge bins
float yavg[4]
average y-bias of reconstruction binned in 4 charge bins
float chi2ymin[4]
minimum of y chi^2 in 4 charge bins
float yavgc2m[4]
1st pass chi2 min search: average y-bias of reconstruction binned in 4 charge bins ...
float x
x coordinate of boundary intersection
void xsigma2(int fxpix, int lxpix, float sxthr, float xsum[BXSIZE], float xsig2[BXSIZE])
float dxtwo
mean offset/correction for one double-pixel x-clusters
int i
x index of traversed pixel
void ysigma2(int fypix, int lypix, float sythr, float ysum[BYSIZE], float ysig2[BYSIZE])
float yflpar[4][6]
Aqfl-parameterized y-correction in 4 charge bins.
float sxone
rms for one pixel x-clusters
float chi2xmin[4]
minimum of x chi^2 in 4 charge bins
float chi2yminone
minimum of y chi^2 for 1 pixel clusters
float costrk[3]
direction cosines of tracks used to generate this entry
SiPixelTemplateEntry entx[5][29]
29 Barrel x templates spanning cluster lengths from -6px (-1.125Rad) to +6px (+1.125Rad) in each of 5...
float ygsig[4]
average sigma_y from Gaussian fit binned in 4 charge bins
SiPixelTemplateEntry enty[60]
60 Barrel y templates spanning cluster lengths from 0px to +18px [28 entries for fpix] ...
float sytwo
rms for one double-pixel y-clusters
float xrmsgen[4]
generic algorithm: average x-rms of reconstruction binned in 4 charge bins
float chi2xavg[4]
average x chi^2 in 4 charge bins
boost::multi_array< float, 3 > array_3d
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
float kappavav
kappa parameter for Vavilov distribution
float xavggen[4]
generic algorithm: average x-bias of reconstruction binned in 4 charge bins
float yrmsgen[4]
generic algorithm: average y-rms of reconstruction binned in 4 charge bins
float clsleny
cluster y-length in pixels at signal height symax/2