CMS 3D CMS Logo

TrackletCalculator.cc
Go to the documentation of this file.
8 
11 
12 using namespace std;
13 using namespace trklet;
14 
15 TrackletCalculator::TrackletCalculator(string name, Settings const& settings, Globals* globals, unsigned int iSector)
16  : TrackletCalculatorBase(name, settings, globals, iSector) {
18 
19  for (unsigned int ilayer = 0; ilayer < N_LAYER; ilayer++) {
20  vector<TrackletProjectionsMemory*> tmp(settings.nallstubs(ilayer), nullptr);
21  trackletprojlayers_.push_back(tmp);
22  }
23 
24  for (unsigned int idisk = 0; idisk < N_DISK; idisk++) {
25  vector<TrackletProjectionsMemory*> tmp(settings.nallstubs(idisk + N_LAYER), nullptr);
26  trackletprojdisks_.push_back(tmp);
27  }
28 
30 
31  // set TC index
32  iTC_ = name_[7] - 'A';
33 
34  TCIndex_ = (iSeed_ << 4) + iTC_;
35  assert(TCIndex_ >= 0 && TCIndex_ <= (int)settings_.ntrackletmax());
36 
38  double phicritFactor =
40  if (std::abs(phicritFactor - 2.) > 0.25)
41  edm::LogPrint("Tracklet")
42  << "TrackletCalculator::TrackletCalculator phicrit approximation may be invalid! Please check.";
43  }
44 }
45 
47  outputProj = dynamic_cast<TrackletProjectionsMemory*>(memory);
48  assert(outputProj != nullptr);
49 }
50 
52  if (settings_.writetrace()) {
53  edm::LogVerbatim("Tracklet") << "In " << name_ << " adding output to " << memory->getName() << " to output "
54  << output;
55  }
56  if (output == "trackpar") {
57  auto* tmp = dynamic_cast<TrackletParametersMemory*>(memory);
58  assert(tmp != nullptr);
60  return;
61  }
62 
63  if (output.substr(0, 7) == "projout") {
64  //output is on the form 'projoutL2PHIC' or 'projoutD3PHIB'
65  auto* tmp = dynamic_cast<TrackletProjectionsMemory*>(memory);
66  assert(tmp != nullptr);
67 
68  unsigned int layerdisk = output[8] - '1'; //layer or disk counting from 0
69  unsigned int phiregion = output[12] - 'A'; //phiregion counting from 0
70 
71  if (output[7] == 'L') {
72  assert(layerdisk < N_LAYER);
73  assert(phiregion < trackletprojlayers_[layerdisk].size());
74  //check that phiregion not already initialized
75  assert(trackletprojlayers_[layerdisk][phiregion] == nullptr);
76  trackletprojlayers_[layerdisk][phiregion] = tmp;
77  return;
78  }
79 
80  if (output[7] == 'D') {
81  assert(layerdisk < N_DISK);
82  assert(phiregion < trackletprojdisks_[layerdisk].size());
83  //check that phiregion not already initialized
84  assert(trackletprojdisks_[layerdisk][phiregion] == nullptr);
85  trackletprojdisks_[layerdisk][phiregion] = tmp;
86  return;
87  }
88  }
89 
90  throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find output : " << output;
91 }
92 
94  if (settings_.writetrace()) {
95  edm::LogVerbatim("Tracklet") << "In " << name_ << " adding input from " << memory->getName() << " to input "
96  << input;
97  }
98  if (input == "innerallstubin") {
99  auto* tmp = dynamic_cast<AllStubsMemory*>(memory);
100  assert(tmp != nullptr);
101  innerallstubs_.push_back(tmp);
102  return;
103  }
104  if (input == "outerallstubin") {
105  auto* tmp = dynamic_cast<AllStubsMemory*>(memory);
106  assert(tmp != nullptr);
107  outerallstubs_.push_back(tmp);
108  return;
109  }
110  if (input.substr(0, 8) == "stubpair") {
111  auto* tmp = dynamic_cast<StubPairsMemory*>(memory);
112  assert(tmp != nullptr);
113  stubpairs_.push_back(tmp);
114  return;
115  }
116  throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find intput : " << input;
117 }
118 
120  unsigned int countall = 0;
121  unsigned int countsel = 0;
122 
123  for (auto& stubpair : stubpairs_) {
125  edm::LogVerbatim("Tracklet") << "Will break on too many tracklets in " << getName();
126  break;
127  }
128  for (unsigned int i = 0; i < stubpair->nStubPairs(); i++) {
129  countall++;
130  const Stub* innerFPGAStub = stubpair->getVMStub1(i).stub();
131  const L1TStub* innerStub = innerFPGAStub->l1tstub();
132 
133  const Stub* outerFPGAStub = stubpair->getVMStub2(i).stub();
134  const L1TStub* outerStub = outerFPGAStub->l1tstub();
135 
136  if (settings_.debugTracklet()) {
137  edm::LogVerbatim("Tracklet") << "TrackletCalculator execute " << getName() << "[" << iSector_ << "]";
138  }
139 
140  if (innerFPGAStub->isBarrel() && (getName() != "TC_D1L2A" && getName() != "TC_D1L2B")) {
141  if (outerFPGAStub->isDisk()) {
142  //overlap seeding
143  bool accept = overlapSeeding(outerFPGAStub, outerStub, innerFPGAStub, innerStub);
144  if (accept)
145  countsel++;
146  } else {
147  //barrel+barrel seeding
148  bool accept = barrelSeeding(innerFPGAStub, innerStub, outerFPGAStub, outerStub);
149  if (accept)
150  countsel++;
151  }
152  } else {
153  if (outerFPGAStub->isDisk()) {
154  //disk+disk seeding
155  bool accept = diskSeeding(innerFPGAStub, innerStub, outerFPGAStub, outerStub);
156  if (accept)
157  countsel++;
158  } else if (innerFPGAStub->isDisk()) {
159  //layer+disk seeding
160  bool accept = overlapSeeding(innerFPGAStub, innerStub, outerFPGAStub, outerStub);
161  if (accept)
162  countsel++;
163  } else {
164  throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " invalid seeding";
165  }
166  }
167 
169  edm::LogVerbatim("Tracklet") << "Will break on number of tracklets in " << getName();
170  break;
171  }
172 
173  if (countall >= settings_.maxStep("TC")) {
174  if (settings_.debugTracklet())
175  edm::LogVerbatim("Tracklet") << "Will break on MAXTC 1";
176  break;
177  }
178  if (settings_.debugTracklet()) {
179  edm::LogVerbatim("Tracklet") << "TrackletCalculator execute done";
180  }
181  }
182  if (countall >= settings_.maxStep("TC")) {
183  if (settings_.debugTracklet())
184  edm::LogVerbatim("Tracklet") << "Will break on MAXTC 2";
185  break;
186  }
187  }
188 
189  if (settings_.writeMonitorData("TC")) {
190  globals_->ofstream("trackletcalculator.txt") << getName() << " " << countall << " " << countsel << endl;
191  }
192 }
Settings.h
trklet::TrackletCalculatorBase::iSeed_
unsigned int iSeed_
Definition: TrackletCalculatorBase.h:128
mps_fire.i
i
Definition: mps_fire.py:428
trklet::Settings::ntrackletmax
unsigned int ntrackletmax() const
Definition: Settings.h:274
trklet::Settings::writetrace
bool writetrace() const
Definition: Settings.h:147
input
static const std::string input
Definition: EdmProvDump.cc:48
trklet::TrackletCalculatorBase::phioffset_
double phioffset_
Definition: TrackletCalculatorBase.h:134
MessageLogger.h
trklet::TrackletCalculator::addOutputProjection
void addOutputProjection(TrackletProjectionsMemory *&outputProj, MemoryBase *memory)
Definition: TrackletCalculator.cc:46
trklet::TrackletCalculatorBase::trackletpars_
TrackletParametersMemory * trackletpars_
Definition: TrackletCalculatorBase.h:139
trklet::TrackletCalculator::outerallstubs_
std::vector< AllStubsMemory * > outerallstubs_
Definition: TrackletCalculator.h:34
AllStubsMemory.h
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
trklet::TrackletProjectionsMemory
Definition: TrackletProjectionsMemory.h:15
edm::LogPrint
Log< level::Warning, true > LogPrint
Definition: MessageLogger.h:130
trklet::Settings
Definition: Settings.h:26
trklet::TrackletCalculator::iTC_
int iTC_
Definition: TrackletCalculator.h:31
trklet::L1TStub
Definition: L1TStub.h:12
cms::cuda::assert
assert(be >=bs)
trklet::TrackletCalculatorBase::barrelSeeding
bool barrelSeeding(const Stub *innerFPGAStub, const L1TStub *innerStub, const Stub *outerFPGAStub, const L1TStub *outerStub)
Definition: TrackletCalculatorBase.cc:331
trklet::N_DISK
constexpr int N_DISK
Definition: Settings.h:20
trklet::ProcessBase::settings_
Settings const & settings_
Definition: ProcessBase.h:44
TrackletCalculator.h
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
trklet::Globals
Definition: Globals.h:32
trklet::TrackletCalculatorBase::trackletprojlayers_
std::vector< std::vector< TrackletProjectionsMemory * > > trackletprojlayers_
Definition: TrackletCalculatorBase.h:142
trklet::Stub::isBarrel
bool isBarrel() const
Definition: Stub.h:60
TrackletProjectionsMemory.h
accept
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:30
trklet::Stub
Definition: Stub.h:16
trklet::N_LAYER
constexpr int N_LAYER
Definition: Settings.h:19
trklet::ProcessBase::initLayerDisksandISeed
void initLayerDisksandISeed(unsigned int &layerdisk1, unsigned int &layerdisk2, unsigned int &iSeed)
Definition: ProcessBase.cc:75
trklet::TrackletCalculatorBase::diskSeeding
bool diskSeeding(const Stub *innerFPGAStub, const L1TStub *innerStub, const Stub *outerFPGAStub, const L1TStub *outerStub)
Definition: TrackletCalculatorBase.cc:753
trklet::Stub::isDisk
bool isDisk() const
Definition: Stub.h:61
trklet::TrackletCalculatorBase
Definition: TrackletCalculatorBase.h:18
trklet::MemoryBase
Definition: MemoryBase.h:13
trklet::TrackletCalculatorBase::layerdisk1_
unsigned int layerdisk1_
Definition: TrackletCalculatorBase.h:129
trklet::TrackletCalculatorBase::layerdisk2_
unsigned int layerdisk2_
Definition: TrackletCalculatorBase.h:130
trklet::VarBase::K
double K() const
Definition: imath.h:246
trklet::Globals::ITC_L1L2
IMATH_TrackletCalculator * ITC_L1L2()
Definition: Globals.h:52
trklet::TrackletCalculatorBase::overlapSeeding
bool overlapSeeding(const Stub *innerFPGAStub, const L1TStub *innerStub, const Stub *outerFPGAStub, const L1TStub *outerStub)
Definition: TrackletCalculatorBase.cc:1108
trklet::IMATH_TrackletCalculator::phi0_final
VarAdjustK phi0_final
Definition: IMATH_TrackletCalculator.h:218
StubPairsMemory.h
trklet::TrackletCalculatorBase::trackletprojdisks_
std::vector< std::vector< TrackletProjectionsMemory * > > trackletprojdisks_
Definition: TrackletCalculatorBase.h:143
Globals.h
trklet
Definition: AllProjectionsMemory.h:9
IMATH_TrackletCalculator.h
trklet::IMATH_TrackletCalculator::rinv_final
VarAdjustK rinv_final
Definition: IMATH_TrackletCalculator.h:216
trklet::Settings::writeMonitorData
bool writeMonitorData(std::string module) const
Definition: Settings.h:86
trklet::TrackletCalculatorBase::TCIndex_
int TCIndex_
Definition: TrackletCalculatorBase.h:132
std
Definition: JetResolutionObject.h:76
trklet::TrackletParametersMemory::nTracklets
unsigned int nTracklets() const
Definition: TrackletParametersMemory.h:25
trklet::Settings::usephicritapprox
bool usephicritapprox() const
Definition: Settings.h:194
trklet::Globals::ofstream
std::ofstream & ofstream(std::string fname)
Definition: Globals.cc:44
trklet::Stub::l1tstub
L1TStub * l1tstub()
Definition: Stub.h:69
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::ProcessBase::name_
std::string name_
Definition: ProcessBase.h:38
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::ProcessBase::iSector_
unsigned int iSector_
Definition: ProcessBase.h:39
trklet::Settings::debugTracklet
bool debugTracklet() const
Definition: Settings.h:146
trklet::Settings::rcrit
double rcrit() const
Definition: Settings.h:236
Exception.h
trklet::Settings::maxStep
unsigned int maxStep(std::string module) const
Definition: Settings.h:93
trklet::TrackletCalculator::addOutput
void addOutput(MemoryBase *memory, std::string output) override
Definition: TrackletCalculator.cc:51
trklet::TrackletCalculator::innerallstubs_
std::vector< AllStubsMemory * > innerallstubs_
Definition: TrackletCalculator.h:33
trklet::ProcessBase::phimin_
double phimin_
Definition: ProcessBase.h:41
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
trklet::TrackletCalculator::execute
void execute()
Definition: TrackletCalculator.cc:119
trklet::ProcessBase::globals_
Globals * globals_
Definition: ProcessBase.h:45
trklet::TrackletCalculator::addInput
void addInput(MemoryBase *memory, std::string input) override
Definition: TrackletCalculator.cc:93
edm::Log
Definition: MessageLogger.h:70
trklet::TrackletCalculator::stubpairs_
std::vector< StubPairsMemory * > stubpairs_
Definition: TrackletCalculator.h:35
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443