CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ListIds.cc
Go to the documentation of this file.
1 #include <string>
2 #include <vector>
3 #include <iostream>
4 
14 
26 
27 static
29  DDValue parameter(name);
30  std::vector<const DDsvalues_type *> result;
31  view.specificsV(result);
32  for (std::vector<const DDsvalues_type *>::iterator it = result.begin(); it != result.end(); ++it) {
33  if (DDfetch(*it,parameter)) {
34  if (parameter.strings().size() == 1) {
35  value = parameter.strings().front();
36  return true;
37  } else {
38  return false;
39  }
40  }
41  }
42  return false;
43 }
44 
45 static inline
46 double dddGetDouble(const std::string & s, const DDFilteredView & view) {
48  if (dddGetStringRaw(view, s, value))
49  return double(::atof(value.c_str()));
50  else
51  return NAN;
52 }
53 
54 static inline
57  if (dddGetStringRaw(view, s, value))
58  return value;
59  else
60  return std::string();
61 }
62 
63 static inline
64 std::ostream & operator<<(std::ostream & out, const math::XYZVector & v) {
65  return out << "(" << v.rho() << ", " << v.z() << ", " << v.phi() << ")";
66 }
67 
68 class ListIds : public edm::EDAnalyzer
69 {
70 public:
71  ListIds(const edm::ParameterSet &);
72  virtual ~ListIds();
73 
74 private:
75  void analyze(const edm::Event &, const edm::EventSetup &);
76 
79 };
80 
82 }
83 
85 }
86 
87 void
89  if (m_idealGeometryWatcher.check(setup)) {
90  std::cout << "______________________________ DDD ______________________________" << std::endl;
92  setup.get<IdealGeometryRecord>().get(hDdd);
93 
94  std::string attribute = "TkDDDStructure";
95  CmsTrackerStringToEnum theCmsTrackerStringToEnum;
97  filter.setCriteria(DDValue(attribute, "any", 0), DDSpecificsFilter::not_equals);
98  DDFilteredView fv(*hDdd);
99  fv.addFilter(filter);
100  if (theCmsTrackerStringToEnum.type(dddGetString(attribute, fv)) != GeometricDet::Tracker) {
101  fv.firstChild();
102  if (theCmsTrackerStringToEnum.type(dddGetString(attribute, fv)) != GeometricDet::Tracker)
103  throw cms::Exception("Configuration") << "The first child of the DDFilteredView is not what is expected \n"
104  << dddGetString(attribute, fv);
105  }
106 
107  std::cout << std::fixed << std::setprecision(3);
108  do {
109  // print the full hierarchy of all Silicon items
110  if (fv.logicalPart().material().name() == "materials:Silicon") {
111 
112  // start from 2 to skip the leading /OCMS[0]/CMSE[1] part
113  const DDGeoHistory & history = fv.geoHistory();
114  std::cout << '/';
115  for (unsigned int h = 2; h < history.size(); ++h) {
116  std::cout << '/' << history[h].logicalPart().name().name() << '[' << history[h].copyno() << ']';
117  }
118 
119  // DD3Vector and DDTranslation are the same type as math::XYZVector
120  math::XYZVector position = fv.translation() / 10.; // mm -> cm
121  std::cout << "\t" << position << std::endl;
122  }
123  } while (fv.next());
124  std::cout << std::endl;
125  }
126 
127  if (m_trackerGeometryWatcher.check(setup)) {
128  std::cout << "______________________________ std::vector<GeomDet*> from TrackerGeometry::dets() ______________________________" << std::endl;
130  setup.get<TrackerDigiGeometryRecord>().get( hGeo );
131 
132  std::cout << std::fixed << std::setprecision(3);
133  const std::vector<GeomDet*> & dets = hGeo->dets();
134  for (unsigned int i = 0; i < dets.size(); ++i) {
135  const GeomDet & det = *dets[i];
136 
137  // Surface::PositionType is a typedef for Point3DBase<float,GlobalTag> a.k.a. GlobalPoint
138  const Surface::PositionType & p = det.position();
139  math::XYZVector position(p.x(), p.y(), p.z());
140 
141  std::cout << det.subDetector() << '\t'
142  << det.geographicalId().det() << '\t'
143  << det.geographicalId().subdetId() << '\t'
144  << det.geographicalId().rawId() << "\t"
145  << position;
146  const std::vector<const GeomDet*> & parts = det.components();
147  if (parts.size()) {
148  std::cout << "\t[" << parts[0]->geographicalId().rawId();
149  for (unsigned int j = 1; j < parts.size(); ++j)
150  std::cout << '\t' << parts[j]->geographicalId().rawId();
151  std::cout << ']';
152  }
153  std::cout << std::endl;
154  }
155  }
156 
157 }
158 
159 //-------------------------------------------------------------------------
160 // define as a plugin
int i
Definition: DBlmapReader.cc:9
void analyze(const edm::Event &, const edm::EventSetup &)
Definition: ListIds.cc:88
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
static bool dddGetStringRaw(const DDFilteredView &view, const std::string &name, std::string &value)
Definition: ListIds.cc:28
void addFilter(const DDFilter &, log_op op=AND)
const N & name() const
Definition: DDBase.h:82
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
T y() const
Definition: PV3DBase.h:63
virtual SubDetector subDetector() const =0
Which subdetector.
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:102
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:41
bool next()
set current node to the next node in the filtered tree
virtual ~ListIds()
Definition: ListIds.cc:84
static double dddGetDouble(const std::string &s, const DDFilteredView &view)
Definition: ListIds.cc:46
T z() const
Definition: PV3DBase.h:64
tuple result
Definition: query.py:137
int j
Definition: DBlmapReader.cc:9
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:72
static std::string dddGetString(const std::string &s, const DDFilteredView &view)
Definition: ListIds.cc:55
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
virtual std::vector< const GeomDet * > components() const =0
Returns direct components, if any.
const std::vector< std::string > & strings() const
a reference to the std::string-valued values stored in the given instance of DDValue ...
Definition: DDValue.h:71
std::vector< DDExpandedNode > DDGeoHistory
Geometrical &#39;path&#39; of the current node up to the root-node.
tuple out
Definition: dbtoconf.py:99
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
const T & get() const
Definition: EventSetup.h:55
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:59
bool firstChild()
set the current node to the first child ...
void setCriteria(const DDValue &nameVal, comp_op, log_op l=AND, bool asString=true, bool merged=true)
Definition: DDFilter.cc:285
void specificsV(std::vector< const DDsvalues_type * > &result) const
User specific data attached to the current node.
tuple cout
Definition: gather_cfg.py:121
ListIds(const edm::ParameterSet &)
Definition: ListIds.cc:81
const DDTranslation & translation() const
The absolute translation of the current node.
Detector det() const
get the detector field from this detid
Definition: DetId.h:37
T x() const
Definition: PV3DBase.h:62
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
GeometricDet::GeometricEnumType type(std::string const &) const
edm::ESWatcher< TrackerDigiGeometryRecord > m_trackerGeometryWatcher
Definition: ListIds.cc:78
edm::ESWatcher< IdealGeometryRecord > m_idealGeometryWatcher
Definition: ListIds.cc:77
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.
Definition: DDFilter.h:37