CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions
EcalSimParametersFromDD Class Reference

#include <EcalSimParametersFromDD.h>

Public Member Functions

bool build (const DDCompactView *, const std::string &name, EcalSimulationParameters &)
 
bool build (const cms::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 ( )
default

Member Function Documentation

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

Definition at line 23 of file EcalSimParametersFromDD.cc.

References buildParameters(), dbl_to_int(), ddtrap, EcalSimulationParameters::depth1Name_, EcalSimulationParameters::depth2Name_, PVValHelper::dz, EcalSimulationParameters::dzs_, EcalSimulationParameters::etaBaskets_, alcazmumu_cfi::filter, spr::find(), DDFilteredView::firstChild(), getDDDArray(), getStringArray(), DDFilteredView::logicalPart(), EcalSimulationParameters::lvNames_, DDLogicalPart::material(), EcalSimulationParameters::matNames_, DDFilteredView::mergedSpecifics(), DDName::name(), DDBase< N, C >::name(), EcalSimulationParameters::ncrys_, DDFilteredView::next(), EcalSimulationParameters::nmods_, EcalSimulationParameters::nxtalEta_, EcalSimulationParameters::nxtalPhi_, DDSolid::parameters(), EcalSimulationParameters::phiBaskets_, DDSolid::shape(), mkfit::Const::sol, DDLogicalPart::solid(), AlCaHLTBitMon_QueryRunRegistry::string, EcalSimulationParameters::useWeight_, and gpuVertexFinder::while().

23  {
24 #ifdef EDM_ML_DEBUG
25  edm::LogVerbatim("EcalGeom")
26  << "Inside EcalSimParametersFromDD::build(const DDCompactView*, const std::string&, EcalSimulationParameters&)";
27 #endif
28  // Get the filtered view
29  std::string attribute = "ReadOutName";
31  DDFilteredView fv(*cpv, filter);
32  bool dodet = fv.firstChild();
33  DDsvalues_type sv(fv.mergedSpecifics());
34 
35  //First the specpars
36  php.useWeight_ = true;
37  std::vector<double> tempD = getDDDArray("EnergyWeight", sv);
38  if (!tempD.empty()) {
39  if (tempD[0] < 0.1)
40  php.useWeight_ = false;
41  }
42  tempD = getDDDArray("nxtalEta", sv);
43  if (tempD.empty())
44  php.nxtalEta_ = 0;
45  else
46  php.nxtalEta_ = static_cast<int>(tempD[0]);
47  tempD = getDDDArray("nxtalPhi", sv);
48  if (tempD.empty())
49  php.nxtalPhi_ = 0;
50  else
51  php.nxtalPhi_ = static_cast<int>(tempD[0]);
52  tempD = getDDDArray("PhiBaskets", sv);
53  if (tempD.empty())
54  php.phiBaskets_ = 0;
55  else
56  php.phiBaskets_ = static_cast<int>(tempD[0]);
57  php.etaBaskets_ = dbl_to_int(getDDDArray("EtaBaskets", sv));
58  tempD = getDDDArray("ncrys", sv);
59  if (tempD.empty())
60  php.ncrys_ = 0;
61  else
62  php.ncrys_ = static_cast<int>(tempD[0]);
63  tempD = getDDDArray("nmods", sv);
64  if (tempD.empty())
65  php.nmods_ = 0;
66  else
67  php.nmods_ = static_cast<int>(tempD[0]);
68 
69  std::vector<std::string> tempS = getStringArray("Depth1Name", sv);
70  if (!tempS.empty())
71  php.depth1Name_ = tempS[0];
72  else
73  php.depth1Name_ = " ";
74  tempS = getStringArray("Depth2Name", sv);
75  if (!tempS.empty())
76  php.depth2Name_ = tempS[0];
77  else
78  php.depth2Name_ = " ";
79 
80  //Then the logical volumes
81  while (dodet) {
82  if (std::find(php.lvNames_.begin(), php.lvNames_.end(), fv.logicalPart().name().name()) == php.lvNames_.end()) {
83  php.matNames_.emplace_back(fv.logicalPart().material().name().name());
84  php.lvNames_.emplace_back(fv.logicalPart().name().name());
85  const DDSolid& sol = fv.logicalPart().solid();
86  const std::vector<double>& paras = sol.parameters();
87  double dz = (sol.shape() == DDSolidShape::ddtrap) ? (2 * paras[0]) : 0.0;
88  php.dzs_.emplace_back(dz);
89  }
90  dodet = fv.next();
91  }
92  return this->buildParameters(php);
93 }
Log< level::Info, true > LogVerbatim
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:125
std::vector< std::string > lvNames_
std::vector< std::string > getStringArray(const std::string &, const DDsvalues_type &)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
std::vector< std::string > matNames_
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
Definition: DDsvalues.h:12
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:123
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
constexpr float sol
Definition: Config.h:48
std::vector< double > getDDDArray(const std::string &, const DDsvalues_type &)
while(__syncthreads_or(more))
bool buildParameters(const EcalSimulationParameters &)
bool EcalSimParametersFromDD::build ( const cms::DDCompactView cpv,
const std::string &  name,
EcalSimulationParameters php 
)

Definition at line 95 of file EcalSimParametersFromDD.cc.

References buildParameters(), data, dbl_to_int(), EcalSimulationParameters::depth1Name_, EcalSimulationParameters::depth2Name_, cms::DDCompactView::detector(), PVValHelper::dz, EcalSimulationParameters::dzs_, EcalSimulationParameters::etaBaskets_, spr::find(), EcalSimulationParameters::lvNames_, EcalSimulationParameters::matNames_, mergeVDriftHistosByStation::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().

97  {
98 #ifdef EDM_ML_DEBUG
99  edm::LogVerbatim("EcalGeom") << "Inside EcalSimParametersFromDD::build(const cms::DDCompactView*, const std::string, "
100  "EcalSimulationParameters&)";
101 #endif
102  // Get the filtered view
103  std::string attribute = "ReadOutName";
104  cms::DDFilteredView fv(cpv->detector(), cpv->detector()->worldVolume());
105 
106  //First the specpars
107  std::string specName = ((name == "EcalHitsEE") ? "ecal_ee" : ((name == "EcalHitsES") ? "ecal_sf" : "ecal_eb"));
108 
109  php.useWeight_ = true;
110  std::vector<double> tempD = fv.get<std::vector<double> >(specName, "EnergyWeight");
111  if (!tempD.empty()) {
112  if (tempD[0] < 0.1)
113  php.useWeight_ = false;
114  }
115  tempD = fv.get<std::vector<double> >(specName, "nxtalEta");
116  if (tempD.empty())
117  php.nxtalEta_ = 0;
118  else
119  php.nxtalEta_ = static_cast<int>(tempD[0]);
120  tempD = fv.get<std::vector<double> >(specName, "nxtalPhi");
121  if (tempD.empty())
122  php.nxtalPhi_ = 0;
123  else
124  php.nxtalPhi_ = static_cast<int>(tempD[0]);
125  tempD = fv.get<std::vector<double> >(specName, "PhiBaskets");
126  if (tempD.empty())
127  php.phiBaskets_ = 0;
128  else
129  php.phiBaskets_ = static_cast<int>(tempD[0]);
130  php.etaBaskets_ = dbl_to_int(fv.get<std::vector<double> >(specName, "EtaBaskets"));
131  tempD = fv.get<std::vector<double> >(specName, "ncrys");
132  if (tempD.empty())
133  php.ncrys_ = 0;
134  else
135  php.ncrys_ = static_cast<int>(tempD[0]);
136  tempD = fv.get<std::vector<double> >(specName, "nmods");
137  if (tempD.empty())
138  php.nmods_ = 0;
139  else
140  php.nmods_ = static_cast<int>(tempD[0]);
141 
142  std::vector<std::string> tempS = fv.get<std::vector<std::string> >(specName, "Depth1Name");
143  if (!tempS.empty())
144  php.depth1Name_ = tempS[0];
145  else
146  php.depth1Name_ = " ";
147  tempS = fv.get<std::vector<std::string> >(specName, "Depth2Name");
148  if (!tempS.empty())
149  php.depth2Name_ = tempS[0];
150  else
151  php.depth2Name_ = " ";
152 
153  //Then the logical volumes
154  cms::DDSpecParRefs refs;
155  const cms::DDSpecParRegistry& mypar = cpv->specpars();
156  mypar.filter(refs, attribute, name);
157  fv.mergedSpecifics(refs);
158  while (fv.firstChild()) {
159  const std::string name{dd4hep::dd::noNamespace(fv.name()).data(), dd4hep::dd::noNamespace(fv.name()).size()};
160  const std::string matName{dd4hep::dd::noNamespace(fv.materialName()).data(),
161  dd4hep::dd::noNamespace(fv.materialName()).size()};
162  if (std::find(php.lvNames_.begin(), php.lvNames_.end(), name) == php.lvNames_.end()) {
163  php.matNames_.emplace_back(matName);
164  php.lvNames_.emplace_back(name);
165  const std::vector<double>& paras = fv.parameters();
166  double dz = (dd4hep::isA<dd4hep::Trap>(fv.solid())) ? ((2.0 * paras[0]) / dd4hep::mm) : 0.0;
167  php.dzs_.emplace_back(dz);
168  }
169  };
170 
171  return this->buildParameters(php);
172 }
Log< level::Info, true > LogVerbatim
std::vector< std::string > lvNames_
dd4hep::SpecParRefs DDSpecParRefs
Definition: DDCompactView.h:29
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
dd4hep::SpecParRegistry DDSpecParRegistry
Definition: DDCompactView.h:28
std::vector< std::string > matNames_
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
dd4hep::Volume worldVolume() const
Handle to the world volume containing everything.
Definition: DDDetector.cc:60
DDSpecParRegistry const & specpars() const
Definition: DDCompactView.h:35
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
tuple size
Write out results.
bool buildParameters(const EcalSimulationParameters &)
const cms::DDDetector * detector() const
Definition: DDCompactView.h:34
bool EcalSimParametersFromDD::buildParameters ( const EcalSimulationParameters php)
private

Definition at line 174 of file EcalSimParametersFromDD.cc.

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_.

Referenced by build().

174  {
175 #ifdef EDM_ML_DEBUG
176  edm::LogVerbatim("EcalGeom") << "EcalSimParametersFromDD:: nxtalEta:" << php.nxtalEta_
177  << " nxtalPhi:" << php.nxtalPhi_ << " phiBaskets:" << php.phiBaskets_
178  << " ncrys:" << php.ncrys_ << " nmods: " << php.nmods_ << " useWeight:" << php.useWeight_
179  << " DeothNames:" << php.depth1Name_ << ":" << php.depth2Name_;
180  myPrint("etaBaskets", php.etaBaskets_);
181  edm::LogVerbatim("EcalGeom") << "EcalSimParametersFromDD:: " << php.lvNames_.size() << " lvNames, "
182  << php.matNames_.size() << " matNames and " << php.dzs_.size() << "dzs";
183 #endif
184 
185  return true;
186 }
Log< level::Info, true > LogVerbatim
std::vector< std::string > lvNames_
void myPrint(std::string value, const std::vector< T > &vec)
std::vector< std::string > matNames_
std::vector< double > EcalSimParametersFromDD::getDDDArray ( const std::string &  str,
const DDsvalues_type sv 
)
private

Definition at line 188 of file EcalSimParametersFromDD.cc.

References DDfetch(), DDValue::doubles(), str, and relativeConstraints::value.

Referenced by build().

188  {
189 #ifdef EDM_ML_DEBUG
190  edm::LogVerbatim("EcalGeom") << "EcalSimParametersFromDD:getDDDArray called for " << str;
191 #endif
192  DDValue value(str);
193  if (DDfetch(&sv, value)) {
194 #ifdef EDM_ML_DEBUG
195  edm::LogVerbatim("EcalGeom") << value;
196 #endif
197  const std::vector<double>& fvec = value.doubles();
198  return fvec;
199  } else {
200  std::vector<double> fvec;
201  return fvec;
202  }
203 }
Log< level::Info, true > LogVerbatim
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:79
#define str(s)
std::vector< std::string > EcalSimParametersFromDD::getStringArray ( const std::string &  str,
const DDsvalues_type sv 
)
private

Definition at line 205 of file EcalSimParametersFromDD.cc.

References DDfetch(), str, DDValue::strings(), and relativeConstraints::value.

Referenced by build().

205  {
206 #ifdef EDM_ML_DEBUG
207  edm::LogVerbatim("EcalGeom") << "EcalSimParametersFromDD:getStringArray called for " << str;
208 #endif
209  DDValue value(str);
210  if (DDfetch(&sv, value)) {
211 #ifdef EDM_ML_DEBUG
212  edm::LogVerbatim("EcalGeom") << value;
213 #endif
214  const std::vector<std::string>& fvec = value.strings();
215  return fvec;
216  } else {
217  std::vector<std::string> fvec;
218  return fvec;
219  }
220 }
Log< level::Info, true > LogVerbatim
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:79
#define str(s)