CMS 3D CMS Logo

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 EDM_ML_DEBUG
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.empty()) {
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  DDSpecificsHasNamedValueFilter filter1{attribute};
49  DDFilteredView fv1(*cpv,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.emplace_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.emplace_back( -log( tan( 0.5 * atan( php.rTable[k] / php.gparHF[4] ))));
100  }
101  //Special parameters at reconstruction level
102  attribute = "OnlyForHcalRecNumbering";
103  DDSpecificsHasNamedValueFilter filter2{attribute};
104  DDFilteredView fv2(*cpv,filter2);
105  ok = fv2.firstChild();
106  if (ok) {
108  int topoMode = getTopologyMode("TopologyMode", sv, true);
109  int trigMode = getTopologyMode("TriggerMode", sv, false);
110  php.topologyMode = ((trigMode&0xFF)<<8) | (topoMode&0xFF);
111  php.etagroup = dbl_to_int( DDVectorGetter::get( "etagroup" ));
112  php.phigroup = dbl_to_int( DDVectorGetter::get( "phigroup" ));
113  for (unsigned int i = 1; i<=nEtaMax; ++i) {
114  std::stringstream sstm;
115  sstm << "layerGroupRecEta" << i;
116  std::string tempName = sstm.str();
117  if (DDVectorGetter::check(tempName)) {
118  HcalParameters::LayerItem layerGroupEta;
119  layerGroupEta.layer = i;
120  layerGroupEta.layerGroup = dbl_to_int(DDVectorGetter::get(tempName));
121  php.layerGroupEtaRec.emplace_back(layerGroupEta);
122  }
123  }
124  } else {
125  throw cms::Exception( "HcalParametersFromDD" ) << "Not found "<< attribute.c_str() << " but needed.";
126  }
127 
128 #ifdef EDM_ML_DEBUG
129  int i(0);
130  std::cout << "HcalParametersFromDD: MaxDepth: ";
131  for (const auto& it : php.maxDepth) std::cout << it << ", ";
132  std::cout << std::endl;
133  std::cout << "HcalParametersFromDD: ModHB [" << php.modHB.size() << "]: ";
134  for (const auto& it : php.modHB) std::cout << it << ", ";
135  std::cout << std::endl;
136  std::cout << "HcalParametersFromDD: ModHE [" << php.modHE.size() << "]: ";
137  for (const auto& it : php.modHE) std::cout << it << ", ";
138  std::cout << std::endl;
139  std::cout << "HcalParametersFromDD: " << php.phioff.size() << " phioff values";
140  std::vector<double>::const_iterator it;
141  for (it=php.phioff.begin(), i=0; it!=php.phioff.end(); ++it)
142  std::cout << " [" << ++i << "] = " << (*it)/CLHEP::deg;
143  std::cout << std::endl;
144  std::cout << "HcalParametersFromDD: " << php.etaTable.size() << " entries for etaTable";
145  for (it=php.etaTable.begin(), i=0; it!=php.etaTable.end(); ++it)
146  std::cout << " [" << ++i << "] = " << (*it);
147  std::cout << std::endl;
148  std::cout << "HcalParametersFromDD: " << php.rTable.size() << " entries for rTable";
149  for (it=php.rTable.begin(), i=0; it!=php.rTable.end(); ++it)
150  std::cout << " [" << ++i << "] = " << (*it)/CLHEP::cm;
151  std::cout << std::endl;
152  std::cout << "HcalParametersFromDD: " << php.phibin.size() << " phibin values";
153  for (it=php.phibin.begin(), i=0; it!=php.phibin.end(); ++it)
154  std::cout << " [" << ++i << "] = " << (*it)/CLHEP::deg;
155  std::cout << std::endl;
156  std::cout << "HcalParametersFromDD: " << php.phitable.size() << " phitable values";
157  for (it=php.phitable.begin(), i=0; it!=php.phitable.end(); ++it)
158  std::cout << " [" << ++i << "] = " << (*it)/CLHEP::deg;
159  std::cout << std::endl;
160  std::cout << "HcalParametersFromDD: " << php.layerGroupEtaSim.size() << " layerGroupEtaSim blocks" << std::endl;
161  std::vector<HcalParameters::LayerItem>::const_iterator jt;
162  std::vector<int>::const_iterator kt;
163  for (unsigned int k=0; k < php.layerGroupEtaSim.size(); ++k) {
164  std::cout << "layerGroupEtaSim[" << k << "] Layer " << php.layerGroupEtaSim[k].layer;
165  for (kt=php.layerGroupEtaSim[k].layerGroup.begin(), i=0; kt!=php.layerGroupEtaSim[k].layerGroup.end(); ++kt)
166  std::cout << " " << ++i << ":" << (*kt);
167  std::cout << std::endl;
168  }
169  std::cout << "HcalParametersFromDD: " << php.etaMin.size() << " etaMin values";
170  for (kt=php.etaMin.begin(), i=0; kt!=php.etaMin.end(); ++kt)
171  std::cout << " [" << ++i << "] = " << (*kt);
172  std::cout << std::endl;
173  std::cout << "HcalParametersFromDD: " << php.etaMax.size() << " etaMax values";
174  for (kt=php.etaMax.begin(), i=0; kt!=php.etaMax.end(); ++kt)
175  std::cout << " [" << ++i << "] = " << (*kt);
176  std::cout << std::endl;
177  std::cout << "HcalParametersFromDD: " << php.etaRange.size() << " etaRange values";
178  for (it=php.etaRange.begin(), i=0; it!=php.etaRange.end(); ++it)
179  std::cout << " [" << ++i << "] = " << (*it);
180  std::cout << std::endl;
181  std::cout << "HcalParametersFromDD: " << php.gparHF.size() << " gparHF values";
182  for (it=php.gparHF.begin(), i=0; it!=php.gparHF.end(); ++it)
183  std::cout << " [" << ++i << "] = " << (*it)/CLHEP::cm;
184  std::cout << std::endl;
185  std::cout << "HcalParametersFromDD: " << php.noff.size() << " noff values";
186  for (kt=php.noff.begin(), i=0; kt!=php.noff.end(); ++kt)
187  std::cout << " [" << ++i << "] = " << (*kt);
188  std::cout << std::endl;
189  std::cout << "HcalParametersFromDD: " << php.Layer0Wt.size() << " Layer0Wt values";
190  for (it=php.Layer0Wt.begin(), i=0; it!=php.Layer0Wt.end(); ++it)
191  std::cout << " [" << ++i << "] = " << (*it);
192  std::cout << std::endl;
193  std::cout << "HcalParametersFromDD: " << php.HBGains.size() << " Shift/Gains values for HB";
194  for (unsigned k=0; k<php.HBGains.size(); ++k)
195  std::cout << " [" << k << "] = " << php.HBShift[k] << ":" << php.HBGains[k];
196  std::cout << std::endl;
197  std::cout << "HcalParametersFromDD: " << php.HEGains.size() << " Shift/Gains values for HE";
198  for (unsigned k=0; k<php.HEGains.size(); ++k)
199  std::cout << " [" << k << "] = " << php.HEShift[k] << ":" << php.HEGains[k];
200  std::cout << std::endl;
201  std::cout << "HcalParametersFromDD: " << php.HFGains.size() << " Shift/Gains values for HF";
202  for (unsigned k=0; k<php.HFGains.size(); ++k)
203  std::cout << " [" << k << "] = " << php.HFShift[k] << ":" << php.HFGains[k];
204  std::cout << std::endl;
205  std::cout << "HcalParametersFromDD: " << php.etagroup.size() << " etagroup values";
206  for (kt=php.etagroup.begin(), i=0; kt!=php.etagroup.end(); ++kt)
207  std::cout << " [" << ++i << "] = " << (*kt);
208  std::cout << std::endl;
209  std::cout << "HcalParametersFromDD: " << php.phigroup.size() << " phigroup values";
210  for (kt=php.phigroup.begin(), i=0; kt!=php.phigroup.end(); ++kt)
211  std::cout << " [" << ++i << "] = " << (*kt);
212  std::cout << std::endl;
213  std::cout << "HcalParametersFromDD: " << php.layerGroupEtaRec.size() << " layerGroupEtaRec blocks" << std::endl;
214  for (unsigned int k=0; k < php.layerGroupEtaRec.size(); ++k) {
215  std::cout << "layerGroupEtaRec[" << k << "] Layer " << php.layerGroupEtaRec[k].layer;
216  for (kt=php.layerGroupEtaRec[k].layerGroup.begin(), i=0; kt!=php.layerGroupEtaRec[k].layerGroup.end(); ++kt)
217  std::cout << " " << ++i << ":" << (*kt);
218  std::cout << std::endl;
219  }
220  std::cout << "HcalParametersFromDD: (topology|trigger)Mode " << std::hex
221  << php.topologyMode << std::dec << std::endl;
222 #endif
223 
224  return true;
225 }
type
Definition: HCALResponse.h:21
std::vector< double > etaTable
std::vector< int > etagroup
void loadGeometry(const DDFilteredView &_fv, HcalParameters &php)
bool build(const DDCompactView *, HcalParameters &)
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:90
double getConstDzHF() const
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:81
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.h:7
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:20
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 &)
int k[5][pyjets_maxn]
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
std::vector< int > HBShift
std::vector< int > maxDepth
std::vector< int > phigroup
std::vector< int > etaMin
T parseString(const std::string &value)