19 using namespace trklet;
23 phimatchcuttable_(settings),
24 zmatchcuttable_(settings),
25 rphicutPStable_(settings),
26 rphicut2Stable_(settings),
27 rcutPStable_(settings),
28 rcut2Stable_(settings) {
80 if (output.substr(0, 8) ==
"matchout") {
87 throw cms::Exception(
"BadConfig") << __FILE__ <<
" " << __LINE__ <<
" could not find output " <<
output;
95 if (input ==
"allstubin") {
101 if (input ==
"allprojin") {
107 if (input.substr(0, 5) ==
"match" && input.substr(input.size() - 2, 2) ==
"in") {
113 throw cms::Exception(
"BadConfig") << __FILE__ <<
" " << __LINE__ <<
" could not find input " <<
input;
117 unsigned int countall = 0;
118 unsigned int countsel = 0;
124 for (
unsigned int j = 0;
j < mergedMatches.size();
j++) {
131 const Stub* fpgastub = mergedMatches[
j].second;
132 Tracklet* tracklet = mergedMatches[
j].first.first;
137 if (oldTracklet !=
nullptr) {
140 oldTracklet = tracklet;
147 int ir = fpgastub->
r().
value();
156 int ideltaz = fpgastub->
z().
value() - iz;
161 double phi = stub->
phi() - phioffset;
162 double r = stub->
r();
163 double z = stub->
z();
187 int seedindex = tracklet->
getISeed();
208 <<
"WARNING dphi and/or dphiapprox too large : " << dphi <<
" " << dphiapprox << endl;
215 <<
layerdisk_ + 1 <<
" " << seedindex <<
" " << pt <<
" "
243 mergedMatches[
j].second);
254 assert(stub->
z() * tracklet->
t() > 0.0);
256 int sign = (tracklet->
t() > 0.0) ? 1 : -1;
264 int iz = fpgastub->
z().
value();
283 int irstub = fpgastub->
r().
value();
287 if (
abs(disk) <= 2) {
297 int ideltar = (irstub >> 1) - ir;
302 ideltaphi += iphialphacor;
307 double phi = stub->
phi() - phioffset;
308 double z = stub->
z();
309 double r = stub->
r();
326 <<
"\n stub " << stub->
z() <<
" disk " << disk <<
" " <<
dz;
333 double deltar = r - rproj;
335 double dr = stub->
r() - rproj;
343 double drphi = dphi * stub->
r();
344 double drphiapprox = dphiapprox * stub->
r();
355 int seedindex = tracklet->
getISeed();
375 << pt <<
" " << ideltaphi *
settings_.
kphi() * stub->
r() <<
" " << drphiapprox <<
" " << drphicut <<
" "
381 imatch = (
std::abs(ideltaphi * irstub) < idrphicut) && (
std::abs(ideltar) < idrcut);
383 edm::LogProblem(
"Tracklet") <<
"WARNING dphi and/or dphiapprox too large : " << dphi <<
" " << dphiapprox
384 <<
"dphi " << dphi <<
" Seed / ISeed " << tracklet->
getISeed() << endl;
406 drphiapprox / stub->
r(),
428 vector<CandidateMatchMemory*>& candmatch) {
429 std::vector<std::pair<std::pair<Tracklet*, int>,
const Stub*> >
tmp;
431 std::vector<unsigned int> indexArray;
432 indexArray.reserve(candmatch.size());
433 for (
unsigned int i = 0;
i < candmatch.size();
i++) {
434 indexArray.push_back(0);
439 int bestSector = 100;
442 for (
unsigned int i = 0;
i < candmatch.size();
i++) {
443 if (indexArray[
i] >= candmatch[
i]->nMatches()) {
447 int TCID = candmatch[
i]->getMatch(indexArray[
i]).first.first->TCID();
456 if (dSector < bestSector) {
457 bestSector = dSector;
461 if (dSector == bestSector) {
462 if (TCID < bestTCID || bestTCID < 0) {
468 if (bestIndex != -1) {
469 tmp.push_back(candmatch[bestIndex]->getMatch(indexArray[bestIndex]));
470 indexArray[bestIndex]++;
472 }
while (bestIndex != -1);
479 for (
unsigned int i = 1;
i < tmp.size();
i++) {
480 if (lastTCID > tmp[
i].
first.first->TCID()) {
481 edm::LogProblem(
"Tracklet") <<
"Wrong TCID ordering for projections in " <<
getName() <<
" last " << lastTCID
482 <<
" " << tmp[
i].first.first->TCID();
485 lastTCID = tmp[
i].first.first->TCID();
490 for (
unsigned int i = 1;
i < tmp.size();
i++) {
492 <<
" " << tmp[
i].first.first->TCID();
497 for (
unsigned int i = 0;
i < tmp.size();
i++) {
503 assert(tmp[
i - 1].
first.first->TCID() <= tmp[
i].first.first->TCID());
const FPGAWord & stubindex() const
Log< level::Info, true > LogVerbatim
double dphisectorHG() const
TrackletLUT rphicutPStable_
void execute(double phioffset)
std::vector< std::pair< std::pair< Tracklet *, int >, const Stub * > > mergeMatches(std::vector< CandidateMatchMemory * > &candmatch)
TrackletLUT rphicut2Stable_
void initmatchcut(unsigned int layerdisk, MatchType type, unsigned int region)
constexpr T reduceRange(T x)
const FPGAWord & fpgaphiproj() const
const FPGAWord & fpgaphiprojder() const
Projection & proj(int layerdisk)
Settings const & settings_
double phiapprox(double phimin, double) const
int PS_zderL_shift() const
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)
U second(std::pair< T, U > const &p)
void addOutput(MemoryBase *memory, std::string output) override
std::string const & getName() const
double zmean(unsigned int iDisk) const
std::string const & getName() const
const FPGAWord & fpgarzprojder() const
int SS_zderL_shift() const
AllStubsMemory * allstubs_
std::vector< CandidateMatchMemory * > matches_
AllProjectionsMemory * allprojs_
unsigned int nrbitsstub(unsigned int layerdisk) const
Abs< T >::type abs(const T &t)
unsigned int nallstubs(unsigned int layerdisk) const
double rDSSouter(unsigned int iBin) const
unsigned int maxStep(std::string module) const
unsigned int isPSmodule() const
unsigned int nzbitsstub(unsigned int layerdisk) const
const FPGAWord & z() const
void initLayerDisk(unsigned int pos, int &layer, int &disk)
int lookup(unsigned int index) const
constexpr unsigned int N_SECTOR
constexpr unsigned int N_PSLAYER
const FPGAWord & phi() const
bool stubtruthmatch(const L1TStub *stub)
double rDSSinner(unsigned int iBin) const
void addInput(MemoryBase *memory, std::string input) override
const FPGAWord & fpgarzproj() const
double phiprojderapprox() const
int ialphafactouter_[N_DSS_MOD *2]
unsigned int getISeed(const std::string &name)
const FPGAWord & alpha() const
double rzprojapprox() const
TrackletLUT zmatchcuttable_
std::ofstream & ofstream(std::string fname)
const FPGAWord & r() const
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
double krprojshiftdisk() const
double rzprojderapprox() const
int ialphafactinner_[N_DSS_MOD *2]
std::vector< FullMatchMemory * > fullMatches_
double phiprojapprox() const
double phiprojder() const
Log< level::Error, true > LogProblem
virtual void FillLayerResidual(int, int, double, double, double, double, bool)
bool writeMonitorData(std::string module) const
TrackletLUT phimatchcuttable_