CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () 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
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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 selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 34 of file OutputMagneticFieldDDToDDL.cc.

Constructor & Destructor Documentation

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

Definition at line 75 of file OutputMagneticFieldDDToDDL.cc.

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

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

Definition at line 91 of file OutputMagneticFieldDDToDDL.cc.

References m_xos.

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

Member Function Documentation

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

Definition at line 228 of file OutputMagneticFieldDDToDDL.cc.

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

Referenced by beginRun().

228  {
229  matStore.insert(mat);
230  if (mat.noOfConstituents() != 0) {
232  int findex(0);
233  while (findex < mat.noOfConstituents()) {
234  if (matStore.find(mat.constituent(findex).first) == matStore.end()) {
235  addToMatStore(mat.constituent(findex).first, matStore);
236  }
237  ++findex;
238  }
239  }
240 }
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:74
int noOfConstituents() const
returns the number of compound materials or 0 for elementary materials
Definition: DDMaterial.cc:72
void OutputMagneticFieldDDToDDL::addToSolStore ( const DDSolid sol,
std::set< DDSolid > &  solStore,
std::set< DDRotation > &  rotStore 
)
private

Definition at line 242 of file OutputMagneticFieldDDToDDL.cc.

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

Referenced by beginRun().

244  {
245  solStore.insert(sol);
248  const DDBooleanSolid& bs(sol);
249  if (solStore.find(bs.solidA()) == solStore.end()) {
250  addToSolStore(bs.solidA(), solStore, rotStore);
251  }
252  if (solStore.find(bs.solidB()) == solStore.end()) {
253  addToSolStore(bs.solidB(), solStore, rotStore);
254  }
255  rotStore.insert(bs.rotation());
256  }
257 }
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:123
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 259 of file OutputMagneticFieldDDToDDL.cc.

References DDLogicalPart::attachedSpecifics().

Referenced by beginRun().

261  {
262  std::vector<std::pair<const DDPartSelection*, const DDsvalues_type*> >::const_iterator spit(
263  lp.attachedSpecifics().begin()),
264  spend(lp.attachedSpecifics().end());
265  for (; spit != spend; ++spit) {
266  specStore[*spit->second].insert(spit->first);
267  }
268 }
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 41 of file OutputMagneticFieldDDToDDL.cc.

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

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 39 of file OutputMagneticFieldDDToDDL.cc.

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

Definition at line 97 of file OutputMagneticFieldDDToDDL.cc.

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

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

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

Definition at line 42 of file OutputMagneticFieldDDToDDL.cc.

42 {}

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