17 TrackletCalculatorBase::TrackletCalculatorBase(
string name,
Settings const& settings,
Globals* global)
35 double phiprojdisk[
N_DISK],
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++) {
88 double phiproj[
N_DISK - 2],
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++) {
141 double phiproj[
N_DISK - 2],
143 double phider[
N_DISK - 2],
144 double rder[
N_DISK - 2]) {
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);
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();
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);
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();
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 <<
" " 1084 ofstream
fout(
"seeds.txt", ofstream::app);
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) {
1163 z1 = innerFPGAStub->
zapprox();
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);
1459 for (
unsigned int disk = 2; disk < 6; disk++) {
1460 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
bool calculate(int debug_level)
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
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)
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
Power< A, B >::type pow(const A &a, const B &b)
bool validProj(int layerdisk) const
bool inSector(int iphi0, int irinv, double phi0approx, double rinvapprox)
bool barrelSeeding(const Stub *innerFPGAStub, const L1TStub *innerStub, const Stub *outerFPGAStub, const L1TStub *outerStub)