CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FastTimeParametersFromDD.cc
Go to the documentation of this file.
7 
9 #include "CLHEP/Units/GlobalSystemOfUnits.h"
10 #include <iostream>
11 #include <iomanip>
12 
13 //#define EDM_ML_DEBUG
14 
16  FastTimeParameters& php,
17  const std::string& name,
18  const int type) {
19 
20 #ifdef EDM_ML_DEBUG
21  std::cout << "FastTimeParametersFromDD::build called with names " << name
22  << " and type " << type << std::endl;
23 #endif
24 
25  //Special parameters at simulation level
26  std::string attribute = "Volume";
28  DDValue val(attribute, value, 0.0);
30  filter.setCriteria(val, DDCompOp::equals);
31  DDFilteredView fv(*cpv);
32  fv.addFilter(filter);
33  bool ok = fv.firstChild();
34 
35  if (ok) {
37  std::vector<double> temp;
38  if (type == 1) {
39  php.geomParBarrel_ = getDDDArray("geomParsB", sv);
40  temp = getDDDArray("numberZB", sv);
41  php.nZBarrel_ = (int)(temp[0]);
42  temp = getDDDArray("numberPhiB", sv);
43  php.nPhiBarrel_ = (int)(temp[0]);
44 #ifdef EDM_ML_DEBUG
45  std::cout << "Barrel Parameters: " << php.nZBarrel_ << ":"
46  << php.nPhiBarrel_ << ":" << php.geomParBarrel_[0] << ":"
47  << php.geomParBarrel_[1] << std::endl;
48 #endif
49  } else if (type == 2) {
50  php.geomParEndcap_ = getDDDArray("geomParsE", sv);
51  temp = getDDDArray("numberEtaE", sv);
52  php.nEtaEndcap_ = (int)(temp[0]);
53  temp = getDDDArray("numberPhiE", sv);
54  php.nPhiEndcap_ = (int)(temp[0]);
55 #ifdef EDM_ML_DEBUG
56  std::cout << "Endcap Parameters: " << php.nEtaEndcap_ << ":"
57  << php.nPhiEndcap_ << ":" << php.geomParEndcap_[0] << ":"
58  << php.geomParEndcap_[1] << ":" << php.geomParEndcap_[2]
59  << std::endl;
60 #endif
61  } else {
62  edm::LogWarning("HGCalGeom") << "Unknown Geometry type " << type
63  << " for FastTiming " << name;
64  }
65  } else {
66  edm::LogError("HGCalGeom") << " Attribute " << val
67  << " not found but needed.";
68  throw cms::Exception("DDException") << "Attribute " << val
69  << " not found but needed.";
70  }
71 #ifdef EDM_ML_DEBUG
72  std::cout << "FastTimeParametersFromDD::Returns with flag " << ok
73  << " for " << name << " and type " << type << std::endl;
74 #endif
75  return ok;
76 }
77 
78 std::vector<double> FastTimeParametersFromDD::getDDDArray(const std::string & str,
79  const DDsvalues_type & sv) {
80 
81  DDValue value(str);
82  if (DDfetch(&sv,value)) {
83  const std::vector<double> & fvec = value.doubles();
84  int nval = fvec.size();
85  if (nval < 1) {
86  edm::LogError("HGCalGeom") << "HGCalGeomParameters : # of " << str
87  << " bins " << nval << " < 1 ==> illegal";
88  throw cms::Exception("DDException") << "HGCalGeomParameters: cannot get array " << str;
89  }
90  return fvec;
91  } else {
92  edm::LogError("HGCalGeom") << "HGCalGeomParameters: cannot get array "
93  << str;
94  throw cms::Exception("DDException") << "HGCalGeomParameters: cannot get array " << str;
95  }
96 }
type
Definition: HCALResponse.h:21
const std::vector< double > & doubles() const
a reference to the double-valued values stored in the given instance of DDValue
Definition: DDValue.cc:137
void addFilter(const DDFilter &, DDLogOp op=DDLogOp::AND)
std::vector< double > getDDDArray(const std::string &, const DDsvalues_type &)
type of data representation of DDCompactView
Definition: DDCompactView.h:90
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:80
std::vector< double > geomParEndcap_
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
std::maps an index to a DDValue. The index corresponds to the index assigned to the name of the std::...
Definition: DDsvalues.h:20
std::vector< double > geomParBarrel_
bool build(const DDCompactView *, FastTimeParameters &, const std::string &, const int)
DDsvalues_type mergedSpecifics() const
bool firstChild()
set the current node to the first child ...
tuple cout
Definition: gather_cfg.py:145
void setCriteria(const DDValue &nameVal, DDCompOp, DDLogOp l=DDLogOp::AND, bool asString=true, bool merged=true)
Definition: DDFilter.cc:253
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.
Definition: DDFilter.h:33