CMS 3D CMS Logo

GeometricDet.cc
Go to the documentation of this file.
6 
7 #include "CLHEP/Units/GlobalSystemOfUnits.h"
8 
9 #include <cfloat>
10 #include <vector>
11 #include <string>
12 
13 namespace {
14 
15  const std::string strue("true");
16 
17  template <typename DDView>
18  double getDouble(const char* s, DDView const& ev) {
19  DDValue val(s);
20  std::vector<const DDsvalues_type*> result;
21  ev.specificsV(result);
22  std::vector<const DDsvalues_type*>::iterator it = result.begin();
23  bool foundIt = false;
24  for (; it != result.end(); ++it) {
25  foundIt = DDfetch(*it, val);
26  if (foundIt)
27  break;
28  }
29  if (foundIt) {
30  const std::vector<std::string>& temp = val.strings();
31  if (temp.size() != 1) {
32  throw cms::Exception("Configuration") << "I need 1 " << s << " tags";
33  }
34  return double(::atof(temp[0].c_str()));
35  }
36  return 0;
37  }
38 
39  template <typename DDView>
40  std::string getString(const char* s, DDView const& ev) {
41  DDValue val(s);
42  std::vector<const DDsvalues_type*> result;
43  ev.specificsV(result);
44  std::vector<const DDsvalues_type*>::iterator it = result.begin();
45  bool foundIt = false;
46  for (; it != result.end(); ++it) {
47  foundIt = DDfetch(*it, val);
48  if (foundIt)
49  break;
50  }
51  if (foundIt) {
52  const std::vector<std::string>& temp = val.strings();
53  if (temp.size() != 1) {
54  throw cms::Exception("Configuration") << "I need 1 " << s << " tags";
55  }
56  return temp[0];
57  }
58  return "NotFound";
59  }
60 } // namespace
61 
67 
69  : //
70  // Set by hand the _ddd
71  //
72  _trans(fv->translation()),
73  _phi(_trans.Phi()),
74  _rho(_trans.Rho()),
75  _rot(fv->rotation()),
76  _shape(fv->shape()),
77  _ddname(fv->name()),
78  _type(type),
79  _params(fv->parameters()),
80  _radLength(getDouble("TrackerRadLength", *fv)),
81  _xi(getDouble("TrackerXi", *fv)),
82  _pixROCRows(getDouble("PixelROCRows", *fv)),
83  _pixROCCols(getDouble("PixelROCCols", *fv)),
84  _pixROCx(getDouble("PixelROC_X", *fv)),
85  _pixROCy(getDouble("PixelROC_Y", *fv)),
86  _stereo(getString("TrackerStereoDetectors", *fv) == strue),
87  _siliconAPVNum(getDouble("SiliconAPVNumber", *fv)) {
88  // workaround instead of this at initialization _ddd(fv->navPos().begin(),fv->navPos().end()),
89  const DDFilteredView::nav_type& nt = fv->navPos();
90  _ddd = nav_type(nt.begin(), nt.end());
91 }
92 
94  : _trans(fv->translation()),
95  _phi(_trans.Phi()),
96  _rho(_trans.Rho()),
97  _rot(fv->rotation()),
98  _shape(DDSolidShape(static_cast<int>(fv->shape()))),
99  _ddd(fv->navPos()),
100  _ddname(fv->name()),
101  _type(type),
102  _params(fv->parameters()),
103  _radLength(fv->get<double>("TrackerRadLength")),
104  _xi(fv->get<double>("TrackerXi")),
105  _pixROCRows(fv->get<double>("PixelROCRows")),
106  _pixROCCols(fv->get<double>("PixelROCCols")),
107  _pixROCx(fv->get<double>("PixelROC_X")),
108  _pixROCy(fv->get<double>("PixelROC_Y")),
109  _stereo(fv->get<std::string_view>("TrackerStereoDetectors") == strue),
110  _siliconAPVNum(fv->get<double>("SiliconAPVNumber")) {}
111 
112 // PGeometricDet is persistent version... make it... then come back here and make the
113 // constructor.
115  : _trans(onePGD._x, onePGD._y, onePGD._z),
116  _phi(onePGD._phi), //_trans.Phi()),
117  _rho(onePGD._rho), //_trans.Rho()),
118  _rot(onePGD._a11,
119  onePGD._a12,
120  onePGD._a13,
121  onePGD._a21,
122  onePGD._a22,
123  onePGD._a23,
124  onePGD._a31,
125  onePGD._a32,
126  onePGD._a33),
127  _shape(static_cast<DDSolidShape>(onePGD._shape)),
128  _ddd(),
129  _ddname(onePGD._name),
130  _type(type),
131  _params(),
132  _geographicalID(onePGD._geographicalID),
133  _radLength(onePGD._radLength),
134  _xi(onePGD._xi),
135  _pixROCRows(onePGD._pixROCRows),
136  _pixROCCols(onePGD._pixROCCols),
137  _pixROCx(onePGD._pixROCx),
138  _pixROCy(onePGD._pixROCy),
139  _stereo(onePGD._stereo),
140  _siliconAPVNum(onePGD._siliconAPVNum) {
141  if (onePGD._shape == 1 || onePGD._shape == 3) { //The parms vector is neede only in the case of box or trap shape
142  _params.reserve(11);
143  _params.emplace_back(onePGD._params0);
144  _params.emplace_back(onePGD._params1);
145  _params.emplace_back(onePGD._params2);
146  _params.emplace_back(onePGD._params3);
147  _params.emplace_back(onePGD._params4);
148  _params.emplace_back(onePGD._params5);
149  _params.emplace_back(onePGD._params6);
150  _params.emplace_back(onePGD._params7);
151  _params.emplace_back(onePGD._params8);
152  _params.emplace_back(onePGD._params9);
153  _params.emplace_back(onePGD._params10);
154  }
155 
156  _ddd.reserve(onePGD._numnt);
157  _ddd.emplace_back(onePGD._nt0);
158  _ddd.emplace_back(onePGD._nt1);
159  _ddd.emplace_back(onePGD._nt2);
160  _ddd.emplace_back(onePGD._nt3);
161  if (onePGD._numnt > 4) {
162  _ddd.emplace_back(onePGD._nt4);
163  if (onePGD._numnt > 5) {
164  _ddd.emplace_back(onePGD._nt5);
165  if (onePGD._numnt > 6) {
166  _ddd.emplace_back(onePGD._nt6);
167  if (onePGD._numnt > 7) {
168  _ddd.emplace_back(onePGD._nt7);
169  if (onePGD._numnt > 8) {
170  _ddd.emplace_back(onePGD._nt8);
171  if (onePGD._numnt > 9) {
172  _ddd.emplace_back(onePGD._nt9);
173  if (onePGD._numnt > 10) {
174  _ddd.emplace_back(onePGD._nt10);
175  }
176  }
177  }
178  }
179  }
180  }
181  }
182 }
183 
185  //
186  // iterate on all the components ;)
187  //
189  deepComponents(_temp);
190  return _temp;
191 }
192 
194  if (isLeaf())
195  cont.emplace_back(this);
196  else
197  std::for_each(_container.begin(), _container.end(), [&](const GeometricDet* iDet) { iDet->deepComponents(cont); });
198 }
199 
201  _container.reserve(_container.size() + cont.size());
202  std::copy(cont.begin(), cont.end(), back_inserter(_container));
203 }
204 
206  _container.reserve(_container.size() + cont.size());
207  std::copy(cont.begin(), cont.end(), back_inserter(_container));
208 }
209 
210 void GeometricDet::addComponent(GeometricDet* det) { _container.emplace_back(det); }
211 
212 namespace {
213  struct Deleter {
214  void operator()(GeometricDet const* det) const { delete const_cast<GeometricDet*>(det); }
215  };
216 } // namespace
217 
219  std::for_each(_container.begin(), _container.end(), Deleter());
220  _container.clear();
221 }
222 
224  Position _pos(float(_trans.x() / cm), float(_trans.y() / cm), float(_trans.z() / cm));
225  return _pos;
226 }
227 
229  Translation x, y, z;
230  _rot.GetComponents(x, y, z);
231  Rotation _rotation(float(x.X()),
232  float(x.Y()),
233  float(x.Z()),
234  float(y.X()),
235  float(y.Y()),
236  float(y.Z()),
237  float(z.X()),
238  float(z.Y()),
239  float(z.Z()));
240  return _rotation;
241 }
242 
243 std::unique_ptr<Bounds> GeometricDet::bounds() const {
244  const std::vector<double>& par = _params;
245  TrackerShapeToBounds shapeToBounds;
246  return std::unique_ptr<Bounds>(shapeToBounds.buildBounds(_shape, par));
247 }
PGeometricDet::Item::_params3
double _params3
Definition: PGeometricDet.h:25
TkRotation< float >
DDAxes::y
GeometricDet::positionBounds
Position positionBounds() const
Definition: GeometricDet.cc:223
PGeometricDet::Item::_params6
double _params6
Definition: PGeometricDet.h:25
DDSolidShape
DDSolidShape
Definition: DDSolidShapes.h:6
PGeometricDet::Item::_nt0
int _nt0
Definition: PGeometricDet.h:42
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
nt
int nt
Definition: AMPTWrapper.h:42
PGeometricDet::Item::_params4
double _params4
Definition: PGeometricDet.h:25
GeometricDet::~GeometricDet
~GeometricDet()
Definition: GeometricDet.cc:66
l1extraParticles_cfi._params
_params
Definition: l1extraParticles_cfi.py:29
DDFilteredView::navPos
nav_type navPos() const
return the stack of sibling numbers
Definition: DDFilteredView.cc:191
generateEDF.cont
cont
load Luminosity info ##
Definition: generateEDF.py:629
PGeometricDet::Item::_nt5
int _nt5
Definition: PGeometricDet.h:42
PGeometricDet::Item::_nt3
int _nt3
Definition: PGeometricDet.h:42
GeometricDet::_trans
Translation _trans
Definition: GeometricDet.h:189
DDAxes::x
cms::DDFilteredView
Definition: DDFilteredView.h:65
PGeometricDet::Item::_nt7
int _nt7
Definition: PGeometricDet.h:42
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
GeometricDet::rotationBounds
Rotation rotationBounds() const
Definition: GeometricDet.cc:228
GeometricDet::_rot
RotationMatrix _rot
Definition: GeometricDet.h:192
parameters
parameters
Definition: BeamSpot_PayloadInspector.cc:14
alignCSCRings.s
s
Definition: alignCSCRings.py:92
DDFilteredView.h
GeometricDet::deleteComponents
void deleteComponents()
Definition: GeometricDet.cc:218
DDAxes::z
GeometricDet
Definition: GeometricDet.h:30
PGeometricDet::Item::_nt1
int _nt1
Definition: PGeometricDet.h:42
DDfetch
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:79
DDFilteredView.h
VtxSmearedParameters_cfi.Phi
Phi
Definition: VtxSmearedParameters_cfi.py:112
Point3DBase< float, GlobalTag >
GeometricDet::GeometricEnumType
enum GeometricDet::GDEnumType GeometricEnumType
GeometricDet::_ddd
nav_type _ddd
Definition: GeometricDet.h:194
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PGeometricDet::Item
Definition: PGeometricDet.h:14
PGeometricDet::Item::_params8
double _params8
Definition: PGeometricDet.h:25
GeometricDet::nav_type
DDExpandedView::nav_type nav_type
Definition: GeometricDet.h:43
PGeometricDet::Item::_nt6
int _nt6
Definition: PGeometricDet.h:42
PGeometricDet::Item::_nt9
int _nt9
Definition: PGeometricDet.h:42
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
PGeometricDet::Item::_params9
double _params9
Definition: PGeometricDet.h:25
PGeometricDet::Item::_nt2
int _nt2
Definition: PGeometricDet.h:42
createfilelist.int
int
Definition: createfilelist.py:10
GeometricDet::addComponents
void addComponents(GeometricDetContainer const &cont)
Definition: GeometricDet.cc:200
PGeometricDet::Item::_numnt
int _numnt
Definition: PGeometricDet.h:41
PGeometricDet::Item::_params1
double _params1
Definition: PGeometricDet.h:25
PGeometricDet::Item::_nt8
int _nt8
Definition: PGeometricDet.h:42
GeometricDet::_params
std::vector< double > _params
Definition: GeometricDet.h:197
GeometricDet::GeometricDet
GeometricDet(DDFilteredView *fv, GeometricEnumType dd)
Definition: GeometricDet.cc:68
PGeometricDet::Item::_nt4
int _nt4
Definition: PGeometricDet.h:42
PGeometricDet::Item::_params7
double _params7
Definition: PGeometricDet.h:25
GeometricDet::deepComponents
ConstGeometricDetContainer deepComponents() const
Definition: GeometricDet.cc:184
GeometricDet.h
get
#define get
PGeometricDet::Item::_shape
int _shape
Definition: PGeometricDet.h:36
PGeometricDet::Item::_nt10
int _nt10
Definition: PGeometricDet.h:42
type
type
Definition: HCALResponse.h:21
heppy_batch.val
val
Definition: heppy_batch.py:351
std
Definition: JetResolutionObject.h:76
PGeometricDet::Item::_params5
double _params5
Definition: PGeometricDet.h:25
GeometricDet::bounds
std::unique_ptr< Bounds > bounds() const
Definition: GeometricDet.cc:243
GeometricDet::Translation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > Translation
Definition: GeometricDet.h:36
GeometricDet::ConstGeometricDetContainer
std::vector< GeometricDet const * > ConstGeometricDetContainer
Definition: GeometricDet.h:33
DDValue
Definition: DDValue.h:21
GeometricDet::_shape
DDSolidShape _shape
Definition: GeometricDet.h:193
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
Exception
Definition: hltDiff.cc:246
TrackerShapeToBounds.h
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
GeometricDet::isLeaf
bool isLeaf() const
Definition: GeometricDet.h:112
TrackerShapeToBounds::buildBounds
Bounds * buildBounds(const DDSolidShape &, const std::vector< double > &) const
Definition: TrackerShapeToBounds.cc:32
GeometricDet::_container
ConstGeometricDetContainer _container
Definition: GeometricDet.h:188
GeometricDet::GeometricDetContainer
std::vector< GeometricDet * > GeometricDetContainer
Definition: GeometricDet.h:34
PGeometricDet.h
DDFilteredView
Definition: DDFilteredView.h:20
mps_fire.result
result
Definition: mps_fire.py:303
TrackerShapeToBounds
Definition: TrackerShapeToBounds.h:11
PGeometricDet::Item::_params0
double _params0
Definition: PGeometricDet.h:25
DDFilteredView::nav_type
DDExpandedView::nav_type nav_type
Definition: DDFilteredView.h:22
PGeometricDet::Item::_params2
double _params2
Definition: PGeometricDet.h:25
PGeometricDet::Item::_params10
double _params10
Definition: PGeometricDet.h:25
GeometricDet::addComponent
void addComponent(GeometricDet *)
Definition: GeometricDet.cc:210