CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  double x,
15  double y,
16  double z,
17  double bend,
18  double strip,
19  std::vector<int> tps) {
20  DTClink_ = DTClink;
21  layerdisk_ = layerdisk;
22  region_ = region;
23  stubword_ = stubword;
24  eventid_ = -1;
25  tps_ = tps;
26  iphi_ = -1;
27  iz_ = -1;
28  layer_ = layerdisk;
29  if (layerdisk >= N_LAYER) {
30  layer_ = 1000 + layerdisk - N_LAYER + 1;
31  if (z < 0.0)
32  layer_ += 1000;
33  }
34 
35  ladder_ = -1;
36  module_ = -1;
37  strip_ = strip;
38  x_ = x;
39  y_ = y;
40  z_ = z;
41  sigmax_ = -1.0;
42  sigmaz_ = -1.0;
43  pt_ = -1.0;
44  bend_ = bend;
45  isPSmodule_ = isPSmodule;
46  isFlipped_ = isFlipped;
47 
48  allstubindex_ = 999;
49 }
50 
51 void L1TStub::write(ofstream& out) {
52  out << "Stub: " << DTClink_ << "\t" << region_ << "\t" << layerdisk_ << "\t" << stubword_ << "\t" << isPSmodule_
53  << "\t" << isFlipped_ << "\t" << x_ << "\t" << y_ << "\t" << z_ << "\t" << bend_ << "\t" << strip_ << "\t"
54  << "\t" << tps_.size() << " \t";
55  for (int itp : tps_) {
56  out << itp << " \t";
57  }
58  out << endl;
59 }
60 
61 bool L1TStub::operator==(const L1TStub& other) const {
62  return (other.iphi() == iphi_ && other.iz() == iz_ && other.layer() == layer_ && other.ladder() == ladder_ &&
63  other.module() == module_);
64 }
65 
66 void L1TStub::lorentzcor(double shift) {
67  double r = this->r();
68  double phi = this->phi() - shift / r;
69  this->x_ = r * cos(phi);
70  this->y_ = r * sin(phi);
71 }
72 
73 double L1TStub::alpha(double pitch) const {
74  if (isPSmodule())
75  return 0.0;
76  int flip = 1;
77  if (isFlipped())
78  flip = -1;
79  if (z_ > 0.0) {
80  return ((int)strip_ - 509.5) * pitch * flip / r2();
81  }
82  return -((int)strip_ - 509.5) * pitch * flip / r2();
83 }
84 
85 double L1TStub::alphanorm() const {
86  if (isPSmodule())
87  return 0.0;
88  int flip = 1;
89  if (isFlipped())
90  flip = -1;
91  if (z_ > 0.0) {
92  return ((int)strip_ - 509.5) * flip / 510.0;
93  }
94  return -((int)strip_ - 509.5) * flip / 510.0;
95 }
96 
97 void L1TStub::setXY(double x, double y) {
98  x_ = x;
99  y_ = y;
100 }
101 
102 bool L1TStub::tpmatch(int tp) const {
103  for (int itp : tps_) {
104  if (tp == std::abs(itp))
105  return true;
106  }
107 
108  return false;
109 }
110 
111 bool L1TStub::tpmatch2(int tp) const {
112  bool match1 = false;
113  bool match2 = false;
114  for (int itp : tps_) {
115  if (tp == itp) {
116  match1 = true;
117  }
118  if (tp == -itp) {
119  match2 = true;
120  }
121  }
122 
123  return match1 && match2;
124 }
125 
126 bool L1TStub::isTilted() const {
127  //here layer_ runs 0-5 for barrel, >1000 for disk
128  //disk modules and outer barrel modules are not tilted by construction
129  if (layer_ >= N_PSLAYER)
130  return false;
131 
132  assert(layer_ < N_PSLAYER); // safety for acccessing # modules/plank
134  return true;
135  return false;
136 }
static const char module_[]
float alpha
Definition: AMPTWrapper.h:105
static const char layer_[]
unsigned int iz() const
Definition: L1TStub.h:66
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
assert(be >=bs)
constexpr std::array< unsigned int, N_PSLAYER > N_MOD_PLANK
Definition: Settings.h:894
constexpr unsigned int N_TILTED_RINGS
Definition: Settings.h:893
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
unsigned int iphi() const
Definition: L1TStub.h:65
unsigned int module() const
Definition: L1TStub.h:53
unsigned int ladder() const
Definition: L1TStub.h:52
constexpr unsigned int N_PSLAYER
Definition: Settings.h:23
static unsigned int const shift
unsigned int layer() const
Definition: L1TStub.h:41
constexpr int N_LAYER
Definition: Settings.h:21