14 using namespace trklet;
18 phimatchcuttable_(settings),
19 zmatchcuttable_(settings),
20 rphicutPStable_(settings),
21 rphicut2Stable_(settings),
22 rcutPStable_(settings),
23 rcut2Stable_(settings),
25 rinvbendlut_(settings),
95 if (output.find(
"matchout") != std::string::npos) {
104 throw cms::Exception(
"BadConfig") << __FILE__ <<
" " << __LINE__ <<
" could not find output: " <<
output;
112 if (input ==
"allstubin") {
118 if (input ==
"vmstubin") {
124 if (input ==
"projin") {
130 throw cms::Exception(
"BadConfig") << __FILE__ <<
" " << __LINE__ <<
" could not find input: " <<
input;
157 unsigned int countme = 0;
158 unsigned int countall = 0;
159 unsigned int countsel = 0;
160 unsigned int countinputproj = 0;
162 unsigned int iprojmem = 0;
167 unsigned int iproj = 0;
172 countinputproj += inputproj->nTracklets();
203 bool projdone =
false;
208 unsigned int iMEbest = 0;
209 int bestTCID = matchengines_[0].TCID();
210 bool meactive = matchengines_[0].active();
212 meactive = meactive || matchengines_[iME].active();
213 int tcid = matchengines_[iME].TCID();
214 if (tcid < bestTCID) {
220 if (!matchengines_[iMEbest].
empty()) {
221 std::pair<Tracklet*, const Stub*> candmatch = matchengines_[iMEbest].read();
223 const Stub* fpgastub = candmatch.second;
224 Tracklet* tracklet = candmatch.first;
226 if (oldTracklet !=
nullptr) {
231 oldTracklet = tracklet;
247 bool addedProjection =
false;
249 if (!matchengines_[iME].idle())
252 if ((!addedProjection) && matchengines_[iME].idle() && (!
inputProjBuffer_.empty())) {
265 matchengines_[iME].init(stubmem,
279 print && (iME == 0));
280 addedProjection =
true;
282 matchengines_[iME].step(print && iME == 0);
295 tmpProj__ = tmpProj_;
300 if (iprojmem < inputprojs_.size()) {
302 if (!projBuffNearFull) {
314 int overlapbits =
nvmbits_ + nextrabits;
316 unsigned int extrabits = fpgaphi.
bits(fpgaphi.
nbits() - overlapbits, nextrabits);
318 unsigned int ivmPlus = iphi;
326 unsigned int ivmMinus = iphi;
327 if (extrabits == 0 && iphi != 0) {
363 unsigned int projfinephi =
367 bool isPSseed = proj->
PSseed();
375 bool usefirstMinus = stubmem->
nStubsBin(ivmMinus * nbins + slot) != 0;
376 bool usesecondMinus = (second && (stubmem->
nStubsBin(ivmMinus * nbins + slot + 1) != 0));
377 bool usefirstPlus = ivmPlus != ivmMinus && stubmem->
nStubsBin(ivmPlus * nbins + slot) != 0;
378 bool usesecondPlus = ivmPlus != ivmMinus && (second && (stubmem->
nStubsBin(ivmPlus * nbins + slot + 1) != 0));
380 good_ = usefirstPlus || usesecondPlus || usefirstMinus || usesecondMinus;
403 }
while (iprojmem < inputprojs_.size() && inputprojs_[iprojmem]->nTracklets() == 0);
408 projdone =
true && !good_ && !good__;
421 <<
" " << countme <<
" " << countinputproj << endl;
437 int ir = fpgastub->
r().
value();
446 int ideltaz = fpgastub->
z().
value() - iz;
451 double phi = stub->
phi();
452 double r = stub->
r();
453 double z = stub->
z();
478 int seedindex = tracklet->
getISeed();
500 <<
layerdisk_ + 1 <<
" " << seedindex <<
" " << pt <<
" "
519 throw cms::Exception(
"LogicError") <<
"WARNING dphi and/or dphiapprox too large : " << dphi <<
" " << dphiapprox
549 assert(stub->
z() * tracklet->
t() > 0.0);
551 int sign = (tracklet->
t() > 0.0) ? 1 : -1;
557 int iz = fpgastub->
z().
value();
570 int ideltaphi = fpgastub->
phi().
value() - iphi;
572 int irstub = fpgastub->
r().
value();
590 ideltaphi += iphialphacor;
595 double phi = stub->
phi();
596 double z = stub->
z();
597 double r = stub->
r();
621 double deltar = r - rproj;
623 double dr = stub->
r() - rproj;
630 double drphi = dphi * stub->
r();
631 double drphiapprox = dphiapprox * stub->
r();
643 int seedindex = tracklet->
getISeed();
660 <<
abs(tracklet->
disk()) <<
" " << pt <<
" " << ideltaphi *
settings_.
kphi() * stub->
r() <<
" " << drphiapprox
666 bool imatch = (
std::abs(ideltaphi * irstub) < idrphicut) && (
std::abs(ideltar) < idrcut);
690 drphiapprox / stub->
r(),
const FPGAWord & stubindex() const
Log< level::Info, true > LogVerbatim
void initBendMatch(unsigned int layerdisk)
constexpr unsigned int N_RZBITS
double dphisectorHG() const
const FPGAWord & fpgafinerzvm() const
void initmatchcut(unsigned int layerdisk, MatchType type, unsigned int region)
constexpr T reduceRange(T x)
void addInput(MemoryBase *memory, std::string input) override
std::vector< MatchEngineUnit > matchengines_
const FPGAWord & fpgaphiproj() const
const FPGAWord & fpgaphiprojder() const
constexpr unsigned int NRINVBITS
void initProjectionBend(double k_phider, unsigned int idisk, unsigned int nrbits, unsigned int nphiderbits)
unsigned int nvmme(unsigned int layerdisk) const
unsigned int nTracklets() const
Projection & proj(int layerdisk)
Settings const & settings_
TrackletLUT phimatchcuttable_
unsigned int nphibitsstub(unsigned int layerdisk) const
double phiapprox(double phimin, double) const
std::vector< TrackletProjectionsMemory * > inputprojs_
constexpr unsigned int N_DSS_MOD
bool debugTracklet() const
double half2SmoduleWidth() const
static std::string const input
double rmean(unsigned int iLayer) const
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
U second(std::pair< T, U > const &p)
unsigned int projrinv() const
std::string const & getName() const
double zmean(unsigned int iDisk) const
std::string const & getName() const
const FPGAWord & fpgarzprojder() const
double kphiderdisk() const
std::vector< FullMatchMemory * > fullmatches_
unsigned int iphi() const
VarAdjustK der_phiD_final
unsigned int bits(unsigned int lsb, unsigned int nbit) const
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Abs< T >::type abs(const T &t)
Tracklet * getTracklet(unsigned int i)
IMATH_TrackletCalculator * ITC_L1L2()
unsigned int nallstubs(unsigned int layerdisk) const
unsigned int projfinephi() const
double rDSSouter(unsigned int iBin) const
CircularBuffer< ProjectionTemp > inputProjBuffer_
unsigned int maxStep(std::string module) const
unsigned int isPSmodule() const
Log< level::Warning, true > LogPrint
unsigned int nzbitsstub(unsigned int layerdisk) const
const FPGAWord & fpgarzbin1projvm() const
const FPGAWord & z() const
void initLayerDisk(unsigned int pos, int &layer, int &disk)
bool use(unsigned int nextrzbin, unsigned int nextiphibin) const
TrackletLUT rphicutPStable_
int lookup(unsigned int index) const
bool matchCalculator(Tracklet *tracklet, const Stub *fpgastub, bool print, unsigned int istep)
TrackletLUT rphicut2Stable_
int ialphafactinner_[N_DSS_MOD *2]
const FPGAWord & phi() const
bool stubtruthmatch(const L1TStub *stub)
void addOutput(MemoryBase *memory, std::string output) override
double rDSSinner(unsigned int iBin) const
constexpr unsigned int NFINEPHIBITS
unsigned int nbitsallstubs(unsigned int layerdisk) const
const FPGAWord & fpgarzproj() const
double phiprojderapprox() const
unsigned int getISeed(const std::string &name)
const FPGAWord & alpha() const
double rzprojapprox() const
void execute(unsigned int iSector, double phimin)
unsigned int nMatchEngines_
std::ofstream & ofstream(std::string fname)
static unsigned int const shift
void setBendIndex(int bendindex)
const FPGAWord & r() const
const FPGAWord & fpgarzbin2projvm() const
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
unsigned int nbitsvmme(unsigned int layerdisk) const
double krprojshiftdisk() const
std::vector< VMStubsMEMemory * > vmstubs_
double rzprojderapprox() const
AllStubsMemory * allstubs_
TrackletLUT zmatchcuttable_
int ialphafactouter_[N_DSS_MOD *2]
double phiprojapprox() const
unsigned int nStubsBin(unsigned int bin) const
constexpr unsigned int N_BITSMEMADDRESS
double phiprojder() const
Log< level::Error, true > LogProblem
virtual void FillLayerResidual(int, int, double, double, double, double, bool)
bool writeMonitorData(std::string module) const
unsigned int slot() const