|
|
Go to the documentation of this file.
21 MatchCalculator::MatchCalculator(
string name,
Settings const& settings,
Globals* global,
unsigned int iSector)
48 for (
unsigned int iSeed = 0; iSeed <
N_SEED; iSeed++) {
65 throw cms::Exception(
"BadDir") << __FILE__ <<
" " << __LINE__ <<
" could not create directory "
70 ofstream outphicut(filephicut);
72 throw cms::Exception(
"BadFile") << __FILE__ <<
" " << __LINE__ <<
" could not create file " << filephicut;
74 outphicut <<
"{" << endl;
75 for (
unsigned int seedindex = 0; seedindex <
N_SEED; seedindex++) {
77 outphicut <<
"," << endl;
80 outphicut << endl <<
"};" << endl;
84 ofstream outzcut(filezcut);
86 throw cms::Exception(
"BadFile") << __FILE__ <<
" " << __LINE__ <<
" could not create file " << filezcut;
88 outzcut <<
"{" << endl;
89 for (
unsigned int seedindex = 0; seedindex <
N_SEED; seedindex++) {
91 outzcut <<
"," << endl;
94 outzcut << endl <<
"};" << endl;
102 throw cms::Exception(
"BadDir") << __FILE__ <<
" " << __LINE__ <<
" could not create directory "
107 ofstream outPSphicut(filePSphicut);
108 if (outPSphicut.fail())
109 throw cms::Exception(
"BadFile") << __FILE__ <<
" " << __LINE__ <<
" could not create file " << filePSphicut;
110 outPSphicut <<
"{" << endl;
111 for (
unsigned int seedindex = 0; seedindex <
N_SEED; seedindex++) {
113 outPSphicut <<
"," << endl;
116 outPSphicut << endl <<
"};" << endl;
120 ofstream out2Sphicut(file2Sphicut);
121 if (out2Sphicut.fail())
122 throw cms::Exception(
"BadFile") << __FILE__ <<
" " << __LINE__ <<
" could not create file " << file2Sphicut;
123 out2Sphicut <<
"{" << endl;
124 for (
unsigned int seedindex = 0; seedindex <
N_SEED; seedindex++) {
126 out2Sphicut <<
"," << endl;
129 out2Sphicut << endl <<
"};" << endl;
133 ofstream outPSrcut(filePSrcut);
134 if (outPSrcut.fail())
135 throw cms::Exception(
"BadFile") << __FILE__ <<
" " << __LINE__ <<
" could not create file " << filePSrcut;
136 outPSrcut <<
"{" << endl;
137 for (
unsigned int seedindex = 0; seedindex <
N_SEED; seedindex++) {
139 outPSrcut <<
"," << endl;
140 outPSrcut <<
rcutPS_[seedindex];
142 outPSrcut << endl <<
"};" << endl;
146 ofstream out2Srcut(file2Srcut);
147 if (out2Srcut.fail())
148 throw cms::Exception(
"BadFile") << __FILE__ <<
" " << __LINE__ <<
" could not create file " << file2Srcut;
149 out2Srcut <<
"{" << endl;
150 for (
unsigned int seedindex = 0; seedindex <
N_SEED; seedindex++) {
152 out2Srcut <<
"," << endl;
153 out2Srcut <<
rcut2S_[seedindex];
155 out2Srcut << endl <<
"};" << endl;
174 if (
output.substr(0, 8) ==
"matchout") {
175 auto*
tmp = dynamic_cast<FullMatchMemory*>(
memory);
181 throw cms::Exception(
"BadConfig") << __FILE__ <<
" " << __LINE__ <<
" could not find output " <<
output;
189 if (
input ==
"allstubin") {
190 auto*
tmp = dynamic_cast<AllStubsMemory*>(
memory);
195 if (
input ==
"allprojin") {
196 auto*
tmp = dynamic_cast<AllProjectionsMemory*>(
memory);
201 if (
input.substr(0, 5) ==
"match" &&
input.substr(
input.size() - 2, 2) ==
"in") {
202 auto*
tmp = dynamic_cast<CandidateMatchMemory*>(
memory);
207 throw cms::Exception(
"BadConfig") << __FILE__ <<
" " << __LINE__ <<
" could not find input " <<
input;
211 unsigned int countall = 0;
212 unsigned int countsel = 0;
218 for (
unsigned int j = 0;
j < mergedMatches.size();
j++) {
225 const Stub* fpgastub = mergedMatches[
j].second;
226 Tracklet* tracklet = mergedMatches[
j].first.first;
231 if (oldTracklet !=
nullptr) {
234 oldTracklet = tracklet;
239 int ir = fpgastub->
r().
value();
248 int ideltaz = fpgastub->
z().
value() - iz;
254 double r = stub->
r();
255 double z = stub->
z();
281 int seedindex = tracklet->
getISeed();
300 edm::LogProblem(
"Tracklet") <<
"WARNING dphi and/or dphiapprox too large : " << dphi <<
" " << dphiapprox
310 <<
layerdisk_ + 1 <<
" " << seedindex <<
" " <<
pt <<
" "
338 mergedMatches[
j].second);
350 assert(stub->
z() * tracklet->
t() > 0.0);
352 int sign = (tracklet->
t() > 0.0) ? 1 : -1;
358 int iz = fpgastub->
z().
value();
377 int irstub = fpgastub->
r().
value();
381 if (
abs(disk) <= 2) {
391 int ideltar = (irstub >> 1) - ir;
396 ideltaphi += iphialphacor;
402 double z = stub->
z();
403 double r = stub->
r();
421 <<
"\n stub " << stub->
z() <<
" disk " << disk <<
" " <<
dz;
430 double dr = stub->
r() - rproj;
439 double drphi = dphi * stub->
r();
440 double drphiapprox = dphiapprox * stub->
r();
451 int seedindex = tracklet->
getISeed();
454 int idrcut =
rcutPS_[seedindex];
470 <<
pt <<
" " << ideltaphi *
settings_.
kphi() * stub->
r() <<
" " << drphiapprox <<
" " << drphicut <<
" "
476 imatch = (
std::abs(ideltaphi * irstub) < idrphicut) && (
std::abs(ideltar) < idrcut);
478 edm::LogProblem(
"Tracklet") <<
"WARNING dphi and/or dphiapprox too large : " << dphi <<
" " << dphiapprox
479 <<
"dphi " << dphi <<
" Seed / ISeed " << tracklet->
getISeed() << endl;
501 drphiapprox / stub->
r(),
525 vector<CandidateMatchMemory*>& candmatch) {
526 std::vector<std::pair<std::pair<Tracklet*, int>,
const Stub*> >
tmp;
528 std::vector<unsigned int> indexArray;
529 indexArray.reserve(candmatch.size());
530 for (
unsigned int i = 0;
i < candmatch.size();
i++) {
531 indexArray.push_back(0);
536 int bestSector = 100;
539 for (
unsigned int i = 0;
i < candmatch.size();
i++) {
540 if (indexArray[
i] >= candmatch[
i]->nMatches()) {
544 int TCID = candmatch[
i]->getMatch(indexArray[
i]).first.first->TCID();
553 if (dSector < bestSector) {
554 bestSector = dSector;
558 if (dSector == bestSector) {
559 if (TCID < bestTCID || bestTCID < 0) {
565 if (bestIndex != -1) {
566 tmp.push_back(candmatch[bestIndex]->getMatch(indexArray[bestIndex]));
567 indexArray[bestIndex]++;
569 }
while (bestIndex != -1);
576 for (
unsigned int i = 1;
i <
tmp.size();
i++) {
577 if (lastTCID >
tmp[
i].
first.first->TCID()) {
578 edm::LogProblem(
"Tracklet") <<
"Wrong TCID ordering for projections in " <<
getName() <<
" last " << lastTCID
579 <<
" " <<
tmp[
i].first.first->TCID();
582 lastTCID =
tmp[
i].first.first->TCID();
587 for (
unsigned int i = 1;
i <
tmp.size();
i++) {
589 <<
" " <<
tmp[
i].first.first->TCID();
594 for (
unsigned int i = 0;
i <
tmp.size();
i++) {
constexpr unsigned int N_PSLAYER
bool stubtruthmatch(const L1TStub *stub)
const FPGAWord & fpgaphiprojder(int layer) const
unsigned int rphicutPS_[N_SEED]
double rphimatchcut(unsigned int iSeed, unsigned int ilayer) const
static const std::string input
double krprojshiftdisk() const
const FPGAWord & fpgaphiprojdisk(int disk) const
const FPGAWord & phi() const
double rprojderdisk(int disk) const
constexpr unsigned int N_SECTOR
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
Settings const & settings_
double phiapprox(double phimin, double) const
void addInput(MemoryBase *memory, std::string input) override
double rDSSinner(unsigned int iBin) const
double half2SmoduleWidth() const
unsigned int rphicut2S_[N_SEED]
unsigned int rcutPS_[N_SEED]
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
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)
AllProjectionsMemory * allprojs_
const FPGAWord & fpgazproj(int layer) const
const FPGAWord & z() const
double rprojdisk(int disk) const
unsigned int isPSmodule() const
Log< level::Error, true > LogProblem
double rcut2S(unsigned int iSeed, unsigned int idisk) const
int ialphafactouter_[N_DSS_MOD *2]
void addOutput(MemoryBase *memory, std::string output) override
double phiprojder(int layer) const
double zmean(unsigned int iDisk) const
std::vector< FullMatchMemory * > fullMatches_
double phiprojderapprox(int layer) const
double rproj(int layer) const
unsigned int phimatchcut_[N_SEED]
double zproj(int layer) const
double phiprojderapproxdisk(int disk) const
double zprojderapprox(int layer) const
void initLayerDisk(unsigned int pos, int &layer, int &disk)
constexpr unsigned int N_SEED
double rcutPS(unsigned int iSeed, unsigned int idisk) const
const FPGAWord & alphanew() const
constexpr unsigned int N_DSS_MOD
std::vector< CandidateMatchMemory * > matches_
unsigned int nzbitsstub(unsigned int layerdisk) const
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
double phiprojdisk(int disk) const
double phiprojapproxdisk(int disk) const
double rprojderapproxdisk(int disk) const
double alpha(double pitch) const
double stripPitch(bool isPSmodule) const
unsigned int getISeed(const std::string &name)
bool writeMonitorData(std::string module) const
int SS_zderL_shift() const
std::ofstream & ofstream(std::string fname)
std::string const & tablePath() const
Log< level::Info, true > LogVerbatim
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
bool debugTracklet() const
double zmatchcut(unsigned int iSeed, unsigned int ilayer) const
int ialphafactinner_[N_DSS_MOD *2]
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
Abs< T >::type abs(const T &t)
const FPGAWord & fpgaphiprojderdisk(int disk) const
double phiprojderdisk(int disk) const
AllStubsMemory * allstubs_
unsigned int zmatchcut_[N_SEED]
unsigned int rcut2S_[N_SEED]
double phiprojapprox(int layer) const
std::vector< std::pair< std::pair< Tracklet *, int >, const Stub * > > mergeMatches(std::vector< CandidateMatchMemory * > &candmatch)
double zprojapprox(int layer) const
constexpr T reduceRange(T x)