CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GeometricTimingDet.cc
Go to the documentation of this file.
6 
8 #include <DD4hep/DD4hepUnits.h>
9 
10 #include <cfloat>
11 #include <vector>
12 #include <string>
13 
14 namespace {
15 
16  const std::string strue("true");
17 
18  template <typename DDView>
19  double getDouble(const char* s, DDView const& ev) {
20  DDValue val(s);
21  std::vector<const DDsvalues_type*> result;
22  ev.specificsV(result);
23  std::vector<const DDsvalues_type*>::iterator it = result.begin();
24  bool foundIt = false;
25  for (; it != result.end(); ++it) {
26  foundIt = DDfetch(*it, val);
27  if (foundIt)
28  break;
29  }
30  if (foundIt) {
31  const std::vector<std::string>& temp = val.strings();
32  if (temp.size() != 1) {
33  throw cms::Exception("Configuration") << "I need 1 " << s << " tags";
34  }
35  return double(::atof(temp[0].c_str()));
36  }
37  return 0;
38  }
39 
40  template <typename DDView>
41  std::string getString(const char* s, DDView const& ev) {
42  DDValue val(s);
43  std::vector<const DDsvalues_type*> result;
44  ev.specificsV(result);
45  std::vector<const DDsvalues_type*>::iterator it = result.begin();
46  bool foundIt = false;
47  for (; it != result.end(); ++it) {
48  foundIt = DDfetch(*it, val);
49  if (foundIt)
50  break;
51  }
52  if (foundIt) {
53  const std::vector<std::string>& temp = val.strings();
54  if (temp.size() != 1) {
55  throw cms::Exception("Configuration") << "I need 1 " << s << " tags";
56  }
57  return temp[0];
58  }
59  return "NotFound";
60  }
61 } // namespace
62 
68 
70  : //
71  // Set by hand the ddd_
72  //
73  trans_(fv->translation()),
74  phi_(trans_.Phi()),
75  rho_(trans_.Rho()),
76  rot_(fv->rotation()),
77  shape_(cms::dd::name_from_value(cms::LegacySolidShapeMap, fv->shape())),
78  ddname_(fv->name()),
79  type_(type),
80  params_(fv->parameters()),
81  radLength_(getDouble("TrackerRadLength", *fv)),
82  xi_(getDouble("TrackerXi", *fv)),
83  pixROCRows_(getDouble("PixelROCRows", *fv)),
84  pixROCCols_(getDouble("PixelROCCols", *fv)),
85  pixROCx_(getDouble("PixelROC_X", *fv)),
86  pixROCy_(getDouble("PixelROC_Y", *fv)),
87  stereo_(getString("TrackerStereoDetectors", *fv) == strue),
88  siliconAPVNum_(getDouble("SiliconAPVNumber", *fv)) {
89  const DDFilteredView::nav_type& nt = fv->navPos();
90  ddd_ = nav_type(nt.begin(), nt.end());
91 }
92 
94  : trans_(fv->translation() / dd4hep::mm),
95  rot_(fv->rotation()),
96  shape_(fv->shape()),
97  ddname_(fv->name()),
98  type_(type),
99  params_(fv->parameters()),
100  radLength_(fv->get<double>("TrackerRadLength")),
101  xi_(fv->get<double>("TrackerXi")),
102  pixROCRows_(fv->get<double>("PixelROCRows")),
103  pixROCCols_(fv->get<double>("PixelROCCols")),
104  pixROCx_(fv->get<double>("PixelROC_X")),
105  pixROCy_(fv->get<double>("PixelROC_Y")),
106  stereo_(fv->get<std::string_view>("TrackerStereoDetectors") == strue),
107  siliconAPVNum_(fv->get<double>("SiliconAPVNumber")) {
108  phi_ = trans_.Phi();
109  rho_ = trans_.Rho();
110  for (size_t pit = 0; pit < params_.size(); pit++) {
111  params_[pit] = params_[pit] / dd4hep::mm;
112  }
113  //
114  // Not navPos(), as not properly working for DD4hep and not used
115  //
116  ddd_ = nav_type(fv->copyNos().size(), 0);
117 }
118 
119 // PGeometricTimingDet is persistent version... make it... then come back here and make the
120 // constructor.
122  : trans_(onePGD.x_, onePGD.y_, onePGD.z_),
123  phi_(onePGD.phi_), //_trans.Phi()),
124  rho_(onePGD.rho_), //_trans.Rho()),
125  rot_(onePGD.a11_,
126  onePGD.a12_,
127  onePGD.a13_,
128  onePGD.a21_,
129  onePGD.a22_,
130  onePGD.a23_,
131  onePGD.a31_,
132  onePGD.a32_,
133  onePGD.a33_),
134  shape_(cms::dd::name_from_value(cms::LegacySolidShapeMap, static_cast<LegacySolidShape>(onePGD.shape_))),
135  ddd_(),
136  ddname_(onePGD.name_), //, "fromdb");
137  type_(type),
138  params_(),
139  geographicalID_(onePGD.geographicalID_),
140  radLength_(onePGD.radLength_),
141  xi_(onePGD.xi_),
142  pixROCRows_(onePGD.pixROCRows_),
143  pixROCCols_(onePGD.pixROCCols_),
144  pixROCx_(onePGD.pixROCx_),
145  pixROCy_(onePGD.pixROCy_),
146  stereo_(onePGD.stereo_),
147  siliconAPVNum_(onePGD.siliconAPVNum_) {
148  if (onePGD.shape_ == 1 || onePGD.shape_ == 3) { //The parms vector is neede only in the case of box or trap shape
149  params_.reserve(11);
150  params_.emplace_back(onePGD.params_0);
151  params_.emplace_back(onePGD.params_1);
152  params_.emplace_back(onePGD.params_2);
153  params_.emplace_back(onePGD.params_3);
154  params_.emplace_back(onePGD.params_4);
155  params_.emplace_back(onePGD.params_5);
156  params_.emplace_back(onePGD.params_6);
157  params_.emplace_back(onePGD.params_7);
158  params_.emplace_back(onePGD.params_8);
159  params_.emplace_back(onePGD.params_9);
160  params_.emplace_back(onePGD.params_10);
161  }
162 
163  ddd_.reserve(onePGD.numnt_);
164  ddd_.emplace_back(onePGD.nt0_);
165  ddd_.emplace_back(onePGD.nt1_);
166  ddd_.emplace_back(onePGD.nt2_);
167  ddd_.emplace_back(onePGD.nt3_);
168  if (onePGD.numnt_ > 4) {
169  ddd_.emplace_back(onePGD.nt4_);
170  if (onePGD.numnt_ > 5) {
171  ddd_.emplace_back(onePGD.nt5_);
172  if (onePGD.numnt_ > 6) {
173  ddd_.emplace_back(onePGD.nt6_);
174  if (onePGD.numnt_ > 7) {
175  ddd_.emplace_back(onePGD.nt7_);
176  if (onePGD.numnt_ > 8) {
177  ddd_.emplace_back(onePGD.nt8_);
178  if (onePGD.numnt_ > 9) {
179  ddd_.emplace_back(onePGD.nt9_);
180  if (onePGD.numnt_ > 10) {
181  ddd_.emplace_back(onePGD.nt10_);
182  }
183  }
184  }
185  }
186  }
187  }
188  }
189 }
190 
192  //
193  // iterate on all the components ;)
194  //
196  deepComponents(temp);
197  return temp;
198 }
199 
201  if (isLeaf()) {
202  cont.emplace_back(this);
203  } else
204  std::for_each(
205  container_.begin(), container_.end(), [&](const GeometricTimingDet* iDet) { iDet->deepComponents(cont); });
206 }
207 
209  container_.reserve(container_.size() + cont.size());
210  std::copy(cont.begin(), cont.end(), back_inserter(container_));
211 }
212 
214  container_.reserve(container_.size() + cont.size());
215  std::copy(cont.begin(), cont.end(), back_inserter(container_));
216 }
217 
219 
220 namespace {
221  struct Deleter {
222  void operator()(GeometricTimingDet const* det) const { delete const_cast<GeometricTimingDet*>(det); }
223  };
224 } // namespace
225 
227  std::for_each(container_.begin(), container_.end(), Deleter());
228  container_.clear();
229 }
230 
235  return pos;
236 }
237 
239  Translation x, y, z;
240  rot_.GetComponents(x, y, z);
241  Rotation rotation(float(x.X()),
242  float(x.Y()),
243  float(x.Z()),
244  float(y.X()),
245  float(y.Y()),
246  float(y.Z()),
247  float(z.X()),
248  float(z.Y()),
249  float(z.Z()));
250  return rotation;
251 }
252 
253 std::unique_ptr<Bounds> GeometricTimingDet::bounds() const {
254  const std::vector<double>& par = params_;
255  TrackerShapeToBounds shapeToBounds;
256  return std::unique_ptr<Bounds>(shapeToBounds.buildBounds(shape_, par));
257 }
tuple cont
load Luminosity info ##
Definition: generateEDF.py:628
std::vector< int > nav_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
tuple result
Definition: mps_fire.py:311
std::vector< double > params_
tuple dd4hep
Definition: dd4hep_cff.py:3
std::unique_ptr< Bounds > bounds() const
ConstGeometricTimingDetContainer deepComponents() const
void addComponent(GeometricTimingDet *)
GeometricTimingDet(DDFilteredView *fv, GeometricTimingEnumType dd)
const std::array< const cms::dd::ValuePair< LegacySolidShape, cms::DDSolidShape >, 21 > LegacySolidShapeMap
int nt
Definition: AMPTWrapper.h:42
const std::vector< int > copyNos() const
The list of the volume copy numbers.
DDSolidShape
Definition: DDSolidShapes.h:6
Bounds * buildBounds(const cms::DDSolidShape &, const std::vector< double > &) const
enum GTDEnumType{unknown=100, MTD=0, BTL=1, BTLLayer=2, BTLTray=3, BTLModule=4, BTLSensor=5, BTLCrystal=6, ETL=7, ETLDisc=8, ETLRing=9, ETLModule=10, ETLSensor=11} GeometricTimingEnumType
cms::DDSolidShape shape_
DDExpandedView::nav_type nav_type
std::vector< GeometricTimingDet const * > ConstGeometricTimingDetContainer
constexpr NumType convertMmToCm(NumType millimeters)
Definition: GeantUnits.h:63
Mapping::value_type::name_type name_from_value(Mapping a, V value)
Definition: DDSolidShapes.h:62
#define get
std::vector< GeometricTimingDet * > GeometricTimingDetContainer
RotationMatrix const & rotation() const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > Translation
ConstGeometricTimingDetContainer container_
Rotation rotationBounds() const