CMS 3D CMS Logo

MTDGeometricTimingDetExtraESModule.cc
Go to the documentation of this file.
9 #include "ExtractStringFromDDD.h"
11 
20 
21 #include <memory>
22 
24 public:
27  std::unique_ptr<std::vector<GeometricTimingDetExtra> > produce(const IdealGeometryRecord&);
28 
29 protected:
30 private:
31  void putOne(std::vector<GeometricTimingDetExtra>& gde,
32  const GeometricTimingDet* gd,
33  const DDExpandedView& ev,
34  int lev);
35 
39  const bool fromDDD_;
40 };
41 
42 using namespace edm;
43 
45  : fromDDD_(p.getParameter<bool>("fromDDD")) {
46  auto cc = setWhatProduced(this);
47  const edm::ESInputTag kEmptyTag;
48  timingDetToken_ = cc.consumes<GeometricTimingDet>(kEmptyTag);
49  if (fromDDD_) {
50  compactViewToken_ = cc.consumes<DDCompactView>(kEmptyTag);
51  } else {
53  }
54 }
55 
57 
58 std::unique_ptr<std::vector<GeometricTimingDetExtra> > MTDGeometricTimingDetExtraESModule::produce(
59  const IdealGeometryRecord& iRecord) {
60  auto gde = std::make_unique<std::vector<GeometricTimingDetExtra> >();
61  // get the GeometricTimingDet which has a nav_type
62  auto const& gd = iRecord.get(timingDetToken_);
63  if (fromDDD_) {
64  // traverse all components from the tracker down;
65  // read the DD if from DD
66  const GeometricTimingDet* tracker = &(gd);
67  auto cpv = iRecord.getTransientHandle(compactViewToken_);
68  DDExpandedView ev(*cpv);
69  ev.goTo(tracker->navType());
70  putOne((*gde), tracker, ev, 0);
71  int count = 0;
72  int lev = 1;
73  // CmsMTDStringToEnum ctst
74  gde->reserve(tracker->deepComponents().size());
75  for (const auto* git : tracker->components()) {
76  ev.goTo(git->navType());
77  putOne((*gde), git, ev, lev);
78  std::vector<const GeometricTimingDet*> const& inone = git->components();
79  if (inone.empty())
80  ++count;
81  ++lev;
82  for (const auto* git2 : inone) {
83  ev.goTo(git2->navType());
84  putOne((*gde), git2, ev, lev);
85  std::vector<const GeometricTimingDet*> const& intwo = git2->components();
86  if (intwo.empty())
87  ++count;
88  ++lev;
89  for (const auto* git3 : intwo) {
90  ev.goTo(git3->navType());
91  putOne((*gde), git3, ev, lev);
92  std::vector<const GeometricTimingDet*> const& inthree = git3->components();
93  if (inthree.empty())
94  ++count;
95  ++lev;
96  for (const auto* git4 : inthree) {
97  ev.goTo(git4->navType());
98  putOne((*gde), git4, ev, lev);
99  std::vector<const GeometricTimingDet*> const& infour = git4->components();
100  if (infour.empty())
101  ++count;
102  ++lev;
103  for (const auto* git5 : infour) {
104  ev.goTo(git5->navType());
105  putOne((*gde), git5, ev, lev);
106  std::vector<const GeometricTimingDet*> const& infive = git5->components();
107  if (infive.empty())
108  ++count;
109  ++lev;
110  for (const auto* git6 : infive) {
111  ev.goTo(git6->navType());
112  putOne((*gde), git6, ev, lev);
113  std::vector<const GeometricTimingDet*> const& insix = git6->components();
114  if (insix.empty()) {
115  ++count;
116  } else {
117  edm::LogError("GeometricTimingDetExtra") << "Hierarchy has exceeded hard-coded level 6 for Tracker ";
118  }
119  } // level 6
120  --lev;
121  } // level 5
122  --lev;
123  } // level 4
124  --lev;
125  } //level 3
126  --lev;
127  } // level 2
128  --lev;
129  }
130  } else {
131  // if it is not from the DD, then just get the GDE from ES and match w/ GD.
132  PGeometricTimingDetExtra const& pgde = iRecord.get(pTimingDetExtraToken_);
133  std::map<uint32_t, const GeometricTimingDet*> helperMap;
134  const GeometricTimingDet* tracker = &gd;
135  helperMap[gd.geographicalID()] = tracker;
136  for (const auto* git : tracker->components()) { // level 1
137  helperMap[git->geographicalID()] = git;
138  for (const auto* git2 : git->components()) { // level 2
139  helperMap[git2->geographicalID()] = git2;
140  for (const auto* git3 : git2->components()) { // level 3
141  helperMap[git3->geographicalID()] = git3;
142  for (const auto* git4 : git3->components()) { // level 4
143  helperMap[git4->geographicalID()] = git4;
144  for (const auto* git5 : git4->components()) { // level 5
145  helperMap[git5->geographicalID()] = git5;
146  for (const auto* git6 : git5->components()) { // level 6
147  helperMap[git6->geographicalID()] = git6;
148  if (!git6->components().empty()) {
149  edm::LogError("GeometricTimingDetExtra")
150  << "Hierarchy has exceeded hard-coded level of 6 for Tracker ";
151  }
152  } // level 6
153  } // level 5
154  } // level 4
155  } //level 3
156  } // level 2
157  }
158 
159  const std::vector<PGeometricTimingDetExtra::Item>& pgdes = pgde.pgdes_;
160  gde->reserve(pgdes.size());
161  std::vector<DDExpandedNode> evs; //EMPTY
162  std::string nm; //EMPTY
163  for (const auto& pgde : pgdes) {
164  gde->emplace_back(GeometricTimingDetExtra(helperMap[pgde.geographicalId_],
165  pgde.geographicalId_,
166  evs,
167  pgde.volume_,
168  pgde.density_,
169  pgde.weight_,
170  pgde.copy_,
171  pgde.material_,
172  nm));
173  }
174  }
175  return gde;
176 }
177 
178 void MTDGeometricTimingDetExtraESModule::putOne(std::vector<GeometricTimingDetExtra>& gde,
179  const GeometricTimingDet* gd,
180  const DDExpandedView& ev,
181  int lev) {
182  std::string matname = ((ev.logicalPart()).material()).name().name();
183  std::string lpname = ((ev.logicalPart()).name().name());
184  std::vector<DDExpandedNode> evs = GeometricTimingDetExtra::GeoHistory(ev.geoHistory().begin(), ev.geoHistory().end());
185  gde.emplace_back(GeometricTimingDetExtra(
186  gd,
187  gd->geographicalId(),
188  evs,
189  ((ev.logicalPart()).solid()).volume(),
190  ((ev.logicalPart()).material()).density(),
191  ((ev.logicalPart()).material()).density() * (((ev.logicalPart()).solid()).volume() / 1000.),
192  ev.copyno(),
193  matname,
194  lpname,
195  true));
196 }
197 
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:138
void putOne(std::vector< GeometricTimingDetExtra > &gde, const GeometricTimingDet *gd, const DDExpandedView &ev, int lev)
std::unique_ptr< std::vector< GeometricTimingDetExtra > > produce(const IdealGeometryRecord &)
edm::ESGetToken< GeometricTimingDet, IdealGeometryRecord > timingDetToken_
DetId geographicalId() const
ESTransientHandle< ProductT > getTransientHandle(ESGetToken< ProductT, DepRecordT > const &iToken) const
bool ev
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
edm::ESGetToken< DDCompactView, IdealGeometryRecord > compactViewToken_
ConstGeometricTimingDetContainer & components()
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
ConstGeometricTimingDetContainer deepComponents() const
edm::ESGetToken< PGeometricTimingDetExtra, PGeometricTimingDetExtraRcd > pTimingDetExtraToken_
nav_type const & navType() const
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
int copyno() const
Copy number associated with the current node.
std::vector< DDExpandedNode > GeoHistory
MTDGeometricTimingDetExtraESModule(const edm::ParameterSet &p)
HLT enums.
bool goTo(const nav_type &)
transversed the DDExpandedView according to the given stack of sibling numbers
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the expanded-view.
Provides an exploded view of the detector (tree-view)