CMS 3D CMS Logo

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

#include <ProjectionRouter.h>

Inheritance diagram for trklet::ProjectionRouter:
trklet::ProcessBase

Public Member Functions

void addInput (MemoryBase *memory, std::string input) override
 
void addOutput (MemoryBase *memory, std::string output) override
 
void execute ()
 
 ProjectionRouter (std::string name, Settings const &settings, Globals *global)
 
 ~ProjectionRouter () 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

AllProjectionsMemoryallproj_
 
std::vector< TrackletProjectionsMemory * > inputproj_
 
unsigned int layerdisk_
 
int nphiderbits_
 
int nrbits_
 
TrackletLUT rinvbendlut_
 
std::vector< VMProjectionsMemory * > vmprojs_
 

Additional Inherited Members

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

Detailed Description

Definition at line 16 of file ProjectionRouter.h.

Constructor & Destructor Documentation

◆ ProjectionRouter()

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

Definition at line 14 of file ProjectionRouter.cc.

References trklet::IMATH_TrackletCalculator::der_phiD_final, trklet::ProcessBase::initLayerDisk(), trklet::TrackletLUT::initProjectionBend(), trklet::Globals::ITC_L1L2(), trklet::VarBase::K(), layerdisk_, trklet::N_LAYER, nphiderbits_, nrbits_, trklet::Settings::nvmme(), rinvbendlut_, trklet::ProcessBase::settings_, and vmprojs_.

15  : ProcessBase(name, settings, global), rinvbendlut_(settings) {
17 
18  vmprojs_.resize(settings_.nvmme(layerdisk_), nullptr);
19 
20  nrbits_ = 5;
21  nphiderbits_ = 6;
22 
23  if (layerdisk_ >= N_LAYER) {
26  }
27 }
void initProjectionBend(double k_phider, unsigned int idisk, unsigned int nrbits, unsigned int nphiderbits)
Definition: TrackletLUT.cc:801
Settings const & settings_
Definition: ProcessBase.h:40
std::vector< VMProjectionsMemory * > vmprojs_
ProcessBase(std::string name, Settings const &settings, Globals *global)
Definition: ProcessBase.cc:14
IMATH_TrackletCalculator * ITC_L1L2()
Definition: Globals.h:48
void initLayerDisk(unsigned int pos, int &layer, int &disk)
Definition: ProcessBase.cc:33
double K() const
Definition: imath.h:247
unsigned int nvmme(unsigned int layerdisk) const
Definition: Settings.h:113
constexpr int N_LAYER
Definition: Settings.h:25

◆ ~ProjectionRouter()

trklet::ProjectionRouter::~ProjectionRouter ( )
overridedefault

Member Function Documentation

◆ addInput()

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

Implements trklet::ProcessBase.

Definition at line 61 of file ProjectionRouter.cc.

References cms::cuda::assert(), Exception, input, inputproj_, mps_setup::memory, trklet::ProcessBase::name_, trklet::ProcessBase::settings_, createJobs::tmp, and trklet::Settings::writetrace().

61  {
62  if (settings_.writetrace()) {
63  edm::LogVerbatim("Tracklet") << "In " << name_ << " adding input from " << memory->getName() << " to input "
64  << input;
65  }
66  if (input.substr(0, 4) == "proj" && input.substr(input.size() - 2, 2) == "in") {
67  auto* tmp = dynamic_cast<TrackletProjectionsMemory*>(memory);
68  assert(tmp != nullptr);
69  inputproj_.push_back(tmp);
70  return;
71  }
72  throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " could not find input: " << input;
73 }
Log< level::Info, true > LogVerbatim
std::string name_
Definition: ProcessBase.h:38
Settings const & settings_
Definition: ProcessBase.h:40
bool writetrace() const
Definition: Settings.h:195
assert(be >=bs)
static std::string const input
Definition: EdmProvDump.cc:50
std::vector< TrackletProjectionsMemory * > inputproj_
tmp
align.sh
Definition: createJobs.py:716

◆ addOutput()

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

Implements trklet::ProcessBase.

Definition at line 29 of file ProjectionRouter.cc.

References allproj_, cms::cuda::assert(), Exception, layerdisk_, mps_setup::memory, trklet::Settings::nallstubs(), Skims_PA_cff::name, trklet::ProcessBase::name_, trklet::Settings::nvmme(), convertSQLitetoXML_cfg::output, trklet::ProcessBase::settings_, AlCaHLTBitMon_QueryRunRegistry::string, createJobs::tmp, to_string(), vmprojs_, and trklet::Settings::writetrace().

29  {
30  if (settings_.writetrace()) {
31  edm::LogVerbatim("Tracklet") << "In " << name_ << " adding output to " << memory->getName() << " to output "
32  << output;
33  }
34  if (output == "allprojout") {
35  auto* tmp = dynamic_cast<AllProjectionsMemory*>(memory);
36  assert(tmp != nullptr);
37  allproj_ = tmp;
38  return;
39  }
40 
41  unsigned int nproj = settings_.nallstubs(layerdisk_);
42  unsigned int nprojvm = settings_.nvmme(layerdisk_);
43 
44  for (unsigned int iproj = 0; iproj < nproj; iproj++) {
45  for (unsigned int iprojvm = 0; iprojvm < nprojvm; iprojvm++) {
46  std::string name = "vmprojoutPHI";
47  name += char(iproj + 'A');
48  name += std::to_string(iproj * nprojvm + iprojvm + 1);
49  if (output == name) {
50  auto* tmp = dynamic_cast<VMProjectionsMemory*>(memory);
51  assert(tmp != nullptr);
52  vmprojs_[iprojvm] = tmp;
53  return;
54  }
55  }
56  }
57 
58  throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " could not find output: " << output;
59 }
Log< level::Info, true > LogVerbatim
std::string name_
Definition: ProcessBase.h:38
Settings const & settings_
Definition: ProcessBase.h:40
std::vector< VMProjectionsMemory * > vmprojs_
bool writetrace() const
Definition: Settings.h:195
assert(be >=bs)
static std::string to_string(const XMLCh *ch)
AllProjectionsMemory * allproj_
unsigned int nallstubs(unsigned int layerdisk) const
Definition: Settings.h:116
unsigned int nvmme(unsigned int layerdisk) const
Definition: Settings.h:113
Definition: output.py:1
tmp
align.sh
Definition: createJobs.py:716

◆ execute()

void ProjectionRouter::execute ( void  )

Definition at line 75 of file ProjectionRouter.cc.

References trklet::AllProjectionsMemory::addTracklet(), allproj_, trklet::FPGAWord::bits(), trklet::Settings::debugTracklet(), trklet::Projection::fpgaphiproj(), trklet::ProcessBase::getName(), trklet::ProcessBase::globals_, mps_fire::i, inputproj_, layerdisk_, trklet::TrackletLUT::lookup(), trklet::Settings::maxStep(), trklet::N_LAYER, trklet::FPGAWord::nbits(), trklet::Settings::nbitsallstubs(), trklet::Settings::nbitsvmme(), nphiderbits_, nrbits_, trklet::AllProjectionsMemory::nTracklets(), trklet::Globals::ofstream(), MillePedeFileConverter_cfg::out, amptDefault_cfi::proj, trklet::Tracklet::proj(), rinvbendlut_, trklet::ProcessBase::settings_, trklet::Tracklet::TCID(), vmprojs_, and trklet::Settings::writeMonitorData().

75  {
76  unsigned int allprojcount = 0;
77 
78  //These are just here to test that the order is correct. Does not affect the actual execution
79 
80  int lastTCID = -1;
81 
82  for (auto& iproj : inputproj_) {
83  for (unsigned int i = 0; i < iproj->nTracklets(); i++) {
84  if (allprojcount >= settings_.maxStep("PR"))
85  continue;
86 
87  Tracklet* tracklet = iproj->getTracklet(i);
88 
89  FPGAWord fpgaphi;
90 
91  if (layerdisk_ < N_LAYER) {
92  fpgaphi = tracklet->proj(layerdisk_).fpgaphiproj();
93  } else {
94  Projection& proj = tracklet->proj(layerdisk_);
95  fpgaphi = proj.fpgaphiproj();
96 
97  //The next lines looks up the predicted bend based on:
98  // 1 - r projections
99  // 2 - phi derivative
100  // 3 - the sign - i.e. if track is forward or backward
101 
102  int rindex = (proj.fpgarzproj().value() >> (proj.fpgarzproj().nbits() - nrbits_)) & ((1 << nrbits_) - 1);
103 
104  int phiderindex = (proj.fpgaphiprojder().value() >> (proj.fpgaphiprojder().nbits() - nphiderbits_)) &
105  ((1 << nphiderbits_) - 1);
106 
107  int signindex = (proj.fpgarzprojder().value() < 0);
108 
109  int bendindex = (signindex << (nphiderbits_ + nrbits_)) + (rindex << (nphiderbits_)) + phiderindex;
110 
111  int ibendproj = rinvbendlut_.lookup(bendindex);
112 
113  proj.setBendIndex(ibendproj);
114  }
115 
116  unsigned int iphivm =
119 
120  //This block of code just checks that the configuration is consistent
121  if (lastTCID >= tracklet->TCID()) {
122  edm::LogPrint("Tracklet") << "Wrong TCID ordering for projections in " << getName();
123  } else {
124  lastTCID = tracklet->TCID();
125  }
126 
127  allproj_->addTracklet(tracklet);
128 
129  vmprojs_[iphivm]->addTracklet(tracklet, allprojcount);
130 
131  if (settings_.debugTracklet()) {
132  edm::LogVerbatim("Tracklet") << getName() << " projection to " << vmprojs_[iphivm]->getName() << " iphivm "
133  << iphivm;
134  }
135 
136  allprojcount++;
137  }
138  }
139 
140  if (settings_.writeMonitorData("AP")) {
141  globals_->ofstream("allprojections.txt") << getName() << " " << allproj_->nTracklets() << endl;
142  }
143 
144  if (settings_.writeMonitorData("VMP")) {
145  ofstream& out = globals_->ofstream("chisq.txt");
146  for (unsigned int i = 0; i < 8; i++) {
147  if (vmprojs_[i] != nullptr) {
148  out << vmprojs_[i]->getName() << " " << vmprojs_[i]->nTracklets() << endl;
149  }
150  }
151  }
152 }
Log< level::Info, true > LogVerbatim
unsigned int maxStep(std::string module) const
Definition: Settings.h:125
Projection & proj(int layerdisk)
Definition: Tracklet.h:87
Settings const & settings_
Definition: ProcessBase.h:40
Globals * globals_
Definition: ProcessBase.h:41
std::vector< VMProjectionsMemory * > vmprojs_
int lookup(unsigned int index) const
int TCID() const
Definition: Tracklet.h:214
void addTracklet(Tracklet *tracklet)
const FPGAWord & fpgaphiproj() const
Definition: Projection.h:39
AllProjectionsMemory * allproj_
unsigned int nbitsallstubs(unsigned int layerdisk) const
Definition: Settings.h:115
unsigned int nbitsvmme(unsigned int layerdisk) const
Definition: Settings.h:112
bool writeMonitorData(std::string module) const
Definition: Settings.h:118
Log< level::Warning, true > LogPrint
bool debugTracklet() const
Definition: Settings.h:194
int nbits() const
Definition: FPGAWord.h:25
std::ofstream & ofstream(std::string fname)
Definition: Globals.cc:44
std::vector< TrackletProjectionsMemory * > inputproj_
unsigned int bits(unsigned int lsb, unsigned int nbit) const
Definition: FPGAWord.cc:74
std::string const & getName() const
Definition: ProcessBase.h:22
constexpr int N_LAYER
Definition: Settings.h:25

Member Data Documentation

◆ allproj_

AllProjectionsMemory* trklet::ProjectionRouter::allproj_
private

Definition at line 38 of file ProjectionRouter.h.

Referenced by addOutput(), and execute().

◆ inputproj_

std::vector<TrackletProjectionsMemory*> trklet::ProjectionRouter::inputproj_
private

Definition at line 36 of file ProjectionRouter.h.

Referenced by addInput(), and execute().

◆ layerdisk_

unsigned int trklet::ProjectionRouter::layerdisk_
private

Definition at line 28 of file ProjectionRouter.h.

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

◆ nphiderbits_

int trklet::ProjectionRouter::nphiderbits_
private

Definition at line 31 of file ProjectionRouter.h.

Referenced by execute(), and ProjectionRouter().

◆ nrbits_

int trklet::ProjectionRouter::nrbits_
private

Definition at line 30 of file ProjectionRouter.h.

Referenced by execute(), and ProjectionRouter().

◆ rinvbendlut_

TrackletLUT trklet::ProjectionRouter::rinvbendlut_
private

Definition at line 34 of file ProjectionRouter.h.

Referenced by execute(), and ProjectionRouter().

◆ vmprojs_

std::vector<VMProjectionsMemory*> trklet::ProjectionRouter::vmprojs_
private

Definition at line 39 of file ProjectionRouter.h.

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