CMS 3D CMS Logo

HcalTB06BeamParametersFromDD.cc
Go to the documentation of this file.
9 
10 #define EDM_ML_DEBUG
11 
14  const std::string& name1,
15  const std::string& name2) {
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 }
42 
45  const std::string& name1,
46  const std::string& name2) {
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>(cms::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 }
72 
74  const std::vector<std::string>& matNames,
75  const std::vector<int>& nocc,
76 #ifdef EDM_ML_DEBUG
77  const std::string& name1,
78  const std::string& name2) {
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 }
110 
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 }
129 
131  std::vector<std::string> tmp;
132  while (fv.firstChild()) {
133  std::string name = static_cast<std::string>(cms::dd::noNamespace(fv.name()));
135  tmp.emplace_back(name);
136  }
137  return tmp;
138 }
mps_fire.i
i
Definition: mps_fire.py:355
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
EDM_ML_DEBUG
#define EDM_ML_DEBUG
Definition: HcalTB06BeamParametersFromDD.cc:10
cms::DDFilteredView
Definition: DDFilteredView.h:65
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
end
#define end
Definition: vmac.h:39
cms::DDFilteredView::name
std::string_view name() const
Definition: DDFilteredView.cc:606
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:54
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:80
DDBase::name
const N & name() const
Definition: DDBase.h:59
cms::dd::noNamespace
std::string_view noNamespace(std::string_view)
Definition: Filter.cc:63
cms::DDFilteredView::firstChild
bool firstChild()
set the current node to the first child
Definition: DDFilteredView.cc:218
dqmdumpme.k
k
Definition: dqmdumpme.py:60
HcalTB06BeamParametersFromDD::getNames
std::vector< std::string > getNames(DDFilteredView &fv)
Definition: HcalTB06BeamParametersFromDD.cc:111
DDValue.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
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:40
edm::LogVerbatim
Definition: MessageLogger.h:297
DDLogicalPart.h
DDValue
Definition: DDValue.h:21
cms::DDFilteredView::materialName
std::string_view materialName() const
Definition: DDFilteredView.cc:612
cms::DDCompactView
Definition: DDCompactView.h:29
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
begin
#define begin
Definition: vmac.h:32