CMS 3D CMS Logo

MTDGeometricTimingDetExtraESModule.cc
Go to the documentation of this file.
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 
electrons_cff.bool
bool
Definition: electrons_cff.py:372
edm::ESInputTag
Definition: ESInputTag.h:87
ESTransientHandle.h
ESHandle.h
MTDGeometricTimingDetExtraESModule::~MTDGeometricTimingDetExtraESModule
~MTDGeometricTimingDetExtraESModule() override
Definition: MTDGeometricTimingDetExtraESModule.cc:56
edm
HLT enums.
Definition: AlignableModifier.h:19
MTDGeometricTimingDetExtraESModule::produce
std::unique_ptr< std::vector< GeometricTimingDetExtra > > produce(const IdealGeometryRecord &)
Definition: MTDGeometricTimingDetExtraESModule.cc:58
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:138
ESProducer.h
PGeometricTimingDetExtraRcd
Definition: PGeometricTimingDetExtraRcd.h:5
DDCompactView.h
GeometricTimingDetExtra
Definition: GeometricTimingDetExtra.h:13
ExtractStringFromDD.h
cc
PGeometricTimingDet.h
MTDGeometricTimingDetExtraESModule
Definition: MTDGeometricTimingDetExtraESModule.cc:23
MTDGeometricTimingDetExtraESModule::compactViewToken_
edm::ESGetToken< DDCompactView, IdealGeometryRecord > compactViewToken_
Definition: MTDGeometricTimingDetExtraESModule.cc:37
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
edm::eventsetup::DependentRecordImplementation::getTransientHandle
ESTransientHandle< ProductT > getTransientHandle(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:99
DDCmsMTDConstruction.h
DDSolid.h
DDExpandedView
Provides an exploded view of the detector (tree-view)
Definition: DDExpandedView.h:41
edm::eventsetup::DependentRecordImplementation::get
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:112
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PbPb_ZMuSkimMuonDPG_cff.tracker
tracker
Definition: PbPb_ZMuSkimMuonDPG_cff.py:60
GeometricTimingDetExtra.h
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
PGeometricTimingDetExtra::pgdes_
std::vector< Item > pgdes_
Definition: PGeometricTimingDetExtra.h:27
GeometricTimingDetExtra::GeoHistory
std::vector< DDExpandedNode > GeoHistory
Definition: GeometricTimingDetExtra.h:18
KineDebug3::count
void count()
Definition: KinematicConstrainedVertexUpdatorT.h:21
CondDBCmsMTDConstruction.h
DDMaterial.h
GeometricTimingDet
Definition: GeometricTimingDet.h:28
IdealGeometryRecord.h
GeometricTimingDet::geographicalId
DetId geographicalId() const
Definition: GeometricTimingDet.h:135
edm::ESGetToken< GeometricTimingDet, IdealGeometryRecord >
PGeometricTimingDetExtra.h
PGeometricTimingDetExtra
Definition: PGeometricTimingDetExtra.h:9
ModuleFactory.h
MTDGeometricTimingDetExtraESModule::fromDDD_
const bool fromDDD_
Definition: MTDGeometricTimingDetExtraESModule.cc:39
GeometricTimingDet.h
MTDGeometricTimingDetExtraESModule::pTimingDetExtraToken_
edm::ESGetToken< PGeometricTimingDetExtra, PGeometricTimingDetExtraRcd > pTimingDetExtraToken_
Definition: MTDGeometricTimingDetExtraESModule.cc:38
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
MTDGeometricTimingDetExtraESModule::timingDetToken_
edm::ESGetToken< GeometricTimingDet, IdealGeometryRecord > timingDetToken_
Definition: MTDGeometricTimingDetExtraESModule.cc:36
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
PGeometricTimingDetExtraRcd.h
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
edm::ESProducer
Definition: ESProducer.h:101
ParameterSet.h
MTDGeometricTimingDetExtraESModule::MTDGeometricTimingDetExtraESModule
MTDGeometricTimingDetExtraESModule(const edm::ParameterSet &p)
Definition: MTDGeometricTimingDetExtraESModule.cc:44
IdealGeometryRecord
Definition: IdealGeometryRecord.h:27
fastSimProducer_cff.density
density
Definition: fastSimProducer_cff.py:61
MTDGeometricTimingDetExtraESModule::putOne
void putOne(std::vector< GeometricTimingDetExtra > &gde, const GeometricTimingDet *gd, const DDExpandedView &ev, int lev)
Definition: MTDGeometricTimingDetExtraESModule.cc:178