test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalParametersFromDD.cc
Go to the documentation of this file.
9 
11 #include "CLHEP/Units/GlobalSystemOfUnits.h"
12 #include <iostream>
13 #include <iomanip>
14 
15 //#define DebugLog
16 
17 namespace {
18  double getTopologyMode( const char* s, const DDsvalues_type & sv ) {
19  DDValue val( s );
20  if( DDfetch( &sv, val )) {
21  const std::vector<std::string> & fvec = val.strings();
22  if( fvec.size() == 0 ) {
23  throw cms::Exception( "HcalParametersFromDD" ) << "Failed to get " << s << " tag.";
24  }
25 
28 
29  return double( mode );
30  } else {
31  throw cms::Exception( "HcalParametersFromDD" ) << "Failed to get "<< s << " tag.";
32  }
33  }
34 }
35 
37  HcalParameters& php) {
38 
39  //Special parameters at simulation level
40  std::string attribute = "OnlyForHcalSimNumbering";
41  std::string value = "any";
42  DDValue val1(attribute, value, 0.0);
43  DDSpecificsFilter filter1;
44  filter1.setCriteria(val1, DDCompOp::not_equals,
45  DDLogOp::AND, true, // compare strings otherwise doubles
46  true // use merged-specifics or simple-specifics
47  );
48  DDFilteredView fv1(*cpv);
49  fv1.addFilter(filter1);
50  bool ok = fv1.firstChild();
51 
52  const int nEtaMax=100;
53 
54  if (ok) {
56  geom->loadGeometry( fv1, php );
57  php.modHB = geom->getModHalfHBHE(0);
58  php.modHE = geom->getModHalfHBHE(1);
59  php.dzVcal = geom->getConstDzHF();
60  geom->getConstRHO(php.rHO);
61 
62  php.phioff = DDVectorGetter::get( "phioff" );
63  php.etaTable = DDVectorGetter::get( "etaTable" );
64  php.rTable = DDVectorGetter::get( "rTable" );
65  php.phibin = DDVectorGetter::get( "phibin" );
66  php.phitable = DDVectorGetter::get( "phitable" );
67  for (unsigned int i = 1; i<=nEtaMax; ++i) {
68  std::stringstream sstm;
69  sstm << "layerGroupSimEta" << i;
70  std::string tempName = sstm.str();
71  if (DDVectorGetter::check(tempName)) {
72  HcalParameters::LayerItem layerGroupEta;
73  layerGroupEta.layer = i;
74  layerGroupEta.layerGroup = dbl_to_int(DDVectorGetter::get(tempName));
75  php.layerGroupEtaSim.push_back(layerGroupEta);
76  }
77  }
78  php.etaMin = dbl_to_int( DDVectorGetter::get( "etaMin" ));
79  php.etaMax = dbl_to_int( DDVectorGetter::get( "etaMax" ));
80  php.etaMin[0] = 1;
81  php.etaMax[1] = (int)(php.etaTable.size())-1;
82  php.etaMax[2] = php.etaMin[2]+(int)(php.rTable.size())-2;
83  php.etaRange = DDVectorGetter::get( "etaRange" );
84  php.gparHF = DDVectorGetter::get( "gparHF" );
85  php.noff = dbl_to_int( DDVectorGetter::get( "noff" ));
86  php.Layer0Wt = DDVectorGetter::get( "Layer0Wt" );
87  php.HBGains = DDVectorGetter::get( "HBGains" );
88  php.HBShift = dbl_to_int( DDVectorGetter::get( "HBShift" ));
89  php.HEGains = DDVectorGetter::get( "HEGains" );
90  php.HEShift = dbl_to_int( DDVectorGetter::get( "HEShift" ));
91  php.HFGains = DDVectorGetter::get( "HFGains" );
92  php.HFShift = dbl_to_int( DDVectorGetter::get( "HFShift" ));
93  php.maxDepth = dbl_to_int( DDVectorGetter::get( "MaxDepth" ));
94  } else {
95  throw cms::Exception("HcalParametersFromDD") << "Not found "<< attribute.c_str() << " but needed.";
96  }
97  for( unsigned int i = 0; i < php.rTable.size(); ++i ) {
98  unsigned int k = php.rTable.size() - i - 1;
99  php.etaTableHF.push_back( -log( tan( 0.5 * atan( php.rTable[k] / php.gparHF[4] ))));
100  }
101  //Special parameters at reconstruction level
102  attribute = "OnlyForHcalRecNumbering";
103  DDValue val2( attribute, value, 0.0 );
104  DDSpecificsFilter filter2;
105  filter2.setCriteria(val2,
107  DDLogOp::AND, true, // compare strings
108  true // use merged-specifics or simple-specifics
109  );
110  DDFilteredView fv2(*cpv);
111  fv2.addFilter(filter2);
112  ok = fv2.firstChild();
113  if (ok) {
115  php.topologyMode = getTopologyMode("TopologyMode", sv);
116  php.etagroup = dbl_to_int( DDVectorGetter::get( "etagroup" ));
117  php.phigroup = dbl_to_int( DDVectorGetter::get( "phigroup" ));
118  for (unsigned int i = 1; i<=nEtaMax; ++i) {
119  std::stringstream sstm;
120  sstm << "layerGroupRecEta" << i;
121  std::string tempName = sstm.str();
122  if (DDVectorGetter::check(tempName)) {
123  HcalParameters::LayerItem layerGroupEta;
124  layerGroupEta.layer = i;
125  layerGroupEta.layerGroup = dbl_to_int(DDVectorGetter::get(tempName));
126  php.layerGroupEtaRec.push_back(layerGroupEta);
127  }
128  }
129  } else {
130  throw cms::Exception( "HcalParametersFromDD" ) << "Not found "<< attribute.c_str() << " but needed.";
131  }
132 
133 #ifdef DebugLog
134  int i(0);
135  std::cout << "HcalParametersFromDD: MaxDepth: ";
136  for (const auto& it : php.maxDepth) std::cout << it << ", ";
137  std::cout << std::endl;
138  std::cout << "HcalParametersFromDD: ModHB [" << php.modHB.size() << "]: ";
139  for (const auto& it : php.modHB) std::cout << it << ", ";
140  std::cout << std::endl;
141  std::cout << "HcalParametersFromDD: ModHE [" << php.modHE.size() << "]: ";
142  for (const auto& it : php.modHE) std::cout << it << ", ";
143  std::cout << std::endl;
144  std::cout << "HcalParametersFromDD: " << php.phioff.size() << " phioff values";
145  std::vector<double>::const_iterator it;
146  for (it=php.phioff.begin(), i=0; it!=php.phioff.end(); ++it)
147  std::cout << " [" << ++i << "] = " << (*it)/CLHEP::deg;
148  std::cout << std::endl;
149  std::cout << "HcalParametersFromDD: " << php.etaTable.size() << " entries for etaTable";
150  for (it=php.etaTable.begin(), i=0; it!=php.etaTable.end(); ++it)
151  std::cout << " [" << ++i << "] = " << (*it);
152  std::cout << std::endl;
153  std::cout << "HcalParametersFromDD: " << php.rTable.size() << " entries for rTable";
154  for (it=php.rTable.begin(), i=0; it!=php.rTable.end(); ++it)
155  std::cout << " [" << ++i << "] = " << (*it)/CLHEP::cm;
156  std::cout << std::endl;
157  std::cout << "HcalParametersFromDD: " << php.phibin.size() << " phibin values";
158  for (it=php.phibin.begin(), i=0; it!=php.phibin.end(); ++it)
159  std::cout << " [" << ++i << "] = " << (*it)/CLHEP::deg;
160  std::cout << std::endl;
161  std::cout << "HcalParametersFromDD: " << php.phitable.size() << " phitable values";
162  for (it=php.phitable.begin(), i=0; it!=php.phitable.end(); ++it)
163  std::cout << " [" << ++i << "] = " << (*it)/CLHEP::deg;
164  std::cout << std::endl;
165  std::cout << "HcalParametersFromDD: " << php.layerGroupEtaSim.size() << " layerGroupEtaSim blocks" << std::endl;
166  std::vector<HcalParameters::LayerItem>::const_iterator jt;
167  std::vector<int>::const_iterator kt;
168  for (unsigned int k=0; k < php.layerGroupEtaSim.size(); ++k) {
169  std::cout << "layerGroupEtaSim[" << k << "] Layer " << php.layerGroupEtaSim[k].layer;
170  for (kt=php.layerGroupEtaSim[k].layerGroup.begin(), i=0; kt!=php.layerGroupEtaSim[k].layerGroup.end(); ++kt)
171  std::cout << " " << ++i << ":" << (*kt);
172  std::cout << std::endl;
173  }
174  std::cout << "HcalParametersFromDD: " << php.etaMin.size() << " etaMin values";
175  for (kt=php.etaMin.begin(), i=0; kt!=php.etaMin.end(); ++kt)
176  std::cout << " [" << ++i << "] = " << (*kt);
177  std::cout << std::endl;
178  std::cout << "HcalParametersFromDD: " << php.etaMax.size() << " etaMax values";
179  for (kt=php.etaMax.begin(), i=0; kt!=php.etaMax.end(); ++kt)
180  std::cout << " [" << ++i << "] = " << (*kt);
181  std::cout << std::endl;
182  std::cout << "HcalParametersFromDD: " << php.etaRange.size() << " etaRange values";
183  for (it=php.etaRange.begin(), i=0; it!=php.etaRange.end(); ++it)
184  std::cout << " [" << ++i << "] = " << (*it);
185  std::cout << std::endl;
186  std::cout << "HcalParametersFromDD: " << php.gparHF.size() << " gparHF values";
187  for (it=php.gparHF.begin(), i=0; it!=php.gparHF.end(); ++it)
188  std::cout << " [" << ++i << "] = " << (*it)/CLHEP::cm;
189  std::cout << std::endl;
190  std::cout << "HcalParametersFromDD: " << php.noff.size() << " noff values";
191  for (kt=php.noff.begin(), i=0; kt!=php.noff.end(); ++kt)
192  std::cout << " [" << ++i << "] = " << (*kt);
193  std::cout << std::endl;
194  std::cout << "HcalParametersFromDD: " << php.Layer0Wt.size() << " Layer0Wt values";
195  for (it=php.Layer0Wt.begin(), i=0; it!=php.Layer0Wt.end(); ++it)
196  std::cout << " [" << ++i << "] = " << (*it);
197  std::cout << std::endl;
198  std::cout << "HcalParametersFromDD: " << php.HBGains.size() << " Shift/Gains values for HB";
199  for (unsigned k=0; k<php.HBGains.size(); ++k)
200  std::cout << " [" << k << "] = " << php.HBShift[k] << ":" << php.HBGains[k];
201  std::cout << std::endl;
202  std::cout << "HcalParametersFromDD: " << php.HEGains.size() << " Shift/Gains values for HE";
203  for (unsigned k=0; k<php.HEGains.size(); ++k)
204  std::cout << " [" << k << "] = " << php.HEShift[k] << ":" << php.HEGains[k];
205  std::cout << std::endl;
206  std::cout << "HcalParametersFromDD: " << php.HFGains.size() << " Shift/Gains values for HF";
207  for (unsigned k=0; k<php.HFGains.size(); ++k)
208  std::cout << " [" << k << "] = " << php.HFShift[k] << ":" << php.HFGains[k];
209  std::cout << std::endl;
210  std::cout << "HcalParametersFromDD: " << php.etagroup.size() << " etagroup values";
211  for (kt=php.etagroup.begin(), i=0; kt!=php.etagroup.end(); ++kt)
212  std::cout << " [" << ++i << "] = " << (*kt);
213  std::cout << std::endl;
214  std::cout << "HcalParametersFromDD: " << php.phigroup.size() << " phigroup values";
215  for (kt=php.phigroup.begin(), i=0; kt!=php.phigroup.end(); ++kt)
216  std::cout << " [" << ++i << "] = " << (*kt);
217  std::cout << std::endl;
218  std::cout << "HcalParametersFromDD: " << php.layerGroupEtaRec.size() << " layerGroupEtaRec blocks" << std::endl;
219  for (unsigned int k=0; k < php.layerGroupEtaRec.size(); ++k) {
220  std::cout << "layerGroupEtaRec[" << k << "] Layer " << php.layerGroupEtaRec[k].layer;
221  for (kt=php.layerGroupEtaRec[k].layerGroup.begin(), i=0; kt!=php.layerGroupEtaRec[k].layerGroup.end(); ++kt)
222  std::cout << " " << ++i << ":" << (*kt);
223  std::cout << std::endl;
224  }
225  std::cout << "HcalParametersFromDD: topologyMode " << php.topologyMode << std::endl;
226 #endif
227 
228  return true;
229 }
int i
Definition: DBlmapReader.cc:9
std::vector< double > etaTable
std::vector< int > etagroup
void loadGeometry(const DDFilteredView &_fv, HcalParameters &php)
bool build(const DDCompactView *, HcalParameters &)
void addFilter(const DDFilter &, DDLogOp op=DDLogOp::AND)
std::vector< double > etaRange
std::vector< double > HBGains
std::vector< int > getModHalfHBHE(const int type) const
std::vector< int > HEShift
type of data representation of DDCompactView
Definition: DDCompactView.h:77
double getConstDzHF() const
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:80
std::vector< double > etaTableHF
void getConstRHO(std::vector< double > &) const
std::vector< int > etaMax
std::vector< int > modHB
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.cc:4
std::vector< LayerItem > layerGroupEtaSim
bool check(const std::string &)
std::vector< double > rHO
std::vector< int > layerGroup
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:19
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
std::vector< int > modHE
std::vector< int > HFShift
std::vector< double > get(const std::string &)
std::vector< double > HEGains
std::vector< double > phioff
std::vector< double > gparHF
DDsvalues_type mergedSpecifics() const
std::vector< double > Layer0Wt
std::vector< double > rTable
std::vector< double > phitable
std::vector< double > phibin
std::vector< LayerItem > layerGroupEtaRec
bool firstChild()
set the current node to the first child ...
std::vector< double > HFGains
std::vector< int > noff
tuple cout
Definition: gather_cfg.py:121
std::vector< int > HBShift
std::vector< int > maxDepth
std::vector< int > phigroup
void setCriteria(const DDValue &nameVal, DDCompOp, DDLogOp l=DDLogOp::AND, bool asString=true, bool merged=true)
Definition: DDFilter.cc:245
std::vector< int > etaMin
T parseString(const std::string &value)
tuple log
Definition: cmsBatch.py:341
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.
Definition: DDFilter.h:32