CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
OutputDDToDDL Class Reference

#include <OutputDDToDDL.h>

Inheritance diagram for OutputDDToDDL:
edm::EDAnalyzer

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginRun (const edm::Run &, edm::EventSetup const &)
 
virtual void endJob ()
 
 OutputDDToDDL (const edm::ParameterSet &iConfig)
 
 ~OutputDDToDDL ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Member Functions

void addToMatStore (const DDMaterial &mat, std::set< DDMaterial > &matStore)
 
void addToSolStore (const DDSolid &sol, std::set< DDSolid > &solStore, std::set< DDRotation > &rotStore)
 
void addToSpecStore (const DDLogicalPart &lp, std::map< DDsvalues_type, std::set< DDPartSelection * >, ddsvaluesCmp > &specStore)
 

Private Attributes

std::string fname_
 
int rotNumSeed_
 
int specNameCount_
 
std::ostream * xos_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 21 of file OutputDDToDDL.h.

Constructor & Destructor Documentation

OutputDDToDDL::OutputDDToDDL ( const edm::ParameterSet iConfig)
explicit

Definition at line 30 of file OutputDDToDDL.cc.

References gather_cfg::cout, fname_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), rotNumSeed_, and xos_.

30  : fname_()
31 {
32  // std::cout<<"OutputDDToDDL::OutputDDToDDL"<<std::endl;
33  rotNumSeed_ = iConfig.getParameter<int>("rotNumSeed");
34  fname_ = iConfig.getUntrackedParameter<std::string>("fileName");
35  if ( fname_ == "" ) {
36  xos_ = &std::cout;
37  } else {
38  xos_ = new std::ofstream(fname_.c_str());
39  }
40  (*xos_) << "<?xml version=\"1.0\"?>" << std::endl;
41  (*xos_) << "<DDDefinition xmlns=\"http://www.cern.ch/cms/DDL\"" << std::endl;
42  (*xos_) << " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" << std::endl;
43  (*xos_) << "xsi:schemaLocation=\"http://www.cern.ch/cms/DDL ../../../DetectorDescription/Schema/DDLSchema.xsd\">" << std::endl;
44  (*xos_) << std::fixed << std::setprecision(18);
45 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::string fname_
Definition: OutputDDToDDL.h:36
std::ostream * xos_
Definition: OutputDDToDDL.h:37
tuple cout
Definition: gather_cfg.py:121
OutputDDToDDL::~OutputDDToDDL ( )

Definition at line 46 of file OutputDDToDDL.cc.

References xos_.

47 {
48  (*xos_) << "</DDDefinition>" << std::endl;
49  (*xos_) << std::endl;
50  xos_->flush();
51 
52 }
std::ostream * xos_
Definition: OutputDDToDDL.h:37

Member Function Documentation

void OutputDDToDDL::addToMatStore ( const DDMaterial mat,
std::set< DDMaterial > &  matStore 
)
private

Definition at line 183 of file OutputDDToDDL.cc.

References DDMaterial::constituent(), cropTnPTrees::frac, and DDMaterial::noOfConstituents().

Referenced by beginRun().

183  {
184  matStore.insert(mat);
185  if ( mat.noOfConstituents() != 0 ) {
187  int findex(0);
188  while ( findex < mat.noOfConstituents() ) {
189  if ( matStore.find(mat.constituent(findex).first) == matStore.end() ) {
190  addToMatStore( mat.constituent(findex).first, matStore );
191  }
192  ++findex;
193  }
194  }
195 }
void addToMatStore(const DDMaterial &mat, std::set< DDMaterial > &matStore)
FractionV::value_type constituent(int i) const
returns the i-th compound material and its fraction-mass
Definition: DDMaterial.cc:89
Container::value_type value_type
int noOfConstituents() const
returns the number of compound materials or 0 for elementary materials
Definition: DDMaterial.cc:83
void OutputDDToDDL::addToSolStore ( const DDSolid sol,
std::set< DDSolid > &  solStore,
std::set< DDRotation > &  rotStore 
)
private

Definition at line 197 of file OutputDDToDDL.cc.

References ddintersection, ddsubtraction, ddunion, DDBooleanSolid::rotation(), DDSolid::shape(), DDBooleanSolid::solidA(), and DDBooleanSolid::solidB().

Referenced by beginRun().

197  {
198  solStore.insert(sol);
199  if ( sol.shape() == ddunion || sol.shape() == ddsubtraction || sol.shape() == ddintersection ) {
200  const DDBooleanSolid& bs (sol);
201  if ( solStore.find(bs.solidA()) == solStore.end()) {
202  addToSolStore(bs.solidA(), solStore, rotStore);
203  }
204  if ( solStore.find(bs.solidB()) == solStore.end()) {
205  addToSolStore(bs.solidB(), solStore, rotStore);
206  }
207  rotStore.insert(bs.rotation());
208  }
209 }
void addToSolStore(const DDSolid &sol, std::set< DDSolid > &solStore, std::set< DDRotation > &rotStore)
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:144
void OutputDDToDDL::addToSpecStore ( const DDLogicalPart lp,
std::map< DDsvalues_type, std::set< DDPartSelection * >, ddsvaluesCmp > &  specStore 
)
private

Definition at line 211 of file OutputDDToDDL.cc.

References DDLogicalPart::attachedSpecifics().

Referenced by beginRun().

211  {
212  std::vector<std::pair<DDPartSelection*, DDsvalues_type*> >::const_iterator spit(lp.attachedSpecifics().begin()), spend(lp.attachedSpecifics().end());
213  for ( ; spit != spend; ++spit ) {
214  specStore[*spit->second].insert(spit->first);
215  }
216 }
const std::vector< std::pair< DDPartSelection *, DDsvalues_type * > > & attachedSpecifics(void) const
virtual void OutputDDToDDL::analyze ( const edm::Event ,
const edm::EventSetup  
)
inlinevirtual

Implements edm::EDAnalyzer.

Definition at line 27 of file OutputDDToDDL.h.

27 {}
void OutputDDToDDL::beginRun ( const edm::Run ,
edm::EventSetup const &  es 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 55 of file OutputDDToDDL.cc.

References addToMatStore(), addToSolStore(), addToSpecStore(), gather_cfg::cout, fname_, edm::EventSetup::get(), i, DDCoreToDDXMLOutput::logicalPart(), DDCoreToDDXMLOutput::material(), DDLogicalPart::material(), DDCoreToDDXMLOutput::ns_, dbtoconf::out, DDCoreToDDXMLOutput::position(), alignCSCRings::r, cmsRelvalreport::red(), DDCoreToDDXMLOutput::rotation(), rotNumSeed_, DDCoreToDDXMLOutput::solid(), DDLogicalPart::solid(), DDCoreToDDXMLOutput::specpar(), and xos_.

56 {
57  std::cout<<"OutputDDToDDL::beginRun"<<std::endl;
58 
60 
61  es.get<IdealGeometryRecord>().get( pDD );
62 
63  DDCompactView::DDCompactView::graph_type gra = pDD->graph();
64  // temporary stores:
65  std::set<DDLogicalPart> lpStore;
66  std::set<DDMaterial> matStore;
67  std::set<DDSolid> solStore;
68  // 2009-08-19: MEC: I've tried this with set<DDPartSelection> and
69  // had to write operator< for DDPartSelection and DDPartSelectionLevel
70  // the output from such an effort is different than this one.
71  std::map<DDsvalues_type, std::set<DDPartSelection*>, ddsvaluesCmp > specStore;
72  std::set<DDRotation> rotStore;
73 
75 
76  std::string rn = fname_;
77  size_t foundLastDot= rn.find_last_of('.');
78  size_t foundLastSlash= rn.find_last_of('/');
79  if ( foundLastSlash > foundLastDot && foundLastSlash != std::string::npos) {
80  std::cout << "What? last . before last / in path for filename... this should die..." << std::endl;
81  }
82  if ( foundLastDot != std::string::npos && foundLastSlash != std::string::npos ) {
83  out.ns_ = rn.substr(foundLastSlash,foundLastDot);
84  } else if ( foundLastDot != std::string::npos ) {
85  out.ns_ = rn.substr(0, foundLastDot);
86  } else {
87  std::cout << "What? no file name? Attempt at namespace =\"" << out.ns_ << "\" filename was " << fname_ << std::endl;
88  }
89  std::cout << "fname_=" << fname_ << " namespace = " << out.ns_ << std::endl;
90  std::string ns_ = out.ns_;
91 
92  (*xos_) << std::fixed << std::setprecision(18);
94 
95  adjl_iterator git = gra.begin();
96  adjl_iterator gend = gra.end();
97 
99  (*xos_) << "<PosPartSection label=\"" << ns_ << "\">" << std::endl;
100  git = gra.begin();
101  for (; git != gend; ++git)
102  {
103  const DDLogicalPart & ddLP = gra.nodeData(git);
104  if ( lpStore.find(ddLP) != lpStore.end() ) {
105  addToSpecStore(ddLP, specStore);
106  }
107  lpStore.insert(ddLP);
108  addToMatStore( ddLP.material(), matStore );
109  addToSolStore( ddLP.solid(), solStore, rotStore );
110  ++i;
111  if (git->size())
112  {
113  // ask for children of ddLP
114  DDCompactView::graph_type::edge_list::const_iterator cit = git->begin();
115  DDCompactView::graph_type::edge_list::const_iterator cend = git->end();
116  for (; cit != cend; ++cit)
117  {
118  const DDLogicalPart & ddcurLP = gra.nodeData(cit->first);
119  if (lpStore.find(ddcurLP) != lpStore.end()) {
120  addToSpecStore(ddcurLP, specStore);
121  }
122  lpStore.insert(ddcurLP);
123  addToMatStore(ddcurLP.material(), matStore);
124  addToSolStore(ddcurLP.solid(), solStore, rotStore);
125  rotStore.insert(gra.edgeData(cit->second)->rot_);
126  out.position(ddLP, ddcurLP, gra.edgeData(cit->second), rotNumSeed_, *xos_);
127  } // iterate over children
128  } // if (children)
129  } // iterate over graph nodes
130  // std::cout << "specStore.size() = " << specStore.size() << std::endl;
131 
132  (*xos_) << "</PosPartSection>" << std::endl;
133 
134  (*xos_) << std::scientific << std::setprecision(18);
135  std::set<DDMaterial>::const_iterator it(matStore.begin()), ed(matStore.end());
136  (*xos_) << "<MaterialSection label=\"" << ns_ << "\">" << std::endl;
137  for (; it != ed; ++it) {
138  if (! it->isDefined().second) continue;
139  out.material(*it, *xos_);
140  }
141  (*xos_) << "</MaterialSection>" << std::endl;
142 
143  (*xos_) << "<RotationSection label=\"" << ns_ << "\">" << std::endl;
144  (*xos_) << std::fixed << std::setprecision(18);
145  std::set<DDRotation>::iterator rit(rotStore.begin()), red(rotStore.end());
146  for (; rit != red; ++rit) {
147  if (! rit->isDefined().second) continue;
148  if ( rit->toString() != ":" ) {
149  DDRotation r(*rit);
150  out.rotation(r, *xos_);
151  }
152  }
153  (*xos_) << "</RotationSection>" << std::endl;
154 
155  (*xos_) << std::fixed << std::setprecision(18);
156  std::set<DDSolid>::const_iterator sit(solStore.begin()), sed(solStore.end());
157  (*xos_) << "<SolidSection label=\"" << ns_ << "\">" << std::endl;
158  for (; sit != sed; ++sit) {
159  if (! sit->isDefined().second) continue;
160  out.solid(*sit, *xos_);
161  }
162  (*xos_) << "</SolidSection>" << std::endl;
163 
164  std::set<DDLogicalPart>::iterator lpit(lpStore.begin()), lped(lpStore.end());
165  (*xos_) << "<LogicalPartSection label=\"" << ns_ << "\">" << std::endl;
166  for (; lpit != lped; ++lpit) {
167  if (! lpit->isDefined().first) continue;
168  const DDLogicalPart & lp = *lpit;
169  out.logicalPart(lp, *xos_);
170  }
171  (*xos_) << "</LogicalPartSection>" << std::endl;
172 
173  (*xos_) << std::fixed << std::setprecision(18);
174  std::map<DDsvalues_type, std::set<DDPartSelection*> >::const_iterator mit(specStore.begin()), mend (specStore.end());
175  (*xos_) << "<SpecParSection label=\"" << ns_ << "\">" << std::endl;
176  for (; mit != mend; ++mit) {
177  out.specpar ( *mit, *xos_ );
178  }
179  (*xos_) << "</SpecParSection>" << std::endl;
180 
181 }
int i
Definition: DBlmapReader.cc:9
void rotation(DDRotation &rotation, std::ostream &xos, const std::string &rotn="")
void addToMatStore(const DDMaterial &mat, std::set< DDMaterial > &matStore)
void addToSpecStore(const DDLogicalPart &lp, std::map< DDsvalues_type, std::set< DDPartSelection * >, ddsvaluesCmp > &specStore)
is sv1 &lt; sv2
Definition: OutputDDToDDL.h:17
void specpar(const DDSpecifics &sp, std::ostream &xos)
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
std::vector< double >::size_type index_type
Definition: adjgraph.h:15
void addToSolStore(const DDSolid &sol, std::set< DDSolid > &solStore, std::set< DDRotation > &rotStore)
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
std::string fname_
Definition: OutputDDToDDL.h:36
void position(const DDLogicalPart &parent, const DDLogicalPart &child, DDPosData *edgeToChild, int &rotNameSeed, std::ostream &xos)
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:88
void logicalPart(const DDLogicalPart &lp, std::ostream &xos)
tuple out
Definition: dbtoconf.py:99
std::ostream * xos_
Definition: OutputDDToDDL.h:37
adj_list::const_iterator const_adj_iterator
Definition: adjgraph.h:125
void material(const DDMaterial &material, std::ostream &xos)
tuple cout
Definition: gather_cfg.py:121
void solid(const DDSolid &solid, std::ostream &xos)
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
virtual void OutputDDToDDL::endJob ( void  )
inlinevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 28 of file OutputDDToDDL.h.

28 {};

Member Data Documentation

std::string OutputDDToDDL::fname_
private

Definition at line 36 of file OutputDDToDDL.h.

Referenced by beginRun(), and OutputDDToDDL().

int OutputDDToDDL::rotNumSeed_
private

Definition at line 35 of file OutputDDToDDL.h.

Referenced by beginRun(), and OutputDDToDDL().

int OutputDDToDDL::specNameCount_
private

Definition at line 38 of file OutputDDToDDL.h.

std::ostream* OutputDDToDDL::xos_
private

Definition at line 37 of file OutputDDToDDL.h.

Referenced by beginRun(), OutputDDToDDL(), and ~OutputDDToDDL().