CMS 3D CMS Logo

GeometricTimingDet.cc
Go to the documentation of this file.
6 
7 #include "CLHEP/Units/GlobalSystemOfUnits.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_(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 
93 using namespace geant_units::operators;
94 
96  : trans_(fv->translation()),
97  rot_(fv->rotation()),
98  shape_(DDSolidShape(static_cast<int>(fv->shape()))),
99  ddname_(fv->name()),
100  type_(type),
101  params_(fv->parameters()),
102  radLength_(fv->get<double>("TrackerRadLength")),
103  xi_(fv->get<double>("TrackerXi")),
104  pixROCRows_(fv->get<double>("PixelROCRows")),
105  pixROCCols_(fv->get<double>("PixelROCCols")),
106  pixROCx_(fv->get<double>("PixelROC_X")),
107  pixROCy_(fv->get<double>("PixelROC_Y")),
108  stereo_(fv->get<std::string_view>("TrackerStereoDetectors") == strue),
109  siliconAPVNum_(fv->get<double>("SiliconAPVNumber")) {
110  //
111  // Translate DD4hep lenghts from cm to mm
112  //
113  trans_.SetCoordinates(convertCmToMm(trans_.X()), convertCmToMm(trans_.Y()), convertCmToMm(trans_.Z()));
114  phi_ = trans_.Phi();
115  rho_ = trans_.Rho();
116  for (size_t pit = 0; pit < params_.size(); pit++) {
117  params_[pit] = convertCmToMm(params_[pit]);
118  }
119  //
120  // Not navPos(), as not properly working for DD4hep and not used
121  //
122  ddd_ = nav_type(fv->copyNos().size(), 0);
123 }
124 
125 // PGeometricTimingDet is persistent version... make it... then come back here and make the
126 // constructor.
128  : trans_(onePGD.x_, onePGD.y_, onePGD.z_),
129  phi_(onePGD.phi_), //_trans.Phi()),
130  rho_(onePGD.rho_), //_trans.Rho()),
131  rot_(onePGD.a11_,
132  onePGD.a12_,
133  onePGD.a13_,
134  onePGD.a21_,
135  onePGD.a22_,
136  onePGD.a23_,
137  onePGD.a31_,
138  onePGD.a32_,
139  onePGD.a33_),
140  shape_(static_cast<DDSolidShape>(onePGD.shape_)),
141  ddd_(),
142  ddname_(onePGD.name_), //, "fromdb");
143  type_(type),
144  params_(),
145  geographicalID_(onePGD.geographicalID_),
146  radLength_(onePGD.radLength_),
147  xi_(onePGD.xi_),
148  pixROCRows_(onePGD.pixROCRows_),
149  pixROCCols_(onePGD.pixROCCols_),
150  pixROCx_(onePGD.pixROCx_),
151  pixROCy_(onePGD.pixROCy_),
152  stereo_(onePGD.stereo_),
153  siliconAPVNum_(onePGD.siliconAPVNum_) {
154  if (onePGD.shape_ == 1 || onePGD.shape_ == 3) { //The parms vector is neede only in the case of box or trap shape
155  params_.reserve(11);
156  params_.emplace_back(onePGD.params_0);
157  params_.emplace_back(onePGD.params_1);
158  params_.emplace_back(onePGD.params_2);
159  params_.emplace_back(onePGD.params_3);
160  params_.emplace_back(onePGD.params_4);
161  params_.emplace_back(onePGD.params_5);
162  params_.emplace_back(onePGD.params_6);
163  params_.emplace_back(onePGD.params_7);
164  params_.emplace_back(onePGD.params_8);
165  params_.emplace_back(onePGD.params_9);
166  params_.emplace_back(onePGD.params_10);
167  }
168 
169  ddd_.reserve(onePGD.numnt_);
170  ddd_.emplace_back(onePGD.nt0_);
171  ddd_.emplace_back(onePGD.nt1_);
172  ddd_.emplace_back(onePGD.nt2_);
173  ddd_.emplace_back(onePGD.nt3_);
174  if (onePGD.numnt_ > 4) {
175  ddd_.emplace_back(onePGD.nt4_);
176  if (onePGD.numnt_ > 5) {
177  ddd_.emplace_back(onePGD.nt5_);
178  if (onePGD.numnt_ > 6) {
179  ddd_.emplace_back(onePGD.nt6_);
180  if (onePGD.numnt_ > 7) {
181  ddd_.emplace_back(onePGD.nt7_);
182  if (onePGD.numnt_ > 8) {
183  ddd_.emplace_back(onePGD.nt8_);
184  if (onePGD.numnt_ > 9) {
185  ddd_.emplace_back(onePGD.nt9_);
186  if (onePGD.numnt_ > 10) {
187  ddd_.emplace_back(onePGD.nt10_);
188  }
189  }
190  }
191  }
192  }
193  }
194  }
195 }
196 
198  //
199  // iterate on all the components ;)
200  //
203  return temp;
204 }
205 
207  if (isLeaf()) {
208  cont.emplace_back(this);
209  } else
210  std::for_each(
211  container_.begin(), container_.end(), [&](const GeometricTimingDet* iDet) { iDet->deepComponents(cont); });
212 }
213 
215  container_.reserve(container_.size() + cont.size());
216  std::copy(cont.begin(), cont.end(), back_inserter(container_));
217 }
218 
220  container_.reserve(container_.size() + cont.size());
221  std::copy(cont.begin(), cont.end(), back_inserter(container_));
222 }
223 
225 
226 namespace {
227  struct Deleter {
228  void operator()(GeometricTimingDet const* det) const { delete const_cast<GeometricTimingDet*>(det); }
229  };
230 } // namespace
231 
233  std::for_each(container_.begin(), container_.end(), Deleter());
234  container_.clear();
235 }
236 
238  Position pos(float(trans_.x() / cm), float(trans_.y() / cm), float(trans_.z() / cm));
239  return pos;
240 }
241 
243  Translation x, y, z;
244  rot_.GetComponents(x, y, z);
245  Rotation rotation(float(x.X()),
246  float(x.Y()),
247  float(x.Z()),
248  float(y.X()),
249  float(y.Y()),
250  float(y.Z()),
251  float(z.X()),
252  float(z.Y()),
253  float(z.Z()));
254  return rotation;
255 }
256 
257 std::unique_ptr<Bounds> GeometricTimingDet::bounds() const {
258  const std::vector<double>& par = params_;
259  TrackerShapeToBounds shapeToBounds;
260  return std::unique_ptr<Bounds>(shapeToBounds.buildBounds(shape_, par));
261 }
GeometricTimingDet::addComponent
void addComponent(GeometricTimingDet *)
Definition: GeometricTimingDet.cc:224
TkRotation< float >
PGeometricTimingDet::Item::params_7
double params_7
Definition: PGeometricTimingDet.h:25
PGeometricTimingDet::Item
Definition: PGeometricTimingDet.h:14
DDAxes::y
PGeometricTimingDet::Item::nt3_
int nt3_
Definition: PGeometricTimingDet.h:42
GeometricTimingDet::shape_
DDSolidShape shape_
Definition: GeometricTimingDet.h:173
DDSolidShape
DDSolidShape
Definition: DDSolidShapes.h:6
PGeometricTimingDet::Item::nt4_
int nt4_
Definition: PGeometricTimingDet.h:42
PGeometricTimingDet::Item::params_6
double params_6
Definition: PGeometricTimingDet.h:25
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
nt
int nt
Definition: AMPTWrapper.h:42
PGeometricTimingDet::Item::shape_
int shape_
Definition: PGeometricTimingDet.h:36
PGeometricTimingDet::Item::nt6_
int nt6_
Definition: PGeometricTimingDet.h:42
PGeometricTimingDet::Item::nt1_
int nt1_
Definition: PGeometricTimingDet.h:42
pos
Definition: PixelAliasList.h:18
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
GeometricTimingDet::rot_
RotationMatrix rot_
Definition: GeometricTimingDet.h:172
GeometricTimingDet::ConstGeometricTimingDetContainer
std::vector< GeometricTimingDet const * > ConstGeometricTimingDetContainer
Definition: GeometricTimingDet.h:31
DDAxes::x
geant_units::operators
Definition: GeantUnits.h:18
cms::DDFilteredView
Definition: DDFilteredView.h:65
GeometricTimingDet::bounds
std::unique_ptr< Bounds > bounds() const
Definition: GeometricTimingDet.cc:257
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
PGeometricTimingDet::Item::params_8
double params_8
Definition: PGeometricTimingDet.h:25
GeometricTimingDet::isLeaf
bool isLeaf() const
Definition: GeometricTimingDet.h:91
GeometricTimingDet::rho_
double rho_
Definition: GeometricTimingDet.h:171
parameters
parameters
Definition: BeamSpot_PayloadInspector.cc:14
PGeometricTimingDet::Item::nt10_
int nt10_
Definition: PGeometricTimingDet.h:42
PGeometricTimingDet::Item::params_9
double params_9
Definition: PGeometricTimingDet.h:25
PGeometricTimingDet::Item::params_0
double params_0
Definition: PGeometricTimingDet.h:25
alignCSCRings.s
s
Definition: alignCSCRings.py:92
DDFilteredView.h
PGeometricTimingDet::Item::params_5
double params_5
Definition: PGeometricTimingDet.h:25
GeometricTimingDet::~GeometricTimingDet
~GeometricTimingDet()
Definition: GeometricTimingDet.cc:67
PGeometricTimingDet.h
PGeometricTimingDet::Item::nt9_
int nt9_
Definition: PGeometricTimingDet.h:42
cms::DDFilteredView::copyNos
const std::vector< int > copyNos() const
The list of the volume copy numbers.
Definition: DDFilteredView.cc:89
DDAxes::z
GeometricTimingDet::trans_
Translation trans_
Definition: GeometricTimingDet.h:169
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
GeometricTimingDet::phi_
double phi_
Definition: GeometricTimingDet.h:170
Point3DBase< float, GlobalTag >
GeometricTimingDet::params_
std::vector< double > params_
Definition: GeometricTimingDet.h:177
GeometricTimingDet::positionBounds
Position positionBounds() const
Definition: GeometricTimingDet.cc:237
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PGeometricTimingDet::Item::nt2_
int nt2_
Definition: PGeometricTimingDet.h:42
PGeometricTimingDet::Item::nt8_
int nt8_
Definition: PGeometricTimingDet.h:42
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
geant_units::operators::convertCmToMm
constexpr NumType convertCmToMm(NumType centimeters)
Definition: GeantUnits.h:68
GeometricTimingDet::nav_type
DDExpandedView::nav_type nav_type
Definition: GeometricTimingDet.h:41
GeantUnits.h
GeometricTimingDet::ddd_
nav_type ddd_
Definition: GeometricTimingDet.h:174
createfilelist.int
int
Definition: createfilelist.py:10
PGeometricTimingDet::Item::nt7_
int nt7_
Definition: PGeometricTimingDet.h:42
PGeometricTimingDet::Item::params_1
double params_1
Definition: PGeometricTimingDet.h:25
GeometricTimingDet
Definition: GeometricTimingDet.h:28
GeometricTimingDet::GeometricTimingDetContainer
std::vector< GeometricTimingDet * > GeometricTimingDetContainer
Definition: GeometricTimingDet.h:32
get
#define get
GeometricTimingDet::container_
ConstGeometricTimingDetContainer container_
Definition: GeometricTimingDet.h:168
type
type
Definition: HCALResponse.h:21
heppy_batch.val
val
Definition: heppy_batch.py:351
std
Definition: JetResolutionObject.h:76
GeometricTimingDet.h
DDValue
Definition: DDValue.h:21
PGeometricTimingDet::Item::params_4
double params_4
Definition: PGeometricTimingDet.h:25
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
PGeometricTimingDet::Item::nt5_
int nt5_
Definition: PGeometricTimingDet.h:42
Exception
Definition: hltDiff.cc:246
PGeometricTimingDet::Item::numnt_
int numnt_
Definition: PGeometricTimingDet.h:41
TrackerShapeToBounds.h
GeometricTimingDet::Translation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > Translation
Definition: GeometricTimingDet.h:34
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
PGeometricTimingDet::Item::params_10
double params_10
Definition: PGeometricTimingDet.h:25
GeometricTimingDet::rotationBounds
Rotation rotationBounds() const
Definition: GeometricTimingDet.cc:242
GeometricTimingDet::deleteComponents
void deleteComponents()
Definition: GeometricTimingDet.cc:232
TrackerShapeToBounds::buildBounds
Bounds * buildBounds(const DDSolidShape &, const std::vector< double > &) const
Definition: TrackerShapeToBounds.cc:32
GeometricTimingDet::rotation
RotationMatrix const & rotation() const
Definition: GeometricTimingDet.h:98
GeometricTimingDet::deepComponents
ConstGeometricTimingDetContainer deepComponents() const
Definition: GeometricTimingDet.cc:197
DDFilteredView
Definition: DDFilteredView.h:20
GeometricTimingDet::addComponents
void addComponents(GeometricTimingDetContainer const &cont)
Definition: GeometricTimingDet.cc:214
mps_fire.result
result
Definition: mps_fire.py:303
TrackerShapeToBounds
Definition: TrackerShapeToBounds.h:11
GeometricTimingDet::GeometricTimingDet
GeometricTimingDet(DDFilteredView *fv, GeometricTimingEnumType dd)
Definition: GeometricTimingDet.cc:69
DDFilteredView::nav_type
DDExpandedView::nav_type nav_type
Definition: DDFilteredView.h:22
PGeometricTimingDet::Item::params_2
double params_2
Definition: PGeometricTimingDet.h:25
GeometricTimingDet::GeometricTimingEnumType
enum GeometricTimingDet::GTDEnumType GeometricTimingEnumType
PGeometricTimingDet::Item::params_3
double params_3
Definition: PGeometricTimingDet.h:25
PGeometricTimingDet::Item::nt0_
int nt0_
Definition: PGeometricTimingDet.h:42