CMS 3D CMS Logo

HcalTB06BeamParametersFromDD.cc
Go to the documentation of this file.
9 
12  const std::string& name1,
13  const std::string& name2) {
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 }
40 
43  const std::string& name1,
44  const std::string& name2) {
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 }
70 
72  const std::vector<std::string>& matNames,
73  const std::vector<int>& nocc,
74 #ifdef EDM_ML_DEBUG
75  const std::string& name1,
76  const std::string& name2) {
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 }
108 
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 }
127 
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 }
mps_fire.i
i
Definition: mps_fire.py:428
HcalTB06BeamParameters::wchambers_
std::vector< std::string > wchambers_
Definition: HcalTB06BeamParameters.h:13
MessageLogger.h
DDFilteredView::logicalPart
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
Definition: DDFilteredView.cc:16
DDSplit.h
DDLogicalPart::material
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
Definition: DDLogicalPart.cc:118
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:10
cms::DDFilteredView::name
std::string_view name() const
Definition: DDFilteredView.cc:857
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
EDM_ML_DEBUG
#define EDM_ML_DEBUG
Definition: MPUnpacker.cc:1
HcalTB06BeamParameters
Definition: HcalTB06BeamParameters.h:9
DDFilteredView::next
bool next()
set current node to the next node in the filtered tree
Definition: DDFilteredView.cc:67
HcalTB06BeamParametersFromDD.h
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
mps_fire.end
end
Definition: mps_fire.py:242
DDBase::name
const N & name() const
Definition: DDBase.h:59
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:109
DDValue.h
DDLogicalPart
A DDLogicalPart aggregates information concerning material, solid and sensitveness ....
Definition: DDLogicalPart.h:93
DDMaterial.h
DDFilter.h
DDName::name
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
DDLogicalPart.h
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDValue
Definition: DDValue.h:22
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
cms::DDFilteredView::materialName
std::string_view materialName() const
Definition: DDFilteredView.cc:876
cms::DDCompactView
Definition: DDCompactView.h:31
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
DDSpecificsMatchesValueFilter
Definition: DDFilter.h:70
Exception.h
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