CMS 3D CMS Logo

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

#include <CaloSimParametersFromDD.h>

Public Member Functions

bool build (const DDCompactView *, CaloSimulationParameters &)
 
bool build (const cms::DDCompactView *, CaloSimulationParameters &)
 
 CaloSimParametersFromDD ()=default
 
virtual ~CaloSimParametersFromDD ()
 

Private Member Functions

bool buildParameters (const CaloSimulationParameters &)
 
std::vector< std::string > getNames (const std::string &, const DDsvalues_type &, bool)
 
std::vector< int > getNumbers (const std::string &, const DDsvalues_type &, bool)
 

Detailed Description

Definition at line 14 of file CaloSimParametersFromDD.h.

Constructor & Destructor Documentation

◆ CaloSimParametersFromDD()

CaloSimParametersFromDD::CaloSimParametersFromDD ( )
default

◆ ~CaloSimParametersFromDD()

virtual CaloSimParametersFromDD::~CaloSimParametersFromDD ( )
inlinevirtual

Definition at line 17 of file CaloSimParametersFromDD.h.

17 {}

Member Function Documentation

◆ build() [1/2]

bool CaloSimParametersFromDD::build ( const DDCompactView cpv,
CaloSimulationParameters php 
)

Definition at line 21 of file CaloSimParametersFromDD.cc.

References buildParameters(), CaloSimulationParameters::caloNames_, CaloSimulationParameters::fCaloNames_, ALCARECOTkAlBeamHalo_cff::filter, DDFilteredView::firstChild(), CaloSimulationParameters::fLevels_, getNames(), getNumbers(), CaloSimulationParameters::insideLevel_, CaloSimulationParameters::insideNames_, CaloSimulationParameters::levels_, DDFilteredView::mergedSpecifics(), Skims_PA_cff::name, CaloSimulationParameters::neighbours_, AlCaHLTBitMon_QueryRunRegistry::string, and pfDeepBoostedJetPreprocessParams_cfi::sv.

21  {
22 #ifdef EDM_ML_DEBUG
23  edm::LogVerbatim("HCalGeom")
24  << "Inside CaloSimParametersFromDD::build(const DDCompactView*, CaloSimulationParameters&)";
25 #endif
26  // Get the names
27  std::string attribute = "ReadOutName";
28  std::string name = "CaloHitsTk";
30  DDFilteredView fv(*cpv, filter);
31  fv.firstChild();
32  DDsvalues_type sv(fv.mergedSpecifics());
33  edm::LogVerbatim("HCalGeom") << "Filtered view " << &fv << " after filter with " << sv.size() << " contents";
34 
35  php.caloNames_ = getNames("Calorimeter", sv, false);
36  php.levels_ = getNumbers("Levels", sv, false);
37  php.neighbours_ = getNumbers("Neighbours", sv, false);
38  php.insideNames_ = getNames("Inside", sv, false);
39  php.insideLevel_ = getNumbers("InsideLevel", sv, false);
40  php.fCaloNames_ = getNames("FineCalorimeter", sv, true);
41  php.fLevels_ = getNumbers("FineLevels", sv, true);
42 
43  return this->buildParameters(php);
44 }
Log< level::Info, true > LogVerbatim
std::vector< std::string > insideNames_
std::vector< std::string > getNames(const std::string &, const DDsvalues_type &, bool)
std::vector< std::string > fCaloNames_
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
Definition: DDsvalues.h:12
std::vector< int > getNumbers(const std::string &, const DDsvalues_type &, bool)
bool buildParameters(const CaloSimulationParameters &)
std::vector< std::string > caloNames_

◆ build() [2/2]

bool CaloSimParametersFromDD::build ( const cms::DDCompactView cpv,
CaloSimulationParameters php 
)

Definition at line 46 of file CaloSimParametersFromDD.cc.

References buildParameters(), CaloSimulationParameters::caloNames_, dbl_to_int(), cms::DDCompactView::detector(), CaloSimulationParameters::fCaloNames_, CaloSimulationParameters::fLevels_, CaloSimulationParameters::insideLevel_, CaloSimulationParameters::insideNames_, CaloSimulationParameters::levels_, CaloSimulationParameters::neighbours_, and cms::DDDetector::worldVolume().

46  {
47 #ifdef EDM_ML_DEBUG
48  edm::LogVerbatim("HCalGeom")
49  << "Inside CaloSimParametersFromDD::build(const cms::DDCompactView*, CaloSimulationParameters&)";
50 #endif
51  // Get the names
52  cms::DDFilteredView fv(cpv->detector(), cpv->detector()->worldVolume());
53  php.caloNames_ = fv.get<std::vector<std::string> >("calo", "Calorimeter");
54  php.levels_ = dbl_to_int(fv.get<std::vector<double> >("calo", "Levels"));
55  php.neighbours_ = dbl_to_int(fv.get<std::vector<double> >("calo", "Neighbours"));
56  php.insideNames_ = fv.get<std::vector<std::string> >("calo", "Inside");
57  php.insideLevel_ = dbl_to_int(fv.get<std::vector<double> >("calo", "InsideLevel"));
58  php.fCaloNames_ = fv.get<std::vector<std::string> >("calo", "FineCalorimeter");
59  php.fLevels_ = dbl_to_int(fv.get<std::vector<double> >("calo", "FineLevels"));
60 
61  return this->buildParameters(php);
62 }
Log< level::Info, true > LogVerbatim
std::vector< std::string > insideNames_
const cms::DDDetector * detector() const
Definition: DDCompactView.h:34
std::vector< std::string > fCaloNames_
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:67
bool buildParameters(const CaloSimulationParameters &)
std::vector< std::string > caloNames_

◆ buildParameters()

bool CaloSimParametersFromDD::buildParameters ( const CaloSimulationParameters php)
private

Definition at line 64 of file CaloSimParametersFromDD.cc.

References CaloSimulationParameters::caloNames_, Exception, CaloSimulationParameters::fCaloNames_, CaloSimulationParameters::fLevels_, CaloSimulationParameters::insideLevel_, CaloSimulationParameters::insideNames_, CaloSimulationParameters::levels_, myPrint(), and CaloSimulationParameters::neighbours_.

Referenced by build().

64  {
65 #ifdef EDM_ML_DEBUG
66  myPrint("Calorimeter", php.caloNames_);
67  myPrint("Levels", php.levels_);
68  myPrint("Neighbours", php.neighbours_);
69  myPrint("Inside", php.insideNames_);
70  myPrint("InsideLevel", php.insideLevel_);
71  myPrint("FineCalorimeter", php.fCaloNames_);
72  myPrint("FineLevels", php.fLevels_);
73 #endif
74 
75  if (php.caloNames_.size() < php.neighbours_.size()) {
76  edm::LogError("HCalGeom") << "CaloSimParametersFromDD: # of Calorimeter bins " << php.caloNames_.size()
77  << " does not match with " << php.neighbours_.size() << " ==> illegal ";
78  throw cms::Exception("Unknown", "CaloSimParametersFromDD")
79  << "Calorimeter array size does not match with size of neighbours\n";
80  }
81 
82  return true;
83 }
std::vector< std::string > insideNames_
Log< level::Error, false > LogError
std::vector< std::string > fCaloNames_
void myPrint(std::string value, const std::vector< T > &vec)
std::vector< std::string > caloNames_

◆ getNames()

std::vector< std::string > CaloSimParametersFromDD::getNames ( const std::string &  str,
const DDsvalues_type sv,
bool  ignore 
)
private

Definition at line 85 of file CaloSimParametersFromDD.cc.

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

Referenced by build().

87  {
88 #ifdef EDM_ML_DEBUG
89  edm::LogVerbatim("HCalGeom") << "CaloSimParametersFromDD::getNames called for " << str;
90 #endif
91  DDValue value(str);
92  if (DDfetch(&sv, value)) {
93 #ifdef EDM_ML_DEBUG
94  edm::LogVerbatim("HCalGeom") << value;
95 #endif
96  const std::vector<std::string>& fvec = value.strings();
97  int nval = fvec.size();
98  if ((nval < 1) && (!ignore)) {
99  edm::LogError("HCalGeom") << "CaloSimParametersFromDD: # of " << str << " bins " << nval << " < 1 ==> illegal ";
100  throw cms::Exception("Unknown", "CaloSimParametersFromDD") << "nval < 1 for array " << str << "\n";
101  }
102 
103  return fvec;
104  } else if (ignore) {
105  std::vector<std::string> fvec;
106  return fvec;
107  } else {
108  edm::LogError("HCalGeom") << "CaloSimParametersFromDD: cannot get array " << str;
109  throw cms::Exception("Unknown", "CaloSimParametersFromDD") << "cannot get array " << str << "\n";
110  }
111 }
Log< level::Info, true > LogVerbatim
Log< level::Error, false > LogError
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:79
Definition: value.py:1
def ignore(seq)
#define str(s)

◆ getNumbers()

std::vector< int > CaloSimParametersFromDD::getNumbers ( const std::string &  str,
const DDsvalues_type sv,
bool  ignore 
)
private

Definition at line 113 of file CaloSimParametersFromDD.cc.

References dbl_to_int(), DDfetch(), Exception, SequenceTypes::ignore(), str, pfDeepBoostedJetPreprocessParams_cfi::sv, and relativeConstraints::value.

Referenced by build().

113  {
114 #ifdef EDM_ML_DEBUG
115  edm::LogVerbatim("HCalGeom") << "CaloSimParametersFromDD::getNumbers called for " << str;
116 #endif
117  DDValue value(str);
118  if (DDfetch(&sv, value)) {
119 #ifdef EDM_ML_DEBUG
120  edm::LogVerbatim("HCalGeom") << value;
121 #endif
122  const std::vector<double>& fvec = value.doubles();
123  int nval = fvec.size();
124  if ((nval < 1) && (!ignore)) {
125  edm::LogError("HCalGeom") << "CaloSimParametersFromDD: # of " << str << " bins " << nval << " < 1 ==> illegal ";
126  throw cms::Exception("Unknown", "CaloSimParametersFromDD") << "nval < 2 for array " << str << "\n";
127  }
128  return dbl_to_int(fvec);
129  } else if (ignore) {
130  std::vector<int> fvec;
131  return fvec;
132  } else {
133  edm::LogError("HCalGeom") << "CaloSimParametersFromDD: cannot get array " << str;
134  throw cms::Exception("Unknown", "CaloSimParametersFromDD") << "cannot get array " << str << "\n";
135  }
136 }
Log< level::Info, true > LogVerbatim
Log< level::Error, false > LogError
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:79
Definition: value.py:1
def ignore(seq)
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
#define str(s)