CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes
trklet::TrackletCalculatorDisplaced Class Reference

#include <TrackletCalculatorDisplaced.h>

Inheritance diagram for trklet::TrackletCalculatorDisplaced:
trklet::ProcessBase trklet::TrackletProcessorDisplaced

Public Member Functions

void addDiskProj (Tracklet *tracklet, int disk)
 
void addInput (MemoryBase *memory, std::string input) override
 
bool addLayerProj (Tracklet *tracklet, int layer)
 
void addOutput (MemoryBase *memory, std::string output) override
 
void addOutputProjection (TrackletProjectionsMemory *&outputProj, MemoryBase *memory)
 
void addProjection (int layer, int iphi, TrackletProjectionsMemory *trackletprojs, Tracklet *tracklet)
 
void addProjectionDisk (int disk, int iphi, TrackletProjectionsMemory *trackletprojs, Tracklet *tracklet)
 
void approxproj (double halfRinv, double phi0, double d0, double t, double z0, double halfRinv_0, double d0_0, double rmean, double &phiproj, double &phiprojder, double &zproj, double &zprojder)
 
void approxprojdisk (double halfRinv, double phi0, double d0, double t, double z0, double halfRinv_0, double d0_0, double zmean, double &phiproj, double &phiprojder, double &rproj, double &rprojder)
 
void approxtracklet (double r1, double z1, double phi1, double r2, double z2, double phi2, double r3, double z3, double phi3, bool take3, unsigned ndisks, double &rinv, double &phi0, double &d0, double &t, double &z0, double phiproj[4], double zproj[4], double phider[4], double zder[4], double phiprojdisk[5], double rprojdisk[5], double phiderdisk[5], double rderdisk[5])
 
bool DDLSeeding (const Stub *innerFPGAStub, const L1TStub *innerStub, const Stub *middleFPGAStub, const L1TStub *middleStub, const Stub *outerFPGAStub, const L1TStub *outerStub)
 
void exactproj (double rproj, double rinv, double phi0, double d0, double t, double z0, double r0, double &phiproj, double &zproj, double &phider, double &zder)
 
void exactprojdisk (double zproj, double rinv, double, double, double t, double z0, double x0, double y0, double &phiproj, double &rproj, double &phider, double &rder)
 
void exacttracklet (double r1, double z1, double phi1, double r2, double z2, double phi2, double r3, double z3, double phi3, int take3, double &rinv, double &phi0, double &d0, double &t, double &z0, double phiproj[N_LAYER - 2], double zproj[N_LAYER - 2], double phiprojdisk[N_DISK], double rprojdisk[N_DISK], double phider[N_LAYER - 2], double zder[N_LAYER - 2], double phiderdisk[N_DISK], double rderdisk[N_DISK])
 
void execute (unsigned int iSector, double phimin, double phimax)
 
bool LLDSeeding (const Stub *innerFPGAStub, const L1TStub *innerStub, const Stub *middleFPGAStub, const L1TStub *middleStub, const Stub *outerFPGAStub, const L1TStub *outerStub)
 
bool LLLSeeding (const Stub *innerFPGAStub, const L1TStub *innerStub, const Stub *middleFPGAStub, const L1TStub *middleStub, const Stub *outerFPGAStub, const L1TStub *outerStub)
 
 TrackletCalculatorDisplaced (std::string name, Settings const &settings, Globals *global)
 
 ~TrackletCalculatorDisplaced () 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)
 
void initLayerDisksandISeedDisp (unsigned int &layerdisk1, unsigned int &layerdisk2, unsigned int &layerdisk3, unsigned int &iSeed)
 
unsigned int nbits (unsigned int power)
 
 ProcessBase (std::string name, Settings const &settings, Globals *global)
 
virtual ~ProcessBase ()=default
 

Protected Attributes

int disk_
 
int dproj_ [N_DISK - 2]
 
std::vector< AllStubsMemory * > innerallstubs_
 
unsigned int iSector_
 
unsigned int iSeed_
 
int layer_
 
int lproj_ [N_LAYER - 2]
 
std::vector< AllStubsMemory * > middleallstubs_
 
std::vector< AllStubsMemory * > outerallstubs_
 
double phimax_
 
double phimin_
 
double rproj_ [N_LAYER - 2]
 
double rzmeanInv_ [N_DISK - 2]
 
std::vector< StubTripletsMemory * > stubtriplets_
 
int TCIndex_
 
std::vector< double > toR_
 
std::vector< double > toZ_
 
TrackletParametersMemorytrackletpars_
 
std::vector< std::vector< TrackletProjectionsMemory * > > trackletprojdisks_
 
std::vector< std::vector< TrackletProjectionsMemory * > > trackletprojlayers_
 
double zproj_ [N_DISK - 2]
 
- Protected Attributes inherited from trklet::ProcessBase
Globalsglobals_
 
std::string name_
 
Settings const & settings_
 

Detailed Description

Definition at line 20 of file TrackletCalculatorDisplaced.h.

Constructor & Destructor Documentation

◆ TrackletCalculatorDisplaced()

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

Definition at line 16 of file TrackletCalculatorDisplaced.cc.

References cms::cuda::assert(), disk_, dproj_, mps_fire::i, iSeed_, layer_, lproj_, trklet::N_DISK, trklet::N_LAYER, trklet::Settings::nallstubs(), mergeVDriftHistosByStation::name, trklet::Settings::rmean(), rproj_, rzmeanInv_, trklet::ProcessBase::settings_, TCIndex_, createJobs::tmp, toR_, toZ_, trackletprojdisks_, trackletprojlayers_, trklet::Settings::zmean(), and zproj_.

17  : ProcessBase(name, settings, global) {
18  for (unsigned int ilayer = 0; ilayer < N_LAYER; ilayer++) {
19  vector<TrackletProjectionsMemory*> tmp(settings.nallstubs(ilayer), nullptr);
20  trackletprojlayers_.push_back(tmp);
21  }
22 
23  for (unsigned int idisk = 0; idisk < N_DISK; idisk++) {
24  vector<TrackletProjectionsMemory*> tmp(settings.nallstubs(idisk + N_LAYER), nullptr);
25  trackletprojdisks_.push_back(tmp);
26  }
27 
28  layer_ = 0;
29  disk_ = 0;
30 
31  string name1 = name.substr(1); //this is to correct for "TCD" having one more letter then "TC"
32  if (name1[3] == 'L')
33  layer_ = name1[4] - '0';
34  if (name1[3] == 'D')
35  disk_ = name1[4] - '0';
36 
37  // set TC index
38  iSeed_ = 0;
39 
40  int iTC = name1[9] - 'A';
41 
42  if (name1.substr(3, 6) == "L3L4L2")
43  iSeed_ = 8;
44  else if (name1.substr(3, 6) == "L5L6L4")
45  iSeed_ = 9;
46  else if (name1.substr(3, 6) == "L2L3D1")
47  iSeed_ = 10;
48  else if (name1.substr(3, 6) == "D1D2L2")
49  iSeed_ = 11;
50 
51  assert(iSeed_ != 0);
52 
53  TCIndex_ = (iSeed_ << 4) + iTC;
54  assert(TCIndex_ >= 128 && TCIndex_ < 191);
55 
56  assert((layer_ != 0) || (disk_ != 0));
57 
58  toR_.clear();
59  toZ_.clear();
60 
61  if (iSeed_ == 8 || iSeed_ == 9) {
62  if (layer_ == 3) {
63  rzmeanInv_[0] = 1.0 / settings_.rmean(2 - 1);
64  rzmeanInv_[1] = 1.0 / settings_.rmean(3 - 1);
65  rzmeanInv_[2] = 1.0 / settings_.rmean(4 - 1);
66 
67  rproj_[0] = settings_.rmean(0);
68  rproj_[1] = settings_.rmean(4);
69  rproj_[2] = settings_.rmean(5);
70  lproj_[0] = 1;
71  lproj_[1] = 5;
72  lproj_[2] = 6;
73 
74  dproj_[0] = 1;
75  dproj_[1] = 2;
76  dproj_[2] = 0;
77  toZ_.push_back(settings_.zmean(0));
78  toZ_.push_back(settings_.zmean(1));
79  }
80  if (layer_ == 5) {
81  rzmeanInv_[0] = 1.0 / settings_.rmean(4 - 1);
82  rzmeanInv_[1] = 1.0 / settings_.rmean(5 - 1);
83  rzmeanInv_[2] = 1.0 / settings_.rmean(6 - 1);
84 
85  rproj_[0] = settings_.rmean(0);
86  rproj_[1] = settings_.rmean(1);
87  rproj_[2] = settings_.rmean(2);
88  lproj_[0] = 1;
89  lproj_[1] = 2;
90  lproj_[2] = 3;
91 
92  dproj_[0] = 0;
93  dproj_[1] = 0;
94  dproj_[2] = 0;
95  }
96  for (unsigned int i = 0; i < N_LAYER - 3; ++i)
97  toR_.push_back(rproj_[i]);
98  }
99 
100  if (iSeed_ == 10 || iSeed_ == 11) {
101  if (layer_ == 2) {
102  rzmeanInv_[0] = 1.0 / settings_.rmean(2 - 1);
103  rzmeanInv_[1] = 1.0 / settings_.rmean(3 - 1);
104  rzmeanInv_[2] = 1.0 / settings_.zmean(1 - 1);
105 
106  rproj_[0] = settings_.rmean(0);
107  lproj_[0] = 1;
108  lproj_[1] = -1;
109  lproj_[2] = -1;
110 
111  zproj_[0] = settings_.zmean(1);
112  zproj_[1] = settings_.zmean(2);
113  zproj_[2] = settings_.zmean(3);
114  dproj_[0] = 2;
115  dproj_[1] = 3;
116  dproj_[2] = 4;
117  }
118  if (disk_ == 1) {
119  rzmeanInv_[0] = 1.0 / settings_.rmean(2 - 1);
120  rzmeanInv_[1] = 1.0 / settings_.zmean(1 - 1);
121  rzmeanInv_[2] = 1.0 / settings_.zmean(2 - 1);
122 
123  rproj_[0] = settings_.rmean(0);
124  lproj_[0] = 1;
125  lproj_[1] = -1;
126  lproj_[2] = -1;
127 
128  zproj_[0] = settings_.zmean(2);
129  zproj_[1] = settings_.zmean(3);
130  zproj_[2] = settings_.zmean(4);
131  dproj_[0] = 3;
132  dproj_[1] = 4;
133  dproj_[2] = 5;
134  }
135  toR_.push_back(settings_.rmean(0));
136  for (unsigned int i = 0; i < N_DISK - 2; ++i)
137  toZ_.push_back(zproj_[i]);
138  }
139 }
constexpr int N_DISK
Definition: Settings.h:26
Settings const & settings_
Definition: ProcessBase.h:44
assert(be >=bs)
ProcessBase(std::string name, Settings const &settings, Globals *global)
Definition: ProcessBase.cc:14
std::vector< std::vector< TrackletProjectionsMemory * > > trackletprojlayers_
double rmean(unsigned int iLayer) const
Definition: Settings.h:173
std::vector< std::vector< TrackletProjectionsMemory * > > trackletprojdisks_
double zmean(unsigned int iDisk) const
Definition: Settings.h:176
tmp
align.sh
Definition: createJobs.py:716
constexpr int N_LAYER
Definition: Settings.h:25

◆ ~TrackletCalculatorDisplaced()

trklet::TrackletCalculatorDisplaced::~TrackletCalculatorDisplaced ( )
overridedefault

Member Function Documentation

◆ addDiskProj()

void TrackletCalculatorDisplaced::addDiskProj ( Tracklet tracklet,
int  disk 
)

Definition at line 301 of file TrackletCalculatorDisplaced.cc.

References funct::abs(), addProjectionDisk(), trklet::Projection::fpgaphiproj(), trklet::Projection::fpgarzproj(), hcalRecHitTable_cff::iphi, trklet::Settings::krprojshiftdisk(), trklet::N_LAYER, trklet::Settings::nallstubs(), trklet::FPGAWord::nbits(), trklet::Tracklet::proj(), trklet::Settings::rmaxdisk(), trklet::Settings::rmindiskvm(), trklet::ProcessBase::settings_, trackletprojdisks_, and trklet::FPGAWord::value().

Referenced by DDLSeeding(), LLDSeeding(), and LLLSeeding().

301  {
302  disk = std::abs(disk);
303  FPGAWord fpgar = tracklet->proj(N_LAYER + disk - 1).fpgarzproj();
304 
305  if (fpgar.value() * settings_.krprojshiftdisk() < settings_.rmindiskvm())
306  return;
307  if (fpgar.value() * settings_.krprojshiftdisk() > settings_.rmaxdisk())
308  return;
309 
310  FPGAWord fpgaphi = tracklet->proj(N_LAYER + disk - 1).fpgaphiproj();
311 
312  int iphivmRaw = fpgaphi.value() >> (fpgaphi.nbits() - 5);
313  int iphi = iphivmRaw / (32 / settings_.nallstubs(disk + N_LAYER - 1));
314 
315  addProjectionDisk(disk, iphi, trackletprojdisks_[disk - 1][iphi], tracklet);
316 }
Projection & proj(int layerdisk)
Definition: Tracklet.h:87
Settings const & settings_
Definition: ProcessBase.h:44
double rmindiskvm() const
Definition: Settings.h:362
const FPGAWord & fpgaphiproj() const
Definition: Projection.h:39
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int value() const
Definition: FPGAWord.h:24
std::vector< std::vector< TrackletProjectionsMemory * > > trackletprojdisks_
unsigned int nallstubs(unsigned int layerdisk) const
Definition: Settings.h:116
double rmaxdisk() const
Definition: Settings.h:134
int nbits() const
Definition: FPGAWord.h:25
const FPGAWord & fpgarzproj() const
Definition: Projection.h:44
double krprojshiftdisk() const
Definition: Settings.h:448
void addProjectionDisk(int disk, int iphi, TrackletProjectionsMemory *trackletprojs, Tracklet *tracklet)
constexpr int N_LAYER
Definition: Settings.h:25

◆ addInput()

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

Implements trklet::ProcessBase.

Reimplemented in trklet::TrackletProcessorDisplaced.

Definition at line 189 of file TrackletCalculatorDisplaced.cc.

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

189  {
190  if (settings_.writetrace()) {
191  edm::LogVerbatim("Tracklet") << "In " << name_ << " adding input from " << memory->getName() << " to input "
192  << input;
193  }
194 
195  if (input == "thirdallstubin") {
196  auto* tmp = dynamic_cast<AllStubsMemory*>(memory);
197  assert(tmp != nullptr);
198  innerallstubs_.push_back(tmp);
199  return;
200  }
201  if (input == "firstallstubin") {
202  auto* tmp = dynamic_cast<AllStubsMemory*>(memory);
203  assert(tmp != nullptr);
204  middleallstubs_.push_back(tmp);
205  return;
206  }
207  if (input == "secondallstubin") {
208  auto* tmp = dynamic_cast<AllStubsMemory*>(memory);
209  assert(tmp != nullptr);
210  outerallstubs_.push_back(tmp);
211  return;
212  }
213  if (input.find("stubtriplet") == 0) {
214  auto* tmp = dynamic_cast<StubTripletsMemory*>(memory);
215  assert(tmp != nullptr);
216  stubtriplets_.push_back(tmp);
217  return;
218  }
219  throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find input : " << input;
220 }
Log< level::Info, true > LogVerbatim
std::vector< AllStubsMemory * > middleallstubs_
std::vector< StubTripletsMemory * > stubtriplets_
std::string name_
Definition: ProcessBase.h:42
std::vector< AllStubsMemory * > innerallstubs_
Settings const & settings_
Definition: ProcessBase.h:44
bool writetrace() const
Definition: Settings.h:195
assert(be >=bs)
static std::string const input
Definition: EdmProvDump.cc:50
std::vector< AllStubsMemory * > outerallstubs_
tmp
align.sh
Definition: createJobs.py:716

◆ addLayerProj()

bool TrackletCalculatorDisplaced::addLayerProj ( Tracklet tracklet,
int  layer 
)

Definition at line 318 of file TrackletCalculatorDisplaced.cc.

References funct::abs(), addProjection(), cms::cuda::assert(), trklet::FPGAWord::atExtreme(), trklet::Projection::fpgaphiproj(), trklet::Projection::fpgarzproj(), hcalRecHitTable_cff::iphi, trklet::Settings::kz(), trklet::Settings::nallstubs(), trklet::FPGAWord::nbits(), trklet::Tracklet::proj(), trklet::ProcessBase::settings_, trackletprojlayers_, trklet::FPGAWord::value(), and trklet::Settings::zlength().

Referenced by DDLSeeding(), LLDSeeding(), and LLLSeeding().

318  {
319  assert(layer > 0);
320 
321  FPGAWord fpgaz = tracklet->proj(layer - 1).fpgarzproj();
322  FPGAWord fpgaphi = tracklet->proj(layer - 1).fpgaphiproj();
323 
324  if (fpgaz.atExtreme())
325  return false;
326 
327  if (std::abs(fpgaz.value() * settings_.kz()) > settings_.zlength())
328  return false;
329 
330  int iphivmRaw = fpgaphi.value() >> (fpgaphi.nbits() - 5);
331  int iphi = iphivmRaw / (32 / settings_.nallstubs(layer - 1));
332 
333  addProjection(layer, iphi, trackletprojlayers_[layer - 1][iphi], tracklet);
334 
335  return true;
336 }
double kz() const
Definition: Settings.h:349
double zlength() const
Definition: Settings.h:133
Projection & proj(int layerdisk)
Definition: Tracklet.h:87
Settings const & settings_
Definition: ProcessBase.h:44
void addProjection(int layer, int iphi, TrackletProjectionsMemory *trackletprojs, Tracklet *tracklet)
assert(be >=bs)
const FPGAWord & fpgaphiproj() const
Definition: Projection.h:39
std::vector< std::vector< TrackletProjectionsMemory * > > trackletprojlayers_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int value() const
Definition: FPGAWord.h:24
unsigned int nallstubs(unsigned int layerdisk) const
Definition: Settings.h:116
int nbits() const
Definition: FPGAWord.h:25
const FPGAWord & fpgarzproj() const
Definition: Projection.h:44
bool atExtreme() const
Definition: FPGAWord.cc:79

◆ addOutput()

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

Implements trklet::ProcessBase.

Reimplemented in trklet::TrackletProcessorDisplaced.

Definition at line 146 of file TrackletCalculatorDisplaced.cc.

References cms::cuda::assert(), Exception, mps_setup::memory, trklet::N_DISK, trklet::N_LAYER, trklet::ProcessBase::name_, convertSQLitetoXML_cfg::output, trklet::ProcessBase::settings_, createJobs::tmp, trackletpars_, trackletprojdisks_, trackletprojlayers_, and trklet::Settings::writetrace().

146  {
147  if (settings_.writetrace()) {
148  edm::LogVerbatim("Tracklet") << "In " << name_ << " adding output to " << memory->getName() << " to output "
149  << output;
150  }
151 
152  if (output == "trackpar") {
153  auto* tmp = dynamic_cast<TrackletParametersMemory*>(memory);
154  assert(tmp != nullptr);
155  trackletpars_ = tmp;
156  return;
157  }
158 
159  if (output.substr(0, 7) == "projout") {
160  //output is on the form 'projoutL2PHIC' or 'projoutD3PHIB'
161  auto* tmp = dynamic_cast<TrackletProjectionsMemory*>(memory);
162  assert(tmp != nullptr);
163 
164  unsigned int layerdisk = output[8] - '1'; //layer or disk counting from 0
165  unsigned int phiregion = output[12] - 'A'; //phiregion counting from 0
166 
167  if (output[7] == 'L') {
168  assert(layerdisk < N_LAYER);
169  assert(phiregion < trackletprojlayers_[layerdisk].size());
170  //check that phiregion not already initialized
171  assert(trackletprojlayers_[layerdisk][phiregion] == nullptr);
172  trackletprojlayers_[layerdisk][phiregion] = tmp;
173  return;
174  }
175 
176  if (output[7] == 'D') {
177  assert(layerdisk < N_DISK);
178  assert(phiregion < trackletprojdisks_[layerdisk].size());
179  //check that phiregion not already initialized
180  assert(trackletprojdisks_[layerdisk][phiregion] == nullptr);
181  trackletprojdisks_[layerdisk][phiregion] = tmp;
182  return;
183  }
184  }
185 
186  throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find output : " << output;
187 }
size
Write out results.
Log< level::Info, true > LogVerbatim
constexpr int N_DISK
Definition: Settings.h:26
std::string name_
Definition: ProcessBase.h:42
Settings const & settings_
Definition: ProcessBase.h:44
bool writetrace() const
Definition: Settings.h:195
assert(be >=bs)
std::vector< std::vector< TrackletProjectionsMemory * > > trackletprojlayers_
std::vector< std::vector< TrackletProjectionsMemory * > > trackletprojdisks_
Definition: output.py:1
tmp
align.sh
Definition: createJobs.py:716
constexpr int N_LAYER
Definition: Settings.h:25

◆ addOutputProjection()

void TrackletCalculatorDisplaced::addOutputProjection ( TrackletProjectionsMemory *&  outputProj,
MemoryBase memory 
)

Definition at line 141 of file TrackletCalculatorDisplaced.cc.

References cms::cuda::assert(), and mps_setup::memory.

141  {
142  outputProj = dynamic_cast<TrackletProjectionsMemory*>(memory);
143  assert(outputProj != nullptr);
144 }
assert(be >=bs)

◆ addProjection()

void TrackletCalculatorDisplaced::addProjection ( int  layer,
int  iphi,
TrackletProjectionsMemory trackletprojs,
Tracklet tracklet 
)

Definition at line 338 of file TrackletCalculatorDisplaced.cc.

References trklet::TrackletProjectionsMemory::addProj(), cms::cuda::assert(), trklet::ProcessBase::getName(), hcalRecHitTable_cff::iphi, trklet::ProcessBase::settings_, and trklet::Settings::warnNoMem().

Referenced by addLayerProj().

341  {
342  if (trackletprojs == nullptr) {
343  if (settings_.warnNoMem()) {
344  edm::LogVerbatim("Tracklet") << "No projection memory exists in " << getName() << " for layer = " << layer
345  << " iphi = " << iphi + 1;
346  }
347  return;
348  }
349  assert(trackletprojs != nullptr);
350  trackletprojs->addProj(tracklet);
351 }
Log< level::Info, true > LogVerbatim
Settings const & settings_
Definition: ProcessBase.h:44
assert(be >=bs)
bool warnNoMem() const
Definition: Settings.h:197
std::string const & getName() const
Definition: ProcessBase.h:22

◆ addProjectionDisk()

void TrackletCalculatorDisplaced::addProjectionDisk ( int  disk,
int  iphi,
TrackletProjectionsMemory trackletprojs,
Tracklet tracklet 
)

Definition at line 353 of file TrackletCalculatorDisplaced.cc.

References funct::abs(), trklet::TrackletProjectionsMemory::addProj(), cms::cuda::assert(), trklet::Settings::debugTracklet(), trklet::MemoryBase::getName(), trklet::ProcessBase::getName(), hcalRecHitTable_cff::iphi, layer_, trklet::ProcessBase::settings_, and trklet::Settings::warnNoMem().

Referenced by addDiskProj().

356  {
357  if (trackletprojs == nullptr) {
358  if (layer_ == 3 && abs(disk) == 3)
359  return; //L3L4 projections to D3 are not used.
360  if (settings_.warnNoMem()) {
361  edm::LogVerbatim("Tracklet") << "No projection memory exists in " << getName() << " for disk = " << abs(disk)
362  << " iphi = " << iphi + 1;
363  }
364  return;
365  }
366  assert(trackletprojs != nullptr);
367  if (settings_.debugTracklet())
368  edm::LogVerbatim("Tracklet") << getName() << " adding projection to " << trackletprojs->getName();
369  trackletprojs->addProj(tracklet);
370 }
Log< level::Info, true > LogVerbatim
Settings const & settings_
Definition: ProcessBase.h:44
assert(be >=bs)
bool warnNoMem() const
Definition: Settings.h:197
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::string const & getName() const
Definition: MemoryBase.h:19
bool debugTracklet() const
Definition: Settings.h:194
std::string const & getName() const
Definition: ProcessBase.h:22

◆ approxproj()

void TrackletCalculatorDisplaced::approxproj ( double  halfRinv,
double  phi0,
double  d0,
double  t,
double  z0,
double  halfRinv_0,
double  d0_0,
double  rmean,
double &  phiproj,
double &  phiprojder,
double &  zproj,
double &  zprojder 
)

Definition at line 1778 of file TrackletCalculatorDisplaced.cc.

References funct::abs(), d0, trklet::Settings::debugTracklet(), trklet::Settings::disp_z0cut(), angle0to2pi::make0To2pi(), trklet::Settings::maxd0(), funct::pow(), trklet::Settings::rinvcut(), trklet::ProcessBase::settings_, trklet::sixth, and submitPVValidationJobs::t.

Referenced by approxtracklet().

1789  {
1790  if (std::abs(2.0 * halfRinv) > settings_.rinvcut() || std::abs(z0) > settings_.disp_z0cut() ||
1791  std::abs(d0) > settings_.maxd0()) {
1792  phiproj = 0.0;
1793  return;
1794  }
1795  double rmeanInv = 1.0 / rmean;
1796 
1797  phiproj = phi0 + rmean * (-halfRinv + 2.0 * d0_0 * halfRinv_0 * halfRinv_0) +
1798  rmeanInv * (-d0 + halfRinv_0 * d0_0 * d0_0) + sixth * pow(-rmean * halfRinv_0 - rmeanInv * d0_0, 3);
1799  phiprojder = -halfRinv + d0 * rmeanInv * rmeanInv; //removed all high terms
1800 
1801  zproj = z0 + t * rmean - 0.5 * rmeanInv * t * d0_0 * d0_0 - t * rmean * halfRinv * d0 +
1802  sixth * pow(rmean, 3) * t * halfRinv_0 * halfRinv_0;
1803  zprojder = t; // removed all high terms
1804 
1805  phiproj = angle0to2pi::make0To2pi(phiproj);
1806 
1807  if (settings_.debugTracklet())
1808  edm::LogVerbatim("Tracklet") << "approx proj layer at " << rmean << " : " << phiproj << " " << zproj << endl;
1809 }
double disp_z0cut() const
Definition: Settings.h:373
double maxd0() const
Definition: Settings.h:355
Settings const & settings_
Definition: ProcessBase.h:44
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double rinvcut() const
Definition: Settings.h:222
bool debugTracklet() const
Definition: Settings.h:194
static constexpr float d0
constexpr valType make0To2pi(valType angle)
Definition: deltaPhi.h:67
constexpr double sixth
Definition: Settings.h:45
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ approxprojdisk()

void TrackletCalculatorDisplaced::approxprojdisk ( double  halfRinv,
double  phi0,
double  d0,
double  t,
double  z0,
double  halfRinv_0,
double  d0_0,
double  zmean,
double &  phiproj,
double &  phiprojder,
double &  rproj,
double &  rprojder 
)

Definition at line 1811 of file TrackletCalculatorDisplaced.cc.

References A, funct::abs(), B, correctionTermsCaloMet_cff::C, d0, trklet::Settings::debugTracklet(), trklet::Settings::disp_z0cut(), geometryDiff::epsilon, angle0to2pi::make0To2pi(), trklet::Settings::maxd0(), funct::pow(), trklet::Settings::rinvcut(), trklet::ProcessBase::settings_, trklet::sixth, and submitPVValidationJobs::t.

Referenced by approxtracklet().

1822  {
1823  if (std::abs(2.0 * halfRinv) > settings_.rinvcut() || std::abs(z0) > settings_.disp_z0cut() ||
1824  std::abs(d0) > settings_.maxd0()) {
1825  phiproj = 0.0;
1826  return;
1827  }
1828 
1829  if (t < 0)
1830  zmean = -zmean;
1831 
1832  double zmeanInv = 1.0 / zmean, rstar = (zmean - z0) / t,
1833  epsilon = 0.5 * zmeanInv * zmeanInv * d0_0 * d0_0 * t * t + halfRinv * d0 -
1834  sixth * rstar * rstar * halfRinv_0 * halfRinv_0;
1835 
1836  rproj = rstar * (1 + epsilon);
1837  rprojder = 1 / t;
1838 
1839  double A = rproj * halfRinv;
1840  double B = -d0 * t * zmeanInv * (1 + z0 * zmeanInv) * (1 - epsilon);
1841  double C = -d0 * halfRinv;
1842  double A_0 = rproj * halfRinv_0;
1843  double B_0 = -d0_0 * t * zmeanInv * (1 + z0 * zmeanInv) * (1 - epsilon);
1844  // double C_0 = -d0_0 * halfRinv_0;
1845 
1846  phiproj = phi0 - A + B * (1 + C - 2 * A_0 * A_0) + sixth * pow(-A_0 + B_0, 3);
1847  phiprojder = -halfRinv / t + d0 * t * zmeanInv * zmeanInv;
1848 
1849  phiproj = angle0to2pi::make0To2pi(phiproj);
1850 
1851  if (settings_.debugTracklet())
1852  edm::LogVerbatim("Tracklet") << "approx proj disk at" << zmean << " : " << phiproj << " " << rproj << endl;
1853 }
Definition: APVGainStruct.h:7
double disp_z0cut() const
Definition: Settings.h:373
double maxd0() const
Definition: Settings.h:355
Settings const & settings_
Definition: ProcessBase.h:44
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double rinvcut() const
Definition: Settings.h:222
bool debugTracklet() const
Definition: Settings.h:194
static constexpr float d0
constexpr valType make0To2pi(valType angle)
Definition: deltaPhi.h:67
constexpr double sixth
Definition: Settings.h:45
Definition: APVGainStruct.h:7
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ approxtracklet()

void TrackletCalculatorDisplaced::approxtracklet ( double  r1,
double  z1,
double  phi1,
double  r2,
double  z2,
double  phi2,
double  r3,
double  z3,
double  phi3,
bool  take3,
unsigned  ndisks,
double &  rinv,
double &  phi0,
double &  d0,
double &  t,
double &  z0,
double  phiproj[4],
double  zproj[4],
double  phider[4],
double  zder[4],
double  phiprojdisk[5],
double  rprojdisk[5],
double  phiderdisk[5],
double  rderdisk[5] 
)

Definition at line 1855 of file TrackletCalculatorDisplaced.cc.

References a, funct::abs(), approxproj(), approxprojdisk(), b, DummyCfis::c, alignmentValidation::c1, d0, trklet::Settings::debugTracklet(), trklet::Settings::disp_z0cut(), mps_fire::i, angle0to2pi::make0To2pi(), trklet::Settings::maxd0(), phimin_, funct::pow(), diffTwoXMLs::r2, trklet::rinv(), trklet::Settings::rinvcut(), rzmeanInv_, trklet::ProcessBase::settings_, trklet::sixth, submitPVValidationJobs::t, toR_, toZ_, ppsModifySingularModes_cfi::z1, and ppsModifySingularModes_cfi::z2.

Referenced by DDLSeeding(), LLDSeeding(), and LLLSeeding().

1878  {
1879  double a = 1.0 / ((r1 - r2) * (r1 - r3));
1880  double b = 1.0 / ((r1 - r2) * (r2 - r3));
1881  double c = 1.0 / ((r1 - r3) * (r2 - r3));
1882 
1883  // first iteration in r-phi plane
1884  double halfRinv_0 = -phi1 * r1 * a + phi2 * r2 * b - phi3 * r3 * c;
1885  double d0_0 = r1 * r2 * r3 * (-phi1 * a + phi2 * b - phi3 * c);
1886 
1887  // corrections to phi1, phi2, and phi3
1888  double r = r2, z = z2;
1889  if (take3)
1890  r = r3, z = z3;
1891 
1892  double d0OverR1 = d0_0 * rzmeanInv_[0] * (ndisks > 2 ? std::abs((z - z1) / (r - r1)) : 1.0);
1893  double d0OverR2 = d0_0 * rzmeanInv_[1] * (ndisks > 1 ? std::abs((z - z1) / (r - r1)) : 1.0);
1894  double d0OverR3 = d0_0 * rzmeanInv_[2] * (ndisks > 0 ? std::abs((z - z1) / (r - r1)) : 1.0);
1895 
1896  double d0OverR = d0OverR2;
1897  if (take3)
1898  d0OverR = d0OverR3;
1899 
1900  double c1 = d0_0 * halfRinv_0 * d0OverR1 + 2.0 * d0_0 * halfRinv_0 * r1 * halfRinv_0 +
1901  sixth * pow(-r1 * halfRinv_0 - d0OverR1, 3);
1902  double c2 = d0_0 * halfRinv_0 * d0OverR2 + 2.0 * d0_0 * halfRinv_0 * r2 * halfRinv_0 +
1903  sixth * pow(-r2 * halfRinv_0 - d0OverR2, 3);
1904  double c3 = d0_0 * halfRinv_0 * d0OverR3 + 2.0 * d0_0 * halfRinv_0 * r3 * halfRinv_0 +
1905  sixth * pow(-r3 * halfRinv_0 - d0OverR3, 3);
1906 
1907  double phi1c = phi1 - c1;
1908  double phi2c = phi2 - c2;
1909  double phi3c = phi3 - c3;
1910 
1911  // second iteration in r-phi plane
1912  double halfRinv = -phi1c * r1 * a + phi2c * r2 * b - phi3c * r3 * c;
1913  phi0 = -phi1c * r1 * (r2 + r3) * a + phi2c * r2 * (r1 + r3) * b - phi3c * r3 * (r1 + r2) * c;
1914  d0 = r1 * r2 * r3 * (-phi1c * a + phi2c * b - phi3c * c);
1915 
1916  t = ((z - z1) / (r - r1)) *
1917  (1. + d0 * halfRinv - 0.5 * d0OverR1 * d0OverR - sixth * (r1 * r1 + r2 * r2 + r1 * r2) * halfRinv_0 * halfRinv_0);
1918  z0 = z1 - t * r1 * (1.0 - d0_0 * halfRinv_0 - 0.5 * d0OverR1 * d0OverR1 + sixth * r1 * r1 * halfRinv_0 * halfRinv_0);
1919 
1920  rinv = 2.0 * halfRinv;
1921  phi0 += -phimin_;
1922 
1923  phi0 = angle0to2pi::make0To2pi(phi0);
1924 
1925  for (unsigned int i = 0; i < toR_.size(); i++) {
1926  approxproj(halfRinv,
1927  phi0,
1928  d0,
1929  t,
1930  z0,
1931  halfRinv_0,
1932  d0_0, // added _0 version for high term calculations
1933  toR_.at(i),
1934  phiproj[i],
1935  phider[i],
1936  zproj[i],
1937  zder[i]);
1938  }
1939 
1940  for (unsigned int i = 0; i < toZ_.size(); i++) {
1941  approxprojdisk(halfRinv,
1942  phi0,
1943  d0,
1944  t,
1945  z0,
1946  halfRinv_0,
1947  d0_0, // added _0 version for high term calculations
1948  toZ_.at(i),
1949  phiprojdisk[i],
1950  phiderdisk[i],
1951  rprojdisk[i],
1952  rderdisk[i]);
1953  }
1954 
1955  if (std::abs(rinv) > settings_.rinvcut() || std::abs(z0) > settings_.disp_z0cut() ||
1956  std::abs(d0) > settings_.maxd0()) {
1957  phi0 = 0.0;
1958  return;
1959  }
1960 
1961  if (settings_.debugTracklet())
1962  edm::LogVerbatim("Tracklet") << "TCD approx tracklet: " << rinv << " " << phi0 << " " << t << " " << z0 << " " << d0
1963  << endl;
1964 }
double disp_z0cut() const
Definition: Settings.h:373
double maxd0() const
Definition: Settings.h:355
Settings const & settings_
Definition: ProcessBase.h:44
void approxprojdisk(double halfRinv, double phi0, double d0, double t, double z0, double halfRinv_0, double d0_0, double zmean, double &phiproj, double &phiprojder, double &rproj, double &rprojder)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double rinvcut() const
Definition: Settings.h:222
bool debugTracklet() const
Definition: Settings.h:194
static constexpr float d0
void approxproj(double halfRinv, double phi0, double d0, double t, double z0, double halfRinv_0, double d0_0, double rmean, double &phiproj, double &phiprojder, double &zproj, double &zprojder)
double rinv(double phi1, double phi2, double r1, double r2)
Definition: Util.h:66
double b
Definition: hdecay.h:120
constexpr valType make0To2pi(valType angle)
Definition: deltaPhi.h:67
constexpr double sixth
Definition: Settings.h:45
double a
Definition: hdecay.h:121
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ DDLSeeding()

bool TrackletCalculatorDisplaced::DDLSeeding ( const Stub innerFPGAStub,
const L1TStub innerStub,
const Stub middleFPGAStub,
const L1TStub middleStub,
const Stub outerFPGAStub,
const L1TStub outerStub 
)

Definition at line 799 of file TrackletCalculatorDisplaced.cc.

References funct::abs(), addDiskProj(), addLayerProj(), trklet::TrackletParametersMemory::addTracklet(), approxtracklet(), d0, trklet::Settings::debugTracklet(), trklet::Stub::disk(), trklet::Settings::disp_z0cut(), dproj_, exacttracklet(), groupFilesInBlocks::fout, trklet::Tracklet::getISeed(), trklet::ProcessBase::getName(), trklet::ProcessBase::globals_, mps_fire::i, trklet::Projection::init(), trklet::Stub::isBarrel(), iSector_, iSeed_, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, trklet::Globals::ITC_L1L2(), dqmiolumiharvest::j, trklet::VarBase::K(), trklet::Settings::kd0(), runTheMatrix::keep, trklet::Settings::kphi1(), trklet::Settings::kr(), trklet::Settings::kz(), trklet::Stub::layer(), layer_, lproj_, trklet::Settings::maxd0(), trklet::N_DISK, trklet::N_LAYER, trklet::ProcessBase::name_, trklet::Settings::nbitsphiprojderL123(), trklet::Settings::nbitsphiprojderL456(), trklet::Settings::nphibitsstub(), trklet::TrackletParametersMemory::nTracklets(), trklet::Settings::nzbitsstub(), trklet::Globals::ofstream(), trklet::L1TStub::phi(), trklet::IMATH_TrackletCalculator::phi0_final, trklet::Settings::phi0_shift(), trklet::Stub::phiapprox(), trklet::Settings::phicritmaxmc(), trklet::Settings::phicritminmc(), phimax_, phimin_, funct::pow(), trklet::Settings::PS_rD_shift(), trklet::Settings::PS_rderD_shift(), trklet::Settings::PS_zderL_shift(), trklet::Settings::PS_zL_shift(), trklet::L1TStub::r(), diffTwoXMLs::r2, trklet::Stub::rapprox(), trklet::Settings::rcrit(), trklet::rinv(), trklet::Settings::rinv_shift(), trklet::Settings::rinvcut(), trklet::Settings::rmaxdisk(), trklet::Settings::rmindisk(), rproj_, trklet::Settings::rPS2S(), trklet::Tracklet::setTCIndex(), trklet::ProcessBase::settings_, trklet::Tracklet::setTrackletIndex(), trklet::Settings::SS_phiD_shift(), trklet::Settings::SS_phiderD_shift(), trklet::Settings::SS_phiderL_shift(), trklet::Settings::SS_phiL_shift(), summarizeEdmComparisonLogfiles::success, submitPVValidationJobs::t, trklet::Settings::t_shift(), TCIndex_, toR_, toZ_, trackletpars_, trklet::Settings::useapprox(), trklet::Settings::usephicritapprox(), trklet::Tracklet::validProj(), trklet::FPGAWord::value(), trklet::Settings::writeMonitorData(), trklet::L1TStub::z(), trklet::Settings::z0_shift(), ppsModifySingularModes_cfi::z1, ppsModifySingularModes_cfi::z2, and trklet::Stub::zapprox().

Referenced by execute(), and trklet::TrackletProcessorDisplaced::execute().

804  {
805  if (settings_.debugTracklet())
806  edm::LogVerbatim("Tracklet") << "TrackletCalculatorDisplaced " << getName() << " " << layer_
807  << " trying stub triplet in (L2 D1 D2): " << innerFPGAStub->layer().value() << " "
808  << middleFPGAStub->disk().value() << " " << outerFPGAStub->disk().value();
809 
810  int take3 = 1; //D1D2L2
811  unsigned ndisks = 2;
812 
813  double r1 = innerStub->r();
814  double z1 = innerStub->z();
815  double phi1 = innerStub->phi();
816 
817  double r2 = middleStub->r();
818  double z2 = middleStub->z();
819  double phi2 = middleStub->phi();
820 
821  double r3 = outerStub->r();
822  double z3 = outerStub->z();
823  double phi3 = outerStub->phi();
824 
825  double rinv, phi0, d0, t, z0;
826 
827  double phiproj[N_LAYER - 2], zproj[N_LAYER - 2], phider[N_LAYER - 2], zder[N_LAYER - 2];
828  double phiprojdisk[N_DISK], rprojdisk[N_DISK], phiderdisk[N_DISK], rderdisk[N_DISK];
829 
830  exacttracklet(r1,
831  z1,
832  phi1,
833  r2,
834  z2,
835  phi2,
836  r3,
837  z3,
838  phi3,
839  take3,
840  rinv,
841  phi0,
842  d0,
843  t,
844  z0,
845  phiproj,
846  zproj,
847  phiprojdisk,
848  rprojdisk,
849  phider,
850  zder,
851  phiderdisk,
852  rderdisk);
853 
854  if (settings_.debugTracklet())
855  edm::LogVerbatim("Tracklet") << __LINE__ << ":" << __FILE__ << " DLL Exact values " << innerFPGAStub->isBarrel()
856  << middleFPGAStub->isBarrel() << outerFPGAStub->isBarrel() << " " << phi1 << ", " << z1
857  << ", " << r1 << ", " << phi2 << ", " << z2 << ", " << r2 << ", " << phi3 << ", " << z3
858  << ", " << r3 << endl;
859 
860  if (settings_.useapprox()) {
861  phi1 = innerFPGAStub->phiapprox(phimin_, phimax_);
862  z1 = innerFPGAStub->zapprox();
863  r1 = innerFPGAStub->rapprox();
864 
865  phi2 = middleFPGAStub->phiapprox(phimin_, phimax_);
866  z2 = middleFPGAStub->zapprox();
867  r2 = middleFPGAStub->rapprox();
868 
869  phi3 = outerFPGAStub->phiapprox(phimin_, phimax_);
870  z3 = outerFPGAStub->zapprox();
871  r3 = outerFPGAStub->rapprox();
872  }
873 
874  if (settings_.debugTracklet())
875  edm::LogVerbatim("Tracklet") << __LINE__ << ":" << __FILE__ << "DLL Approx values " << innerFPGAStub->isBarrel()
876  << middleFPGAStub->isBarrel() << outerFPGAStub->isBarrel() << " " << phi1 << ", " << z1
877  << ", " << r1 << ", " << phi2 << ", " << z2 << ", " << r2 << ", " << phi3 << ", " << z3
878  << ", " << r3 << endl;
879 
880  double rinvapprox, phi0approx, d0approx, tapprox, z0approx;
881  double phiprojapprox[N_LAYER - 2], zprojapprox[N_LAYER - 2], phiderapprox[N_LAYER - 2], zderapprox[N_LAYER - 2];
882  double phiprojdiskapprox[N_DISK], rprojdiskapprox[N_DISK];
883  double phiderdiskapprox[N_DISK], rderdiskapprox[N_DISK];
884 
885  //TODO: implement the actual integer calculation
886  if (settings_.useapprox()) {
887  approxtracklet(r1,
888  z1,
889  phi1,
890  r2,
891  z2,
892  phi2,
893  r3,
894  z3,
895  phi3,
896  take3,
897  ndisks,
898  rinvapprox,
899  phi0approx,
900  d0approx,
901  tapprox,
902  z0approx,
903  phiprojapprox,
904  zprojapprox,
905  phiderapprox,
906  zderapprox,
907  phiprojdiskapprox,
908  rprojdiskapprox,
909  phiderdiskapprox,
910  rderdiskapprox);
911  } else {
912  rinvapprox = rinv;
913  phi0approx = phi0;
914  d0approx = d0;
915  tapprox = t;
916  z0approx = z0;
917 
918  for (unsigned int i = 0; i < toR_.size(); ++i) {
919  phiprojapprox[i] = phiproj[i];
920  zprojapprox[i] = zproj[i];
921  phiderapprox[i] = phider[i];
922  zderapprox[i] = zder[i];
923  }
924 
925  for (unsigned int i = 0; i < toZ_.size(); ++i) {
926  phiprojdiskapprox[i] = phiprojdisk[i];
927  rprojdiskapprox[i] = rprojdisk[i];
928  phiderdiskapprox[i] = phiderdisk[i];
929  rderdiskapprox[i] = rderdisk[i];
930  }
931  }
932 
933  //store the approcximate results
934  if (settings_.debugTracklet()) {
935  edm::LogVerbatim("Tracklet") << "rinvapprox: " << rinvapprox << " rinv: " << rinv << endl;
936  edm::LogVerbatim("Tracklet") << "phi0approx: " << phi0approx << " phi0: " << phi0 << endl;
937  edm::LogVerbatim("Tracklet") << "d0approx: " << d0approx << " d0: " << d0 << endl;
938  edm::LogVerbatim("Tracklet") << "tapprox: " << tapprox << " t: " << t << endl;
939  edm::LogVerbatim("Tracklet") << "z0approx: " << z0approx << " z0: " << z0 << endl;
940  }
941 
942  for (unsigned int i = 0; i < toR_.size(); ++i) {
943  if (settings_.debugTracklet()) {
944  edm::LogVerbatim("Tracklet") << "phiprojapprox[" << i << "]: " << phiprojapprox[i] << " phiproj[" << i
945  << "]: " << phiproj[i] << endl;
946  edm::LogVerbatim("Tracklet") << "zprojapprox[" << i << "]: " << zprojapprox[i] << " zproj[" << i
947  << "]: " << zproj[i] << endl;
948  edm::LogVerbatim("Tracklet") << "phiderapprox[" << i << "]: " << phiderapprox[i] << " phider[" << i
949  << "]: " << phider[i] << endl;
950  edm::LogVerbatim("Tracklet") << "zderapprox[" << i << "]: " << zderapprox[i] << " zder[" << i << "]: " << zder[i]
951  << endl;
952  }
953  }
954 
955  for (unsigned int i = 0; i < toZ_.size(); ++i) {
956  if (settings_.debugTracklet()) {
957  edm::LogVerbatim("Tracklet") << "phiprojdiskapprox[" << i << "]: " << phiprojdiskapprox[i] << " phiprojdisk[" << i
958  << "]: " << phiprojdisk[i] << endl;
959  edm::LogVerbatim("Tracklet") << "rprojdiskapprox[" << i << "]: " << rprojdiskapprox[i] << " rprojdisk[" << i
960  << "]: " << rprojdisk[i] << endl;
961  edm::LogVerbatim("Tracklet") << "phiderdiskapprox[" << i << "]: " << phiderdiskapprox[i] << " phiderdisk[" << i
962  << "]: " << phiderdisk[i] << endl;
963  edm::LogVerbatim("Tracklet") << "rderdiskapprox[" << i << "]: " << rderdiskapprox[i] << " rderdisk[" << i
964  << "]: " << rderdisk[i] << endl;
965  }
966  }
967 
968  //now binary
969  double krinv = settings_.kphi1() / settings_.kr() * pow(2, settings_.rinv_shift()),
970  kphi0 = settings_.kphi1() * pow(2, settings_.phi0_shift()),
971  kt = settings_.kz() / settings_.kr() * pow(2, settings_.t_shift()),
972  kz0 = settings_.kz() * pow(2, settings_.z0_shift()),
973  kphiproj = settings_.kphi1() * pow(2, settings_.SS_phiL_shift()),
974  kphider = settings_.kphi1() / settings_.kr() * pow(2, settings_.SS_phiderL_shift()),
975  kzproj = settings_.kz() * pow(2, settings_.PS_zL_shift()),
976  kzder = settings_.kz() / settings_.kr() * pow(2, settings_.PS_zderL_shift()),
977  kphiprojdisk = settings_.kphi1() * pow(2, settings_.SS_phiD_shift()),
978  kphiderdisk = settings_.kphi1() / settings_.kr() * pow(2, settings_.SS_phiderD_shift()),
979  krprojdisk = settings_.kr() * pow(2, settings_.PS_rD_shift()),
980  krderdisk = settings_.kr() / settings_.kz() * pow(2, settings_.PS_rderD_shift());
981 
982  int irinv, iphi0, id0, it, iz0;
983  int iphiproj[N_LAYER - 2], izproj[N_LAYER - 2], iphider[N_LAYER - 2], izder[N_LAYER - 2];
984  int iphiprojdisk[N_DISK], irprojdisk[N_DISK], iphiderdisk[N_DISK], irderdisk[N_DISK];
985 
986  //store the binary results
987  irinv = rinvapprox / krinv;
988  iphi0 = phi0approx / kphi0;
989  id0 = d0approx / settings_.kd0();
990  it = tapprox / kt;
991  iz0 = z0approx / kz0;
992 
993  bool success = true;
994  if (std::abs(rinvapprox) > settings_.rinvcut()) {
995  if (settings_.debugTracklet())
996  edm::LogVerbatim("Tracklet") << "TrackletCalculator::DDL Seeding irinv too large: " << rinvapprox << "(" << irinv
997  << ")";
998  success = false;
999  }
1000  if (std::abs(z0approx) > settings_.disp_z0cut()) {
1001  if (settings_.debugTracklet())
1002  edm::LogVerbatim("Tracklet") << "Failed tracklet z0 cut " << z0approx;
1003  success = false;
1004  }
1005  if (std::abs(d0approx) > settings_.maxd0()) {
1006  if (settings_.debugTracklet())
1007  edm::LogVerbatim("Tracklet") << "Failed tracklet approx d0 cut " << d0approx;
1008  success = false;
1009  }
1010  if (std::abs(d0) > settings_.maxd0()) {
1011  if (settings_.debugTracklet())
1012  edm::LogVerbatim("Tracklet") << "Failed tracklet exact d0 cut " << d0;
1013  success = false;
1014  }
1015 
1016  if (!success)
1017  return false;
1018 
1019  double phicritapprox = phi0approx - asin((0.5 * settings_.rcrit() * rinvapprox) + (d0approx / settings_.rcrit()));
1020  int phicrit = iphi0 - 2 * irinv - 2 * id0;
1021 
1022  int iphicritmincut = settings_.phicritminmc() / globals_->ITC_L1L2()->phi0_final.K();
1023  int iphicritmaxcut = settings_.phicritmaxmc() / globals_->ITC_L1L2()->phi0_final.K();
1024 
1025  bool keepapprox = (phicritapprox > settings_.phicritminmc()) && (phicritapprox < settings_.phicritmaxmc()),
1026  keep = (phicrit > iphicritmincut) && (phicrit < iphicritmaxcut);
1027 
1028  if (settings_.debugTracklet())
1029  if (keep && !keepapprox)
1030  edm::LogVerbatim("Tracklet") << "TrackletCalculatorDisplaced::DDLSeeding tracklet kept with exact phicrit cut "
1031  "but not approximate, phicritapprox: "
1032  << phicritapprox;
1033  if (settings_.usephicritapprox()) {
1034  if (!keepapprox)
1035  return false;
1036  } else {
1037  if (!keep)
1038  return false;
1039  }
1040 
1041  Projection projs[N_LAYER + N_DISK];
1042 
1043  for (unsigned int i = 0; i < toR_.size(); ++i) {
1044  iphiproj[i] = phiprojapprox[i] / kphiproj;
1045  izproj[i] = zprojapprox[i] / kzproj;
1046 
1047  iphider[i] = phiderapprox[i] / kphider;
1048  izder[i] = zderapprox[i] / kzder;
1049 
1050  //check that z projection in range
1051  if (izproj[i] < -(1 << (settings_.nzbitsstub(0) - 1)))
1052  continue;
1053  if (izproj[i] >= (1 << (settings_.nzbitsstub(0) - 1)))
1054  continue;
1055 
1056  //check that phi projection in range
1057  if (iphiproj[i] >= (1 << settings_.nphibitsstub(5)) - 1)
1058  continue;
1059  if (iphiproj[i] <= 0)
1060  continue;
1061 
1062  if (rproj_[i] < settings_.rPS2S()) {
1063  iphiproj[i] >>= (settings_.nphibitsstub(5) - settings_.nphibitsstub(0));
1064  } else {
1065  izproj[i] >>= (settings_.nzbitsstub(0) - settings_.nzbitsstub(5));
1066  }
1067 
1068  if (rproj_[i] < settings_.rPS2S()) {
1069  if (iphider[i] < -(1 << (settings_.nbitsphiprojderL123() - 1)))
1070  iphider[i] = -(1 << (settings_.nbitsphiprojderL123() - 1));
1071  if (iphider[i] >= (1 << (settings_.nbitsphiprojderL123() - 1)))
1072  iphider[i] = (1 << (settings_.nbitsphiprojderL123() - 1)) - 1;
1073  } else {
1074  if (iphider[i] < -(1 << (settings_.nbitsphiprojderL456() - 1)))
1075  iphider[i] = -(1 << (settings_.nbitsphiprojderL456() - 1));
1076  if (iphider[i] >= (1 << (settings_.nbitsphiprojderL456() - 1)))
1077  iphider[i] = (1 << (settings_.nbitsphiprojderL456() - 1)) - 1;
1078  }
1079 
1080  projs[lproj_[i] - 1].init(settings_,
1081  lproj_[i] - 1,
1082  iphiproj[i],
1083  izproj[i],
1084  iphider[i],
1085  izder[i],
1086  phiproj[i],
1087  zproj[i],
1088  phider[i],
1089  zder[i],
1090  phiprojapprox[i],
1091  zprojapprox[i],
1092  phiderapprox[i],
1093  zderapprox[i],
1094  false);
1095  }
1096 
1097  if (std::abs(it * kt) > 1.0) {
1098  for (unsigned int i = 0; i < toZ_.size(); ++i) {
1099  iphiprojdisk[i] = phiprojdiskapprox[i] / kphiprojdisk;
1100  irprojdisk[i] = rprojdiskapprox[i] / krprojdisk;
1101 
1102  iphiderdisk[i] = phiderdiskapprox[i] / kphiderdisk;
1103  irderdisk[i] = rderdiskapprox[i] / krderdisk;
1104 
1105  if (iphiprojdisk[i] <= 0)
1106  continue;
1107  if (iphiprojdisk[i] >= (1 << settings_.nphibitsstub(0)) - 1)
1108  continue;
1109 
1110  if (irprojdisk[i] < settings_.rmindisk() / krprojdisk || irprojdisk[i] >= settings_.rmaxdisk() / krprojdisk)
1111  continue;
1112 
1113  projs[N_LAYER + i + 2].init(settings_,
1114  N_LAYER + i + 2,
1115  iphiprojdisk[i],
1116  irprojdisk[i],
1117  iphiderdisk[i],
1118  irderdisk[i],
1119  phiprojdisk[i],
1120  rprojdisk[i],
1121  phiderdisk[i],
1122  rderdisk[i],
1123  phiprojdiskapprox[i],
1124  rprojdiskapprox[i],
1125  phiderdisk[i],
1126  rderdisk[i],
1127  false);
1128  }
1129  }
1130 
1131  if (settings_.writeMonitorData("TrackletPars")) {
1132  globals_->ofstream("trackletpars.txt")
1133  << layer_ << " , " << rinv << " , " << rinvapprox << " , " << phi0 << " , " << phi0approx << " , " << t << " , "
1134  << tapprox << " , " << z0 << " , " << z0approx << " , " << d0 << " , " << d0approx << endl;
1135  }
1136 
1137  Tracklet* tracklet = new Tracklet(settings_,
1138  iSeed_,
1139  innerFPGAStub,
1140  middleFPGAStub,
1141  outerFPGAStub,
1142  rinv,
1143  phi0,
1144  d0,
1145  z0,
1146  t,
1147  rinvapprox,
1148  phi0approx,
1149  d0approx,
1150  z0approx,
1151  tapprox,
1152  irinv,
1153  iphi0,
1154  id0,
1155  iz0,
1156  it,
1157  projs,
1158  true);
1159 
1160  if (settings_.debugTracklet())
1161  edm::LogVerbatim("Tracklet") << "TrackletCalculatorDisplaced " << getName()
1162  << " Found DDL tracklet in sector = " << iSector_ << " phi0 = " << phi0;
1163 
1165  tracklet->setTCIndex(TCIndex_);
1166 
1167  if (settings_.writeMonitorData("Seeds")) {
1168  ofstream fout("seeds.txt", ofstream::app);
1169  fout << __FILE__ << ":" << __LINE__ << " " << name_ << "_" << iSector_ << " " << tracklet->getISeed() << endl;
1170  fout.close();
1171  }
1172  trackletpars_->addTracklet(tracklet);
1173 
1174  for (unsigned int j = 0; j < toR_.size(); j++) {
1175  if (settings_.debugTracklet())
1176  edm::LogVerbatim("Tracklet") << "adding layer projection " << j << "/" << toR_.size() << " " << lproj_[j] << " "
1177  << tracklet->validProj(lproj_[j] - 1);
1178  if (tracklet->validProj(lproj_[j] - 1)) {
1179  addLayerProj(tracklet, lproj_[j]);
1180  }
1181  }
1182 
1183  for (unsigned int j = 0; j < toZ_.size(); j++) {
1184  int disk = dproj_[j];
1185  if (disk == 0)
1186  continue;
1187  if (it < 0)
1188  disk = -disk;
1189  if (settings_.debugTracklet())
1190  edm::LogVerbatim("Tracklet") << "adding disk projection " << j << "/" << toZ_.size() << " " << disk << " "
1191  << tracklet->validProj(N_LAYER + abs(disk) - 1);
1192  if (tracklet->validProj(N_LAYER + abs(disk) - 1)) {
1193  addDiskProj(tracklet, disk);
1194  }
1195  }
1196 
1197  return true;
1198 }
Log< level::Info, true > LogVerbatim
double kz() const
Definition: Settings.h:349
double phi() const
Definition: L1TStub.h:65
int PS_rD_shift() const
Definition: Settings.h:404
int PS_zL_shift() const
Definition: Settings.h:396
double zapprox() const
Definition: Stub.cc:166
constexpr int N_DISK
Definition: Settings.h:26
int PS_rderD_shift() const
Definition: Settings.h:407
int PS_zderL_shift() const
Definition: Settings.h:399
double rPS2S() const
Definition: Settings.h:369
std::string name_
Definition: ProcessBase.h:42
double kphi1() const
Definition: Settings.h:346
bool addLayerProj(Tracklet *tracklet, int layer)
double phiapprox(double phimin, double) const
Definition: Stub.cc:185
double disp_z0cut() const
Definition: Settings.h:373
double phicritmaxmc() const
Definition: Settings.h:342
double rmindisk() const
Definition: Settings.h:135
bool isBarrel() const
Definition: Stub.h:87
double maxd0() const
Definition: Settings.h:355
Settings const & settings_
Definition: ProcessBase.h:44
double z() const
Definition: L1TStub.h:59
Globals * globals_
Definition: ProcessBase.h:45
int phi0_shift() const
Definition: Settings.h:388
double phicritminmc() const
Definition: Settings.h:341
const FPGAWord & disk() const
Definition: Stub.h:74
void init(Settings const &settings, unsigned int layerdisk, int iphiproj, int irzproj, int iphider, int irzder, double phiproj, double rzproj, double phiprojder, double rzprojder, double phiprojapprox, double rzprojapprox, double phiprojderapprox, double rzprojderapprox, bool isPSseed)
Definition: Projection.cc:11
unsigned int nbitsphiprojderL456() const
Definition: Settings.h:97
void exacttracklet(double r1, double z1, double phi1, double r2, double z2, double phi2, double r3, double z3, double phi3, int take3, double &rinv, double &phi0, double &d0, double &t, double &z0, double phiproj[N_LAYER - 2], double zproj[N_LAYER - 2], double phiprojdisk[N_DISK], double rprojdisk[N_DISK], double phider[N_LAYER - 2], double zder[N_LAYER - 2], double phiderdisk[N_DISK], double rderdisk[N_DISK])
unsigned int nzbitsstub(unsigned int layerdisk) const
Definition: Settings.h:91
unsigned int nphibitsstub(unsigned int layerdisk) const
Definition: Settings.h:92
int t_shift() const
Definition: Settings.h:389
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
IMATH_TrackletCalculator * ITC_L1L2()
Definition: Globals.h:48
int value() const
Definition: FPGAWord.h:24
double rinvcut() const
Definition: Settings.h:222
int z0_shift() const
Definition: Settings.h:390
void approxtracklet(double r1, double z1, double phi1, double r2, double z2, double phi2, double r3, double z3, double phi3, bool take3, unsigned ndisks, double &rinv, double &phi0, double &d0, double &t, double &z0, double phiproj[4], double zproj[4], double phider[4], double zder[4], double phiprojdisk[5], double rprojdisk[5], double phiderdisk[5], double rderdisk[5])
bool writeMonitorData(std::string module) const
Definition: Settings.h:118
double rapprox() const
Definition: Stub.cc:152
void setTCIndex(int index)
Definition: Tracklet.h:210
double K() const
Definition: imath.h:247
int SS_phiD_shift() const
Definition: Settings.h:403
bool debugTracklet() const
Definition: Settings.h:194
int SS_phiderD_shift() const
Definition: Settings.h:406
double kr() const
Definition: Settings.h:351
static constexpr float d0
double rmaxdisk() const
Definition: Settings.h:134
void addDiskProj(Tracklet *tracklet, int disk)
void setTrackletIndex(unsigned int index)
Definition: Tracklet.cc:815
double kd0() const
Definition: Settings.h:358
double rinv(double phi1, double phi2, double r1, double r2)
Definition: Util.h:66
int getISeed() const
Definition: Tracklet.cc:820
int SS_phiderL_shift() const
Definition: Settings.h:398
unsigned int nbitsphiprojderL123() const
Definition: Settings.h:96
double r() const
Definition: L1TStub.h:60
int rinv_shift() const
Definition: Settings.h:387
std::ofstream & ofstream(std::string fname)
Definition: Globals.cc:44
const FPGAWord & layer() const
Definition: Stub.h:73
bool usephicritapprox() const
Definition: Settings.h:248
std::string const & getName() const
Definition: ProcessBase.h:22
int SS_phiL_shift() const
Definition: Settings.h:395
bool useapprox() const
Definition: Settings.h:247
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
bool validProj(int layerdisk) const
Definition: Tracklet.h:82
constexpr int N_LAYER
Definition: Settings.h:25
double rcrit() const
Definition: Settings.h:334

◆ exactproj()

void TrackletCalculatorDisplaced::exactproj ( double  rproj,
double  rinv,
double  phi0,
double  d0,
double  t,
double  z0,
double  r0,
double &  phiproj,
double &  zproj,
double &  phider,
double &  zder 
)

Definition at line 1603 of file TrackletCalculatorDisplaced.cc.

References funct::abs(), HLT_2024v14_cff::beta, d0, trklet::Settings::debugTracklet(), funct::pow(), trklet::rinv(), trklet::ProcessBase::settings_, mathSSE::sqrt(), and submitPVValidationJobs::t.

Referenced by exacttracklet().

1613  {
1614  double rho = 1 / rinv;
1615  if (rho < 0) {
1616  r0 = -r0;
1617  }
1618  phiproj = phi0 - asin((rproj * rproj + r0 * r0 - rho * rho) / (2 * rproj * r0));
1619  double beta = acos((rho * rho + r0 * r0 - rproj * rproj) / (2 * r0 * rho));
1620  zproj = z0 + t * std::abs(rho * beta);
1621 
1622  //not exact, but close
1623  phider = -0.5 * rinv / sqrt(1 - pow(0.5 * rproj * rinv, 2)) + d0 / (rproj * rproj);
1624  zder = t / sqrt(1 - pow(0.5 * rproj * rinv, 2));
1625 
1626  if (settings_.debugTracklet())
1627  edm::LogVerbatim("Tracklet") << "exact proj layer at " << rproj << " : " << phiproj << " " << zproj;
1628 }
Settings const & settings_
Definition: ProcessBase.h:44
T sqrt(T t)
Definition: SSEVec.h:23
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool debugTracklet() const
Definition: Settings.h:194
static constexpr float d0
double rinv(double phi1, double phi2, double r1, double r2)
Definition: Util.h:66
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ exactprojdisk()

void TrackletCalculatorDisplaced::exactprojdisk ( double  zproj,
double  rinv,
double  ,
double  ,
double  t,
double  z0,
double  x0,
double  y0,
double &  phiproj,
double &  rproj,
double &  phider,
double &  rder 
)

Definition at line 1630 of file TrackletCalculatorDisplaced.cc.

References funct::abs(), Matriplex::atan2(), HLT_2024v14_cff::beta, DummyCfis::c, funct::cos(), trklet::Settings::debugTracklet(), phimin_, reco::reduceRange(), trklet::rinv(), trklet::ProcessBase::settings_, funct::sin(), mathSSE::sqrt(), submitPVValidationJobs::t, and x.

Referenced by exacttracklet().

1641  {
1642  //protect against t=0
1643  if (std::abs(t) < 0.1)
1644  t = 0.1;
1645  if (t < 0)
1646  zproj = -zproj;
1647  double rho = std::abs(1 / rinv);
1648  double beta = (zproj - z0) / (t * rho);
1649  double phiV = atan2(-y0, -x0);
1650  double c = rinv > 0 ? -1 : 1;
1651 
1652  double x = x0 + rho * cos(phiV + c * beta);
1653  double y = y0 + rho * sin(phiV + c * beta);
1654 
1655  phiproj = atan2(y, x);
1656 
1657  phiproj = reco::reduceRange(phiproj - phimin_);
1658 
1659  rproj = sqrt(x * x + y * y);
1660 
1661  phider = c / t / (x * x + y * y) * (rho + x0 * cos(phiV + c * beta) + y0 * sin(phiV + c * beta));
1662  rder = c / t / rproj * (y0 * cos(phiV + c * beta) - x0 * sin(phiV + c * beta));
1663 
1664  if (settings_.debugTracklet())
1665  edm::LogVerbatim("Tracklet") << "exact proj disk at" << zproj << " : " << phiproj << " " << rproj;
1666 }
constexpr T reduceRange(T x)
Definition: deltaPhi.h:18
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Settings const & settings_
Definition: ProcessBase.h:44
T sqrt(T t)
Definition: SSEVec.h:23
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool debugTracklet() const
Definition: Settings.h:194
double rinv(double phi1, double phi2, double r1, double r2)
Definition: Util.h:66
float x
MPlex< T, D1, D2, N > atan2(const MPlex< T, D1, D2, N > &y, const MPlex< T, D1, D2, N > &x)
Definition: Matriplex.h:648

◆ exacttracklet()

void TrackletCalculatorDisplaced::exacttracklet ( double  r1,
double  z1,
double  phi1,
double  r2,
double  z2,
double  phi2,
double  r3,
double  z3,
double  phi3,
int  take3,
double &  rinv,
double &  phi0,
double &  d0,
double &  t,
double &  z0,
double  phiproj[N_LAYER - 2],
double  zproj[N_LAYER - 2],
double  phiprojdisk[N_DISK],
double  rprojdisk[N_DISK],
double  phider[N_LAYER - 2],
double  zder[N_LAYER - 2],
double  phiderdisk[N_DISK],
double  rderdisk[N_DISK] 
)

Definition at line 1668 of file TrackletCalculatorDisplaced.cc.

References funct::abs(), Matriplex::atan2(), b1, b2, funct::cos(), d0, trklet::Settings::debugTracklet(), MillePedeFileConverter_cfg::e, exactproj(), exactprojdisk(), mps_fire::i, relval_steps::k2, M_PI, angle0to2pi::make0To2pi(), phimax_, phimin_, funct::pow(), diffTwoXMLs::r2, reco::reduceRange(), trklet::rinv(), trklet::ProcessBase::settings_, funct::sin(), mathSSE::sqrt(), submitPVValidationJobs::t, toR_, toZ_, testProducerWithPsetDescEmpty_cfi::y1, testProducerWithPsetDescEmpty_cfi::y2, ppsModifySingularModes_cfi::z1, and ppsModifySingularModes_cfi::z2.

Referenced by DDLSeeding(), LLDSeeding(), and LLLSeeding().

1690  {
1691  //two lines perpendicular to the 1->2 and 2->3
1692  double x1 = r1 * cos(phi1);
1693  double x2 = r2 * cos(phi2);
1694  double x3 = r3 * cos(phi3);
1695 
1696  double y1 = r1 * sin(phi1);
1697  double y2 = r2 * sin(phi2);
1698  double y3 = r3 * sin(phi3);
1699 
1700  double dy21 = y2 - y1;
1701  double dy32 = y3 - y2;
1702 
1703  //Hack to protect against dividing by zero
1704  //code should be rewritten to avoid this
1705  if (dy21 == 0.0)
1706  dy21 = 1e-9;
1707  if (dy32 == 0.0)
1708  dy32 = 1e-9;
1709 
1710  double k1 = -(x2 - x1) / dy21;
1711  double k2 = -(x3 - x2) / dy32;
1712  double b1 = 0.5 * (y2 + y1) - 0.5 * (x1 + x2) * k1;
1713  double b2 = 0.5 * (y3 + y2) - 0.5 * (x2 + x3) * k2;
1714  //their intersection gives the center of the circle
1715  double y0 = (b1 * k2 - b2 * k1) / (k2 - k1);
1716  double x0 = (b1 - b2) / (k2 - k1);
1717  //get the radius three ways:
1718  double R1 = sqrt(pow(x1 - x0, 2) + pow(y1 - y0, 2));
1719  double R2 = sqrt(pow(x2 - x0, 2) + pow(y2 - y0, 2));
1720  double R3 = sqrt(pow(x3 - x0, 2) + pow(y3 - y0, 2));
1721  //check if the same
1722  double eps1 = std::abs(R1 / R2 - 1);
1723  double eps2 = std::abs(R3 / R2 - 1);
1724  if (eps1 > 1e-10 || eps2 > 1e-10)
1725  edm::LogVerbatim("Tracklet") << "&&&&&&&&&&&& bad circle! " << R1 << "\t" << R2 << "\t" << R3;
1726 
1727  if (settings_.debugTracklet())
1728  edm::LogVerbatim("Tracklet") << "phimin_: " << phimin_ << " phimax_: " << phimax_;
1729  //results
1730  rinv = 1. / R1;
1731  phi0 = 0.5 * M_PI + atan2(y0, x0);
1732 
1733  phi0 -= phimin_;
1734 
1735  d0 = -R1 + sqrt(x0 * x0 + y0 * y0);
1736  //sign of rinv:
1737  double dphi = reco::reduceRange(phi3 - atan2(y0, x0));
1738  if (dphi < 0) {
1739  rinv = -rinv;
1740  d0 = -d0;
1741  phi0 = phi0 + M_PI;
1742  }
1743  phi0 = angle0to2pi::make0To2pi(phi0);
1744 
1745  //now in RZ:
1746  //turning angle
1747  double beta1 = reco::reduceRange(atan2(y1 - y0, x1 - x0) - atan2(-y0, -x0));
1748  double beta2 = reco::reduceRange(atan2(y2 - y0, x2 - x0) - atan2(-y0, -x0));
1749  double beta3 = reco::reduceRange(atan2(y3 - y0, x3 - x0) - atan2(-y0, -x0));
1750 
1751  double t12 = (z2 - z1) / std::abs(beta2 - beta1) / R1;
1752  double z12 = (z1 * beta2 - z2 * beta1) / (beta2 - beta1);
1753  double t13 = (z3 - z1) / std::abs(beta3 - beta1) / R1;
1754  double z13 = (z1 * beta3 - z3 * beta1) / (beta3 - beta1);
1755 
1756  if (take3 > 0) {
1757  //take 13 (large lever arm)
1758  t = t13;
1759  z0 = z13;
1760  } else {
1761  //take 12 (pixel layers)
1762  t = t12;
1763  z0 = z12;
1764  }
1765 
1766  for (unsigned int i = 0; i < toR_.size(); i++) {
1767  exactproj(toR_[i], rinv, phi0, d0, t, z0, sqrt(x0 * x0 + y0 * y0), phiproj[i], zproj[i], phider[i], zder[i]);
1768  }
1769 
1770  for (unsigned int i = 0; i < toZ_.size(); i++) {
1771  exactprojdisk(toZ_[i], rinv, phi0, d0, t, z0, x0, y0, phiprojdisk[i], rprojdisk[i], phiderdisk[i], rderdisk[i]);
1772  }
1773 
1774  if (settings_.debugTracklet())
1775  edm::LogVerbatim("Tracklet") << "exact tracklet: " << rinv << " " << phi0 << " " << t << " " << z0 << " " << d0;
1776 }
Log< level::Info, true > LogVerbatim
void exactproj(double rproj, double rinv, double phi0, double d0, double t, double z0, double r0, double &phiproj, double &zproj, double &phider, double &zder)
constexpr T reduceRange(T x)
Definition: deltaPhi.h:18
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Settings const & settings_
Definition: ProcessBase.h:44
void exactprojdisk(double zproj, double rinv, double, double, double t, double z0, double x0, double y0, double &phiproj, double &rproj, double &phider, double &rder)
T sqrt(T t)
Definition: SSEVec.h:23
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define M_PI
bias2_t b2[25]
Definition: b2.h:9
bool debugTracklet() const
Definition: Settings.h:194
static constexpr float d0
double rinv(double phi1, double phi2, double r1, double r2)
Definition: Util.h:66
constexpr valType make0To2pi(valType angle)
Definition: deltaPhi.h:67
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
static constexpr float b1
MPlex< T, D1, D2, N > atan2(const MPlex< T, D1, D2, N > &y, const MPlex< T, D1, D2, N > &x)
Definition: Matriplex.h:648

◆ execute()

void TrackletCalculatorDisplaced::execute ( unsigned int  iSector,
double  phimin,
double  phimax 
)

Definition at line 222 of file TrackletCalculatorDisplaced.cc.

References accept(), DDLSeeding(), trklet::Settings::debugTracklet(), Exception, trklet::ProcessBase::getName(), trklet::ProcessBase::globals_, mps_fire::i, iSector_, trklet::Stub::l1tstub(), trklet::Stub::layerdisk(), LLDSeeding(), LLLSeeding(), trklet::Settings::maxStep(), trklet::N_LAYER, trklet::Settings::ntrackletmax(), trklet::TrackletParametersMemory::nTracklets(), trklet::Globals::ofstream(), phimax, phimax_, phimin, phimin_, trklet::ProcessBase::settings_, stubtriplets_, trackletpars_, and trklet::Settings::writeMonitorData().

222  {
223  unsigned int countall = 0;
224  unsigned int countsel = 0;
225 
226  phimin_ = phimin;
227  phimax_ = phimax;
228  iSector_ = iSector;
229 
230  for (auto& stubtriplet : stubtriplets_) {
232  edm::LogVerbatim("Tracklet") << "Will break on too many tracklets in " << getName();
233  break;
234  }
235  for (unsigned int i = 0; i < stubtriplet->nStubTriplets(); i++) {
236  countall++;
237 
238  const Stub* innerFPGAStub = stubtriplet->getFPGAStub1(i);
239  const L1TStub* innerStub = innerFPGAStub->l1tstub();
240 
241  const Stub* middleFPGAStub = stubtriplet->getFPGAStub2(i);
242  const L1TStub* middleStub = middleFPGAStub->l1tstub();
243 
244  const Stub* outerFPGAStub = stubtriplet->getFPGAStub3(i);
245  const L1TStub* outerStub = outerFPGAStub->l1tstub();
246 
247  if (settings_.debugTracklet())
248  edm::LogVerbatim("Tracklet") << "TrackletCalculatorDisplaced execute " << getName() << "[" << iSector_ << "]";
249 
250  if (innerFPGAStub->layerdisk() < N_LAYER && middleFPGAStub->layerdisk() < N_LAYER &&
251  outerFPGAStub->layerdisk() < N_LAYER) {
252  //barrel+barrel seeding
253  bool accept = LLLSeeding(innerFPGAStub, innerStub, middleFPGAStub, middleStub, outerFPGAStub, outerStub);
254  if (accept)
255  countsel++;
256  } else if (innerFPGAStub->layerdisk() >= N_LAYER && middleFPGAStub->layerdisk() >= N_LAYER &&
257  outerFPGAStub->layerdisk() >= N_LAYER) {
258  throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " Invalid seeding!";
259  } else {
260  //layer+disk seeding
261  if (innerFPGAStub->layerdisk() < N_LAYER && middleFPGAStub->layerdisk() >= N_LAYER &&
262  outerFPGAStub->layerdisk() >= N_LAYER) { //D1D2L2
263  bool accept = DDLSeeding(innerFPGAStub, innerStub, middleFPGAStub, middleStub, outerFPGAStub, outerStub);
264  if (accept)
265  countsel++;
266  } else if (innerFPGAStub->layerdisk() >= N_LAYER && middleFPGAStub->layerdisk() < N_LAYER &&
267  outerFPGAStub->layerdisk() < N_LAYER) { //L2L3D1
268  bool accept = LLDSeeding(innerFPGAStub, innerStub, middleFPGAStub, middleStub, outerFPGAStub, outerStub);
269  if (accept)
270  countsel++;
271  } else {
272  throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " Invalid seeding!";
273  }
274  }
275 
277  edm::LogVerbatim("Tracklet") << "Will break on number of tracklets in " << getName();
278  break;
279  }
280 
281  if (countall >= settings_.maxStep("TC")) {
282  if (settings_.debugTracklet())
283  edm::LogVerbatim("Tracklet") << "Will break on MAXTC 1";
284  break;
285  }
286  if (settings_.debugTracklet())
287  edm::LogVerbatim("Tracklet") << "TrackletCalculatorDisplaced execute done";
288  }
289  if (countall >= settings_.maxStep("TC")) {
290  if (settings_.debugTracklet())
291  edm::LogVerbatim("Tracklet") << "Will break on MAXTC 2";
292  break;
293  }
294  }
295 
296  if (settings_.writeMonitorData("TPD")) {
297  globals_->ofstream("trackletcalculatordisplaced.txt") << getName() << " " << countall << " " << countsel << endl;
298  }
299 }
Log< level::Info, true > LogVerbatim
unsigned int maxStep(std::string module) const
Definition: Settings.h:125
std::vector< StubTripletsMemory * > stubtriplets_
Settings const & settings_
Definition: ProcessBase.h:44
Globals * globals_
Definition: ProcessBase.h:45
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:31
bool LLDSeeding(const Stub *innerFPGAStub, const L1TStub *innerStub, const Stub *middleFPGAStub, const L1TStub *middleStub, const Stub *outerFPGAStub, const L1TStub *outerStub)
bool LLLSeeding(const Stub *innerFPGAStub, const L1TStub *innerStub, const Stub *middleFPGAStub, const L1TStub *middleStub, const Stub *outerFPGAStub, const L1TStub *outerStub)
L1TStub * l1tstub()
Definition: Stub.h:83
bool writeMonitorData(std::string module) const
Definition: Settings.h:118
unsigned int layerdisk() const
Definition: Stub.cc:193
bool debugTracklet() const
Definition: Settings.h:194
bool DDLSeeding(const Stub *innerFPGAStub, const L1TStub *innerStub, const Stub *middleFPGAStub, const L1TStub *middleStub, const Stub *outerFPGAStub, const L1TStub *outerStub)
std::ofstream & ofstream(std::string fname)
Definition: Globals.cc:44
unsigned int ntrackletmax() const
Definition: Settings.h:378
std::string const & getName() const
Definition: ProcessBase.h:22
constexpr int N_LAYER
Definition: Settings.h:25

◆ LLDSeeding()

bool TrackletCalculatorDisplaced::LLDSeeding ( const Stub innerFPGAStub,
const L1TStub innerStub,
const Stub middleFPGAStub,
const L1TStub middleStub,
const Stub outerFPGAStub,
const L1TStub outerStub 
)

Definition at line 1200 of file TrackletCalculatorDisplaced.cc.

References funct::abs(), addDiskProj(), addLayerProj(), trklet::TrackletParametersMemory::addTracklet(), approxtracklet(), d0, trklet::Settings::debugTracklet(), trklet::Stub::disk(), trklet::Settings::disp_z0cut(), dproj_, exacttracklet(), groupFilesInBlocks::fout, trklet::Tracklet::getISeed(), trklet::ProcessBase::getName(), trklet::ProcessBase::globals_, mps_fire::i, trklet::Projection::init(), trklet::Stub::isBarrel(), iSector_, iSeed_, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, trklet::Globals::ITC_L1L2(), dqmiolumiharvest::j, trklet::VarBase::K(), trklet::Settings::kd0(), runTheMatrix::keep, trklet::Settings::kphi1(), trklet::Settings::kr(), trklet::Settings::kz(), trklet::Stub::layer(), layer_, lproj_, trklet::Settings::maxd0(), trklet::N_DISK, trklet::N_LAYER, trklet::ProcessBase::name_, trklet::Settings::nbitsphiprojderL123(), trklet::Settings::nbitsphiprojderL456(), trklet::Settings::nphibitsstub(), trklet::TrackletParametersMemory::nTracklets(), trklet::Settings::nzbitsstub(), trklet::Globals::ofstream(), trklet::L1TStub::phi(), trklet::IMATH_TrackletCalculator::phi0_final, trklet::Settings::phi0_shift(), trklet::Stub::phiapprox(), trklet::Settings::phicritmaxmc(), trklet::Settings::phicritminmc(), phimax_, phimin_, funct::pow(), trklet::Settings::PS_rD_shift(), trklet::Settings::PS_rderD_shift(), trklet::Settings::PS_zderL_shift(), trklet::Settings::PS_zL_shift(), trklet::L1TStub::r(), diffTwoXMLs::r2, trklet::Stub::rapprox(), trklet::Settings::rcrit(), trklet::rinv(), trklet::Settings::rinv_shift(), trklet::Settings::rinvcut(), trklet::Settings::rmaxdisk(), trklet::Settings::rmindisk(), rproj_, trklet::Settings::rPS2S(), trklet::Tracklet::setTCIndex(), trklet::ProcessBase::settings_, trklet::Tracklet::setTrackletIndex(), trklet::Settings::SS_phiD_shift(), trklet::Settings::SS_phiderD_shift(), trklet::Settings::SS_phiderL_shift(), trklet::Settings::SS_phiL_shift(), summarizeEdmComparisonLogfiles::success, submitPVValidationJobs::t, trklet::Settings::t_shift(), TCIndex_, toR_, toZ_, trackletpars_, trklet::Settings::useapprox(), trklet::Settings::usephicritapprox(), trklet::Tracklet::validProj(), trklet::FPGAWord::value(), trklet::Settings::writeMonitorData(), trklet::L1TStub::z(), trklet::Settings::z0_shift(), ppsModifySingularModes_cfi::z1, ppsModifySingularModes_cfi::z2, and trklet::Stub::zapprox().

Referenced by execute(), and trklet::TrackletProcessorDisplaced::execute().

1205  {
1206  if (settings_.debugTracklet())
1207  edm::LogVerbatim("Tracklet") << "TrackletCalculatorDisplaced " << getName() << " " << layer_
1208  << " trying stub triplet in (L2L3D1): " << middleFPGAStub->layer().value() << " "
1209  << outerFPGAStub->layer().value() << " " << innerFPGAStub->disk().value();
1210 
1211  int take3 = 0; //L2L3D1
1212  unsigned ndisks = 1;
1213 
1214  // N.B. The names r1, r2, r3 reflect the fact that confusingly,
1215  // innerStub is actually the one furthest from the beamline ...
1216 
1217  double r3 = innerStub->r();
1218  double z3 = innerStub->z();
1219  double phi3 = innerStub->phi();
1220 
1221  double r1 = middleStub->r();
1222  double z1 = middleStub->z();
1223  double phi1 = middleStub->phi();
1224 
1225  double r2 = outerStub->r();
1226  double z2 = outerStub->z();
1227  double phi2 = outerStub->phi();
1228 
1229  double rinv, phi0, d0, t, z0;
1230 
1231  double phiproj[N_LAYER - 2], zproj[N_LAYER - 2], phider[N_LAYER - 2], zder[N_LAYER - 2];
1232  double phiprojdisk[N_DISK], rprojdisk[N_DISK], phiderdisk[N_DISK], rderdisk[N_DISK];
1233 
1234  exacttracklet(r1,
1235  z1,
1236  phi1,
1237  r2,
1238  z2,
1239  phi2,
1240  r3,
1241  z3,
1242  phi3,
1243  take3,
1244  rinv,
1245  phi0,
1246  d0,
1247  t,
1248  z0,
1249  phiproj,
1250  zproj,
1251  phiprojdisk,
1252  rprojdisk,
1253  phider,
1254  zder,
1255  phiderdisk,
1256  rderdisk);
1257 
1258  if (settings_.debugTracklet())
1259  edm::LogVerbatim("Tracklet") << __LINE__ << ":" << __FILE__ << "LLD Exact values " << innerFPGAStub->isBarrel()
1260  << middleFPGAStub->isBarrel() << outerFPGAStub->isBarrel() << " " << phi3 << ", " << z3
1261  << ", " << r3 << ", " << phi1 << ", " << z1 << ", " << r1 << ", " << phi2 << ", " << z2
1262  << ", " << r2 << endl;
1263 
1264  if (settings_.useapprox()) {
1265  phi3 = innerFPGAStub->phiapprox(phimin_, phimax_);
1266  z3 = innerFPGAStub->zapprox();
1267  r3 = innerFPGAStub->rapprox();
1268 
1269  phi1 = middleFPGAStub->phiapprox(phimin_, phimax_);
1270  z1 = middleFPGAStub->zapprox();
1271  r1 = middleFPGAStub->rapprox();
1272 
1273  phi2 = outerFPGAStub->phiapprox(phimin_, phimax_);
1274  z2 = outerFPGAStub->zapprox();
1275  r2 = outerFPGAStub->rapprox();
1276  }
1277 
1278  if (settings_.debugTracklet())
1279  edm::LogVerbatim("Tracklet") << __LINE__ << ":" << __FILE__ << "LLD approx values " << innerFPGAStub->isBarrel()
1280  << middleFPGAStub->isBarrel() << outerFPGAStub->isBarrel() << " " << phi3 << ", " << z3
1281  << ", " << r3 << ", " << phi1 << ", " << z1 << ", " << r1 << ", " << phi2 << ", " << z2
1282  << ", " << r2 << endl;
1283 
1284  double rinvapprox, phi0approx, d0approx, tapprox, z0approx;
1285  double phiprojapprox[N_LAYER - 2], zprojapprox[N_LAYER - 2], phiderapprox[N_LAYER - 2], zderapprox[N_LAYER - 2];
1286  double phiprojdiskapprox[N_DISK], rprojdiskapprox[N_DISK];
1287  double phiderdiskapprox[N_DISK], rderdiskapprox[N_DISK];
1288 
1289  //TODO: implement the actual integer calculation
1290  if (settings_.useapprox()) {
1291  approxtracklet(r1,
1292  z1,
1293  phi1,
1294  r2,
1295  z2,
1296  phi2,
1297  r3,
1298  z3,
1299  phi3,
1300  take3,
1301  ndisks,
1302  rinvapprox,
1303  phi0approx,
1304  d0approx,
1305  tapprox,
1306  z0approx,
1307  phiprojapprox,
1308  zprojapprox,
1309  phiderapprox,
1310  zderapprox,
1311  phiprojdiskapprox,
1312  rprojdiskapprox,
1313  phiderdiskapprox,
1314  rderdiskapprox);
1315  } else {
1316  rinvapprox = rinv;
1317  phi0approx = phi0;
1318  d0approx = d0;
1319  tapprox = t;
1320  z0approx = z0;
1321 
1322  for (unsigned int i = 0; i < toR_.size(); ++i) {
1323  phiprojapprox[i] = phiproj[i];
1324  zprojapprox[i] = zproj[i];
1325  phiderapprox[i] = phider[i];
1326  zderapprox[i] = zder[i];
1327  }
1328 
1329  for (unsigned int i = 0; i < toZ_.size(); ++i) {
1330  phiprojdiskapprox[i] = phiprojdisk[i];
1331  rprojdiskapprox[i] = rprojdisk[i];
1332  phiderdiskapprox[i] = phiderdisk[i];
1333  rderdiskapprox[i] = rderdisk[i];
1334  }
1335  }
1336 
1337  //store the approcximate results
1338  if (settings_.debugTracklet()) {
1339  edm::LogVerbatim("Tracklet") << "rinvapprox: " << rinvapprox << " rinv: " << rinv << endl;
1340  edm::LogVerbatim("Tracklet") << "phi0approx: " << phi0approx << " phi0: " << phi0 << endl;
1341  edm::LogVerbatim("Tracklet") << "d0approx: " << d0approx << " d0: " << d0 << endl;
1342  edm::LogVerbatim("Tracklet") << "tapprox: " << tapprox << " t: " << t << endl;
1343  edm::LogVerbatim("Tracklet") << "z0approx: " << z0approx << " z0: " << z0 << endl;
1344  }
1345 
1346  for (unsigned int i = 0; i < toR_.size(); ++i) {
1347  if (settings_.debugTracklet()) {
1348  edm::LogVerbatim("Tracklet") << "phiprojapprox[" << i << "]: " << phiprojapprox[i] << " phiproj[" << i
1349  << "]: " << phiproj[i] << endl;
1350  edm::LogVerbatim("Tracklet") << "zprojapprox[" << i << "]: " << zprojapprox[i] << " zproj[" << i
1351  << "]: " << zproj[i] << endl;
1352  edm::LogVerbatim("Tracklet") << "phiderapprox[" << i << "]: " << phiderapprox[i] << " phider[" << i
1353  << "]: " << phider[i] << endl;
1354  edm::LogVerbatim("Tracklet") << "zderapprox[" << i << "]: " << zderapprox[i] << " zder[" << i << "]: " << zder[i]
1355  << endl;
1356  }
1357  }
1358 
1359  for (unsigned int i = 0; i < toZ_.size(); ++i) {
1360  if (settings_.debugTracklet()) {
1361  edm::LogVerbatim("Tracklet") << "phiprojdiskapprox[" << i << "]: " << phiprojdiskapprox[i] << " phiprojdisk[" << i
1362  << "]: " << phiprojdisk[i] << endl;
1363  edm::LogVerbatim("Tracklet") << "rprojdiskapprox[" << i << "]: " << rprojdiskapprox[i] << " rprojdisk[" << i
1364  << "]: " << rprojdisk[i] << endl;
1365  edm::LogVerbatim("Tracklet") << "phiderdiskapprox[" << i << "]: " << phiderdiskapprox[i] << " phiderdisk[" << i
1366  << "]: " << phiderdisk[i] << endl;
1367  edm::LogVerbatim("Tracklet") << "rderdiskapprox[" << i << "]: " << rderdiskapprox[i] << " rderdisk[" << i
1368  << "]: " << rderdisk[i] << endl;
1369  }
1370  }
1371 
1372  //now binary
1373  double krinv = settings_.kphi1() / settings_.kr() * pow(2, settings_.rinv_shift()),
1374  kphi0 = settings_.kphi1() * pow(2, settings_.phi0_shift()),
1375  kt = settings_.kz() / settings_.kr() * pow(2, settings_.t_shift()),
1376  kz0 = settings_.kz() * pow(2, settings_.z0_shift()),
1377  kphiproj = settings_.kphi1() * pow(2, settings_.SS_phiL_shift()),
1378  kphider = settings_.kphi1() / settings_.kr() * pow(2, settings_.SS_phiderL_shift()),
1379  kzproj = settings_.kz() * pow(2, settings_.PS_zL_shift()),
1380  kzder = settings_.kz() / settings_.kr() * pow(2, settings_.PS_zderL_shift()),
1381  kphiprojdisk = settings_.kphi1() * pow(2, settings_.SS_phiD_shift()),
1382  kphiderdisk = settings_.kphi1() / settings_.kr() * pow(2, settings_.SS_phiderD_shift()),
1383  krprojdisk = settings_.kr() * pow(2, settings_.PS_rD_shift()),
1384  krderdisk = settings_.kr() / settings_.kz() * pow(2, settings_.PS_rderD_shift());
1385 
1386  int irinv, iphi0, id0, it, iz0;
1387  int iphiproj[N_LAYER - 2], izproj[N_LAYER - 2], iphider[N_LAYER - 2], izder[N_LAYER - 2];
1388  int iphiprojdisk[N_DISK], irprojdisk[N_DISK], iphiderdisk[N_DISK], irderdisk[N_DISK];
1389 
1390  //store the binary results
1391  irinv = rinvapprox / krinv;
1392  iphi0 = phi0approx / kphi0;
1393  id0 = d0approx / settings_.kd0();
1394  it = tapprox / kt;
1395  iz0 = z0approx / kz0;
1396 
1397  bool success = true;
1398  if (std::abs(rinvapprox) > settings_.rinvcut()) {
1399  if (settings_.debugTracklet())
1400  edm::LogVerbatim("Tracklet") << "TrackletCalculator:: LLD Seeding irinv too large: " << rinvapprox << "(" << irinv
1401  << ")";
1402  success = false;
1403  }
1404  if (std::abs(z0approx) > settings_.disp_z0cut()) {
1405  if (settings_.debugTracklet())
1406  edm::LogVerbatim("Tracklet") << "Failed tracklet z0 cut " << z0approx;
1407  success = false;
1408  }
1409  if (std::abs(d0approx) > settings_.maxd0()) {
1410  if (settings_.debugTracklet())
1411  edm::LogVerbatim("Tracklet") << "Failed tracklet approx d0 cut " << d0approx;
1412  success = false;
1413  }
1414  if (std::abs(d0) > settings_.maxd0()) {
1415  if (settings_.debugTracklet())
1416  edm::LogVerbatim("Tracklet") << "Failed tracklet exact d0 cut " << d0;
1417  success = false;
1418  }
1419 
1420  if (!success)
1421  return false;
1422 
1423  double phicritapprox = phi0approx - asin((0.5 * settings_.rcrit() * rinvapprox) + (d0approx / settings_.rcrit()));
1424  int phicrit = iphi0 - 2 * irinv - 2 * id0;
1425 
1426  int iphicritmincut = settings_.phicritminmc() / globals_->ITC_L1L2()->phi0_final.K();
1427  int iphicritmaxcut = settings_.phicritmaxmc() / globals_->ITC_L1L2()->phi0_final.K();
1428 
1429  bool keepapprox = (phicritapprox > settings_.phicritminmc()) && (phicritapprox < settings_.phicritmaxmc()),
1430  keep = (phicrit > iphicritmincut) && (phicrit < iphicritmaxcut);
1431 
1432  if (settings_.debugTracklet())
1433  if (keep && !keepapprox)
1434  edm::LogVerbatim("Tracklet") << "TrackletCalculatorDisplaced::LLDSeeding tracklet kept with exact phicrit cut "
1435  "but not approximate, phicritapprox: "
1436  << phicritapprox;
1437  if (settings_.usephicritapprox()) {
1438  if (!keepapprox)
1439  return false;
1440  } else {
1441  if (!keep)
1442  return false;
1443  }
1444 
1445  Projection projs[N_LAYER + N_DISK];
1446 
1447  for (unsigned int i = 0; i < toR_.size(); ++i) {
1448  iphiproj[i] = phiprojapprox[i] / kphiproj;
1449  izproj[i] = zprojapprox[i] / kzproj;
1450 
1451  iphider[i] = phiderapprox[i] / kphider;
1452  izder[i] = zderapprox[i] / kzder;
1453 
1454  if (izproj[i] < -(1 << (settings_.nzbitsstub(0) - 1)))
1455  continue;
1456  if (izproj[i] >= (1 << (settings_.nzbitsstub(0) - 1)))
1457  continue;
1458 
1459  //this is left from the original....
1460  if (iphiproj[i] >= (1 << settings_.nphibitsstub(5)) - 1)
1461  continue;
1462  if (iphiproj[i] <= 0)
1463  continue;
1464 
1465  if (rproj_[i] < settings_.rPS2S()) {
1466  iphiproj[i] >>= (settings_.nphibitsstub(5) - settings_.nphibitsstub(0));
1467  } else {
1468  izproj[i] >>= (settings_.nzbitsstub(0) - settings_.nzbitsstub(5));
1469  }
1470 
1471  if (rproj_[i] < settings_.rPS2S()) {
1472  if (iphider[i] < -(1 << (settings_.nbitsphiprojderL123() - 1)))
1473  iphider[i] = -(1 << (settings_.nbitsphiprojderL123() - 1));
1474  if (iphider[i] >= (1 << (settings_.nbitsphiprojderL123() - 1)))
1475  iphider[i] = (1 << (settings_.nbitsphiprojderL123() - 1)) - 1;
1476  } else {
1477  if (iphider[i] < -(1 << (settings_.nbitsphiprojderL456() - 1)))
1478  iphider[i] = -(1 << (settings_.nbitsphiprojderL456() - 1));
1479  if (iphider[i] >= (1 << (settings_.nbitsphiprojderL456() - 1)))
1480  iphider[i] = (1 << (settings_.nbitsphiprojderL456() - 1)) - 1;
1481  }
1482 
1483  projs[lproj_[i] - 1].init(settings_,
1484  lproj_[i] - 1,
1485  iphiproj[i],
1486  izproj[i],
1487  iphider[i],
1488  izder[i],
1489  phiproj[i],
1490  zproj[i],
1491  phider[i],
1492  zder[i],
1493  phiprojapprox[i],
1494  zprojapprox[i],
1495  phiderapprox[i],
1496  zderapprox[i],
1497  false);
1498  }
1499 
1500  if (std::abs(it * kt) > 1.0) {
1501  for (unsigned int i = 0; i < toZ_.size(); ++i) {
1502  iphiprojdisk[i] = phiprojdiskapprox[i] / kphiprojdisk;
1503  irprojdisk[i] = rprojdiskapprox[i] / krprojdisk;
1504 
1505  iphiderdisk[i] = phiderdiskapprox[i] / kphiderdisk;
1506  irderdisk[i] = rderdiskapprox[i] / krderdisk;
1507 
1508  //Check phi range of projection
1509  if (iphiprojdisk[i] <= 0)
1510  continue;
1511  if (iphiprojdisk[i] >= (1 << settings_.nphibitsstub(0)) - 1)
1512  continue;
1513 
1514  //Check r range of projection
1515  if (irprojdisk[i] < settings_.rmindisk() / krprojdisk || irprojdisk[i] >= settings_.rmaxdisk() / krprojdisk)
1516  continue;
1517 
1518  projs[N_LAYER + i + 1].init(settings_,
1519  N_LAYER + i + 1,
1520  iphiprojdisk[i],
1521  irprojdisk[i],
1522  iphiderdisk[i],
1523  irderdisk[i],
1524  phiprojdisk[i],
1525  rprojdisk[i],
1526  phiderdisk[i],
1527  rderdisk[i],
1528  phiprojdiskapprox[i],
1529  rprojdiskapprox[i],
1530  phiderdisk[i],
1531  rderdisk[i],
1532  false);
1533  }
1534  }
1535 
1536  if (settings_.writeMonitorData("TrackletPars")) {
1537  globals_->ofstream("trackletpars.txt")
1538  << layer_ << " , " << rinv << " , " << rinvapprox << " , " << phi0 << " , " << phi0approx << " , " << t << " , "
1539  << tapprox << " , " << z0 << " , " << z0approx << " , " << d0 << " , " << d0approx << endl;
1540  }
1541 
1542  Tracklet* tracklet = new Tracklet(settings_,
1543  iSeed_,
1544  innerFPGAStub,
1545  middleFPGAStub,
1546  outerFPGAStub,
1547  rinv,
1548  phi0,
1549  d0,
1550  z0,
1551  t,
1552  rinvapprox,
1553  phi0approx,
1554  d0approx,
1555  z0approx,
1556  tapprox,
1557  irinv,
1558  iphi0,
1559  id0,
1560  iz0,
1561  it,
1562  projs,
1563  false);
1564 
1565  if (settings_.debugTracklet())
1566  edm::LogVerbatim("Tracklet") << "TrackletCalculatorDisplaced " << getName()
1567  << " Found LLD tracklet in sector = " << iSector_ << " phi0 = " << phi0;
1568 
1570  tracklet->setTCIndex(TCIndex_);
1571 
1572  if (settings_.writeMonitorData("Seeds")) {
1573  ofstream fout("seeds.txt", ofstream::app);
1574  fout << __FILE__ << ":" << __LINE__ << " " << name_ << "_" << iSector_ << " " << tracklet->getISeed() << endl;
1575  fout.close();
1576  }
1577  trackletpars_->addTracklet(tracklet);
1578 
1579  for (unsigned int j = 0; j < toR_.size(); j++) {
1580  if (settings_.debugTracklet())
1581  edm::LogVerbatim("Tracklet") << "adding layer projection " << j << "/" << toR_.size() << " " << lproj_[j];
1582  if (tracklet->validProj(lproj_[j] - 1)) {
1583  addLayerProj(tracklet, lproj_[j]);
1584  }
1585  }
1586 
1587  for (unsigned int j = 0; j < toZ_.size(); j++) {
1588  int disk = dproj_[j];
1589  if (disk == 0)
1590  continue;
1591  if (it < 0)
1592  disk = -disk;
1593  if (settings_.debugTracklet())
1594  edm::LogVerbatim("Tracklet") << "adding disk projection " << j << "/" << toZ_.size() << " " << disk;
1595  if (tracklet->validProj(N_LAYER + abs(disk) - 1)) {
1596  addDiskProj(tracklet, disk);
1597  }
1598  }
1599 
1600  return true;
1601 }
Log< level::Info, true > LogVerbatim
double kz() const
Definition: Settings.h:349
double phi() const
Definition: L1TStub.h:65
int PS_rD_shift() const
Definition: Settings.h:404
int PS_zL_shift() const
Definition: Settings.h:396
double zapprox() const
Definition: Stub.cc:166
constexpr int N_DISK
Definition: Settings.h:26
int PS_rderD_shift() const
Definition: Settings.h:407
int PS_zderL_shift() const
Definition: Settings.h:399
double rPS2S() const
Definition: Settings.h:369
std::string name_
Definition: ProcessBase.h:42
double kphi1() const
Definition: Settings.h:346
bool addLayerProj(Tracklet *tracklet, int layer)
double phiapprox(double phimin, double) const
Definition: Stub.cc:185
double disp_z0cut() const
Definition: Settings.h:373
double phicritmaxmc() const
Definition: Settings.h:342
double rmindisk() const
Definition: Settings.h:135
bool isBarrel() const
Definition: Stub.h:87
double maxd0() const
Definition: Settings.h:355
Settings const & settings_
Definition: ProcessBase.h:44
double z() const
Definition: L1TStub.h:59
Globals * globals_
Definition: ProcessBase.h:45
int phi0_shift() const
Definition: Settings.h:388
double phicritminmc() const
Definition: Settings.h:341
const FPGAWord & disk() const
Definition: Stub.h:74
void init(Settings const &settings, unsigned int layerdisk, int iphiproj, int irzproj, int iphider, int irzder, double phiproj, double rzproj, double phiprojder, double rzprojder, double phiprojapprox, double rzprojapprox, double phiprojderapprox, double rzprojderapprox, bool isPSseed)
Definition: Projection.cc:11
unsigned int nbitsphiprojderL456() const
Definition: Settings.h:97
void exacttracklet(double r1, double z1, double phi1, double r2, double z2, double phi2, double r3, double z3, double phi3, int take3, double &rinv, double &phi0, double &d0, double &t, double &z0, double phiproj[N_LAYER - 2], double zproj[N_LAYER - 2], double phiprojdisk[N_DISK], double rprojdisk[N_DISK], double phider[N_LAYER - 2], double zder[N_LAYER - 2], double phiderdisk[N_DISK], double rderdisk[N_DISK])
unsigned int nzbitsstub(unsigned int layerdisk) const
Definition: Settings.h:91
unsigned int nphibitsstub(unsigned int layerdisk) const
Definition: Settings.h:92
int t_shift() const
Definition: Settings.h:389
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
IMATH_TrackletCalculator * ITC_L1L2()
Definition: Globals.h:48
int value() const
Definition: FPGAWord.h:24
double rinvcut() const
Definition: Settings.h:222
int z0_shift() const
Definition: Settings.h:390
void approxtracklet(double r1, double z1, double phi1, double r2, double z2, double phi2, double r3, double z3, double phi3, bool take3, unsigned ndisks, double &rinv, double &phi0, double &d0, double &t, double &z0, double phiproj[4], double zproj[4], double phider[4], double zder[4], double phiprojdisk[5], double rprojdisk[5], double phiderdisk[5], double rderdisk[5])
bool writeMonitorData(std::string module) const
Definition: Settings.h:118
double rapprox() const
Definition: Stub.cc:152
void setTCIndex(int index)
Definition: Tracklet.h:210
double K() const
Definition: imath.h:247
int SS_phiD_shift() const
Definition: Settings.h:403
bool debugTracklet() const
Definition: Settings.h:194
int SS_phiderD_shift() const
Definition: Settings.h:406
double kr() const
Definition: Settings.h:351
static constexpr float d0
double rmaxdisk() const
Definition: Settings.h:134
void addDiskProj(Tracklet *tracklet, int disk)
void setTrackletIndex(unsigned int index)
Definition: Tracklet.cc:815
double kd0() const
Definition: Settings.h:358
double rinv(double phi1, double phi2, double r1, double r2)
Definition: Util.h:66
int getISeed() const
Definition: Tracklet.cc:820
int SS_phiderL_shift() const
Definition: Settings.h:398
unsigned int nbitsphiprojderL123() const
Definition: Settings.h:96
double r() const
Definition: L1TStub.h:60
int rinv_shift() const
Definition: Settings.h:387
std::ofstream & ofstream(std::string fname)
Definition: Globals.cc:44
const FPGAWord & layer() const
Definition: Stub.h:73
bool usephicritapprox() const
Definition: Settings.h:248
std::string const & getName() const
Definition: ProcessBase.h:22
int SS_phiL_shift() const
Definition: Settings.h:395
bool useapprox() const
Definition: Settings.h:247
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
bool validProj(int layerdisk) const
Definition: Tracklet.h:82
constexpr int N_LAYER
Definition: Settings.h:25
double rcrit() const
Definition: Settings.h:334

◆ LLLSeeding()

bool TrackletCalculatorDisplaced::LLLSeeding ( const Stub innerFPGAStub,
const L1TStub innerStub,
const Stub middleFPGAStub,
const L1TStub middleStub,
const Stub outerFPGAStub,
const L1TStub outerStub 
)

Definition at line 372 of file TrackletCalculatorDisplaced.cc.

References funct::abs(), addDiskProj(), addLayerProj(), trklet::TrackletParametersMemory::addTracklet(), approxtracklet(), cms::cuda::assert(), d0, trklet::Settings::debugTracklet(), trklet::Settings::disp_z0cut(), dproj_, exacttracklet(), groupFilesInBlocks::fout, trklet::Tracklet::getISeed(), trklet::ProcessBase::getName(), trklet::ProcessBase::globals_, mps_fire::i, trklet::Projection::init(), trklet::Stub::isBarrel(), iSector_, iSeed_, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, trklet::Globals::ITC_L1L2(), dqmiolumiharvest::j, trklet::VarBase::K(), trklet::Settings::kd0(), runTheMatrix::keep, trklet::Settings::kphi1(), trklet::Settings::kr(), trklet::Settings::kz(), trklet::Stub::layer(), layer_, trklet::Stub::layerdisk(), lproj_, trklet::Settings::maxd0(), trklet::N_DISK, trklet::N_LAYER, trklet::ProcessBase::name_, trklet::Settings::nbitsphiprojderL123(), trklet::Settings::nbitsphiprojderL456(), trklet::Settings::nphibitsstub(), trklet::TrackletParametersMemory::nTracklets(), trklet::Settings::nzbitsstub(), trklet::Globals::ofstream(), trklet::L1TStub::phi(), trklet::IMATH_TrackletCalculator::phi0_final, trklet::Settings::phi0_shift(), trklet::Stub::phiapprox(), trklet::Settings::phicritmaxmc(), trklet::Settings::phicritminmc(), phimax_, phimin_, funct::pow(), trklet::Settings::PS_rD_shift(), trklet::Settings::PS_rderD_shift(), trklet::Settings::PS_zderL_shift(), trklet::Settings::PS_zL_shift(), trklet::L1TStub::r(), diffTwoXMLs::r2, trklet::Stub::rapprox(), trklet::Settings::rcrit(), trklet::rinv(), trklet::Settings::rinv_shift(), trklet::Settings::rinvcut(), trklet::Settings::rmaxdisk(), trklet::Settings::rmindisk(), rproj_, trklet::Settings::rPS2S(), trklet::Tracklet::setTCIndex(), trklet::ProcessBase::settings_, trklet::Tracklet::setTrackletIndex(), trklet::Settings::SS_phiD_shift(), trklet::Settings::SS_phiderD_shift(), trklet::Settings::SS_phiderL_shift(), trklet::Settings::SS_phiL_shift(), summarizeEdmComparisonLogfiles::success, submitPVValidationJobs::t, trklet::Settings::t_shift(), TCIndex_, toR_, toZ_, trackletpars_, trklet::Settings::useapprox(), trklet::Settings::usephicritapprox(), trklet::Tracklet::validProj(), trklet::FPGAWord::value(), trklet::Settings::writeMonitorData(), trklet::L1TStub::z(), trklet::Settings::z0_shift(), ppsModifySingularModes_cfi::z1, ppsModifySingularModes_cfi::z2, and trklet::Stub::zapprox().

Referenced by execute(), and trklet::TrackletProcessorDisplaced::execute().

377  {
378  if (settings_.debugTracklet())
379  edm::LogVerbatim("Tracklet") << "TrackletCalculatorDisplaced " << getName() << " " << layer_
380  << " trying stub triplet in layer (L L L): " << innerFPGAStub->layer().value() << " "
381  << middleFPGAStub->layer().value() << " " << outerFPGAStub->layer().value();
382 
383  assert(outerFPGAStub->layerdisk() < N_LAYER);
384 
385  double r1 = innerStub->r();
386  double z1 = innerStub->z();
387  double phi1 = innerStub->phi();
388 
389  double r2 = middleStub->r();
390  double z2 = middleStub->z();
391  double phi2 = middleStub->phi();
392 
393  double r3 = outerStub->r();
394  double z3 = outerStub->z();
395  double phi3 = outerStub->phi();
396 
397  int take3 = 0;
398  if (layer_ == 5)
399  take3 = 1;
400  unsigned ndisks = 0;
401 
402  double rinv, phi0, d0, t, z0;
403 
404  Projection projs[N_LAYER + N_DISK];
405 
406  double phiproj[N_LAYER - 2], zproj[N_LAYER - 2], phider[N_LAYER - 2], zder[N_LAYER - 2];
407  double phiprojdisk[N_DISK], rprojdisk[N_DISK], phiderdisk[N_DISK], rderdisk[N_DISK];
408 
409  exacttracklet(r1,
410  z1,
411  phi1,
412  r2,
413  z2,
414  phi2,
415  r3,
416  z3,
417  phi3,
418  take3,
419  rinv,
420  phi0,
421  d0,
422  t,
423  z0,
424  phiproj,
425  zproj,
426  phiprojdisk,
427  rprojdisk,
428  phider,
429  zder,
430  phiderdisk,
431  rderdisk);
432  if (settings_.debugTracklet())
433  edm::LogVerbatim("Tracklet") << __LINE__ << ":" << __FILE__ << "LLL Exact values " << innerFPGAStub->isBarrel()
434  << middleFPGAStub->isBarrel() << outerFPGAStub->isBarrel() << " " << phi1 << ", " << z1
435  << ", " << r1 << ", " << phi2 << ", " << z2 << ", " << r2 << ", " << phi3 << ", " << z3
436  << ", " << r3 << endl;
437 
438  if (settings_.useapprox()) {
439  phi1 = innerFPGAStub->phiapprox(phimin_, phimax_);
440  z1 = innerFPGAStub->zapprox();
441  r1 = innerFPGAStub->rapprox();
442 
443  phi2 = middleFPGAStub->phiapprox(phimin_, phimax_);
444  z2 = middleFPGAStub->zapprox();
445  r2 = middleFPGAStub->rapprox();
446 
447  phi3 = outerFPGAStub->phiapprox(phimin_, phimax_);
448  z3 = outerFPGAStub->zapprox();
449  r3 = outerFPGAStub->rapprox();
450  }
451 
452  if (settings_.debugTracklet())
453  edm::LogVerbatim("Tracklet") << __LINE__ << ":" << __FILE__ << "LLL Approx values " << innerFPGAStub->isBarrel()
454  << middleFPGAStub->isBarrel() << outerFPGAStub->isBarrel() << " " << phi1 << ", " << z1
455  << ", " << r1 << ", " << phi2 << ", " << z2 << ", " << r2 << ", " << phi3 << ", " << z3
456  << ", " << r3 << endl;
457 
458  double rinvapprox, phi0approx, d0approx, tapprox, z0approx;
459  double phiprojapprox[N_LAYER - 2], zprojapprox[N_LAYER - 2], phiderapprox[N_LAYER - 2], zderapprox[N_LAYER - 2];
460  double phiprojdiskapprox[N_DISK], rprojdiskapprox[N_DISK];
461  double phiderdiskapprox[N_DISK], rderdiskapprox[N_DISK];
462 
463  //TODO: implement the actual integer calculation
464  if (settings_.useapprox()) {
465  approxtracklet(r1,
466  z1,
467  phi1,
468  r2,
469  z2,
470  phi2,
471  r3,
472  z3,
473  phi3,
474  take3,
475  ndisks,
476  rinvapprox,
477  phi0approx,
478  d0approx,
479  tapprox,
480  z0approx,
481  phiprojapprox,
482  zprojapprox,
483  phiderapprox,
484  zderapprox,
485  phiprojdiskapprox,
486  rprojdiskapprox,
487  phiderdiskapprox,
488  rderdiskapprox);
489  } else {
490  rinvapprox = rinv;
491  phi0approx = phi0;
492  d0approx = d0;
493  tapprox = t;
494  z0approx = z0;
495 
496  for (unsigned int i = 0; i < toR_.size(); ++i) {
497  phiprojapprox[i] = phiproj[i];
498  zprojapprox[i] = zproj[i];
499  phiderapprox[i] = phider[i];
500  zderapprox[i] = zder[i];
501  }
502 
503  for (unsigned int i = 0; i < toZ_.size(); ++i) {
504  phiprojdiskapprox[i] = phiprojdisk[i];
505  rprojdiskapprox[i] = rprojdisk[i];
506  phiderdiskapprox[i] = phiderdisk[i];
507  rderdiskapprox[i] = rderdisk[i];
508  }
509  }
510 
511  //store the approcximate results
512 
513  if (settings_.debugTracklet()) {
514  edm::LogVerbatim("Tracklet") << "rinvapprox: " << rinvapprox << " rinv: " << rinv << endl;
515  edm::LogVerbatim("Tracklet") << "phi0approx: " << phi0approx << " phi0: " << phi0 << endl;
516  edm::LogVerbatim("Tracklet") << "d0approx: " << d0approx << " d0: " << d0 << endl;
517  edm::LogVerbatim("Tracklet") << "tapprox: " << tapprox << " t: " << t << endl;
518  edm::LogVerbatim("Tracklet") << "z0approx: " << z0approx << " z0: " << z0 << endl;
519  }
520 
521  for (unsigned int i = 0; i < toR_.size(); ++i) {
522  if (settings_.debugTracklet()) {
523  edm::LogVerbatim("Tracklet") << "phiprojapprox[" << i << "]: " << phiprojapprox[i] << " phiproj[" << i
524  << "]: " << phiproj[i] << endl;
525  edm::LogVerbatim("Tracklet") << "zprojapprox[" << i << "]: " << zprojapprox[i] << " zproj[" << i
526  << "]: " << zproj[i] << endl;
527  edm::LogVerbatim("Tracklet") << "phiderapprox[" << i << "]: " << phiderapprox[i] << " phider[" << i
528  << "]: " << phider[i] << endl;
529  edm::LogVerbatim("Tracklet") << "zderapprox[" << i << "]: " << zderapprox[i] << " zder[" << i << "]: " << zder[i]
530  << endl;
531  }
532  }
533 
534  for (unsigned int i = 0; i < toZ_.size(); ++i) {
535  if (settings_.debugTracklet()) {
536  edm::LogVerbatim("Tracklet") << "phiprojdiskapprox[" << i << "]: " << phiprojdiskapprox[i] << " phiprojdisk[" << i
537  << "]: " << phiprojdisk[i] << endl;
538  edm::LogVerbatim("Tracklet") << "rprojdiskapprox[" << i << "]: " << rprojdiskapprox[i] << " rprojdisk[" << i
539  << "]: " << rprojdisk[i] << endl;
540  edm::LogVerbatim("Tracklet") << "phiderdiskapprox[" << i << "]: " << phiderdiskapprox[i] << " phiderdisk[" << i
541  << "]: " << phiderdisk[i] << endl;
542  edm::LogVerbatim("Tracklet") << "rderdiskapprox[" << i << "]: " << rderdiskapprox[i] << " rderdisk[" << i
543  << "]: " << rderdisk[i] << endl;
544  }
545  }
546 
547  //now binary
548  double krinv = settings_.kphi1() / settings_.kr() * pow(2, settings_.rinv_shift()),
549  kphi0 = settings_.kphi1() * pow(2, settings_.phi0_shift()),
550  kt = settings_.kz() / settings_.kr() * pow(2, settings_.t_shift()),
551  kz0 = settings_.kz() * pow(2, settings_.z0_shift()),
552  kphiproj = settings_.kphi1() * pow(2, settings_.SS_phiL_shift()),
553  kphider = settings_.kphi1() / settings_.kr() * pow(2, settings_.SS_phiderL_shift()),
554  kzproj = settings_.kz() * pow(2, settings_.PS_zL_shift()),
555  kzder = settings_.kz() / settings_.kr() * pow(2, settings_.PS_zderL_shift()),
556  kphiprojdisk = settings_.kphi1() * pow(2, settings_.SS_phiD_shift()),
557  kphiderdisk = settings_.kphi1() / settings_.kr() * pow(2, settings_.SS_phiderD_shift()),
558  krprojdisk = settings_.kr() * pow(2, settings_.PS_rD_shift()),
559  krderdisk = settings_.kr() / settings_.kz() * pow(2, settings_.PS_rderD_shift());
560 
561  int irinv, iphi0, id0, it, iz0;
562  int iphiproj[N_LAYER - 2], izproj[N_LAYER - 2], iphider[N_LAYER - 2], izder[N_LAYER - 2];
563  int iphiprojdisk[N_DISK], irprojdisk[N_DISK], iphiderdisk[N_DISK], irderdisk[N_DISK];
564 
565  //store the binary results
566  irinv = rinvapprox / krinv;
567  iphi0 = phi0approx / kphi0;
568  id0 = d0approx / settings_.kd0();
569  it = tapprox / kt;
570  iz0 = z0approx / kz0;
571 
572  bool success = true;
573  if (std::abs(rinvapprox) > settings_.rinvcut()) {
574  if (settings_.debugTracklet())
575  edm::LogVerbatim("Tracklet") << "TrackletCalculator::LLL Seeding irinv too large: " << rinvapprox << "(" << irinv
576  << ")";
577  success = false;
578  }
579  if (std::abs(z0approx) > settings_.disp_z0cut()) {
580  if (settings_.debugTracklet())
581  edm::LogVerbatim("Tracklet") << "Failed tracklet z0 cut " << z0approx << " in layer " << layer_;
582  success = false;
583  }
584  if (std::abs(d0approx) > settings_.maxd0()) {
585  if (settings_.debugTracklet())
586  edm::LogVerbatim("Tracklet") << "Failed tracklet approx d0 cut " << d0approx;
587  success = false;
588  }
589  if (std::abs(d0) > settings_.maxd0()) {
590  if (settings_.debugTracklet())
591  edm::LogVerbatim("Tracklet") << "Failed tracklet exact d0 cut " << d0;
592  success = false;
593  }
594 
595  if (!success) {
596  return false;
597  }
598 
599  double phicritapprox = phi0approx - asin((0.5 * settings_.rcrit() * rinvapprox) + (d0approx / settings_.rcrit()));
600  int phicrit = iphi0 - 2 * irinv - 2 * id0;
601 
602  int iphicritmincut = settings_.phicritminmc() / globals_->ITC_L1L2()->phi0_final.K();
603  int iphicritmaxcut = settings_.phicritmaxmc() / globals_->ITC_L1L2()->phi0_final.K();
604 
605  bool keepapprox = (phicritapprox > settings_.phicritminmc()) && (phicritapprox < settings_.phicritmaxmc()),
606  keep = (phicrit > iphicritmincut) && (phicrit < iphicritmaxcut);
607 
608  if (settings_.debugTracklet())
609  if (keep && !keepapprox)
610  edm::LogVerbatim("Tracklet") << "TrackletCalculatorDisplaced::LLLSeeding tracklet kept with exact phicrit cut "
611  "but not approximate, phicritapprox: "
612  << phicritapprox;
613  if (settings_.usephicritapprox()) {
614  if (!keepapprox) {
615  return false;
616  }
617  } else {
618  if (!keep) {
619  return false;
620  }
621  }
622 
623  for (unsigned int i = 0; i < toR_.size(); ++i) {
624  iphiproj[i] = phiprojapprox[i] / kphiproj;
625  izproj[i] = zprojapprox[i] / kzproj;
626 
627  iphider[i] = phiderapprox[i] / kphider;
628  izder[i] = zderapprox[i] / kzder;
629 
630  //check that z projection is in range
631  if (izproj[i] < -(1 << (settings_.nzbitsstub(0) - 1)))
632  continue;
633  if (izproj[i] >= (1 << (settings_.nzbitsstub(0) - 1)))
634  continue;
635 
636  //check that phi projection is in range
637  if (iphiproj[i] >= (1 << settings_.nphibitsstub(N_LAYER - 1)) - 1)
638  continue;
639  if (iphiproj[i] <= 0)
640  continue;
641 
642  //adjust number of bits for phi and z projection
643  if (rproj_[i] < settings_.rPS2S()) {
644  iphiproj[i] >>= (settings_.nphibitsstub(N_LAYER - 1) - settings_.nphibitsstub(0));
645  if (iphiproj[i] >= (1 << settings_.nphibitsstub(0)) - 1)
646  iphiproj[i] = (1 << settings_.nphibitsstub(0)) - 2; //-2 not to hit atExtreme
647  } else {
648  izproj[i] >>= (settings_.nzbitsstub(0) - settings_.nzbitsstub(N_LAYER - 1));
649  }
650 
651  if (rproj_[i] < settings_.rPS2S()) {
652  if (iphider[i] < -(1 << (settings_.nbitsphiprojderL123() - 1))) {
653  iphider[i] = -(1 << (settings_.nbitsphiprojderL123() - 1));
654  }
655  if (iphider[i] >= (1 << (settings_.nbitsphiprojderL123() - 1))) {
656  iphider[i] = (1 << (settings_.nbitsphiprojderL123() - 1)) - 1;
657  }
658  } else {
659  if (iphider[i] < -(1 << (settings_.nbitsphiprojderL456() - 1))) {
660  iphider[i] = -(1 << (settings_.nbitsphiprojderL456() - 1));
661  }
662  if (iphider[i] >= (1 << (settings_.nbitsphiprojderL456() - 1))) {
663  iphider[i] = (1 << (settings_.nbitsphiprojderL456() - 1)) - 1;
664  }
665  }
666 
667  projs[lproj_[i] - 1].init(settings_,
668  lproj_[i] - 1,
669  iphiproj[i],
670  izproj[i],
671  iphider[i],
672  izder[i],
673  phiproj[i],
674  zproj[i],
675  phider[i],
676  zder[i],
677  phiprojapprox[i],
678  zprojapprox[i],
679  phiderapprox[i],
680  zderapprox[i],
681  false);
682  }
683 
684  if (std::abs(it * kt) > 1.0) {
685  for (unsigned int i = 0; i < toZ_.size(); ++i) {
686  iphiprojdisk[i] = phiprojdiskapprox[i] / kphiprojdisk;
687  irprojdisk[i] = rprojdiskapprox[i] / krprojdisk;
688 
689  iphiderdisk[i] = phiderdiskapprox[i] / kphiderdisk;
690  irderdisk[i] = rderdiskapprox[i] / krderdisk;
691 
692  //check phi projection in range
693  if (iphiprojdisk[i] <= 0)
694  continue;
695  if (iphiprojdisk[i] >= (1 << settings_.nphibitsstub(0)) - 1)
696  continue;
697 
698  //check r projection in range
699  if (rprojdiskapprox[i] < settings_.rmindisk() || rprojdiskapprox[i] >= settings_.rmaxdisk())
700  continue;
701 
702  projs[N_LAYER + i].init(settings_,
703  N_LAYER + i,
704  iphiprojdisk[i],
705  irprojdisk[i],
706  iphiderdisk[i],
707  irderdisk[i],
708  phiprojdisk[i],
709  rprojdisk[i],
710  phiderdisk[i],
711  rderdisk[i],
712  phiprojdiskapprox[i],
713  rprojdiskapprox[i],
714  phiderdisk[i],
715  rderdisk[i],
716  false);
717  }
718  }
719 
720  if (settings_.writeMonitorData("TrackletPars")) {
721  globals_->ofstream("trackletpars.txt")
722  << layer_ << " , " << rinv << " , " << rinvapprox << " , " << phi0 << " , " << phi0approx << " , " << t << " , "
723  << tapprox << " , " << z0 << " , " << z0approx << " , " << d0 << " , " << d0approx << endl;
724  }
725 
726  Tracklet* tracklet = new Tracklet(settings_,
727  iSeed_,
728  innerFPGAStub,
729  middleFPGAStub,
730  outerFPGAStub,
731  rinv,
732  phi0,
733  d0,
734  z0,
735  t,
736  rinvapprox,
737  phi0approx,
738  d0approx,
739  z0approx,
740  tapprox,
741  irinv,
742  iphi0,
743  id0,
744  iz0,
745  it,
746  projs,
747  false);
748 
749  if (settings_.debugTracklet())
750  edm::LogVerbatim("Tracklet") << "TrackletCalculatorDisplaced " << getName()
751  << " Found LLL tracklet in sector = " << iSector_ << " phi0 = " << phi0;
752 
754  tracklet->setTCIndex(TCIndex_);
755 
756  if (settings_.writeMonitorData("Seeds")) {
757  ofstream fout("seeds.txt", ofstream::app);
758  fout << __FILE__ << ":" << __LINE__ << " " << name_ << "_" << iSector_ << " " << tracklet->getISeed() << endl;
759  fout.close();
760  }
761  trackletpars_->addTracklet(tracklet);
762 
763  bool addL5 = false;
764  bool addL6 = false;
765  for (unsigned int j = 0; j < toR_.size(); j++) {
766  bool added = false;
767 
768  if (settings_.debugTracklet())
769  edm::LogVerbatim("Tracklet") << "adding layer projection " << j << "/" << toR_.size() << " " << lproj_[j];
770  if (tracklet->validProj(lproj_[j] - 1)) {
771  added = addLayerProj(tracklet, lproj_[j]);
772  if (added && lproj_[j] == 5)
773  addL5 = true;
774  if (added && lproj_[j] == 6)
775  addL6 = true;
776  }
777  }
778 
779  for (unsigned int j = 0; j < toZ_.size(); j++) {
780  int disk = dproj_[j];
781  if (disk == 0)
782  continue;
783  if (disk == 2 && addL5)
784  continue;
785  if (disk == 1 && addL6)
786  continue;
787  if (it < 0)
788  disk = -disk;
789  if (settings_.debugTracklet())
790  edm::LogVerbatim("Tracklet") << "adding disk projection " << j << "/" << toZ_.size() << " " << disk;
791  if (tracklet->validProj(N_LAYER + abs(disk) - 1)) {
792  addDiskProj(tracklet, disk);
793  }
794  }
795 
796  return true;
797 }
Log< level::Info, true > LogVerbatim
double kz() const
Definition: Settings.h:349
double phi() const
Definition: L1TStub.h:65
int PS_rD_shift() const
Definition: Settings.h:404
int PS_zL_shift() const
Definition: Settings.h:396
double zapprox() const
Definition: Stub.cc:166
constexpr int N_DISK
Definition: Settings.h:26
int PS_rderD_shift() const
Definition: Settings.h:407
int PS_zderL_shift() const
Definition: Settings.h:399
double rPS2S() const
Definition: Settings.h:369
std::string name_
Definition: ProcessBase.h:42
double kphi1() const
Definition: Settings.h:346
bool addLayerProj(Tracklet *tracklet, int layer)
double phiapprox(double phimin, double) const
Definition: Stub.cc:185
double disp_z0cut() const
Definition: Settings.h:373
double phicritmaxmc() const
Definition: Settings.h:342
double rmindisk() const
Definition: Settings.h:135
bool isBarrel() const
Definition: Stub.h:87
double maxd0() const
Definition: Settings.h:355
Settings const & settings_
Definition: ProcessBase.h:44
double z() const
Definition: L1TStub.h:59
Globals * globals_
Definition: ProcessBase.h:45
int phi0_shift() const
Definition: Settings.h:388
assert(be >=bs)
double phicritminmc() const
Definition: Settings.h:341
void init(Settings const &settings, unsigned int layerdisk, int iphiproj, int irzproj, int iphider, int irzder, double phiproj, double rzproj, double phiprojder, double rzprojder, double phiprojapprox, double rzprojapprox, double phiprojderapprox, double rzprojderapprox, bool isPSseed)
Definition: Projection.cc:11
unsigned int nbitsphiprojderL456() const
Definition: Settings.h:97
void exacttracklet(double r1, double z1, double phi1, double r2, double z2, double phi2, double r3, double z3, double phi3, int take3, double &rinv, double &phi0, double &d0, double &t, double &z0, double phiproj[N_LAYER - 2], double zproj[N_LAYER - 2], double phiprojdisk[N_DISK], double rprojdisk[N_DISK], double phider[N_LAYER - 2], double zder[N_LAYER - 2], double phiderdisk[N_DISK], double rderdisk[N_DISK])
unsigned int nzbitsstub(unsigned int layerdisk) const
Definition: Settings.h:91
unsigned int nphibitsstub(unsigned int layerdisk) const
Definition: Settings.h:92
int t_shift() const
Definition: Settings.h:389
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
IMATH_TrackletCalculator * ITC_L1L2()
Definition: Globals.h:48
int value() const
Definition: FPGAWord.h:24
double rinvcut() const
Definition: Settings.h:222
int z0_shift() const
Definition: Settings.h:390
void approxtracklet(double r1, double z1, double phi1, double r2, double z2, double phi2, double r3, double z3, double phi3, bool take3, unsigned ndisks, double &rinv, double &phi0, double &d0, double &t, double &z0, double phiproj[4], double zproj[4], double phider[4], double zder[4], double phiprojdisk[5], double rprojdisk[5], double phiderdisk[5], double rderdisk[5])
bool writeMonitorData(std::string module) const
Definition: Settings.h:118
unsigned int layerdisk() const
Definition: Stub.cc:193
double rapprox() const
Definition: Stub.cc:152
void setTCIndex(int index)
Definition: Tracklet.h:210
double K() const
Definition: imath.h:247
int SS_phiD_shift() const
Definition: Settings.h:403
bool debugTracklet() const
Definition: Settings.h:194
int SS_phiderD_shift() const
Definition: Settings.h:406
double kr() const
Definition: Settings.h:351
static constexpr float d0
double rmaxdisk() const
Definition: Settings.h:134
void addDiskProj(Tracklet *tracklet, int disk)
void setTrackletIndex(unsigned int index)
Definition: Tracklet.cc:815
double kd0() const
Definition: Settings.h:358
double rinv(double phi1, double phi2, double r1, double r2)
Definition: Util.h:66
int getISeed() const
Definition: Tracklet.cc:820
int SS_phiderL_shift() const
Definition: Settings.h:398
unsigned int nbitsphiprojderL123() const
Definition: Settings.h:96
double r() const
Definition: L1TStub.h:60
int rinv_shift() const
Definition: Settings.h:387
std::ofstream & ofstream(std::string fname)
Definition: Globals.cc:44
const FPGAWord & layer() const
Definition: Stub.h:73
bool usephicritapprox() const
Definition: Settings.h:248
std::string const & getName() const
Definition: ProcessBase.h:22
int SS_phiL_shift() const
Definition: Settings.h:395
bool useapprox() const
Definition: Settings.h:247
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
bool validProj(int layerdisk) const
Definition: Tracklet.h:82
constexpr int N_LAYER
Definition: Settings.h:25
double rcrit() const
Definition: Settings.h:334

Member Data Documentation

◆ disk_

int trklet::TrackletCalculatorDisplaced::disk_
protected

Definition at line 161 of file TrackletCalculatorDisplaced.h.

Referenced by TrackletCalculatorDisplaced().

◆ dproj_

int trklet::TrackletCalculatorDisplaced::dproj_[N_DISK - 2]
protected

◆ innerallstubs_

std::vector<AllStubsMemory*> trklet::TrackletCalculatorDisplaced::innerallstubs_
protected

◆ iSector_

unsigned int trklet::TrackletCalculatorDisplaced::iSector_
protected

◆ iSeed_

unsigned int trklet::TrackletCalculatorDisplaced::iSeed_
protected

◆ layer_

int trklet::TrackletCalculatorDisplaced::layer_
protected

◆ lproj_

int trklet::TrackletCalculatorDisplaced::lproj_[N_LAYER - 2]
protected

◆ middleallstubs_

std::vector<AllStubsMemory*> trklet::TrackletCalculatorDisplaced::middleallstubs_
protected

◆ outerallstubs_

std::vector<AllStubsMemory*> trklet::TrackletCalculatorDisplaced::outerallstubs_
protected

◆ phimax_

double trklet::TrackletCalculatorDisplaced::phimax_
protected

◆ phimin_

double trklet::TrackletCalculatorDisplaced::phimin_
protected

◆ rproj_

double trklet::TrackletCalculatorDisplaced::rproj_[N_LAYER - 2]
protected

◆ rzmeanInv_

double trklet::TrackletCalculatorDisplaced::rzmeanInv_[N_DISK - 2]
protected

Definition at line 167 of file TrackletCalculatorDisplaced.h.

Referenced by approxtracklet(), and TrackletCalculatorDisplaced().

◆ stubtriplets_

std::vector<StubTripletsMemory*> trklet::TrackletCalculatorDisplaced::stubtriplets_
protected

Definition at line 178 of file TrackletCalculatorDisplaced.h.

Referenced by addInput(), and execute().

◆ TCIndex_

int trklet::TrackletCalculatorDisplaced::TCIndex_
protected

◆ toR_

std::vector<double> trklet::TrackletCalculatorDisplaced::toR_
protected

◆ toZ_

std::vector<double> trklet::TrackletCalculatorDisplaced::toZ_
protected

◆ trackletpars_

TrackletParametersMemory* trklet::TrackletCalculatorDisplaced::trackletpars_
protected

◆ trackletprojdisks_

std::vector<std::vector<TrackletProjectionsMemory*> > trklet::TrackletCalculatorDisplaced::trackletprojdisks_
protected

◆ trackletprojlayers_

std::vector<std::vector<TrackletProjectionsMemory*> > trklet::TrackletCalculatorDisplaced::trackletprojlayers_
protected

◆ zproj_

double trklet::TrackletCalculatorDisplaced::zproj_[N_DISK - 2]
protected

Definition at line 165 of file TrackletCalculatorDisplaced.h.

Referenced by TrackletCalculatorDisplaced().