18 TrackletCalculatorBase::TrackletCalculatorBase(
string name,
Settings const& settings,
Globals* global)
36 double phiprojdisk[
N_DISK],
42 double dist =
sqrt(
r2 *
r2 + r1 * r1 - 2 * r1 *
r2 *
cos(deltaphi));
44 rinv = 2 *
sin(deltaphi) / dist;
46 double phi1tmp = phi1 -
phimin_;
50 double rhopsi1 = 2 * asin(0.5 * r1 *
rinv) /
rinv;
51 double rhopsi2 = 2 * asin(0.5 *
r2 *
rinv) /
rinv;
53 t = (z1 -
z2) / (rhopsi1 - rhopsi2);
55 z0 = z1 -
t * rhopsi1;
57 for (
unsigned int i = 0;
i <
N_LAYER - 2;
i++) {
69 for (
unsigned int i = 0;
i <
N_DISK;
i++) {
89 double phiproj[
N_DISK - 2],
95 double dist =
sqrt(
r2 *
r2 + r1 * r1 - 2 * r1 *
r2 *
cos(deltaphi));
97 rinv = 2 *
sin(deltaphi) / dist;
99 double phi1tmp = phi1 -
phimin_;
103 double rhopsi1 = 2 * asin(0.5 * r1 *
rinv) /
rinv;
104 double rhopsi2 = 2 * asin(0.5 *
r2 *
rinv) /
rinv;
106 t = (z1 -
z2) / (rhopsi1 - rhopsi2);
108 z0 = z1 -
t * rhopsi1;
110 for (
unsigned int i = 0;
i <
N_DISK - 2;
i++) {
122 for (
unsigned int i = 0;
i <
N_DISK - 2;
i++) {
142 double phiproj[
N_DISK - 2],
144 double phider[
N_DISK - 2],
145 double rder[
N_DISK - 2]) {
148 double dist =
sqrt(
r2 *
r2 + r1 * r1 - 2 * r1 *
r2 *
cos(deltaphi));
150 rinv = 2 *
sin(deltaphi) / dist;
155 double phi1tmp = phi1 -
phimin_;
159 double rhopsi1 = 2 * asin(0.5 * r1 *
rinv) /
rinv;
160 double rhopsi2 = 2 * asin(0.5 *
r2 *
rinv) /
rinv;
162 t = (z1 -
z2) / (rhopsi1 - rhopsi2);
164 z0 = z1 -
t * rhopsi1;
166 for (
int i = 0;
i < 4;
i++) {
170 for (
int i = 0;
i < 1;
i++) {
184 phiproj = phi0 - asin(0.5 * rproj *
rinv);
185 zproj = z0 + (2 *
t /
rinv) * asin(0.5 * rproj *
rinv);
203 double tmp =
rinv * (zproj - z0) / (2.0 *
t);
205 phiproj = phi0 -
tmp;
207 phider = -
rinv / (2 *
t);
223 int iphivmRaw = fpgaphi.
value() >> (fpgaphi.
nbits() - 5);
247 int iphivmRaw = fpgaphi.
value() >> (fpgaphi.
nbits() - 5);
259 if (trackletprojs ==
nullptr) {
262 <<
" iphi = " <<
iphi + 1;
266 assert(trackletprojs !=
nullptr);
267 trackletprojs->
addProj(tracklet);
276 if (trackletprojs ==
nullptr) {
281 <<
" iphi = " <<
iphi + 1;
285 assert(trackletprojs !=
nullptr);
286 trackletprojs->
addProj(tracklet);
307 double phicritapprox = phi0approx - asin(0.5 *
settings_.
rcrit() * rinvapprox);
310 int iphicrit = iphi0 - (irinv >> 8) * ifactor;
316 keep = (iphicrit > iphicritmincut) && (iphicrit < iphicritmaxcut);
318 if (keepapprox && !
keep)
320 <<
" Tracklet kept with exact phicrit cut but not approximate, phicritapprox: " 333 const Stub* outerFPGAStub,
337 <<
" trying stub pair in layer (inner outer): " << innerFPGAStub->
layer().
value()
345 double r1 = innerStub->
r();
346 double z1 = innerStub->
z();
347 double phi1 = innerStub->
phi();
349 double r2 = outerStub->
r();
350 double z2 = outerStub->
z();
351 double phi2 = outerStub->
phi();
353 double rinv, phi0,
t, z0;
388 double rinvapprox, phi0approx, tapprox, z0approx;
390 double phiprojdiskapprox[
N_DISK], rprojdiskapprox[
N_DISK];
485 int irinv, iphi0,
it, iz0;
491 int ir1 = innerFPGAStub->
r().
value();
492 int iphi1 = innerFPGAStub->
phi().
value();
493 int iz1 = innerFPGAStub->
z().
value();
495 int ir2 = outerFPGAStub->
r().
value();
496 int iphi2 = outerFPGAStub->
phi().
value();
497 int iz2 = outerFPGAStub->
z().
value();
569 if (!
inSector(iphi0, irinv, phi0approx, rinvapprox)) {
576 for (
unsigned int i = 0;
i <
N_LAYER - 2; ++
i) {
586 if (iphiproj[
i] <= 0)
626 for (
unsigned int i = 0;
i <
N_DISK; ++
i) {
627 if (iphiprojdisk[
i] <= 0)
646 phiprojdiskapprox[
i],
657 <<
" " << phi0 <<
" " << phi0approx <<
" " << ITC->
phi0_final.
fval() <<
" " <<
t <<
" " << tapprox <<
" " 693 ofstream
fout(
"seeds.txt", ofstream::app);
721 for (
unsigned int j = 0;
j <
N_LAYER - 2;
j++) {
726 if (added && lproj == 3)
728 if (added && lproj == 4)
730 if (added && lproj == 5)
732 if (added && lproj == 6)
737 for (
unsigned int j = 0;
j <
N_DISK - 1;
j++) {
739 if (disk == 4 && addL3)
741 if (disk == 3 && addL4)
743 if (disk == 2 && addL5)
745 if (disk == 1 && addL6)
759 const Stub* outerFPGAStub,
762 edm::LogVerbatim(
"Tracklet") <<
"TrackletCalculator::execute calculate disk seeds";
769 int disk = innerFPGAStub->
disk().
value();
775 double r1 = innerStub->
r();
776 double z1 = innerStub->
z();
777 double phi1 = innerStub->
phi();
779 double r2 = outerStub->
r();
780 double z2 = outerStub->
z();
781 double phi2 = outerStub->
phi();
787 double rinv, phi0,
t, z0;
823 double rinvapprox, phi0approx, tapprox, z0approx;
825 double phiprojdiskapprox[
N_DISK - 2], rprojdiskapprox[
N_DISK - 2];
839 int signt =
t > 0 ? 1 : -1;
905 int irinv, iphi0,
it, iz0;
910 int ir1 = innerFPGAStub->
r().
value();
911 int iphi1 = innerFPGAStub->
phi().
value();
912 int iz1 = innerFPGAStub->
z().
value();
914 int ir2 = outerFPGAStub->
r().
value();
915 int iphi2 = outerFPGAStub->
phi().
value();
916 int iz2 = outerFPGAStub->
z().
value();
972 if (!
inSector(iphi0, irinv, phi0approx, rinvapprox))
977 for (
unsigned int i = 0;
i <
N_DISK - 2; ++
i) {
987 if (iphiproj[
i] <= 0)
1018 for (
unsigned int i = 0;
i <
N_DISK - 2; ++
i) {
1020 if (iphiprojdisk[
i] <= 0)
1039 phiprojdiskapprox[
i],
1048 <<
"Trackpars " <<
layerdisk1_ - 5 <<
" " <<
rinv <<
" " << rinvapprox <<
" " 1050 <<
" " << tapprox <<
" " << ITC->
t_final.
fval() <<
" " << z0 <<
" " << z0approx <<
" " << ITC->
z0_final.
fval()
1085 ofstream
fout(
"seeds.txt", ofstream::app);
1099 for (
unsigned int j = 0;
j <
N_DISK - 2;
j++) {
1110 const Stub* outerFPGAStub,
1117 int disk = innerFPGAStub->
disk().
value();
1123 double r1 = innerStub->
r();
1124 double z1 = innerStub->
z();
1125 double phi1 = innerStub->
phi();
1127 double r2 = outerStub->
r();
1128 double z2 = outerStub->
z();
1129 double phi2 = outerStub->
phi();
1132 if (r1 <
r2 + 1.5) {
1136 double rinv, phi0,
t, z0;
1164 z1 = innerFPGAStub->
zapprox();
1165 r1 = innerFPGAStub->
rapprox();
1172 double rinvapprox, phi0approx, tapprox, z0approx;
1174 double phiprojdiskapprox[
N_DISK - 1], rprojdiskapprox[
N_DISK - 1];
1178 if (ll == 1 && disk == 1)
1180 else if (ll == 2 && disk == 1)
1182 else if (ll == 1 && disk == -1)
1184 else if (ll == 2 && disk == -1)
1187 throw cms::Exception(
"LogicError") << __FILE__ <<
" " << __LINE__ <<
" Invalid seeding!";
1191 int signt =
t > 0 ? 1 : -1;
1262 int irinv, iphi0,
it, iz0;
1266 int ir2 = innerFPGAStub->
r().
value();
1267 int iphi2 = innerFPGAStub->
phi().
value();
1268 int iz2 = innerFPGAStub->
z().
value();
1270 int ir1 = outerFPGAStub->
r().
value();
1271 int iphi1 = outerFPGAStub->
phi().
value();
1272 int iz1 = outerFPGAStub->
z().
value();
1341 if (!
inSector(iphi0, irinv, phi0approx, rinvapprox))
1346 for (
unsigned int i = 0;
i <
N_DISK - 2; ++
i) {
1356 if (iphiproj[
i] <= 0)
1379 for (
int i = 0;
i < 4; ++
i) {
1381 if (iphiprojdisk[
i] <= 0)
1400 phiprojdiskapprox[
i],
1410 << phi0 <<
" " << iphi0 <<
" " << ITC->
phi0_final.
fval() <<
" " <<
t <<
" " <<
it <<
" " 1446 ofstream
fout(
"seeds.txt", ofstream::app);
1452 int layer = outerFPGAStub->
layer().
value() + 1;
1460 for (
unsigned int disk = 2; disk < 6; disk++) {
1461 if (layer == 2 && disk == 5)
Log< level::Info, true > LogVerbatim
VarAdjustK der_phiL_final
bool diskSeeding(const Stub *innerFPGAStub, const L1TStub *innerStub, const Stub *outerFPGAStub, const L1TStub *outerStub)
const FPGAWord & r() const
unsigned int nrbitsstub(unsigned int layerdisk) const
IMATH_TrackletCalculator * ITC_L2L3()
constexpr T reduceRange(T x)
double phiapprox(double phimin, double) const
const FPGAWord & z() const
double phicritmaxmc() const
bool goodTrackPars(bool goodrinv, bool goodz0)
Sin< T >::type sin(const T &t)
Projection & proj(int layerdisk)
Settings const & settings_
bool addLayerProj(Tracklet *tracklet, int layer)
VarAdjustK der_phiL_final
void exacttrackletOverlap(double r1, double z1, double phi1, double r2, double z2, double phi2, double, double &rinv, double &phi0, double &t, double &z0, double phiprojLayer[N_PSLAYER], double zprojLayer[N_PSLAYER], double phiderLayer[N_PSLAYER], double zderLayer[N_PSLAYER], double phiproj[N_DISK - 2], double rproj[N_DISK - 2], double phider[N_DISK - 2], double rder[N_DISK - 2])
double rmindiskvm() const
void set_fval(double fval)
IMATH_TrackletCalculatorOverlap * ITC_L2B1()
void exacttracklet(double r1, double z1, double phi1, double r2, double z2, double phi2, double, double &rinv, double &phi0, double &t, double &z0, double phiproj[N_LAYER - 2], double zproj[N_LAYER - 2], double phider[N_LAYER - 2], double zder[N_LAYER - 2], double phiprojdisk[N_DISK], double rprojdisk[N_DISK], double phiderdisk[N_DISK], double rderdisk[N_DISK])
unsigned int nTracklets() const
double phicritminmc() const
IMATH_TrackletCalculatorDisk * ITC_B1B2()
const FPGAWord & fpgaphiproj() const
void exactprojdisk(double zproj, double rinv, double phi0, double t, double z0, double &phiproj, double &rproj, double &phider, double &rder)
unsigned int isPSmodule() const
const FPGAWord & disk() const
bool overlapSeeding(const Stub *innerFPGAStub, const L1TStub *innerStub, const Stub *outerFPGAStub, const L1TStub *outerStub)
IMATH_TrackletCalculatorDisk * ITC_F3F4()
unsigned int projlayers(unsigned int iSeed, unsigned int i) const
IMATH_TrackletCalculatorOverlap * ITC_L1F1()
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)
void addProjection(int layer, int iphi, TrackletProjectionsMemory *trackletprojs, Tracklet *tracklet)
unsigned int nzbitsstub(unsigned int layerdisk) const
unsigned int nphibitsstub(unsigned int layerdisk) const
double rmean(unsigned int iLayer) const
bool local_passes() const
VarAdjustK der_phiD_final
Cos< T >::type cos(const T &t)
VarAdjustK der_phiD_final
Abs< T >::type abs(const T &t)
IMATH_TrackletCalculator * ITC_L1L2()
void exacttrackletdisk(double r1, double z1, double phi1, double r2, double z2, double phi2, double, double &rinv, double &phi0, double &t, double &z0, double phiprojLayer[N_PSLAYER], double zprojLayer[N_PSLAYER], double phiderLayer[N_PSLAYER], double zderLayer[N_PSLAYER], double phiproj[N_DISK - 2], double rproj[N_DISK - 2], double phider[N_DISK - 2], double rder[N_DISK - 2])
unsigned int projdisks(unsigned int iSeed, unsigned int i) const
TrackletParametersMemory * trackletpars_
bool writeMonitorData(std::string module) const
unsigned int layerdisk() const
double zmean(unsigned int iDisk) const
void setTCIndex(int index)
std::vector< std::vector< TrackletProjectionsMemory * > > trackletprojdisks_
unsigned int nallstubs(unsigned int layerdisk) const
bool debugTracklet() const
void addTracklet(Tracklet *tracklet)
constexpr unsigned int N_PSLAYER
IMATH_TrackletCalculatorDisk * ITC_B3B4()
void exactproj(double rproj, double rinv, double phi0, double t, double z0, double &phiproj, double &zproj, double &phider, double &zder)
std::vector< std::vector< TrackletProjectionsMemory * > > trackletprojlayers_
IMATH_TrackletCalculatorDisk * ITC_F1F2()
VarAdjustK der_phiD_final
void setTrackletIndex(unsigned int index)
double rinv(double phi1, double phi2, double r1, double r2)
constexpr valType make0To2pi(valType angle)
IMATH_TrackletCalculator * ITC_L5L6()
const FPGAWord & fpgarzproj() const
void addDiskProj(Tracklet *tracklet, int disk)
IMATH_TrackletCalculator * ITC_L3L4()
void addProjectionDisk(int disk, int iphi, TrackletProjectionsMemory *trackletprojs, Tracklet *tracklet)
VarAdjustK der_phiL_final
IMATH_TrackletCalculatorOverlap * ITC_L1B1()
IMATH_TrackletCalculatorOverlap * ITC_L2F1()
void addProj(Tracklet *tracklet)
std::ofstream & ofstream(std::string fname)
double krprojshiftdisk() const
const FPGAWord & layer() const
const FPGAWord & phi() const
bool usephicritapprox() const
std::string const & getName() const
bool calculate(int debug_level=0)
Power< A, B >::type pow(const A &a, const B &b)
bool validProj(int layerdisk) const
int bitShift(int num, int bits)
bool inSector(int iphi0, int irinv, double phi0approx, double rinvapprox)
bool barrelSeeding(const Stub *innerFPGAStub, const L1TStub *innerStub, const Stub *outerFPGAStub, const L1TStub *outerStub)