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 }
56 
57 void L1TStub::write(ofstream& out) {
58  out << "Stub: " << DTClink_ << "\t" << region_ << "\t" << layerdisk_ << "\t" << stubword_ << "\t" << isPSmodule_
59  << "\t" << isFlipped_ << "\t" << x_ << "\t" << y_ << "\t" << z_ << "\t" << bend_ << "\t" << strip_ << "\t"
60  << "\t" << tps_.size() << " \t";
61  for (int itp : tps_) {
62  out << itp << " \t";
63  }
64  out << endl;
65 }
66 
67 bool L1TStub::operator==(const L1TStub& other) const {
68  return (other.iphi() == iphi_ && other.iz() == iz_ && other.layer() == layer_ && other.detId() == detId_);
69 }
70 
71 void L1TStub::lorentzcor(double shift) {
72  double r = this->r();
73  double phi = this->phi() - shift / r;
74  this->x_ = r * cos(phi);
75  this->y_ = r * sin(phi);
76 }
77 
78 double L1TStub::alpha(double pitch) const {
79  if (isPSmodule())
80  return 0.0;
81  int flip = 1;
82  if (isFlipped())
83  flip = -1;
84  if (z_ > 0.0) {
85  return ((int)strip_ - 509.5) * pitch * flip / r2();
86  }
87  return -((int)strip_ - 509.5) * pitch * flip / r2();
88 }
89 
90 double L1TStub::alphanorm() const {
91  if (isPSmodule())
92  return 0.0;
93  int flip = 1;
94  if (isFlipped())
95  flip = -1;
96  if (z_ > 0.0) {
97  return ((int)strip_ - 509.5) * flip / 510.0;
98  }
99  return -((int)strip_ - 509.5) * flip / 510.0;
100 }
101 
102 void L1TStub::setXY(double x, double y) {
103  x_ = x;
104  y_ = y;
105 }
106 
107 bool L1TStub::tpmatch(int tp) const {
108  for (int itp : tps_) {
109  if (tp == std::abs(itp))
110  return true;
111  }
112 
113  return false;
114 }
115 
116 bool L1TStub::tpmatch2(int tp) const {
117  bool match1 = false;
118  bool match2 = false;
119  for (int itp : tps_) {
120  if (tp == itp) {
121  match1 = true;
122  }
123  if (tp == -itp) {
124  match2 = true;
125  }
126  }
127 
128  return match1 && match2;
129 }
float alpha
Definition: AMPTWrapper.h:105
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:21