CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
trklet::MatchCalculator Class Reference

#include <MatchCalculator.h>

Inheritance diagram for trklet::MatchCalculator:
trklet::ProcessBase

Public Member Functions

void addInput (MemoryBase *memory, std::string input) override
 
void addOutput (MemoryBase *memory, std::string output) override
 
void execute (double phioffset)
 
 MatchCalculator (std::string name, Settings const &settings, Globals *global)
 
std::vector< std::pair< std::pair< Tracklet *, int >, const Stub * > > mergeMatches (std::vector< CandidateMatchMemory * > &candmatch)
 
 ~MatchCalculator () override=default
 
- Public Member Functions inherited from trklet::ProcessBase
unsigned int getISeed (const std::string &name)
 
std::string const & getName () const
 
unsigned int initLayerDisk (unsigned int pos)
 
void initLayerDisk (unsigned int pos, int &layer, int &disk)
 
void initLayerDisk (unsigned int pos, int &layer, int &disk, int &layerdisk)
 
void initLayerDisksandISeed (unsigned int &layerdisk1, unsigned int &layerdisk2, unsigned int &iSeed)
 
unsigned int nbits (unsigned int power)
 
 ProcessBase (std::string name, Settings const &settings, Globals *global)
 
virtual ~ProcessBase ()=default
 

Private Attributes

AllProjectionsMemoryallprojs_
 
AllStubsMemoryallstubs_
 
int fact_
 
std::vector< FullMatchMemory * > fullMatches_
 
int ialphafactinner_ [N_DSS_MOD *2]
 
int ialphafactouter_ [N_DSS_MOD *2]
 
int icorrshift_
 
int icorzshift_
 
unsigned int layerdisk_
 
std::vector< CandidateMatchMemory * > matches_
 
int phi0shift_
 
TrackletLUT phimatchcuttable_
 
unsigned int phiregion_
 
TrackletLUT rcut2Stable_
 
TrackletLUT rcutPStable_
 
TrackletLUT rphicut2Stable_
 
TrackletLUT rphicutPStable_
 
TrackletLUT zmatchcuttable_
 

Additional Inherited Members

- Protected Attributes inherited from trklet::ProcessBase
Globalsglobals_
 
std::string name_
 
Settings const & settings_
 

Detailed Description

Definition at line 22 of file MatchCalculator.h.

Constructor & Destructor Documentation

◆ MatchCalculator()

MatchCalculator::MatchCalculator ( std::string  name,
Settings const &  settings,
Globals global 
)

Definition at line 21 of file MatchCalculator.cc.

22  : ProcessBase(name, settings, global),
23  phimatchcuttable_(settings),
24  zmatchcuttable_(settings),
25  rphicutPStable_(settings),
26  rphicut2Stable_(settings),
27  rcutPStable_(settings),
28  rcut2Stable_(settings) {
29  phiregion_ = name[8] - 'A';
31 
32  fullMatches_.resize(12, nullptr);
33 
34  //TODO - need to sort out constants here
35  icorrshift_ = 7;
36 
37  if (layerdisk_ < N_PSLAYER) {
39  } else {
41  }
42  phi0shift_ = 3;
43  fact_ = 1;
44  if (layerdisk_ >= N_PSLAYER && layerdisk_ < N_LAYER) {
45  fact_ = (1 << (settings_.nzbitsstub(0) - settings_.nzbitsstub(5)));
49  phi0shift_ = 0;
50  }
51 
52  unsigned int region = getName()[8] - 'A';
54 
55  if (layerdisk_ < N_LAYER) {
56  phimatchcuttable_.initmatchcut(layerdisk_, TrackletLUT::MatchType::barrelphi, region);
57  zmatchcuttable_.initmatchcut(layerdisk_, TrackletLUT::MatchType::barrelz, region);
58  } else {
59  rphicutPStable_.initmatchcut(layerdisk_, TrackletLUT::MatchType::diskPSphi, region);
60  rphicut2Stable_.initmatchcut(layerdisk_, TrackletLUT::MatchType::disk2Sphi, region);
61  rcutPStable_.initmatchcut(layerdisk_, TrackletLUT::MatchType::diskPSr, region);
62  rcut2Stable_.initmatchcut(layerdisk_, TrackletLUT::MatchType::disk2Sr, region);
63  }
64 
65  for (unsigned int i = 0; i < N_DSS_MOD * 2; i++) {
67  (1 << (settings_.nbitsalpha() - 1)) / (settings_.rDSSinner(i) * settings_.rDSSinner(i)) /
68  settings_.kphi();
70  (1 << (settings_.nbitsalpha() - 1)) / (settings_.rDSSouter(i) * settings_.rDSSouter(i)) /
71  settings_.kphi();
72  }
73 }

References trklet::Settings::alphashift(), cms::cuda::assert(), fact_, fullMatches_, trklet::ProcessBase::getName(), trklet::Settings::half2SmoduleWidth(), mps_fire::i, ialphafactinner_, ialphafactouter_, icorrshift_, icorzshift_, trklet::ProcessBase::initLayerDisk(), trklet::TrackletLUT::initmatchcut(), trklet::Settings::kphi(), trklet::Settings::krprojshiftdisk(), layerdisk_, trklet::N_DSS_MOD, trklet::N_LAYER, trklet::N_PSLAYER, trklet::Settings::nallstubs(), Skims_PA_cff::name, trklet::Settings::nbitsalpha(), trklet::Settings::nrbitsstub(), trklet::Settings::nzbitsstub(), phi0shift_, phimatchcuttable_, phiregion_, trklet::Settings::PS_zderL_shift(), rcut2Stable_, rcutPStable_, trklet::Settings::rDSSinner(), trklet::Settings::rDSSouter(), HLT_FULL_cff::region, rphicut2Stable_, rphicutPStable_, trklet::ProcessBase::settings_, trklet::Settings::SS_zderL_shift(), and zmatchcuttable_.

◆ ~MatchCalculator()

trklet::MatchCalculator::~MatchCalculator ( )
overridedefault

Member Function Documentation

◆ addInput()

void MatchCalculator::addInput ( MemoryBase memory,
std::string  input 
)
overridevirtual

Implements trklet::ProcessBase.

Definition at line 90 of file MatchCalculator.cc.

90  {
91  if (settings_.writetrace()) {
92  edm::LogVerbatim("Tracklet") << "In " << name_ << " adding input from " << memory->getName() << " to input "
93  << input;
94  }
95  if (input == "allstubin") {
96  auto* tmp = dynamic_cast<AllStubsMemory*>(memory);
97  assert(tmp != nullptr);
98  allstubs_ = tmp;
99  return;
100  }
101  if (input == "allprojin") {
102  auto* tmp = dynamic_cast<AllProjectionsMemory*>(memory);
103  assert(tmp != nullptr);
104  allprojs_ = tmp;
105  return;
106  }
107  if (input.substr(0, 5) == "match" && input.substr(input.size() - 2, 2) == "in") {
108  auto* tmp = dynamic_cast<CandidateMatchMemory*>(memory);
109  assert(tmp != nullptr);
110  matches_.push_back(tmp);
111  return;
112  }
113  throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " could not find input " << input;
114 }

References allprojs_, allstubs_, cms::cuda::assert(), Exception, input, matches_, trklet::ProcessBase::name_, trklet::ProcessBase::settings_, createJobs::tmp, and trklet::Settings::writetrace().

◆ addOutput()

void MatchCalculator::addOutput ( MemoryBase memory,
std::string  output 
)
overridevirtual

Implements trklet::ProcessBase.

Definition at line 75 of file MatchCalculator.cc.

75  {
76  if (settings_.writetrace()) {
77  edm::LogVerbatim("Tracklet") << "In " << name_ << " adding output to " << memory->getName() << " to output "
78  << output;
79  }
80  if (output.substr(0, 8) == "matchout") {
81  auto* tmp = dynamic_cast<FullMatchMemory*>(memory);
82  assert(tmp != nullptr);
83  unsigned int iSeed = getISeed(memory->getName());
84  fullMatches_[iSeed] = tmp;
85  return;
86  }
87  throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " could not find output " << output;
88 }

References cms::cuda::assert(), Exception, fullMatches_, trklet::ProcessBase::getISeed(), trklet::ProcessBase::name_, convertSQLitetoXML_cfg::output, trklet::ProcessBase::settings_, createJobs::tmp, and trklet::Settings::writetrace().

◆ execute()

void MatchCalculator::execute ( double  phioffset)

Definition at line 116 of file MatchCalculator.cc.

116  {
117  unsigned int countall = 0;
118  unsigned int countsel = 0;
119 
120  Tracklet* oldTracklet = nullptr;
121 
122  std::vector<std::pair<std::pair<Tracklet*, int>, const Stub*> > mergedMatches = mergeMatches(matches_);
123 
124  for (unsigned int j = 0; j < mergedMatches.size(); j++) {
125  if (settings_.debugTracklet() && j == 0) {
126  edm::LogVerbatim("Tracklet") << getName() << " has " << mergedMatches.size() << " candidate matches";
127  }
128 
129  countall++;
130 
131  const Stub* fpgastub = mergedMatches[j].second;
132  Tracklet* tracklet = mergedMatches[j].first.first;
133  const L1TStub* stub = fpgastub->l1tstub();
134 
135  //check that the matches are orderd correctly
136  //allow equal here since we can have more than one cadidate match per tracklet projection
137  if (oldTracklet != nullptr) {
138  assert(oldTracklet->TCID() <= tracklet->TCID());
139  }
140  oldTracklet = tracklet;
141 
142  if (layerdisk_ < N_LAYER) {
143  //Integer calculation
144 
145  const Projection& proj = tracklet->proj(layerdisk_);
146 
147  int ir = fpgastub->r().value();
148  int iphi = proj.fpgaphiproj().value();
149  int icorr = (ir * proj.fpgaphiprojder().value()) >> icorrshift_;
150  iphi += icorr;
151 
152  int iz = proj.fpgarzproj().value();
153  int izcor = (ir * proj.fpgarzprojder().value() + (1 << (icorzshift_ - 1))) >> icorzshift_;
154  iz += izcor;
155 
156  int ideltaz = fpgastub->z().value() - iz;
157  int ideltaphi = (fpgastub->phi().value() << phi0shift_) - (iphi << (settings_.phi0bitshift() - 1 + phi0shift_));
158 
159  //Floating point calculations
160 
161  double phi = stub->phi() - phioffset;
162  double r = stub->r();
163  double z = stub->z();
164 
165  if (settings_.useapprox()) {
166  double dphi = reco::reduceRange(phi - fpgastub->phiapprox(0.0, 0.0));
167  assert(std::abs(dphi) < 0.001);
168  phi = fpgastub->phiapprox(0.0, 0.0);
169  z = fpgastub->zapprox();
170  r = fpgastub->rapprox();
171  }
172 
173  if (phi < 0)
174  phi += 2 * M_PI;
175 
176  double dr = r - settings_.rmean(layerdisk_);
178 
179  double dphi = reco::reduceRange(phi - (proj.phiproj() + dr * proj.phiprojder()));
180 
181  double dz = z - (proj.rzproj() + dr * proj.rzprojder());
182 
183  double dphiapprox = reco::reduceRange(phi - (proj.phiprojapprox() + dr * proj.phiprojderapprox()));
184 
185  double dzapprox = z - (proj.rzprojapprox() + dr * proj.rzprojderapprox());
186 
187  int seedindex = tracklet->getISeed();
188 
189  assert(phimatchcuttable_.lookup(seedindex) > 0);
190  assert(zmatchcuttable_.lookup(seedindex) > 0);
191 
192  if (settings_.bookHistos()) {
193  bool truthmatch = tracklet->stubtruthmatch(stub);
194 
196  hists->FillLayerResidual(layerdisk_ + 1,
197  seedindex,
198  dphiapprox * settings_.rmean(layerdisk_),
199  ideltaphi * settings_.kphi1() * settings_.rmean(layerdisk_),
200  ideltaz * fact_ * settings_.kz(),
201  dz,
202  truthmatch);
203  }
204 
205  //This would catch significant consistency problems in the configuration - helps to debug if there are problems.
206  if (std::abs(dphi) > 0.5 * settings_.dphisectorHG() || std::abs(dphiapprox) > 0.5 * settings_.dphisectorHG()) {
207  throw cms::Exception("LogicError")
208  << "WARNING dphi and/or dphiapprox too large : " << dphi << " " << dphiapprox << endl;
209  }
210 
211  if (settings_.writeMonitorData("Residuals")) {
212  double pt = 0.01 * settings_.c() * settings_.bfield() / std::abs(tracklet->rinv());
213 
214  globals_->ofstream("layerresiduals.txt")
215  << layerdisk_ + 1 << " " << seedindex << " " << pt << " "
216  << ideltaphi * settings_.kphi1() * settings_.rmean(layerdisk_) << " "
217  << dphiapprox * settings_.rmean(layerdisk_) << " "
218  << phimatchcuttable_.lookup(seedindex) * settings_.kphi1() * settings_.rmean(layerdisk_) << " "
219  << ideltaz * fact_ * settings_.kz() << " " << dz << " "
220  << zmatchcuttable_.lookup(seedindex) * settings_.kz() << endl;
221  }
222 
223  bool imatch = (std::abs(ideltaphi) <= (int)phimatchcuttable_.lookup(seedindex)) &&
224  (std::abs(ideltaz * fact_) <= (int)zmatchcuttable_.lookup(seedindex));
225 
226  if (settings_.debugTracklet()) {
227  edm::LogVerbatim("Tracklet") << getName() << " imatch = " << imatch << " ideltaphi cut " << ideltaphi << " "
228  << phimatchcuttable_.lookup(seedindex) << " ideltaz*fact cut " << ideltaz * fact_
229  << " " << zmatchcuttable_.lookup(seedindex);
230  }
231 
232  if (imatch) {
233  countsel++;
234 
235  tracklet->addMatch(layerdisk_,
236  ideltaphi,
237  ideltaz,
238  dphi,
239  dz,
240  dphiapprox,
241  dzapprox,
242  (phiregion_ << 7) + fpgastub->stubindex().value(),
243  mergedMatches[j].second);
244 
245  if (settings_.debugTracklet()) {
246  edm::LogVerbatim("Tracklet") << "Accepted full match in layer " << getName() << " " << tracklet;
247  }
248 
249  fullMatches_[seedindex]->addMatch(tracklet, mergedMatches[j].second);
250  }
251  } else { //disk matches
252 
253  //check that stubs and projections in same half of detector
254  assert(stub->z() * tracklet->t() > 0.0);
255 
256  int sign = (tracklet->t() > 0.0) ? 1 : -1;
257  int disk = sign * (layerdisk_ - (N_LAYER - 1));
258  assert(disk != 0);
259 
260  //Perform integer calculations here
261 
262  const Projection& proj = tracklet->proj(layerdisk_);
263 
264  int iz = fpgastub->z().value();
265  int iphi = proj.fpgaphiproj().value();
266 
267  //TODO - need to express interms of constants
268  int shifttmp = 6;
269  int iphicorr = (iz * proj.fpgaphiprojder().value()) >> shifttmp;
270 
271  iphi += iphicorr;
272 
273  int ir = proj.fpgarzproj().value();
274 
275  //TODO - need to express interms of constants
276  int shifttmp2 = 7;
277  int ircorr = (iz * proj.fpgarzprojder().value()) >> shifttmp2;
278 
279  ir += ircorr;
280 
281  int ideltaphi = fpgastub->phi().value() * settings_.kphi() / settings_.kphi() - iphi;
282 
283  int irstub = fpgastub->r().value();
284  int ialphafact = 0;
285  if (!stub->isPSmodule()) {
286  assert(irstub < (int)N_DSS_MOD * 2);
287  if (abs(disk) <= 2) {
288  ialphafact = ialphafactinner_[irstub];
289  irstub = settings_.rDSSinner(irstub) / settings_.kr();
290  } else {
291  ialphafact = ialphafactouter_[irstub];
292  irstub = settings_.rDSSouter(irstub) / settings_.kr();
293  }
294  }
295 
296  //TODO stub and projection r should not use different # bits...
297  int ideltar = (irstub >> 1) - ir;
298 
299  if (!stub->isPSmodule()) {
300  int ialpha = fpgastub->alpha().value();
301  int iphialphacor = ((ideltar * ialpha * ialphafact) >> settings_.alphashift());
302  ideltaphi += iphialphacor;
303  }
304 
305  //Perform floating point calculations here
306 
307  double phi = stub->phi() - phioffset;
308  double z = stub->z();
309  double r = stub->r();
310 
311  if (settings_.useapprox()) {
312  double dphi = reco::reduceRange(phi - fpgastub->phiapprox(0.0, 0.0));
313  assert(std::abs(dphi) < 0.001);
314  phi = fpgastub->phiapprox(0.0, 0.0);
315  z = fpgastub->zapprox();
316  r = fpgastub->rapprox();
317  }
318 
319  if (phi < 0)
320  phi += 2 * M_PI;
321 
322  double dz = z - sign * settings_.zmean(layerdisk_ - N_LAYER);
323 
324  if (std::abs(dz) > settings_.dzmax()) {
325  throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " " << name_ << " " << tracklet->getISeed()
326  << "\n stub " << stub->z() << " disk " << disk << " " << dz;
327  }
328 
329  double phiproj = proj.phiproj() + dz * proj.phiprojder();
330 
331  double rproj = proj.rzproj() + dz * proj.rzprojder();
332 
333  double deltar = r - rproj;
334 
335  double dr = stub->r() - rproj;
336 
337  double dphi = reco::reduceRange(phi - phiproj);
338 
339  double dphiapprox = reco::reduceRange(phi - (proj.phiprojapprox() + dz * proj.phiprojderapprox()));
340 
341  double drapprox = stub->r() - (proj.rzprojapprox() + dz * proj.rzprojderapprox());
342 
343  double drphi = dphi * stub->r();
344  double drphiapprox = dphiapprox * stub->r();
345 
346  if (!stub->isPSmodule()) {
347  double alphanorm = stub->alphanorm();
348  dphi += dr * alphanorm * settings_.half2SmoduleWidth() / stub->r2();
349  dphiapprox += drapprox * alphanorm * settings_.half2SmoduleWidth() / stub->r2();
350 
351  drphi += dr * alphanorm * settings_.half2SmoduleWidth() / stub->r();
352  drphiapprox += dr * alphanorm * settings_.half2SmoduleWidth() / stub->r();
353  }
354 
355  int seedindex = tracklet->getISeed();
356 
357  int idrphicut = rphicutPStable_.lookup(seedindex);
358  int idrcut = rcutPStable_.lookup(seedindex);
359  if (!stub->isPSmodule()) {
360  idrphicut = rphicut2Stable_.lookup(seedindex);
361  idrcut = rcut2Stable_.lookup(seedindex);
362  }
363 
364  double drphicut = idrphicut * settings_.kphi() * settings_.kr();
365  double drcut = idrcut * settings_.krprojshiftdisk();
366 
367  bool match, imatch;
368  if (std::abs(dphi) < third * settings_.dphisectorHG() &&
369  std::abs(dphiapprox) < third * settings_.dphisectorHG()) { //1/3 of sector size to catch errors
370  if (settings_.writeMonitorData("Residuals")) {
371  double pt = 0.01 * settings_.c() * settings_.bfield() / std::abs(tracklet->rinv());
372 
373  globals_->ofstream("diskresiduals.txt")
374  << disk << " " << stub->isPSmodule() << " " << tracklet->layer() << " " << abs(tracklet->disk()) << " "
375  << pt << " " << ideltaphi * settings_.kphi() * stub->r() << " " << drphiapprox << " " << drphicut << " "
376  << ideltar * settings_.krprojshiftdisk() << " " << deltar << " " << drcut << " " << endl;
377  }
378 
379  match = (std::abs(drphi) < drphicut) && (std::abs(deltar) < drcut);
380 
381  imatch = (std::abs(ideltaphi * irstub) < idrphicut) && (std::abs(ideltar) < idrcut);
382  } else {
383  edm::LogProblem("Tracklet") << "WARNING dphi and/or dphiapprox too large : " << dphi << " " << dphiapprox
384  << "dphi " << dphi << " Seed / ISeed " << tracklet->getISeed() << endl;
385  match = false;
386  imatch = false;
387  }
388  if (settings_.debugTracklet()) {
389  edm::LogVerbatim("Tracklet") << "imatch match disk: " << imatch << " " << match << " " << std::abs(ideltaphi)
390  << " " << drphicut / (settings_.kphi() * stub->r()) << " " << std::abs(ideltar)
391  << " " << drcut / settings_.krprojshiftdisk() << " r = " << stub->r();
392  }
393 
394  if (imatch) {
395  countsel++;
396 
397  if (settings_.debugTracklet()) {
398  edm::LogVerbatim("Tracklet") << "MatchCalculator found match in disk " << getName();
399  }
400 
401  tracklet->addMatch(layerdisk_,
402  ideltaphi,
403  ideltar,
404  drphi / stub->r(),
405  dr,
406  drphiapprox / stub->r(),
407  drapprox,
408  (phiregion_ << 7) + fpgastub->stubindex().value(),
409  fpgastub);
410 
411  if (settings_.debugTracklet()) {
412  edm::LogVerbatim("Tracklet") << "Accepted full match in disk " << getName() << " " << tracklet;
413  }
414 
415  fullMatches_[seedindex]->addMatch(tracklet, mergedMatches[j].second);
416  }
417  }
418  if (countall >= settings_.maxStep("MC"))
419  break;
420  }
421 
422  if (settings_.writeMonitorData("MC")) {
423  globals_->ofstream("matchcalculator.txt") << getName() << " " << countall << " " << countsel << endl;
424  }
425 }

References funct::abs(), trklet::Tracklet::addMatch(), trklet::Stub::alpha(), trklet::L1TStub::alphanorm(), trklet::Settings::alphashift(), cms::cuda::assert(), trklet::Settings::bfield(), trklet::Settings::bookHistos(), trklet::Settings::c(), trklet::Settings::debugTracklet(), trklet::Tracklet::disk(), trklet::Settings::dphisectorHG(), flavorHistoryFilter_cfi::dr, trklet::Settings::drmax(), PVValHelper::dz, trklet::Settings::dzmax(), Exception, fact_, fullMatches_, trklet::Tracklet::getISeed(), trklet::ProcessBase::getName(), trklet::ProcessBase::globals_, trklet::Settings::half2SmoduleWidth(), trklet::Globals::histograms(), compare::hists, ialphafactinner_, ialphafactouter_, icorrshift_, icorzshift_, createfilelist::int, LEDCalibrationChannels::iphi, trklet::L1TStub::isPSmodule(), dqmiolumiharvest::j, trklet::Settings::kphi(), trklet::Settings::kphi1(), trklet::Settings::kr(), trklet::Settings::krprojshiftdisk(), trklet::Settings::kz(), trklet::Stub::l1tstub(), trklet::Tracklet::layer(), layerdisk_, trklet::TrackletLUT::lookup(), M_PI, match(), matches_, trklet::Settings::maxStep(), mergeMatches(), trklet::N_DSS_MOD, trklet::N_LAYER, trklet::ProcessBase::name_, trklet::Globals::ofstream(), trklet::Stub::phi(), trklet::L1TStub::phi(), trklet::Settings::phi0bitshift(), phi0shift_, trklet::Stub::phiapprox(), phimatchcuttable_, phiregion_, amptDefault_cfi::proj, trklet::Tracklet::proj(), DiDispStaMuonMonitor_cfi::pt, trklet::L1TStub::r(), trklet::Stub::r(), alignCSCRings::r, trklet::L1TStub::r2(), trklet::Stub::rapprox(), rcut2Stable_, rcutPStable_, trklet::Settings::rDSSinner(), trklet::Settings::rDSSouter(), reco::reduceRange(), trklet::Tracklet::rinv(), trklet::Settings::rmean(), rphicut2Stable_, rphicutPStable_, edm::second(), trklet::ProcessBase::settings_, Validation_hcalonly_cfi::sign, trklet::Stub::stubindex(), trklet::Tracklet::stubtruthmatch(), trklet::Tracklet::t(), trklet::Tracklet::TCID(), trklet::third, trklet::Settings::useapprox(), trklet::FPGAWord::value(), trklet::Settings::writeMonitorData(), trklet::L1TStub::z(), trklet::Stub::z(), trklet::Stub::zapprox(), zmatchcuttable_, and trklet::Settings::zmean().

◆ mergeMatches()

std::vector< std::pair< std::pair< Tracklet *, int >, const Stub * > > MatchCalculator::mergeMatches ( std::vector< CandidateMatchMemory * > &  candmatch)

Definition at line 427 of file MatchCalculator.cc.

428  {
429  std::vector<std::pair<std::pair<Tracklet*, int>, const Stub*> > tmp;
430 
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);
435  }
436 
437  int bestIndex = -1;
438  do {
439  int bestSector = 100;
440  int bestTCID = -1;
441  bestIndex = -1;
442  for (unsigned int i = 0; i < candmatch.size(); i++) {
443  if (indexArray[i] >= candmatch[i]->nMatches()) {
444  // skip as we were at the end
445  continue;
446  }
447  int TCID = candmatch[i]->getMatch(indexArray[i]).first.first->TCID();
448  int dSector = 0;
449  if (dSector > 2)
450  dSector -= N_SECTOR;
451  if (dSector < -2)
452  dSector += N_SECTOR;
453  assert(abs(dSector) < 2);
454  if (dSector == -1)
455  dSector = 2;
456  if (dSector < bestSector) {
457  bestSector = dSector;
458  bestTCID = TCID;
459  bestIndex = i;
460  }
461  if (dSector == bestSector) {
462  if (TCID < bestTCID || bestTCID < 0) {
463  bestTCID = TCID;
464  bestIndex = i;
465  }
466  }
467  }
468  if (bestIndex != -1) {
469  tmp.push_back(candmatch[bestIndex]->getMatch(indexArray[bestIndex]));
470  indexArray[bestIndex]++;
471  }
472  } while (bestIndex != -1);
473 
474  if (layerdisk_ < N_LAYER) {
475  int lastTCID = -1;
476  bool error = false;
477 
478  //Allow equal TCIDs since we can have multiple candidate matches
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();
483  error = true;
484  } else {
485  lastTCID = tmp[i].first.first->TCID();
486  }
487  }
488 
489  if (error) {
490  for (unsigned int i = 1; i < tmp.size(); i++) {
491  edm::LogProblem("Tracklet") << "Wrong order for in " << getName() << " " << i << " " << tmp[i].first.first
492  << " " << tmp[i].first.first->TCID();
493  }
494  }
495  }
496 
497  for (unsigned int i = 0; i < tmp.size(); i++) {
498  if (i > 0) {
499  //This allows for equal TCIDs. This means that we can e.g. have a track seeded
500  //in L1L2 that projects to both L3 and D4. The algorithm will pick up the first hit and
501  //drop the second
502 
503  assert(tmp[i - 1].first.first->TCID() <= tmp[i].first.first->TCID());
504  }
505  }
506 
507  return tmp;
508 }

References funct::abs(), cms::cuda::assert(), relativeConstraints::error, first, trklet::ProcessBase::getName(), mps_fire::i, layerdisk_, trklet::N_LAYER, trklet::N_SECTOR, and createJobs::tmp.

Referenced by execute().

Member Data Documentation

◆ allprojs_

AllProjectionsMemory* trklet::MatchCalculator::allprojs_
private

Definition at line 57 of file MatchCalculator.h.

Referenced by addInput().

◆ allstubs_

AllStubsMemory* trklet::MatchCalculator::allstubs_
private

Definition at line 56 of file MatchCalculator.h.

Referenced by addInput().

◆ fact_

int trklet::MatchCalculator::fact_
private

Definition at line 40 of file MatchCalculator.h.

Referenced by execute(), and MatchCalculator().

◆ fullMatches_

std::vector<FullMatchMemory*> trklet::MatchCalculator::fullMatches_
private

Definition at line 60 of file MatchCalculator.h.

Referenced by addOutput(), execute(), and MatchCalculator().

◆ ialphafactinner_

int trklet::MatchCalculator::ialphafactinner_[N_DSS_MOD *2]
private

Definition at line 53 of file MatchCalculator.h.

Referenced by execute(), and MatchCalculator().

◆ ialphafactouter_

int trklet::MatchCalculator::ialphafactouter_[N_DSS_MOD *2]
private

Definition at line 54 of file MatchCalculator.h.

Referenced by execute(), and MatchCalculator().

◆ icorrshift_

int trklet::MatchCalculator::icorrshift_
private

Definition at line 41 of file MatchCalculator.h.

Referenced by execute(), and MatchCalculator().

◆ icorzshift_

int trklet::MatchCalculator::icorzshift_
private

Definition at line 42 of file MatchCalculator.h.

Referenced by execute(), and MatchCalculator().

◆ layerdisk_

unsigned int trklet::MatchCalculator::layerdisk_
private

Definition at line 37 of file MatchCalculator.h.

Referenced by execute(), MatchCalculator(), and mergeMatches().

◆ matches_

std::vector<CandidateMatchMemory*> trklet::MatchCalculator::matches_
private

Definition at line 59 of file MatchCalculator.h.

Referenced by addInput(), and execute().

◆ phi0shift_

int trklet::MatchCalculator::phi0shift_
private

Definition at line 43 of file MatchCalculator.h.

Referenced by execute(), and MatchCalculator().

◆ phimatchcuttable_

TrackletLUT trklet::MatchCalculator::phimatchcuttable_
private

Definition at line 45 of file MatchCalculator.h.

Referenced by execute(), and MatchCalculator().

◆ phiregion_

unsigned int trklet::MatchCalculator::phiregion_
private

Definition at line 38 of file MatchCalculator.h.

Referenced by execute(), and MatchCalculator().

◆ rcut2Stable_

TrackletLUT trklet::MatchCalculator::rcut2Stable_
private

Definition at line 51 of file MatchCalculator.h.

Referenced by execute(), and MatchCalculator().

◆ rcutPStable_

TrackletLUT trklet::MatchCalculator::rcutPStable_
private

Definition at line 50 of file MatchCalculator.h.

Referenced by execute(), and MatchCalculator().

◆ rphicut2Stable_

TrackletLUT trklet::MatchCalculator::rphicut2Stable_
private

Definition at line 49 of file MatchCalculator.h.

Referenced by execute(), and MatchCalculator().

◆ rphicutPStable_

TrackletLUT trklet::MatchCalculator::rphicutPStable_
private

Definition at line 48 of file MatchCalculator.h.

Referenced by execute(), and MatchCalculator().

◆ zmatchcuttable_

TrackletLUT trklet::MatchCalculator::zmatchcuttable_
private

Definition at line 46 of file MatchCalculator.h.

Referenced by execute(), and MatchCalculator().

trklet::ProcessBase::ProcessBase
ProcessBase(std::string name, Settings const &settings, Globals *global)
Definition: ProcessBase.cc:14
trklet::N_PSLAYER
constexpr unsigned int N_PSLAYER
Definition: Settings.h:23
trklet::Tracklet::stubtruthmatch
bool stubtruthmatch(const L1TStub *stub)
Definition: Tracklet.cc:138
trklet::MatchCalculator::phiregion_
unsigned int phiregion_
Definition: MatchCalculator.h:38
mps_fire.i
i
Definition: mps_fire.py:428
trklet::Settings::writetrace
bool writetrace() const
Definition: Settings.h:183
input
static const std::string input
Definition: EdmProvDump.cc:48
trklet::TrackletLUT::lookup
int lookup(unsigned int index) const
Definition: TrackletLUT.cc:900
trklet::Settings::krprojshiftdisk
double krprojshiftdisk() const
Definition: Settings.h:400
trklet::Stub::phi
const FPGAWord & phi() const
Definition: Stub.h:62
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
trklet::MatchCalculator::zmatchcuttable_
TrackletLUT zmatchcuttable_
Definition: MatchCalculator.h:46
trklet::Settings::dzmax
double dzmax() const
Definition: Settings.h:129
memory
Definition: HGCRecHitSoA.h:20
trklet::N_SECTOR
constexpr unsigned int N_SECTOR
Definition: Settings.h:19
trklet::L1TStub
Definition: L1TStub.h:14
trklet::L1TStub::z
double z() const
Definition: L1TStub.h:57
trklet::Tracklet::getISeed
int getISeed() const
Definition: Tracklet.cc:798
cms::cuda::assert
assert(be >=bs)
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
deltar
Definition: deltar.py:1
trklet::Settings::rmean
double rmean(unsigned int iLayer) const
Definition: Settings.h:164
trklet::ProcessBase::settings_
Settings const & settings_
Definition: ProcessBase.h:40
compare.hists
hists
Definition: compare.py:318
trklet::Stub::phiapprox
double phiapprox(double phimin, double) const
Definition: Stub.cc:177
trklet::Settings::kphi1
double kphi1() const
Definition: Settings.h:299
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
trklet::Settings::rDSSinner
double rDSSinner(unsigned int iBin) const
Definition: Settings.h:171
trklet::Settings::half2SmoduleWidth
double half2SmoduleWidth() const
Definition: Settings.h:131
relativeConstraints.error
error
Definition: relativeConstraints.py:53
trklet::MatchCalculator::icorzshift_
int icorzshift_
Definition: MatchCalculator.h:42
trklet::Stub::r
const FPGAWord & r() const
Definition: Stub.h:60
trklet::Settings::bfield
double bfield() const
Definition: Settings.h:253
trklet::Settings::bookHistos
bool bookHistos() const
Definition: Settings.h:207
trklet::Settings::nrbitsstub
unsigned int nrbitsstub(unsigned int layerdisk) const
Definition: Settings.h:84
trklet::HistBase
Definition: HistBase.h:16
trklet::Tracklet
Definition: Tracklet.h:27
trklet::Settings::rDSSouter
double rDSSouter(unsigned int iBin) const
Definition: Settings.h:174
trklet::Projection
Definition: Projection.h:10
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
trklet::Tracklet::proj
Projection & proj(int layerdisk)
Definition: Tracklet.h:87
trklet::MatchCalculator::allprojs_
AllProjectionsMemory * allprojs_
Definition: MatchCalculator.h:57
trklet::MatchCalculator::rcut2Stable_
TrackletLUT rcut2Stable_
Definition: MatchCalculator.h:51
trklet::Stub::z
const FPGAWord & z() const
Definition: Stub.h:61
trklet::Settings::dphisectorHG
double dphisectorHG() const
Definition: Settings.h:281
trklet::Stub
Definition: Stub.h:18
trklet::L1TStub::isPSmodule
unsigned int isPSmodule() const
Definition: L1TStub.h:94
trklet::Settings::alphashift
int alphashift() const
Definition: Settings.h:216
edm::LogProblem
Log< level::Error, true > LogProblem
Definition: MessageLogger.h:131
DDAxes::z
trklet::N_LAYER
constexpr int N_LAYER
Definition: Settings.h:21
trklet::MatchCalculator::ialphafactouter_
int ialphafactouter_[N_DSS_MOD *2]
Definition: MatchCalculator.h:54
trklet::Settings::zmean
double zmean(unsigned int iDisk) const
Definition: Settings.h:167
trklet::MatchCalculator::fullMatches_
std::vector< FullMatchMemory * > fullMatches_
Definition: MatchCalculator.h:60
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
trklet::MatchCalculator::rcutPStable_
TrackletLUT rcutPStable_
Definition: MatchCalculator.h:50
trklet::ProcessBase::initLayerDisk
void initLayerDisk(unsigned int pos, int &layer, int &disk)
Definition: ProcessBase.cc:33
trklet::Settings::kr
double kr() const
Definition: Settings.h:304
trklet::Settings::drmax
double drmax() const
Definition: Settings.h:128
amptDefault_cfi.proj
proj
Definition: amptDefault_cfi.py:13
trklet::MatchCalculator::phimatchcuttable_
TrackletLUT phimatchcuttable_
Definition: MatchCalculator.h:45
trklet::MatchCalculator::phi0shift_
int phi0shift_
Definition: MatchCalculator.h:43
trklet::N_DSS_MOD
constexpr unsigned int N_DSS_MOD
Definition: Settings.h:27
trklet::MatchCalculator::icorrshift_
int icorrshift_
Definition: MatchCalculator.h:41
trklet::Tracklet::TCID
int TCID() const
Definition: Tracklet.h:212
trklet::MatchCalculator::matches_
std::vector< CandidateMatchMemory * > matches_
Definition: MatchCalculator.h:59
trklet::Settings::nzbitsstub
unsigned int nzbitsstub(unsigned int layerdisk) const
Definition: Settings.h:82
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
trklet::Stub::rapprox
double rapprox() const
Definition: Stub.cc:144
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88286
createfilelist.int
int
Definition: createfilelist.py:10
trklet::L1TStub::alphanorm
double alphanorm() const
Definition: L1TStub.cc:85
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
trklet::MatchCalculator::layerdisk_
unsigned int layerdisk_
Definition: MatchCalculator.h:37
trklet::Tracklet::addMatch
void addMatch(unsigned int layerdisk, int ideltaphi, int ideltarz, double dphi, double drz, double dphiapprox, double drzapprox, int stubid, const trklet::Stub *stubptr)
Definition: Tracklet.cc:295
trklet::FPGAWord::value
int value() const
Definition: FPGAWord.h:24
trklet::Settings::nbitsalpha
int nbitsalpha() const
Definition: Settings.h:217
trklet::Settings::kphi
double kphi() const
Definition: Settings.h:298
trklet::ProcessBase::getISeed
unsigned int getISeed(const std::string &name)
Definition: ProcessBase.cc:119
alignCSCRings.r
r
Definition: alignCSCRings.py:93
DDAxes::phi
trklet::Settings::writeMonitorData
bool writeMonitorData(std::string module) const
Definition: Settings.h:109
trklet::Tracklet::rinv
double rinv() const
Definition: Tracklet.h:120
trklet::Settings::SS_zderL_shift
int SS_zderL_shift() const
Definition: Settings.h:353
trklet::Globals::ofstream
std::ofstream & ofstream(std::string fname)
Definition: Globals.cc:44
trklet::Stub::l1tstub
L1TStub * l1tstub()
Definition: Stub.h:77
PVValHelper::dz
Definition: PVValidationHelpers.h:51
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
trklet::TrackletLUT::initmatchcut
void initmatchcut(unsigned int layerdisk, MatchType type, unsigned int region)
Definition: TrackletLUT.cc:13
trklet::Settings::useapprox
bool useapprox() const
Definition: Settings.h:234
flavorHistoryFilter_cfi.dr
dr
Definition: flavorHistoryFilter_cfi.py:37
Exception
Definition: hltDiff.cc:245
trklet::ProcessBase::getName
std::string const & getName() const
Definition: ProcessBase.h:22
trklet::Settings::kz
double kz() const
Definition: Settings.h:302
trklet::ProcessBase::name_
std::string name_
Definition: ProcessBase.h:38
trklet::Stub::stubindex
const FPGAWord & stubindex() const
Definition: Stub.h:66
trklet::Settings::nallstubs
unsigned int nallstubs(unsigned int layerdisk) const
Definition: Settings.h:107
trklet::Settings::phi0bitshift
int phi0bitshift() const
Definition: Settings.h:363
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
trklet::Settings::debugTracklet
bool debugTracklet() const
Definition: Settings.h:182
trklet::MatchCalculator::ialphafactinner_
int ialphafactinner_[N_DSS_MOD *2]
Definition: MatchCalculator.h:53
trklet::Tracklet::disk
int disk() const
Definition: Tracklet.cc:779
trklet::Settings::maxStep
unsigned int maxStep(std::string module) const
Definition: Settings.h:116
trklet::L1TStub::r
double r() const
Definition: L1TStub.h:58
trklet::Settings::PS_zderL_shift
int PS_zderL_shift() const
Definition: Settings.h:352
trklet::Stub::alpha
const FPGAWord & alpha() const
Definition: Stub.h:64
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
trklet::third
constexpr double third
Definition: Settings.h:42
trklet::MatchCalculator::rphicutPStable_
TrackletLUT rphicutPStable_
Definition: MatchCalculator.h:48
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
trklet::Globals::histograms
HistBase *& histograms()
Definition: Globals.h:38
trklet::ProcessBase::globals_
Globals * globals_
Definition: ProcessBase.h:41
trklet::Tracklet::t
double t() const
Definition: Tracklet.h:123
trklet::Settings::c
double c() const
Definition: Settings.h:212
trklet::MatchCalculator::allstubs_
AllStubsMemory * allstubs_
Definition: MatchCalculator.h:56
trklet::MatchCalculator::fact_
int fact_
Definition: MatchCalculator.h:40
trklet::MatchCalculator::mergeMatches
std::vector< std::pair< std::pair< Tracklet *, int >, const Stub * > > mergeMatches(std::vector< CandidateMatchMemory * > &candmatch)
Definition: MatchCalculator.cc:427
trklet::Stub::zapprox
double zapprox() const
Definition: Stub.cc:158
trklet::L1TStub::r2
double r2() const
Definition: L1TStub.h:60
trklet::Tracklet::layer
int layer() const
Definition: Tracklet.cc:770
trklet::MatchCalculator::rphicut2Stable_
TrackletLUT rphicut2Stable_
Definition: MatchCalculator.h:49
trklet::L1TStub::phi
double phi() const
Definition: L1TStub.h:63
reco::reduceRange
constexpr T reduceRange(T x)
Definition: deltaPhi.h:18