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, unsigned int iSector)
 
 ~ProjectionRouter () override=default
 
- Public Member Functions inherited from trklet::ProcessBase
unsigned int getISeed (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, unsigned int iSector)
 
virtual ~ProcessBase ()=default
 

Private Attributes

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

Additional Inherited Members

- Protected Attributes inherited from trklet::ProcessBase
Globalsglobals_
 
unsigned int iSector_
 
std::string name_
 
double phimax_
 
double phimin_
 
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,
unsigned int  iSector 
)

Definition at line 13 of file ProjectionRouter.cc.

14  : ProcessBase(name, settings, global, iSector) {
16 
17  vmprojs_.resize(settings_.nvmme(layerdisk_), nullptr);
18 
19  nrbits_ = 5;
20  nphiderbits_ = 6;
21 }

References trklet::ProcessBase::initLayerDisk(), layerdisk_, nphiderbits_, nrbits_, trklet::Settings::nvmme(), trklet::ProcessBase::settings_, and vmprojs_.

◆ ~ProjectionRouter()

trklet::ProjectionRouter::~ProjectionRouter ( )
overridedefault

Member Function Documentation

◆ addInput()

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

Implements trklet::ProcessBase.

Definition at line 55 of file ProjectionRouter.cc.

55  {
56  if (settings_.writetrace()) {
57  edm::LogVerbatim("Tracklet") << "In " << name_ << " adding input from " << memory->getName() << " to input "
58  << input;
59  }
60  if (input.substr(0, 4) == "proj" && input.substr(input.size() - 2, 2) == "in") {
61  auto* tmp = dynamic_cast<TrackletProjectionsMemory*>(memory);
62  assert(tmp != nullptr);
63  inputproj_.push_back(tmp);
64  return;
65  }
66  throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " could not find input: " << input;
67 }

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

◆ addOutput()

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

Implements trklet::ProcessBase.

Definition at line 23 of file ProjectionRouter.cc.

23  {
24  if (settings_.writetrace()) {
25  edm::LogVerbatim("Tracklet") << "In " << name_ << " adding output to " << memory->getName() << " to output "
26  << output;
27  }
28  if (output == "allprojout") {
29  auto* tmp = dynamic_cast<AllProjectionsMemory*>(memory);
30  assert(tmp != nullptr);
31  allproj_ = tmp;
32  return;
33  }
34 
35  unsigned int nproj = settings_.nallstubs(layerdisk_);
36  unsigned int nprojvm = settings_.nvmme(layerdisk_);
37 
38  for (unsigned int iproj = 0; iproj < nproj; iproj++) {
39  for (unsigned int iprojvm = 0; iprojvm < nprojvm; iprojvm++) {
40  std::string name = "vmprojoutPHI";
41  name += char(iproj + 'A');
42  name += std::to_string(iproj * nprojvm + iprojvm + 1);
43  if (output == name) {
44  auto* tmp = dynamic_cast<VMProjectionsMemory*>(memory);
45  assert(tmp != nullptr);
46  vmprojs_[iprojvm] = tmp;
47  return;
48  }
49  }
50  }
51 
52  throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " could not find output: " << output;
53 }

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, vmprojs_, and trklet::Settings::writetrace().

◆ execute()

void ProjectionRouter::execute ( void  )

Definition at line 69 of file ProjectionRouter.cc.

69  {
70  if (globals_->projectionRouterBendTable() == nullptr) {
71  auto* bendTablePtr = new ProjectionRouterBendTable();
72  bendTablePtr->init(settings_, globals_, nrbits_, nphiderbits_);
73  globals_->projectionRouterBendTable() = bendTablePtr;
74  }
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->fpgaphiproj(layerdisk_ + 1);
93  } else {
94  int disk = layerdisk_ - (N_LAYER - 1);
95  fpgaphi = tracklet->fpgaphiprojdisk(disk);
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  int rindex = (tracklet->fpgarprojdisk(disk).value() >> (tracklet->fpgarprojdisk(disk).nbits() - nrbits_)) &
102  ((1 << nrbits_) - 1);
103 
104  int phiderindex = (tracklet->fpgaphiprojderdisk(disk).value() >>
105  (tracklet->fpgaphiprojderdisk(disk).nbits() - nphiderbits_)) &
106  ((1 << nphiderbits_) - 1);
107 
108  int signindex = (tracklet->fpgarprojderdisk(disk).value() < 0);
109 
110  int bendindex = (signindex << (nphiderbits_ + nrbits_)) + (rindex << (nphiderbits_)) + phiderindex;
111 
112  int ibendproj = globals_->projectionRouterBendTable()->bendLoookup(disk - 1, bendindex);
113 
114  tracklet->setBendIndex(ibendproj, disk);
115  }
116 
117  unsigned int iphivm =
118  fpgaphi.bits(fpgaphi.nbits() - settings_.nbitsallstubs(layerdisk_) - settings_.nbitsvmme(layerdisk_),
120 
121  //This block of code just checks that the configuration is consistent
122  if (lastTCID >= tracklet->TCID()) {
123  edm::LogPrint("Tracklet") << "Wrong TCID ordering for projections in " << getName();
124  } else {
125  lastTCID = tracklet->TCID();
126  }
127 
128  allproj_->addTracklet(tracklet);
129 
130  vmprojs_[iphivm]->addTracklet(tracklet, allprojcount);
131 
132  allprojcount++;
133  }
134  }
135 
136  if (settings_.writeMonitorData("AP")) {
137  globals_->ofstream("allprojections.txt") << getName() << " " << allproj_->nTracklets() << endl;
138  }
139 
140  if (settings_.writeMonitorData("VMP")) {
141  ofstream& out = globals_->ofstream("chisq.txt");
142  for (unsigned int i = 0; i < 8; i++) {
143  if (vmprojs_[i] != nullptr) {
144  out << vmprojs_[i]->getName() << " " << vmprojs_[i]->nTracklets() << endl;
145  }
146  }
147  }
148 }

References trklet::AllProjectionsMemory::addTracklet(), allproj_, trklet::ProjectionRouterBendTable::bendLoookup(), trklet::FPGAWord::bits(), trklet::Tracklet::fpgaphiproj(), trklet::Tracklet::fpgaphiprojderdisk(), trklet::Tracklet::fpgaphiprojdisk(), trklet::Tracklet::fpgarprojderdisk(), trklet::Tracklet::fpgarprojdisk(), trklet::ProcessBase::getName(), trklet::ProcessBase::globals_, mps_fire::i, inputproj_, layerdisk_, 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, trklet::Globals::projectionRouterBendTable(), trklet::Tracklet::setBendIndex(), trklet::ProcessBase::settings_, trklet::Tracklet::TCID(), trklet::FPGAWord::value(), vmprojs_, and trklet::Settings::writeMonitorData().

Member Data Documentation

◆ allproj_

AllProjectionsMemory* trklet::ProjectionRouter::allproj_
private

Definition at line 35 of file ProjectionRouter.h.

Referenced by addOutput(), and execute().

◆ inputproj_

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

Definition at line 33 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().

◆ vmprojs_

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

Definition at line 36 of file ProjectionRouter.h.

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

mps_fire.i
i
Definition: mps_fire.py:428
trklet::Settings::writetrace
bool writetrace() const
Definition: Settings.h:147
input
static const std::string input
Definition: EdmProvDump.cc:48
trklet::Tracklet::fpgaphiprojdisk
const FPGAWord & fpgaphiprojdisk(int disk) const
Definition: Tracklet.h:266
trklet::AllProjectionsMemory::addTracklet
void addTracklet(Tracklet *tracklet)
Definition: AllProjectionsMemory.h:20
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
trklet::ProjectionRouter::nphiderbits_
int nphiderbits_
Definition: ProjectionRouter.h:31
edm::LogPrint
Log< level::Warning, true > LogPrint
Definition: MessageLogger.h:130
trklet::Settings::nbitsallstubs
unsigned int nbitsallstubs(unsigned int layerdisk) const
Definition: Settings.h:83
cms::cuda::assert
assert(be >=bs)
trklet::ProcessBase::settings_
Settings const & settings_
Definition: ProcessBase.h:44
trklet::ProjectionRouter::layerdisk_
unsigned int layerdisk_
Definition: ProjectionRouter.h:28
trklet::FPGAWord::nbits
int nbits() const
Definition: FPGAWord.h:25
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
trklet::Tracklet::fpgarprojderdisk
const FPGAWord & fpgarprojderdisk(int disk) const
Definition: Tracklet.h:281
trklet::Tracklet
Definition: Tracklet.h:28
trklet::AllProjectionsMemory::nTracklets
unsigned int nTracklets() const
Definition: AllProjectionsMemory.h:22
trklet::ProjectionRouter::inputproj_
std::vector< TrackletProjectionsMemory * > inputproj_
Definition: ProjectionRouter.h:33
trklet::ProjectionRouter::nrbits_
int nrbits_
Definition: ProjectionRouter.h:30
trklet::Settings::nbitsvmme
unsigned int nbitsvmme(unsigned int layerdisk) const
Definition: Settings.h:80
trklet::N_LAYER
constexpr int N_LAYER
Definition: Settings.h:19
trklet::FPGAWord
Definition: FPGAWord.h:9
trklet::ProcessBase::initLayerDisk
void initLayerDisk(unsigned int pos, int &layer, int &disk)
Definition: ProcessBase.cc:45
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
trklet::Tracklet::TCID
int TCID() const
Definition: Tracklet.h:500
trklet::Settings::nvmme
unsigned int nvmme(unsigned int layerdisk) const
Definition: Settings.h:81
trklet::ProjectionRouter::allproj_
AllProjectionsMemory * allproj_
Definition: ProjectionRouter.h:35
trklet::FPGAWord::value
int value() const
Definition: FPGAWord.h:24
trklet::ProjectionRouterBendTable::bendLoookup
int bendLoookup(int diskindex, int bendindex)
Definition: ProjectionRouterBendTable.cc:54
trklet::Tracklet::setBendIndex
void setBendIndex(int bendIndex, int disk)
Definition: Tracklet.h:246
trklet::Globals::projectionRouterBendTable
ProjectionRouterBendTable *& projectionRouterBendTable()
Definition: Globals.h:46
trklet::Settings::writeMonitorData
bool writeMonitorData(std::string module) const
Definition: Settings.h:86
trklet::Globals::ofstream
std::ofstream & ofstream(std::string fname)
Definition: Globals.cc:44
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
mps_setup.memory
memory
Definition: mps_setup.py:156
Exception
Definition: hltDiff.cc:246
trklet::ProcessBase::getName
std::string const & getName() const
Definition: ProcessBase.h:22
trklet::Tracklet::fpgaphiproj
const FPGAWord & fpgaphiproj(int layer) const
Definition: Tracklet.h:104
trklet::ProcessBase::name_
std::string name_
Definition: ProcessBase.h:38
trklet::ProjectionRouter::vmprojs_
std::vector< VMProjectionsMemory * > vmprojs_
Definition: ProjectionRouter.h:36
trklet::Settings::nallstubs
unsigned int nallstubs(unsigned int layerdisk) const
Definition: Settings.h:84
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
trklet::Tracklet::fpgarprojdisk
const FPGAWord & fpgarprojdisk(int disk) const
Definition: Tracklet.h:276
trklet::Settings::maxStep
unsigned int maxStep(std::string module) const
Definition: Settings.h:93
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
trklet::Tracklet::fpgaphiprojderdisk
const FPGAWord & fpgaphiprojderdisk(int disk) const
Definition: Tracklet.h:271
trklet::ProcessBase::globals_
Globals * globals_
Definition: ProcessBase.h:45
trklet::ProcessBase::ProcessBase
ProcessBase(std::string name, Settings const &settings, Globals *global, unsigned int iSector)
Definition: ProcessBase.cc:14
trklet::ProjectionRouterBendTable
Definition: ProjectionRouterBendTable.h:16