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  int getTopologyMode(const char* s, const DDsvalues_type & sv, bool type) {
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 
26  int result(-1);
27  if (type) {
30  result = (int)(mode);
31  } else {
34  result = (int)(mode);
35  }
36  return result;
37  } else {
38  throw cms::Exception( "HcalParametersFromDD" ) << "Failed to get "<< s << " tag.";
39  }
40  }
41 }
42 
44  HcalParameters& php) {
45 
46  //Special parameters at simulation level
47  std::string attribute = "OnlyForHcalSimNumbering";
48  std::string value = "any";
49  DDValue val1(attribute, value, 0.0);
50  DDSpecificsFilter filter1;
51  filter1.setCriteria(val1, DDCompOp::not_equals,
52  DDLogOp::AND, true, // compare strings otherwise doubles
53  true // use merged-specifics or simple-specifics
54  );
55  DDFilteredView fv1(*cpv);
56  fv1.addFilter(filter1);
57  bool ok = fv1.firstChild();
58 
59  const int nEtaMax=100;
60 
61  if (ok) {
63  geom->loadGeometry( fv1, php );
64  php.modHB = geom->getModHalfHBHE(0);
65  php.modHE = geom->getModHalfHBHE(1);
66  php.dzVcal = geom->getConstDzHF();
67  geom->getConstRHO(php.rHO);
68 
69  php.phioff = DDVectorGetter::get( "phioff" );
70  php.etaTable = DDVectorGetter::get( "etaTable" );
71  php.rTable = DDVectorGetter::get( "rTable" );
72  php.phibin = DDVectorGetter::get( "phibin" );
73  php.phitable = DDVectorGetter::get( "phitable" );
74  for (unsigned int i = 1; i<=nEtaMax; ++i) {
75  std::stringstream sstm;
76  sstm << "layerGroupSimEta" << i;
77  std::string tempName = sstm.str();
78  if (DDVectorGetter::check(tempName)) {
79  HcalParameters::LayerItem layerGroupEta;
80  layerGroupEta.layer = i;
81  layerGroupEta.layerGroup = dbl_to_int(DDVectorGetter::get(tempName));
82  php.layerGroupEtaSim.push_back(layerGroupEta);
83  }
84  }
85  php.etaMin = dbl_to_int( DDVectorGetter::get( "etaMin" ));
86  php.etaMax = dbl_to_int( DDVectorGetter::get( "etaMax" ));
87  php.etaMin[0] = 1;
88  php.etaMax[1] = (int)(php.etaTable.size())-1;
89  php.etaMax[2] = php.etaMin[2]+(int)(php.rTable.size())-2;
90  php.etaRange = DDVectorGetter::get( "etaRange" );
91  php.gparHF = DDVectorGetter::get( "gparHF" );
92  php.noff = dbl_to_int( DDVectorGetter::get( "noff" ));
93  php.Layer0Wt = DDVectorGetter::get( "Layer0Wt" );
94  php.HBGains = DDVectorGetter::get( "HBGains" );
95  php.HBShift = dbl_to_int( DDVectorGetter::get( "HBShift" ));
96  php.HEGains = DDVectorGetter::get( "HEGains" );
97  php.HEShift = dbl_to_int( DDVectorGetter::get( "HEShift" ));
98  php.HFGains = DDVectorGetter::get( "HFGains" );
99  php.HFShift = dbl_to_int( DDVectorGetter::get( "HFShift" ));
100  php.maxDepth = dbl_to_int( DDVectorGetter::get( "MaxDepth" ));
101  } else {
102  throw cms::Exception("HcalParametersFromDD") << "Not found "<< attribute.c_str() << " but needed.";
103  }
104  for( unsigned int i = 0; i < php.rTable.size(); ++i ) {
105  unsigned int k = php.rTable.size() - i - 1;
106  php.etaTableHF.push_back( -log( tan( 0.5 * atan( php.rTable[k] / php.gparHF[4] ))));
107  }
108  //Special parameters at reconstruction level
109  attribute = "OnlyForHcalRecNumbering";
110  DDValue val2( attribute, value, 0.0 );
111  DDSpecificsFilter filter2;
112  filter2.setCriteria(val2,
114  DDLogOp::AND, true, // compare strings
115  true // use merged-specifics or simple-specifics
116  );
117  DDFilteredView fv2(*cpv);
118  fv2.addFilter(filter2);
119  ok = fv2.firstChild();
120  if (ok) {
122  int topoMode = getTopologyMode("TopologyMode", sv, true);
123  int trigMode = getTopologyMode("TriggerMode", sv, false);
124  php.topologyMode = ((trigMode&0xFF)<<8) | (topoMode&0xFF);
125  php.etagroup = dbl_to_int( DDVectorGetter::get( "etagroup" ));
126  php.phigroup = dbl_to_int( DDVectorGetter::get( "phigroup" ));
127  for (unsigned int i = 1; i<=nEtaMax; ++i) {
128  std::stringstream sstm;
129  sstm << "layerGroupRecEta" << i;
130  std::string tempName = sstm.str();
131  if (DDVectorGetter::check(tempName)) {
132  HcalParameters::LayerItem layerGroupEta;
133  layerGroupEta.layer = i;
134  layerGroupEta.layerGroup = dbl_to_int(DDVectorGetter::get(tempName));
135  php.layerGroupEtaRec.push_back(layerGroupEta);
136  }
137  }
138  } else {
139  throw cms::Exception( "HcalParametersFromDD" ) << "Not found "<< attribute.c_str() << " but needed.";
140  }
141 
142 #ifdef DebugLog
143  int i(0);
144  std::cout << "HcalParametersFromDD: MaxDepth: ";
145  for (const auto& it : php.maxDepth) std::cout << it << ", ";
146  std::cout << std::endl;
147  std::cout << "HcalParametersFromDD: ModHB [" << php.modHB.size() << "]: ";
148  for (const auto& it : php.modHB) std::cout << it << ", ";
149  std::cout << std::endl;
150  std::cout << "HcalParametersFromDD: ModHE [" << php.modHE.size() << "]: ";
151  for (const auto& it : php.modHE) std::cout << it << ", ";
152  std::cout << std::endl;
153  std::cout << "HcalParametersFromDD: " << php.phioff.size() << " phioff values";
154  std::vector<double>::const_iterator it;
155  for (it=php.phioff.begin(), i=0; it!=php.phioff.end(); ++it)
156  std::cout << " [" << ++i << "] = " << (*it)/CLHEP::deg;
157  std::cout << std::endl;
158  std::cout << "HcalParametersFromDD: " << php.etaTable.size() << " entries for etaTable";
159  for (it=php.etaTable.begin(), i=0; it!=php.etaTable.end(); ++it)
160  std::cout << " [" << ++i << "] = " << (*it);
161  std::cout << std::endl;
162  std::cout << "HcalParametersFromDD: " << php.rTable.size() << " entries for rTable";
163  for (it=php.rTable.begin(), i=0; it!=php.rTable.end(); ++it)
164  std::cout << " [" << ++i << "] = " << (*it)/CLHEP::cm;
165  std::cout << std::endl;
166  std::cout << "HcalParametersFromDD: " << php.phibin.size() << " phibin values";
167  for (it=php.phibin.begin(), i=0; it!=php.phibin.end(); ++it)
168  std::cout << " [" << ++i << "] = " << (*it)/CLHEP::deg;
169  std::cout << std::endl;
170  std::cout << "HcalParametersFromDD: " << php.phitable.size() << " phitable values";
171  for (it=php.phitable.begin(), i=0; it!=php.phitable.end(); ++it)
172  std::cout << " [" << ++i << "] = " << (*it)/CLHEP::deg;
173  std::cout << std::endl;
174  std::cout << "HcalParametersFromDD: " << php.layerGroupEtaSim.size() << " layerGroupEtaSim blocks" << std::endl;
175  std::vector<HcalParameters::LayerItem>::const_iterator jt;
176  std::vector<int>::const_iterator kt;
177  for (unsigned int k=0; k < php.layerGroupEtaSim.size(); ++k) {
178  std::cout << "layerGroupEtaSim[" << k << "] Layer " << php.layerGroupEtaSim[k].layer;
179  for (kt=php.layerGroupEtaSim[k].layerGroup.begin(), i=0; kt!=php.layerGroupEtaSim[k].layerGroup.end(); ++kt)
180  std::cout << " " << ++i << ":" << (*kt);
181  std::cout << std::endl;
182  }
183  std::cout << "HcalParametersFromDD: " << php.etaMin.size() << " etaMin values";
184  for (kt=php.etaMin.begin(), i=0; kt!=php.etaMin.end(); ++kt)
185  std::cout << " [" << ++i << "] = " << (*kt);
186  std::cout << std::endl;
187  std::cout << "HcalParametersFromDD: " << php.etaMax.size() << " etaMax values";
188  for (kt=php.etaMax.begin(), i=0; kt!=php.etaMax.end(); ++kt)
189  std::cout << " [" << ++i << "] = " << (*kt);
190  std::cout << std::endl;
191  std::cout << "HcalParametersFromDD: " << php.etaRange.size() << " etaRange values";
192  for (it=php.etaRange.begin(), i=0; it!=php.etaRange.end(); ++it)
193  std::cout << " [" << ++i << "] = " << (*it);
194  std::cout << std::endl;
195  std::cout << "HcalParametersFromDD: " << php.gparHF.size() << " gparHF values";
196  for (it=php.gparHF.begin(), i=0; it!=php.gparHF.end(); ++it)
197  std::cout << " [" << ++i << "] = " << (*it)/CLHEP::cm;
198  std::cout << std::endl;
199  std::cout << "HcalParametersFromDD: " << php.noff.size() << " noff values";
200  for (kt=php.noff.begin(), i=0; kt!=php.noff.end(); ++kt)
201  std::cout << " [" << ++i << "] = " << (*kt);
202  std::cout << std::endl;
203  std::cout << "HcalParametersFromDD: " << php.Layer0Wt.size() << " Layer0Wt values";
204  for (it=php.Layer0Wt.begin(), i=0; it!=php.Layer0Wt.end(); ++it)
205  std::cout << " [" << ++i << "] = " << (*it);
206  std::cout << std::endl;
207  std::cout << "HcalParametersFromDD: " << php.HBGains.size() << " Shift/Gains values for HB";
208  for (unsigned k=0; k<php.HBGains.size(); ++k)
209  std::cout << " [" << k << "] = " << php.HBShift[k] << ":" << php.HBGains[k];
210  std::cout << std::endl;
211  std::cout << "HcalParametersFromDD: " << php.HEGains.size() << " Shift/Gains values for HE";
212  for (unsigned k=0; k<php.HEGains.size(); ++k)
213  std::cout << " [" << k << "] = " << php.HEShift[k] << ":" << php.HEGains[k];
214  std::cout << std::endl;
215  std::cout << "HcalParametersFromDD: " << php.HFGains.size() << " Shift/Gains values for HF";
216  for (unsigned k=0; k<php.HFGains.size(); ++k)
217  std::cout << " [" << k << "] = " << php.HFShift[k] << ":" << php.HFGains[k];
218  std::cout << std::endl;
219  std::cout << "HcalParametersFromDD: " << php.etagroup.size() << " etagroup values";
220  for (kt=php.etagroup.begin(), i=0; kt!=php.etagroup.end(); ++kt)
221  std::cout << " [" << ++i << "] = " << (*kt);
222  std::cout << std::endl;
223  std::cout << "HcalParametersFromDD: " << php.phigroup.size() << " phigroup values";
224  for (kt=php.phigroup.begin(), i=0; kt!=php.phigroup.end(); ++kt)
225  std::cout << " [" << ++i << "] = " << (*kt);
226  std::cout << std::endl;
227  std::cout << "HcalParametersFromDD: " << php.layerGroupEtaRec.size() << " layerGroupEtaRec blocks" << std::endl;
228  for (unsigned int k=0; k < php.layerGroupEtaRec.size(); ++k) {
229  std::cout << "layerGroupEtaRec[" << k << "] Layer " << php.layerGroupEtaRec[k].layer;
230  for (kt=php.layerGroupEtaRec[k].layerGroup.begin(), i=0; kt!=php.layerGroupEtaRec[k].layerGroup.end(); ++kt)
231  std::cout << " " << ++i << ":" << (*kt);
232  std::cout << std::endl;
233  }
234  std::cout << "HcalParametersFromDD: (topology|trigger)Mode " << std::hex
235  << php.topologyMode << std::dec << std::endl;
236 #endif
237 
238  return true;
239 }
type
Definition: HCALResponse.h:21
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
tuple result
Definition: mps_fire.py:83
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:145
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)
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.
Definition: DDFilter.h:32