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
 
 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

edm::ESGetToken< DDCompactView, IdealMagneticFieldRecordddToken_
 
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< Bconsumes (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 ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
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::OutputMagneticFieldDDToDDL ( const edm::ParameterSet iConfig)
explicit

Definition at line 76 of file OutputMagneticFieldDDToDDL.cc.

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

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

◆ ~OutputMagneticFieldDDToDDL()

OutputMagneticFieldDDToDDL::~OutputMagneticFieldDDToDDL ( void  )
override

Definition at line 94 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

◆ addToMatStore()

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

Definition at line 230 of file OutputMagneticFieldDDToDDL.cc.

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

Referenced by beginRun().

230  {
231  matStore.insert(mat);
232  if (mat.noOfConstituents() != 0) {
234  int findex(0);
235  while (findex < mat.noOfConstituents()) {
236  if (matStore.find(mat.constituent(findex).first) == matStore.end()) {
237  addToMatStore(mat.constituent(findex).first, matStore);
238  }
239  ++findex;
240  }
241  }
242 }
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

◆ addToSolStore()

void OutputMagneticFieldDDToDDL::addToSolStore ( const DDSolid sol,
std::set< DDSolid > &  solStore,
std::set< DDRotation > &  rotStore 
)
private

Definition at line 244 of file OutputMagneticFieldDDToDDL.cc.

References cms::cuda::bs, ddintersection, ddsubtraction, ddunion, and mkfit::Const::sol.

Referenced by beginRun().

246  {
247  solStore.insert(sol);
248  if (sol.shape() == DDSolidShape::ddunion || sol.shape() == DDSolidShape::ddsubtraction ||
249  sol.shape() == DDSolidShape::ddintersection) {
250  const DDBooleanSolid& bs(sol);
251  if (solStore.find(bs.solidA()) == solStore.end()) {
252  addToSolStore(bs.solidA(), solStore, rotStore);
253  }
254  if (solStore.find(bs.solidB()) == solStore.end()) {
255  addToSolStore(bs.solidB(), solStore, rotStore);
256  }
257  rotStore.insert(bs.rotation());
258  }
259 }
void addToSolStore(const DDSolid &sol, std::set< DDSolid > &solStore, std::set< DDRotation > &rotStore)
constexpr float sol
Definition: Config.h:48

◆ addToSpecStore()

void OutputMagneticFieldDDToDDL::addToSpecStore ( const DDLogicalPart lp,
std::map< const DDsvalues_type, std::set< const DDPartSelection *>, ddsvaluesCmp > &  specStore 
)
private

Definition at line 261 of file OutputMagneticFieldDDToDDL.cc.

References DDLogicalPart::attachedSpecifics().

Referenced by beginRun().

263  {
264  std::vector<std::pair<const DDPartSelection*, const DDsvalues_type*> >::const_iterator spit(
265  lp.attachedSpecifics().begin()),
266  spend(lp.attachedSpecifics().end());
267  for (; spit != spend; ++spit) {
268  specStore[*spit->second].insert(spit->first);
269  }
270 }
const std::vector< std::pair< const DDPartSelection *, const DDsvalues_type * > > & attachedSpecifics(void) const

◆ analyze()

void OutputMagneticFieldDDToDDL::analyze ( edm::Event const &  iEvent,
edm::EventSetup const &   
)
inlineoverridevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 41 of file OutputMagneticFieldDDToDDL.cc.

41 {}

◆ beginJob()

void OutputMagneticFieldDDToDDL::beginJob ( )
inlineoverridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 39 of file OutputMagneticFieldDDToDDL.cc.

39 {}

◆ beginRun()

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

Definition at line 100 of file OutputMagneticFieldDDToDDL.cc.

References addToMatStore(), addToSolStore(), addToSpecStore(), ddToken_, alignBH_cfg::fixed, edm::EventSetup::getTransientHandle(), DDCompactView::graph(), mps_fire::i, m_fname, m_rotNumSeed, m_xos, DDLogicalPart::material(), MillePedeFileConverter_cfg::out, alignCSCRings::r, DivergingColor::red, DDLogicalPart::solid(), and AlCaHLTBitMon_QueryRunRegistry::string.

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

◆ endJob()

void OutputMagneticFieldDDToDDL::endJob ( void  )
inlineoverridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 43 of file OutputMagneticFieldDDToDDL.cc.

43 {}

◆ endRun()

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

Definition at line 42 of file OutputMagneticFieldDDToDDL.cc.

42 {}

Member Data Documentation

◆ ddToken_

edm::ESGetToken<DDCompactView, IdealMagneticFieldRecord> OutputMagneticFieldDDToDDL::ddToken_
private

Definition at line 54 of file OutputMagneticFieldDDToDDL.cc.

Referenced by beginRun(), and OutputMagneticFieldDDToDDL().

◆ m_fname

std::string OutputMagneticFieldDDToDDL::m_fname
private

Definition at line 52 of file OutputMagneticFieldDDToDDL.cc.

Referenced by beginRun(), and OutputMagneticFieldDDToDDL().

◆ m_rotNumSeed

int OutputMagneticFieldDDToDDL::m_rotNumSeed
private

Definition at line 51 of file OutputMagneticFieldDDToDDL.cc.

Referenced by beginRun(), and OutputMagneticFieldDDToDDL().

◆ m_xos

std::ostream* OutputMagneticFieldDDToDDL::m_xos
private