CMS 3D CMS Logo

ProjectionRouter.cc
Go to the documentation of this file.
6 
9 
10 using namespace std;
11 using namespace trklet;
12 
13 ProjectionRouter::ProjectionRouter(string name, Settings const& settings, Globals* global, unsigned int iSector)
14  : ProcessBase(name, settings, global, iSector) {
16 
17  vmprojs_.resize(settings_.nvmme(layerdisk_), nullptr);
18 
19  nrbits_ = 5;
20  nphiderbits_ = 6;
21 }
22 
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 }
54 
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 }
68 
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 =
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 }
Settings.h
trklet::ProjectionRouter::execute
void execute()
Definition: ProjectionRouter.cc:69
mps_fire.i
i
Definition: mps_fire.py:355
trklet::Settings::writetrace
bool writetrace() const
Definition: Settings.h:147
input
static const std::string input
Definition: EdmProvDump.cc:48
MessageLogger.h
ProjectionRouter.h
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:32
trklet::ProjectionRouter::nphiderbits_
int nphiderbits_
Definition: ProjectionRouter.h:31
trklet::Settings
Definition: Settings.h:26
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::Globals
Definition: Globals.h:32
trklet::Tracklet::fpgarprojderdisk
const FPGAWord & fpgarprojderdisk(int disk) const
Definition: Tracklet.h:281
trklet::Tracklet
Definition: Tracklet.h:28
FPGAWord.h
trklet::AllProjectionsMemory::nTracklets
unsigned int nTracklets() const
Definition: AllProjectionsMemory.h:22
trklet::ProjectionRouter::addInput
void addInput(MemoryBase *memory, std::string input) override
Definition: ProjectionRouter.cc:55
trklet::ProjectionRouter::inputproj_
std::vector< TrackletProjectionsMemory * > inputproj_
Definition: ProjectionRouter.h:33
trklet::FPGAWord::bits
unsigned int bits(unsigned int lsb, unsigned int nbit) const
Definition: FPGAWord.cc:74
trklet::ProjectionRouter::nrbits_
int nrbits_
Definition: ProjectionRouter.h:30
trklet::ProjectionRouter::addOutput
void addOutput(MemoryBase *memory, std::string output) override
Definition: ProjectionRouter.cc:23
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::MemoryBase
Definition: MemoryBase.h:13
trklet::Tracklet::TCID
int TCID() const
Definition: Tracklet.h:500
trklet::Settings::nvmme
unsigned int nvmme(unsigned int layerdisk) const
Definition: Settings.h:81
Globals.h
edm::LogVerbatim
Definition: MessageLogger.h:297
edm::LogPrint
Definition: MessageLogger.h:342
trklet::ProjectionRouter::allproj_
AllProjectionsMemory * allproj_
Definition: ProjectionRouter.h:35
trklet
Definition: AllProjectionsMemory.h:9
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
std
Definition: JetResolutionObject.h:76
trklet::ProcessBase
Definition: ProcessBase.h:12
trklet::Globals::ofstream
std::ofstream & ofstream(std::string fname)
Definition: Globals.cc:44
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
Exception.h
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
Tracklet.h
trklet::ProjectionRouterBendTable
Definition: ProjectionRouterBendTable.h:16
memory
Definition: vlib.h:178