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 &) override;
76  void beginJob() override {}
77  void endJob() override;
78 };
79 
81 }
82 
84 }
85 
86 void
88  std::cout << "______________________________ DDD ______________________________" << std::endl;
90  setup.get<IdealGeometryRecord>().get( hDdd );
91 
92  std::string attribute = "TkDDDStructure";
93  CmsTrackerStringToEnum theCmsTrackerStringToEnum;
95  filter.setCriteria(DDValue(attribute, "any", 0), DDSpecificsFilter::not_equals);
96  DDFilteredView fv(*hDdd);
97  fv.addFilter(filter);
98  if (theCmsTrackerStringToEnum.type(dddGetString(attribute, fv)) != GeometricDet::Tracker) {
99  fv.firstChild();
100  if (theCmsTrackerStringToEnum.type(dddGetString(attribute, fv)) != GeometricDet::Tracker)
101  throw cms::Exception("Configuration") << "The first child of the DDFilteredView is not what is expected \n"
102  << dddGetString(attribute, fv);
103  }
104 
105  std::cout << std::fixed << std::setprecision(3);
106  do {
107  // print the full hierarchy of all Silicon items
108  if (fv.logicalPart().material().name() == "materials:Silicon") {
109 
110  // start from 2 to skip the leading /OCMS[0]/CMSE[1] part
111  const DDGeoHistory & history = fv.geoHistory();
112  std::cout << '/';
113  for (unsigned int h = 2; h < history.size(); ++h) {
114  std::cout << '/' << history[h].logicalPart().name().name() << '[' << history[h].copyno() << ']';
115  }
116 
117  // DD3Vector and DDTranslation are the same type as math::XYZVector
118  math::XYZVector position = fv.translation() / 10.; // mm -> cm
119  std::cout << "\t" << position << std::endl;
120  }
121  } while (fv.next());
122  std::cout << std::endl;
123 
124  std::cout << "______________________________ std::vector<GeomDet*> from TrackerGeometry::dets() ______________________________" << std::endl;
126  setup.get<TrackerDigiGeometryRecord>().get( hGeo );
127 
128  std::cout << std::fixed << std::setprecision(3);
129  auto const & dets = hGeo->dets();
130  for (unsigned int i = 0; i < dets.size(); ++i) {
131  const GeomDet & det = *dets[i];
132 
133  // Surface::PositionType is a typedef for Point3DBase<float,GlobalTag> a.k.a. GlobalPoint
134  const Surface::PositionType & p = det.position();
135  math::XYZVector position(p.x(), p.y(), p.z());
136 
137  std::cout << det.subDetector() << '\t'
138  << det.geographicalId().det() << '\t'
139  << det.geographicalId().subdetId() << '\t'
140  << det.geographicalId().rawId() << "\t"
141  << position;
142  const std::vector<const GeomDet*> & parts = det.components();
143  if (parts.size()) {
144  std::cout << "\t[" << parts[0]->geographicalId().rawId();
145  for (unsigned int j = 1; j < parts.size(); ++j)
146  std::cout << '\t' << parts[j]->geographicalId().rawId();
147  std::cout << ']';
148  }
149  std::cout << std::endl;
150  }
151 
152 }
153 
154 void
156 }
157 
158 //-------------------------------------------------------------------------
159 // define as a plugin
int i
Definition: DBlmapReader.cc:9
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: ListIds.cc:87
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
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:80
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:46
bool next()
set current node to the next node in the filtered tree
virtual ~ListIds()
Definition: ListIds.cc:83
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:77
void endJob() override
Definition: ListIds.cc:155
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
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:37
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:62
std::vector< DDExpandedNode > DDGeoHistory
Geometrical &#39;path&#39; of the current node up to the root-node.
tuple out
Definition: dbtoconf.py:99
virtual std::vector< const GeomDet * > components() const
Returns direct components, if any.
Definition: GeomDet.h:86
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
const T & get() const
Definition: EventSetup.h:55
static int position[264][3]
Definition: ReadPGInfo.cc:509
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:80
const DDTranslation & translation() const
The absolute translation of the current node.
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
virtual SubDetector subDetector() const
Which subdetector.
Definition: GeomDet.cc:49
T x() const
Definition: PV3DBase.h:62
void beginJob() override
Definition: ListIds.cc:76
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
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.
Definition: DDFilter.h:37