34 phimatchcuttable_(settings),
35 zmatchcuttable_(settings),
36 rphicutPStable_(settings),
37 rphicut2Stable_(settings),
38 rcutPStable_(settings),
39 rcut2Stable_(settings),
40 alphainner_(settings),
41 alphaouter_(settings),
99 if (
output.substr(0, 8) ==
"matchout") {
106 throw cms::Exception(
"BadConfig") << __FILE__ <<
" " << __LINE__ <<
" could not find output " <<
output;
114 if (
input ==
"allstubin") {
120 if (
input ==
"allprojin") {
126 if (
input.substr(0, 5) ==
"match" &&
input.substr(
input.size() - 2, 2) ==
"in") {
132 throw cms::Exception(
"BadConfig") << __FILE__ <<
" " << __LINE__ <<
" could not find input " <<
input;
136 unsigned int countall = 0;
137 unsigned int countsel = 0;
148 unsigned int mergedepth = 3;
153 int best_ideltaphi_barrel = 0xFFFF;
154 int best_ideltaz_barrel = 0xFFFF;
155 int best_ideltaphi_disk = 0xFFFF;
156 int best_ideltar_disk = 0xFFFF;
157 unsigned int curr_projid = -1;
158 unsigned int next_projid = -1;
160 for (
unsigned int j = 0;
j < maxProc;
j++) {
167 const Stub* fpgastub = mergedMatches[
j].second;
168 Tracklet* tracklet = mergedMatches[
j].first.first;
173 if (oldTracklet !=
nullptr) {
176 oldTracklet = tracklet;
183 int ir = fpgastub->
r().
value();
184 int iphi =
proj.fpgaphiproj().value();
188 int iz =
proj.fpgarzproj().value();
192 int ideltaz = fpgastub->
z().
value() - iz;
197 double phi = stub->
phi() - phioffset;
198 double r = stub->
r();
199 double z = stub->
z();
217 double dz = z - (
proj.rzproj() + dr *
proj.rzprojder());
221 double dzapprox = z - (
proj.rzprojapprox() + dr *
proj.rzprojderapprox());
223 int seedindex = tracklet->
getISeed();
224 unsigned int projindex = mergedMatches[
j].first.second;
225 curr_projid = next_projid;
226 next_projid = projindex;
229 bool newtracklet = (
j == 0 || projindex != curr_projid);
231 best_ideltar_disk = (1 << (fpgastub->
r().
nbits() - 1));
257 <<
"WARNING dphi and/or dphiapprox too large : " << dphi <<
" " << dphiapprox << endl;
264 <<
layerdisk_ + 1 <<
" " << seedindex <<
" " <<
pt <<
" " 273 bool imatch = (
std::abs(ideltaphi) <= best_ideltaphi_barrel) && (ideltaz *
fact_ < best_ideltaz_barrel) &&
274 (ideltaz *
fact_ >= -best_ideltaz_barrel);
277 best_ideltaphi_barrel =
std::abs(ideltaphi);
298 mergedMatches[
j].second);
308 assert(stub->
z() * tracklet->
t() > 0.0);
310 int sign = (tracklet->
t() > 0.0) ? 1 : -1;
318 int iz = fpgastub->
z().
value();
319 int iphi =
proj.fpgaphiproj().value();
323 int iphicorr = (iz *
proj.fpgaphiprojder().value()) >> shifttmp;
327 int ir =
proj.fpgarzproj().value();
331 int ircorr = (iz *
proj.fpgarzprojder().value()) >> shifttmp2;
337 int irstub = fpgastub->
r().
value();
341 if (
abs(disk) <= 2) {
351 int ideltar = (irstub >> 1) - ir;
356 ideltaphi += iphialphacor;
361 double phi = stub->
phi() - phioffset;
362 double z = stub->
z();
363 double r = stub->
r();
380 <<
"\n stub " << stub->
z() <<
" disk " << disk <<
" " <<
dz;
383 double phiproj =
proj.phiproj() +
dz *
proj.phiprojder();
385 double rproj =
proj.rzproj() +
dz *
proj.rzprojder();
387 double deltar = r - rproj;
389 double dr = stub->
r() - rproj;
395 double drapprox = stub->
r() - (
proj.rzprojapprox() +
dz *
proj.rzprojderapprox());
397 double drphi = dphi * stub->
r();
398 double drphiapprox = dphiapprox * stub->
r();
409 int seedindex = tracklet->
getISeed();
418 unsigned int projindex = mergedMatches[
j].first.second;
419 curr_projid = next_projid;
420 next_projid = projindex;
422 bool newtracklet = (
j == 0 || projindex != curr_projid);
425 best_ideltaphi_disk = idrphicut;
426 best_ideltar_disk = idrcut;
440 <<
pt <<
" " << ideltaphi *
settings_.
kphi() * stub->
r() <<
" " << drphiapprox <<
" " << drphicut <<
" " 448 imatch = (
std::abs(ideltaphi) * irstub < best_ideltaphi_disk) && (
std::abs(ideltar) < best_ideltar_disk);
451 best_ideltaphi_disk =
std::abs(ideltaphi) * irstub;
452 best_ideltar_disk =
std::abs(ideltar);
455 edm::LogProblem(
"Tracklet") <<
"WARNING dphi and/or dphiapprox too large : " << dphi <<
" " << dphiapprox
456 <<
"dphi " << dphi <<
" Seed / ISeed " << tracklet->
getISeed() << endl;
478 drphiapprox / stub->
r(),
501 vector<CandidateMatchMemory*>& candmatch) {
502 std::vector<std::pair<std::pair<Tracklet*, int>,
const Stub*> >
tmp;
504 std::vector<unsigned int> indexArray;
505 indexArray.reserve(candmatch.size());
506 for (
unsigned int i = 0;
i < candmatch.size();
i++) {
507 indexArray.push_back(0);
512 int bestSector = 100;
515 for (
unsigned int i = 0;
i < candmatch.size();
i++) {
516 if (indexArray[
i] >= candmatch[
i]->nMatches()) {
520 int TCID = candmatch[
i]->getMatch(indexArray[
i]).first.first->TCID();
529 if (dSector < bestSector) {
530 bestSector = dSector;
534 if (dSector == bestSector) {
535 if (TCID < bestTCID || bestTCID < 0) {
541 if (bestIndex != -1) {
542 tmp.push_back(candmatch[bestIndex]->getMatch(indexArray[bestIndex]));
543 indexArray[bestIndex]++;
545 }
while (bestIndex != -1);
552 for (
unsigned int i = 1;
i <
tmp.size();
i++) {
553 if (lastTCID >
tmp[
i].
first.first->TCID()) {
554 edm::LogProblem(
"Tracklet") <<
"Wrong TCID ordering for projections in " <<
getName() <<
" last " << lastTCID
555 <<
" " <<
tmp[
i].first.first->TCID();
558 lastTCID =
tmp[
i].first.first->TCID();
563 for (
unsigned int i = 1;
i <
tmp.size();
i++) {
565 <<
" " <<
tmp[
i].first.first->TCID();
570 for (
unsigned int i = 0;
i <
tmp.size();
i++) {
Log< level::Info, true > LogVerbatim
TrackletLUT rphicutPStable_
unsigned int maxStep(std::string module) const
const FPGAWord & r() const
int PS_zderL_shift() const
unsigned int nrbitsstub(unsigned int layerdisk) const
TrackletLUT rphicut2Stable_
void initmatchcut(unsigned int layerdisk, MatchType type, unsigned int region)
double rDSSinner(unsigned int iBin) const
constexpr T reduceRange(T x)
double phiapprox(double phimin, double) const
const FPGAWord & z() const
double dphisectorHG() const
Projection & proj(int layerdisk)
Settings const & settings_
int lookup(unsigned int index) const
constexpr unsigned int N_DSS_MOD
static std::string const input
unsigned int isPSmodule() 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
double half2SmoduleWidth() const
unsigned int nzbitsstub(unsigned int layerdisk) const
double rmean(unsigned int iLayer) const
AllStubsMemory * allstubs_
std::vector< CandidateMatchMemory * > matches_
AllProjectionsMemory * allprojs_
double rDSSouter(unsigned int iBin) const
Abs< T >::type abs(const T &t)
bool writeMonitorData(std::string module) const
double zmean(unsigned int iDisk) const
void initLayerDisk(unsigned int pos, int &layer, int &disk)
const FPGAWord & stubindex() const
unsigned int nallstubs(unsigned int layerdisk) const
bool debugTracklet() const
constexpr unsigned int N_SECTOR
std::vector< std::pair< std::pair< Tracklet *, int >, const Stub * > > mergeMatches(std::vector< CandidateMatchMemory *> &candmatch)
constexpr unsigned int N_PSLAYER
void execute(unsigned int iSector, double phioffset)
bool stubtruthmatch(const L1TStub *stub)
void addInput(MemoryBase *memory, std::string input) override
int ialphafactouter_[N_DSS_MOD *2]
unsigned int getISeed(const std::string &name)
const FPGAWord & alpha() const
TrackletLUT zmatchcuttable_
std::ofstream & ofstream(std::string fname)
double krprojshiftdisk() const
const FPGAWord & phi() const
int ialphafactinner_[N_DSS_MOD *2]
std::string const & getName() const
int SS_zderL_shift() const
std::vector< FullMatchMemory * > fullMatches_
Log< level::Error, true > LogProblem
TrackletLUT phimatchcuttable_