|
|
Go to the documentation of this file.
16 MatchProcessor::MatchProcessor(
string name,
Settings const& settings,
Globals* global,
unsigned int iSector)
17 :
ProcessBase(
name, settings, global, iSector), fullmatches_(12), inputProjBuffer_(3) {
50 for (
unsigned int iSeed = 0; iSeed < 12; iSeed++) {
68 throw cms::Exception(
"BadDir") << __FILE__ <<
" " << __LINE__ <<
" could not create directory "
73 ofstream outphicut(filephicut);
75 throw cms::Exception(
"BadFile") << __FILE__ <<
" " << __LINE__ <<
" could not create file " << filephicut;
77 outphicut <<
"{" << endl;
78 for (
unsigned int seedindex = 0; seedindex < 12; seedindex++) {
80 outphicut <<
"," << endl;
83 outphicut << endl <<
"};" << endl;
87 ofstream outzcut(filezcut);
89 throw cms::Exception(
"BadFile") << __FILE__ <<
" " << __LINE__ <<
" could not create file " << filezcut;
91 outzcut <<
"{" << endl;
92 for (
unsigned int seedindex = 0; seedindex <
N_SEED; seedindex++) {
94 outzcut <<
"," << endl;
97 outzcut << endl <<
"};" << endl;
102 unsigned int nbits = 3;
106 for (
unsigned int irinv = 0; irinv < 32; irinv++) {
111 for (
unsigned int ibend = 0; ibend < (
unsigned int)(1 <<
nbits); ibend++) {
122 throw cms::Exception(
"BadDir") << __FILE__ <<
" " << __LINE__ <<
" could not create directory "
127 string fname =
"METable_L";
131 ofstream
out(full_fname);
133 throw cms::Exception(
"BadFile") << __FILE__ <<
" " << __LINE__ <<
" could not create file " << full_fname;
136 for (
unsigned int i = 0;
i <
table_.size();
i++) {
148 for (
unsigned int iprojbend = 0; iprojbend < 32; iprojbend++) {
149 double projbend = 0.5 * (iprojbend - 15.0);
150 for (
unsigned int ibend = 0; ibend < 8; ibend++) {
155 for (
unsigned int ibend = 0; ibend < 16; ibend++) {
196 if (
output.find(
"matchout") != std::string::npos) {
197 auto*
tmp = dynamic_cast<FullMatchMemory*>(
memory);
205 throw cms::Exception(
"BadConfig") << __FILE__ <<
" " << __LINE__ <<
" could not find output: " <<
output;
213 if (
input ==
"allstubin") {
214 auto*
tmp = dynamic_cast<AllStubsMemory*>(
memory);
219 if (
input ==
"vmstubin") {
220 auto*
tmp = dynamic_cast<VMStubsMEMemory*>(
memory);
225 if (
input ==
"projin") {
226 auto*
tmp = dynamic_cast<TrackletProjectionsMemory*>(
memory);
231 throw cms::Exception(
"BadConfig") << __FILE__ <<
" " << __LINE__ <<
" could not find input: " <<
input;
259 unsigned int countme = 0;
260 unsigned int countall = 0;
261 unsigned int countsel = 0;
262 unsigned int countinputproj = 0;
264 unsigned int iprojmem = 0;
265 unsigned int iproj = 0;
277 unsigned int step2delay = 0;
278 unsigned int step3delay = 0;
280 for (
unsigned int istep = 0; istep <
settings_.
maxStep(
"MP") + step3delay; istep++) {
281 bool projdone =
false;
292 }
else if (iproj < projMem->nTracklets()) {
314 int phiderindex = (
proj->fpgaphiprojderdisk(
disk_).value() >>
318 int signindex = (
proj->fpgarprojderdisk(
disk_).value() < 0);
332 unsigned int projfinephi =
333 (fpgaphi.
value() >> (fpgaphi.
nbits() - (
nvmbits_ + nfinephi))) & ((1 << nfinephi) - 1);
336 bool isPSseed =
proj->PSseed() == 1;
349 }
else if (usesecond) {
369 bool addedProjection =
false;
395 addedProjection =
true;
403 if (istep >= step3delay) {
406 bool bestInPipeline =
false;
415 bestTCID = currentTCID;
416 bestInPipeline =
empty;
421 const std::pair<Tracklet*, const Stub*>& candmatch =
matchengines_[iMEbest].read();
423 const Stub* fpgastub = candmatch.second;
424 Tracklet* tracklet = candmatch.first;
426 if (oldTracklet !=
nullptr) {
430 oldTracklet = tracklet;
443 if ((projdone && medone) || (istep ==
settings_.
maxStep(
"MP") + step3delay - 1)) {
444 globals_->
ofstream(
"matchprocessor.txt") <<
getName() <<
" " << istep <<
" " << countall <<
" " << countsel <<
" "
445 << countme <<
" " << countinputproj << endl;
459 int ir = fpgastub->
r().
value();
468 int ideltaz = fpgastub->
z().
value() - iz;
473 double phi = stub->
phi();
474 double r = stub->
r();
475 double z = stub->
z();
501 int seedindex = tracklet->
getISeed();
523 <<
layer_ <<
" " << seedindex <<
" " <<
pt <<
" "
540 edm::LogPrint(
"Tracklet") <<
"WARNING dphi and/or dphiapprox too large : " << dphi <<
" " << dphiapprox;
574 assert(stub->
z() * tracklet->
t() > 0.0);
576 int sign = (tracklet->
t() > 0.0) ? 1 : -1;
582 int iz = fpgastub->
z().
value();
601 int irstub = fpgastub->
r().
value();
619 ideltaphi += iphialphacor;
624 double phi = stub->
phi();
625 double z = stub->
z();
626 double r = stub->
r();
653 double dr = stub->
r() - rproj;
660 double drphi = dphi * stub->
r();
661 double drphiapprox = dphiapprox * stub->
r();
673 int seedindex = tracklet->
getISeed();
676 int idrcut =
rcutPS_[seedindex];
690 <<
" " << ideltaphi *
settings_.
kphi() * stub->
r() <<
" " << drphiapprox <<
" " << drphicut <<
" "
695 bool imatch = (
std::abs(ideltaphi * irstub) < idrphicut) && (
std::abs(ideltar) < idrcut);
719 drphiapprox / stub->
r(),
constexpr unsigned int N_PSLAYER
bool stubtruthmatch(const L1TStub *stub)
const FPGAWord & fpgaphiprojder(int layer) const
double rphimatchcut(unsigned int iSeed, unsigned int ilayer) const
static const std::string input
double krprojshiftdisk() const
std::vector< VMStubsMEMemory * > vmstubs_
const FPGAWord & fpgaphiprojdisk(int disk) const
const FPGAWord & phi() const
double rprojderdisk(int disk) const
int ialphafactouter_[N_DSS_MOD *2]
unsigned int zmatchcut_[N_SEED]
Log< level::Warning, true > LogPrint
void addMatch(int layer, int ideltaphi, int ideltaz, double dphi, double dz, double dphiapprox, double dzapprox, int stubid, double rstub, const trklet::Stub *stubptr)
U second(std::pair< T, U > const &p)
double rphicutPS(unsigned int iSeed, unsigned int idisk) const
double rmean(unsigned int iLayer) const
unsigned int nbits(unsigned int power)
Settings const & settings_
double phiapprox(double phimin, double) const
double rDSSinner(unsigned int iBin) const
double half2SmoduleWidth() const
unsigned int projfinephi() const
void addInput(MemoryBase *memory, std::string input) override
const FPGAWord & r() const
const FPGAWord & fpgarprojderdisk(int disk) const
unsigned int nrbitsstub(unsigned int layerdisk) const
const FPGAWord & fpgazprojder(int layer) const
double rDSSouter(unsigned int iBin) const
unsigned int iphi() const
std::vector< FullMatchMemory * > fullmatches_
void addMatchDisk(int disk, int ideltaphi, int ideltar, double dphi, double dr, double dphiapprox, double drapprox, double alpha, int stubid, double zstub, const trklet::Stub *stubptr)
const FPGAWord & fpgazproj(int layer) const
const FPGAWord & z() const
std::string const & getName() const
double rprojdisk(int disk) const
unsigned int isPSmodule() const
unsigned int projrinv() const
Log< level::Error, true > LogProblem
CircularBuffer< ProjectionTemp > inputProjBuffer_
double rcut2S(unsigned int iSeed, unsigned int idisk) const
std::vector< TrackletProjectionsMemory * > inputprojs_
unsigned int rcutPS_[N_SEED]
double phiprojder(int layer) const
double zmean(unsigned int iDisk) const
double phiprojderapprox(int layer) const
double rproj(int layer) const
double zproj(int layer) const
unsigned int rphicut2S_[N_SEED]
double phiprojderapproxdisk(int disk) const
bool matchCalculator(Tracklet *tracklet, const Stub *fpgastub)
constexpr std::array< uint8_t, layerIndexSize > layer
double zprojderapprox(int layer) const
void initLayerDisk(unsigned int pos, int &layer, int &disk)
double bendcutme(unsigned int layerdisk) const
unsigned int rphicutPS_[N_SEED]
constexpr unsigned int N_SEED
int ialphafactinner_[N_DSS_MOD *2]
unsigned int rcut2S_[N_SEED]
double rcutPS(unsigned int iSeed, unsigned int idisk) const
const FPGAWord & alphanew() const
double rinv(double phi1, double phi2, double r1, double r2)
constexpr unsigned int N_DSS_MOD
Tracklet * getTracklet(unsigned int i)
unsigned int nzbitsstub(unsigned int layerdisk) const
unsigned int nvmme(unsigned int layerdisk) const
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
std::vector< bool > tablePS_
double phiprojdisk(int disk) const
unsigned int nMatchEngines_
unsigned int slot() const
double phiprojapproxdisk(int disk) const
std::vector< bool > table2S_
double rprojderapproxdisk(int disk) const
double alpha(double pitch) const
unsigned int nTracklets() const
int bendLoookup(int diskindex, int bendindex)
double stripPitch(bool isPSmodule) const
unsigned int getISeed(const std::string &name)
ProjectionRouterBendTable *& projectionRouterBendTable()
bool writeMonitorData(std::string module) const
int SS_zderL_shift() const
std::ofstream & ofstream(std::string fname)
std::string const & tablePath() const
std::vector< bool > table_
Log< level::Info, true > LogVerbatim
double bend(double r, double rinv, double stripPitch)
AllStubsMemory * allstubs_
double zprojder(int layer) const
double phiproj(int layer) const
std::string const & getName() const
const FPGAWord & fpgaphiproj(int layer) const
const FPGAWord & stubindex() const
unsigned int nallstubs(unsigned int layerdisk) const
bool debugTracklet() const
double zmatchcut(unsigned int iSeed, unsigned int ilayer) const
void addOutput(MemoryBase *memory, std::string output) override
double rphicut2S(unsigned int iSeed, unsigned int idisk) const
const FPGAWord & fpgarprojdisk(int disk) const
unsigned int maxStep(std::string module) const
int PS_zderL_shift() const
double rprojapproxdisk(int disk) const
double benddecode(int ibend, bool isPS)
Abs< T >::type abs(const T &t)
const FPGAWord & fpgaphiprojderdisk(int disk) const
double phiprojderdisk(int disk) const
unsigned int phimatchcut_[N_SEED]
unsigned int nStubsBin(unsigned int bin) const
double phiprojapprox(int layer) const
double zprojapprox(int layer) const
std::vector< MatchEngineUnit > matchengines_
constexpr unsigned int NRINVBITS
constexpr T reduceRange(T x)