CMS 3D CMS Logo

L1TStub.cc
Go to the documentation of this file.
2 
3 using namespace std;
4 using namespace trklet;
5 
6 L1TStub::L1TStub() {}
7 
8 L1TStub::L1TStub(std::string DTClink,
9  int region,
10  int layerdisk,
11  std::string stubword,
12  int isPSmodule,
13  int isFlipped,
14  bool tiltedBarrel,
15  unsigned int tiltedRingId,
16  unsigned int endcapRingId,
17  unsigned int detId,
18  double x,
19  double y,
20  double z,
21  double bend,
22  double strip,
23  std::vector<int> tps) {
24  DTClink_ = DTClink;
25  layerdisk_ = layerdisk;
26  region_ = region;
27  stubword_ = stubword;
28  eventid_ = -1;
29  tps_ = tps;
30  iphi_ = -1;
31  iz_ = -1;
32  layer_ = layerdisk;
33  if (layerdisk >= N_LAYER) {
34  layer_ = 1000 + layerdisk - N_LAYER + 1;
35  if (z < 0.0)
36  layer_ += 1000;
37  }
38 
39  strip_ = strip;
40  x_ = x;
41  y_ = y;
42  z_ = z;
43  sigmax_ = -1.0;
44  sigmaz_ = -1.0;
45  pt_ = -1.0;
46  bend_ = bend;
47  isPSmodule_ = isPSmodule;
48  isFlipped_ = isFlipped;
49  tiltedBarrel_ = tiltedBarrel;
50  tiltedRingId_ = tiltedRingId;
51  endcapRingId_ = endcapRingId;
52  detId_ = detId;
53 
54  allstubindex_ = 999;
55  uniqueindex_ = 99999;
56 }
57 
58 void L1TStub::write(ofstream& out) {
59  out << "Stub: " << DTClink_ << "\t" << region_ << "\t" << layerdisk_ << "\t" << stubword_ << "\t" << isPSmodule_
60  << "\t" << isFlipped_ << "\t" << x_ << "\t" << y_ << "\t" << z_ << "\t" << bend_ << "\t" << strip_ << "\t"
61  << "\t" << tps_.size() << " \t";
62  for (int itp : tps_) {
63  out << itp << " \t";
64  }
65  out << endl;
66 }
67 
68 bool L1TStub::operator==(const L1TStub& other) const {
69  return (other.iphi() == iphi_ && other.iz() == iz_ && other.layer() == layer_ && other.detId() == detId_);
70 }
71 
72 void L1TStub::lorentzcor(double shift) {
73  double r = this->r();
74  double phi = this->phi() - shift / r;
75  this->x_ = r * cos(phi);
76  this->y_ = r * sin(phi);
77 }
78 
79 double L1TStub::alpha(double pitch) const {
80  if (isPSmodule())
81  return 0.0;
82  int flip = 1;
83  if (isFlipped())
84  flip = -1;
85  if (z_ > 0.0) {
86  return ((int)strip_ - 509.5) * pitch * flip / r2();
87  }
88  return -((int)strip_ - 509.5) * pitch * flip / r2();
89 }
90 
91 double L1TStub::alphanorm() const {
92  if (isPSmodule())
93  return 0.0;
94  int flip = 1;
95  if (isFlipped())
96  flip = -1;
97  if (z_ > 0.0) {
98  return ((int)strip_ - 509.5) * flip / 510.0;
99  }
100  return -((int)strip_ - 509.5) * flip / 510.0;
101 }
102 
103 void L1TStub::setXY(double x, double y) {
104  x_ = x;
105  y_ = y;
106 }
107 
108 bool L1TStub::tpmatch(int tp) const {
109  for (int itp : tps_) {
110  if (tp == std::abs(itp))
111  return true;
112  }
113 
114  return false;
115 }
116 
117 bool L1TStub::tpmatch2(int tp) const {
118  bool match1 = false;
119  bool match2 = false;
120  for (int itp : tps_) {
121  if (tp == itp) {
122  match1 = true;
123  }
124  if (tp == -itp) {
125  match2 = true;
126  }
127  }
128 
129  return match1 && match2;
130 }
static const char layer_[]
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
bool operator==(const QGLikelihoodParameters &lhs, const QGLikelihoodCategory &rhs)
Test if parameters are compatible with category.
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static unsigned int const shift
float x
constexpr int N_LAYER
Definition: Settings.h:25