CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
HGCalGeomParameters Class Reference

#include <HGCalGeomParameters.h>

Classes

struct  cellParameters
 
struct  layerParameters
 

Public Member Functions

 HGCalGeomParameters ()
 
void loadCellParsHexagon (const DDCompactView *cpv, HGCalParameters &php)
 
void loadGeometryHexagon (const DDFilteredView &, HGCalParameters &, const std::string &, const DDCompactView *, const std::string &, const std::string &, HGCalGeometryMode::WaferMode)
 
void loadSpecParsHexagon (const DDFilteredView &, HGCalParameters &, const DDCompactView *, const std::string &, const std::string &)
 
void loadWaferHexagon (HGCalParameters &php)
 
 ~HGCalGeomParameters ()
 

Private Member Functions

std::pair< double, double > cellPosition (const std::vector< cellParameters > &wafers, std::vector< cellParameters >::const_iterator &itrf, int wafer, double xx, double yy)
 
std::vector< double > getDDDArray (const std::string &, const DDsvalues_type &, int &)
 

Private Attributes

double waferSize_
 

Detailed Description

this class extracts some geometry constants from CompactView to be used by Reco Geometry/Topology

Date
2015/06/25 00:06:50
Author
Sunanda Banerjee, Fermilab sunan.nosp@m.da.b.nosp@m.anerj.nosp@m.ee@c.nosp@m.ern.c.nosp@m.h
Lindsey Gray, Fermilab lagra.nosp@m.y@fn.nosp@m.al.go.nosp@m.v (for fixes)

Definition at line 28 of file HGCalGeomParameters.h.

Constructor & Destructor Documentation

HGCalGeomParameters::HGCalGeomParameters ( )

Definition at line 25 of file HGCalGeomParameters.cc.

References gather_cfg::cout.

25  {
26 #ifdef EDM_ML_DEBUG
27  std::cout << "HGCalGeomParameters::HGCalGeomParameters() constructor\n";
28 #endif
29 }
HGCalGeomParameters::~HGCalGeomParameters ( )

Definition at line 31 of file HGCalGeomParameters.cc.

References gather_cfg::cout.

31  {
32 #ifdef EDM_ML_DEBUG
33  std::cout << "HGCalGeomParameters::destructed!!!\n";
34 #endif
35 }

Member Function Documentation

std::pair< double, double > HGCalGeomParameters::cellPosition ( const std::vector< cellParameters > &  wafers,
std::vector< cellParameters >::const_iterator &  itrf,
int  wafer,
double  xx,
double  yy 
)
private

Definition at line 707 of file HGCalGeomParameters.cc.

References funct::abs(), PVValHelper::dx, and PVValHelper::dy.

Referenced by HGCalGeomParameters::cellParameters::cellParameters(), and loadGeometryHexagon().

709  {
710 
711  if (itrf == wafers.end()) {
712  for (std::vector<HGCalGeomParameters::cellParameters>::const_iterator itr = wafers.begin();
713  itr != wafers.end(); ++itr) {
714  if (itr->wafer == wafer) {
715  itrf = itr;
716  break;
717  }
718  }
719  }
720  double dx(0), dy(0);
721  if (itrf != wafers.end()) {
722  dx = (xx - itrf->xyz.x());
723  if (std::abs(dx) < 0.001) dx = 0;
724  dy = (yy - itrf->xyz.y());
725  if (std::abs(dy) < 0.001) dy = 0;
726  }
727  return std::pair<double,double>(dx,dy);
728 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< double > HGCalGeomParameters::getDDDArray ( const std::string &  str,
const DDsvalues_type sv,
int &  nmin 
)
private

Definition at line 670 of file HGCalGeomParameters.cc.

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

Referenced by HGCalGeomParameters::cellParameters::cellParameters(), and loadSpecParsHexagon().

672  {
673  DDValue value(str);
674  if (DDfetch(&sv,value)) {
675  const std::vector<double> & fvec = value.doubles();
676  int nval = fvec.size();
677  if (nmin > 0) {
678  if (nval < nmin) {
679  edm::LogError("HGCalGeom") << "HGCalGeomParameters : # of " << str
680  << " bins " << nval << " < " << nmin
681  << " ==> illegal";
682  throw cms::Exception("DDException") << "HGCalGeomParameters: cannot get array " << str;
683  }
684  } else {
685  if (nval < 1 && nmin == 0) {
686  edm::LogError("HGCalGeom") << "HGCalGeomParameters : # of " << str
687  << " bins " << nval << " < 1 ==> illegal"
688  << " (nmin=" << nmin << ")";
689  throw cms::Exception("DDException") << "HGCalGeomParameters: cannot get array " << str;
690  }
691  }
692  nmin = nval;
693  return fvec;
694  } else {
695  if (nmin >= 0) {
696  edm::LogError("HGCalGeom") << "HGCalGeomParameters: cannot get array "
697  << str;
698  throw cms::Exception("DDException") << "HGCalGeomParameters: cannot get array " << str;
699  }
700  std::vector<double> fvec;
701  nmin = 0;
702  return fvec;
703  }
704 }
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:81
Definition: value.py:1
void HGCalGeomParameters::loadCellParsHexagon ( const DDCompactView cpv,
HGCalParameters php 
)

Definition at line 642 of file HGCalGeomParameters.cc.

References HGCalParameters::cellCoarse_, HGCalParameters::cellFine_, gather_cfg::cout, dbl_to_int(), DDFilteredView::firstChild(), DDVectorGetter::get(), gen::k, convertSQLiteXML::ok, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by HGCalParametersFromDD::build().

643  {
644 
645  //Special parameters for cell parameters
646  std::string attribute = "OnlyForHGCalNumbering";
647  DDSpecificsHasNamedValueFilter filter1{attribute};
648  DDFilteredView fv1(*cpv,filter1);
649  bool ok = fv1.firstChild();
650 
651  if (ok) {
652  php.cellFine_ = dbl_to_int(DDVectorGetter::get("waferFine"));
653  php.cellCoarse_ = dbl_to_int(DDVectorGetter::get("waferCoarse"));
654  }
655 
656 #ifdef EDM_ML_DEBUG
657  std::cout << "HGCalLoadCellPars: " << php.cellFine_.size()
658  << " rows for fine cells\n";
659  for (unsigned int k=0; k<php.cellFine_.size(); ++k)
660  std::cout << k << ":" << php.cellFine_[k] << " ";
661  std::cout << std::endl;
662  std::cout << "HGCalLoadCellPars: " <<php.cellCoarse_.size()
663  << " rows for coarse cells\n";
664  for (unsigned int k=0; k<php.cellCoarse_.size(); ++k)
665  std::cout << k << ":" << php.cellCoarse_[k] << " ";
666  std::cout << std::endl;
667 #endif
668 }
std::vector< int > cellFine_
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< int > cellCoarse_
std::vector< double > get(const std::string &)
int k[5][pyjets_maxn]
void HGCalGeomParameters::loadGeometryHexagon ( const DDFilteredView _fv,
HGCalParameters php,
const std::string &  sdTag1,
const DDCompactView cpv,
const std::string &  sdTag2,
const std::string &  sdTag3,
HGCalGeometryMode::WaferMode  mode 
)

Definition at line 37 of file HGCalGeomParameters.cc.

References funct::abs(), HGCalParameters::addTrForm(), HGCalParameters::hgtrap::alpha, HGCalParameters::hgtrap::bl, HGCalParameters::boundR_, HGCalParameters::cellCoarseHalf_, HGCalParameters::cellCoarseX_, HGCalParameters::cellCoarseY_, HGCalParameters::cellFineHalf_, HGCalParameters::cellFineX_, HGCalParameters::cellFineY_, cellPosition(), HGCalParameters::hgtrap::cellSize, HGCalParameters::cellSize_, HGCalParameters::copiesInLayers_, popcon2dropbox::copy(), DDFilteredView::copyNumbers(), funct::cos(), gather_cfg::cout, SimDataFormats::CaloAnalysis::cp, TauDecayModes::dec, egammaForCoreTracking_cff::depth, HGCalParameters::depth_, HGCalParameters::depthIndex_, HGCalParameters::depthLayerF_, HGCalParameters::hgtrap::dz, PVValHelper::dz, Exception, HGCalParameters::fillModule(), HGCalParameters::fillTrForm(), spr::find(), plotBeamSpotDB::first, DDFilteredView::firstChild(), HGCalParameters::getModule(), HGCalParameters::hgtrap::h, AnalysisDataFormats_SUSYBSMObjects::hr, mps_fire::i, createfilelist::int, gen::k, k_ScaleFromDDD, HGCalParameters::hgtrap::lay, HGCalParameters::layer_, HGCalParameters::layerGroup_, HGCalParameters::layerIndex_, LayerTriplets::layers(), DDFilteredView::logicalPart(), HGCalParameters::moduleAlphaR_, HGCalParameters::moduleAlphaS_, HGCalParameters::moduleBlR_, HGCalParameters::moduleBlS_, HGCalParameters::moduleDzR_, HGCalParameters::moduleDzS_, HGCalParameters::moduleHR_, HGCalParameters::moduleHS_, HGCalParameters::moduleLayR_, HGCalParameters::moduleLayS_, HGCalParameters::moduleTlR_, HGCalParameters::moduleTlS_, dataset::name, DDBase< N, C >::name(), cscdqm::h::names, DDFilteredView::next(), HGCalParameters::nSectors_, convertSQLiteXML::ok, AlCaHLTBitMon_ParallelJobs::p, p1, p2, HGCalGeometryMode::Polyhedra, alignCSCRings::r, DDTubs::rIn(), HGCalParameters::rMaxLayHex_, DDPolyhedra::rMaxVec(), HGCalParameters::rMinLayHex_, idealTransformation::rotation, DDFilteredView::rotation(), DDTubs::rOut(), HGCalParameters::scaleTrForm(), DDLogicalPart::solid(), AlCaHLTBitMon_QueryRunRegistry::string, HGCalParameters::hgtrap::tl, DDFilteredView::translation(), HGCalParameters::trformIndex_, HGCalParameters::trformRotXX_, HGCalParameters::trformRotXY_, HGCalParameters::trformRotXZ_, HGCalParameters::trformRotYX_, HGCalParameters::trformRotYY_, HGCalParameters::trformRotYZ_, HGCalParameters::trformRotZX_, HGCalParameters::trformRotZY_, HGCalParameters::trformRotZZ_, HGCalParameters::trformTranX_, HGCalParameters::trformTranY_, HGCalParameters::trformTranZ_, HGCalParameters::waferCopy_, HGCalParameters::waferPosX_, HGCalParameters::waferPosY_, HGCalParameters::waferR_, waferSize_, HGCalParameters::waferTypeL_, HGCalParameters::waferTypeT_, x, DDExtrudedPolygon::xVec(), geometryCSVtoXML::xx, geometryCSVtoXML::xy, y, geometryCSVtoXML::yy, z, HGCalParameters::zLayerHex_, HGCalParameters::hgtrform::zp, DDPolyhedra::zVec(), and DDExtrudedPolygon::zVec().

Referenced by HGCalParametersFromDD::build().

43  {
44 
45  DDFilteredView fv = _fv;
46  bool dodet(true);
47  std::map<int,HGCalGeomParameters::layerParameters> layers;
48  std::vector<HGCalParameters::hgtrform> trforms;
49  std::vector<bool> trformUse;
50 
51  while (dodet) {
52  const DDSolid & sol = fv.logicalPart().solid();
53  std::string name = sol.name();
54  // Layers first
55  std::vector<int> copy = fv.copyNumbers();
56  int nsiz = (int)(copy.size());
57  int lay = (nsiz > 0) ? copy[nsiz-1] : 0;
58  int zp = (nsiz > 2) ? copy[nsiz-3] : -1;
59  if (zp != 1) zp = -1;
60  if (lay == 0) {
61  edm::LogError("HGCalGeom") << "Funny layer # " << lay << " zp "
62  << zp << " in " << nsiz << " components";
63  throw cms::Exception("DDException") << "Funny layer # " << lay;
64  } else {
65  if (std::find(php.layer_.begin(),php.layer_.end(),lay) ==
66  php.layer_.end()) php.layer_.emplace_back(lay);
67  std::map<int,HGCalGeomParameters::layerParameters>::iterator itr = layers.find(lay);
68  if (itr == layers.end()) {
69  const DDTubs & tube = static_cast<DDTubs>(sol);
70  double rin = k_ScaleFromDDD*tube.rIn();
71  double rout= k_ScaleFromDDD*tube.rOut();
72  double zp = k_ScaleFromDDD*fv.translation().Z();
73  HGCalGeomParameters::layerParameters laypar(rin,rout,zp);
74  layers[lay] = laypar;
75  }
76  DD3Vector x, y, z;
77  fv.rotation().GetComponents( x, y, z ) ;
78  const CLHEP::HepRep3x3 rotation ( x.X(), y.X(), z.X(),
79  x.Y(), y.Y(), z.Y(),
80  x.Z(), y.Z(), z.Z() );
81  const CLHEP::HepRotation hr ( rotation );
82  double xx = k_ScaleFromDDD*fv.translation().X();
83  if (std::abs(xx) < 0.001) xx = 0;
84  double yy = k_ScaleFromDDD*fv.translation().Y();
85  if (std::abs(yy) < 0.001) yy = 0;
86  const CLHEP::Hep3Vector h3v ( xx, yy, fv.translation().Z() );
88  mytrf.zp = zp;
89  mytrf.lay = lay;
90  mytrf.sec = 0;
91  mytrf.subsec= 0;
92  mytrf.h3v = h3v;
93  mytrf.hr = hr;
94  trforms.emplace_back(mytrf);
95  trformUse.emplace_back(false);
96  }
97  dodet = fv.next();
98  }
99 
100  // Then wafers
101  // This assumes layers are build starting from 1 (which on 25 Jan 2016, they were)
102  // to ensure that new copy numbers are always added
103  // to the end of the list.
104  std::unordered_map<int32_t,int32_t> copies;
105  HGCalParameters::layer_map copiesInLayers(layers.size()+1);
106  std::vector<int32_t> wafer2copy;
107  std::vector<HGCalGeomParameters::cellParameters> wafers;
108  std::string attribute = "Volume";
109  DDValue val1(attribute, sdTag2, 0.0);
110  DDSpecificsMatchesValueFilter filter1{val1};
111  DDFilteredView fv1(*cpv,filter1);
112  bool ok = fv1.firstChild();
113  if (!ok) {
114  edm::LogError("HGCalGeom") << " Attribute " << val1
115  << " not found but needed.";
116  throw cms::Exception("DDException") << "Attribute " << val1
117  << " not found but needed.";
118  } else {
119  dodet = true;
120  std::unordered_set<std::string> names;
121  while (dodet) {
122  const DDSolid & sol = fv1.logicalPart().solid();
123  std::string name = fv1.logicalPart().name();
124  std::vector<int> copy = fv1.copyNumbers();
125  int nsiz = (int)(copy.size());
126  int wafer = (nsiz > 0) ? copy[nsiz-1] : 0;
127  int layer = (nsiz > 1) ? copy[nsiz-2] : 0;
128  if (nsiz < 2) {
129  edm::LogError("HGCalGeom") << "Funny wafer # " << wafer << " in "
130  << nsiz << " components";
131  throw cms::Exception("DDException") << "Funny wafer # " << wafer;
132  } else {
133  std::unordered_map<int32_t,int32_t>::iterator itr = copies.find(wafer);
134  std::unordered_map<int32_t,int32_t>::iterator cpy =
135  copiesInLayers[layer].find(wafer);
136  if (itr != copies.end() && cpy == copiesInLayers[layer].end()) {
137  copiesInLayers[layer][wafer] = itr->second;
138  }
139  if (itr == copies.end()) {
140  copies[wafer] = wafer2copy.size();
141  copiesInLayers[layer][wafer] = wafer2copy.size();
142  double xx = k_ScaleFromDDD*fv1.translation().X();
143  if (std::abs(xx) < 0.001) xx = 0;
144  double yy = k_ScaleFromDDD*fv1.translation().Y();
145  if (std::abs(yy) < 0.001) yy = 0;
146  wafer2copy.emplace_back(wafer);
147  GlobalPoint p(xx,yy,k_ScaleFromDDD*fv1.translation().Z());
148  HGCalGeomParameters::cellParameters cell(false,wafer,p);
149  wafers.emplace_back(cell);
150  if ( names.count(name) == 0 ) {
151  std::vector<double> zv, rv;
153  const DDPolyhedra & polyhedra = static_cast<DDPolyhedra>(sol);
154  zv = polyhedra.zVec();
155  rv = polyhedra.rMaxVec();
156  } else {
157  const DDExtrudedPolygon & polygon = static_cast<DDExtrudedPolygon>(sol);
158  zv = polygon.zVec();
159  rv = polygon.xVec();
160  }
161  php.waferR_ = rv[0]/std::cos(30.0*CLHEP::deg);
162  double dz = 0.5*(zv[1]-zv[0]);
163 #ifdef EDM_ML_DEBUG
164  std::cout << "Mode " << mode << " R " << php.waferR_ << " z " << dz
165  << std::endl;
166 #endif
168  mytr.lay = 1; mytr.bl = php.waferR_;
169  mytr.tl = php.waferR_; mytr.h = php.waferR_;
170  mytr.dz = dz; mytr.alpha = 0.0;
171  mytr.cellSize = waferSize_;
172  php.fillModule(mytr,false);
173  names.insert(name);
174  }
175  }
176  }
177  dodet = fv1.next();
178  }
179  }
180 
181  // Finally the cells
182  std::map<int,int> wafertype;
183  std::map<int,HGCalGeomParameters::cellParameters> cellsf, cellsc;
184  DDValue val2(attribute, sdTag3, 0.0);
185  DDSpecificsMatchesValueFilter filter2{val2};
186  DDFilteredView fv2(*cpv,filter2);
187  ok = fv2.firstChild();
188  if (!ok) {
189  edm::LogError("HGCalGeom") << " Attribute " << val2
190  << " not found but needed.";
191  throw cms::Exception("DDException") << "Attribute " << val2
192  << " not found but needed.";
193  } else {
194  dodet = true;
195  while (dodet) {
196  const DDSolid & sol = fv2.logicalPart().solid();
197  std::string name = sol.name();
198  std::vector<int> copy = fv2.copyNumbers();
199  int nsiz = (int)(copy.size());
200  int cellx= (nsiz > 0) ? copy[nsiz-1] : 0;
201  int wafer= (nsiz > 1) ? copy[nsiz-2] : 0;
202  int cell = cellx%1000;
203  int type = cellx/1000;
204  if (type != 1 && type != 2) {
205  edm::LogError("HGCalGeom") << "Funny cell # " << cell << " type "
206  << type << " in " << nsiz << " components";
207  throw cms::Exception("DDException") << "Funny cell # " << cell;
208  } else {
209  std::map<int,int>::iterator ktr = wafertype.find(wafer);
210  if (ktr == wafertype.end()) wafertype[wafer] = type;
211  bool newc(false);
212  std::map<int,HGCalGeomParameters::cellParameters>::iterator itr;
213  double cellsize = php.cellSize_[0];
214  if (type == 1) {
215  itr = cellsf.find(cell);
216  newc= (itr == cellsf.end());
217  } else {
218  itr = cellsc.find(cell);
219  newc= (itr == cellsc.end());
220  cellsize = php.cellSize_[1];
221  }
222  if (newc) {
223  bool half = (name.find("Half") != std::string::npos);
224  double xx = k_ScaleFromDDD*fv2.translation().X();
225  double yy = k_ScaleFromDDD*fv2.translation().Y();
226  if (half) {
227  math::XYZPointD p1(-2.0*cellsize/9.0,0,0);
228  math::XYZPointD p2 = fv2.rotation()(p1);
229  xx += (k_ScaleFromDDD*(p2.X()));
230  yy += (k_ScaleFromDDD*(p2.Y()));
231 #ifdef EDM_ML_DEBUG
232  std::cout << "Type " << type << " Cell " << cellx << " local "
233  << xx << ":" << yy << " new " << p1 << ":" << p2 <<"\n";
234 #endif
235  }
237  if (type == 1) {
238  cellsf[cell] = cp;
239  } else {
240  cellsc[cell] = cp;
241  }
242  }
243  }
244  dodet = fv2.next();
245  }
246  }
247 
248  if (((cellsf.size()+cellsc.size())==0) || (wafers.empty()) ||
249  (layers.empty())) {
250  edm::LogError("HGCalGeom") << "HGCalGeomParameters : number of cells "
251  << cellsf.size() << ":" << cellsc.size()
252  << " wafers " << wafers.size() << " layers "
253  << layers.size() << " illegal";
254  throw cms::Exception("DDException")
255  << "HGCalGeomParameters: mismatch between geometry and specpar: cells "
256  << cellsf.size() << ":" << cellsc.size() << " wafers " << wafers.size()
257  << " layers " << layers.size();
258  }
259 
260  for (unsigned int i=0; i<layers.size(); ++i) {
261  for (auto & layer : layers) {
262  if (layer.first == (int)(i+1)) {
263  php.layerIndex_.emplace_back(i);
264  php.rMinLayHex_.emplace_back(layer.second.rmin);
265  php.rMaxLayHex_.emplace_back(layer.second.rmax);
266  php.zLayerHex_.emplace_back(layer.second.zpos);
267  break;
268  }
269  }
270  }
271  for (unsigned int i=0; i<php.layer_.size(); ++i) {
272  for (unsigned int i1=0; i1<trforms.size(); ++i1) {
273  if (!trformUse[i1] && php.layerGroup_[trforms[i1].lay-1] ==
274  (int)(i+1)) {
275  trforms[i1].h3v *= k_ScaleFromDDD;
276  trforms[i1].lay = (i+1);
277  trformUse[i1] = true;
278  php.fillTrForm(trforms[i1]);
279  int nz(1);
280  for (unsigned int i2=i1+1; i2<trforms.size(); ++i2) {
281  if (!trformUse[i2] && trforms[i2].zp == trforms[i1].zp &&
282  php.layerGroup_[trforms[i2].lay-1] == (int)(i+1)) {
283  php.addTrForm(k_ScaleFromDDD*trforms[i2].h3v);
284  nz++;
285  trformUse[i2] = true;
286  }
287  }
288  if (nz > 0) {
289  php.scaleTrForm(double(1.0/nz));
290  }
291  }
292  }
293  }
294 
295  double rmin = k_ScaleFromDDD*php.waferR_;
296  for (unsigned i = 0; i < wafer2copy.size(); ++i ) {
297  php.waferCopy_.emplace_back(wafer2copy[i]);
298  php.waferPosX_.emplace_back(wafers[i].xyz.x());
299  php.waferPosY_.emplace_back(wafers[i].xyz.y());
300  std::map<int,int>::iterator ktr = wafertype.find(wafer2copy[i]);
301  int typet = (ktr == wafertype.end()) ? 0 : (ktr->second);
302  php.waferTypeT_.emplace_back(typet);
303  double r = wafers[i].xyz.perp();
304  int type(3);
305  for (int k=1; k<4; ++k) {
306  if ((r+rmin)<=php.boundR_[k]) {
307  type = k; break;
308  }
309  }
310  php.waferTypeL_.emplace_back(type);
311  }
312  php.copiesInLayers_ = copiesInLayers;
313  php.nSectors_ = (int)(php.waferCopy_.size());
314 
315  std::vector<HGCalGeomParameters::cellParameters>::const_iterator itrf = wafers.end();
316  for (unsigned int i=0; i<cellsf.size(); ++i) {
317  std::map<int,HGCalGeomParameters::cellParameters>::iterator itr = cellsf.find(i);
318  if (itr == cellsf.end()) {
319  edm::LogError("HGCalGeom") << "HGCalGeomParameters: missing info for"
320  << " fine cell number " << i;
321  throw cms::Exception("DDException")
322  << "HGCalGeomParameters: missing info for fine cell number " << i;
323  } else {
324  double xx = (itr->second).xyz.x();
325  double yy = (itr->second).xyz.y();
326  int waf= (itr->second).wafer;
327  std::pair<double,double> xy = cellPosition(wafers,itrf,waf,xx,yy);
328  php.cellFineX_.emplace_back(xy.first);
329  php.cellFineY_.emplace_back(xy.second);
330  php.cellFineHalf_.emplace_back((itr->second).half);
331  }
332  }
333  itrf = wafers.end();
334  for (unsigned int i=0; i<cellsc.size(); ++i) {
335  std::map<int,HGCalGeomParameters::cellParameters>::iterator itr = cellsc.find(i);
336  if (itr == cellsc.end()) {
337  edm::LogError("HGCalGeom") << "HGCalGeomParameters: missing info for"
338  << " coarse cell number " << i;
339  throw cms::Exception("DDException")
340  << "HGCalGeomParameters: missing info for coarse cell number " << i;
341  } else {
342  double xx = (itr->second).xyz.x();
343  double yy = (itr->second).xyz.y();
344  int waf= (itr->second).wafer;
345  std::pair<double,double> xy = cellPosition(wafers,itrf,waf,xx,yy);
346  php.cellCoarseX_.emplace_back(xy.first);
347  php.cellCoarseY_.emplace_back(xy.second);
348  php.cellCoarseHalf_.emplace_back((itr->second).half);
349  }
350  }
351  int depth(0);
352  for (unsigned int i=0; i<php.layerGroup_.size(); ++i) {
353  bool first(true);
354  for (unsigned int k=0; k<php.layerGroup_.size(); ++k) {
355  if (php.layerGroup_[k] == (int)(i+1)) {
356  if (first) {
357  php.depth_.emplace_back(i+1);
358  php.depthIndex_.emplace_back(depth);
359  php.depthLayerF_.emplace_back(k);
360  ++depth;
361  first = false;
362  }
363  }
364  }
365  }
366  HGCalParameters::hgtrap mytr = php.getModule(0, false);
367  mytr.bl *= k_ScaleFromDDD;
368  mytr.tl *= k_ScaleFromDDD;
369  mytr.h *= k_ScaleFromDDD;
370  mytr.dz *= k_ScaleFromDDD;
371  double dz = mytr.dz;
372  php.fillModule(mytr, true);
373  mytr.dz = 2*dz;
374  php.fillModule(mytr, true);
375  mytr.dz = 3*dz;
376  php.fillModule(mytr, true);
377 #ifdef EDM_ML_DEBUG
378  std::cout << "HGCalGeomParameters finds " << php.zLayerHex_.size()
379  << " layers" << std::endl;
380  for (unsigned int i=0; i<php.zLayerHex_.size(); ++i) {
381  int k = php.layerIndex_[i];
382  std::cout << "Layer[" << i << ":" << k << ":" << php.layer_[k]
383  << "] with r = " << php.rMinLayHex_[i] << ":"
384  << php.rMaxLayHex_[i] << " at z = " << php.zLayerHex_[i]
385  << std::endl;
386  }
387  std::cout << "HGCalGeomParameters has " << php.depthIndex_.size()
388  << " depths" <<std::endl;
389  for (unsigned int i=0; i<php.depthIndex_.size(); ++i) {
390  int k = php.depthIndex_[i];
391  std::cout << "Reco Layer[" << i << ":" << k << "] First Layer "
392  << php.depthLayerF_[i] << " Depth " << php.depth_[k] <<std::endl;
393  }
394  std::cout << "HGCalGeomParameters finds " << php.nSectors_ << " wafers\n";
395  for (unsigned int i=0; i<php.waferCopy_.size(); ++i)
396  std::cout << "Wafer[" << i << ": " << php.waferCopy_[i] << "] type "
397  << php.waferTypeL_[i] << ":" << php.waferTypeT_[i] << " at ("
398  << php.waferPosX_[i] << "," << php.waferPosY_[i] << ",0)\n";
399  std::cout << "HGCalGeomParameters: wafer radius " << php.waferR_
400  << " and dimensions of the wafers:" << std::endl;
401  std::cout << "Sim[0] " << php.moduleLayS_[0] << " dx " << php.moduleBlS_[0]
402  << ":" << php.moduleTlS_[0] << " dy " << php.moduleHS_[0] << " dz "
403  << php.moduleDzS_[0] << " alpha " << php.moduleAlphaS_[0] << "\n";
404  for (unsigned int k=0; k<php.moduleLayR_.size(); ++k)
405  std::cout << "Rec[" << k << "] " << php.moduleLayR_[k] << " dx "
406  << php.moduleBlR_[k] << ":" << php.moduleTlR_[k] << " dy "
407  << php.moduleHR_[k] << " dz " << php.moduleDzR_[k] << " alpha "
408  << php.moduleAlphaR_[k] << std::endl;
409  std::cout << "HGCalGeomParameters finds " << php.cellFineX_.size()
410  << " fine cells in a wafer" << std::endl;
411  for (unsigned int i=0; i<php.cellFineX_.size(); ++i)
412  std::cout << "Fine Cell[" << i << "] at (" << php.cellFineX_[i] << ","
413  << php.cellFineY_[i] << ",0)" << std::endl;
414  std::cout << "HGCalGeomParameters finds " << php.cellCoarseX_.size()
415  << " coarse cells in a wafer" << std::endl;
416  for (unsigned int i=0; i<php.cellCoarseX_.size(); ++i)
417  std::cout << "Coarse Cell[" << i << "] at (" << php.cellCoarseX_[i]
418  << "," << php.cellCoarseY_[i] << ",0)" << std::endl;
419  std::cout << "Obtained " << php.trformIndex_.size()
420  << " transformation matrices" << std::endl;
421  for (unsigned int k=0; k<php.trformIndex_.size(); ++k) {
422  std::cout << "Matrix[" << k << "] (" << std::hex << php.trformIndex_[k]
423  << std::dec << ") Trnaslation (" << php.trformTranX_[k]
424  << ", " << php.trformTranY_[k] << ", " << php.trformTranZ_[k]
425  << " Rotation (" << php.trformRotXX_[k] << ", "
426  << php.trformRotYX_[k] << ", " << php.trformRotZX_[k] << ", "
427  << php.trformRotXY_[k] << ", " << php.trformRotYY_[k] << ", "
428  << php.trformRotZY_[k] << ", " << php.trformRotXZ_[k] << ", "
429  << php.trformRotYZ_[k] << ", " << php.trformRotZZ_[k] << ")\n";
430  }
431  std::cout << "Dump copiesInLayers for " << php.copiesInLayers_.size()
432  << " layers\n";
433  for (unsigned int k=0; k<php.copiesInLayers_.size(); ++k) {
434  const auto& theModules = php.copiesInLayers_[k];
435  std::cout << "Layer " << k << ":" << theModules.size() << std::endl;
436  int k2(0);
437  for (std::unordered_map<int, int>::const_iterator itr=theModules.begin();
438  itr != theModules.end(); ++itr) {
439  std::cout << " " << itr->first << ":" << itr->second;
440  ++k2;
441  if (k2 > 9) { std::cout << std::endl; k2 = 0; }
442  }
443  if (k2 > 0) std::cout << std::endl;
444  }
445 #endif
446 }
std::vector< double > waferPosY_
type
Definition: HCALResponse.h:21
std::vector< int > layer_
std::vector< double > moduleDzR_
std::vector< int > depthLayerF_
std::vector< int > depth_
std::vector< double > moduleHR_
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
layer_map copiesInLayers_
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
Definition: LayerTriplets.cc:4
const N & name() const
Definition: DDBase.h:78
std::vector< bool > cellCoarseHalf_
static const HistoName names[]
std::vector< bool > cellFineHalf_
std::vector< double > rMaxVec(void) const
Definition: DDSolid.cc:457
def copy(args, dbName)
std::vector< int > moduleLayR_
nav_type copyNumbers() const
return the stack of copy numbers
std::vector< double > moduleHS_
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
std::vector< double > trformTranY_
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< double > cellFineY_
std::vector< double > trformRotZY_
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
std::vector< uint32_t > trformIndex_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::vector< double > trformRotXX_
A DDSolid represents the shape of a part.
Definition: DDSolid.h:38
void fillTrForm(const hgtrform &mytr)
std::vector< double > trformRotZX_
std::vector< double > xVec(void) const
Definition: DDSolid.cc:500
std::vector< double > cellCoarseX_
std::vector< double > trformRotYZ_
std::pair< double, double > cellPosition(const std::vector< cellParameters > &wafers, std::vector< cellParameters >::const_iterator &itrf, int wafer, double xx, double yy)
std::vector< double > boundR_
std::vector< double > cellSize_
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
std::vector< double > moduleDzS_
bool next()
set current node to the next node in the filtered tree
std::vector< int > layerIndex_
std::vector< double > moduleAlphaR_
susybsm::HSCParticleRef hr
Definition: classes.h:26
std::vector< double > trformRotXY_
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
std::vector< double > trformRotYX_
hgtrap getModule(unsigned int k, bool reco) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< std::unordered_map< int32_t, int32_t > > layer_map
std::vector< double > moduleBlR_
std::vector< double > rMinLayHex_
void fillModule(const hgtrap &mytr, bool reco)
double p2[4]
Definition: TauolaWrapper.h:90
std::vector< double > moduleTlS_
double rOut(void) const
Definition: DDSolid.cc:611
std::vector< double > zLayerHex_
int k[5][pyjets_maxn]
std::vector< double > rMaxLayHex_
std::vector< double > trformTranX_
std::vector< double > zVec(void) const
Definition: DDSolid.cc:514
std::vector< double > trformRotXZ_
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double > > XYZPointD
point in space with cartesian internal representation
Definition: Point3D.h:8
std::vector< double > zVec(void) const
Definition: DDSolid.cc:441
void scaleTrForm(double)
std::vector< int > layerGroup_
std::vector< double > trformRotYY_
std::vector< double > cellFineX_
std::vector< double > trformRotZZ_
std::vector< double > moduleAlphaS_
std::vector< double > moduleBlS_
double p1[4]
Definition: TauolaWrapper.h:89
std::vector< int > waferCopy_
const double k_ScaleFromDDD
std::vector< int > depthIndex_
std::vector< int > waferTypeT_
const DDTranslation & translation() const
The absolute translation of the current node.
std::vector< double > cellCoarseY_
std::vector< int > moduleLayS_
std::vector< double > trformTranZ_
double rIn(void) const
Definition: DDSolid.cc:608
std::vector< double > waferPosX_
void addTrForm(const CLHEP::Hep3Vector &h3v)
std::vector< double > moduleTlR_
std::vector< int > waferTypeL_
void HGCalGeomParameters::loadSpecParsHexagon ( const DDFilteredView fv,
HGCalParameters php,
const DDCompactView cpv,
const std::string &  sdTag1,
const std::string &  sdTag2 
)

Definition at line 448 of file HGCalGeomParameters.cc.

References HGCalParameters::boundR_, gather_cfg::cout, dbl_to_int(), DDFilteredView::firstChild(), getDDDArray(), gen::k, k_ScaleFromDDD, HGCalParameters::layerGroup_, HGCalParameters::layerGroupM_, HGCalParameters::layerGroupO_, HGCalParameters::levelT_, DDFilteredView::mergedSpecifics(), HGCalParameters::rLimit_, HGCalParameters::slopeMin_, AlCaHLTBitMon_QueryRunRegistry::string, and waferSize_.

Referenced by HGCalParametersFromDD::build().

452  {
453 
455  int nmin(4);
456  php.boundR_ = getDDDArray("RadiusBound",sv,nmin);
457  for (double & k : php.boundR_)
458  k *= k_ScaleFromDDD;
459 #ifdef EDM_ML_DEBUG
460  std::cout << "HGCalGeomParameters: wafer radius ranges for cell grouping "
461  << php.boundR_[0] << ":" << php.boundR_[1] << ":"
462  << php.boundR_[2] << ":" << php.boundR_[3] << std::endl;
463 #endif
464  nmin = 2;
465  php.rLimit_ = getDDDArray("RadiusLimits",sv,nmin);
466  for (double & k : php.rLimit_)
467  k *= k_ScaleFromDDD;
468 #ifdef EDM_ML_DEBUG
469  std::cout << "HGCalGeomParameters: Minimum/maximum R "
470  << php.rLimit_[0] << ":" << php.rLimit_[1] << "\n";
471 #endif
472  nmin = 0;
473  std::vector<int> ndummy = dbl_to_int(getDDDArray("LevelTop",sv,nmin));
474  php.levelT_ = ndummy[0];
475 #ifdef EDM_ML_DEBUG
476  std::cout << "HGCalGeomParameters: LevelTop " << php.levelT_ << "\n";
477 #endif
478 
479  //Grouping of layers
480  nmin = 0;
481  php.layerGroup_ = dbl_to_int(getDDDArray("GroupingZFine",sv,nmin));
482  php.layerGroupM_ = dbl_to_int(getDDDArray("GroupingZMid",sv,nmin));
483  php.layerGroupO_ = dbl_to_int(getDDDArray("GroupingZOut",sv,nmin));
484  nmin = 1;
485  std::vector<double> slp = getDDDArray("Slope",sv,nmin);
486  php.slopeMin_ = slp[0];
487 #ifdef EDM_ML_DEBUG
488  std::cout << "HGCalGeomParameters: minimum slope " << php.slopeMin_
489  << " and layer groupings for the 3 ranges:" << std::endl;
490  for (int k=0; k<nmin; ++k)
491  std::cout << "[" << k << "] " << php.layerGroup_[k] << ":"
492  << php.layerGroupM_[k] << ":" << php.layerGroupO_[k] << "\n";
493 #endif
494 
495  //Wafer size
496  std::string attribute = "Volume";
497  DDSpecificsMatchesValueFilter filter1{DDValue(attribute, sdTag1, 0.0)};
498  DDFilteredView fv1(*cpv,filter1);
499  if (fv1.firstChild()) {
500  DDsvalues_type sv(fv1.mergedSpecifics());
501  int nmin(0);
502  std::vector<double> dummy = getDDDArray("WaferSize",sv,nmin);
503  waferSize_ = dummy[0];
504  }
505 #ifdef EDM_ML_DEBUG
506  std::cout << "HGCalGeomParameters: Wafer Size: " << waferSize_ << std::endl;
507 #endif
508 
509  //Cell size
510  DDSpecificsMatchesValueFilter filter2{DDValue(attribute, sdTag2, 0.0)};
511  DDFilteredView fv2(*cpv,filter2);
512  if (fv2.firstChild()) {
513  DDsvalues_type sv(fv2.mergedSpecifics());
514  int nmin(0);
515  php.cellSize_ = getDDDArray("CellSize",sv,nmin);
516  }
517 #ifdef EDM_ML_DEBUG
518  std::cout << "HGCalGeomParameters: " << php.cellSize_.size()
519  << " cells of sizes:\n";
520  for (unsigned int k=0; k<php.cellSize_.size(); ++k)
521  std::cout << " [" << k << "] " << php.cellSize_[k] << "\n";
522 #endif
523 
524 }
std::vector< int > layerGroupM_
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< double > boundR_
std::vector< double > cellSize_
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 > getDDDArray(const std::string &, const DDsvalues_type &, int &)
int k[5][pyjets_maxn]
std::vector< int > layerGroup_
DDsvalues_type mergedSpecifics() const
std::vector< int > layerGroupO_
const double k_ScaleFromDDD
std::vector< double > rLimit_
void HGCalGeomParameters::loadWaferHexagon ( HGCalParameters php)

Definition at line 526 of file HGCalGeomParameters.cc.

References HGCalParameters::boundR_, HGCalParameters::copiesInLayers_, popcon2dropbox::copy(), TCMET_cfi::corner, gather_cfg::cout, PVValHelper::dx, PVValHelper::dy, createfilelist::int, gen::k, k_ScaleFromDDD, HGCalParameters::layer_, create_public_lumi_plots::ncol, HGCalParameters::nSectors_, HGCalParameters::rLimit_, HGCalParameters::rMaxLayHex_, HGCalParameters::rMinLayHex_, findQualityFiles::rr, mathSSE::sqrt(), funct::tan(), HGCalParameters::waferCopy_, HGCalParameters::waferPosX_, HGCalParameters::waferPosY_, HGCalParameters::waferR_, waferSize_, HGCalParameters::waferTypeL_, and HGCalParameters::waferTypeT_.

Referenced by HGCalParametersFromDD::build().

526  {
527 
528  double waferW(k_ScaleFromDDD*waferSize_), rmin(k_ScaleFromDDD*php.waferR_);
529  double rin(php.rLimit_[0]), rout(php.rLimit_[1]), rMaxFine(php.boundR_[1]);
530 #ifdef EDM_ML_DEBUG
531  std::cout << "Input waferWidth " << waferW << ":" << rmin
532  << " R Limits: " << rin << ":" << rout
533  << " Fine " << rMaxFine << "\n";
534 #endif
535  // Clear the vectors
536  php.waferCopy_.clear();
537  php.waferTypeL_.clear();
538  php.waferTypeT_.clear();
539  php.waferPosX_.clear();
540  php.waferPosY_.clear();
541  double dx = 0.5*waferW;
542  double dy = 3.0*dx*tan(30.0*CLHEP::deg);
543  double rr = 2.0*dx*tan(30.0*CLHEP::deg);
544  int ncol = (int)(2.0*rout/waferW) + 1;
545  int nrow = (int)(rout/(waferW*tan(30.0*CLHEP::deg))) + 1;
546  int incm(0), inrm(0), kount(0), ntot(0);
547  double xc[6], yc[6];
548  HGCalParameters::layer_map copiesInLayers(php.layer_.size()+1);
549 #ifdef EDM_ML_DEBUG
550  std::cout << "Row " << nrow << " Column " << ncol << std::endl;
551 #endif
552  for (int nr=-nrow; nr <= nrow; ++nr) {
553  int inr = (nr >= 0) ? nr : -nr;
554  for (int nc=-ncol; nc <= ncol; ++nc) {
555  int inc = (nc >= 0) ? nc : -nc;
556  if (inr%2 == inc%2) {
557  double xpos = nc*dx;
558  double ypos = nr*dy;
559  xc[0] = xpos+dx; yc[0] = ypos-0.5*rr;
560  xc[1] = xpos+dx; yc[1] = ypos+0.5*rr;
561  xc[2] = xpos; yc[2] = ypos+rr;
562  xc[3] = xpos-dx; yc[3] = ypos+0.5*rr;
563  xc[4] = xpos+dx; yc[4] = ypos-0.5*rr;
564  xc[5] = xpos; yc[5] = ypos-rr;
565  bool cornerOne(false);
566  bool cornerAll(true);
567  for (int k=0; k<6; ++k) {
568  double rpos = std::sqrt(xc[k]*xc[k]+yc[k]*yc[k]);
569  if (rpos >= rin && rpos <= rout) cornerOne = true;
570  else cornerAll = false;
571  }
572  double rpos = std::sqrt(xpos*xpos+ypos*ypos);
573  int typet = (rpos < rMaxFine) ? 1 : 2;
574  int typel(3);
575  for (int k=1; k<4; ++k) {
576  if ((rpos+rmin)<=php.boundR_[k]) {
577  typel = k; break;
578  }
579  }
580  ++ntot;
581  if (cornerOne) {
582  int copy = inr*100 + inc;
583  if (nc < 0) copy += 10000;
584  if (nr < 0) copy += 100000;
585  if (inc > incm) incm = inc;
586  if (inr > inrm) inrm = inr;
587  kount++;
588 #ifdef EDM_ML_DEBUG
589  std::cout << kount << ":" << ntot << " Copy " << copy
590  << " Type " << typel << ":" << typet
591  << " Location " << cornerOne << ":" << cornerAll
592  << " Position " << xpos << ":" << ypos << "\n";
593 #endif
594  php.waferCopy_.emplace_back(copy);
595  php.waferTypeL_.emplace_back(typel);
596  php.waferTypeT_.emplace_back(typet);
597  php.waferPosX_.emplace_back(xpos);
598  php.waferPosY_.emplace_back(ypos);
599  for (unsigned int il=0; il<php.layer_.size(); ++il) {
600  bool corner(false);
601  cornerAll = true;
602  for (int k=0; k<6; ++k) {
603  double rpos = std::sqrt(xc[k]*xc[k]+yc[k]*yc[k]);
604  if (rpos >= php.rMinLayHex_[il] &&
605  rpos <= php.rMaxLayHex_[il]) corner = true;
606  else cornerAll = false;
607  }
608  if (corner) {
609  std::unordered_map<int32_t,int32_t>::iterator cpy =
610  copiesInLayers[php.layer_[il]].find(copy);
611  if (cpy == copiesInLayers[php.layer_[il]].end())
612  copiesInLayers[php.layer_[il]][copy] = cornerAll ? php.waferCopy_.size() : -1;
613  }
614  }
615  }
616  }
617  }
618  }
619  php.copiesInLayers_ = copiesInLayers;
620  php.nSectors_ = (int)(php.waferCopy_.size());
621 #ifdef EDM_ML_DEBUG
622  std::cout << "HGCalWaferHexagon: # of columns " << incm << " # of rows "
623  << inrm << " and " << kount << ":" << ntot << " wafers; R "
624  << rin << ":" << rout << std::endl;
625  std::cout << "Dump copiesInLayers for " << php.copiesInLayers_.size()
626  << " layers\n";
627  for (unsigned int k=0; k<copiesInLayers.size(); ++k) {
628  const auto& theModules = copiesInLayers[k];
629  std::cout << "Layer " << k << ":" << theModules.size() << std::endl;
630  int k2(0);
631  for (std::unordered_map<int, int>::const_iterator itr=theModules.begin();
632  itr != theModules.end(); ++itr) {
633  std::cout << " " << itr->first << ":" << itr->second;
634  ++k2;
635  if (k2 > 9) { std::cout << std::endl; k2 = 0; }
636  }
637  if (k2 > 0) std::cout << std::endl;
638  }
639 #endif
640 }
std::vector< double > waferPosY_
std::vector< int > layer_
layer_map copiesInLayers_
def copy(args, dbName)
std::vector< double > boundR_
T sqrt(T t)
Definition: SSEVec.h:18
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
std::vector< std::unordered_map< int32_t, int32_t > > layer_map
std::vector< double > rMinLayHex_
int k[5][pyjets_maxn]
std::vector< double > rMaxLayHex_
std::vector< int > waferCopy_
const double k_ScaleFromDDD
std::vector< double > rLimit_
std::vector< int > waferTypeT_
std::vector< double > waferPosX_
std::vector< int > waferTypeL_

Member Data Documentation

double HGCalGeomParameters::waferSize_
private