CMS 3D CMS Logo

MTDGeometricTimingDetExtraESModule.cc
Go to the documentation of this file.
10 #include "ExtractStringFromDDD.h"
12 
18 
19 
20 #include <memory>
21 
22 using namespace edm;
23 
25  : fromDDD_(p.getParameter<bool>("fromDDD"))
26 {
27  setWhatProduced(this);
28 }
29 
31 
32 std::unique_ptr<std::vector<GeometricTimingDetExtra> >
34  auto gde = std::make_unique<std::vector<GeometricTimingDetExtra> >();
35  // get the GeometricTimingDet which has a nav_type
37  iRecord.get ( gd );
38  if (fromDDD_) {
39  // traverse all components from the tracker down;
40  // read the DD if from DD
41  const GeometricTimingDet* tracker = &(*gd);
43  iRecord.get( cpv );
44  DDExpandedView ev(*cpv);
45  ev.goTo(tracker->navType());
46  putOne((*gde), tracker, ev, 0);
47  std::vector<const GeometricTimingDet*> tc = tracker->components();
48  int count=0;
49  int lev = 1;
50  // CmsMTDStringToEnum ctst
51  gde->reserve(tracker->deepComponents().size());
52  for( const auto* git : tc ) {
53  ev.goTo(git->navType());
54  putOne((*gde), git, ev, lev);
55  std::vector<const GeometricTimingDet*> inone = git->components();
56  if ( inone.empty() ) ++count;
57  ++lev;
58  for( const auto* git2 : inone ) {
59  ev.goTo(git2->navType());
60  putOne((*gde), git2, ev, lev);
61  std::vector<const GeometricTimingDet*> intwo= git2->components();
62  if ( intwo.empty() ) ++count;
63  ++lev;
64  for( const auto* git3 : intwo ) {
65  ev.goTo(git3->navType());
66  putOne((*gde), git3, ev, lev);
67  std::vector<const GeometricTimingDet*> inthree= git3->components();
68  if ( inthree.empty() ) ++count;
69  ++lev;
70  for( const auto* git4 : inthree ) {
71  ev.goTo(git4->navType());
72  putOne((*gde), git4, ev, lev);
73  std::vector<const GeometricTimingDet*> infour= git4->components();
74  if ( infour.empty() ) ++count;
75  ++lev;
76  for( const auto* git5 : infour ) {
77  ev.goTo(git5->navType());
78  putOne((*gde), git5, ev, lev);
79  std::vector<const GeometricTimingDet*> infive= git5->components();
80  if ( infive.empty() ) ++count;
81  ++lev;
82  for( const auto* git6 : infive ) {
83  ev.goTo(git6->navType());
84  putOne((*gde), git6, ev, lev);
85  std::vector<const GeometricTimingDet*> insix= git6->components();
86  if ( insix.empty() ){
87  ++count;
88  } else {
89  edm::LogError("GeometricTimingDetExtra") << "Hierarchy has exceeded hard-coded level 6 for Tracker " ;
90  }
91  } // level 6
92  --lev;
93  } // level 5
94  --lev;
95  } // level 4
96  --lev;
97  } //level 3
98  --lev;
99  } // level 2
100  --lev;
101  }
102  }else{
103  // if it is not from the DD, then just get the GDE from ES and match w/ GD.
105  iRecord.getRecord<PGeometricTimingDetExtraRcd>().get(pgde);
106  std::map<uint32_t, const GeometricTimingDet*> helperMap;
107  const GeometricTimingDet* tracker = &(*gd);
108  helperMap[gd->geographicalID()] = tracker;
109  std::vector<const GeometricTimingDet*> tc = tracker->components();
110  for( const auto* git : tc ) { // level 1
111  helperMap[git->geographicalID()] = git;
112  std::vector<const GeometricTimingDet*> inone = git->components();
113  for( const auto* git2 : inone ) { // level 2
114  helperMap[git2->geographicalID()] = git2;
115  std::vector<const GeometricTimingDet*> intwo= git2->components();
116  for( const auto* git3 : intwo ) { // level 3
117  helperMap[git3->geographicalID()] = git3;
118  std::vector<const GeometricTimingDet*> inthree= git3->components();
119  for( const auto* git4 : inthree ) { // level 4
120  helperMap[git4->geographicalID()] = git4;
121  std::vector<const GeometricTimingDet*> infour= git4->components();
122  for( const auto* git5 : infour ) { // level 5
123  helperMap[git5->geographicalID()] = git5;
124  std::vector<const GeometricTimingDet*> infive= git5->components();
125  for( const auto* git6 : infive ) { // level 6
126  helperMap[git6->geographicalID()] = git6;
127  if ( !git6->components().empty() ){
128  edm::LogError("GeometricTimingDetExtra") << "Hierarchy has exceeded hard-coded level of 6 for Tracker " ;
129  }
130  } // level 6
131  } // level 5
132  } // level 4
133  } //level 3
134  } // level 2
135  }
136 
137  const std::vector<PGeometricTimingDetExtra::Item>& pgdes = pgde->pgdes_;
138  gde->reserve(pgdes.size());
139  std::vector<DDExpandedNode> evs; //EMPTY
140  std::string nm; //EMPTY
141  for (const auto & pgde : pgdes) {
142  gde->emplace_back( GeometricTimingDetExtra(helperMap[pgde.geographicalId_], pgde.geographicalId_, evs
143  , pgde.volume_, pgde.density_, pgde.weight_, pgde.copy_
144  , pgde.material_, nm));
145  }
146  }
147  return gde;
148 }
149 
150 void MTDGeometricTimingDetExtraESModule::putOne(std::vector<GeometricTimingDetExtra> & gde, const GeometricTimingDet* gd, const DDExpandedView& ev, int lev ) {
151  std::string matname = ((ev.logicalPart()).material()).name().fullname();
152  std::string lpname = ((ev.logicalPart()).name().fullname());
153  std::vector<DDExpandedNode> evs = GeometricTimingDetExtra::GeoHistory(ev.geoHistory().begin(),ev.geoHistory().end());
154  gde.emplace_back(GeometricTimingDetExtra( gd, gd->geographicalId(), evs,
155  ((ev.logicalPart()).solid()).volume(), ((ev.logicalPart()).material()).density(),
156  ((ev.logicalPart()).material()).density() * ( ((ev.logicalPart()).solid()).volume() / 1000.),
157  ev.copyno(), matname, lpname, true ));
158 }
159 
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:124
void putOne(std::vector< GeometricTimingDetExtra > &gde, const GeometricTimingDet *gd, const DDExpandedView &ev, int lev)
std::unique_ptr< std::vector< GeometricTimingDetExtra > > produce(const IdealGeometryRecord &)
DetId geographicalId() const
bool ev
std::vector< DDExpandedNode > GeoHistory
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
ConstGeometricTimingDetContainer & components()
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
ConstGeometricTimingDetContainer deepComponents() const
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.
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)