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 }
Log< level::Info, true > LogVerbatim
bool build(const DDCompactView *cpv, HcalTB06BeamParameters &php, const std::string &name1, const std::string &name2)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
std::string_view name() const
#define EDM_ML_DEBUG
Definition: MPUnpacker.cc:1
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
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
std::string_view materialName() const
std::vector< std::string > getNames(DDFilteredView &fv)
bool firstChild()
set the current node to the first child
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
const N & name() const
Definition: DDBase.h:59
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
std::vector< std::string > wchambers_
bool firstChild()
set the current node to the first child ...
tmp
align.sh
Definition: createJobs.py:716