16 TrackletCalculatorDisplaced::TrackletCalculatorDisplaced(
string name,
Settings const& settings,
Globals* global)
18 for (
unsigned int ilayer = 0; ilayer <
N_LAYER; ilayer++) {
19 vector<TrackletProjectionsMemory*>
tmp(settings.
nallstubs(ilayer),
nullptr);
23 for (
unsigned int idisk = 0; idisk <
N_DISK; idisk++) {
31 string name1 =
name.substr(1);
35 disk_ = name1[4] -
'0';
40 int iTC = name1[9] -
'A';
42 if (name1.substr(3, 6) ==
"L3L4L2")
44 else if (name1.substr(3, 6) ==
"L5L6L4")
46 else if (name1.substr(3, 6) ==
"L2L3D1")
48 else if (name1.substr(3, 6) ==
"D1D2L2")
136 for (
unsigned int i = 0;
i <
N_DISK - 2; ++
i)
143 assert(outputProj !=
nullptr);
152 if (
output ==
"trackpar") {
159 if (
output.substr(0, 7) ==
"projout") {
164 unsigned int layerdisk =
output[8] -
'1';
165 unsigned int phiregion =
output[12] -
'A';
186 throw cms::Exception(
"BadConfig") << __FILE__ <<
" " << __LINE__ <<
" Could not find output : " <<
output;
195 if (
input ==
"thirdallstubin") {
201 if (
input ==
"firstallstubin") {
207 if (
input ==
"secondallstubin") {
213 if (
input.find(
"stubtriplet") == 0) {
219 throw cms::Exception(
"BadConfig") << __FILE__ <<
" " << __LINE__ <<
" Could not find input : " <<
input;
223 unsigned int countall = 0;
224 unsigned int countsel = 0;
235 for (
unsigned int i = 0;
i < stubtriplet->nStubTriplets();
i++) {
238 const Stub* innerFPGAStub = stubtriplet->getFPGAStub1(
i);
241 const Stub* middleFPGAStub = stubtriplet->getFPGAStub2(
i);
244 const Stub* outerFPGAStub = stubtriplet->getFPGAStub3(
i);
253 bool accept =
LLLSeeding(innerFPGAStub, innerStub, middleFPGAStub, middleStub, outerFPGAStub, outerStub);
258 throw cms::Exception(
"LogicError") << __FILE__ <<
" " << __LINE__ <<
" Invalid seeding!";
263 bool accept =
DDLSeeding(innerFPGAStub, innerStub, middleFPGAStub, middleStub, outerFPGAStub, outerStub);
268 bool accept =
LLDSeeding(innerFPGAStub, innerStub, middleFPGAStub, middleStub, outerFPGAStub, outerStub);
272 throw cms::Exception(
"LogicError") << __FILE__ <<
" " << __LINE__ <<
" Invalid seeding!";
297 globals_->
ofstream(
"trackletcalculatordisplaced.txt") <<
getName() <<
" " << countall <<
" " << countsel << endl;
312 int iphivmRaw = fpgaphi.
value() >> (fpgaphi.
nbits() - 5);
330 int iphivmRaw = fpgaphi.
value() >> (fpgaphi.
nbits() - 5);
342 if (trackletprojs ==
nullptr) {
345 <<
" iphi = " <<
iphi + 1;
349 assert(trackletprojs !=
nullptr);
350 trackletprojs->
addProj(tracklet);
357 if (trackletprojs ==
nullptr) {
362 <<
" iphi = " <<
iphi + 1;
366 assert(trackletprojs !=
nullptr);
369 trackletprojs->
addProj(tracklet);
374 const Stub* middleFPGAStub,
376 const Stub* outerFPGAStub,
380 <<
" trying stub triplet in layer (L L L): " << innerFPGAStub->
layer().
value() <<
" " 385 double r1 = innerStub->
r();
386 double z1 = innerStub->
z();
387 double phi1 = innerStub->
phi();
389 double r2 = middleStub->
r();
390 double z2 = middleStub->
z();
391 double phi2 = middleStub->
phi();
393 double r3 = outerStub->
r();
394 double z3 = outerStub->
z();
395 double phi3 = outerStub->
phi();
434 << middleFPGAStub->
isBarrel() << outerFPGAStub->
isBarrel() <<
" " << phi1 <<
", " << z1
435 <<
", " << r1 <<
", " << phi2 <<
", " <<
z2 <<
", " <<
r2 <<
", " << phi3 <<
", " << z3
436 <<
", " << r3 << endl;
454 << middleFPGAStub->
isBarrel() << outerFPGAStub->
isBarrel() <<
" " << phi1 <<
", " << z1
455 <<
", " << r1 <<
", " << phi2 <<
", " <<
z2 <<
", " <<
r2 <<
", " << phi3 <<
", " << z3
456 <<
", " << r3 << endl;
458 double rinvapprox, phi0approx, d0approx, tapprox, z0approx;
460 double phiprojdiskapprox[
N_DISK], rprojdiskapprox[
N_DISK];
461 double phiderdiskapprox[
N_DISK], rderdiskapprox[
N_DISK];
496 for (
unsigned int i = 0;
i <
toR_.size(); ++
i) {
497 phiprojapprox[
i] = phiproj[
i];
498 zprojapprox[
i] = zproj[
i];
499 phiderapprox[
i] = phider[
i];
500 zderapprox[
i] = zder[
i];
503 for (
unsigned int i = 0;
i <
toZ_.size(); ++
i) {
504 phiprojdiskapprox[
i] = phiprojdisk[
i];
505 rprojdiskapprox[
i] = rprojdisk[
i];
506 phiderdiskapprox[
i] = phiderdisk[
i];
507 rderdiskapprox[
i] = rderdisk[
i];
515 edm::LogVerbatim(
"Tracklet") <<
"phi0approx: " << phi0approx <<
" phi0: " << phi0 << endl;
518 edm::LogVerbatim(
"Tracklet") <<
"z0approx: " << z0approx <<
" z0: " << z0 << endl;
521 for (
unsigned int i = 0;
i <
toR_.size(); ++
i) {
523 edm::LogVerbatim(
"Tracklet") <<
"phiprojapprox[" <<
i <<
"]: " << phiprojapprox[
i] <<
" phiproj[" <<
i 524 <<
"]: " << phiproj[
i] << endl;
525 edm::LogVerbatim(
"Tracklet") <<
"zprojapprox[" <<
i <<
"]: " << zprojapprox[
i] <<
" zproj[" <<
i 526 <<
"]: " << zproj[
i] << endl;
527 edm::LogVerbatim(
"Tracklet") <<
"phiderapprox[" <<
i <<
"]: " << phiderapprox[
i] <<
" phider[" <<
i 528 <<
"]: " << phider[
i] << endl;
529 edm::LogVerbatim(
"Tracklet") <<
"zderapprox[" <<
i <<
"]: " << zderapprox[
i] <<
" zder[" <<
i <<
"]: " << zder[
i]
534 for (
unsigned int i = 0;
i <
toZ_.size(); ++
i) {
536 edm::LogVerbatim(
"Tracklet") <<
"phiprojdiskapprox[" <<
i <<
"]: " << phiprojdiskapprox[
i] <<
" phiprojdisk[" <<
i 537 <<
"]: " << phiprojdisk[
i] << endl;
538 edm::LogVerbatim(
"Tracklet") <<
"rprojdiskapprox[" <<
i <<
"]: " << rprojdiskapprox[
i] <<
" rprojdisk[" <<
i 539 <<
"]: " << rprojdisk[
i] << endl;
540 edm::LogVerbatim(
"Tracklet") <<
"phiderdiskapprox[" <<
i <<
"]: " << phiderdiskapprox[
i] <<
" phiderdisk[" <<
i 541 <<
"]: " << phiderdisk[
i] << endl;
542 edm::LogVerbatim(
"Tracklet") <<
"rderdiskapprox[" <<
i <<
"]: " << rderdiskapprox[
i] <<
" rderdisk[" <<
i 543 <<
"]: " << rderdisk[
i] << endl;
561 int irinv, iphi0, id0, it, iz0;
566 irinv = rinvapprox / krinv;
567 iphi0 = phi0approx / kphi0;
570 iz0 = z0approx / kz0;
575 edm::LogVerbatim(
"Tracklet") <<
"TrackletCalculator::LLL Seeding irinv too large: " << rinvapprox <<
"(" << irinv
586 edm::LogVerbatim(
"Tracklet") <<
"Failed tracklet approx d0 cut " << d0approx;
600 int phicrit = iphi0 - 2 * irinv - 2 * id0;
606 keep = (phicrit > iphicritmincut) && (phicrit < iphicritmaxcut);
609 if (
keep && !keepapprox)
610 edm::LogVerbatim(
"Tracklet") <<
"TrackletCalculatorDisplaced::LLLSeeding tracklet kept with exact phicrit cut " 611 "but not approximate, phicritapprox: " 623 for (
unsigned int i = 0;
i <
toR_.size(); ++
i) {
624 iphiproj[
i] = phiprojapprox[
i] / kphiproj;
625 izproj[
i] = zprojapprox[
i] / kzproj;
627 iphider[
i] = phiderapprox[
i] / kphider;
628 izder[
i] = zderapprox[
i] / kzder;
639 if (iphiproj[
i] <= 0)
685 for (
unsigned int i = 0;
i <
toZ_.size(); ++
i) {
686 iphiprojdisk[
i] = phiprojdiskapprox[
i] / kphiprojdisk;
687 irprojdisk[
i] = rprojdiskapprox[
i] / krprojdisk;
689 iphiderdisk[
i] = phiderdiskapprox[
i] / kphiderdisk;
690 irderdisk[
i] = rderdiskapprox[
i] / krderdisk;
693 if (iphiprojdisk[
i] <= 0)
712 phiprojdiskapprox[
i],
722 <<
layer_ <<
" , " <<
rinv <<
" , " << rinvapprox <<
" , " << phi0 <<
" , " << phi0approx <<
" , " <<
t <<
" , " 723 << tapprox <<
" , " << z0 <<
" , " << z0approx <<
" , " <<
d0 <<
" , " << d0approx << endl;
751 <<
" Found LLL tracklet in sector = " <<
iSector_ <<
" phi0 = " << phi0;
757 ofstream
fout(
"seeds.txt", ofstream::app);
765 for (
unsigned int j = 0;
j <
toR_.size();
j++) {
779 for (
unsigned int j = 0;
j <
toZ_.size();
j++) {
783 if (disk == 2 && addL5)
785 if (disk == 1 && addL6)
801 const Stub* middleFPGAStub,
803 const Stub* outerFPGAStub,
807 <<
" trying stub triplet in (L2 D1 D2): " << innerFPGAStub->
layer().
value() <<
" " 813 double r1 = innerStub->
r();
814 double z1 = innerStub->
z();
815 double phi1 = innerStub->
phi();
817 double r2 = middleStub->
r();
818 double z2 = middleStub->
z();
819 double phi2 = middleStub->
phi();
821 double r3 = outerStub->
r();
822 double z3 = outerStub->
z();
823 double phi3 = outerStub->
phi();
856 << middleFPGAStub->
isBarrel() << outerFPGAStub->
isBarrel() <<
" " << phi1 <<
", " << z1
857 <<
", " << r1 <<
", " << phi2 <<
", " <<
z2 <<
", " <<
r2 <<
", " << phi3 <<
", " << z3
858 <<
", " << r3 << endl;
876 << middleFPGAStub->
isBarrel() << outerFPGAStub->
isBarrel() <<
" " << phi1 <<
", " << z1
877 <<
", " << r1 <<
", " << phi2 <<
", " <<
z2 <<
", " <<
r2 <<
", " << phi3 <<
", " << z3
878 <<
", " << r3 << endl;
880 double rinvapprox, phi0approx, d0approx, tapprox, z0approx;
882 double phiprojdiskapprox[
N_DISK], rprojdiskapprox[
N_DISK];
883 double phiderdiskapprox[
N_DISK], rderdiskapprox[
N_DISK];
918 for (
unsigned int i = 0;
i <
toR_.size(); ++
i) {
919 phiprojapprox[
i] = phiproj[
i];
920 zprojapprox[
i] = zproj[
i];
921 phiderapprox[
i] = phider[
i];
922 zderapprox[
i] = zder[
i];
925 for (
unsigned int i = 0;
i <
toZ_.size(); ++
i) {
926 phiprojdiskapprox[
i] = phiprojdisk[
i];
927 rprojdiskapprox[
i] = rprojdisk[
i];
928 phiderdiskapprox[
i] = phiderdisk[
i];
929 rderdiskapprox[
i] = rderdisk[
i];
936 edm::LogVerbatim(
"Tracklet") <<
"phi0approx: " << phi0approx <<
" phi0: " << phi0 << endl;
939 edm::LogVerbatim(
"Tracklet") <<
"z0approx: " << z0approx <<
" z0: " << z0 << endl;
942 for (
unsigned int i = 0;
i <
toR_.size(); ++
i) {
944 edm::LogVerbatim(
"Tracklet") <<
"phiprojapprox[" <<
i <<
"]: " << phiprojapprox[
i] <<
" phiproj[" <<
i 945 <<
"]: " << phiproj[
i] << endl;
946 edm::LogVerbatim(
"Tracklet") <<
"zprojapprox[" <<
i <<
"]: " << zprojapprox[
i] <<
" zproj[" <<
i 947 <<
"]: " << zproj[
i] << endl;
948 edm::LogVerbatim(
"Tracklet") <<
"phiderapprox[" <<
i <<
"]: " << phiderapprox[
i] <<
" phider[" <<
i 949 <<
"]: " << phider[
i] << endl;
950 edm::LogVerbatim(
"Tracklet") <<
"zderapprox[" <<
i <<
"]: " << zderapprox[
i] <<
" zder[" <<
i <<
"]: " << zder[
i]
955 for (
unsigned int i = 0;
i <
toZ_.size(); ++
i) {
957 edm::LogVerbatim(
"Tracklet") <<
"phiprojdiskapprox[" <<
i <<
"]: " << phiprojdiskapprox[
i] <<
" phiprojdisk[" <<
i 958 <<
"]: " << phiprojdisk[
i] << endl;
959 edm::LogVerbatim(
"Tracklet") <<
"rprojdiskapprox[" <<
i <<
"]: " << rprojdiskapprox[
i] <<
" rprojdisk[" <<
i 960 <<
"]: " << rprojdisk[
i] << endl;
961 edm::LogVerbatim(
"Tracklet") <<
"phiderdiskapprox[" <<
i <<
"]: " << phiderdiskapprox[
i] <<
" phiderdisk[" <<
i 962 <<
"]: " << phiderdisk[
i] << endl;
963 edm::LogVerbatim(
"Tracklet") <<
"rderdiskapprox[" <<
i <<
"]: " << rderdiskapprox[
i] <<
" rderdisk[" <<
i 964 <<
"]: " << rderdisk[
i] << endl;
982 int irinv, iphi0, id0, it, iz0;
987 irinv = rinvapprox / krinv;
988 iphi0 = phi0approx / kphi0;
991 iz0 = z0approx / kz0;
996 edm::LogVerbatim(
"Tracklet") <<
"TrackletCalculator::DDL Seeding irinv too large: " << rinvapprox <<
"(" << irinv
1007 edm::LogVerbatim(
"Tracklet") <<
"Failed tracklet approx d0 cut " << d0approx;
1020 int phicrit = iphi0 - 2 * irinv - 2 * id0;
1026 keep = (phicrit > iphicritmincut) && (phicrit < iphicritmaxcut);
1029 if (
keep && !keepapprox)
1030 edm::LogVerbatim(
"Tracklet") <<
"TrackletCalculatorDisplaced::DDLSeeding tracklet kept with exact phicrit cut " 1031 "but not approximate, phicritapprox: " 1043 for (
unsigned int i = 0;
i <
toR_.size(); ++
i) {
1044 iphiproj[
i] = phiprojapprox[
i] / kphiproj;
1045 izproj[
i] = zprojapprox[
i] / kzproj;
1047 iphider[
i] = phiderapprox[
i] / kphider;
1048 izder[
i] = zderapprox[
i] / kzder;
1059 if (iphiproj[
i] <= 0)
1098 for (
unsigned int i = 0;
i <
toZ_.size(); ++
i) {
1099 iphiprojdisk[
i] = phiprojdiskapprox[
i] / kphiprojdisk;
1100 irprojdisk[
i] = rprojdiskapprox[
i] / krprojdisk;
1102 iphiderdisk[
i] = phiderdiskapprox[
i] / kphiderdisk;
1103 irderdisk[
i] = rderdiskapprox[
i] / krderdisk;
1105 if (iphiprojdisk[
i] <= 0)
1123 phiprojdiskapprox[
i],
1133 <<
layer_ <<
" , " <<
rinv <<
" , " << rinvapprox <<
" , " << phi0 <<
" , " << phi0approx <<
" , " <<
t <<
" , " 1134 << tapprox <<
" , " << z0 <<
" , " << z0approx <<
" , " <<
d0 <<
" , " << d0approx << endl;
1162 <<
" Found DDL tracklet in sector = " <<
iSector_ <<
" phi0 = " << phi0;
1168 ofstream
fout(
"seeds.txt", ofstream::app);
1174 for (
unsigned int j = 0;
j <
toR_.size();
j++) {
1183 for (
unsigned int j = 0;
j <
toZ_.size();
j++) {
1190 edm::LogVerbatim(
"Tracklet") <<
"adding disk projection " <<
j <<
"/" <<
toZ_.size() <<
" " << disk <<
" " 1202 const Stub* middleFPGAStub,
1204 const Stub* outerFPGAStub,
1208 <<
" trying stub triplet in (L2L3D1): " << middleFPGAStub->
layer().
value() <<
" " 1212 unsigned ndisks = 1;
1214 double r3 = innerStub->
r();
1215 double z3 = innerStub->
z();
1216 double phi3 = innerStub->
phi();
1218 double r1 = middleStub->
r();
1219 double z1 = middleStub->
z();
1220 double phi1 = middleStub->
phi();
1222 double r2 = outerStub->
r();
1223 double z2 = outerStub->
z();
1224 double phi2 = outerStub->
phi();
1257 << middleFPGAStub->
isBarrel() << outerFPGAStub->
isBarrel() <<
" " << phi3 <<
", " << z3
1258 <<
", " << r3 <<
", " << phi1 <<
", " << z1 <<
", " << r1 <<
", " << phi2 <<
", " <<
z2 1259 <<
", " <<
r2 << endl;
1263 z3 = innerFPGAStub->
zapprox();
1264 r3 = innerFPGAStub->
rapprox();
1267 z1 = middleFPGAStub->
zapprox();
1268 r1 = middleFPGAStub->
rapprox();
1277 << middleFPGAStub->
isBarrel() << outerFPGAStub->
isBarrel() <<
" " << phi3 <<
", " << z3
1278 <<
", " << r3 <<
", " << phi1 <<
", " << z1 <<
", " << r1 <<
", " << phi2 <<
", " <<
z2 1279 <<
", " <<
r2 << endl;
1281 double rinvapprox, phi0approx, d0approx, tapprox, z0approx;
1283 double phiprojdiskapprox[
N_DISK], rprojdiskapprox[
N_DISK];
1284 double phiderdiskapprox[
N_DISK], rderdiskapprox[
N_DISK];
1319 for (
unsigned int i = 0;
i <
toR_.size(); ++
i) {
1320 phiprojapprox[
i] = phiproj[
i];
1321 zprojapprox[
i] = zproj[
i];
1322 phiderapprox[
i] = phider[
i];
1323 zderapprox[
i] = zder[
i];
1326 for (
unsigned int i = 0;
i <
toZ_.size(); ++
i) {
1327 phiprojdiskapprox[
i] = phiprojdisk[
i];
1328 rprojdiskapprox[
i] = rprojdisk[
i];
1329 phiderdiskapprox[
i] = phiderdisk[
i];
1330 rderdiskapprox[
i] = rderdisk[
i];
1337 edm::LogVerbatim(
"Tracklet") <<
"phi0approx: " << phi0approx <<
" phi0: " << phi0 << endl;
1340 edm::LogVerbatim(
"Tracklet") <<
"z0approx: " << z0approx <<
" z0: " << z0 << endl;
1343 for (
unsigned int i = 0;
i <
toR_.size(); ++
i) {
1345 edm::LogVerbatim(
"Tracklet") <<
"phiprojapprox[" <<
i <<
"]: " << phiprojapprox[
i] <<
" phiproj[" <<
i 1346 <<
"]: " << phiproj[
i] << endl;
1347 edm::LogVerbatim(
"Tracklet") <<
"zprojapprox[" <<
i <<
"]: " << zprojapprox[
i] <<
" zproj[" <<
i 1348 <<
"]: " << zproj[
i] << endl;
1349 edm::LogVerbatim(
"Tracklet") <<
"phiderapprox[" <<
i <<
"]: " << phiderapprox[
i] <<
" phider[" <<
i 1350 <<
"]: " << phider[
i] << endl;
1351 edm::LogVerbatim(
"Tracklet") <<
"zderapprox[" <<
i <<
"]: " << zderapprox[
i] <<
" zder[" <<
i <<
"]: " << zder[
i]
1356 for (
unsigned int i = 0;
i <
toZ_.size(); ++
i) {
1358 edm::LogVerbatim(
"Tracklet") <<
"phiprojdiskapprox[" <<
i <<
"]: " << phiprojdiskapprox[
i] <<
" phiprojdisk[" <<
i 1359 <<
"]: " << phiprojdisk[
i] << endl;
1360 edm::LogVerbatim(
"Tracklet") <<
"rprojdiskapprox[" <<
i <<
"]: " << rprojdiskapprox[
i] <<
" rprojdisk[" <<
i 1361 <<
"]: " << rprojdisk[
i] << endl;
1362 edm::LogVerbatim(
"Tracklet") <<
"phiderdiskapprox[" <<
i <<
"]: " << phiderdiskapprox[
i] <<
" phiderdisk[" <<
i 1363 <<
"]: " << phiderdisk[
i] << endl;
1364 edm::LogVerbatim(
"Tracklet") <<
"rderdiskapprox[" <<
i <<
"]: " << rderdiskapprox[
i] <<
" rderdisk[" <<
i 1365 <<
"]: " << rderdisk[
i] << endl;
1383 int irinv, iphi0, id0, it, iz0;
1388 irinv = rinvapprox / krinv;
1389 iphi0 = phi0approx / kphi0;
1392 iz0 = z0approx / kz0;
1397 edm::LogVerbatim(
"Tracklet") <<
"TrackletCalculator:: LLD Seeding irinv too large: " << rinvapprox <<
"(" << irinv
1408 edm::LogVerbatim(
"Tracklet") <<
"Failed tracklet approx d0 cut " << d0approx;
1421 int phicrit = iphi0 - 2 * irinv - 2 * id0;
1427 keep = (phicrit > iphicritmincut) && (phicrit < iphicritmaxcut);
1430 if (
keep && !keepapprox)
1431 edm::LogVerbatim(
"Tracklet") <<
"TrackletCalculatorDisplaced::LLDSeeding tracklet kept with exact phicrit cut " 1432 "but not approximate, phicritapprox: " 1444 for (
unsigned int i = 0;
i <
toR_.size(); ++
i) {
1445 iphiproj[
i] = phiprojapprox[
i] / kphiproj;
1446 izproj[
i] = zprojapprox[
i] / kzproj;
1448 iphider[
i] = phiderapprox[
i] / kphider;
1449 izder[
i] = zderapprox[
i] / kzder;
1459 if (iphiproj[
i] <= 0)
1498 for (
unsigned int i = 0;
i <
toZ_.size(); ++
i) {
1499 iphiprojdisk[
i] = phiprojdiskapprox[
i] / kphiprojdisk;
1500 irprojdisk[
i] = rprojdiskapprox[
i] / krprojdisk;
1502 iphiderdisk[
i] = phiderdiskapprox[
i] / kphiderdisk;
1503 irderdisk[
i] = rderdiskapprox[
i] / krderdisk;
1506 if (iphiprojdisk[
i] <= 0)
1525 phiprojdiskapprox[
i],
1535 <<
layer_ <<
" , " <<
rinv <<
" , " << rinvapprox <<
" , " << phi0 <<
" , " << phi0approx <<
" , " <<
t <<
" , " 1536 << tapprox <<
" , " << z0 <<
" , " << z0approx <<
" , " <<
d0 <<
" , " << d0approx << endl;
1564 <<
" Found LLD tracklet in sector = " <<
iSector_ <<
" phi0 = " << phi0;
1570 ofstream
fout(
"seeds.txt", ofstream::app);
1576 for (
unsigned int j = 0;
j <
toR_.size();
j++) {
1584 for (
unsigned int j = 0;
j <
toZ_.size();
j++) {
1591 edm::LogVerbatim(
"Tracklet") <<
"adding disk projection " <<
j <<
"/" <<
toZ_.size() <<
" " << disk;
1611 double rho = 1 /
rinv;
1615 phiproj = phi0 - asin((rproj * rproj + r0 * r0 - rho * rho) / (2 * rproj * r0));
1616 double beta = acos((rho * rho + r0 * r0 - rproj * rproj) / (2 * r0 * rho));
1620 phider = -0.5 *
rinv /
sqrt(1 -
pow(0.5 * rproj *
rinv, 2)) +
d0 / (rproj * rproj);
1624 edm::LogVerbatim(
"Tracklet") <<
"exact proj layer at " << rproj <<
" : " << phiproj <<
" " << zproj;
1645 double beta = (zproj - z0) / (
t * rho);
1646 double phiV = atan2(-y0, -x0);
1647 double c =
rinv > 0 ? -1 : 1;
1649 double x = x0 + rho *
cos(phiV +
c *
beta);
1650 double y = y0 + rho *
sin(phiV +
c *
beta);
1652 phiproj = atan2(y,
x);
1656 rproj =
sqrt(
x *
x + y * y);
1658 phider =
c /
t / (
x *
x + y * y) * (rho + x0 *
cos(phiV +
c *
beta) + y0 *
sin(phiV +
c *
beta));
1662 edm::LogVerbatim(
"Tracklet") <<
"exact proj disk at" << zproj <<
" : " << phiproj <<
" " << rproj;
1682 double phiprojdisk[
N_DISK],
1683 double rprojdisk[
N_DISK],
1686 double phiderdisk[
N_DISK],
1687 double rderdisk[
N_DISK]) {
1689 double x1 = r1 *
cos(phi1);
1690 double x2 =
r2 *
cos(phi2);
1691 double x3 = r3 *
cos(phi3);
1693 double y1 = r1 *
sin(phi1);
1695 double y3 = r3 *
sin(phi3);
1697 double dy21 =
y2 -
y1;
1698 double dy32 = y3 -
y2;
1707 double k1 = -(x2 - x1) / dy21;
1708 double k2 = -(x3 - x2) / dy32;
1709 double b1 = 0.5 * (
y2 +
y1) - 0.5 * (x1 + x2) * k1;
1710 double b2 = 0.5 * (y3 +
y2) - 0.5 * (x2 + x3) * k2;
1712 double y0 = (
b1 * k2 -
b2 * k1) / (k2 - k1);
1713 double x0 = (
b1 -
b2) / (k2 - k1);
1717 double R3 =
sqrt(
pow(x3 - x0, 2) +
pow(y3 - y0, 2));
1719 double eps1 =
std::abs(R1 / R2 - 1);
1720 double eps2 =
std::abs(R3 / R2 - 1);
1721 if (eps1 > 1
e-10 || eps2 > 1
e-10)
1722 edm::LogVerbatim(
"Tracklet") <<
"&&&&&&&&&&&& bad circle! " << R1 <<
"\t" << R2 <<
"\t" << R3;
1728 phi0 = 0.5 *
M_PI + atan2(y0, x0);
1732 d0 = -R1 +
sqrt(x0 * x0 + y0 * y0);
1748 double t12 = (
z2 - z1) /
std::abs(beta2 - beta1) / R1;
1749 double z12 = (z1 * beta2 -
z2 * beta1) / (beta2 - beta1);
1750 double t13 = (z3 - z1) /
std::abs(beta3 - beta1) / R1;
1751 double z13 = (z1 * beta3 - z3 * beta1) / (beta3 - beta1);
1763 for (
unsigned int i = 0;
i <
toR_.size();
i++) {
1764 exactproj(
toR_[
i],
rinv, phi0,
d0,
t, z0,
sqrt(x0 * x0 + y0 * y0), phiproj[
i], zproj[
i], phider[
i], zder[
i]);
1767 for (
unsigned int i = 0;
i <
toZ_.size();
i++) {
1768 exactprojdisk(
toZ_[
i],
rinv, phi0,
d0,
t, z0, x0, y0, phiprojdisk[
i], rprojdisk[
i], phiderdisk[
i], rderdisk[
i]);
1772 edm::LogVerbatim(
"Tracklet") <<
"exact tracklet: " <<
rinv <<
" " << phi0 <<
" " <<
t <<
" " << z0 <<
" " <<
d0;
1792 double rmeanInv = 1.0 / rmean;
1794 phiproj = phi0 + rmean * (-halfRinv + 2.0 * d0_0 * halfRinv_0 * halfRinv_0) +
1795 rmeanInv * (-
d0 + halfRinv_0 * d0_0 * d0_0) +
sixth *
pow(-rmean * halfRinv_0 - rmeanInv * d0_0, 3);
1796 phiprojder = -halfRinv +
d0 * rmeanInv * rmeanInv;
1798 zproj = z0 +
t * rmean - 0.5 * rmeanInv *
t * d0_0 * d0_0 -
t * rmean * halfRinv *
d0 +
1799 sixth *
pow(rmean, 3) *
t * halfRinv_0 * halfRinv_0;
1805 edm::LogVerbatim(
"Tracklet") <<
"approx proj layer at " << rmean <<
" : " << phiproj <<
" " << zproj << endl;
1829 double zmeanInv = 1.0 / zmean, rstar = (zmean - z0) /
t,
1830 epsilon = 0.5 * zmeanInv * zmeanInv * d0_0 * d0_0 *
t *
t + halfRinv *
d0 -
1831 sixth * rstar * rstar * halfRinv_0 * halfRinv_0;
1833 rproj = rstar * (1 +
epsilon);
1836 double A = rproj * halfRinv;
1837 double B = -
d0 *
t * zmeanInv * (1 + z0 * zmeanInv) * (1 -
epsilon);
1838 double C = -
d0 * halfRinv;
1839 double A_0 = rproj * halfRinv_0;
1840 double B_0 = -d0_0 *
t * zmeanInv * (1 + z0 * zmeanInv) * (1 -
epsilon);
1843 phiproj = phi0 -
A +
B * (1 +
C - 2 * A_0 * A_0) +
sixth *
pow(-A_0 + B_0, 3);
1844 phiprojder = -halfRinv /
t +
d0 *
t * zmeanInv * zmeanInv;
1849 edm::LogVerbatim(
"Tracklet") <<
"approx proj disk at" << zmean <<
" : " << phiproj <<
" " << rproj << endl;
1872 double phiprojdisk[5],
1873 double rprojdisk[5],
1874 double phiderdisk[5],
1875 double rderdisk[5]) {
1876 double a = 1.0 / ((r1 -
r2) * (r1 - r3));
1877 double b = 1.0 / ((r1 -
r2) * (
r2 - r3));
1878 double c = 1.0 / ((r1 - r3) * (
r2 - r3));
1881 double halfRinv_0 = -phi1 * r1 *
a + phi2 *
r2 *
b - phi3 * r3 *
c;
1882 double d0_0 = r1 *
r2 * r3 * (-phi1 *
a + phi2 *
b - phi3 *
c);
1885 double r =
r2, z =
z2;
1889 double d0OverR1 = d0_0 *
rzmeanInv_[0] * (ndisks > 2 ?
std::abs((z - z1) / (r - r1)) : 1.0);
1890 double d0OverR2 = d0_0 *
rzmeanInv_[1] * (ndisks > 1 ?
std::abs((z - z1) / (r - r1)) : 1.0);
1891 double d0OverR3 = d0_0 *
rzmeanInv_[2] * (ndisks > 0 ?
std::abs((z - z1) / (r - r1)) : 1.0);
1893 double d0OverR = d0OverR2;
1897 double c1 = d0_0 * halfRinv_0 * d0OverR1 + 2.0 * d0_0 * halfRinv_0 * r1 * halfRinv_0 +
1898 sixth *
pow(-r1 * halfRinv_0 - d0OverR1, 3);
1899 double c2 = d0_0 * halfRinv_0 * d0OverR2 + 2.0 * d0_0 * halfRinv_0 *
r2 * halfRinv_0 +
1901 double c3 = d0_0 * halfRinv_0 * d0OverR3 + 2.0 * d0_0 * halfRinv_0 * r3 * halfRinv_0 +
1902 sixth *
pow(-r3 * halfRinv_0 - d0OverR3, 3);
1904 double phi1c = phi1 -
c1;
1905 double phi2c = phi2 - c2;
1906 double phi3c = phi3 - c3;
1909 double halfRinv = -phi1c * r1 *
a + phi2c *
r2 *
b - phi3c * r3 *
c;
1910 phi0 = -phi1c * r1 * (
r2 + r3) *
a + phi2c *
r2 * (r1 + r3) *
b - phi3c * r3 * (r1 +
r2) *
c;
1911 d0 = r1 *
r2 * r3 * (-phi1c *
a + phi2c *
b - phi3c *
c);
1913 t = ((z - z1) / (r - r1)) *
1914 (1. +
d0 * halfRinv - 0.5 * d0OverR1 * d0OverR -
sixth * (r1 * r1 +
r2 *
r2 + r1 *
r2) * halfRinv_0 * halfRinv_0);
1915 z0 = z1 -
t * r1 * (1.0 - d0_0 * halfRinv_0 - 0.5 * d0OverR1 * d0OverR1 +
sixth * r1 * r1 * halfRinv_0 * halfRinv_0);
1917 rinv = 2.0 * halfRinv;
1922 for (
unsigned int i = 0;
i <
toR_.size();
i++) {
1937 for (
unsigned int i = 0;
i <
toZ_.size();
i++) {
1959 edm::LogVerbatim(
"Tracklet") <<
"TCD approx tracklet: " <<
rinv <<
" " << phi0 <<
" " <<
t <<
" " << z0 <<
" " <<
d0
Log< level::Info, true > LogVerbatim
std::vector< AllStubsMemory * > middleallstubs_
unsigned int maxStep(std::string module) const
int PS_rderD_shift() const
int PS_zderL_shift() const
std::vector< StubTripletsMemory * > stubtriplets_
void exactproj(double rproj, double rinv, double phi0, double d0, double t, double z0, double r0, double &phiproj, double &zproj, double &phider, double &zder)
constexpr T reduceRange(T x)
bool addLayerProj(Tracklet *tracklet, int layer)
double phiapprox(double phimin, double) const
std::vector< AllStubsMemory * > innerallstubs_
void addInput(MemoryBase *memory, std::string input) override
double disp_z0cut() const
double phicritmaxmc() const
Sin< T >::type sin(const T &t)
Projection & proj(int layerdisk)
Settings const & settings_
void addProjection(int layer, int iphi, TrackletProjectionsMemory *trackletprojs, Tracklet *tracklet)
double rmindiskvm() const
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
unsigned int nTracklets() const
double phicritminmc() const
const FPGAWord & fpgaphiproj() const
static std::string const input
const FPGAWord & disk() const
void exactprojdisk(double zproj, double rinv, double, double, double t, double z0, double x0, double y0, double &phiproj, double &rproj, double &phider, double &rder)
bool LLDSeeding(const Stub *innerFPGAStub, const L1TStub *innerStub, const Stub *middleFPGAStub, const L1TStub *middleStub, const Stub *outerFPGAStub, const L1TStub *outerStub)
std::vector< std::vector< TrackletProjectionsMemory * > > trackletprojlayers_
void init(Settings const &settings, unsigned int layerdisk, int iphiproj, int irzproj, int iphider, int irzder, double phiproj, double rzproj, double phiprojder, double rzprojder, double phiprojapprox, double rzprojapprox, double phiprojderapprox, double rzprojderapprox, bool isPSseed)
unsigned int nbitsphiprojderL456() const
void exacttracklet(double r1, double z1, double phi1, double r2, double z2, double phi2, double r3, double z3, double phi3, int take3, double &rinv, double &phi0, double &d0, double &t, double &z0, double phiproj[N_LAYER - 2], double zproj[N_LAYER - 2], double phiprojdisk[N_DISK], double rprojdisk[N_DISK], double phider[N_LAYER - 2], double zder[N_LAYER - 2], double phiderdisk[N_DISK], double rderdisk[N_DISK])
unsigned int nzbitsstub(unsigned int layerdisk) const
unsigned int nphibitsstub(unsigned int layerdisk) const
std::vector< double > toR_
double rmean(unsigned int iLayer) const
void approxprojdisk(double halfRinv, double phi0, double d0, double t, double z0, double halfRinv_0, double d0_0, double zmean, double &phiproj, double &phiprojder, double &rproj, double &rprojder)
Cos< T >::type cos(const T &t)
bool LLLSeeding(const Stub *innerFPGAStub, const L1TStub *innerStub, const Stub *middleFPGAStub, const L1TStub *middleStub, const Stub *outerFPGAStub, const L1TStub *outerStub)
Abs< T >::type abs(const T &t)
IMATH_TrackletCalculator * ITC_L1L2()
double zproj_[N_DISK - 2]
void execute(unsigned int iSector, double phimin, double phimax)
std::string const & getName() const
std::vector< std::vector< TrackletProjectionsMemory * > > trackletprojdisks_
void approxtracklet(double r1, double z1, double phi1, double r2, double z2, double phi2, double r3, double z3, double phi3, bool take3, unsigned ndisks, double &rinv, double &phi0, double &d0, double &t, double &z0, double phiproj[4], double zproj[4], double phider[4], double zder[4], double phiprojdisk[5], double rprojdisk[5], double phiderdisk[5], double rderdisk[5])
bool writeMonitorData(std::string module) const
unsigned int layerdisk() const
double zmean(unsigned int iDisk) const
void setTCIndex(int index)
int SS_phiD_shift() const
unsigned int nallstubs(unsigned int layerdisk) const
bool debugTracklet() const
double rproj_[N_LAYER - 2]
int SS_phiderD_shift() const
void addTracklet(Tracklet *tracklet)
static constexpr float d0
bool DDLSeeding(const Stub *innerFPGAStub, const L1TStub *innerStub, const Stub *middleFPGAStub, const L1TStub *middleStub, const Stub *outerFPGAStub, const L1TStub *outerStub)
void approxproj(double halfRinv, double phi0, double d0, double t, double z0, double halfRinv_0, double d0_0, double rmean, double &phiproj, double &phiprojder, double &zproj, double &zprojder)
void addDiskProj(Tracklet *tracklet, int disk)
void setTrackletIndex(unsigned int index)
double rinv(double phi1, double phi2, double r1, double r2)
constexpr valType make0To2pi(valType angle)
int SS_phiderL_shift() const
unsigned int nbitsphiprojderL123() const
const FPGAWord & fpgarzproj() const
double rzmeanInv_[N_DISK - 2]
void addProj(Tracklet *tracklet)
std::ofstream & ofstream(std::string fname)
unsigned int ntrackletmax() const
std::vector< AllStubsMemory * > outerallstubs_
double krprojshiftdisk() const
void addOutputProjection(TrackletProjectionsMemory *&outputProj, MemoryBase *memory)
const FPGAWord & layer() const
bool usephicritapprox() const
std::string const & getName() const
int SS_phiL_shift() const
void addProjectionDisk(int disk, int iphi, TrackletProjectionsMemory *trackletprojs, Tracklet *tracklet)
std::vector< double > toZ_
void addOutput(MemoryBase *memory, std::string output) override
TrackletParametersMemory * trackletpars_
bool validProj(int layerdisk) const