15 using namespace trklet;
17 TrackletCalculatorBase::TrackletCalculatorBase(
string name,
Settings const& settings,
Globals* global)
35 double phiprojdisk[
N_DISK],
36 double rprojdisk[N_DISK],
37 double phiderdisk[N_DISK],
38 double rderdisk[N_DISK]) {
41 double dist =
sqrt(r2 * r2 + r1 * r1 - 2 * r1 * r2 *
cos(deltaphi));
43 rinv = 2 *
sin(deltaphi) / dist;
45 double phi1tmp = phi1 -
phimin_;
49 double rhopsi1 = 2 * asin(0.5 * r1 * rinv) /
rinv;
50 double rhopsi2 = 2 * asin(0.5 * r2 * rinv) /
rinv;
52 t = (z1 - z2) / (rhopsi1 - rhopsi2);
54 z0 = z1 - t * rhopsi1;
56 for (
unsigned int i = 0;
i <
N_LAYER - 2;
i++) {
68 for (
unsigned int i = 0;
i <
N_DISK;
i++) {
85 double zprojLayer[N_PSLAYER],
86 double phiderLayer[N_PSLAYER],
87 double zderLayer[N_PSLAYER],
88 double phiproj[
N_DISK - 2],
94 double dist =
sqrt(r2 * r2 + r1 * r1 - 2 * r1 * r2 *
cos(deltaphi));
96 rinv = 2 *
sin(deltaphi) / dist;
98 double phi1tmp = phi1 -
phimin_;
102 double rhopsi1 = 2 * asin(0.5 * r1 * rinv) /
rinv;
103 double rhopsi2 = 2 * asin(0.5 * r2 * rinv) /
rinv;
105 t = (z1 - z2) / (rhopsi1 - rhopsi2);
107 z0 = z1 - t * rhopsi1;
109 for (
unsigned int i = 0;
i <
N_DISK - 2;
i++) {
121 for (
unsigned int i = 0;
i < N_DISK - 2;
i++) {
138 double zprojLayer[N_PSLAYER],
139 double phiderLayer[N_PSLAYER],
140 double zderLayer[N_PSLAYER],
141 double phiproj[
N_DISK - 2],
143 double phider[
N_DISK - 2],
144 double rder[
N_DISK - 2]) {
147 double dist =
sqrt(r2 * r2 + r1 * r1 - 2 * r1 * r2 *
cos(deltaphi));
149 rinv = 2 *
sin(deltaphi) / dist;
154 double phi1tmp = phi1 -
phimin_;
158 double rhopsi1 = 2 * asin(0.5 * r1 * rinv) /
rinv;
159 double rhopsi2 = 2 * asin(0.5 * r2 * rinv) /
rinv;
161 t = (z1 - z2) / (rhopsi1 - rhopsi2);
163 z0 = z1 - t * rhopsi1;
165 for (
int i = 0;
i < 4;
i++) {
169 for (
int i = 0;
i < 1;
i++) {
183 phiproj = phi0 - asin(0.5 * rproj * rinv);
184 zproj = z0 + (2 * t /
rinv) * asin(0.5 * rproj * rinv);
186 phider = -0.5 * rinv /
sqrt(1 -
pow(0.5 * rproj * rinv, 2));
187 zder = t /
sqrt(1 -
pow(0.5 * rproj * rinv, 2));
202 double tmp = rinv * (zproj - z0) / (2.0 * t);
203 rproj = (2.0 /
rinv) *
sin(tmp);
204 phiproj = phi0 -
tmp;
206 phider = -rinv / (2 *
t);
222 int iphivmRaw = fpgaphi.
value() >> (fpgaphi.
nbits() - 5);
246 int iphivmRaw = fpgaphi.
value() >> (fpgaphi.
nbits() - 5);
258 if (trackletprojs ==
nullptr) {
261 <<
" iphi = " << iphi + 1;
265 assert(trackletprojs !=
nullptr);
266 trackletprojs->
addProj(tracklet);
275 if (trackletprojs ==
nullptr) {
280 <<
" iphi = " << iphi + 1;
284 assert(trackletprojs !=
nullptr);
285 trackletprojs->
addProj(tracklet);
306 double phicritapprox = phi0approx - asin(0.5 *
settings_.
rcrit() * rinvapprox);
309 int iphicrit = iphi0 - (irinv >> 8) * ifactor;
315 keep = (iphicrit > iphicritmincut) && (iphicrit < iphicritmaxcut);
317 if (keepapprox && !
keep)
319 <<
" Tracklet kept with exact phicrit cut but not approximate, phicritapprox: "
332 const Stub* outerFPGAStub,
336 <<
" trying stub pair in layer (inner outer): " << innerFPGAStub->
layer().
value()
344 double r1 = innerStub->
r();
345 double z1 = innerStub->
z();
346 double phi1 = innerStub->
phi();
348 double r2 = outerStub->
r();
349 double z2 = outerStub->
z();
350 double phi2 = outerStub->
phi();
352 double rinv, phi0,
t, z0;
387 double rinvapprox, phi0approx, tapprox, z0approx;
389 double phiprojdiskapprox[
N_DISK], rprojdiskapprox[
N_DISK];
484 int irinv, iphi0, it, iz0;
490 int ir1 = innerFPGAStub->
r().
value();
491 int iphi1 = innerFPGAStub->
phi().
value();
492 int iz1 = innerFPGAStub->
z().
value();
494 int ir2 = outerFPGAStub->
r().
value();
495 int iphi2 = outerFPGAStub->
phi().
value();
496 int iz2 = outerFPGAStub->
z().
value();
568 if (!
inSector(iphi0, irinv, phi0approx, rinvapprox)) {
575 for (
unsigned int i = 0;
i <
N_LAYER - 2; ++
i) {
585 if (iphiproj[
i] <= 0)
625 for (
unsigned int i = 0;
i <
N_DISK; ++
i) {
626 if (iphiprojdisk[
i] <= 0)
645 phiprojdiskapprox[
i],
656 <<
" " << phi0 <<
" " << phi0approx <<
" " << ITC->
phi0_final.
fval() <<
" " << t <<
" " << tapprox <<
" "
692 ofstream
fout(
"seeds.txt", ofstream::app);
693 fout << __FILE__ <<
":" << __LINE__ <<
" " <<
name_ <<
"_" <<
iSector_ <<
" " << tracklet->
getISeed() << endl;
720 for (
unsigned int j = 0;
j < N_LAYER - 2;
j++) {
725 if (added && lproj == 3)
727 if (added && lproj == 4)
729 if (added && lproj == 5)
731 if (added && lproj == 6)
736 for (
unsigned int j = 0;
j <
N_DISK - 1;
j++) {
738 if (disk == 4 && addL3)
740 if (disk == 3 && addL4)
742 if (disk == 2 && addL5)
744 if (disk == 1 && addL6)
758 const Stub* outerFPGAStub,
761 edm::LogVerbatim(
"Tracklet") <<
"TrackletCalculator::execute calculate disk seeds";
768 int disk = innerFPGAStub->
disk().
value();
774 double r1 = innerStub->
r();
775 double z1 = innerStub->
z();
776 double phi1 = innerStub->
phi();
778 double r2 = outerStub->
r();
779 double z2 = outerStub->
z();
780 double phi2 = outerStub->
phi();
786 double rinv, phi0,
t, z0;
822 double rinvapprox, phi0approx, tapprox, z0approx;
824 double phiprojdiskapprox[
N_DISK - 2], rprojdiskapprox[
N_DISK - 2];
838 int signt = t > 0 ? 1 : -1;
904 int irinv, iphi0, it, iz0;
909 int ir1 = innerFPGAStub->
r().
value();
910 int iphi1 = innerFPGAStub->
phi().
value();
911 int iz1 = innerFPGAStub->
z().
value();
913 int ir2 = outerFPGAStub->
r().
value();
914 int iphi2 = outerFPGAStub->
phi().
value();
915 int iz2 = outerFPGAStub->
z().
value();
971 if (!
inSector(iphi0, irinv, phi0approx, rinvapprox))
976 for (
unsigned int i = 0;
i <
N_DISK - 2; ++
i) {
986 if (iphiproj[
i] <= 0)
1017 for (
unsigned int i = 0;
i < N_DISK - 2; ++
i) {
1019 if (iphiprojdisk[
i] <= 0)
1038 phiprojdiskapprox[
i],
1047 <<
"Trackpars " <<
layerdisk1_ - 5 <<
" " << rinv <<
" " << rinvapprox <<
" "
1049 <<
" " << tapprox <<
" " << ITC->
t_final.
fval() <<
" " << z0 <<
" " << z0approx <<
" " << ITC->
z0_final.
fval()
1084 ofstream
fout(
"seeds.txt", ofstream::app);
1085 fout << __FILE__ <<
":" << __LINE__ <<
" " <<
name_ <<
"_" <<
iSector_ <<
" " << tracklet->
getISeed() << endl;
1098 for (
unsigned int j = 0;
j < N_DISK - 2;
j++) {
1109 const Stub* outerFPGAStub,
1116 int disk = innerFPGAStub->
disk().
value();
1122 double r1 = innerStub->
r();
1123 double z1 = innerStub->
z();
1124 double phi1 = innerStub->
phi();
1126 double r2 = outerStub->
r();
1127 double z2 = outerStub->
z();
1128 double phi2 = outerStub->
phi();
1131 if (r1 < r2 + 1.5) {
1135 double rinv, phi0,
t, z0;
1163 z1 = innerFPGAStub->
zapprox();
1164 r1 = innerFPGAStub->
rapprox();
1167 z2 = outerFPGAStub->
zapprox();
1168 r2 = outerFPGAStub->
rapprox();
1171 double rinvapprox, phi0approx, tapprox, z0approx;
1173 double phiprojdiskapprox[
N_DISK - 1], rprojdiskapprox[
N_DISK - 1];
1177 if (ll == 1 && disk == 1)
1179 else if (ll == 2 && disk == 1)
1181 else if (ll == 1 && disk == -1)
1183 else if (ll == 2 && disk == -1)
1186 throw cms::Exception(
"LogicError") << __FILE__ <<
" " << __LINE__ <<
" Invalid seeding!";
1190 int signt = t > 0 ? 1 : -1;
1261 int irinv, iphi0, it, iz0;
1265 int ir2 = innerFPGAStub->
r().
value();
1266 int iphi2 = innerFPGAStub->
phi().
value();
1267 int iz2 = innerFPGAStub->
z().
value();
1269 int ir1 = outerFPGAStub->
r().
value();
1270 int iphi1 = outerFPGAStub->
phi().
value();
1271 int iz1 = outerFPGAStub->
z().
value();
1340 if (!
inSector(iphi0, irinv, phi0approx, rinvapprox))
1345 for (
unsigned int i = 0;
i <
N_DISK - 2; ++
i) {
1355 if (iphiproj[
i] <= 0)
1378 for (
int i = 0;
i < 4; ++
i) {
1380 if (iphiprojdisk[
i] <= 0)
1399 phiprojdiskapprox[
i],
1409 << phi0 <<
" " << iphi0 <<
" " << ITC->
phi0_final.
fval() <<
" " << t <<
" " << it <<
" "
1445 ofstream
fout(
"seeds.txt", ofstream::app);
1446 fout << __FILE__ <<
":" << __LINE__ <<
" " <<
name_ <<
"_" <<
iSector_ <<
" " << tracklet->
getISeed() << endl;
1459 for (
unsigned int disk = 2; disk < 6; disk++) {
1460 if (layer == 2 && disk == 5)
Log< level::Info, true > LogVerbatim
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])
const FPGAWord & disk() const
VarAdjustK der_phiL_final
bool diskSeeding(const Stub *innerFPGAStub, const L1TStub *innerStub, const Stub *outerFPGAStub, const L1TStub *outerStub)
unsigned int projlayers(unsigned int iSeed, unsigned int i) const
IMATH_TrackletCalculator * ITC_L2L3()
constexpr T reduceRange(T x)
const FPGAWord & fpgaphiproj() const
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])
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
bool calculate(int debug_level)
const FPGAWord & layer() const
unsigned int projdisks(unsigned int iSeed, unsigned int i) const
unsigned int nphibitsstub(unsigned int layerdisk) const
double phiapprox(double phimin, double) const
void set_fval(double fval)
IMATH_TrackletCalculatorOverlap * ITC_L2B1()
bool debugTracklet() const
IMATH_TrackletCalculatorDisk * ITC_B1B2()
constexpr std::array< uint8_t, layerIndexSize > layer
void exactprojdisk(double zproj, double rinv, double phi0, double t, double z0, double &phiproj, double &rproj, double &phider, double &rder)
bool validProj(int layerdisk) const
double rmean(unsigned int iLayer) const
bool overlapSeeding(const Stub *innerFPGAStub, const L1TStub *innerStub, const Stub *outerFPGAStub, const L1TStub *outerStub)
IMATH_TrackletCalculatorDisk * ITC_F3F4()
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)
std::string const & getName() const
double zmean(unsigned int iDisk) const
void addProjection(int layer, int iphi, TrackletProjectionsMemory *trackletprojs, Tracklet *tracklet)
virtual void fillTrackletParams(Settings const &, Globals *, int, int, double, double, double, double, double, double, double, double, int)
unsigned int nTracklets() const
double phicritminmc() const
VarAdjustK der_phiD_final
Cos< T >::type cos(const T &t)
VarAdjustK der_phiD_final
unsigned int nrbitsstub(unsigned int layerdisk) const
Abs< T >::type abs(const T &t)
IMATH_TrackletCalculator * ITC_L1L2()
unsigned int nallstubs(unsigned int layerdisk) const
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])
TrackletParametersMemory * trackletpars_
unsigned int isPSmodule() const
unsigned int nzbitsstub(unsigned int layerdisk) const
bool usephicritapprox() const
void setTCIndex(int index)
const FPGAWord & z() const
std::vector< std::vector< TrackletProjectionsMemory * > > trackletprojdisks_
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)
const FPGAWord & phi() const
std::vector< std::vector< TrackletProjectionsMemory * > > trackletprojlayers_
double phicritmaxmc() const
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)
const FPGAWord & fpgarzproj() const
IMATH_TrackletCalculator * ITC_L5L6()
void addDiskProj(Tracklet *tracklet, int disk)
bool local_passes() const
IMATH_TrackletCalculator * ITC_L3L4()
void addProjectionDisk(int disk, int iphi, TrackletProjectionsMemory *trackletprojs, Tracklet *tracklet)
unsigned int layerdisk() const
VarAdjustK der_phiL_final
IMATH_TrackletCalculatorOverlap * ITC_L1B1()
IMATH_TrackletCalculatorOverlap * ITC_L2F1()
double rmindiskvm() const
void addProj(Tracklet *tracklet)
std::ofstream & ofstream(std::string fname)
const FPGAWord & r() const
double krprojshiftdisk() const
Power< A, B >::type pow(const A &a, const B &b)
bool inSector(int iphi0, int irinv, double phi0approx, double rinvapprox)
bool writeMonitorData(std::string module) const
bool barrelSeeding(const Stub *innerFPGAStub, const L1TStub *innerStub, const Stub *outerFPGAStub, const L1TStub *outerStub)