CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ListGroups.cc
Go to the documentation of this file.
1 #include <string>
2 #include <vector>
3 #include <iostream>
4 #include <iomanip>
5 
14 
21 
22 static
23 bool dddGetStringRaw(const DDFilteredView & view, const std::string & name, std::string & value) {
24  std::vector<const DDsvalues_type *> result;
25  view.specificsV(result);
26  for (std::vector<const DDsvalues_type *>::iterator it = result.begin(); it != result.end(); ++it) {
27  DDValue parameter(name);
28  if (DDfetch(*it, parameter)) {
29  if (parameter.strings().size() == 1) {
30  value = parameter.strings().front();
31  return true;
32  } else {
33  throw cms::Exception("Configuration")<< " ERROR: multiple " << name << " tags encountered";
34  return false;
35  }
36  }
37  }
38  return false;
39 }
40 
41 static inline
42 double dddGetDouble(const std::string & s, DDFilteredView const & view) {
43  std::string value;
44  if (dddGetStringRaw(view, s, value))
45  return double(::atof(value.c_str()));
46  else
47  return NAN;
48 }
49 
50 static inline
51 std::string dddGetString(const std::string & s, DDFilteredView const & view) {
52  std::string value;
53  if (dddGetStringRaw(view, s, value))
54  return value;
55  else
56  return std::string();
57 }
58 
59 static inline
60 std::ostream & operator<<(std::ostream & out, const math::XYZVector & v) {
61  out << std::fixed << std::setprecision(3);
62  return out << "(" << v.rho() << ", " << v.z() << ", " << v.phi() << ")";
63 }
64 
66 {
67 public:
69  virtual ~ListGroups();
70 
71 private:
72  void analyze(const edm::Event &, const edm::EventSetup &);
73  void beginJob() {}
74  void endJob();
75 };
76 
78 }
79 
81 }
82 
83 void
86  setup.get<IdealGeometryRecord>().get( hDdd );
87  DDFilteredView fv(*hDdd);
88 
90  filter.setCriteria(DDValue("TrackingMaterialGroup", ""), DDSpecificsFilter::not_equals);
91  fv.addFilter(filter);
92 
93  while (fv.next()) {
94  // print the group name and full hierarchy of all items
95  std::cout << dddGetString("TrackingMaterialGroup", fv) << '\t';
96 
97  // start from 2 to skip the leading /OCMS[0]/CMSE[1] part
98  const DDGeoHistory & history = fv.geoHistory();
99  std::cout << '/';
100  for (unsigned int h = 2; h < history.size(); ++h)
101  std::cout << '/' << history[h].logicalPart().name().name() << '[' << history[h].copyno() << ']';
102 
103  // DD3Vector and DDTranslation are the same type as math::XYZVector
104  math::XYZVector position = fv.translation() / 10.; // mm -> cm
105  std::cout << "\t" << position << std::endl;
106  };
107  std::cout << std::endl;
108 }
109 
110 void
112 }
113 
114 //-------------------------------------------------------------------------
115 // define as a plugin
void addFilter(const DDFilter &, log_op op=AND)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual ~ListGroups()
Definition: ListGroups.cc:80
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
void analyze(const edm::Event &, const edm::EventSetup &)
Definition: ListGroups.cc:84
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
bool next()
set current node to the next node in the filtered tree
tuple result
Definition: query.py:137
static double dddGetDouble(const std::string &s, DDFilteredView const &view)
Definition: ListGroups.cc:42
void endJob()
Definition: ListGroups.cc:111
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
static int position[264][3]
Definition: ReadPGInfo.cc:509
ListGroups(const edm::ParameterSet &)
Definition: ListGroups.cc:77
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
static bool dddGetStringRaw(const DDFilteredView &view, const std::string &name, std::string &value)
Definition: ListGroups.cc:23
void beginJob()
Definition: ListGroups.cc:73
const DDTranslation & translation() const
The absolute translation of the current node.
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
mathSSE::Vec4< T > v
static std::string dddGetString(const std::string &s, DDFilteredView const &view)
Definition: ListGroups.cc:51
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.
Definition: DDFilter.h:37