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
OutputMagneticFieldDDToDDL Class Reference

#include <OutputMagneticFieldDDToDDL.h>

Inheritance diagram for OutputMagneticFieldDDToDDL:
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
 
 OutputMagneticFieldDDToDDL (const edm::ParameterSet &iConfig)
 
 ~OutputMagneticFieldDDToDDL (void)
 
- 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 ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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 23 of file OutputMagneticFieldDDToDDL.h.

Constructor & Destructor Documentation

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

Definition at line 33 of file OutputMagneticFieldDDToDDL.cc.

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

34  : m_fname()
35 {
36  m_rotNumSeed = iConfig.getParameter<int>( "rotNumSeed" );
37  m_fname = iConfig.getUntrackedParameter<std::string>( "fileName" );
38  if( m_fname == "" )
39  {
40  m_xos = &std::cout;
41  }
42  else
43  {
44  m_xos = new std::ofstream( m_fname.c_str());
45  }
46 
47  ( *m_xos ) << "<?xml version=\"1.0\"?>\n";
48  ( *m_xos ) << "<DDDefinition xmlns=\"http://www.cern.ch/cms/DDL\"\n";
49  ( *m_xos ) << " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
50  ( *m_xos ) << "xsi:schemaLocation=\"http://www.cern.ch/cms/DDL ../../../DetectorDescription/Schema/DDLSchema.xsd\">\n";
51  ( *m_xos ) << std::fixed << std::setprecision( 18 );
52 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
tuple cout
Definition: gather_cfg.py:121
OutputMagneticFieldDDToDDL::~OutputMagneticFieldDDToDDL ( void  )

Definition at line 54 of file OutputMagneticFieldDDToDDL.cc.

References m_xos.

55 {
56  ( *m_xos ) << "</DDDefinition>\n";
57  ( *m_xos ) << std::endl;
58  m_xos->flush();
59 }

Member Function Documentation

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

Definition at line 204 of file OutputMagneticFieldDDToDDL.cc.

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

Referenced by beginRun().

205 {
206  matStore.insert( mat );
207  if( mat.noOfConstituents() != 0 )
208  {
210  int findex( 0 );
211  while( findex < mat.noOfConstituents())
212  {
213  if( matStore.find( mat.constituent( findex ).first ) == matStore.end())
214  {
215  addToMatStore( mat.constituent( findex ).first, matStore );
216  }
217  ++findex;
218  }
219  }
220 }
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 OutputMagneticFieldDDToDDL::addToSolStore ( const DDSolid sol,
std::set< DDSolid > &  solStore,
std::set< DDRotation > &  rotStore 
)
private

Definition at line 223 of file OutputMagneticFieldDDToDDL.cc.

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

Referenced by beginRun().

224 {
225  solStore.insert( sol );
226  if( sol.shape() == ddunion || sol.shape() == ddsubtraction || sol.shape() == ddintersection )
227  {
228  const DDBooleanSolid& bs ( sol );
229  if( solStore.find(bs.solidA()) == solStore.end())
230  {
231  addToSolStore( bs.solidA(), solStore, rotStore );
232  }
233  if( solStore.find( bs.solidB()) == solStore.end())
234  {
235  addToSolStore( bs.solidB(), solStore, rotStore );
236  }
237  rotStore.insert( bs.rotation());
238  }
239 }
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:144
void addToSolStore(const DDSolid &sol, std::set< DDSolid > &solStore, std::set< DDRotation > &rotStore)
void OutputMagneticFieldDDToDDL::addToSpecStore ( const DDLogicalPart lp,
std::map< const DDsvalues_type, std::set< const DDPartSelection * >, ddsvaluesCmp > &  specStore 
)
private

Definition at line 242 of file OutputMagneticFieldDDToDDL.cc.

References DDLogicalPart::attachedSpecifics().

Referenced by beginRun().

243 {
244  std::vector<std::pair<const DDPartSelection*, const DDsvalues_type*> >::const_iterator spit( lp.attachedSpecifics().begin()), spend( lp.attachedSpecifics().end());
245  for( ; spit != spend; ++spit )
246  {
247  specStore[ *spit->second ].insert( spit->first );
248  }
249 }
const std::vector< std::pair< const DDPartSelection *, const DDsvalues_type * > > & attachedSpecifics(void) const
void OutputMagneticFieldDDToDDL::analyze ( edm::Event const &  iEvent,
edm::EventSetup const &   
)
inlineoverridevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 31 of file OutputMagneticFieldDDToDDL.h.

31 {}
void OutputMagneticFieldDDToDDL::beginJob ( void  )
inlineoverridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 29 of file OutputMagneticFieldDDToDDL.h.

29 {}
void OutputMagneticFieldDDToDDL::beginRun ( edm::Run const &  iEvent,
edm::EventSetup const &  es 
)
override

Definition at line 62 of file OutputMagneticFieldDDToDDL.cc.

References addToMatStore(), addToSolStore(), addToSpecStore(), edm::EventSetup::get(), i, DDCoreToDDXMLOutput::logicalPart(), m_fname, m_rotNumSeed, m_xos, DDCoreToDDXMLOutput::material(), DDLogicalPart::material(), DDCoreToDDXMLOutput::ns_, dbtoconf::out, DDCoreToDDXMLOutput::position(), alignCSCRings::r, cmsRelvalreport::red(), DDCoreToDDXMLOutput::rotation(), DDCoreToDDXMLOutput::solid(), DDLogicalPart::solid(), DDCoreToDDXMLOutput::specpar(), and AlCaHLTBitMon_QueryRunRegistry::string.

63 {
64  edm::LogInfo( "OutputMagneticFieldDDToDDL" ) << "OutputMagneticFieldDDToDDL::beginRun";
65 
67  es.get<IdealMagneticFieldRecord>().get( pDD );
68 
69  DDCompactView::DDCompactView::graph_type gra = pDD->graph();
70 
71  // Temporary stores:
72  std::set<DDLogicalPart> lpStore;
73  std::set<DDMaterial> matStore;
74  std::set<DDSolid> solStore;
75 
76  std::map<const DDsvalues_type, std::set<const DDPartSelection*>, ddsvaluesCmp > specStore;
77  std::set<DDRotation> rotStore;
78 
80 
81  std::string rn = m_fname;
82  size_t foundLastDot= rn.find_last_of('.');
83  size_t foundLastSlash= rn.find_last_of('/');
84 
85  if( foundLastSlash > foundLastDot && foundLastSlash != std::string::npos )
86  {
87  edm::LogError( "OutputMagneticFieldDDToDDL" ) << "What? last . before last / in path for filename... this should die...";
88  }
89  if( foundLastDot != std::string::npos && foundLastSlash != std::string::npos )
90  {
91  out.ns_ = rn.substr( foundLastSlash, foundLastDot );
92  }
93  else if ( foundLastDot != std::string::npos )
94  {
95  out.ns_ = rn.substr(0, foundLastDot);
96  }
97  else
98  {
99  edm::LogError( "OutputMagneticFieldDDToDDL" ) << "What? no file name? Attempt at namespace =\"" << out.ns_ << "\" filename was " << m_fname;
100  }
101 
102  edm::LogInfo( "OutputMagneticFieldDDToDDL" ) << "m_fname=" << m_fname << " namespace = " << out.ns_;
103  std::string ns_ = out.ns_;
104 
105  ( *m_xos ) << std::fixed << std::setprecision( 18 );
106 
107  typedef DDCompactView::graph_type::const_adj_iterator adjl_iterator;
108 
109  adjl_iterator git = gra.begin();
110  adjl_iterator gend = gra.end();
111 
113  ( *m_xos) << "<PosPartSection label=\"" << ns_ << "\">\n";
114  git = gra.begin();
115  for( ; git != gend; ++git )
116  {
117  const DDLogicalPart & ddLP = gra.nodeData( git );
118  if( lpStore.find(ddLP) != lpStore.end())
119  {
120  addToSpecStore( ddLP, specStore );
121  }
122  lpStore.insert( ddLP );
123  addToMatStore( ddLP.material(), matStore );
124  addToSolStore( ddLP.solid(), solStore, rotStore );
125  ++i;
126  if( git->size())
127  {
128  // ask for children of ddLP
129  DDCompactView::graph_type::edge_list::const_iterator cit = git->begin();
130  DDCompactView::graph_type::edge_list::const_iterator cend = git->end();
131  for( ; cit != cend; ++cit )
132  {
133  const DDLogicalPart & ddcurLP = gra.nodeData( cit->first );
134  if( lpStore.find(ddcurLP) != lpStore.end())
135  {
136  addToSpecStore( ddcurLP, specStore );
137  }
138  lpStore.insert( ddcurLP );
139  addToMatStore( ddcurLP.material(), matStore );
140  addToSolStore( ddcurLP.solid(), solStore, rotStore );
141  rotStore.insert( gra.edgeData( cit->second )->rot_ );
142  out.position( ddLP, ddcurLP, gra.edgeData( cit->second ), m_rotNumSeed, *m_xos );
143  } // iterate over children
144  } // if (children)
145  } // iterate over graph nodes
146 
147  ( *m_xos ) << "</PosPartSection>\n";
148 
149  ( *m_xos ) << std::scientific << std::setprecision( 18 );
150  std::set<DDMaterial>::const_iterator it( matStore.begin()), ed( matStore.end());
151  ( *m_xos) << "<MaterialSection label=\"" << ns_ << "\">\n";
152  for( ; it != ed; ++it )
153  {
154  if( ! it->isDefined().second ) continue;
155  out.material( *it, *m_xos );
156  }
157  ( *m_xos ) << "</MaterialSection>\n";
158 
159  ( *m_xos ) << "<RotationSection label=\"" << ns_ << "\">\n";
160  ( *m_xos ) << std::fixed << std::setprecision( 18 );
161  std::set<DDRotation>::iterator rit( rotStore.begin()), red( rotStore.end());
162  for( ; rit != red; ++rit )
163  {
164  if( ! rit->isDefined().second ) continue;
165  if( rit->toString() != ":" )
166  {
167  DDRotation r( *rit );
168  out.rotation( r, *m_xos );
169  }
170  }
171  ( *m_xos ) << "</RotationSection>\n";
172 
173  ( *m_xos ) << std::fixed << std::setprecision( 18 );
174  std::set<DDSolid>::const_iterator sit( solStore.begin()), sed( solStore.end());
175  ( *m_xos ) << "<SolidSection label=\"" << ns_ << "\">\n";
176  for( ; sit != sed; ++sit)
177  {
178  if( ! sit->isDefined().second ) continue;
179  out.solid( *sit, *m_xos );
180  }
181  ( *m_xos ) << "</SolidSection>\n";
182 
183  std::set<DDLogicalPart>::iterator lpit( lpStore.begin()), lped( lpStore.end());
184  ( *m_xos ) << "<LogicalPartSection label=\"" << ns_ << "\">\n";
185  for( ; lpit != lped; ++lpit )
186  {
187  if( ! lpit->isDefined().first ) continue;
188  const DDLogicalPart & lp = *lpit;
189  out.logicalPart( lp, *m_xos );
190  }
191  ( *m_xos ) << "</LogicalPartSection>\n";
192 
193  ( *m_xos ) << std::fixed << std::setprecision( 18 );
194  std::map<DDsvalues_type, std::set<const DDPartSelection*> >::const_iterator mit( specStore.begin()), mend( specStore.end());
195  ( *m_xos ) << "<SpecParSection label=\"" << ns_ << "\">\n";
196  for( ; mit != mend; ++mit )
197  {
198  out.specpar( *mit, *m_xos );
199  }
200  ( *m_xos ) << "</SpecParSection>\n";
201 }
void addToSpecStore(const DDLogicalPart &lp, std::map< const DDsvalues_type, std::set< const DDPartSelection * >, ddsvaluesCmp > &specStore)
int i
Definition: DBlmapReader.cc:9
void rotation(DDRotation &rotation, std::ostream &xos, const std::string &rotn="")
void specpar(const DDSpecifics &sp, std::ostream &xos)
void addToMatStore(const DDMaterial &mat, std::set< DDMaterial > &matStore)
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
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
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 addToSolStore(const DDSolid &sol, std::set< DDSolid > &solStore, std::set< DDRotation > &rotStore)
void logicalPart(const DDLogicalPart &lp, std::ostream &xos)
tuple out
Definition: dbtoconf.py:99
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 OutputMagneticFieldDDToDDL::endJob ( void  )
inlineoverridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 33 of file OutputMagneticFieldDDToDDL.h.

33 {}
void OutputMagneticFieldDDToDDL::endRun ( edm::Run const &  iEvent,
edm::EventSetup const &   
)
inlineoverride

Definition at line 32 of file OutputMagneticFieldDDToDDL.h.

32 {}

Member Data Documentation

std::string OutputMagneticFieldDDToDDL::m_fname
private

Definition at line 41 of file OutputMagneticFieldDDToDDL.h.

Referenced by beginRun(), and OutputMagneticFieldDDToDDL().

int OutputMagneticFieldDDToDDL::m_rotNumSeed
private

Definition at line 40 of file OutputMagneticFieldDDToDDL.h.

Referenced by beginRun(), and OutputMagneticFieldDDToDDL().

std::ostream* OutputMagneticFieldDDToDDL::m_xos
private