CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
OutputMagneticFieldDDToDDL Class Reference
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) override
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns >
 EDAnalyzer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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 & itemsToGetFrom (BranchType iType) 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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 34 of file OutputMagneticFieldDDToDDL.cc.

Constructor & Destructor Documentation

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

Definition at line 72 of file OutputMagneticFieldDDToDDL.cc.

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

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

Definition at line 93 of file OutputMagneticFieldDDToDDL.cc.

References m_xos.

94 {
95  ( *m_xos ) << "</DDDefinition>\n";
96  ( *m_xos ) << std::endl;
97  m_xos->flush();
98 }

Member Function Documentation

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

Definition at line 244 of file OutputMagneticFieldDDToDDL.cc.

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

Referenced by beginRun().

245 {
246  matStore.insert( mat );
247  if( mat.noOfConstituents() != 0 )
248  {
250  int findex( 0 );
251  while( findex < mat.noOfConstituents())
252  {
253  if( matStore.find( mat.constituent( findex ).first ) == matStore.end())
254  {
255  addToMatStore( mat.constituent( findex ).first, matStore );
256  }
257  ++findex;
258  }
259  }
260 }
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:87
int noOfConstituents() const
returns the number of compound materials or 0 for elementary materials
Definition: DDMaterial.cc:82
void OutputMagneticFieldDDToDDL::addToSolStore ( const DDSolid sol,
std::set< DDSolid > &  solStore,
std::set< DDRotation > &  rotStore 
)
private

Definition at line 263 of file OutputMagneticFieldDDToDDL.cc.

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

Referenced by beginRun().

264 {
265  solStore.insert( sol );
267  {
268  const DDBooleanSolid& bs ( sol );
269  if( solStore.find(bs.solidA()) == solStore.end())
270  {
271  addToSolStore( bs.solidA(), solStore, rotStore );
272  }
273  if( solStore.find( bs.solidB()) == solStore.end())
274  {
275  addToSolStore( bs.solidB(), solStore, rotStore );
276  }
277  rotStore.insert( bs.rotation());
278  }
279 }
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:138
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 282 of file OutputMagneticFieldDDToDDL.cc.

References DDLogicalPart::attachedSpecifics(), and DEFINE_FWK_MODULE.

Referenced by beginRun().

284 {
285  std::vector<std::pair<const DDPartSelection*, const DDsvalues_type*> >::const_iterator spit( lp.attachedSpecifics().begin()), spend( lp.attachedSpecifics().end());
286  for( ; spit != spend; ++spit )
287  {
288  specStore[ *spit->second ].insert( spit->first );
289  }
290 }
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 42 of file OutputMagneticFieldDDToDDL.cc.

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

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 40 of file OutputMagneticFieldDDToDDL.cc.

References iEvent.

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

Definition at line 101 of file OutputMagneticFieldDDToDDL.cc.

References addToMatStore(), addToSolStore(), addToSpecStore(), 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, DivergingColor::red, DDCoreToDDXMLOutput::rotation(), DDCoreToDDXMLOutput::solid(), DDLogicalPart::solid(), DDCoreToDDXMLOutput::specpar(), and AlCaHLTBitMon_QueryRunRegistry::string.

102 {
103  edm::LogInfo( "OutputMagneticFieldDDToDDL" ) << "OutputMagneticFieldDDToDDL::beginRun";
104 
106  es.get<IdealMagneticFieldRecord>().get( pDD );
107 
108  const auto& gra = pDD->graph();
109 
110  // Temporary stores:
111  std::set<DDLogicalPart> lpStore;
112  std::set<DDMaterial> matStore;
113  std::set<DDSolid> solStore;
114 
115  std::map<const DDsvalues_type, std::set<const DDPartSelection*>, ddsvaluesCmp > specStore;
116  std::set<DDRotation> rotStore;
117 
119 
120  std::string rn = m_fname;
121  size_t foundLastDot= rn.find_last_of('.');
122  size_t foundLastSlash= rn.find_last_of('/');
123 
124  if( foundLastSlash > foundLastDot && foundLastSlash != std::string::npos )
125  {
126  edm::LogError( "OutputMagneticFieldDDToDDL" ) << "What? last . before last / in path for filename... this should die...";
127  }
128  if( foundLastDot != std::string::npos && foundLastSlash != std::string::npos )
129  {
130  out.ns_ = rn.substr( foundLastSlash, foundLastDot );
131  }
132  else if ( foundLastDot != std::string::npos )
133  {
134  out.ns_ = rn.substr(0, foundLastDot);
135  }
136  else
137  {
138  edm::LogError( "OutputMagneticFieldDDToDDL" ) << "What? no file name? Attempt at namespace =\"" << out.ns_ << "\" filename was " << m_fname;
139  }
140 
141  edm::LogInfo( "OutputMagneticFieldDDToDDL" ) << "m_fname=" << m_fname << " namespace = " << out.ns_;
142  std::string ns_ = out.ns_;
143 
144  ( *m_xos ) << std::fixed << std::setprecision( 18 );
145 
146  using Graph = DDCompactView::Graph;
148 
149  adjl_iterator git = gra.begin();
150  adjl_iterator gend = gra.end();
151 
153  ( *m_xos) << "<PosPartSection label=\"" << ns_ << "\">\n";
154  git = gra.begin();
155  for( ; git != gend; ++git )
156  {
157  const DDLogicalPart & ddLP = gra.nodeData( git );
158  if( lpStore.find(ddLP) != lpStore.end())
159  {
160  addToSpecStore( ddLP, specStore );
161  }
162  lpStore.insert( ddLP );
163  addToMatStore( ddLP.material(), matStore );
164  addToSolStore( ddLP.solid(), solStore, rotStore );
165  ++i;
166  if( !git->empty())
167  {
168  // ask for children of ddLP
169  auto cit = git->begin();
170  auto cend = git->end();
171  for( ; cit != cend; ++cit )
172  {
173  const DDLogicalPart & ddcurLP = gra.nodeData( cit->first );
174  if( lpStore.find(ddcurLP) != lpStore.end())
175  {
176  addToSpecStore( ddcurLP, specStore );
177  }
178  lpStore.insert( ddcurLP );
179  addToMatStore( ddcurLP.material(), matStore );
180  addToSolStore( ddcurLP.solid(), solStore, rotStore );
181  rotStore.insert( gra.edgeData( cit->second )->ddrot() );
182  out.position( ddLP, ddcurLP, gra.edgeData( cit->second ), m_rotNumSeed, *m_xos );
183  } // iterate over children
184  } // if (children)
185  } // iterate over graph nodes
186 
187  ( *m_xos ) << "</PosPartSection>\n";
188 
189  ( *m_xos ) << std::scientific << std::setprecision( 18 );
190  std::set<DDMaterial>::const_iterator it( matStore.begin()), ed( matStore.end());
191  ( *m_xos) << "<MaterialSection label=\"" << ns_ << "\">\n";
192  for( ; it != ed; ++it )
193  {
194  if( ! it->isDefined().second ) continue;
195  out.material( *it, *m_xos );
196  }
197  ( *m_xos ) << "</MaterialSection>\n";
198 
199  ( *m_xos ) << "<RotationSection label=\"" << ns_ << "\">\n";
200  ( *m_xos ) << std::fixed << std::setprecision( 18 );
201  std::set<DDRotation>::iterator rit( rotStore.begin()), red( rotStore.end());
202  for( ; rit != red; ++rit )
203  {
204  if( ! rit->isDefined().second ) continue;
205  if( rit->toString() != ":" )
206  {
207  DDRotation r( *rit );
208  out.rotation( r, *m_xos );
209  }
210  }
211  ( *m_xos ) << "</RotationSection>\n";
212 
213  ( *m_xos ) << std::fixed << std::setprecision( 18 );
214  std::set<DDSolid>::const_iterator sit( solStore.begin()), sed( solStore.end());
215  ( *m_xos ) << "<SolidSection label=\"" << ns_ << "\">\n";
216  for( ; sit != sed; ++sit)
217  {
218  if( ! sit->isDefined().second ) continue;
219  out.solid( *sit, *m_xos );
220  }
221  ( *m_xos ) << "</SolidSection>\n";
222 
223  std::set<DDLogicalPart>::iterator lpit( lpStore.begin()), lped( lpStore.end());
224  ( *m_xos ) << "<LogicalPartSection label=\"" << ns_ << "\">\n";
225  for( ; lpit != lped; ++lpit )
226  {
227  if( ! lpit->isDefined().first ) continue;
228  const DDLogicalPart & lp = *lpit;
229  out.logicalPart( lp, *m_xos );
230  }
231  ( *m_xos ) << "</LogicalPartSection>\n";
232 
233  ( *m_xos ) << std::fixed << std::setprecision( 18 );
234  std::map<DDsvalues_type, std::set<const DDPartSelection*> >::const_iterator mit( specStore.begin()), mend( specStore.end());
235  ( *m_xos ) << "<SpecParSection label=\"" << ns_ << "\">\n";
236  for( ; mit != mend; ++mit )
237  {
238  out.specpar( *mit, *m_xos );
239  }
240  ( *m_xos ) << "</SpecParSection>\n";
241 }
void addToSpecStore(const DDLogicalPart &lp, std::map< const DDsvalues_type, std::set< const DDPartSelection * >, ddsvaluesCmp > &specStore)
std::vector< double >::size_type index_type
Definition: Graph.h:16
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.
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:68
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:93
void addToSolStore(const DDSolid &sol, std::set< DDSolid > &solStore, std::set< DDRotation > &rotStore)
void logicalPart(const DDLogicalPart &lp, std::ostream &xos)
Graph::const_adj_iterator adjl_iterator
const Graph & graph() const
Provides read-only access to the data structure of the compact-view.
void material(const DDMaterial &material, std::ostream &xos)
math::Graph< DDLogicalPart, DDPosData * > Graph
Definition: DDCompactView.h:83
adj_list::const_iterator const_adj_iterator
Definition: Graph.h:125
void rotation(const DDRotation &rotation, std::ostream &xos, const std::string &rotn="")
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 44 of file OutputMagneticFieldDDToDDL.cc.

References genParticles_cff::map.

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

Definition at line 43 of file OutputMagneticFieldDDToDDL.cc.

43 {}

Member Data Documentation

std::string OutputMagneticFieldDDToDDL::m_fname
private

Definition at line 52 of file OutputMagneticFieldDDToDDL.cc.

Referenced by beginRun(), and OutputMagneticFieldDDToDDL().

int OutputMagneticFieldDDToDDL::m_rotNumSeed
private

Definition at line 51 of file OutputMagneticFieldDDToDDL.cc.

Referenced by beginRun(), and OutputMagneticFieldDDToDDL().

std::ostream* OutputMagneticFieldDDToDDL::m_xos
private