CMS 3D CMS Logo

DDHGCalEEAlgo.cc
Go to the documentation of this file.
1 // File: DDHGCalEEAlgo.cc
3 // Description: Geometry factory class for HGCal (EE and HESil)
5 
15 #include "CLHEP/Units/GlobalPhysicalConstants.h"
16 #include "CLHEP/Units/GlobalSystemOfUnits.h"
17 
18 //#define EDM_ML_DEBUG
19 
21 #ifdef EDM_ML_DEBUG
22  edm::LogVerbatim("HGCalGeom") << "DDHGCalEEAlgo: Creating an instance";
23 #endif
24 }
25 
27 
29  const DDVectorArguments & vArgs,
30  const DDMapArguments & ,
31  const DDStringArguments & sArgs,
32  const DDStringVectorArguments &vsArgs) {
33 
34  wafers_ = vsArgs["WaferNames"];
35 #ifdef EDM_ML_DEBUG
36  edm::LogVerbatim("HGCalGeom") << "DDHGCalEEAlgo: " << wafers_.size()
37  << " wafers";
38  for (unsigned int i=0; i<wafers_.size(); ++i)
39  edm::LogVerbatim("HGCalGeom") << "Wafer[" << i << "] " << wafers_[i];
40 #endif
41  materials_ = vsArgs["MaterialNames"];
42  names_ = vsArgs["VolumeNames"];
43  thick_ = vArgs["Thickness"];
44  for (unsigned int i=0; i<materials_.size(); ++i) {
45  copyNumber_.emplace_back(1);
46  }
47 #ifdef EDM_ML_DEBUG
48  edm::LogVerbatim("HGCalGeom") << "DDHGCalEEAlgo: " << materials_.size()
49  << " types of volumes";
50  for (unsigned int i=0; i<names_.size(); ++i)
51  edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << names_[i]
52  << " of thickness " << thick_[i]
53  << " filled with " << materials_[i]
54  << " first copy number " << copyNumber_[i];
55 #endif
56  layers_ = dbl_to_int(vArgs["Layers"]);
57  layerThick_ = vArgs["LayerThick"];
58 #ifdef EDM_ML_DEBUG
59  edm::LogVerbatim("HGCalGeom") << "There are " << layers_.size() << " blocks";
60  for (unsigned int i=0; i<layers_.size(); ++i)
61  edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] of thickness "
62  << layerThick_[i]
63  << " with " << layers_[i] << " layers";
64 #endif
65  layerType_ = dbl_to_int(vArgs["LayerType"]);
66  layerSense_ = dbl_to_int(vArgs["LayerSense"]);
67  firstLayer_ = (int)(nArgs["FirstLayer"]);
68  if (firstLayer_ > 0) {
69  for (unsigned int i=0; i<layerType_.size(); ++i) {
70  if (layerSense_[i] != 0) {
71  int ii = layerType_[i];
72  copyNumber_[ii] = firstLayer_;
73 #ifdef EDM_ML_DEBUG
74  edm::LogVerbatim("HGCalGeom") << "First copy number for layer type "
75  << i << ":" << ii << " with "
76  << materials_[ii] << " changed to "
77  << copyNumber_[ii];
78 #endif
79  break;
80  }
81  }
82  }
83 #ifdef EDM_ML_DEBUG
84  edm::LogVerbatim("HGCalGeom") << "There are " << layerType_.size()
85  << " layers" ;
86  for (unsigned int i=0; i<layerType_.size(); ++i)
87  edm::LogVerbatim("HGCalGeom") << "Layer [" << i << "] with material type "
88  << layerType_[i] << " sensitive class "
89  << layerSense_[i];
90 #endif
91  zMinBlock_ = nArgs["zMinBlock"];
92  rad100to200_ = vArgs["rad100to200"];
93  rad200to300_ = vArgs["rad200to300"];
94  zMinRadPar_ = nArgs["zMinForRadPar"];
95  choiceType_ = (int)(nArgs["choiceType"]);
96  nCutRadPar_ = (int)(nArgs["nCornerCut"]);
97  fracAreaMin_ = nArgs["fracAreaMin"];
98  waferSize_ = nArgs["waferSize"];
99  waferSepar_ = nArgs["SensorSeparation"];
100  sectors_ = (int)(nArgs["Sectors"]);
101 #ifdef EDM_ML_DEBUG
102  edm::LogVerbatim("HGCalGeom") << "zStart " << zMinBlock_
103  << " radius for wafer type separation uses "
104  << rad100to200_.size() << " parameters; zmin "
105  << zMinRadPar_ << " cutoff " << choiceType_
106  << ":" << nCutRadPar_ << ":" << fracAreaMin_
107  << " wafer width " << waferSize_
108  << " separations " << waferSepar_
109  << " sectors " << sectors_;
110  for (unsigned int k=0; k<rad100to200_.size(); ++k)
111  edm::LogVerbatim("HGCalGeom") << "[" << k << "] 100-200 " <<rad100to200_[k]
112  << " 200-300 " << rad200to300_[k];
113 #endif
114  slopeB_ = vArgs["SlopeBottom"];
115  zFrontB_ = vArgs["ZFrontBottom"];
116  rMinFront_ = vArgs["RMinFront"];
117  slopeT_ = vArgs["SlopeTop"];
118  zFrontT_ = vArgs["ZFrontTop"];
119  rMaxFront_ = vArgs["RMaxFront"];
120 #ifdef EDM_ML_DEBUG
121  for (unsigned int i=0; i<slopeB_.size(); ++i)
122  edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] Zmin " << zFrontB_[i]
123  << " Rmin " << rMinFront_[i] << " Slope "
124  << slopeB_[i];
125  for (unsigned int i=0; i<slopeT_.size(); ++i)
126  edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] Zmin " << zFrontT_[i]
127  << " Rmax " << rMaxFront_[i] << " Slope "
128  << slopeT_[i];
129 #endif
131 #ifdef EDM_ML_DEBUG
132  edm::LogVerbatim("HGCalGeom") << "DDHGCalEEAlgo: NameSpace " << nameSpace_;
133 #endif
134 
135  waferType_ = std::make_unique<HGCalWaferType>(rad100to200_, rad200to300_,
139 }
140 
142 // DDHGCalEEAlgo methods...
144 
146 
147 #ifdef EDM_ML_DEBUG
148  edm::LogVerbatim("HGCalGeom") << "==>> Constructing DDHGCalEEAlgo...";
149  copies_.clear();
150 #endif
151  constructLayers (parent(), cpv);
152 #ifdef EDM_ML_DEBUG
153  edm::LogVerbatim("HGCalGeom") << "DDHGCalEEAlgo: " << copies_.size()
154  << " different wafer copy numbers";
155  int k(0);
156  for (std::unordered_set<int>::const_iterator itr=copies_.begin();
157  itr != copies_.end(); ++itr,++k) {
158  edm::LogVerbatim("HGCalGeom") << "Copy [" << k << "] : " << (*itr);
159  }
160  copies_.clear();
161  edm::LogVerbatim("HGCalGeom") << "<<== End of DDHGCalEEAlgo construction...";
162 #endif
163 }
164 
166  DDCompactView& cpv) {
167 
168 #ifdef EDM_ML_DEBUG
169  edm::LogVerbatim("HGCalGeom") << "DDHGCalEEAlgo: \t\tInside Layers";
170 #endif
171  double zi(zMinBlock_);
172  int laymin(0);
173  const double tol(0.01);
174  for (unsigned int i=0; i<layers_.size(); i++) {
175  double zo = zi + layerThick_[i];
177  int laymax = laymin+layers_[i];
178  double zz = zi;
179  double thickTot(0);
180  std::vector<double> pgonZ(2), pgonRin(2), pgonRout(2);
181  for (int ly=laymin; ly<laymax; ++ly) {
182  int ii = layerType_[ly];
183  int copy = copyNumber_[ii];
184  double hthick = 0.5*thick_[ii];
186  zz += hthick;
187  thickTot += thick_[ii];
188 
189  std::string name = names_[ii]+std::to_string(copy);
190 #ifdef EDM_ML_DEBUG
191  edm::LogVerbatim("HGCalGeom") << "DDHGCalEEAlgo: Layer " << ly << ":"
192  << ii << " Front " << zi << ", " << routF
193  << " Back " << zo << ", " << rinB
194  << " superlayer thickness "
195  << layerThick_[i];
196 #endif
197  DDName matName(DDSplit(materials_[ii]).first,
198  DDSplit(materials_[ii]).second);
199  DDMaterial matter(matName);
200  DDLogicalPart glog;
201  if (layerSense_[ly] == 0) {
202  double alpha = CLHEP::pi/sectors_;
203  double rmax = routF*cos(alpha) - tol;
204  pgonZ[0] =-hthick; pgonZ[1] = hthick;
205  pgonRin[0] = rinB; pgonRin[1] = rinB;
206  pgonRout[0] = rmax; pgonRout[1] = rmax;
208  sectors_,-alpha,CLHEP::twopi,
209  pgonZ, pgonRin, pgonRout);
210  glog = DDLogicalPart(solid.ddname(), matter, solid);
211 #ifdef EDM_ML_DEBUG
212  edm::LogVerbatim("HGCalGeom") << "DDHGCalEEAlgo: " << solid.name()
213  << " polyhedra of " << sectors_
214  << " sectors covering "
215  << -alpha/CLHEP::deg << ":"
216  << (-alpha+CLHEP::twopi)/CLHEP::deg
217  << " with " << pgonZ.size()
218  << " sections and filled with "
219  << matName << ":" << &matter;
220  for (unsigned int k=0; k<pgonZ.size(); ++k)
221  edm::LogVerbatim("HGCalGeom") << "[" << k << "] z " << pgonZ[k]
222  << " R " << pgonRin[k] << ":"
223  << pgonRout[k];
224 #endif
225  } else {
227  hthick, rinB, routF, 0.0,
228  CLHEP::twopi);
229  glog = DDLogicalPart(solid.ddname(), matter, solid);
230 #ifdef EDM_ML_DEBUG
231  edm::LogVerbatim("HGCalGeom") << "DDHGCalEEAlgo: " << solid.name()
232  << " Tubs made of " << matName << ":"
233  << &matter << " of dimensions " << rinB
234  << ", " << routF << ", " << hthick
235  << ", 0.0, " << CLHEP::twopi/CLHEP::deg
236  << " and position " << glog.name()
237  << " number " << copy;
238 #endif
239  positionSensitive(glog,rinB,routF,zz,layerSense_[ly],cpv);
240  }
241  DDTranslation r1(0,0,zz);
242  DDRotation rot;
243  cpv.position(glog, module, copy, r1, rot);
244  ++copyNumber_[ii];
245 #ifdef EDM_ML_DEBUG
246  edm::LogVerbatim("HGCalGeom") << "DDHGCalEEAlgo: " << glog.name()
247  << " number " << copy << " positioned in "
248  << module.name() << " at " << r1
249  << " with " << rot;
250 #endif
251  zz += hthick;
252  } // End of loop over layers in a block
253  zi = zo;
254  laymin = laymax;
255  if (std::abs(thickTot-layerThick_[i]) < 0.00001) {
256  } else if (thickTot > layerThick_[i]) {
257  edm::LogError("HGCalGeom") << "Thickness of the partition "
258  << layerThick_[i] << " is smaller than "
259  << thickTot << ": thickness of all its "
260  << "components **** ERROR ****";
261  } else if (thickTot < layerThick_[i]) {
262  edm::LogWarning("HGCalGeom") << "Thickness of the partition "
263  << layerThick_[i] << " does not match with "
264  << thickTot << " of the components";
265  }
266  } // End of loop over blocks
267 }
268 
269 void DDHGCalEEAlgo::positionSensitive(const DDLogicalPart& glog, double rin,
270  double rout, double zpos, int layertype,
271  DDCompactView& cpv) {
272  static const double sqrt3 = std::sqrt(3.0);
273  double r = 0.5*(waferSize_ + waferSepar_);
274  double R = 2.0*r/sqrt3;
275  double dy = 0.75*R;
276  int N = (int)(0.5*rout/r) + 2;
277 #ifdef EDM_ML_DEBUG
278  int ium(0), ivm(0), iumAll(0), ivmAll(0), kount(0), ntot(0), nin(0);
279  std::vector<int> ntype(6,0);
280  edm::LogVerbatim("HGCalGeom") << "DDHGCalEEAlgo: " << glog.ddname()
281  << " rout " << rout << " N " << N
282  << " for maximum u, v; r " << r << " R "
283  << R << " dy " << dy;
284 #endif
285  for (int u = -N; u <= N; ++u) {
286  int iu = std::abs(u);
287  for (int v = -N; v <= N; ++v) {
288  int iv = std::abs(v);
289  int nr = 2*v;
290  int nc =-2*u+v;
291  double xpos = nc*r;
292  double ypos = nr*dy;
293  std::pair<int,int> corner =
294  HGCalGeomTools::waferCorner(xpos, ypos, r, R, rin, rout, false);
295 #ifdef EDM_ML_DEBUG
296  ++ntot;
297  if (((corner.first <= 0) && std::abs(u) < 5 && std::abs(v) < 5) ||
298  (std::abs(u) < 2 && std::abs(v) < 2)) {
299  edm::LogVerbatim("HGCalGeom") << "DDHGCalEEAlgo: " << glog.ddname()
300  << " R " << rin << ":" << rout
301  << "\n Z " << zpos << " LayerType "
302  << layertype << " u " << u << " v " << v
303  << " with " << corner.first <<" corners";
304  }
305 #endif
306  if (corner.first > 0) {
307  int type = waferType_->getType(xpos,ypos,zpos);
308  int copy = type*1000000 + iv*100 + iu;
309  if (u < 0) copy += 10000;
310  if (v < 0) copy += 100000;
311 #ifdef EDM_ML_DEBUG
312  if (iu > ium) ium = iu;
313  if (iv > ivm) ivm = iv;
314  kount++;
315  if (copies_.count(copy) == 0) copies_.insert(copy);
316 #endif
317  if (corner.first == (int)(HGCalParameters::k_CornerSize)) {
318 #ifdef EDM_ML_DEBUG
319  if (iu > iumAll) iumAll = iu;
320  if (iv > ivmAll) ivmAll = iv;
321  ++nin;
322 #endif
323  DDTranslation tran(xpos, ypos, 0.0);
325  if (layertype > 1) type += 3;
327  DDSplit(wafers_[type]).second);
328  cpv.position(name, glog.ddname(), copy, tran, rotation);
329 #ifdef EDM_ML_DEBUG
330  ++ntype[type];
331  edm::LogVerbatim("HGCalGeom") << " DDHGCalEEAlgo: " << name
332  << " number " << copy
333  << " positioned in " << glog.ddname()
334  << " at " << tran
335  << " with " << rotation;
336 #endif
337  }
338  }
339  }
340  }
341 #ifdef EDM_ML_DEBUG
342  edm::LogVerbatim("HGCalGeom") << "DDHGCalEEAlgo: Maximum # of u " << ium
343  << ":" << iumAll << " # of v " << ivm << ":"
344  << ivmAll << " and " << nin << ":" << kount
345  << ":" << ntot << " wafers (" << ntype[0]
346  << ":" << ntype[1] << ":" << ntype[2] << ":"
347  << ntype[3] << ":" << ntype[4] << ":"
348  << ntype[5] << ") for " << glog.ddname()
349  << " R " << rin << ":" << rout;
350 #endif
351 }
type
Definition: HCALResponse.h:21
std::vector< double > slopeB_
Definition: DDHGCalEEAlgo.h:60
void execute(DDCompactView &cpv) override
~DDHGCalEEAlgo() override
float alpha
Definition: AMPTWrapper.h:95
std::unordered_set< int > copies_
Definition: DDHGCalEEAlgo.h:67
const N & name() const
Definition: DDBase.h:74
std::vector< double > zFrontT_
Definition: DDHGCalEEAlgo.h:64
std::vector< double > thick_
Definition: DDHGCalEEAlgo.h:43
std::vector< double > layerThick_
Definition: DDHGCalEEAlgo.h:46
def copy(args, dbName)
double fracAreaMin_
Definition: DDHGCalEEAlgo.h:56
static double radius(double z, std::vector< double > const &zFront, std::vector< double > const &rFront, std::vector< double > const &slope)
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:43
std::vector< int > copyNumber_
Definition: DDHGCalEEAlgo.h:44
std::vector< double > zFrontB_
Definition: DDHGCalEEAlgo.h:61
std::vector< std::string > wafers_
Definition: DDHGCalEEAlgo.h:40
std::string nameSpace_
Definition: DDHGCalEEAlgo.h:66
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
double waferSepar_
Definition: DDHGCalEEAlgo.h:58
static std::string & ns()
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
std::vector< double > slopeT_
Definition: DDHGCalEEAlgo.h:63
std::vector< int > layerSense_
Definition: DDHGCalEEAlgo.h:48
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
int nin
const Double_t pi
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:68
U second(std::pair< T, U > const &p)
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
static std::pair< int32_t, int32_t > waferCorner(double xpos, double ypos, double r, double R, double rMin, double rMax, bool oldBug=false)
double zMinRadPar_
Definition: DDHGCalEEAlgo.h:53
T sqrt(T t)
Definition: SSEVec.h:18
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
std::vector< int > layerType_
Definition: DDHGCalEEAlgo.h:47
static DDSolid tubs(const DDName &name, double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)
Definition: DDSolid.cc:865
std::vector< double > rad100to200_
Definition: DDHGCalEEAlgo.h:51
ii
Definition: cuy.py:590
int k[5][pyjets_maxn]
double zMinBlock_
Definition: DDHGCalEEAlgo.h:50
static uint32_t k_CornerSize
std::unique_ptr< HGCalWaferType > waferType_
Definition: DDHGCalEEAlgo.h:38
std::vector< int > layers_
Definition: DDHGCalEEAlgo.h:45
std::vector< std::string > names_
Definition: DDHGCalEEAlgo.h:42
#define N
Definition: blowfish.cc:9
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=0)
std::vector< double > rMinFront_
Definition: DDHGCalEEAlgo.h:62
void positionSensitive(const DDLogicalPart &glog, double rin, double rout, double zpos, int layertype, DDCompactView &cpv)
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
std::vector< std::string > materials_
Definition: DDHGCalEEAlgo.h:41
std::vector< double > rMaxFront_
Definition: DDHGCalEEAlgo.h:65
std::vector< double > rad200to300_
Definition: DDHGCalEEAlgo.h:52
Definition: vlib.h:208
static DDSolid polyhedra(const DDName &name, int sides, double startPhi, double deltaPhi, const std::vector< double > &z, const std::vector< double > &rmin, const std::vector< double > &rmax)
Creates a polyhedra (refere to Geant3 or Geant4 documentation)
Definition: DDSolid.cc:730
double waferSize_
Definition: DDHGCalEEAlgo.h:57
const N & ddname() const
Definition: DDBase.h:76
void constructLayers(const DDLogicalPart &, DDCompactView &cpv)