CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes
trklet::TrackletProcessor Class Reference

#include <TrackletProcessor.h>

Inheritance diagram for trklet::TrackletProcessor:
trklet::TrackletCalculatorBase trklet::ProcessBase

Public Member Functions

void addInput (MemoryBase *memory, std::string input) override
 
void addOutput (MemoryBase *memory, std::string output) override
 
void addOutputProjection (TrackletProjectionsMemory *&outputProj, MemoryBase *memory)
 
void execute (unsigned int iSector, double phimin, double phimax)
 
 TrackletProcessor (std::string name, Settings const &settings, Globals *globals)
 
 ~TrackletProcessor () override=default
 
- Public Member Functions inherited from trklet::TrackletCalculatorBase
void addDiskProj (Tracklet *tracklet, int disk)
 
bool addLayerProj (Tracklet *tracklet, int layer)
 
void addProjection (int layer, int iphi, TrackletProjectionsMemory *trackletprojs, Tracklet *tracklet)
 
void addProjectionDisk (int disk, int iphi, TrackletProjectionsMemory *trackletprojs, Tracklet *tracklet)
 
bool barrelSeeding (const Stub *innerFPGAStub, const L1TStub *innerStub, const Stub *outerFPGAStub, const L1TStub *outerStub)
 
bool diskSeeding (const Stub *innerFPGAStub, const L1TStub *innerStub, const Stub *outerFPGAStub, const L1TStub *outerStub)
 
void exactproj (double rproj, double rinv, double phi0, double t, double z0, double &phiproj, double &zproj, double &phider, double &zder)
 
void exactprojdisk (double zproj, double rinv, double phi0, double t, double z0, double &phiproj, double &rproj, double &phider, double &rder)
 
void exacttracklet (double r1, double z1, double phi1, double r2, double z2, double phi2, double, double &rinv, double &phi0, double &t, double &z0, double phiproj[N_LAYER-2], double zproj[N_LAYER-2], double phider[N_LAYER-2], double zder[N_LAYER-2], double phiprojdisk[N_DISK], double rprojdisk[N_DISK], double phiderdisk[N_DISK], double rderdisk[N_DISK])
 
void exacttrackletdisk (double r1, double z1, double phi1, double r2, double z2, double phi2, double, double &rinv, double &phi0, double &t, double &z0, double phiprojLayer[N_PSLAYER], double zprojLayer[N_PSLAYER], double phiderLayer[N_PSLAYER], double zderLayer[N_PSLAYER], double phiproj[N_DISK-2], double rproj[N_DISK-2], double phider[N_DISK-2], double rder[N_DISK-2])
 
void exacttrackletOverlap (double r1, double z1, double phi1, double r2, double z2, double phi2, double, double &rinv, double &phi0, double &t, double &z0, double phiprojLayer[N_PSLAYER], double zprojLayer[N_PSLAYER], double phiderLayer[N_PSLAYER], double zderLayer[N_PSLAYER], double phiproj[N_DISK-2], double rproj[N_DISK-2], double phider[N_DISK-2], double rder[N_DISK-2])
 
bool goodTrackPars (bool goodrinv, bool goodz0)
 
bool inSector (int iphi0, int irinv, double phi0approx, double rinvapprox)
 
bool overlapSeeding (const Stub *innerFPGAStub, const L1TStub *innerStub, const Stub *outerFPGAStub, const L1TStub *outerStub)
 
 TrackletCalculatorBase (std::string name, Settings const &settings, Globals *global)
 
 ~TrackletCalculatorBase () override=default
 
- Public Member Functions inherited from trklet::ProcessBase
unsigned int getISeed (const std::string &name)
 
std::string const & getName () const
 
void initLayerDisk (unsigned int pos, int &layer, int &disk)
 
void initLayerDisk (unsigned int pos, int &layer, int &disk, int &layerdisk)
 
unsigned int initLayerDisk (unsigned int pos)
 
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

int iAllStub_
 
std::vector
< AllInnerStubsMemory * > 
innerallstubs_
 
TrackletLUT innerOverlapTable_
 
int innerphibits_
 
TrackletLUT innerTable_
 
int iTC_
 
unsigned int maxStep_
 
int nbitsfinephi_
 
int nbitsfinephidiff_
 
unsigned int nbitsrfinebintable_
 
unsigned int nbitsrzbin_
 
unsigned int nbitszfinebintable_
 
std::vector< AllStubsMemory * > outerallstubs_
 
int outerphibits_
 
VMStubsTEMemoryoutervmstubs_
 
TrackletLUT pttableinner_
 
TrackletLUT pttableouter_
 
std::tuple< CircularBuffer
< TEData >, unsigned int,
unsigned int, unsigned int,
unsigned int > 
tebuffer_
 
std::vector< TrackletEngineUnitteunits_
 
TrackletLUT useregiontable_
 

Additional Inherited Members

- Protected Attributes inherited from trklet::TrackletCalculatorBase
unsigned int iSector_
 
unsigned int iSeed_
 
unsigned int layerdisk1_
 
unsigned int layerdisk2_
 
double phimax_
 
double phimin_
 
int TCIndex_
 
TrackletParametersMemorytrackletpars_
 
std::vector< std::vector
< TrackletProjectionsMemory * > > 
trackletprojdisks_
 
std::vector< std::vector
< TrackletProjectionsMemory * > > 
trackletprojlayers_
 
- Protected Attributes inherited from trklet::ProcessBase
Globalsglobals_
 
std::string name_
 
Settings const & settings_
 

Detailed Description

Definition at line 24 of file TrackletProcessor.h.

Constructor & Destructor Documentation

TrackletProcessor::TrackletProcessor ( std::string  name,
Settings const &  settings,
Globals globals 
)

Definition at line 19 of file TrackletProcessor.cc.

References cms::cuda::assert(), trklet::D1D2, trklet::D3, trklet::D3D4, trklet::Settings::dphisectorHG(), iAllStub_, trklet::ProcessBase::initLayerDisksandISeed(), trklet::TrackletLUT::initVMRTable(), SurfaceOrientation::inner, innerOverlapTable_, innerphibits_, innerTable_, trklet::TrackletCalculatorBase::iSeed_, iTC_, PixelRegions::L1, trklet::L1D1, trklet::L1L2, PixelRegions::L2, trklet::L2D1, trklet::L2L3, PixelRegions::L3, trklet::L3L4, trklet::L5, trklet::L5L6, trklet::TrackletCalculatorBase::layerdisk1_, trklet::TrackletCalculatorBase::layerdisk2_, log, trklet::Settings::maxrinv(), trklet::Settings::maxStep(), maxStep_, trklet::N_DISK, trklet::N_LAYER, trklet::N_RZBITS, trklet::Settings::nallstubs(), trklet::ProcessBase::name_, hlt_dqm_clientPB-live_cfg::nbins, trklet::Settings::nbitsallstubs(), nbitsfinephi_, nbitsfinephidiff_, nbitsrfinebintable_, nbitsrzbin_, trklet::Settings::nbitsvmte(), nbitszfinebintable_, trklet::Settings::nfinephi(), trklet::Settings::ntrackletmax(), trklet::Settings::nvmte(), outerphibits_, outervmstubs_, trklet::Settings::rmaxdiskl1overlapvm(), trklet::Settings::rmaxdiskvm(), trklet::Settings::rmean(), trklet::ProcessBase::settings_, trklet::TrackletCalculatorBase::TCIndex_, createJobs::tmp, trklet::TrackletCalculatorBase::trackletprojdisks_, trklet::TrackletCalculatorBase::trackletprojlayers_, trklet::Settings::vmrlutrbits(), trklet::Settings::vmrlutzbits(), and trklet::Settings::zmean().

20  : TrackletCalculatorBase(name, settings, globals),
21  tebuffer_(CircularBuffer<TEData>(3), 0, 0, 0, 0),
22  pttableinner_(settings),
23  pttableouter_(settings),
24  useregiontable_(settings),
25  innerTable_(settings),
26  innerOverlapTable_(settings) {
27  iAllStub_ = -1;
28 
29  for (unsigned int ilayer = 0; ilayer < N_LAYER; ilayer++) {
30  vector<TrackletProjectionsMemory*> tmp(settings_.nallstubs(ilayer), nullptr);
31  trackletprojlayers_.push_back(tmp);
32  }
33 
34  for (unsigned int idisk = 0; idisk < N_DISK; idisk++) {
35  vector<TrackletProjectionsMemory*> tmp(settings_.nallstubs(idisk + N_LAYER), nullptr);
36  trackletprojdisks_.push_back(tmp);
37  }
38 
39  outervmstubs_ = nullptr;
40 
42 
43  double rmin = -1.0;
44  double rmax = -1.0;
45 
47  rmin = settings_.rmean(layerdisk1_);
48  rmax = settings_.rmean(layerdisk2_);
49  } else {
50  if (iSeed_ == Seed::L1D1) {
52  rmin = settings_.rmean(layerdisk1_);
53  } else if (iSeed_ == Seed::L2D1) {
54  rmax = settings_.rmaxdiskvm();
55  rmin = settings_.rmean(layerdisk1_);
56  } else {
57  rmax = settings_.rmaxdiskvm();
58  rmin = rmax * settings_.zmean(layerdisk2_ - N_LAYER - 1) / settings_.zmean(layerdisk2_ - N_LAYER);
59  }
60  }
61 
62  double dphimax = asin(0.5 * settings_.maxrinv() * rmax) - asin(0.5 * settings_.maxrinv() * rmin);
63 
64  //number of fine phi bins in sector
65  int nfinephibins =
67  double dfinephi = settings_.dphisectorHG() / nfinephibins;
68 
70 
71  int nbins = 2.0 * (dphimax / dfinephi + 1.0);
72 
73  nbitsfinephidiff_ = log(nbins) / log(2.0) + 1;
74 
77 
79  if (iSeed_ == Seed::D1D2 || iSeed_ == Seed::D3D4)
80  nbitsrzbin_ = 2;
81 
84 
87  innerTable_.initVMRTable(layerdisk1_, TrackletLUT::VMRTableType::inner); //projection to next layer/disk
88  }
89 
92  TrackletLUT::VMRTableType::inneroverlap); //projection to disk from layer
93  }
94 
95  // set TC index
96  iTC_ = name_[7] - 'A';
97  assert(iTC_ >= 0 && iTC_ < 14);
98 
99  TCIndex_ = (iSeed_ << 4) + iTC_;
100  assert(TCIndex_ >= 0 && TCIndex_ <= (int)settings_.ntrackletmax());
101 
102  maxStep_ = settings_.maxStep("TP");
103 }
constexpr unsigned int N_RZBITS
Definition: Settings.h:35
double dphisectorHG() const
Definition: Settings.h:281
unsigned int vmrlutrbits(unsigned int layerdisk) const
Definition: Settings.h:179
static std::vector< std::string > checklist log
constexpr int N_DISK
Definition: Settings.h:22
unsigned int vmrlutzbits(unsigned int layerdisk) const
Definition: Settings.h:178
std::string name_
Definition: ProcessBase.h:38
unsigned int ntrackletmax() const
Definition: Settings.h:331
void initLayerDisksandISeed(unsigned int &layerdisk1, unsigned int &layerdisk2, unsigned int &iSeed)
Definition: ProcessBase.cc:63
Settings const & settings_
Definition: ProcessBase.h:40
assert(be >=bs)
double rmean(unsigned int iLayer) const
Definition: Settings.h:164
std::tuple< CircularBuffer< TEData >, unsigned int, unsigned int, unsigned int, unsigned int > tebuffer_
double zmean(unsigned int iDisk) const
Definition: Settings.h:167
double rmaxdiskl1overlapvm() const
Definition: Settings.h:318
Divides< A, C > D1
Definition: Factorize.h:136
unsigned int nvmte(unsigned int inner, unsigned int iSeed) const
Definition: Settings.h:101
unsigned int nallstubs(unsigned int layerdisk) const
Definition: Settings.h:107
VMStubsTEMemory * outervmstubs_
unsigned int maxStep(std::string module) const
Definition: Settings.h:116
std::vector< std::vector< TrackletProjectionsMemory * > > trackletprojdisks_
std::vector< std::vector< TrackletProjectionsMemory * > > trackletprojlayers_
TrackletCalculatorBase(std::string name, Settings const &settings, Globals *global)
unsigned int nbitsallstubs(unsigned int layerdisk) const
Definition: Settings.h:106
int nfinephi(unsigned int inner, unsigned int iSeed) const
Definition: Settings.h:133
tmp
align.sh
Definition: createJobs.py:716
unsigned int nbitsvmte(unsigned int inner, unsigned int iSeed) const
Definition: Settings.h:95
double rmaxdiskvm() const
Definition: Settings.h:316
void initVMRTable(unsigned int layerdisk, VMRTableType type, int region=-1)
Definition: TrackletLUT.cc:490
double maxrinv() const
Definition: Settings.h:307
constexpr int N_LAYER
Definition: Settings.h:21
trklet::TrackletProcessor::~TrackletProcessor ( )
overridedefault

Member Function Documentation

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

Implements trklet::ProcessBase.

Definition at line 152 of file TrackletProcessor.cc.

References cms::cuda::assert(), Exception, trklet::MemoryBase::getName(), trklet::ProcessBase::getName(), iAllStub_, trklet::TrackletLUT::initTPlut(), trklet::TrackletLUT::initTPregionlut(), innerallstubs_, input, trklet::TrackletCalculatorBase::iSeed_, trklet::L1D1, trklet::L2D1, trklet::L2L3, trklet::TrackletCalculatorBase::layerdisk1_, trklet::TrackletCalculatorBase::layerdisk2_, trklet::ProcessBase::name_, nbitsfinephi_, nbitsfinephidiff_, outerallstubs_, outervmstubs_, pttableinner_, pttableouter_, trklet::ProcessBase::settings_, tebuffer_, trklet::Settings::teunits(), teunits_, createJobs::tmp, useregiontable_, and trklet::Settings::writetrace().

152  {
153  if (settings_.writetrace()) {
154  edm::LogVerbatim("Tracklet") << "In " << name_ << " adding input from " << memory->getName() << " to input "
155  << input;
156  }
157 
158  if (input == "outervmstubin") {
159  auto* tmp = dynamic_cast<VMStubsTEMemory*>(memory);
160  assert(tmp != nullptr);
161  outervmstubs_ = tmp;
162  iAllStub_ = tmp->getName()[11] - 'A';
163  if (iSeed_ == Seed::L2L3)
164  iAllStub_ = tmp->getName()[11] - 'I';
165  if (iSeed_ == Seed::L1D1 || iSeed_ == Seed::L2D1) {
166  if (tmp->getName()[11] == 'X')
167  iAllStub_ = 0;
168  if (tmp->getName()[11] == 'Y')
169  iAllStub_ = 1;
170  if (tmp->getName()[11] == 'Z')
171  iAllStub_ = 2;
172  if (tmp->getName()[11] == 'W')
173  iAllStub_ = 3;
174  }
175 
176  unsigned int iTP = getName()[7] - 'A';
177 
180 
181  //need iAllStub_ set before building the table
182 
185 
188  layerdisk1_,
189  layerdisk2_,
190  iSeed_,
192  iAllStub_,
193  &pttableinner_,
194  &pttableouter_,
195  outervmstubs_);
196 
197  teunits_.resize(settings_.teunits(iSeed_), teunit);
198 
199  return;
200  }
201 
202  if (input == "innerallstubin") {
203  auto* tmp = dynamic_cast<AllInnerStubsMemory*>(memory);
204  assert(tmp != nullptr);
205  if (innerallstubs_.size() == 2) { //FIXME this should be done with better logic with reading the input stubs
206  innerallstubs_.insert(innerallstubs_.begin(), tmp);
207  } else {
208  innerallstubs_.push_back(tmp);
209  }
210 
211  //FIXME should be done once after all inputs are added
212  tebuffer_ = tuple<CircularBuffer<TEData>, unsigned int, unsigned int, unsigned int, unsigned int>(
213  CircularBuffer<TEData>(3), 0, 0, 0, innerallstubs_.size());
214 
215  return;
216  }
217  if (input == "outerallstubin") {
218  auto* tmp = dynamic_cast<AllStubsMemory*>(memory);
219  assert(tmp != nullptr);
220  outerallstubs_.push_back(tmp);
221  return;
222  }
223  throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find input : " << input;
224 }
Log< level::Info, true > LogVerbatim
unsigned int teunits(unsigned int iSeed) const
Definition: Settings.h:151
std::string name_
Definition: ProcessBase.h:38
Settings const & settings_
Definition: ProcessBase.h:40
std::vector< AllStubsMemory * > outerallstubs_
assert(be >=bs)
static std::string const input
Definition: EdmProvDump.cc:47
std::vector< TrackletEngineUnit > teunits_
std::tuple< CircularBuffer< TEData >, unsigned int, unsigned int, unsigned int, unsigned int > tebuffer_
std::string const & getName() const
Definition: ProcessBase.h:22
std::string const & getName() const
Definition: MemoryBase.h:19
VMStubsTEMemory * outervmstubs_
std::vector< AllInnerStubsMemory * > innerallstubs_
void initTPlut(bool fillInner, unsigned int iSeed, unsigned int layerdisk1, unsigned int layerdisk2, unsigned int nbitsfinephidiff, unsigned int iTP)
Definition: TrackletLUT.cc:63
void initTPregionlut(unsigned int iSeed, unsigned int layerdisk1, unsigned int layerdisk2, unsigned int iAllStub, unsigned int nbitsfinephidiff, unsigned int nbitsfinephi, const TrackletLUT &tplutinner, unsigned int iTP)
Definition: TrackletLUT.cc:183
tmp
align.sh
Definition: createJobs.py:716
bool writetrace() const
Definition: Settings.h:183
void TrackletProcessor::addOutput ( MemoryBase memory,
std::string  output 
)
overridevirtual

Implements trklet::ProcessBase.

Definition at line 110 of file TrackletProcessor.cc.

References cms::cuda::assert(), Exception, trklet::MemoryBase::getName(), trklet::N_DISK, trklet::N_LAYER, trklet::ProcessBase::name_, convertSQLitetoXML_cfg::output, trklet::ProcessBase::settings_, findQualityFiles::size, createJobs::tmp, trklet::TrackletCalculatorBase::trackletpars_, trklet::TrackletCalculatorBase::trackletprojdisks_, trklet::TrackletCalculatorBase::trackletprojlayers_, and trklet::Settings::writetrace().

110  {
111  if (settings_.writetrace()) {
112  edm::LogVerbatim("Tracklet") << "In " << name_ << " adding output to " << memory->getName() << " to output "
113  << output;
114  }
115  if (output == "trackpar") {
116  auto* tmp = dynamic_cast<TrackletParametersMemory*>(memory);
117  assert(tmp != nullptr);
118  trackletpars_ = tmp;
119  return;
120  }
121 
122  if (output.substr(0, 7) == "projout") {
123  //output is on the form 'projoutL2PHIC' or 'projoutD3PHIB'
124  auto* tmp = dynamic_cast<TrackletProjectionsMemory*>(memory);
125  assert(tmp != nullptr);
126 
127  unsigned int layerdisk = output[8] - '1'; //layer or disk counting from 0
128  unsigned int phiregion = output[12] - 'A'; //phiregion counting from 0
129 
130  if (output[7] == 'L') {
131  assert(layerdisk < N_LAYER);
132  assert(phiregion < trackletprojlayers_[layerdisk].size());
133  //check that phiregion not already initialized
134  assert(trackletprojlayers_[layerdisk][phiregion] == nullptr);
135  trackletprojlayers_[layerdisk][phiregion] = tmp;
136  return;
137  }
138 
139  if (output[7] == 'D') {
140  assert(layerdisk < N_DISK);
141  assert(phiregion < trackletprojdisks_[layerdisk].size());
142  //check that phiregion not already initialized
143  assert(trackletprojdisks_[layerdisk][phiregion] == nullptr);
144  trackletprojdisks_[layerdisk][phiregion] = tmp;
145  return;
146  }
147  }
148 
149  throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find output : " << output;
150 }
Log< level::Info, true > LogVerbatim
constexpr int N_DISK
Definition: Settings.h:22
std::string name_
Definition: ProcessBase.h:38
Settings const & settings_
Definition: ProcessBase.h:40
assert(be >=bs)
std::string const & getName() const
Definition: MemoryBase.h:19
TrackletParametersMemory * trackletpars_
std::vector< std::vector< TrackletProjectionsMemory * > > trackletprojdisks_
std::vector< std::vector< TrackletProjectionsMemory * > > trackletprojlayers_
tmp
align.sh
Definition: createJobs.py:716
tuple size
Write out results.
bool writetrace() const
Definition: Settings.h:183
constexpr int N_LAYER
Definition: Settings.h:21
void TrackletProcessor::addOutputProjection ( TrackletProjectionsMemory *&  outputProj,
MemoryBase memory 
)

Definition at line 105 of file TrackletProcessor.cc.

References cms::cuda::assert().

105  {
106  outputProj = dynamic_cast<TrackletProjectionsMemory*>(memory);
107  assert(outputProj != nullptr);
108 }
assert(be >=bs)
void TrackletProcessor::execute ( unsigned int  iSector,
double  phimin,
double  phimax 
)

Definition at line 226 of file TrackletProcessor.cc.

References accept(), cms::cuda::assert(), trklet::TrackletCalculatorBase::barrelSeeding(), trklet::Stub::bend(), trklet::FPGAWord::bits(), gather_cfg::cout, trklet::D1D2, trklet::D3D4, trklet::Settings::debugTracklet(), trklet::Stub::disk(), trklet::TrackletCalculatorBase::diskSeeding(), fileCollector::done, trklet::CircularBuffer< T >::empty(), trklet::ProcessBase::getName(), trklet::ProcessBase::globals_, iAllStub_, innerallstubs_, trklet::TEData::innerbend_, trklet::TEData::innerfinephi_, innerOverlapTable_, innerTable_, trklet::TrackletCalculatorBase::iSector_, trklet::TrackletCalculatorBase::iSeed_, relval_steps::istep, isotrackApplyRegressor::k, trklet::L1D1, trklet::L1L2, trklet::Stub::l1tstub(), trklet::L2D1, trklet::L2L3, trklet::L3L4, trklet::L5L6, dqmdumpme::last, trklet::TrackletCalculatorBase::layerdisk1_, trklet::TrackletCalculatorBase::layerdisk2_, trklet::TrackletLUT::lookup(), trklet::Settings::lutwidthtab(), maxStep_, trklet::N_LAYER, trklet::N_RZBITS, trklet::Settings::nallstubs(), hlt_dqm_clientPB-live_cfg::nbins, trklet::FPGAWord::nbits(), nbitsfinephi_, nbitsrfinebintable_, nbitsrzbin_, nbitszfinebintable_, trklet::CircularBuffer< T >::nearfull(), GetRecoTauVFromDQM_MC_cff::next, trklet::NFINERZBITS, trklet::Settings::ntrackletmax(), trklet::TrackletParametersMemory::nTracklets(), trklet::VMStubsTEMemory::nVMStubs(), trklet::VMStubsTEMemory::nVMStubsBinned(), trklet::Settings::nvmte(), trklet::Globals::ofstream(), outervmstubs_, trklet::TrackletCalculatorBase::overlapSeeding(), trklet::Stub::phicorr(), phimax, trklet::TrackletCalculatorBase::phimax_, phimin, trklet::TrackletCalculatorBase::phimin_, print(), trklet::Stub::r(), SiPixelLorentzAngle_cfi::read, trklet::TrackletEngineUnit::read(), trklet::TEData::regions_, reset(), trklet::CircularBuffer< T >::rptr(), trklet::TEData::rzbinfirst_, trklet::TEData::rzdiffmax_, trklet::TrackletEngineUnit::setNearFull(), trklet::ProcessBase::settings_, command_line::start, trklet::TEData::start_, trklet::CircularBuffer< T >::store(), AlCaHLTBitMon_QueryRunRegistry::string, trklet::TEData::stub_, tebuffer_, teunits_, trklet::TrackletCalculatorBase::trackletpars_, useregiontable_, trklet::Settings::useSeed(), trklet::FPGAWord::value(), trklet::CircularBuffer< T >::wptr(), trklet::Settings::writeMonitorData(), and trklet::Stub::z().

226  {
227  bool print = (iSector == 3) && (getName() == "TP_L1L2D");
228  print = false;
229 
230  phimin_ = phimin;
231  phimax_ = phimax;
232  iSector_ = iSector;
233 
234  if (!settings_.useSeed(iSeed_))
235  return;
236 
237  //Not most elegant solution; but works
238  int donecount = 0;
239 
240  //Consistency checks
241  assert(iAllStub_ >= 0);
243  assert(outervmstubs_ != nullptr);
244 
245  //used to collect performance data
246  unsigned int countall = 0;
247  unsigned int countsel = 0;
248 
249  unsigned int countteall = 0;
250  unsigned int stubpairs = 0;
251 
252  unsigned int ntedata = 0;
253 
254  unsigned int ninnerstubs = 0;
255 
256  //Actual implemenation starts here
257 
258  //Reset the tebuffer
259  std::get<0>(tebuffer_).reset();
260  std::get<1>(tebuffer_) = 0;
261  std::get<2>(tebuffer_) = std::get<3>(tebuffer_);
262 
263  //Reset the teunits
264  for (auto& teunit : teunits_) {
265  teunit.reset();
266  }
267 
268  TEData tedata;
269  TEData tedata__;
270  TEData tedata___;
271  bool goodtedata = false;
272  bool goodtedata__ = false;
273  bool goodtedata___ = false;
274 
275  bool tebuffernearfull;
276 
277  for (unsigned int istep = 0; istep < maxStep_; istep++) {
278  // These print statements are not on by defaul but can be enabled for the
279  // comparison with HLS code to track differences.
280  if (print) {
281  CircularBuffer<TEData>& tedatabuffer = std::get<0>(tebuffer_);
282  unsigned int& istub = std::get<1>(tebuffer_);
283  unsigned int& imem = std::get<2>(tebuffer_);
284  cout << "istep=" << istep << " TEBuffer: " << istub << " " << imem << " " << tedatabuffer.rptr() << " "
285  << tedatabuffer.wptr();
286  int k = -1;
287  for (auto& teunit : teunits_) {
288  k++;
289  cout << " [" << k << " " << teunit.rptr() << " " << teunit.wptr() << " " << teunit.idle() << "]";
290  }
291  cout << endl;
292  }
293 
294  CircularBuffer<TEData>& tedatabuffer = std::get<0>(tebuffer_);
295  tebuffernearfull = tedatabuffer.nearfull();
296 
297  //
298  // First block here checks if there is a teunit with data that should should be used
299  // to calculate the tracklet parameters
300  //
301 
302  TrackletEngineUnit* teunitptr = nullptr;
303 
304  for (auto& teunit : teunits_) {
305  teunit.setNearFull();
306  if (!teunit.empty()) {
307  teunitptr = &teunit;
308  }
309  }
310 
311  if (teunitptr != nullptr) {
312  auto stubpair = teunitptr->read();
313  stubpairs++;
314 
316  edm::LogVerbatim("Tracklet") << "Will break on too many tracklets in " << getName();
317  break;
318  }
319  countall++;
320  const Stub* innerFPGAStub = stubpair.first;
321  const L1TStub* innerStub = innerFPGAStub->l1tstub();
322 
323  const Stub* outerFPGAStub = stubpair.second;
324  const L1TStub* outerStub = outerFPGAStub->l1tstub();
325 
326  if (settings_.debugTracklet()) {
327  edm::LogVerbatim("Tracklet") << "TrackletProcessor execute " << getName() << "[" << iSector_ << "]";
328  }
329 
330  bool accept = false;
331 
333  accept = barrelSeeding(innerFPGAStub, innerStub, outerFPGAStub, outerStub);
334  } else if (iSeed_ == Seed::D1D2 || iSeed_ == Seed::D3D4) {
335  accept = diskSeeding(innerFPGAStub, innerStub, outerFPGAStub, outerStub);
336  } else {
337  accept = overlapSeeding(outerFPGAStub, outerStub, innerFPGAStub, innerStub);
338  }
339 
340  if (accept)
341  countsel++;
342 
344  edm::LogVerbatim("Tracklet") << "Will break on number of tracklets in " << getName();
345  assert(0);
346  break;
347  }
348 
349  if (settings_.debugTracklet()) {
350  edm::LogVerbatim("Tracklet") << "TrackletProcessor execute done";
351  }
352  }
353 
354  //
355  // The second block fills the teunit if data in buffer and process TEUnit step
356  //
357  //
358 
359  bool notemptytebuffer = !tedatabuffer.empty();
360 
361  int ite = -1;
362  for (auto& teunit : teunits_) {
363  ite++;
364  if (teunit.idle()) {
365  if (notemptytebuffer) {
366  teunit.init(std::get<0>(tebuffer_).read());
367  notemptytebuffer = false; //prevent initialzing another TE unit
368  }
369  }
370  teunit.step(print, istep, ite);
371  }
372 
373  //
374  // The third block here checks if we have input stubs to process
375  //
376  //
377 
378  if (goodtedata___)
379  tedatabuffer.store(tedata___);
380 
381  goodtedata = false;
382 
383  unsigned int& istub = std::get<1>(tebuffer_);
384  unsigned int& imem = std::get<2>(tebuffer_);
385  unsigned int imemend = std::get<4>(tebuffer_);
386 
387  if ((!tebuffernearfull) && imem < imemend && istub < innerallstubs_[imem]->nStubs()) {
388  ninnerstubs++;
389 
390  const Stub* stub = innerallstubs_[imem]->getStub(istub);
391 
392  if (settings_.debugTracklet()) {
393  edm::LogVerbatim("Tracklet") << getName() << " Have stub in " << innerallstubs_[imem]->getName();
394  }
395 
396  bool negdisk = (stub->disk().value() < 0); //FIXME stub needs to contain bit for +/- z disk
397 
398  FPGAWord phicorr = stub->phicorr();
399  int innerfinephi = phicorr.bits(phicorr.nbits() - nbitsfinephi_, nbitsfinephi_);
400  FPGAWord innerbend = stub->bend();
401 
402  //Take the top nbitszfinebintable_ bits of the z coordinate
403  int indexz = (stub->z().value() >> (stub->z().nbits() - nbitszfinebintable_)) & ((1 << nbitszfinebintable_) - 1);
404  int indexr = -1;
405  if (layerdisk1_ > (N_LAYER - 1)) {
406  if (negdisk) {
407  indexz = ((1 << nbitszfinebintable_) - 1) - indexz;
408  }
409  indexr = stub->r().value() >> (stub->r().nbits() - nbitsrfinebintable_);
410  } else { //Take the top nbitsfinebintable_ bits of the z coordinate
411  indexr = (stub->r().value() >> (stub->r().nbits() - nbitsrfinebintable_)) & ((1 << nbitsrfinebintable_) - 1);
412  }
413 
414  int lutval = -1;
415  if (iSeed_ < 6) { //FIXME should only be one table - but will need coordination with HLS code.
416  lutval = innerTable_.lookup((indexz << nbitsrfinebintable_) + indexr);
417  } else {
418  lutval = innerOverlapTable_.lookup((indexz << nbitsrfinebintable_) + indexr);
419  }
420 
421  if (lutval != -1) {
422  unsigned int lutwidth = settings_.lutwidthtab(0, iSeed_);
423  FPGAWord lookupbits(lutval, lutwidth, true, __LINE__, __FILE__);
424 
425  int rzfinebinfirst = lookupbits.bits(0, NFINERZBITS); //finerz
426  int next = lookupbits.bits(NFINERZBITS, 1); //use next r/z bin
427  int start = lookupbits.bits(NFINERZBITS + 1, nbitsrzbin_); //rz bin
428  int rzdiffmax = lookupbits.bits(NFINERZBITS + 1 + nbitsrzbin_, NFINERZBITS);
429 
430  if ((iSeed_ == Seed::D1D2 || iSeed_ == Seed::D3D4) && negdisk) { //TODO - need to store negative disk
431  start += (1 << nbitsrzbin_);
432  }
433  int last = start + next;
434 
435  int nbins = (1 << N_RZBITS);
436 
437  unsigned int useregindex = (innerfinephi << innerbend.nbits()) + innerbend.value();
439  //FIXME If the lookupbits were rationally organized this would be much simpler
440  unsigned int nrbits = 3;
441  int ir = ((start & ((1 << (nrbits - 1)) - 1)) << 1) + (rzfinebinfirst >> (NFINERZBITS - 1));
442  useregindex = (useregindex << nrbits) + ir;
443  }
444 
445  unsigned int usereg = useregiontable_.lookup(useregindex);
446 
447  tedata.regions_.clear();
448  tedata.stub_ = stub;
449  tedata.rzbinfirst_ = rzfinebinfirst;
450  tedata.start_ = start;
451  tedata.innerfinephi_ = innerfinephi;
452  tedata.rzdiffmax_ = rzdiffmax;
453  tedata.innerbend_ = innerbend;
454 
455  std::string mask = "";
456 
457  for (int ibin = start; ibin <= last; ibin++) {
458  for (unsigned int ireg = 0; ireg < settings_.nvmte(1, iSeed_); ireg++) {
459  if (!(usereg & (1 << ireg))) {
460  mask = "0" + mask;
461  continue;
462  }
463 
464  if (settings_.debugTracklet()) {
465  edm::LogVerbatim("Tracklet") << getName() << " looking for matching stub in bin " << ibin << " with "
466  << outervmstubs_->nVMStubsBinned(ireg * nbins + ibin) << " stubs";
467  }
468  assert(ireg * nbins + ibin < outervmstubs_->nBin());
469  int nstubs = outervmstubs_->nVMStubsBinned(ireg * nbins + ibin);
470 
471  if (nstubs > 0) {
472  mask = "1" + mask;
473  tedata.regions_.emplace_back(tuple<int, int, int>(ibin - start, ireg, nstubs));
474  countteall += nstubs;
475  } else {
476  mask = "0" + mask;
477  }
478  }
479  }
480 
481  if (!tedata.regions_.empty()) {
482  ntedata++;
483  goodtedata = true;
484  }
485  }
486  istub++;
487  if (istub >= innerallstubs_[imem]->nStubs()) {
488  istub = 0;
489  imem++;
490  }
491  } else if ((!tebuffernearfull) && imem < imemend && istub == 0) {
492  imem++;
493  }
494 
495  goodtedata___ = goodtedata__;
496  goodtedata__ = goodtedata;
497 
498  tedata___ = tedata__;
499  tedata__ = tedata;
500 
501  //
502  // stop looping over istep if done
503  //
504 
505  bool done = true;
506 
507  if (imem < imemend || (!tedatabuffer.empty())) {
508  done = false;
509  }
510 
511  for (auto& teunit : teunits_) {
512  if (!(teunit.idle() && teunit.empty()))
513  done = false;
514  }
515 
516  if (done) {
517  donecount++;
518  }
519 
520  //FIXME This should be done cleaner... Not too hard, but need to check fully the TEBuffer and TEUnit buffer.
521  if (donecount > 4) {
522  break;
523  }
524  }
525 
526  //
527  // Done with processing - collect performance statistics
528  //
529 
530  if (settings_.writeMonitorData("TP")) {
531  globals_->ofstream("trackletprocessor.txt") << getName() << " " << ninnerstubs //# inner stubs
532  << " " << outervmstubs_->nVMStubs() //# outer stubs
533  << " " << countteall //# pairs tried in TE
534  << " " << stubpairs //# stubs pairs
535  << " " << countsel //# tracklets found
536  << endl;
537  }
538 }
Log< level::Info, true > LogVerbatim
constexpr unsigned int N_RZBITS
Definition: Settings.h:35
const FPGAWord & bend() const
Definition: Stub.h:58
const FPGAWord & disk() const
Definition: Stub.h:68
const FPGAWord & phicorr() const
Definition: Stub.h:63
const std::pair< const Stub *, const Stub * > & read()
bool diskSeeding(const Stub *innerFPGAStub, const L1TStub *innerStub, const Stub *outerFPGAStub, const L1TStub *outerStub)
unsigned int ntrackletmax() const
Definition: Settings.h:331
int nbits() const
Definition: FPGAWord.h:25
Settings const & settings_
Definition: ProcessBase.h:40
Globals * globals_
Definition: ProcessBase.h:41
assert(be >=bs)
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:31
bool debugTracklet() const
Definition: Settings.h:182
std::vector< TrackletEngineUnit > teunits_
bool overlapSeeding(const Stub *innerFPGAStub, const L1TStub *innerStub, const Stub *outerFPGAStub, const L1TStub *outerStub)
std::tuple< CircularBuffer< TEData >, unsigned int, unsigned int, unsigned int, unsigned int > tebuffer_
unsigned int nVMStubsBinned(unsigned int bin) const
std::string const & getName() const
Definition: ProcessBase.h:22
int value() const
Definition: FPGAWord.h:24
unsigned int nvmte(unsigned int inner, unsigned int iSeed) const
Definition: Settings.h:101
unsigned int bits(unsigned int lsb, unsigned int nbit) const
Definition: FPGAWord.cc:74
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
unsigned int nallstubs(unsigned int layerdisk) const
Definition: Settings.h:107
VMStubsTEMemory * outervmstubs_
void store(T element)
L1TStub * l1tstub()
Definition: Stub.h:77
TrackletParametersMemory * trackletpars_
const FPGAWord & z() const
Definition: Stub.h:61
std::vector< AllInnerStubsMemory * > innerallstubs_
constexpr unsigned int NFINERZBITS
Definition: Settings.h:33
int lookup(unsigned int index) const
Definition: TrackletLUT.cc:900
unsigned int nVMStubs() const
unsigned int rptr() const
const Stub * stub_
std::ofstream & ofstream(std::string fname)
Definition: Globals.cc:44
const FPGAWord & r() const
Definition: Stub.h:60
tuple cout
Definition: gather_cfg.py:144
bool useSeed(unsigned int iSeed) const
Definition: Settings.h:94
double lutwidthtab(unsigned int inner, unsigned int iSeed) const
Definition: Settings.h:140
tuple last
Definition: dqmdumpme.py:56
bool nearfull() const
void reset(double vett[256])
Definition: TPedValues.cc:11
unsigned int wptr() const
bool writeMonitorData(std::string module) const
Definition: Settings.h:109
constexpr int N_LAYER
Definition: Settings.h:21
bool barrelSeeding(const Stub *innerFPGAStub, const L1TStub *innerStub, const Stub *outerFPGAStub, const L1TStub *outerStub)
std::vector< std::tuple< int, int, int > > regions_

Member Data Documentation

int trklet::TrackletProcessor::iAllStub_
private

Definition at line 40 of file TrackletProcessor.h.

Referenced by addInput(), execute(), and TrackletProcessor().

std::vector<AllInnerStubsMemory*> trklet::TrackletProcessor::innerallstubs_
private

Definition at line 51 of file TrackletProcessor.h.

Referenced by addInput(), and execute().

TrackletLUT trklet::TrackletProcessor::innerOverlapTable_
private

Definition at line 70 of file TrackletProcessor.h.

Referenced by execute(), and TrackletProcessor().

int trklet::TrackletProcessor::innerphibits_
private

Definition at line 61 of file TrackletProcessor.h.

Referenced by TrackletProcessor().

TrackletLUT trklet::TrackletProcessor::innerTable_
private

Definition at line 69 of file TrackletProcessor.h.

Referenced by execute(), and TrackletProcessor().

int trklet::TrackletProcessor::iTC_
private

Definition at line 39 of file TrackletProcessor.h.

Referenced by TrackletProcessor().

unsigned int trklet::TrackletProcessor::maxStep_
private

Definition at line 42 of file TrackletProcessor.h.

Referenced by execute(), and TrackletProcessor().

int trklet::TrackletProcessor::nbitsfinephi_
private

Definition at line 58 of file TrackletProcessor.h.

Referenced by addInput(), execute(), and TrackletProcessor().

int trklet::TrackletProcessor::nbitsfinephidiff_
private

Definition at line 59 of file TrackletProcessor.h.

Referenced by addInput(), and TrackletProcessor().

unsigned int trklet::TrackletProcessor::nbitsrfinebintable_
private

Definition at line 65 of file TrackletProcessor.h.

Referenced by execute(), and TrackletProcessor().

unsigned int trklet::TrackletProcessor::nbitsrzbin_
private

Definition at line 67 of file TrackletProcessor.h.

Referenced by execute(), and TrackletProcessor().

unsigned int trklet::TrackletProcessor::nbitszfinebintable_
private

Definition at line 64 of file TrackletProcessor.h.

Referenced by execute(), and TrackletProcessor().

std::vector<AllStubsMemory*> trklet::TrackletProcessor::outerallstubs_
private

Definition at line 52 of file TrackletProcessor.h.

Referenced by addInput().

int trklet::TrackletProcessor::outerphibits_
private

Definition at line 62 of file TrackletProcessor.h.

Referenced by TrackletProcessor().

VMStubsTEMemory* trklet::TrackletProcessor::outervmstubs_
private

Definition at line 44 of file TrackletProcessor.h.

Referenced by addInput(), execute(), and TrackletProcessor().

TrackletLUT trklet::TrackletProcessor::pttableinner_
private

Definition at line 54 of file TrackletProcessor.h.

Referenced by addInput().

TrackletLUT trklet::TrackletProcessor::pttableouter_
private

Definition at line 55 of file TrackletProcessor.h.

Referenced by addInput().

std::tuple<CircularBuffer<TEData>, unsigned int, unsigned int, unsigned int, unsigned int> trklet::TrackletProcessor::tebuffer_
private

Definition at line 47 of file TrackletProcessor.h.

Referenced by addInput(), and execute().

std::vector<TrackletEngineUnit> trklet::TrackletProcessor::teunits_
private

Definition at line 49 of file TrackletProcessor.h.

Referenced by addInput(), and execute().

TrackletLUT trklet::TrackletProcessor::useregiontable_
private

Definition at line 56 of file TrackletProcessor.h.

Referenced by addInput(), and execute().