14 using namespace trklet;
18 const Stub* innerFPGAStub,
19 const Stub* middleFPGAStub,
20 const Stub* outerFPGAStub,
39 : settings_(settings) {
44 assert(!(disk && overlap));
53 if (
barrel_ && middleFPGAStub ==
nullptr)
75 for (
unsigned int i = 0;
i <
N_LAYER - 2;
i++) {
80 for (
unsigned int i = 0;
i <
N_DISK;
i++) {
85 for (
unsigned int i = 0;
i < N_LAYER - 2;
i++) {
94 for (
unsigned int i = 0;
i <
N_DISK;
i++) {
97 if (!projs[N_LAYER +
projdisk_[
i] - 1].valid())
110 set<int> tpsetstubinner;
111 set<int> tpsetstubouter;
114 for (
auto tp : tps) {
116 tpsetstubinner.insert(
tp);
117 tpset.insert(
abs(
tp));
122 for (
auto tp : tps) {
124 tpsetstubouter.insert(
tp);
125 tpset.insert(
abs(
tp));
129 for (
auto&
tp : tpset) {
130 if (tpsetstubinner.find(
tp) != tpsetstubinner.end() && tpsetstubinner.find(-
tp) != tpsetstubinner.end() &&
131 tpsetstubouter.find(
tp) != tpsetstubouter.end() && tpsetstubouter.find(-
tp) != tpsetstubouter.end()) {
141 set<int> tpsetstubinner;
142 set<int> tpsetstubouter;
144 vector<int> tps = stub->
tps();
145 for (
auto tp : tps) {
147 tpsetstub.insert(
tp);
148 tpset.insert(
abs(
tp));
152 for (
auto tp : tps) {
154 tpsetstubinner.insert(
tp);
155 tpset.insert(
abs(
tp));
159 for (
auto tp : tps) {
161 tpsetstubouter.insert(
tp);
162 tpset.insert(
abs(
tp));
166 for (
auto tp : tpset) {
167 if (tpsetstub.find(
tp) != tpsetstub.end() && tpsetstub.find(-
tp) != tpsetstub.end() &&
168 tpsetstubinner.find(
tp) != tpsetstubinner.end() && tpsetstubinner.find(-
tp) != tpsetstubinner.end() &&
169 tpsetstubouter.find(
tp) != tpsetstubouter.end() && tpsetstubouter.find(-
tp) != tpsetstubouter.end()) {
211 if (allstubindex >= (1 << 7)) {
212 edm::LogPrint(
"Tracklet") <<
"Warning projection number too large!";
213 index.
set((1 << 7) - 1, 7,
true, __LINE__, __FILE__);
215 index.
set(allstubindex, 7,
true, __LINE__, __FILE__);
227 int irinvvm = 16 + (tmp_irinv >> (nbits_irinv - 5));
230 edm::LogPrint(
"Tracklet") <<
"Warning irinvvm too large:" << irinvvm;
237 tmp.
set(irinvvm, 5,
true, __LINE__, __FILE__);
246 if (allstubindex >= (1 << 7)) {
247 edm::LogPrint(
"Tracklet") <<
"Warning projection number too large!";
248 index.
set((1 << 7) - 1, 7,
true, __LINE__, __FILE__);
250 index.
set(allstubindex, 7,
true, __LINE__, __FILE__);
305 resid_[layerdisk].
init(
settings_, layerdisk, ideltaphi, ideltarz, stubid, dphi, drz, dphiapprox, drzapprox, stubptr);
337 (isPS ? stubr.
str() : (
"00000000" + stubr.
str())) +
"|" +
344 std::vector<const L1TStub*>
tmp;
353 for (
const auto& iresid :
resid_) {
355 tmp.push_back(iresid.stubptr()->l1tstub());
362 std::map<int, int> stubIDs;
389 if (
resid_[N_LAYER +
i].valid()) {
397 stubIDs[-(N_LAYER +
N_DISK) -
i] =
resid_[N_LAYER +
i].fpgastubid().value() + location;
424 if (
i == 4 &&
resid_[1].valid())
527 double chisqrphifitexact,
528 double chisqrzfitexact,
537 const vector<const L1TStub*>& l1stubs) {
542 fitparsexact_.
init(rinvfitexact, phi0fitexact, d0fitexact, tfitexact, z0fitexact);
546 if (irinvfit > (1 << 14))
547 irinvfit = (1 << 14);
548 if (irinvfit <= -(1 << 14))
549 irinvfit = -(1 << 14) + 1;
550 fpgafitpars_.rinv().set(irinvfit, 15,
false, __LINE__, __FILE__);
551 fpgafitpars_.phi0().set(iphi0fit, 19,
false, __LINE__, __FILE__);
552 fpgafitpars_.d0().set(id0fit, 19,
false, __LINE__, __FILE__);
553 fpgafitpars_.t().set(itfit, 14,
false, __LINE__, __FILE__);
575 std::stringstream oss(
"");
576 if (!
resid_[layer].valid())
577 oss <<
"0|0000000|0000000000|0000000|000000000000|000000000";
585 oss <<
tmp.str() <<
"|";
598 std::stringstream oss(
"");
600 oss <<
"0|0000000|0000000000|000000000000|000000000000|0000000";
610 oss <<
tmp.str() <<
"|";
612 oss << (isPS ? stubr.str() : (
"00000000" + stubr.str())) <<
"|";
621 const unsigned maxNHits = 8;
622 const unsigned nBitsPerHit = 3;
623 vector<string> stub(maxNHits,
"0");
624 string hitmap(maxNHits * nBitsPerHit,
'0');
713 for (
unsigned i = 0;
i < maxNHits;
i++)
714 hitmap[
i * nBitsPerHit + 2] = stub[
i][0];
722 oss +=
tmp.str() +
"|";
728 for (
unsigned i = 0;
i < maxNHits;
i++)
732 oss +=
"|" + stub[
i];
748 vector<const L1TStub*>
tmp = l1stubs.empty() ?
getL1Stubs() : l1stubs;
750 vector<L1TStub> tmp2;
752 tmp2.reserve(tmp.size());
753 for (
auto stub : tmp) {
754 tmp2.push_back(*stub);
757 Track tmpTrack(ipars,
776 return (
l < 999 ?
l : 0);
790 return (
d < 999 ?
d : 0);
806 assert(iTC >= 0 && iTC <= 14);
TrackPars< FPGAWord > fpgapars_
const FPGAWord & stubindex() const
const FPGAWord & disk() const
const Stub * innerFPGAStub()
Projection proj_[N_LAYER+N_DISK]
const FPGAWord & fpgastubid() const
const FPGAWord & fpgafinerzvm() const
std::string fullmatchdiskstr(int disk)
unsigned int nbitsseed() const
const Stub * outerFPGAStub()
unsigned int projlayers(unsigned int iSeed, unsigned int i) const
std::string fullmatchstr(int layer)
const FPGAWord & fpgaphiproj() const
unsigned int ntrackletmax() const
const FPGAWord & fpgaphiprojder() const
constexpr unsigned int N_SEED
const Stub * stubptr() const
std::string vmstrlayer(int layer, unsigned int allstubindex)
Track makeTrack(const std::vector< const L1TStub * > &l1stubs)
const FPGAWord & layer() const
unsigned int projdisks(unsigned int iSeed, unsigned int i) const
std::string phiregionaddressstr() const
TrackPars< double > trackparsapprox_
void init(Settings const &settings, unsigned int layerdisk, int iphiresid, int irzresid, int istubid, double phiresid, double rzresid, double phiresidapprox, double rzresidapprox, const Stub *stubptr)
std::string vmstrdisk(int disk, unsigned int allstubindex)
void setTrackIndex(int index)
const FPGAWord & fpgafinephivm() const
const FPGAWord & getBendIndex() const
std::vector< const L1TStub * > getL1Stubs()
Settings const & settings_
void setFitPars(double rinvfit, double phi0fit, double d0fit, double tfit, double z0fit, double chisqrphifit, double chisqrzfit, double rinvfitexact, double phi0fitexact, double d0fitexact, double tfitexact, double z0fitexact, double chisqrphifitexact, double chisqrzfitexact, int irinvfit, int iphi0fit, int id0fit, int itfit, int iz0fit, int ichisqrphifit, int ichisqrzfit, int hitpattern, const std::vector< const L1TStub * > &l1stubs=std::vector< const L1TStub * >())
constexpr std::array< uint8_t, layerIndexSize > layer
bool overlap(const reco::Muon &muon1, const reco::Muon &muon2, double pullX=1.0, double pullY=1.0, bool checkAdjacentChambers=false)
void addMatch(unsigned int layerdisk, int ideltaphi, int ideltarz, double dphi, double drz, double dphiapprox, double drzapprox, int stubid, const trklet::Stub *stubptr)
unsigned int PSseed() const
TrackPars< double > fitpars_
const Stub * middleFPGAStub()
const FPGAWord & fpgarzprojder() const
std::string trackletprojstr(int layer) const
unsigned int nbitstrackletindex() const
TrackPars< FPGAWord > fpgafitpars_
Abs< T >::type abs(const T &t)
std::unique_ptr< Track > fpgatrack_
unsigned int nbitsitc() const
const std::string diskstubstr(const unsigned disk) const
Log< level::Warning, true > LogPrint
int projlayer_[N_LAYER-2]
const FPGAWord & fpgarzbin1projvm() const
unsigned int nbitstcindex() const
const FPGAWord & fpgarzresid() const
Residual resid_[N_LAYER+N_DISK]
static constexpr float d0
unsigned int nbitsd0() const
std::string trackletprojstrD(int disk) const
bool stubtruthmatch(const L1TStub *stub)
const std::string layerstubstr(const unsigned layer) const
void setTrackletIndex(unsigned int index)
double rinv(double phi1, double phi2, double r1, double r2)
void set(int value, int nbits, bool positive=true, int line=-1, const char *file=nullptr)
const FPGAWord & fpgarzproj() const
TrackPars< double > fitparsexact_
const FPGAWord & itfit() const
unsigned int layerdisk() const
unsigned int phiregionaddress() const
bool writeoutReal() const
unsigned int seedIndex() const
const Stub * outerFPGAStub_
unsigned int layer() const
std::string trackletparstr()
const FPGAWord & r() const
const FPGAWord & fpgarzbin2projvm() const
const Stub * innerFPGAStub_
std::vector< int > tps() const
std::string trackfitstr() const
const FPGAWord & fpgaphiresid() const
const Stub * middleFPGAStub_
static constexpr float d1
TrackPars< double > trackpars_
double chisqrphifitexact_
constexpr unsigned int N_BITSMEMADDRESS
void init(T rinv, T phi0, T d0, T t, T z0)
std::map< int, int > getStubIDs()