CMS 3D CMS Logo

TrackerGeometricDetExtraESModule.cc
Go to the documentation of this file.
19 #include "ExtractStringFromDDD.h"
21 
22 #include <memory>
23 
25 public:
27 
28  std::unique_ptr<std::vector<GeometricDetExtra> > produce(const IdealGeometryRecord&);
29 
30  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
31 
32 private:
33  void putOne(std::vector<GeometricDetExtra>& gde, const GeometricDet* gd, const DDExpandedView& ev, int lev);
34 
39  const bool fromDDD_;
40  const bool fromDD4hep_;
41 };
42 
43 using namespace edm;
44 
46  : fromDDD_(p.getParameter<bool>("fromDDD")), fromDD4hep_(p.getParameter<bool>("fromDD4hep")) {
47  auto c = setWhatProduced(this);
49  if (fromDDD_) {
50  ddToken_ = c.consumes<DDCompactView>(edm::ESInputTag());
51  } else if (fromDD4hep_) {
53  } else {
55  }
56 }
57 
60  descDB.add<bool>("fromDDD", false);
61  descDB.add<bool>("fromDD4hep", false);
62  descriptions.add("trackerNumberingExtraGeometryDB", descDB);
63 
65  desc.add<bool>("fromDDD", true);
66  desc.add<bool>("fromDD4hep", false);
67  descriptions.add("trackerNumberingExtraGeometry", desc);
68 
70  descDD4hep.add<bool>("fromDDD", false);
71  descDD4hep.add<bool>("fromDD4hep", true);
72  descriptions.add("DD4hep_trackerNumberingExtraGeometry", descDD4hep);
73 }
74 
75 std::unique_ptr<std::vector<GeometricDetExtra> > TrackerGeometricDetExtraESModule::produce(
76  const IdealGeometryRecord& iRecord) {
77  auto gde = std::make_unique<std::vector<GeometricDetExtra> >();
78  // get the GeometricDet which has a nav_type
79  GeometricDet const& gd = iRecord.get(geometricDetToken_);
80  if (fromDDD_) {
81  // traverse all components from the tracker down;
82  // read the DD if from DD
83  const GeometricDet* tracker = &(gd);
85  DDExpandedView ev(*cpv);
86  ev.goTo(tracker->navType());
87  putOne((*gde), tracker, ev, 0);
88  std::vector<const GeometricDet*> tc = tracker->components();
89  std::vector<const GeometricDet*>::const_iterator git = tc.begin();
90  std::vector<const GeometricDet*>::const_iterator egit = tc.end();
91  int count = 0;
92  int lev = 1;
93  // CmsTrackerStringToEnum ctst
94  gde->reserve(tracker->deepComponents().size());
95  for (; git != egit; ++git) { // one level below "tracker"
96  ev.goTo((*git)->navType());
97  putOne((*gde), *git, ev, lev);
98  std::vector<const GeometricDet*> inone = (*git)->components();
99  // std::cout << lev << " type " << (*git)->type() << " " << int((*git)->geographicalId()) << std::endl; // << " has " << inone.size() << " components." << std::endl;
100  if (inone.empty())
101  ++count;
102  std::vector<const GeometricDet*>::const_iterator git2 = inone.begin();
103  std::vector<const GeometricDet*>::const_iterator egit2 = inone.end();
104  ++lev;
105  for (; git2 != egit2; ++git2) { // level 2
106  ev.goTo((*git2)->navType());
107  putOne((*gde), *git2, ev, lev);
108  std::vector<const GeometricDet*> intwo = (*git2)->components();
109  // std::cout << lev << "\ttype " << (*git2)->type() << " " << int((*git2)->geographicalId()) << std::endl; // << " has " << intwo.size() << " components." << std::endl;
110  if (intwo.empty())
111  ++count;
112  std::vector<const GeometricDet*>::const_iterator git3 = intwo.begin();
113  std::vector<const GeometricDet*>::const_iterator egit3 = intwo.end();
114  ++lev;
115  for (; git3 != egit3; ++git3) { // level 3
116  ev.goTo((*git3)->navType());
117  putOne((*gde), *git3, ev, lev);
118  std::vector<const GeometricDet*> inthree = (*git3)->components();
119  //std::cout << lev << "\t\ttype " << (*git3)->type() << " " << int((*git3)->geographicalId()) << std::endl; // << " has " << inthree.size() << " components." << std::endl;
120  if (inthree.empty())
121  ++count;
122  std::vector<const GeometricDet*>::const_iterator git4 = inthree.begin();
123  std::vector<const GeometricDet*>::const_iterator egit4 = inthree.end();
124  ++lev;
125  for (; git4 != egit4; ++git4) { //level 4
126  ev.goTo((*git4)->navType());
127  putOne((*gde), *git4, ev, lev);
128  std::vector<const GeometricDet*> infour = (*git4)->components();
129  // std::cout << lev << "\t\t\ttype " << (*git4)->type() << " " << int((*git4)->geographicalId()) << std::endl; // << " has " << infour.size() << " components." << std::endl;
130  if (infour.empty())
131  ++count;
132  std::vector<const GeometricDet*>::const_iterator git5 = infour.begin();
133  std::vector<const GeometricDet*>::const_iterator egit5 = infour.end();
134  ++lev;
135  for (; git5 != egit5; ++git5) { // level 5
136  ev.goTo((*git5)->navType());
137  putOne((*gde), *git5, ev, lev);
138  std::vector<const GeometricDet*> infive = (*git5)->components();
139  // std::cout << lev << "\t\t\t\ttype " << (*git5)->type() << " " << int((*git5)->geographicalId()) << std::endl; // << " has " << infive.size() << " components." << std::endl;
140  if (infive.empty())
141  ++count;
142  std::vector<const GeometricDet*>::const_iterator git6 = infive.begin();
143  std::vector<const GeometricDet*>::const_iterator egit6 = infive.end();
144  ++lev;
145  for (; git6 != egit6; ++git6) { //level 6
146  ev.goTo((*git6)->navType());
147  putOne((*gde), *git6, ev, lev);
148  std::vector<const GeometricDet*> insix = (*git6)->components();
149  // std::cout << lev << "\t\t\t\t\ttype " << (*git6)->type() << " " << int((*git6)->geographicalId()) << std::endl; // << " has " << insix.size() << " components." << std::endl;
150  if (insix.empty()) {
151  ++count;
152  } else {
153  edm::LogError("GeometricDetExtra") << "Hierarchy has exceeded hard-coded level 6 for Tracker ";
154  }
155  } // level 6
156  --lev;
157  } // level 5
158  --lev;
159  } // level 4
160  --lev;
161  } //level 3
162  --lev;
163  } // level 2
164  --lev;
165  }
166  } else if (fromDD4hep_) {
167  // FIXME:
168  // traverse all components from the tracker down;
169  // read the DD if from DD
170  const GeometricDet* tracker = &(gd);
172  edm::LogInfo("GeometricDetExtra") << " Top node is " << tracker << " " << tracker->name() << std::endl;
173  edm::LogInfo("GeometricDetExtra") << " radLength " << tracker->radLength() << "\n"
174  << " xi " << tracker->xi() << "\n"
175  << " PixelROCRows " << tracker->pixROCRows() << "\n"
176  << " PixROCCols " << tracker->pixROCCols() << "\n"
177  << " PixelROC_X " << tracker->pixROCx() << "\n"
178  << " PixelROC_Y " << tracker->pixROCy() << "\n"
179  << "TrackerStereoDetectors " << (tracker->stereo() ? "true" : "false") << "\n"
180  << "SiliconAPVNumber " << tracker->siliconAPVNum() << "\n";
181  } else {
182  // if it is not from the DD, then just get the GDE from ES and match w/ GD.
184  std::map<uint32_t, const GeometricDet*> helperMap;
185  const GeometricDet* tracker = &gd;
186  helperMap[gd.geographicalID()] = tracker;
187  std::vector<const GeometricDet*> tc = tracker->components();
188  std::vector<const GeometricDet*>::const_iterator git = tc.begin();
189  std::vector<const GeometricDet*>::const_iterator egit = tc.end();
190  for (; git != egit; ++git) { // one level below "tracker"
191  helperMap[(*git)->geographicalID()] = (*git);
192  std::vector<const GeometricDet*> inone = (*git)->components();
193  std::vector<const GeometricDet*>::const_iterator git2 = inone.begin();
194  std::vector<const GeometricDet*>::const_iterator egit2 = inone.end();
195  for (; git2 != egit2; ++git2) { // level 2
196  helperMap[(*git2)->geographicalID()] = (*git2);
197  std::vector<const GeometricDet*> intwo = (*git2)->components();
198  std::vector<const GeometricDet*>::const_iterator git3 = intwo.begin();
199  std::vector<const GeometricDet*>::const_iterator egit3 = intwo.end();
200  for (; git3 != egit3; ++git3) { // level 3
201  helperMap[(*git3)->geographicalID()] = (*git3);
202  std::vector<const GeometricDet*> inthree = (*git3)->components();
203  std::vector<const GeometricDet*>::const_iterator git4 = inthree.begin();
204  std::vector<const GeometricDet*>::const_iterator egit4 = inthree.end();
205  for (; git4 != egit4; ++git4) { //level 4
206  helperMap[(*git4)->geographicalID()] = (*git4);
207  std::vector<const GeometricDet*> infour = (*git4)->components();
208  std::vector<const GeometricDet*>::const_iterator git5 = infour.begin();
209  std::vector<const GeometricDet*>::const_iterator egit5 = infour.end();
210  for (; git5 != egit5; ++git5) { // level 5
211  helperMap[(*git5)->geographicalID()] = (*git5);
212  std::vector<const GeometricDet*> infive = (*git5)->components();
213  std::vector<const GeometricDet*>::const_iterator git6 = infive.begin();
214  std::vector<const GeometricDet*>::const_iterator egit6 = infive.end();
215  for (; git6 != egit6; ++git6) { //level 6
216  helperMap[(*git6)->geographicalID()] = (*git6);
217  if (!(*git6)->components().empty()) {
218  edm::LogError("GeometricDetExtra") << "Hierarchy has exceeded hard-coded level of 6 for Tracker ";
219  }
220  } // level 6
221  } // level 5
222  } // level 4
223  } //level 3
224  } // level 2
225  }
226 
227  const std::vector<PGeometricDetExtra::Item>& pgdes = pgde.pgdes_;
228  gde->reserve(pgdes.size());
229  std::vector<DDExpandedNode> evs; //EMPTY
230  std::string nm; //EMPTY
231  for (const auto& pgde : pgdes) {
232  // GeometricDetExtra( GeometricDet const *gd, DetId id, GeoHistory& gh, double vol, double dens, double wgt, double cpy, const std::string& mat, const std::string& name, bool dd=false );
233  gde->emplace_back(GeometricDetExtra(helperMap[pgde._geographicalId],
234  pgde._geographicalId,
235  evs,
236  pgde._volume,
237  pgde._density,
238  pgde._weight,
239  pgde._copy,
240  pgde._material,
241  nm));
242  }
243  }
244  return gde;
245 }
246 
247 void TrackerGeometricDetExtraESModule::putOne(std::vector<GeometricDetExtra>& gde,
248  const GeometricDet* gd,
249  const DDExpandedView& ev,
250  int lev) {
251  std::string matname = ((ev.logicalPart()).material()).name().fullname();
252  std::string lpname = ((ev.logicalPart()).name().fullname());
253  std::vector<DDExpandedNode> evs = GeometricDetExtra::GeoHistory(ev.geoHistory().begin(), ev.geoHistory().end());
254  gde.emplace_back(
256  gd->geographicalId(),
257  evs,
258  ((ev.logicalPart()).solid()).volume(),
259  ((ev.logicalPart()).material()).density(),
260  ((ev.logicalPart()).material()).density() * (((ev.logicalPart()).solid()).volume() / 1000.),
261  ev.copyno(),
262  matname,
263  lpname,
264  true));
265 }
266 
ConfigurationDescriptions.h
edm::eventsetup::DependentRecordImplementation::getRecord
const DepRecordT getRecord() const
Definition: DependentRecordImplementation.h:51
TrackerGeometricDetExtraESModule::pgToken_
edm::ESGetToken< PGeometricDetExtra, PGeometricDetExtraRcd > pgToken_
Definition: TrackerGeometricDetExtraESModule.cc:38
TrackerGeometricDetExtraESModule::fromDD4hep_
const bool fromDD4hep_
Definition: TrackerGeometricDetExtraESModule.cc:40
electrons_cff.bool
bool
Definition: electrons_cff.py:372
edm::ESInputTag
Definition: ESInputTag.h:87
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
TrackerGeometricDetExtraESModule::geometricDetToken_
edm::ESGetToken< GeometricDet, IdealGeometryRecord > geometricDetToken_
Definition: TrackerGeometricDetExtraESModule.cc:35
ESTransientHandle.h
TrackerGeometricDetExtraESModule::dd4hepToken_
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > dd4hepToken_
Definition: TrackerGeometricDetExtraESModule.cc:37
TrackerGeometricDetExtraESModule::putOne
void putOne(std::vector< GeometricDetExtra > &gde, const GeometricDet *gd, const DDExpandedView &ev, int lev)
Definition: TrackerGeometricDetExtraESModule.cc:247
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::LogInfo
Definition: MessageLogger.h:254
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:138
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
ESProducer.h
PGeometricDetExtraRcd
Definition: PGeometricDetExtraRcd.h:5
PGeometricDetExtra.h
TrackerGeometricDetExtraESModule::TrackerGeometricDetExtraESModule
TrackerGeometricDetExtraESModule(const edm::ParameterSet &p)
Definition: TrackerGeometricDetExtraESModule.cc:45
TrackerGeometricDetExtraESModule
Definition: TrackerGeometricDetExtraESModule.cc:24
DDCompactView.h
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
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
GeometricDet
Definition: GeometricDet.h:30
DDSolid.h
DDCompactView.h
DDExpandedView
Provides an exploded view of the detector (tree-view)
Definition: DDExpandedView.h:41
ParameterSetDescription.h
edm::eventsetup::DependentRecordImplementation::get
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:112
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PbPb_ZMuSkimMuonDPG_cff.tracker
tracker
Definition: PbPb_ZMuSkimMuonDPG_cff.py:60
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
KineDebug3::count
void count()
Definition: KinematicConstrainedVertexUpdatorT.h:21
TrackerGeometricDetExtraESModule::ddToken_
edm::ESGetToken< DDCompactView, IdealGeometryRecord > ddToken_
Definition: TrackerGeometricDetExtraESModule.cc:36
DDMaterial.h
TrackerGeometricDetExtraESModule::produce
std::unique_ptr< std::vector< GeometricDetExtra > > produce(const IdealGeometryRecord &)
Definition: TrackerGeometricDetExtraESModule.cc:75
GeometricDetExtra
Definition: GeometricDetExtra.h:17
TrackerGeometricDetExtraESModule::fromDDD_
const bool fromDDD_
Definition: TrackerGeometricDetExtraESModule.cc:39
IdealGeometryRecord.h
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
GeometricDet.h
get
#define get
TrackerGeometricDetExtraESModule::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: TrackerGeometricDetExtraESModule.cc:58
edm::ESGetToken< GeometricDet, IdealGeometryRecord >
GeometricDetExtra.h
edm::ESTransientHandle
Definition: ESTransientHandle.h:41
GeometricDetExtra::GeoHistory
std::vector< DDExpandedNode > GeoHistory
Definition: GeometricDetExtra.h:22
ModuleFactory.h
ExtractStringFromDDD.h
PGeometricDetExtra
Definition: PGeometricDetExtra.h:9
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
CondDBCmsTrackerConstruction.h
cms::DDCompactView
Definition: DDCompactView.h:29
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
PGeometricDet.h
edm::ESProducer
Definition: ESProducer.h:101
GeometricDet::geographicalId
DetId geographicalId() const
Definition: GeometricDet.h:154
ParameterSet.h
PGeometricDetExtraRcd.h
IdealGeometryRecord
Definition: IdealGeometryRecord.h:27
DDDCmsTrackerContruction.h
fastSimProducer_cff.density
density
Definition: fastSimProducer_cff.py:61
PGeometricDetExtra::pgdes_
std::vector< Item > pgdes_
Definition: PGeometricDetExtra.h:27