CMS 3D CMS Logo

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  //
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 }
GeometricTimingDet::addComponent
void addComponent(GeometricTimingDet *)
Definition: GeometricTimingDet.cc:218
TkRotation< float >
PGeometricTimingDet::Item::params_7
double params_7
Definition: PGeometricTimingDet.h:25
PGeometricTimingDet::Item
Definition: PGeometricTimingDet.h:14
DDAxes::y
BeamSpotPI::parameters
parameters
Definition: BeamSpotPayloadInspectorHelper.h:30
PGeometricTimingDet::Item::nt3_
int nt3_
Definition: PGeometricTimingDet.h:42
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:628
GeometricTimingDet::rot_
RotationMatrix rot_
Definition: GeometricTimingDet.h:172
GeometricTimingDet::ConstGeometricTimingDetContainer
std::vector< GeometricTimingDet const * > ConstGeometricTimingDetContainer
Definition: GeometricTimingDet.h:32
DDAxes::x
GeometricTimingDet::GeometricTimingEnumType
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
Definition: GeometricTimingDet.h:63
cms::DDFilteredView
Definition: DDFilteredView.h:70
GeometricTimingDet::bounds
std::unique_ptr< Bounds > bounds() const
Definition: GeometricTimingDet.cc:253
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
cms::dd::name_from_value
Mapping::value_type::name_type name_from_value(Mapping a, V value)
Definition: DDSolidShapes.h:62
PGeometricTimingDet::Item::params_8
double params_8
Definition: PGeometricTimingDet.h:25
GeometricTimingDet::isLeaf
bool isLeaf() const
Definition: GeometricTimingDet.h:90
GeometricTimingDet::rho_
double rho_
Definition: GeometricTimingDet.h:171
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
createTree.dd
string dd
Definition: createTree.py:154
GeometricTimingDet::positionBounds
Position positionBounds() const
Definition: GeometricTimingDet.cc:231
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
GeantUnits.h
type
type
Definition: SiPixelVCal_PayloadInspector.cc:39
GeometricTimingDet::ddd_
nav_type ddd_
Definition: GeometricTimingDet.h:174
GeometricTimingDet::shape_
cms::DDSolidShape shape_
Definition: GeometricTimingDet.h:173
PGeometricTimingDet::Item::nt7_
int nt7_
Definition: PGeometricTimingDet.h:42
PGeometricTimingDet::Item::params_1
double params_1
Definition: PGeometricTimingDet.h:25
GeometricTimingDet
Definition: GeometricTimingDet.h:29
GeometricTimingDet::GeometricTimingDetContainer
std::vector< GeometricTimingDet * > GeometricTimingDetContainer
Definition: GeometricTimingDet.h:33
get
#define get
GeometricTimingDet::container_
ConstGeometricTimingDetContainer container_
Definition: GeometricTimingDet.h:168
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
heppy_batch.val
val
Definition: heppy_batch.py:351
std
Definition: JetResolutionObject.h:76
GeometricTimingDet.h
DDValue
Definition: DDValue.h:22
PGeometricTimingDet::Item::params_4
double params_4
Definition: PGeometricTimingDet.h:25
dd4hep
Definition: DDPlugins.h:8
ev
bool ev
Definition: Hydjet2Hadronizer.cc:97
PGeometricTimingDet::Item::nt5_
int nt5_
Definition: PGeometricTimingDet.h:42
Exception
Definition: hltDiff.cc:245
PGeometricTimingDet::Item::numnt_
int numnt_
Definition: PGeometricTimingDet.h:41
TrackerShapeToBounds.h
GeometricTimingDet::Translation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > Translation
Definition: GeometricTimingDet.h:35
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
PGeometricTimingDet::Item::params_10
double params_10
Definition: PGeometricTimingDet.h:25
GeometricTimingDet::nav_type
std::vector< int > nav_type
Definition: GeometricTimingDet.h:40
GeometricTimingDet::rotationBounds
Rotation rotationBounds() const
Definition: GeometricTimingDet.cc:238
GeometricTimingDet::deleteComponents
void deleteComponents()
Definition: GeometricTimingDet.cc:226
GeometricTimingDet::rotation
RotationMatrix const & rotation() const
Definition: GeometricTimingDet.h:97
GeometricTimingDet::deepComponents
ConstGeometricTimingDetContainer deepComponents() const
Definition: GeometricTimingDet.cc:191
DDFilteredView
Definition: DDFilteredView.h:20
geant_units::operators::convertMmToCm
constexpr NumType convertMmToCm(NumType millimeters)
Definition: GeantUnits.h:63
GeometricTimingDet::addComponents
void addComponents(GeometricTimingDetContainer const &cont)
Definition: GeometricTimingDet.cc:208
mps_fire.result
result
Definition: mps_fire.py:311
TrackerShapeToBounds
Definition: TrackerShapeToBounds.h:11
cms::LegacySolidShapeMap
const std::array< const cms::dd::ValuePair< LegacySolidShape, cms::DDSolidShape >, 21 > LegacySolidShapeMap
Definition: DDSolidShapes.h:122
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
PGeometricTimingDet::Item::params_3
double params_3
Definition: PGeometricTimingDet.h:25
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
TrackerShapeToBounds::buildBounds
Bounds * buildBounds(const cms::DDSolidShape &, const std::vector< double > &) const
Definition: TrackerShapeToBounds.cc:32
PGeometricTimingDet::Item::nt0_
int nt0_
Definition: PGeometricTimingDet.h:42