CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
OutputDDToDDL Class Reference
Inheritance diagram for OutputDDToDDL:
edm::one::EDAnalyzer< edm::one::WatchRuns > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (edm::Event const &iEvent, edm::EventSetup const &) override
 
void beginJob () override
 
void beginRun (edm::Run const &iEvent, edm::EventSetup const &) override
 
void endJob () override
 
void endRun (edm::Run const &iEvent, edm::EventSetup const &) override
 
 OutputDDToDDL (const edm::ParameterSet &iConfig)
 
 ~OutputDDToDDL ()
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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< const DDsvalues_type, std::set< const DDPartSelection * >, ddsvaluesCmp > &specStore)
 

Private Attributes

std::string m_fname
 
int m_rotNumSeed
 
std::ostream * m_xos
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 36 of file OutputDDToDDL.cc.

Constructor & Destructor Documentation

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

Definition at line 74 of file OutputDDToDDL.cc.

References gather_cfg::cout, alignBH_cfg::fixed, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), m_fname, m_rotNumSeed, m_xos, and AlCaHLTBitMon_QueryRunRegistry::string.

75  : m_fname()
76 {
77  m_rotNumSeed = iConfig.getParameter<int>("rotNumSeed");
78  m_fname = iConfig.getUntrackedParameter<std::string>("fileName");
79  if( m_fname == "" ) {
80  m_xos = &std::cout;
81  } else {
82  m_xos = new std::ofstream( m_fname.c_str());
83  }
84  (*m_xos) << "<?xml version=\"1.0\"?>" << std::endl;
85  (*m_xos) << "<DDDefinition xmlns=\"http://www.cern.ch/cms/DDL\"" << std::endl;
86  (*m_xos) << " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" << std::endl;
87  (*m_xos) << "xsi:schemaLocation=\"http://www.cern.ch/cms/DDL ../../../DetectorDescription/Schema/DDLSchema.xsd\">" << std::endl;
88  (*m_xos) << std::fixed << std::setprecision(18);
89 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::string m_fname
std::ostream * m_xos
OutputDDToDDL::~OutputDDToDDL ( )

Definition at line 91 of file OutputDDToDDL.cc.

References m_xos.

92 {
93  (*m_xos) << "</DDDefinition>" << std::endl;
94  (*m_xos) << std::endl;
95  m_xos->flush();
96 }
std::ostream * m_xos

Member Function Documentation

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

Definition at line 221 of file OutputDDToDDL.cc.

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

Referenced by beginRun().

222 {
223  matStore.insert( mat );
224  if( mat.noOfConstituents() != 0 ) {
225  int findex(0);
226  while( findex < mat.noOfConstituents()) {
227  if( matStore.find( mat.constituent( findex ).first) == matStore.end()) {
228  addToMatStore( mat.constituent( findex ).first, matStore );
229  }
230  ++findex;
231  }
232  }
233 }
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:91
int noOfConstituents() const
returns the number of compound materials or 0 for elementary materials
Definition: DDMaterial.cc:85
void OutputDDToDDL::addToSolStore ( const DDSolid sol,
std::set< DDSolid > &  solStore,
std::set< DDRotation > &  rotStore 
)
private

Definition at line 236 of file OutputDDToDDL.cc.

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

Referenced by beginRun().

237 {
238  solStore.insert(sol);
239  if( sol.shape() == ddunion || sol.shape() == ddsubtraction || sol.shape() == ddintersection ) {
240  const DDBooleanSolid& bs (sol);
241  if( solStore.find( bs.solidA()) == solStore.end()) {
242  addToSolStore( bs.solidA(), solStore, rotStore );
243  }
244  if( solStore.find( bs.solidB()) == solStore.end()) {
245  addToSolStore( bs.solidB(), solStore, rotStore );
246  }
247  rotStore.insert( bs.rotation());
248  }
249 }
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:140
void OutputDDToDDL::addToSpecStore ( const DDLogicalPart lp,
std::map< const DDsvalues_type, std::set< const DDPartSelection * >, ddsvaluesCmp > &  specStore 
)
private

Definition at line 252 of file OutputDDToDDL.cc.

References DDLogicalPart::attachedSpecifics(), and DEFINE_FWK_MODULE.

Referenced by beginRun().

254 {
255  for( auto spit : lp.attachedSpecifics()) {
256  specStore[*spit.second].insert( spit.first );
257  }
258 }
const std::vector< std::pair< const DDPartSelection *, const DDsvalues_type * > > & attachedSpecifics(void) const
void OutputDDToDDL::analyze ( edm::Event const &  iEvent,
edm::EventSetup const &   
)
inlineoverridevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 44 of file OutputDDToDDL.cc.

44 {}
void OutputDDToDDL::beginJob ( void  )
inlineoverridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 42 of file OutputDDToDDL.cc.

References iEvent.

42 {}
void OutputDDToDDL::beginRun ( edm::Run const &  iEvent,
edm::EventSetup const &   
)
override

Definition at line 99 of file OutputDDToDDL.cc.

References addToMatStore(), addToSolStore(), addToSpecStore(), gather_cfg::cout, alignBH_cfg::fixed, edm::EventSetup::get(), DDCompactView::graph(), mps_fire::i, DDCoreToDDXMLOutput::logicalPart(), m_fname, m_rotNumSeed, m_xos, DDCoreToDDXMLOutput::material(), DDLogicalPart::material(), DDCoreToDDXMLOutput::ns_, MillePedeFileConverter_cfg::out, DDCoreToDDXMLOutput::position(), alignCSCRings::r, cmsRelvalreport::red(), DDCoreToDDXMLOutput::rotation(), DDCoreToDDXMLOutput::solid(), DDLogicalPart::solid(), DDCoreToDDXMLOutput::specpar(), and AlCaHLTBitMon_QueryRunRegistry::string.

100 {
101  std::cout << "OutputDDToDDL::beginRun" << std::endl;
102 
104  es.get<IdealGeometryRecord>().get( pDD );
105 
106  DDCompactView::DDCompactView::graph_type gra = pDD->graph();
107  // temporary stores:
108  std::set<DDLogicalPart> lpStore;
109  std::set<DDMaterial> matStore;
110  std::set<DDSolid> solStore;
111  // 2009-08-19: MEC: I've tried this with set<DDPartSelection> and
112  // had to write operator< for DDPartSelection and DDPartSelectionLevel
113  // the output from such an effort is different than this one.
114  std::map<const DDsvalues_type, std::set<const DDPartSelection*>, ddsvaluesCmp > specStore;
115  std::set<DDRotation> rotStore;
116 
118 
119  std::string rn = m_fname;
120  size_t foundLastDot = rn.find_last_of('.');
121  size_t foundLastSlash = rn.find_last_of('/');
122  if( foundLastSlash > foundLastDot && foundLastSlash != std::string::npos ) {
123  std::cout << "What? last . before last / in path for filename... this should die..." << std::endl;
124  }
125  if( foundLastDot != std::string::npos && foundLastSlash != std::string::npos ) {
126  out.ns_ = rn.substr( foundLastSlash, foundLastDot );
127  } else if( foundLastDot != std::string::npos ) {
128  out.ns_ = rn.substr(0, foundLastDot);
129  } else {
130  std::cout << "What? no file name? Attempt at namespace =\"" << out.ns_ << "\" filename was " << m_fname << std::endl;
131  }
132  std::cout << "m_fname = " << m_fname << " namespace = " << out.ns_ << std::endl;
133  std::string ns_ = out.ns_;
134 
135  (*m_xos) << std::fixed << std::setprecision(18);
136  typedef DDCompactView::graph_type::const_adj_iterator adjl_iterator;
137 
138  adjl_iterator git = gra.begin();
139  adjl_iterator gend = gra.end();
140 
142  (*m_xos) << "<PosPartSection label=\"" << ns_ << "\">" << std::endl;
143  git = gra.begin();
144  for( ; git != gend; ++git ) {
145  const DDLogicalPart & ddLP = gra.nodeData( git );
146  if( lpStore.find( ddLP ) != lpStore.end()) {
147  addToSpecStore( ddLP, specStore );
148  }
149  lpStore.insert( ddLP );
150  addToMatStore( ddLP.material(), matStore );
151  addToSolStore( ddLP.solid(), solStore, rotStore );
152  ++i;
153  if( git->size()) {
154  // ask for children of ddLP
155  DDCompactView::graph_type::edge_list::const_iterator cit = git->begin();
156  DDCompactView::graph_type::edge_list::const_iterator cend = git->end();
157  for( ; cit != cend; ++cit ) {
158  const DDLogicalPart & ddcurLP = gra.nodeData( cit->first );
159  if( lpStore.find( ddcurLP ) != lpStore.end()) {
160  addToSpecStore( ddcurLP, specStore );
161  }
162  lpStore.insert( ddcurLP );
163  addToMatStore( ddcurLP.material(), matStore );
164  addToSolStore( ddcurLP.solid(), solStore, rotStore );
165  rotStore.insert( gra.edgeData( cit->second )->rot_ );
166  out.position( ddLP, ddcurLP, gra.edgeData( cit->second ), m_rotNumSeed, *m_xos );
167  } // iterate over children
168  } // if (children)
169  } // iterate over graph nodes
170 
171  (*m_xos) << "</PosPartSection>" << std::endl;
172 
173  (*m_xos) << std::scientific << std::setprecision(18);
174 
175  (*m_xos) << "<MaterialSection label=\"" << ns_ << "\">" << std::endl;
176  for( auto it : matStore ) {
177  if( ! it.isDefined().second ) continue;
178  out.material( it, *m_xos );
179  }
180  (*m_xos) << "</MaterialSection>" << std::endl;
181  (*m_xos) << "<RotationSection label=\"" << ns_ << "\">" << std::endl;
182  (*m_xos) << std::fixed << std::setprecision(18);
183  std::set<DDRotation>::iterator rit( rotStore.begin()), red( rotStore.end());
184  for( ; rit != red; ++rit ) {
185  if( !rit->isDefined().second ) continue;
186  if( rit->toString() != ":" ) {
187  DDRotation r(*rit);
188  out.rotation(r, *m_xos);
189  }
190  }
191  (*m_xos) << "</RotationSection>" << std::endl;
192 
193  (*m_xos) << std::fixed << std::setprecision(18);
194  std::set<DDSolid>::const_iterator sit( solStore.begin()), sed( solStore.end());
195  (*m_xos) << "<SolidSection label=\"" << ns_ << "\">" << std::endl;
196  for( ; sit != sed; ++sit ) {
197  if( !sit->isDefined().second) continue;
198  out.solid( *sit, *m_xos );
199  }
200  (*m_xos) << "</SolidSection>" << std::endl;
201 
202  std::set<DDLogicalPart>::iterator lpit( lpStore.begin()), lped( lpStore.end());
203  (*m_xos) << "<LogicalPartSection label=\"" << ns_ << "\">" << std::endl;
204  for( ; lpit != lped; ++lpit ) {
205  if( !lpit->isDefined().first ) continue;
206  const DDLogicalPart & lp = *lpit;
207  out.logicalPart( lp, *m_xos);
208  }
209  (*m_xos) << "</LogicalPartSection>" << std::endl;
210 
211  (*m_xos) << std::fixed << std::setprecision(18);
212  std::map<DDsvalues_type, std::set<const DDPartSelection*> >::const_iterator mit( specStore.begin()), mend( specStore.end());
213  (*m_xos) << "<SpecParSection label=\"" << ns_ << "\">" << std::endl;
214  for( ; mit != mend; ++mit ) {
215  out.specpar ( *mit, *m_xos );
216  }
217  (*m_xos) << "</SpecParSection>" << std::endl;
218 }
void rotation(DDRotation &rotation, std::ostream &xos, const std::string &rotn="")
void addToSpecStore(const DDLogicalPart &lp, std::map< const DDsvalues_type, std::set< const DDPartSelection * >, ddsvaluesCmp > &specStore)
std::string m_fname
void addToMatStore(const DDMaterial &mat, std::set< DDMaterial > &matStore)
const graph_type & graph() const
Provides read-only access to the data structure of the compact-view.
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:64
std::ostream * m_xos
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:92
void logicalPart(const DDLogicalPart &lp, std::ostream &xos)
adj_list::const_iterator const_adj_iterator
Definition: adjgraph.h:125
void material(const DDMaterial &material, std::ostream &xos)
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.
void OutputDDToDDL::endJob ( void  )
inlineoverridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 46 of file OutputDDToDDL.cc.

References genParticles_cff::map.

46 {}
void OutputDDToDDL::endRun ( edm::Run const &  iEvent,
edm::EventSetup const &   
)
inlineoverride

Definition at line 45 of file OutputDDToDDL.cc.

45 {}

Member Data Documentation

std::string OutputDDToDDL::m_fname
private

Definition at line 54 of file OutputDDToDDL.cc.

Referenced by beginRun(), and OutputDDToDDL().

int OutputDDToDDL::m_rotNumSeed
private

Definition at line 53 of file OutputDDToDDL.cc.

Referenced by beginRun(), and OutputDDToDDL().

std::ostream* OutputDDToDDL::m_xos
private

Definition at line 55 of file OutputDDToDDL.cc.

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