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 cms::DDCompactView *cpv, HcalTB06BeamParameters &php, const std::string &name1, const std::string &name2)
 
bool build (const 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 (cms::DDFilteredView &fv)
 
std::vector< std::string > getNames (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 cms::DDCompactView cpv,
HcalTB06BeamParameters php,
const std::string &  name1,
const std::string &  name2 
)

Definition at line 43 of file HcalTB06BeamParametersFromDD.cc.

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

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

◆ build() [2/3]

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

Definition at line 12 of file HcalTB06BeamParametersFromDD.cc.

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

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(), and HcalTB06ParametersESModule::produce().

◆ 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 73 of file HcalTB06BeamParametersFromDD.cc.

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

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

◆ getNames() [1/2]

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

Definition at line 130 of file HcalTB06BeamParametersFromDD.cc.

130  {
131  std::vector<std::string> tmp;
132  while (fv.firstChild()) {
133  std::string name = static_cast<std::string>(dd4hep::dd::noNamespace(fv.name()));
134  if (std::find(std::begin(tmp), std::end(tmp), name) == std::end(tmp))
135  tmp.emplace_back(name);
136  }
137  return tmp;
138 }

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

◆ getNames() [2/2]

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

Definition at line 111 of file HcalTB06BeamParametersFromDD.cc.

111  {
112  std::vector<std::string> tmp;
113  bool dodet = fv.firstChild();
114  while (dodet) {
115  const DDLogicalPart& log = fv.logicalPart();
116  bool ok = true;
117  for (unsigned int i = 0; i < tmp.size(); i++) {
118  if (!strcmp(tmp[i].c_str(), log.name().name().c_str())) {
119  ok = false;
120  break;
121  }
122  }
123  if (ok)
124  tmp.push_back(log.name().name());
125  dodet = fv.next();
126  }
127  return tmp;
128 }

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

Referenced by build().

mps_fire.i
i
Definition: mps_fire.py:428
HcalTB06BeamParameters::wchambers_
std::vector< std::string > wchambers_
Definition: HcalTB06BeamParameters.h:13
DDFilteredView::logicalPart
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
Definition: DDFilteredView.cc:16
cms::DDFilteredView
Definition: DDFilteredView.h:70
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
HcalTB06BeamParametersFromDD::build
bool build(const DDCompactView *cpv, HcalTB06BeamParameters &php, const std::string &name1, const std::string &name2)
Definition: HcalTB06BeamParametersFromDD.cc:12
cms::DDFilteredView::name
std::string_view name() const
Definition: DDFilteredView.cc:853
HcalTB06BeamParameters::material_
std::string material_
Definition: HcalTB06BeamParameters.h:14
DDFilteredView::firstChild
bool firstChild()
set the current node to the first child ...
Definition: DDFilteredView.cc:86
cms::DDFilter
Definition: DDFilteredView.h:59
DDFilteredView::next
bool next()
set current node to the next node in the filtered tree
Definition: DDFilteredView.cc:67
mps_fire.end
end
Definition: mps_fire.py:242
cms::DDFilteredView::firstChild
bool firstChild()
set the current node to the first child
Definition: DDFilteredView.cc:268
dqmdumpme.k
k
Definition: dqmdumpme.py:60
HcalTB06BeamParametersFromDD::getNames
std::vector< std::string > getNames(DDFilteredView &fv)
Definition: HcalTB06BeamParametersFromDD.cc:111
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDLogicalPart
A DDLogicalPart aggregates information concerning material, solid and sensitveness ....
Definition: DDLogicalPart.h:93
DDValue
Definition: DDValue.h:21
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
DDSpecificsMatchesValueFilter
Definition: DDFilter.h:70
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
DDFilteredView
Definition: DDFilteredView.h:20
hfnoseParametersInitialization_cfi.name2
name2
Definition: hfnoseParametersInitialization_cfi.py:8
edm::Log
Definition: MessageLogger.h:70