11 TrackletLUT::TrackletLUT(
const Settings& settings) : settings_(settings) {}
14 char cregion =
'A' +
region;
16 for (
unsigned int iSeed = 0; iSeed < 12; iSeed++) {
65 unsigned int layerdisk1,
66 unsigned int layerdisk2,
67 unsigned int nbitsfinephidiff,
79 int outerrbins = (1 << outerrbits);
84 unsigned int nbendbitsinner = 3;
85 unsigned int nbendbitsouter = 3;
93 int nbinsfinephidiff = (1 << nbitsfinephidiff);
95 for (
int iphibin = 0; iphibin < nbinsfinephidiff; iphibin++) {
96 int iphidiff = iphibin;
97 if (iphibin >= nbinsfinephidiff / 2) {
98 iphidiff = iphibin - nbinsfinephidiff;
101 dphi[0] = (iphidiff - 1.5) * dfinephi;
102 dphi[1] = (iphidiff + 1.5) * dfinephi;
103 for (
int irouterbin = 0; irouterbin < outerrbins; irouterbin++) {
114 double bendinnermin = 20.0;
115 double bendinnermax = -20.0;
116 double bendoutermin = 20.0;
117 double bendoutermax = -20.0;
118 double rinvmin = 1.0;
119 for (
int i2 = 0;
i2 < 2;
i2++) {
120 for (
int i3 = 0;
i3 < 2;
i3++) {
127 double rinv1 =
rinv(0.0, -dphi[
i2], rinner, router[
i3]);
131 double abendinner =
bendstrip(rinner, rinv1, pitchinner);
132 double abendouter =
bendstrip(router[
i3], rinv1, pitchouter);
133 if (abendinner < bendinnermin)
134 bendinnermin = abendinner;
135 if (abendinner > bendinnermax)
136 bendinnermax = abendinner;
137 if (abendouter < bendoutermin)
138 bendoutermin = abendouter;
139 if (abendouter > bendoutermax)
140 bendoutermax = abendouter;
150 for (
int ibend = 0; ibend < (1 << nbendbitsinner); ibend++) {
153 bool passinner = bend <= bendinnermax +
settings_.
bendcutte(ibend, layerdisk1, nbendbitsinner == 3) &&
155 table_.push_back(passinner && passptcut);
158 for (
int ibend = 0; ibend < (1 << nbendbitsouter); ibend++) {
161 bool passouter = bend <= bendoutermax +
settings_.
bendcutte(ibend, layerdisk2, nbendbitsouter == 3) &&
163 table_.push_back(passouter && passptcut);
170 char cTP =
'A' + iTP;
175 name_ +=
"_stubptinnercut.tab";
177 name_ +=
"_stubptoutercut.tab";
184 unsigned int layerdisk1,
185 unsigned int layerdisk2,
186 unsigned int iAllStub,
187 unsigned int nbitsfinephidiff,
188 unsigned int nbitsfinephi,
196 unsigned int nbendbitsinner = 3;
202 for (
int innerfinephi = 0; innerfinephi < (1 << nbitsfinephi); innerfinephi++) {
203 for (
int innerbend = 0; innerbend < (1 << nbendbitsinner); innerbend++) {
204 for (
int ir = 0; ir < (1 << nirbits); ir++) {
205 unsigned int usereg = 0;
206 for (
unsigned int ireg = 0; ireg <
settings_.
nvmte(1, iSeed); ireg++) {
208 for (
int ifinephiouter = 0; ifinephiouter < (1 <<
settings_.
nfinephi(1, iSeed)); ifinephiouter++) {
211 int idphi = outerfinephi - innerfinephi;
212 bool inrange = (idphi < (1 << (nbitsfinephidiff - 1))) && (idphi >= -(1 << (nbitsfinephidiff - 1)));
214 idphi = idphi + (1 << nbitsfinephidiff);
217 idphi1 = (idphi << 3) + ir;
218 int ptinnerindexnew = (idphi1 << nbendbitsinner) + innerbend;
222 usereg = usereg | (1 << ireg);
232 char cTP =
'A' + iTP;
243 unsigned int layerdisk1,
244 unsigned int layerdisk2,
245 unsigned int innerphibits,
246 unsigned int outerphibits,
258 int outerrbins = (1 << outerrbits);
259 int innerphibins = (1 << innerphibits);
260 int outerphibins = (1 << outerphibits);
266 unsigned int nbendbitsinner = 3;
267 unsigned int nbendbitsouter = 3;
278 table_.resize((1 << nbendbitsinner),
false);
280 table_.resize((1 << nbendbitsouter),
false);
284 for (
int iphiinnerbin = 0; iphiinnerbin < innerphibins; iphiinnerbin++) {
285 phiinner[0] = innerphimin + iphiinnerbin * (innerphimax - innerphimin) / innerphibins;
286 phiinner[1] = innerphimin + (iphiinnerbin + 1) * (innerphimax - innerphimin) / innerphibins;
287 for (
int iphiouterbin = 0; iphiouterbin < outerphibins; iphiouterbin++) {
288 phiouter[0] = outerphimin + iphiouterbin * (outerphimax - outerphimin) / outerphibins;
289 phiouter[1] = outerphimin + (iphiouterbin + 1) * (outerphimax - outerphimin) / outerphibins;
290 for (
int irouterbin = 0; irouterbin < outerrbins; irouterbin++) {
301 double bendinnermin = 20.0;
302 double bendinnermax = -20.0;
303 double bendoutermin = 20.0;
304 double bendoutermax = -20.0;
305 double rinvmin = 1.0;
306 for (
int i1 = 0;
i1 < 2;
i1++) {
307 for (
int i2 = 0;
i2 < 2;
i2++) {
308 for (
int i3 = 0;
i3 < 2;
i3++) {
315 double rinv1 = -
rinv(phiinner[
i1], phiouter[
i2], rinner, router[
i3]);
320 double abendinner =
bendstrip(rinner, rinv1, pitchinner);
321 double abendouter =
bendstrip(router[
i3], rinv1, pitchouter);
322 if (abendinner < bendinnermin)
323 bendinnermin = abendinner;
324 if (abendinner > bendinnermax)
325 bendinnermax = abendinner;
326 if (abendouter < bendoutermin)
327 bendoutermin = abendouter;
328 if (abendouter > bendoutermax)
329 bendoutermax = abendouter;
340 for (
int ibend = 0; ibend < (1 << nbendbitsinner); ibend++) {
343 bool passinner = bend > bendinnermin -
settings_.
bendcutte(ibend, layerdisk1, nbendbitsinner == 3) &&
351 table_.push_back(passinner && passptcut);
355 for (
int ibend = 0; ibend < (1 << nbendbitsouter); ibend++) {
358 bool passouter = bend > bendoutermin -
settings_.
bendcutte(ibend, layerdisk2, nbendbitsouter == 3) &&
365 table_.push_back(passouter && passptcut);
377 name_ =
"VMSTE_" + innermem +
"_vmbendcut.tab";
379 name_ =
"VMSTE_" + outermem +
"_vmbendcut.tab";
382 name_ =
"TE_" + innermem.substr(0, innermem.size() - 2) +
"_" + outermem.substr(0, outermem.size() - 2);
384 name_ +=
"_stubptinnercut.tab";
386 name_ +=
"_stubptoutercut.tab";
396 unsigned int nphiderbits) {
397 unsigned int nsignbins = 2;
398 unsigned int nrbins = 1 << (nrbits);
399 unsigned int nphiderbins = 1 << (nphiderbits);
401 for (
unsigned int isignbin = 0; isignbin < nsignbins; isignbin++) {
402 for (
unsigned int irbin = 0; irbin < nrbins; irbin++) {
404 if (ir > (1 << (nrbits - 1)))
407 for (
unsigned int iphiderbin = 0; iphiderbin < nphiderbins; iphiderbin++) {
408 int iphider = iphiderbin;
409 if (iphider > (1 << (nphiderbits - 1)))
410 iphider -= (1 << nphiderbits);
414 double phider = iphider * k_phider;
420 double rinv = -phider * (2.0 *
t);
425 int ibendproj = 2.0 * bendproj + 15.5;
431 table_.push_back(ibendproj);
445 double rinvhalf = 0.5 * ((1 << nrinv) - 1);
454 for (
unsigned int irinv = 0; irinv < (1u << nrinv); irinv++) {
458 for (
unsigned int ibend = 0; ibend < (1u << nbits); ibend++) {
465 for (
unsigned int iprojbend = 0; iprojbend < (1u << nrinv); iprojbend++) {
466 double projbend = 0.5 * (iprojbend - rinvhalf);
467 for (
unsigned int ibend = 0; ibend < (1 <<
N_BENDBITS_2S); ibend++) {
473 for (
unsigned int iprojbend = 0; iprojbend < (1u << nrinv); iprojbend++) {
474 double projbend = 0.5 * (iprojbend - rinvhalf);
475 for (
unsigned int ibend = 0; ibend < (1 <<
N_BENDBITS_PS); ibend++) {
494 unsigned int rbins = (1 << rbits);
495 unsigned int zbins = (1 << zbits);
511 double dr = (rmax - rmin) / rbins;
516 for (
unsigned int izbin = 0; izbin <
zbins; izbin++) {
517 for (
unsigned int irbin = 0; irbin < rbins; irbin++) {
518 double r = rmin + (irbin + 0.5) *
dr;
519 double z =
zmin + (izbin + 0.5) *
dz;
522 int iznew = izbin - (1 << (zbits - 1));
524 iznew += (1 << zbits);
526 assert(iznew < (1 << zbits));
527 z =
zmin + (iznew + 0.5) *
dz;
529 int irnew = irbin - (1 << (rbits - 1));
531 irnew += (1 << rbits);
533 assert(irnew < (1 << rbits));
534 r = rmin + (irnew + 0.5) *
dr;
538 if (layerdisk >=
N_LAYER && irbin < 10)
558 if (
type == VMRTableType::disk) {
581 if (
type == VMRTableType::inneroverlap) {
587 if (
type == VMRTableType::innerthird) {
612 if (
type == VMRTableType::disk) {
623 if (
type == VMRTableType::inneroverlap) {
632 if (layerdisk == 1 || layerdisk == 2 || layerdisk == 3 || layerdisk == 4) {
639 char cregion =
'A' +
region;
650 if (
type == VMRTableType::inneroverlap) {
656 if (
type == VMRTableType::disk) {
674 double rratio1 = rmean / (
r + 0.5 *
dr);
675 double rratio2 = rmean / (
r - 0.5 *
dr);
677 double z1 = (z - 0.5 *
dz) * rratio1 + z0cut * (rratio1 - 1.0);
678 double z2 = (z + 0.5 *
dz) * rratio1 + z0cut * (rratio1 - 1.0);
679 double z3 = (z - 0.5 *
dz) * rratio2 + z0cut * (rratio2 - 1.0);
680 double z4 = (z + 0.5 *
dz) * rratio2 + z0cut * (rratio2 - 1.0);
681 double z5 = (z - 0.5 *
dz) * rratio1 - z0cut * (rratio1 - 1.0);
682 double z6 = (z + 0.5 *
dz) * rratio1 - z0cut * (rratio1 - 1.0);
683 double z7 = (z - 0.5 *
dz) * rratio2 - z0cut * (rratio2 - 1.0);
684 double z8 = (z + 0.5 *
dz) * rratio2 - z0cut * (rratio2 - 1.0);
714 int value = zbin1 / 8;
716 if (zbin2 / 8 - zbin1 / 8 > 0)
719 value += (zbin1 & 7);
721 int deltaz = zbin2 - zbin1;
726 value += (deltaz << 7);
738 double r1 = (
r + 0.5 *
dr) * (zmean + z0cut) / (z + 0.5 *
dz + z0cut);
739 double r2 = (
r - 0.5 *
dr) * (zmean - z0cut) / (z + 0.5 *
dz - z0cut);
740 double r3 = (
r + 0.5 *
dr) * (zmean + z0cut) / (z - 0.5 *
dz + z0cut);
741 double r4 = (
r - 0.5 *
dr) * (zmean - z0cut) / (z - 0.5 *
dz - z0cut);
742 double r5 = (
r + 0.5 *
dr) * (zmean - z0cut) / (z + 0.5 *
dz - z0cut);
743 double r6 = (
r - 0.5 *
dr) * (zmean + z0cut) / (z + 0.5 *
dz + z0cut);
744 double r7 = (
r + 0.5 *
dr) * (zmean - z0cut) / (z - 0.5 *
dz - z0cut);
745 double r8 = (
r - 0.5 *
dr) * (zmean + z0cut) / (z - 0.5 *
dz + z0cut);
747 double rmin =
std::min({
r1,
r2, r3, r4, r5, r6, r7, r8});
748 double rmax =
std::max({
r1,
r2, r3, r4, r5, r6, r7, r8});
776 constexpr
double rminspec = 40.0;
798 int value = rbin1 / 8;
804 if (rbin2 / 8 - rbin1 / 8 > 0)
807 value += (rbin1 & 7);
809 int deltar = rbin2 - rbin1;
827 unsigned int rbins = (1 << rbits);
832 double dr = 2.0 * drmax / rbins;
834 unsigned int bendbins = (1 << bendbits);
836 for (
unsigned int ibend = 0; ibend < bendbins; ibend++) {
837 for (
unsigned int irbin = 0; irbin < rbins; irbin++) {
843 name_ =
"VMPhiCorrL" + std::to_string(layerdisk + 1) +
".tab";
851 unsigned int layerdisk,
unsigned int ibend,
unsigned int irbin,
double rmean,
double dr,
double drmax)
const {
857 double Delta = (irbin + 0.5) *
dr - drmax;
864 int idphi = dphi / kphi;
882 for (
unsigned int i = 0;
i <
table_.size();
i++) {
890 itable = (1 <<
nbits_) - 1;
896 out << endl <<
"};" << endl;