CMS 3D CMS Logo

GeometricTimingDet.cc
Go to the documentation of this file.
5 
6 #include "CLHEP/Units/GlobalSystemOfUnits.h"
7 
8 #include <cfloat>
9 #include <vector>
10 #include <string>
11 
12 namespace {
13 
14  const std::string strue("true");
15 
16  template <typename DDView>
17  double getDouble(const char* s, DDView const& ev) {
18  DDValue val(s);
19  std::vector<const DDsvalues_type*> result;
20  ev.specificsV(result);
21  std::vector<const DDsvalues_type*>::iterator it = result.begin();
22  bool foundIt = false;
23  for (; it != result.end(); ++it) {
24  foundIt = DDfetch(*it, val);
25  if (foundIt)
26  break;
27  }
28  if (foundIt) {
29  const std::vector<std::string>& temp = val.strings();
30  if (temp.size() != 1) {
31  throw cms::Exception("Configuration") << "I need 1 " << s << " tags";
32  }
33  return double(::atof(temp[0].c_str()));
34  }
35  return 0;
36  }
37 
38  template <typename DDView>
39  std::string getString(const char* s, DDView const& ev) {
40  DDValue val(s);
41  std::vector<const DDsvalues_type*> result;
42  ev.specificsV(result);
43  std::vector<const DDsvalues_type*>::iterator it = result.begin();
44  bool foundIt = false;
45  for (; it != result.end(); ++it) {
46  foundIt = DDfetch(*it, val);
47  if (foundIt)
48  break;
49  }
50  if (foundIt) {
51  const std::vector<std::string>& temp = val.strings();
52  if (temp.size() != 1) {
53  throw cms::Exception("Configuration") << "I need 1 " << s << " tags";
54  }
55  return temp[0];
56  }
57  return "NotFound";
58  }
59 } // namespace
60 
66 
68  : //
69  // Set by hand the ddd_
70  //
71  trans_(fv->translation()),
72  phi_(trans_.Phi()),
73  rho_(trans_.Rho()),
74  rot_(fv->rotation()),
75  shape_(fv->shape()),
76  ddname_(fv->name()),
77  type_(type),
78  params_(fv->parameters()),
79  radLength_(getDouble("TrackerRadLength", *fv)),
80  xi_(getDouble("TrackerXi", *fv)),
81  pixROCRows_(getDouble("PixelROCRows", *fv)),
82  pixROCCols_(getDouble("PixelROCCols", *fv)),
83  pixROCx_(getDouble("PixelROC_X", *fv)),
84  pixROCy_(getDouble("PixelROC_Y", *fv)),
85  stereo_(getString("TrackerStereoDetectors", *fv) == strue),
86  siliconAPVNum_(getDouble("SiliconAPVNumber", *fv)) {
87  const DDFilteredView::nav_type& nt = fv->navPos();
88  ddd_ = nav_type(nt.begin(), nt.end());
89 }
90 
91 // PGeometricTimingDet is persistent version... make it... then come back here and make the
92 // constructor.
94  : trans_(onePGD.x_, onePGD.y_, onePGD.z_),
95  phi_(onePGD.phi_), //_trans.Phi()),
96  rho_(onePGD.rho_), //_trans.Rho()),
97  rot_(onePGD.a11_,
98  onePGD.a12_,
99  onePGD.a13_,
100  onePGD.a21_,
101  onePGD.a22_,
102  onePGD.a23_,
103  onePGD.a31_,
104  onePGD.a32_,
105  onePGD.a33_),
106  shape_(static_cast<DDSolidShape>(onePGD.shape_)),
107  ddd_(),
108  ddname_(onePGD.name_), //, "fromdb");
109  type_(type),
110  params_(),
112  radLength_(onePGD.radLength_),
113  xi_(onePGD.xi_),
114  pixROCRows_(onePGD.pixROCRows_),
115  pixROCCols_(onePGD.pixROCCols_),
116  pixROCx_(onePGD.pixROCx_),
117  pixROCy_(onePGD.pixROCy_),
118  stereo_(onePGD.stereo_),
120  if (onePGD.shape_ == 1 || onePGD.shape_ == 3) { //The parms vector is neede only in the case of box or trap shape
121  params_.reserve(11);
122  params_.emplace_back(onePGD.params_0);
123  params_.emplace_back(onePGD.params_1);
124  params_.emplace_back(onePGD.params_2);
125  params_.emplace_back(onePGD.params_3);
126  params_.emplace_back(onePGD.params_4);
127  params_.emplace_back(onePGD.params_5);
128  params_.emplace_back(onePGD.params_6);
129  params_.emplace_back(onePGD.params_7);
130  params_.emplace_back(onePGD.params_8);
131  params_.emplace_back(onePGD.params_9);
132  params_.emplace_back(onePGD.params_10);
133  }
134 
135  ddd_.reserve(onePGD.numnt_);
136  ddd_.emplace_back(onePGD.nt0_);
137  ddd_.emplace_back(onePGD.nt1_);
138  ddd_.emplace_back(onePGD.nt2_);
139  ddd_.emplace_back(onePGD.nt3_);
140  if (onePGD.numnt_ > 4) {
141  ddd_.emplace_back(onePGD.nt4_);
142  if (onePGD.numnt_ > 5) {
143  ddd_.emplace_back(onePGD.nt5_);
144  if (onePGD.numnt_ > 6) {
145  ddd_.emplace_back(onePGD.nt6_);
146  if (onePGD.numnt_ > 7) {
147  ddd_.emplace_back(onePGD.nt7_);
148  if (onePGD.numnt_ > 8) {
149  ddd_.emplace_back(onePGD.nt8_);
150  if (onePGD.numnt_ > 9) {
151  ddd_.emplace_back(onePGD.nt9_);
152  if (onePGD.numnt_ > 10) {
153  ddd_.emplace_back(onePGD.nt10_);
154  }
155  }
156  }
157  }
158  }
159  }
160  }
161 }
162 
164  //
165  // iterate on all the components ;)
166  //
168  deepComponents(temp);
169  return temp;
170 }
171 
173  if (isLeaf()) {
174  cont.emplace_back(this);
175  } else
176  std::for_each(
177  container_.begin(), container_.end(), [&](const GeometricTimingDet* iDet) { iDet->deepComponents(cont); });
178 }
179 
181  container_.reserve(container_.size() + cont.size());
182  std::copy(cont.begin(), cont.end(), back_inserter(container_));
183 }
184 
186  container_.reserve(container_.size() + cont.size());
187  std::copy(cont.begin(), cont.end(), back_inserter(container_));
188 }
189 
191 
192 namespace {
193  struct Deleter {
194  void operator()(GeometricTimingDet const* det) const { delete const_cast<GeometricTimingDet*>(det); }
195  };
196 } // namespace
197 
199  std::for_each(container_.begin(), container_.end(), Deleter());
200  container_.clear();
201 }
202 
204  Position pos(float(trans_.x() / cm), float(trans_.y() / cm), float(trans_.z() / cm));
205  return pos;
206 }
207 
209  Translation x, y, z;
210  rot_.GetComponents(x, y, z);
211  Rotation rotation(float(x.X()),
212  float(x.Y()),
213  float(x.Z()),
214  float(y.X()),
215  float(y.Y()),
216  float(y.Z()),
217  float(z.X()),
218  float(z.Y()),
219  float(z.Z()));
220  return rotation;
221 }
222 
223 std::unique_ptr<Bounds> GeometricTimingDet::bounds() const {
224  const std::vector<double>& par = params_;
225  TrackerShapeToBounds shapeToBounds;
226  return std::unique_ptr<Bounds>(shapeToBounds.buildBounds(shape_, par));
227 }
type
Definition: HCALResponse.h:21
GeometricTimingEnumType type_
bool ev
nav_type navPos() const
return the stack of sibling numbers
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:79
void addComponents(GeometricTimingDetContainer const &cont)
Position positionBounds() const
std::vector< double > params_
Bounds * buildBounds(const DDSolidShape &, const std::vector< double > &) const
std::unique_ptr< Bounds > bounds() const
ConstGeometricTimingDetContainer deepComponents() const
void addComponent(GeometricTimingDet *)
GeometricTimingDet(DDFilteredView *fv, GeometricTimingEnumType dd)
int nt
Definition: AMPTWrapper.h:42
enum GeometricTimingDet::GTDEnumType GeometricTimingEnumType
std::string const & name() const
DDSolidShape
Definition: DDSolidShapes.h:6
DDExpandedView::nav_type nav_type
DDExpandedView::nav_type nav_type
std::vector< GeometricTimingDet const * > ConstGeometricTimingDetContainer
std::vector< GeometricTimingDet * > GeometricTimingDetContainer
RotationMatrix const & rotation() const
DDSolidShape const & shape() const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > Translation
ConstGeometricTimingDetContainer container_
cont
load Luminosity info ##
Definition: generateEDF.py:629
Rotation rotationBounds() const
Translation const & translation() const