CMS 3D CMS Logo

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 ( )
default
virtual CaloSimParametersFromDD::~CaloSimParametersFromDD ( )
inlinevirtual

Member Function Documentation

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

Definition at line 23 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.

Referenced by ~CaloSimParametersFromDD().

23  {
24 #ifdef EDM_ML_DEBUG
25  edm::LogVerbatim("HCalGeom")
26  << "Inside CaloSimParametersFromDD::build(const DDCompactView*, CaloSimulationParameters&)";
27 #endif
28  // Get the names
29  std::string attribute = "ReadOutName";
30  std::string name = "CaloHitsTk";
31  DDSpecificsMatchesValueFilter filter{DDValue(attribute, name, 0)};
32  DDFilteredView fv(*cpv, filter);
33  fv.firstChild();
34  DDsvalues_type sv(fv.mergedSpecifics());
35 
36  php.caloNames_ = getNames("Calorimeter", sv, false);
37  php.levels_ = getNumbers("Levels", sv, false);
38  php.neighbours_ = getNumbers("Neighbours", sv, false);
39  php.insideNames_ = getNames("Inside", sv, false);
40  php.insideLevel_ = getNumbers("InsideLevel", sv, false);
41  php.fCaloNames_ = getNames("FineCalorimeter", sv, true);
42  php.fLevels_ = getNumbers("FineLevels", sv, true);
43 
44  return this->buildParameters(php);
45 }
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_
bool CaloSimParametersFromDD::build ( const cms::DDCompactView cpv,
CaloSimulationParameters php 
)

Definition at line 47 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().

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

Definition at line 65 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(), and ~CaloSimParametersFromDD().

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

Definition at line 86 of file CaloSimParametersFromDD.cc.

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

Referenced by build(), and ~CaloSimParametersFromDD().

88  {
89 #ifdef EDM_ML_DEBUG
90  edm::LogVerbatim("HCalGeom") << "CaloSimParametersFromDD::getNames called for " << str;
91 #endif
92  DDValue value(str);
93  if (DDfetch(&sv, value)) {
94 #ifdef EDM_ML_DEBUG
95  edm::LogVerbatim("HCalGeom") << value;
96 #endif
97  const std::vector<std::string>& fvec = value.strings();
98  int nval = fvec.size();
99  if ((nval < 1) && (!ignore)) {
100  edm::LogError("HCalGeom") << "CaloSimParametersFromDD: # of " << str << " bins " << nval << " < 1 ==> illegal ";
101  throw cms::Exception("Unknown", "CaloSimParametersFromDD") << "nval < 2 for array " << str << "\n";
102  }
103 
104  return fvec;
105  } else if (ignore) {
106  std::vector<std::string> fvec;
107  return fvec;
108  } else {
109  edm::LogError("HCalGeom") << "CaloSimParametersFromDD: cannot get array " << str;
110  throw cms::Exception("Unknown", "CaloSimParametersFromDD") << "cannot get array " << str << "\n";
111  }
112 }
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)
std::vector< int > CaloSimParametersFromDD::getNumbers ( const std::string &  str,
const DDsvalues_type sv,
bool  ignore 
)
private

Definition at line 114 of file CaloSimParametersFromDD.cc.

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

Referenced by build(), and ~CaloSimParametersFromDD().

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