CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions
EcalSimParametersFromDD Class Reference

#include <EcalSimParametersFromDD.h>

Public Member Functions

bool build (const cms::DDCompactView *, const std::string &name, EcalSimulationParameters &)
 
bool build (const DDCompactView *, const std::string &name, EcalSimulationParameters &)
 
 EcalSimParametersFromDD ()=default
 

Private Member Functions

bool buildParameters (const EcalSimulationParameters &)
 
std::vector< double > getDDDArray (const std::string &, const DDsvalues_type &)
 
std::vector< std::string > getStringArray (const std::string &, const DDsvalues_type &)
 

Detailed Description

Definition at line 14 of file EcalSimParametersFromDD.h.

Constructor & Destructor Documentation

◆ EcalSimParametersFromDD()

EcalSimParametersFromDD::EcalSimParametersFromDD ( )
default

Member Function Documentation

◆ build() [1/2]

bool EcalSimParametersFromDD::build ( const cms::DDCompactView cpv,
const std::string &  name,
EcalSimulationParameters php 
)

Definition at line 98 of file EcalSimParametersFromDD.cc.

100  {
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{dd4hep::dd::noNamespace(fv.name()).data(), dd4hep::dd::noNamespace(fv.name()).size()};
163  const std::string matName{dd4hep::dd::noNamespace(fv.materialName()).data(),
164  dd4hep::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 = (dd4hep::isA<dd4hep::Trap>(fv.solid())) ? convertCmToMm(2 * paras[0]) : 0.0;
170  php.dzs_.emplace_back(dz);
171  }
172  };
173 
174  return this->buildParameters(php);
175 }

References geant_units::operators::convertCmToMm(), data, dbl_to_int(), EcalSimulationParameters::depth1Name_, EcalSimulationParameters::depth2Name_, cms::DDCompactView::detector(), PVValHelper::dz, EcalSimulationParameters::dzs_, EcalSimulationParameters::etaBaskets_, spr::find(), EcalSimulationParameters::lvNames_, EcalSimulationParameters::matNames_, Skims_PA_cff::name, EcalSimulationParameters::ncrys_, EcalSimulationParameters::nmods_, EcalSimulationParameters::nxtalEta_, EcalSimulationParameters::nxtalPhi_, EcalSimulationParameters::phiBaskets_, findQualityFiles::size, cms::DDCompactView::specpars(), AlCaHLTBitMon_QueryRunRegistry::string, EcalSimulationParameters::useWeight_, and cms::DDDetector::worldVolume().

◆ build() [2/2]

bool EcalSimParametersFromDD::build ( const DDCompactView cpv,
const std::string &  name,
EcalSimulationParameters php 
)

Definition at line 26 of file EcalSimParametersFromDD.cc.

26  {
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();
36  DDsvalues_type sv(fv.mergedSpecifics());
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 }

References dbl_to_int(), ddtrap, EcalSimulationParameters::depth1Name_, EcalSimulationParameters::depth2Name_, PVValHelper::dz, EcalSimulationParameters::dzs_, EcalSimulationParameters::etaBaskets_, ALCARECOTkAlBeamHalo_cff::filter, spr::find(), DDFilteredView::firstChild(), DDFilteredView::logicalPart(), EcalSimulationParameters::lvNames_, DDLogicalPart::material(), EcalSimulationParameters::matNames_, DDFilteredView::mergedSpecifics(), Skims_PA_cff::name, DDName::name(), DDBase< N, C >::name(), EcalSimulationParameters::ncrys_, DDFilteredView::next(), EcalSimulationParameters::nmods_, EcalSimulationParameters::nxtalEta_, EcalSimulationParameters::nxtalPhi_, DDSolid::parameters(), EcalSimulationParameters::phiBaskets_, DDSolid::shape(), DDLogicalPart::solid(), AlCaHLTBitMon_QueryRunRegistry::string, pfDeepBoostedJetPreprocessParams_cfi::sv, and EcalSimulationParameters::useWeight_.

Referenced by EcalSimParametersESModule::produce().

◆ buildParameters()

bool EcalSimParametersFromDD::buildParameters ( const EcalSimulationParameters php)
private

Definition at line 177 of file EcalSimParametersFromDD.cc.

177  {
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 }

References EcalSimulationParameters::depth1Name_, EcalSimulationParameters::depth2Name_, EcalSimulationParameters::dzs_, EcalSimulationParameters::etaBaskets_, EcalSimulationParameters::lvNames_, EcalSimulationParameters::matNames_, myPrint(), EcalSimulationParameters::ncrys_, EcalSimulationParameters::nmods_, EcalSimulationParameters::nxtalEta_, EcalSimulationParameters::nxtalPhi_, EcalSimulationParameters::phiBaskets_, and EcalSimulationParameters::useWeight_.

◆ getDDDArray()

std::vector< double > EcalSimParametersFromDD::getDDDArray ( const std::string &  str,
const DDsvalues_type sv 
)
private

Definition at line 191 of file EcalSimParametersFromDD.cc.

191  {
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 }

References DDfetch(), str, pfDeepBoostedJetPreprocessParams_cfi::sv, and relativeConstraints::value.

◆ getStringArray()

std::vector< std::string > EcalSimParametersFromDD::getStringArray ( const std::string &  str,
const DDsvalues_type sv 
)
private

Definition at line 208 of file EcalSimParametersFromDD.cc.

208  {
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 }

References DDfetch(), str, pfDeepBoostedJetPreprocessParams_cfi::sv, and relativeConstraints::value.

DDSolidShape::ddtrap
EcalSimParametersFromDD::buildParameters
bool buildParameters(const EcalSimulationParameters &)
Definition: EcalSimParametersFromDD.cc:177
cms::DDSpecParRefs
dd4hep::SpecParRefs DDSpecParRefs
Definition: DDCompactView.h:29
cms::DDFilteredView
Definition: DDFilteredView.h:70
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
cms::DDSpecParRegistry
dd4hep::SpecParRegistry DDSpecParRegistry
Definition: DDCompactView.h:28
pfDeepBoostedJetPreprocessParams_cfi.sv
sv
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:352
str
#define str(s)
Definition: TestProcessor.cc:51
DDfetch
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:79
ALCARECOTkAlBeamHalo_cff.filter
filter
Definition: ALCARECOTkAlBeamHalo_cff.py:27
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
geant_units::operators::convertCmToMm
constexpr NumType convertCmToMm(NumType centimeters)
Definition: GeantUnits.h:68
cms::DDDetector::worldVolume
dd4hep::Volume worldVolume() const
Handle to the world volume containing everything.
Definition: DDDetector.cc:40
EcalSimulationParameters::nmods_
int nmods_
Definition: EcalSimulationParameters.h:16
value
Definition: value.py:1
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:35
EcalSimulationParameters::matNames_
std::vector< std::string > matNames_
Definition: EcalSimulationParameters.h:21
PVValHelper::dz
Definition: PVValidationHelpers.h:50
DDValue
Definition: DDValue.h:21
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
relativeConstraints.value
value
Definition: relativeConstraints.py:53
EcalSimulationParameters::lvNames_
std::vector< std::string > lvNames_
Definition: EcalSimulationParameters.h:20
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
cms::DDCompactView::detector
const cms::DDDetector * detector() const
Definition: DDCompactView.h:34
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443