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::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 ( 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:393
unsigned int nvmme(unsigned int layerdisk) const
Definition: Settings.h:104
Settings const & settings_
Definition: ProcessBase.h:40
std::vector< VMProjectionsMemory * > vmprojs_
double K() const
Definition: imath.h:246
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
constexpr int N_LAYER
Definition: Settings.h:21
trklet::ProjectionRouter::~ProjectionRouter ( )
overridedefault

Member Function Documentation

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, trklet::MemoryBase::getName(), input, inputproj_, 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
assert(be >=bs)
static std::string const input
Definition: EdmProvDump.cc:47
std::string const & getName() const
Definition: MemoryBase.h:19
std::vector< TrackletProjectionsMemory * > inputproj_
tmp
align.sh
Definition: createJobs.py:716
bool writetrace() const
Definition: Settings.h:183
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, trklet::MemoryBase::getName(), layerdisk_, trklet::Settings::nallstubs(), mergeVDriftHistosByStation::name, trklet::ProcessBase::name_, trklet::Settings::nvmme(), convertSQLitetoXML_cfg::output, trklet::ProcessBase::settings_, AlCaHLTBitMon_QueryRunRegistry::string, createJobs::tmp, cond::impl::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
unsigned int nvmme(unsigned int layerdisk) const
Definition: Settings.h:104
Settings const & settings_
Definition: ProcessBase.h:40
std::string to_string(const V &value)
Definition: OMSAccess.h:71
std::vector< VMProjectionsMemory * > vmprojs_
assert(be >=bs)
AllProjectionsMemory * allproj_
std::string const & getName() const
Definition: MemoryBase.h:19
unsigned int nallstubs(unsigned int layerdisk) const
Definition: Settings.h:107
tmp
align.sh
Definition: createJobs.py:716
bool writetrace() const
Definition: Settings.h:183
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::Projection::fpgaphiprojder(), trklet::Projection::fpgarzproj(), trklet::Projection::fpgarzprojder(), 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(), submitPVResolutionJobs::out, trklet::Tracklet::proj(), rinvbendlut_, trklet::Projection::setBendIndex(), trklet::ProcessBase::settings_, trklet::Tracklet::TCID(), trklet::FPGAWord::value(), 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
const FPGAWord & fpgaphiproj() const
Definition: Projection.h:39
const FPGAWord & fpgaphiprojder() const
Definition: Projection.h:49
int nbits() const
Definition: FPGAWord.h:25
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_
bool debugTracklet() const
Definition: Settings.h:182
void addTracklet(Tracklet *tracklet)
AllProjectionsMemory * allproj_
std::string const & getName() const
Definition: ProcessBase.h:22
const FPGAWord & fpgarzprojder() const
Definition: Projection.h:54
int value() const
Definition: FPGAWord.h:24
int TCID() const
Definition: Tracklet.h:212
unsigned int bits(unsigned int lsb, unsigned int nbit) const
Definition: FPGAWord.cc:74
unsigned int maxStep(std::string module) const
Definition: Settings.h:116
Log< level::Warning, true > LogPrint
unsigned int nTracklets() const
int lookup(unsigned int index) const
Definition: TrackletLUT.cc:900
unsigned int nbitsallstubs(unsigned int layerdisk) const
Definition: Settings.h:106
const FPGAWord & fpgarzproj() const
Definition: Projection.h:44
std::ofstream & ofstream(std::string fname)
Definition: Globals.cc:44
void setBendIndex(int bendindex)
Definition: Projection.h:119
unsigned int nbitsvmme(unsigned int layerdisk) const
Definition: Settings.h:103
std::vector< TrackletProjectionsMemory * > inputproj_
bool writeMonitorData(std::string module) const
Definition: Settings.h:109
constexpr int N_LAYER
Definition: Settings.h:21

Member Data Documentation

AllProjectionsMemory* trklet::ProjectionRouter::allproj_
private

Definition at line 38 of file ProjectionRouter.h.

Referenced by addOutput(), and execute().

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

Definition at line 36 of file ProjectionRouter.h.

Referenced by addInput(), and execute().

unsigned int trklet::ProjectionRouter::layerdisk_
private

Definition at line 28 of file ProjectionRouter.h.

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

int trklet::ProjectionRouter::nphiderbits_
private

Definition at line 31 of file ProjectionRouter.h.

Referenced by execute(), and ProjectionRouter().

int trklet::ProjectionRouter::nrbits_
private

Definition at line 30 of file ProjectionRouter.h.

Referenced by execute(), and ProjectionRouter().

TrackletLUT trklet::ProjectionRouter::rinvbendlut_
private

Definition at line 34 of file ProjectionRouter.h.

Referenced by execute(), and ProjectionRouter().

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

Definition at line 39 of file ProjectionRouter.h.

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