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 () 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, IdealGeometryRecordddToken_
 
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 36 of file OutputDDToDDL.cc.

Constructor & Destructor Documentation

◆ OutputDDToDDL()

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

Definition at line 79 of file OutputDDToDDL.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.

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

◆ ~OutputDDToDDL()

OutputDDToDDL::~OutputDDToDDL ( )
override

Definition at line 97 of file OutputDDToDDL.cc.

References m_xos.

97  {
98  (*m_xos) << "</DDDefinition>" << std::endl;
99  (*m_xos) << std::endl;
100  m_xos->flush();
101 }
std::ostream * m_xos

Member Function Documentation

◆ addToMatStore()

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

Definition at line 230 of file OutputDDToDDL.cc.

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

Referenced by beginRun().

230  {
231  matStore.insert(mat);
232  if (mat.noOfConstituents() != 0) {
233  int findex(0);
234  while (findex < mat.noOfConstituents()) {
235  if (matStore.find(mat.constituent(findex).first) == matStore.end()) {
236  addToMatStore(mat.constituent(findex).first, matStore);
237  }
238  ++findex;
239  }
240  }
241 }
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 OutputDDToDDL::addToSolStore ( const DDSolid sol,
std::set< DDSolid > &  solStore,
std::set< DDRotation > &  rotStore 
)
private

Definition at line 243 of file OutputDDToDDL.cc.

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

Referenced by beginRun().

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

◆ addToSpecStore()

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

Definition at line 258 of file OutputDDToDDL.cc.

References DDLogicalPart::attachedSpecifics().

Referenced by beginRun().

260  {
261  for (auto spit : lp.attachedSpecifics()) {
262  specStore[*spit.second].insert(spit.first);
263  }
264 }
const std::vector< std::pair< const DDPartSelection *, const DDsvalues_type * > > & attachedSpecifics(void) const

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 43 of file OutputDDToDDL.cc.

43 {}

◆ beginJob()

void OutputDDToDDL::beginJob ( void  )
inlineoverridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 41 of file OutputDDToDDL.cc.

41 {}

◆ beginRun()

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

Definition at line 103 of file OutputDDToDDL.cc.

References addToMatStore(), addToSolStore(), addToSpecStore(), gather_cfg::cout, 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.

103  {
104  std::cout << "OutputDDToDDL::beginRun" << std::endl;
105 
106  edm::ESTransientHandle<DDCompactView> pDD = es.getTransientHandle(ddToken_);
107 
108  using Graph = DDCompactView::Graph;
110 
111  const auto& gra = pDD->graph();
112  // temporary stores:
113  std::set<DDLogicalPart> lpStore;
114  std::set<DDMaterial> matStore;
115  std::set<DDSolid> solStore;
116  // 2009-08-19: MEC: I've tried this with set<DDPartSelection> and
117  // had to write operator< for DDPartSelection and DDPartSelectionLevel
118  // the output from such an effort is different than this one.
119  std::map<const DDsvalues_type, std::set<const DDPartSelection*>, ddsvaluesCmp> specStore;
120  std::set<DDRotation> rotStore;
121 
123 
124  std::string rn = m_fname;
125  size_t foundLastDot = rn.find_last_of('.');
126  size_t foundLastSlash = rn.find_last_of('/');
127  if (foundLastSlash > foundLastDot && foundLastSlash != std::string::npos) {
128  std::cout << "What? last . before last / in path for filename... this should die..." << std::endl;
129  }
130  if (foundLastDot != std::string::npos && foundLastSlash != std::string::npos) {
131  out.ns_ = rn.substr(foundLastSlash, foundLastDot);
132  } else if (foundLastDot != std::string::npos) {
133  out.ns_ = rn.substr(0, foundLastDot);
134  } else {
135  std::cout << "What? no file name? Attempt at namespace =\"" << out.ns_ << "\" filename was " << m_fname
136  << std::endl;
137  }
138  std::cout << "m_fname = " << m_fname << " namespace = " << out.ns_ << std::endl;
139  std::string ns_ = out.ns_;
140 
141  (*m_xos) << std::fixed << std::setprecision(18);
142 
143  adjl_iterator git = gra.begin();
144  adjl_iterator gend = gra.end();
145 
146  Graph::index_type i = 0;
147  (*m_xos) << "<PosPartSection label=\"" << ns_ << "\">" << std::endl;
148  git = gra.begin();
149  for (; git != gend; ++git) {
150  const DDLogicalPart& ddLP = gra.nodeData(git);
151  if (lpStore.find(ddLP) != lpStore.end()) {
152  addToSpecStore(ddLP, specStore);
153  }
154  lpStore.insert(ddLP);
155  addToMatStore(ddLP.material(), matStore);
156  addToSolStore(ddLP.solid(), solStore, rotStore);
157  ++i;
158  if (!git->empty()) {
159  // ask for children of ddLP
160  auto cit = git->begin();
161  auto cend = git->end();
162  for (; cit != cend; ++cit) {
163  const DDLogicalPart& ddcurLP = gra.nodeData(cit->first);
164  if (lpStore.find(ddcurLP) != lpStore.end()) {
165  addToSpecStore(ddcurLP, specStore);
166  }
167  lpStore.insert(ddcurLP);
168  addToMatStore(ddcurLP.material(), matStore);
169  addToSolStore(ddcurLP.solid(), solStore, rotStore);
170  rotStore.insert(gra.edgeData(cit->second)->ddrot());
171  out.position(ddLP, ddcurLP, gra.edgeData(cit->second), m_rotNumSeed, *m_xos);
172  } // iterate over children
173  } // if (children)
174  } // iterate over graph nodes
175 
176  (*m_xos) << "</PosPartSection>" << std::endl;
177 
178  (*m_xos) << std::scientific << std::setprecision(18);
179 
180  (*m_xos) << "<MaterialSection label=\"" << ns_ << "\">" << std::endl;
181  for (const auto& it : matStore) {
182  if (!it.isDefined().second)
183  continue;
184  out.material(it, *m_xos);
185  }
186  (*m_xos) << "</MaterialSection>" << std::endl;
187  (*m_xos) << "<RotationSection label=\"" << ns_ << "\">" << std::endl;
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>" << std::endl;
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_ << "\">" << std::endl;
203  for (; sit != sed; ++sit) {
204  if (!sit->isDefined().second)
205  continue;
206  out.solid(*sit, *m_xos);
207  }
208  (*m_xos) << "</SolidSection>" << std::endl;
209 
210  std::set<DDLogicalPart>::iterator lpit(lpStore.begin()), lped(lpStore.end());
211  (*m_xos) << "<LogicalPartSection label=\"" << ns_ << "\">" << std::endl;
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>" << std::endl;
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_ << "\">" << std::endl;
224  for (; mit != mend; ++mit) {
225  out.specpar(*mit, *m_xos);
226  }
227  (*m_xos) << "</SpecParSection>" << std::endl;
228 }
math::Graph< DDLogicalPart, DDPosData * > Graph
Definition: DDCompactView.h:83
std::vector< double >::size_type index_type
Definition: Graph.h:15
std::string m_fname
void addToMatStore(const DDMaterial &mat, std::set< DDMaterial > &matStore)
void addToSpecStore(const DDLogicalPart &lp, std::map< const DDsvalues_type, std::set< const DDPartSelection *>, ddsvaluesCmp > &specStore)
void addToSolStore(const DDSolid &sol, std::set< DDSolid > &solStore, std::set< DDRotation > &rotStore)
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
std::ostream * m_xos
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
Graph::const_adj_iterator adjl_iterator
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
edm::ESGetToken< DDCompactView, IdealGeometryRecord > ddToken_
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 OutputDDToDDL::endJob ( void  )
inlineoverridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 45 of file OutputDDToDDL.cc.

45 {}

◆ endRun()

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

Definition at line 44 of file OutputDDToDDL.cc.

44 {}

Member Data Documentation

◆ ddToken_

edm::ESGetToken<DDCompactView, IdealGeometryRecord> OutputDDToDDL::ddToken_
private

Definition at line 56 of file OutputDDToDDL.cc.

Referenced by beginRun(), and OutputDDToDDL().

◆ m_fname

std::string OutputDDToDDL::m_fname
private

Definition at line 54 of file OutputDDToDDL.cc.

Referenced by beginRun(), and OutputDDToDDL().

◆ m_rotNumSeed

int OutputDDToDDL::m_rotNumSeed
private

Definition at line 53 of file OutputDDToDDL.cc.

Referenced by beginRun(), and OutputDDToDDL().

◆ m_xos

std::ostream* OutputDDToDDL::m_xos
private

Definition at line 55 of file OutputDDToDDL.cc.

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