CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackerGeometricDetExtraESModule.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 boost::shared_ptr<std::vector<GeometricDetExtra> >
34  boost::shared_ptr<std::vector<GeometricDetExtra> > gde (new std::vector<GeometricDetExtra>);
35  // get the GeometricDet 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 GeometricDet* 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 GeometricDet*> tc = tracker->components();
48  std::vector<const GeometricDet*>::const_iterator git = tc.begin();
49  std::vector<const GeometricDet*>::const_iterator egit = tc.end();
50  int count=0;
51  int lev = 1;
52  // CmsTrackerStringToEnum ctst
53  gde->reserve(tracker->deepComponents().size());
54  for (; git!= egit; ++git) { // one level below "tracker"
55  ev.goTo((*git)->navType());
56  putOne((*gde), *git, ev, lev);
57  std::vector<const GeometricDet*> inone = (*git)->components();
58  // std::cout << lev << " type " << (*git)->type() << " " << int((*git)->geographicalId()) << std::endl; // << " has " << inone.size() << " components." << std::endl;
59  if ( inone.size() == 0 ) ++count;
60  std::vector<const GeometricDet*>::const_iterator git2 = inone.begin();
61  std::vector<const GeometricDet*>::const_iterator egit2 = inone.end();
62  ++lev;
63  for (; git2 != egit2; ++git2) { // level 2
64  ev.goTo((*git2)->navType());
65  putOne((*gde), *git2, ev, lev);
66  std::vector<const GeometricDet*> intwo= (*git2)->components();
67  // std::cout << lev << "\ttype " << (*git2)->type() << " " << int((*git2)->geographicalId()) << std::endl; // << " has " << intwo.size() << " components." << std::endl;
68  if ( intwo.size() == 0 ) ++count;
69  std::vector<const GeometricDet*>::const_iterator git3 = intwo.begin();
70  std::vector<const GeometricDet*>::const_iterator egit3 = intwo.end();
71  ++lev;
72  for (; git3 != egit3; ++git3) { // level 3
73  ev.goTo((*git3)->navType());
74  putOne((*gde), *git3, ev, lev);
75  std::vector<const GeometricDet*> inthree= (*git3)->components();
76  //std::cout << lev << "\t\ttype " << (*git3)->type() << " " << int((*git3)->geographicalId()) << std::endl; // << " has " << inthree.size() << " components." << std::endl;
77  if ( inthree.size() == 0 ) ++count;
78  std::vector<const GeometricDet*>::const_iterator git4 = inthree.begin();
79  std::vector<const GeometricDet*>::const_iterator egit4 = inthree.end();
80  ++lev;
81  for (; git4 != egit4; ++git4) { //level 4
82  ev.goTo((*git4)->navType());
83  putOne((*gde), *git4, ev, lev);
84  std::vector<const GeometricDet*> infour= (*git4)->components();
85  // std::cout << lev << "\t\t\ttype " << (*git4)->type() << " " << int((*git4)->geographicalId()) << std::endl; // << " has " << infour.size() << " components." << std::endl;
86  if ( infour.size() == 0 ) ++count;
87  std::vector<const GeometricDet*>::const_iterator git5 = infour.begin();
88  std::vector<const GeometricDet*>::const_iterator egit5 = infour.end();
89  ++lev;
90  for (; git5 != egit5; ++git5) { // level 5
91  ev.goTo((*git5)->navType());
92  putOne((*gde), *git5, ev, lev);
93  std::vector<const GeometricDet*> infive= (*git5)->components();
94  // std::cout << lev << "\t\t\t\ttype " << (*git5)->type() << " " << int((*git5)->geographicalId()) << std::endl; // << " has " << infive.size() << " components." << std::endl;
95  if ( infive.size() == 0 ) ++count;
96  std::vector<const GeometricDet*>::const_iterator git6 = infive.begin();
97  std::vector<const GeometricDet*>::const_iterator egit6 = infive.end();
98  ++lev;
99  for (; git6 != egit6; ++git6) { //level 6
100  ev.goTo((*git6)->navType());
101  putOne((*gde), *git6, ev, lev);
102  std::vector<const GeometricDet*> insix= (*git6)->components();
103  // std::cout << lev << "\t\t\t\t\ttype " << (*git6)->type() << " " << int((*git6)->geographicalId()) << std::endl; // << " has " << insix.size() << " components." << std::endl;
104  if ( insix.size() == 0 ){
105  ++count;
106  } else {
107  edm::LogError("GeometricDetExtra") << "Hierarchy has exceeded hard-coded level 6 for Tracker " ;
108  }
109  } // level 6
110  --lev;
111  } // level 5
112  --lev;
113  } // level 4
114  --lev;
115  } //level 3
116  --lev;
117  } // level 2
118  --lev;
119  }
120  }else{
121  // if it is not from the DD, then just get the GDE from ES and match w/ GD.
123  iRecord.getRecord<PGeometricDetExtraRcd>().get(pgde);
124  std::map<uint32_t, const GeometricDet*> helperMap;
125  const GeometricDet* tracker = &(*gd);
126  helperMap[gd->geographicalID()] = tracker;
127  std::vector<const GeometricDet*> tc = tracker->components();
128  std::vector<const GeometricDet*>::const_iterator git = tc.begin();
129  std::vector<const GeometricDet*>::const_iterator egit = tc.end();
130  for (; git!= egit; ++git) { // one level below "tracker"
131  helperMap[(*git)->geographicalID()] = (*git);
132  std::vector<const GeometricDet*> inone = (*git)->components();
133  std::vector<const GeometricDet*>::const_iterator git2 = inone.begin();
134  std::vector<const GeometricDet*>::const_iterator egit2 = inone.end();
135  for (; git2 != egit2; ++git2) { // level 2
136  helperMap[(*git2)->geographicalID()] = (*git2);
137  std::vector<const GeometricDet*> intwo= (*git2)->components();
138  std::vector<const GeometricDet*>::const_iterator git3 = intwo.begin();
139  std::vector<const GeometricDet*>::const_iterator egit3 = intwo.end();
140  for (; git3 != egit3; ++git3) { // level 3
141  helperMap[(*git3)->geographicalID()] = (*git3);
142  std::vector<const GeometricDet*> inthree= (*git3)->components();
143  std::vector<const GeometricDet*>::const_iterator git4 = inthree.begin();
144  std::vector<const GeometricDet*>::const_iterator egit4 = inthree.end();
145  for (; git4 != egit4; ++git4) { //level 4
146  helperMap[(*git4)->geographicalID()] = (*git4);
147  std::vector<const GeometricDet*> infour= (*git4)->components();
148  std::vector<const GeometricDet*>::const_iterator git5 = infour.begin();
149  std::vector<const GeometricDet*>::const_iterator egit5 = infour.end();
150  for (; git5 != egit5; ++git5) { // level 5
151  helperMap[(*git5)->geographicalID()] = (*git5);
152  std::vector<const GeometricDet*> infive= (*git5)->components();
153  std::vector<const GeometricDet*>::const_iterator git6 = infive.begin();
154  std::vector<const GeometricDet*>::const_iterator egit6 = infive.end();
155  for (; git6 != egit6; ++git6) { //level 6
156  helperMap[(*git6)->geographicalID()] = (*git6);
157  if ( (*git6)->components().size() != 0 ){
158  edm::LogError("GeometricDetExtra") << "Hierarchy has exceeded hard-coded level of 6 for Tracker " ;
159  }
160  } // level 6
161  } // level 5
162  } // level 4
163  } //level 3
164  } // level 2
165  }
166 
167  const std::vector<PGeometricDetExtra::Item>& pgdes = pgde->pgdes_;
168  gde->reserve(pgdes.size());
169  std::vector<DDExpandedNode> evs; //EMPTY
170  std::string nm; //EMPTY
171  for (unsigned int i = 0; i < pgdes.size(); ++i) {
172  // 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 );
173  gde->push_back( GeometricDetExtra(helperMap[pgdes[i]._geographicalId], pgdes[i]._geographicalId, evs
174  , pgdes[i]._volume, pgdes[i]._density, pgdes[i]._weight, pgdes[i]._copy
175  , pgdes[i]._material, nm));
176  }
177  }
178  return boost::shared_ptr<std::vector<GeometricDetExtra> >(gde);
179 }
180 
181 void TrackerGeometricDetExtraESModule::putOne(std::vector<GeometricDetExtra> & gde, const GeometricDet* gd, const DDExpandedView& ev, int lev ) {
182  std::string matname = ((ev.logicalPart()).material()).name().fullname();
183  std::string lpname = ((ev.logicalPart()).name().fullname());
184  std::vector<DDExpandedNode> evs = GeometricDetExtra::GeoHistory(ev.geoHistory().begin(),ev.geoHistory().end());
185  gde.push_back(GeometricDetExtra( gd, gd->geographicalId(), evs,
186  ((ev.logicalPart()).solid()).volume(), ((ev.logicalPart()).material()).density(),
187  ((ev.logicalPart()).material()).density() * ( ((ev.logicalPart()).solid()).volume() / 1000.),
188  ev.copyno(), matname, lpname, true ));
189 }
190 
int i
Definition: DBlmapReader.cc:9
boost::shared_ptr< std::vector< GeometricDetExtra > > produce(const IdealGeometryRecord &)
void putOne(std::vector< GeometricDetExtra > &gde, const GeometricDet *gd, const DDExpandedView &ev, int lev)
nav_type const & navType() const
Definition: GeometricDet.h:138
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
std::vector< DDExpandedNode > GeoHistory
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
TrackerGeometricDetExtraESModule(const edm::ParameterSet &p)
void get(HolderT &iHolder) const
int copyno() const
Copy number associated with the current node.
DetId geographicalId() const
Definition: GeometricDet.h:199
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:56
ConstGeometricDetContainer deepComponents() const
GeometricDetContainer & components()
Definition: GeometricDet.h:163
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)