CMS 3D CMS Logo

EcalSimParametersFromDD.cc
Go to the documentation of this file.
9 #include <iostream>
10 #include <iomanip>
11 
12 //#define EDM_ML_DEBUG
13 
14 using namespace geant_units::operators;
15 
16 template <typename T>
17 void myPrint(std::string value, const std::vector<T>& vec) {
18  edm::LogVerbatim("EcalGeom") << "EcalSimParametersFromDD: " << vec.size() << " entries for " << value << ":";
19  unsigned int i(0);
20  for (const auto& e : vec) {
21  edm::LogVerbatim("EcalGeom") << " (" << i << ") " << e;
22  ++i;
23  }
24 }
25 
27 #ifdef EDM_ML_DEBUG
28  edm::LogVerbatim("EcalGeom")
29  << "Inside EcalSimParametersFromDD::build(const DDCompactView*, const std::string&, EcalSimulationParameters&)";
30 #endif
31  // Get the filtered view
32  std::string attribute = "ReadOutName";
34  DDFilteredView fv(*cpv, filter);
35  bool dodet = fv.firstChild();
37 
38  //First the specpars
39  php.useWeight_ = true;
40  std::vector<double> tempD = getDDDArray("EnergyWeight", sv);
41  if (!tempD.empty()) {
42  if (tempD[0] < 0.1)
43  php.useWeight_ = false;
44  }
45  tempD = getDDDArray("nxtalEta", sv);
46  if (tempD.empty())
47  php.nxtalEta_ = 0;
48  else
49  php.nxtalEta_ = static_cast<int>(tempD[0]);
50  tempD = getDDDArray("nxtalPhi", sv);
51  if (tempD.empty())
52  php.nxtalPhi_ = 0;
53  else
54  php.nxtalPhi_ = static_cast<int>(tempD[0]);
55  tempD = getDDDArray("PhiBaskets", sv);
56  if (tempD.empty())
57  php.phiBaskets_ = 0;
58  else
59  php.phiBaskets_ = static_cast<int>(tempD[0]);
60  php.etaBaskets_ = dbl_to_int(getDDDArray("EtaBaskets", sv));
61  tempD = getDDDArray("ncrys", sv);
62  if (tempD.empty())
63  php.ncrys_ = 0;
64  else
65  php.ncrys_ = static_cast<int>(tempD[0]);
66  tempD = getDDDArray("nmods", sv);
67  if (tempD.empty())
68  php.nmods_ = 0;
69  else
70  php.nmods_ = static_cast<int>(tempD[0]);
71 
72  std::vector<std::string> tempS = getStringArray("Depth1Name", sv);
73  if (!tempS.empty())
74  php.depth1Name_ = tempS[0];
75  else
76  php.depth1Name_ = " ";
77  tempS = getStringArray("Depth2Name", sv);
78  if (!tempS.empty())
79  php.depth2Name_ = tempS[0];
80  else
81  php.depth2Name_ = " ";
82 
83  //Then the logical volumes
84  while (dodet) {
85  if (std::find(php.lvNames_.begin(), php.lvNames_.end(), fv.logicalPart().name().name()) == php.lvNames_.end()) {
86  php.matNames_.emplace_back(fv.logicalPart().material().name().name());
87  php.lvNames_.emplace_back(fv.logicalPart().name().name());
88  const DDSolid& sol = fv.logicalPart().solid();
89  const std::vector<double>& paras = sol.parameters();
90  double dz = (sol.shape() == DDSolidShape::ddtrap) ? (2 * paras[0]) : 0.0;
91  php.dzs_.emplace_back(dz);
92  }
93  dodet = fv.next();
94  }
95  return this->buildParameters(php);
96 }
97 
99  const std::string& name,
101 #ifdef EDM_ML_DEBUG
102  edm::LogVerbatim("EcalGeom") << "Inside EcalSimParametersFromDD::build(const cms::DDCompactView*, const std::string, "
103  "EcalSimulationParameters&)";
104 #endif
105  // Get the filtered view
106  std::string attribute = "ReadOutName";
107  cms::DDFilteredView fv(cpv->detector(), cpv->detector()->worldVolume());
108 
109  //First the specpars
110  std::string specName = ((name == "EcalHitsEE") ? "ecal_ee" : ((name == "EcalHitsES") ? "ecal_sf" : "ecal_eb"));
111 
112  php.useWeight_ = true;
113  std::vector<double> tempD = fv.get<std::vector<double> >(specName, "EnergyWeight");
114  if (!tempD.empty()) {
115  if (tempD[0] < 0.1)
116  php.useWeight_ = false;
117  }
118  tempD = fv.get<std::vector<double> >(specName, "nxtalEta");
119  if (tempD.empty())
120  php.nxtalEta_ = 0;
121  else
122  php.nxtalEta_ = static_cast<int>(tempD[0]);
123  tempD = fv.get<std::vector<double> >(specName, "nxtalPhi");
124  if (tempD.empty())
125  php.nxtalPhi_ = 0;
126  else
127  php.nxtalPhi_ = static_cast<int>(tempD[0]);
128  tempD = fv.get<std::vector<double> >(specName, "PhiBaskets");
129  if (tempD.empty())
130  php.phiBaskets_ = 0;
131  else
132  php.phiBaskets_ = static_cast<int>(tempD[0]);
133  php.etaBaskets_ = dbl_to_int(fv.get<std::vector<double> >(specName, "EtaBaskets"));
134  tempD = fv.get<std::vector<double> >(specName, "ncrys");
135  if (tempD.empty())
136  php.ncrys_ = 0;
137  else
138  php.ncrys_ = static_cast<int>(tempD[0]);
139  tempD = fv.get<std::vector<double> >(specName, "nmods");
140  if (tempD.empty())
141  php.nmods_ = 0;
142  else
143  php.nmods_ = static_cast<int>(tempD[0]);
144 
145  std::vector<std::string> tempS = fv.get<std::vector<std::string> >(specName, "Depth1Name");
146  if (!tempS.empty())
147  php.depth1Name_ = tempS[0];
148  else
149  php.depth1Name_ = " ";
150  tempS = fv.get<std::vector<std::string> >(specName, "Depth2Name");
151  if (!tempS.empty())
152  php.depth2Name_ = tempS[0];
153  else
154  php.depth2Name_ = " ";
155 
156  //Then the logical volumes
157  cms::DDSpecParRefs refs;
158  const cms::DDSpecParRegistry& mypar = cpv->specpars();
159  mypar.filter(refs, attribute, name);
160  fv.mergedSpecifics(refs);
161  while (fv.firstChild()) {
162  const std::string name{fv.name().data(), fv.name().size()};
163  const std::string matName{cms::dd::noNamespace(fv.materialName()).data(),
164  cms::dd::noNamespace(fv.materialName()).size()};
165  if (std::find(php.lvNames_.begin(), php.lvNames_.end(), name) == php.lvNames_.end()) {
166  php.matNames_.emplace_back(matName);
167  php.lvNames_.emplace_back(name);
168  const std::vector<double>& paras = fv.parameters();
169  double dz = (fv.isATrapezoid()) ? convertCmToMm(2 * paras[0]) : 0.0;
170  php.dzs_.emplace_back(dz);
171  }
172  };
173 
174  return this->buildParameters(php);
175 }
176 
178 #ifdef EDM_ML_DEBUG
179  edm::LogVerbatim("EcalGeom") << "EcalSimParametersFromDD:: nxtalEta:" << php.nxtalEta_
180  << " nxtalPhi:" << php.nxtalPhi_ << " phiBaskets:" << php.phiBaskets_
181  << " ncrys:" << php.ncrys_ << " nmods: " << php.nmods_ << " useWeight:" << php.useWeight_
182  << " DeothNames:" << php.depth1Name_ << ":" << php.depth2Name_;
183  myPrint("etaBaskets", php.etaBaskets_);
184  edm::LogVerbatim("EcalGeom") << "EcalSimParametersFromDD:: " << php.lvNames_.size() << " lvNames, "
185  << php.matNames_.size() << " matNames and " << php.dzs_.size() << "dzs";
186 #endif
187 
188  return true;
189 }
190 
192 #ifdef EDM_ML_DEBUG
193  edm::LogVerbatim("EcalGeom") << "EcalSimParametersFromDD:getDDDArray called for " << str;
194 #endif
195  DDValue value(str);
196  if (DDfetch(&sv, value)) {
197 #ifdef EDM_ML_DEBUG
198  edm::LogVerbatim("EcalGeom") << value;
199 #endif
200  const std::vector<double>& fvec = value.doubles();
201  return fvec;
202  } else {
203  std::vector<double> fvec;
204  return fvec;
205  }
206 }
207 
208 std::vector<std::string> EcalSimParametersFromDD::getStringArray(const std::string& str, const DDsvalues_type& sv) {
209 #ifdef EDM_ML_DEBUG
210  edm::LogVerbatim("EcalGeom") << "EcalSimParametersFromDD:getStringArray called for " << str;
211 #endif
212  DDValue value(str);
213  if (DDfetch(&sv, value)) {
214 #ifdef EDM_ML_DEBUG
215  edm::LogVerbatim("EcalGeom") << value;
216 #endif
217  const std::vector<std::string>& fvec = value.strings();
218  return fvec;
219  } else {
220  std::vector<std::string> fvec;
221  return fvec;
222  }
223 }
mps_fire.i
i
Definition: mps_fire.py:355
DDSolidShape::ddtrap
EcalSimParametersFromDD::buildParameters
bool buildParameters(const EcalSimulationParameters &)
Definition: EcalSimParametersFromDD.cc:177
EcalSimulationParameters
Definition: EcalSimulationParameters.h:6
DDFilteredView::mergedSpecifics
DDsvalues_type mergedSpecifics() const
Definition: DDFilteredView.cc:42
DDFilteredView::logicalPart
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
Definition: DDFilteredView.cc:16
DDLogicalPart::material
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
Definition: DDLogicalPart.cc:118
cms::DDSpecParRegistry
Definition: DDSpecParRegistry.h:32
geant_units::operators
Definition: GeantUnits.h:18
cms::DDFilteredView
Definition: DDFilteredView.h:65
dbl_to_int
std::vector< int > dbl_to_int(const std::vector< double > &vecdbl)
Converts a std::vector of doubles to a std::vector of int.
Definition: DDutils.h:7
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
EcalSimulationParameters::dzs_
std::vector< double > dzs_
Definition: EcalSimulationParameters.h:22
EcalSimParametersFromDD::getStringArray
std::vector< std::string > getStringArray(const std::string &, const DDsvalues_type &)
Definition: EcalSimParametersFromDD.cc:208
DDSolid::shape
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:119
DDFilteredView::firstChild
bool firstChild()
set the current node to the first child ...
Definition: DDFilteredView.cc:86
DDFilteredView.h
DDFilteredView::next
bool next()
set current node to the next node in the filtered tree
Definition: DDFilteredView.cc:67
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
pfDeepBoostedJetPreprocessParams_cfi.sv
sv
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:226
DDBase::name
const N & name() const
Definition: DDBase.h:59
str
#define str(s)
Definition: TestProcessor.cc:48
cms::dd::noNamespace
std::string_view noNamespace(std::string_view)
Definition: Filter.cc:63
DDfetch
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:79
DDFilteredView.h
ALCARECOTkAlBeamHalo_cff.filter
filter
Definition: ALCARECOTkAlBeamHalo_cff.py:27
cms::DDSpecParRefs
std::vector< const DDSpecPar * > DDSpecParRefs
Definition: DDSpecParRegistry.h:30
DDValue.h
EcalSimParametersFromDD::build
bool build(const DDCompactView *, const std::string &name, EcalSimulationParameters &)
Definition: EcalSimParametersFromDD.cc:26
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalSimParametersFromDD.h
geant_units::operators::convertCmToMm
constexpr NumType convertCmToMm(NumType centimeters)
Definition: GeantUnits.h:68
GeantUnits.h
EcalSimulationParameters.h
EcalSimulationParameters::nmods_
int nmods_
Definition: EcalSimulationParameters.h:16
DDutils.h
DDFilter.h
value
Definition: value.py:1
DDName::name
const std::string & name() const
Returns the name.
Definition: DDName.cc:40
edm::LogVerbatim
Definition: MessageLogger.h:297
EcalSimulationParameters::etaBaskets_
std::vector< int > etaBaskets_
Definition: EcalSimulationParameters.h:14
EcalSimulationParameters::depth1Name_
std::string depth1Name_
Definition: EcalSimulationParameters.h:18
EcalSimulationParameters::ncrys_
int ncrys_
Definition: EcalSimulationParameters.h:15
myPrint
void myPrint(std::string value, const std::vector< T > &vec)
Definition: EcalSimParametersFromDD.cc:17
EcalSimulationParameters::phiBaskets_
int phiBaskets_
Definition: EcalSimulationParameters.h:13
EcalSimulationParameters::nxtalEta_
int nxtalEta_
Definition: EcalSimulationParameters.h:11
cms::DDCompactView::specpars
DDSpecParRegistry const & specpars() const
Definition: DDCompactView.h:33
EcalSimulationParameters::matNames_
std::vector< std::string > matNames_
Definition: EcalSimulationParameters.h:21
PVValHelper::dz
Definition: PVValidationHelpers.h:50
DDValue
Definition: DDValue.h:21
relativeConstraints.value
value
Definition: relativeConstraints.py:53
cms::DDSpecParRegistry::filter
void filter(DDSpecParRefs &, const std::string &, const std::string &="") const
Definition: DDSpecparRegistry.cc:98
EcalSimulationParameters::lvNames_
std::vector< std::string > lvNames_
Definition: EcalSimulationParameters.h:20
cms::DDCompactView
Definition: DDCompactView.h:29
EcalSimulationParameters::nxtalPhi_
int nxtalPhi_
Definition: EcalSimulationParameters.h:12
EcalSimulationParameters::depth2Name_
std::string depth2Name_
Definition: EcalSimulationParameters.h:19
DDSolid::parameters
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:121
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
DDSolid
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
DDSpecificsMatchesValueFilter
Definition: DDFilter.h:70
EcalSimParametersFromDD::getDDDArray
std::vector< double > getDDDArray(const std::string &, const DDsvalues_type &)
Definition: EcalSimParametersFromDD.cc:191
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
DDFilteredView
Definition: DDFilteredView.h:20
EcalSimulationParameters::useWeight_
bool useWeight_
Definition: EcalSimulationParameters.h:17
DDsvalues_type
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
Definition: DDsvalues.h:12
DDLogicalPart::solid
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
Definition: DDLogicalPart.cc:120
cms::DDDetector::worldVolume
Volume worldVolume() const
Handle to the world volume containing everything.
Definition: DDDetector.cc:41
cms::DDCompactView::detector
const cms::DDDetector * detector() const
Definition: DDCompactView.h:32
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37