CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions
HcalTB06BeamParametersFromDD Class Reference

#include <HcalTB06BeamParametersFromDD.h>

Public Member Functions

bool build (const DDCompactView *cpv, HcalTB06BeamParameters &php, const std::string &name1, const std::string &name2)
 
bool build (const cms::DDCompactView *cpv, HcalTB06BeamParameters &php, const std::string &name1, const std::string &name2)
 
 HcalTB06BeamParametersFromDD ()=default
 

Private Member Functions

bool build (HcalTB06BeamParameters &php, const std::vector< std::string > &matNames, const std::vector< int > &nocc, const std::string &name1, const std::string &name2)
 
std::vector< std::string > getNames (DDFilteredView &fv)
 
std::vector< std::string > getNames (cms::DDFilteredView &fv)
 

Detailed Description

Definition at line 12 of file HcalTB06BeamParametersFromDD.h.

Constructor & Destructor Documentation

◆ HcalTB06BeamParametersFromDD()

HcalTB06BeamParametersFromDD::HcalTB06BeamParametersFromDD ( )
default

Member Function Documentation

◆ build() [1/3]

bool HcalTB06BeamParametersFromDD::build ( const DDCompactView cpv,
HcalTB06BeamParameters php,
const std::string &  name1,
const std::string &  name2 
)

Definition at line 10 of file HcalTB06BeamParametersFromDD.cc.

References DDFilteredView::firstChild(), getNames(), mps_fire::i, DDFilteredView::logicalPart(), DDLogicalPart::material(), DDName::name(), DDBase< N, C >::name(), hfnoseParametersInitialization_cfi::name2, DDFilteredView::next(), AlCaHLTBitMon_QueryRunRegistry::string, and HcalTB06BeamParameters::wchambers_.

Referenced by build().

13  {
14  DDSpecificsMatchesValueFilter filter1{DDValue("Volume", name1, 0)};
15  DDFilteredView fv1(*cpv, filter1);
16  php.wchambers_ = getNames(fv1);
17 
18  DDSpecificsMatchesValueFilter filter2{DDValue("ReadOutName", name2, 0)};
19  DDFilteredView fv2(*cpv, filter2);
20  bool dodet = fv2.firstChild();
21  std::vector<std::string> matNames;
22  std::vector<int> nocc;
23  while (dodet) {
24  std::string matName = fv2.logicalPart().material().name().name();
25  bool notIn = true;
26  for (unsigned int i = 0; i < matNames.size(); i++) {
27  if (matName == matNames[i]) {
28  notIn = false;
29  nocc[i]++;
30  }
31  }
32  if (notIn) {
33  matNames.push_back(matName);
34  nocc.push_back(0);
35  }
36  dodet = fv2.next();
37  }
38  return build(php, matNames, nocc, name1, name2);
39 }
bool build(const DDCompactView *cpv, HcalTB06BeamParameters &php, const std::string &name1, const std::string &name2)
std::vector< std::string > getNames(DDFilteredView &fv)
std::vector< std::string > wchambers_

◆ build() [2/3]

bool HcalTB06BeamParametersFromDD::build ( const cms::DDCompactView cpv,
HcalTB06BeamParameters php,
const std::string &  name1,
const std::string &  name2 
)

Definition at line 41 of file HcalTB06BeamParametersFromDD.cc.

References build(), cms::DDFilteredView::firstChild(), getNames(), mps_fire::i, cms::DDFilteredView::materialName(), hfnoseParametersInitialization_cfi::name2, AlCaHLTBitMon_QueryRunRegistry::string, and HcalTB06BeamParameters::wchambers_.

44  {
45  const cms::DDFilter filter1("Volume", name1);
46  cms::DDFilteredView fv1(*cpv, filter1);
47  php.wchambers_ = getNames(fv1);
48 
49  const cms::DDFilter filter2("ReadOutName", name2);
50  cms::DDFilteredView fv2(*cpv, filter2);
51  std::vector<std::string> matNames;
52  std::vector<int> nocc;
53  while (fv2.firstChild()) {
54  std::string matName = static_cast<std::string>(dd4hep::dd::noNamespace(fv2.materialName()));
55  ;
56  bool notIn = true;
57  for (unsigned int i = 0; i < matNames.size(); i++) {
58  if (matName == matNames[i]) {
59  notIn = false;
60  nocc[i]++;
61  }
62  }
63  if (notIn) {
64  matNames.push_back(matName);
65  nocc.push_back(0);
66  }
67  }
68  return build(php, matNames, nocc, name1, name2);
69 }
bool build(const DDCompactView *cpv, HcalTB06BeamParameters &php, const std::string &name1, const std::string &name2)
std::vector< std::string > getNames(DDFilteredView &fv)
std::vector< std::string > wchambers_

◆ build() [3/3]

bool HcalTB06BeamParametersFromDD::build ( HcalTB06BeamParameters php,
const std::vector< std::string > &  matNames,
const std::vector< int > &  nocc,
const std::string &  name1,
const std::string &  name2 
)
private

Definition at line 71 of file HcalTB06BeamParametersFromDD.cc.

References mps_fire::i, dqmdumpme::k, HcalTB06BeamParameters::material_, hfnoseParametersInitialization_cfi::name2, AlCaHLTBitMon_QueryRunRegistry::string, and HcalTB06BeamParameters::wchambers_.

76  {
77  edm::LogVerbatim("HcalTBSim") << "HcalTB06BeamParametersFromDD:: Names to be tested for Volume = " << name1 << ": "
78  << php.wchambers_.size() << " paths";
79  for (unsigned int i = 0; i < php.wchambers_.size(); i++)
80  edm::LogVerbatim("HcalTBSim") << "HcalTB06BeamParametersFromDD:: (" << i << ") " << php.wchambers_[i];
81 #else
82  const std::string&,
83  const std::string&) {
84 #endif
85 
86  if (!matNames.empty()) {
87  php.material_ = matNames[0];
88  int occ = nocc[0];
89  for (unsigned int i = 0; i < matNames.size(); i++) {
90  if (nocc[i] > occ) {
91  occ = nocc[i];
92  php.material_ = matNames[i];
93  }
94  }
95  } else {
96  php.material_ = "Not Found";
97  }
98 #ifdef EDM_ML_DEBUG
99  edm::LogVerbatim("HcalTBSim") << "HcalTB06BeamParametersFromDD: finds " << matNames.size() << " materials for "
100  << name2;
101  for (unsigned k = 0; k < matNames.size(); ++k)
102  edm::LogVerbatim("HcalTBSim") << "[" << k << "] " << matNames[k] << " " << nocc[k];
103  edm::LogVerbatim("HcalTBSim") << "HcalTB06BeamParametersFromDD: Material name for ReadOut = " << name2 << ":"
104  << php.material_;
105 #endif
106  return true;
107 }
Log< level::Info, true > LogVerbatim
std::vector< std::string > wchambers_

◆ getNames() [1/2]

std::vector< std::string > HcalTB06BeamParametersFromDD::getNames ( DDFilteredView fv)
private

Definition at line 109 of file HcalTB06BeamParametersFromDD.cc.

References DDFilteredView::firstChild(), mps_fire::i, dqm-mbProfile::log, DDFilteredView::logicalPart(), DDFilteredView::next(), convertSQLiteXML::ok, and createJobs::tmp.

Referenced by build().

109  {
110  std::vector<std::string> tmp;
111  bool dodet = fv.firstChild();
112  while (dodet) {
113  const DDLogicalPart& log = fv.logicalPart();
114  bool ok = true;
115  for (unsigned int i = 0; i < tmp.size(); i++) {
116  if (!strcmp(tmp[i].c_str(), log.name().name().c_str())) {
117  ok = false;
118  break;
119  }
120  }
121  if (ok)
122  tmp.push_back(log.name().name());
123  dodet = fv.next();
124  }
125  return tmp;
126 }
bool next()
set current node to the next node in the filtered tree
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
bool firstChild()
set the current node to the first child ...
tmp
align.sh
Definition: createJobs.py:716

◆ getNames() [2/2]

std::vector< std::string > HcalTB06BeamParametersFromDD::getNames ( cms::DDFilteredView fv)
private

Definition at line 128 of file HcalTB06BeamParametersFromDD.cc.

References mps_fire::end, spr::find(), cms::DDFilteredView::firstChild(), Skims_PA_cff::name, cms::DDFilteredView::name(), AlCaHLTBitMon_QueryRunRegistry::string, and createJobs::tmp.

128  {
129  std::vector<std::string> tmp;
130  while (fv.firstChild()) {
131  std::string name = static_cast<std::string>(dd4hep::dd::noNamespace(fv.name()));
132  if (std::find(std::begin(tmp), std::end(tmp), name) == std::end(tmp))
133  tmp.emplace_back(name);
134  }
135  return tmp;
136 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::string_view name() const
bool firstChild()
set the current node to the first child
tmp
align.sh
Definition: createJobs.py:716