CMS 3D CMS Logo

MuonPath.cc
Go to the documentation of this file.
2 
3 #include <cmath>
4 #include <iostream>
5 #include <memory>
6 
7 using namespace cmsdt;
8 
10  quality_ = NOPATH;
11  baseChannelId_ = -1;
12 
13  for (int i = 0; i < NUM_LAYERS_2SL; i++) {
14  prim_.push_back(std::make_shared<DTPrimitive>());
15  }
16 
17  nprimitives_ = NUM_LAYERS;
18  bxTimeValue_ = -1;
19  bxNumId_ = -1;
20  tanPhi_ = 0;
21  horizPos_ = 0;
22  chiSquare_ = 0;
23  for (int i = 0; i < NUM_LAYERS; i++) {
24  lateralComb_[i] = LEFT;
25  setXCoorCell(0, i);
26  setDriftDistance(0, i);
27  }
28 }
29 
30 MuonPath::MuonPath(DTPrimitivePtrs &ptrPrimitive, int nprimUp, int nprimDown) {
31  if (nprimUp > 0 || nprimDown > 0)
32  nprimitives_ = NUM_LAYERS_2SL; //Instead of nprimUp + nprimDown;
33  else {
34  nprimitives_ = NUM_LAYERS;
35  }
36  nprimitivesUp_ = nprimUp;
37  nprimitivesDown_ = nprimDown;
38  rawId_ = 0;
39  quality_ = NOPATH;
40  baseChannelId_ = -1;
41  bxTimeValue_ = -1;
42  bxNumId_ = -1;
43  tanPhi_ = 0;
44  horizPos_ = 0;
45  chiSquare_ = 0;
46  phi_ = 0;
47  phiB_ = 0;
48  phicmssw_ = 0;
49  phiBcmssw_ = 0;
50 
51  for (short i = 0; i < nprimitives_; i++) {
52  lateralComb_[i] = LEFT;
53  prim_.push_back(std::make_shared<DTPrimitive>(ptrPrimitive[i]));
54 
55  setXCoorCell(0, i);
56  setDriftDistance(0, i);
57  setXWirePos(0, i);
58  setZWirePos(0, i);
59  setTWireTDC(0, i);
60  }
61 }
62 
63 MuonPath::MuonPath(DTPrimitives &ptrPrimitive, int nprimUp, int nprimDown) {
64  if (nprimUp > 0 || nprimDown > 0)
65  nprimitives_ = NUM_LAYERS_2SL; //Instead of nprimUp + nprimDown;
66  else {
67  nprimitives_ = NUM_LAYERS;
68  }
69  nprimitivesUp_ = nprimUp;
70  nprimitivesDown_ = nprimDown;
71  rawId_ = 0;
72  quality_ = NOPATH;
73  baseChannelId_ = -1;
74  bxTimeValue_ = -1;
75  bxNumId_ = -1;
76  tanPhi_ = 0;
77  horizPos_ = 0;
78  chiSquare_ = 0;
79  phi_ = 0;
80  phiB_ = 0;
81  phicmssw_ = 0;
82  phiBcmssw_ = 0;
83 
84  for (short i = 0; i < nprimitives_; i++) {
85  lateralComb_[i] = LEFT;
86  prim_.push_back(std::make_shared<DTPrimitive>(ptrPrimitive[i]));
87 
88  setXCoorCell(0, i);
89  setDriftDistance(0, i);
90  setXWirePos(0, i);
91  setZWirePos(0, i);
92  setTWireTDC(0, i);
93  }
94 }
95 
97  setRawId(ptr->rawId());
98  setPhi(ptr->phi());
99  setPhiB(ptr->phiB());
100  setPhiCMSSW(ptr->phi_cmssw());
101  setPhiBCMSSW(ptr->phiB_cmssw());
102  setQuality(ptr->quality());
103  setBaseChannelId(ptr->baseChannelId());
104  setCellHorizontalLayout(ptr->cellLayout());
105  setNPrimitives(ptr->nprimitives());
106 
107  setLateralComb(ptr->lateralComb());
108  setBxTimeValue(ptr->bxTimeValue());
109  setTanPhi(ptr->tanPhi());
110  setHorizPos(ptr->horizPos());
111  setChiSquare(ptr->chiSquare());
112 
113  for (int i = 0; i < ptr->nprimitives(); i++) {
114  prim_.push_back(ptr->primitive(i));
115 
116  setXCoorCell(ptr->xCoorCell(i), i);
117  setDriftDistance(ptr->xDriftDistance(i), i);
118  setXWirePos(ptr->xWirePos(i), i);
119  setZWirePos(ptr->zWirePos(i), i);
120  setTWireTDC(ptr->tWireTDC(i), i);
121  }
122 }
123 
124 //------------------------------------------------------------------
125 //--- Public
126 //------------------------------------------------------------------
127 void MuonPath::setPrimitive(DTPrimitivePtr &ptr, int layer) { prim_[layer] = std::move(ptr); }
128 
130  for (int i = 0; i < NUM_LAYERS; i++)
131  cellLayout_[i] = layout[i];
132 }
133 
135  for (int i = 0; i < NUM_LAYERS; i++)
136  cellLayout_[i] = layout[i];
137 }
138 
140  for (int i = 0; i < ptr->nprimitives(); i++) {
141  if (this->primitive(i)->isValidTime() && ptr->primitive(i)->isValidTime()) {
142  if (ptr->primitive(i)->superLayerId() != this->primitive(i)->superLayerId() ||
143 
144  ptr->primitive(i)->channelId() != this->primitive(i)->channelId() ||
145 
146  ptr->primitive(i)->tdcTimeStamp() != this->primitive(i)->tdcTimeStamp() ||
147 
148  ptr->primitive(i)->orbit() != this->primitive(i)->orbit() ||
149  (ptr->lateralComb())[i] != (this->lateralComb())[i])
150  return false;
151  } else {
152  if (!this->primitive(i)->isValidTime() && !ptr->primitive(i)->isValidTime())
153  continue;
154 
155  else
156  return false;
157  }
158  }
159 
160  return true;
161 }
162 
164  short countValidHits = 0;
165  for (int i = 0; i < this->nprimitives(); i++) {
166  // if (!this->primitive(i))
167  // continue;
168  if (this->primitive(i)->isValidTime())
169  countValidHits++;
170  }
171 
172  if (countValidHits >= 3)
173  return true;
174  return false;
175 }
176 
178  return (prim_[0]->isValidTime() && prim_[1]->isValidTime() && prim_[2]->isValidTime() && prim_[3]->isValidTime());
179 }
180 
182  bxTimeValue_ = time;
183 
184  float auxBxId = float(time) / LHC_CLK_FREQ;
185  bxNumId_ = int(auxBxId);
186  if ((auxBxId - int(auxBxId)) >= 0.5)
187  bxNumId_ = int(bxNumId_ + 1);
188 }
189 
191  for (int i = 0; i < nprimitives_; i++) {
192  if (!this->primitive(i)->isValidTime())
193  continue;
194  lateralComb_[i] = this->primitive(i)->laterality();
195  }
196 }
197 
199  for (int i = 0; i < NUM_LAYERS; i++)
200  lateralComb_[i] = latComb[i];
201 }
202 
204  for (int i = 0; i < NUM_LAYERS; i++)
205  lateralComb_[i] = latComb[i];
206 }
std::vector< DTPrimitivePtr > DTPrimitivePtrs
Definition: DTprimitive.h:55
void setLateralCombFromPrimitives(void)
Definition: MuonPath.cc:190
LATERAL_CASES
Definition: constants.h:45
void setCellHorizontalLayout(int layout[4])
Definition: MuonPath.cc:129
bool isAnalyzable()
Definition: MuonPath.cc:163
Primitive< F, X >::type primitive(const F &f)
Definition: Primitive.h:41
constexpr std::array< uint8_t, layerIndexSize > layer
bool isEqualTo(MuonPath *ptr)
Definition: MuonPath.cc:139
DTPrimitivePtr primitive(int layer) const
Definition: MuonPath.h:45
void setLateralComb(cmsdt::LATERAL_CASES latComb[4])
Definition: MuonPath.cc:198
constexpr int NUM_LAYERS_2SL
Definition: constants.h:254
constexpr int LHC_CLK_FREQ
Definition: constants.h:176
short nprimitives() const
Definition: MuonPath.h:46
void setBxTimeValue(int time)
Definition: MuonPath.cc:181
MuonPath()
Definition: MuonPath.cc:9
std::vector< DTPrimitive > DTPrimitives
Definition: DTprimitive.h:53
std::shared_ptr< MuonPath > MuonPathPtr
Definition: MuonPath.h:127
constexpr int NUM_LAYERS
Definition: constants.h:219
bool completeMP()
Definition: MuonPath.cc:177
void setPrimitive(DTPrimitivePtr &ptr, int layer)
Definition: MuonPath.cc:127
def move(src, dest)
Definition: eostools.py:511
std::shared_ptr< DTPrimitive > DTPrimitivePtr
Definition: DTprimitive.h:54
const cmsdt::LATERAL_CASES * lateralComb() const
Definition: MuonPath.h:55