CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Attributes | Static Private Attributes
DDHGCalModule Class Reference
Inheritance diagram for DDHGCalModule:

Public Member Functions

 DDHGCalModule ()
 
void execute (DDCompactView &cpv) override
 
void initialize (const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
 

Protected Member Functions

void constructLayers (const DDLogicalPart &, DDCompactView &cpv)
 
void positionSensitive (DDLogicalPart &glog, double rin, double rout, DDCompactView &cpv)
 
double rMax (double z)
 

Private Attributes

std::unordered_set< int > copies_
 
std::vector< int > copyNumber_
 
std::string idNameSpace_
 
std::vector< int > layers_
 
std::vector< int > layerSense_
 
std::vector< double > layerThick_
 
std::vector< int > layerType_
 
std::vector< std::string > materials_
 
std::vector< std::string > names_
 
double rMaxFine_
 
std::vector< double > rMaxFront_
 
int sectors_
 
std::vector< double > slopeB_
 
std::vector< double > slopeT_
 
std::vector< double > thick_
 
std::vector< std::string > wafer_
 
double waferW_
 
std::vector< double > zFront_
 
double zMinBlock_
 

Static Private Attributes

static constexpr double tol_ = 0.00001
 

Detailed Description

Definition at line 32 of file DDHGCalModule.cc.

Constructor & Destructor Documentation

◆ DDHGCalModule()

DDHGCalModule::DDHGCalModule ( )

Definition at line 73 of file DDHGCalModule.cc.

73  {
74 #ifdef EDM_ML_DEBUG
75  edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: Creating an instance";
76 #endif
77 }
Log< level::Info, true > LogVerbatim

Member Function Documentation

◆ constructLayers()

void DDHGCalModule::constructLayers ( const DDLogicalPart module,
DDCompactView cpv 
)
protected

Definition at line 163 of file DDHGCalModule.cc.

References simBeamSpotPI::alpha, angle_units::operators::convertRadToDeg(), filterCSVwithJSON::copy, funct::cos(), DDBase< N, C >::ddname(), DDSplit(), dqmdumpme::first, mps_fire::i, cuy::ii, dqmdumpme::k, Skims_PA_cff::name, DDBase< N, C >::name(), DDSolidFactory::polyhedra(), DDCompactView::position(), photonAnalyzer_cfi::rMax, makeMuonMisalignmentScenario::rot, edm::second(), AlCaHLTBitMon_QueryRunRegistry::string, to_string(), DDSolidFactory::tubs(), and geometryCSVtoXML::zz.

163  {
164 #ifdef EDM_ML_DEBUG
165  edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: \t\tInside Layers";
166 #endif
167  double zi(zMinBlock_);
168  int laymin(0);
169  const double tol(0.01);
170  for (unsigned int i = 0; i < layers_.size(); i++) {
171  double zo = zi + layerThick_[i];
172  double routF = rMax(zi);
173  int laymax = laymin + layers_[i];
174  double zz = zi;
175  double thickTot(0);
176  for (int ly = laymin; ly < laymax; ++ly) {
177  int ii = layerType_[ly];
178  int copy = copyNumber_[ii];
179  double rinB = (layerSense_[ly] == 0) ? (zo * slopeB_[0]) : (zo * slopeB_[1]);
180  zz += (0.5 * thick_[ii]);
181  thickTot += thick_[ii];
182 
183  std::string name = "HGCal" + names_[ii] + std::to_string(copy);
184 #ifdef EDM_ML_DEBUG
185  edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: Layer " << ly << ":" << ii << " Front " << zi << ", " << routF
186  << " Back " << zo << ", " << rinB << " superlayer thickness " << layerThick_[i];
187 #endif
189  DDMaterial matter(matName);
190  DDLogicalPart glog;
191  if (layerSense_[ly] == 0) {
192  double alpha = 1._pi / sectors_;
193  double rmax = routF * cos(alpha) - tol;
194  std::vector<double> pgonZ, pgonRin, pgonRout;
195  pgonZ.emplace_back(-0.5 * thick_[ii]);
196  pgonZ.emplace_back(0.5 * thick_[ii]);
197  pgonRin.emplace_back(rinB);
198  pgonRin.emplace_back(rinB);
199  pgonRout.emplace_back(rmax);
200  pgonRout.emplace_back(rmax);
201  DDSolid solid =
202  DDSolidFactory::polyhedra(DDName(name, idNameSpace_), sectors_, -alpha, 2._pi, pgonZ, pgonRin, pgonRout);
203  glog = DDLogicalPart(solid.ddname(), matter, solid);
204 #ifdef EDM_ML_DEBUG
205  edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: " << solid.name() << " polyhedra of " << sectors_
206  << " sectors covering " << convertRadToDeg(-alpha) << ":"
207  << (360.0 + convertRadToDeg(-alpha)) << " with " << pgonZ.size() << " sections";
208  for (unsigned int k = 0; k < pgonZ.size(); ++k)
209  edm::LogVerbatim("HGCalGeom") << "[" << k << "] z " << pgonZ[k] << " R " << pgonRin[k] << ":" << pgonRout[k];
210 #endif
211  } else {
212  DDSolid solid = DDSolidFactory::tubs(DDName(name, idNameSpace_), 0.5 * thick_[ii], rinB, routF, 0.0, 2._pi);
213  glog = DDLogicalPart(solid.ddname(), matter, solid);
214 #ifdef EDM_ML_DEBUG
215  edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: " << solid.name() << " Tubs made of " << matName
216  << " of dimensions " << rinB << ", " << routF << ", " << 0.5 * thick_[ii]
217  << ", 0.0, 360.0";
218  edm::LogVerbatim("HGCalGeom") << "DDHGCalModule test position in: " << glog.name() << " number " << copy;
219 #endif
220  positionSensitive(glog, rinB, routF, cpv);
221  }
222  DDTranslation r1(0, 0, zz);
223  DDRotation rot;
224  cpv.position(glog, module, copy, r1, rot);
225  ++copyNumber_[ii];
226 #ifdef EDM_ML_DEBUG
227  edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: " << glog.name() << " number " << copy << " positioned in "
228  << module.name() << " at " << r1 << " with " << rot;
229 #endif
230  zz += (0.5 * thick_[ii]);
231  } // End of loop over layers in a block
232  zi = zo;
233  laymin = laymax;
234  if (fabs(thickTot - layerThick_[i]) > tol_) {
235  if (thickTot > layerThick_[i]) {
236  edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " is smaller than thickness "
237  << thickTot << " of all its components **** ERROR ****\n";
238  } else {
239  edm::LogWarning("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " does not match with "
240  << thickTot << " of the components\n";
241  }
242  }
243  } // End of loop over blocks
244 }
Log< level::Info, true > LogVerbatim
std::vector< std::string > names_
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
double rMax(double z)
std::string idNameSpace_
std::vector< std::string > materials_
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
Log< level::Error, false > LogError
std::vector< int > copyNumber_
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
static std::string to_string(const XMLCh *ch)
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
U second(std::pair< T, U > const &p)
std::vector< int > layerSense_
std::vector< int > layerType_
std::vector< double > slopeB_
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
std::vector< double > thick_
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
static constexpr double tol_
static DDSolid tubs(const DDName &name, double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)
Definition: DDSolid.cc:667
std::vector< int > layers_
ii
Definition: cuy.py:589
const N & name() const
Definition: DDBase.h:59
const N & ddname() const
Definition: DDBase.h:61
void positionSensitive(DDLogicalPart &glog, double rin, double rout, DDCompactView &cpv)
Log< level::Warning, false > LogWarning
std::vector< double > layerThick_
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
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:565

◆ execute()

void DDHGCalModule::execute ( DDCompactView cpv)
override

Definition at line 145 of file DDHGCalModule.cc.

References DDHGCalGeom::constructLayers(), dqmdumpme::k, and class-composition::parent.

145  {
146 #ifdef EDM_ML_DEBUG
147  edm::LogVerbatim("HGCalGeom") << "==>> Constructing DDHGCalModule...";
148 #endif
149  copies_.clear();
150  constructLayers(parent(), cpv);
151 #ifdef EDM_ML_DEBUG
152  edm::LogVerbatim("HGCalGeom") << copies_.size() << " different wafer copy numbers";
153  int k(0);
154  for (std::unordered_set<int>::const_iterator itr = copies_.begin(); itr != copies_.end(); ++itr, ++k)
155  edm::LogVerbatim("HGCalGeom") << "Copy[" << k << "] : " << (*itr);
156 #endif
157  copies_.clear();
158 #ifdef EDM_ML_DEBUG
159  edm::LogVerbatim("HGCalGeom") << "<<== End of DDHGCalModule construction ...";
160 #endif
161 }
Log< level::Info, true > LogVerbatim
std::unordered_set< int > copies_
void constructLayers(const DDLogicalPart &, DDCompactView &cpv)

◆ initialize()

void DDHGCalModule::initialize ( const DDNumericArguments nArgs,
const DDVectorArguments vArgs,
const DDMapArguments mArgs,
const DDStringArguments sArgs,
const DDStringVectorArguments vsArgs 
)
override

Definition at line 79 of file DDHGCalModule.cc.

References dbl_to_int(), mps_fire::i, createfilelist::int, and DDCurrentNamespace::ns().

83  {
84  wafer_ = vsArgs["WaferName"];
85 #ifdef EDM_ML_DEBUG
86  edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: " << wafer_.size() << " wafers";
87  for (unsigned int i = 0; i < wafer_.size(); ++i)
88  edm::LogVerbatim("HGCalGeom") << "Wafer[" << i << "] " << wafer_[i];
89 #endif
90  materials_ = vsArgs["MaterialNames"];
91  names_ = vsArgs["VolumeNames"];
92  thick_ = vArgs["Thickness"];
93  copyNumber_.resize(materials_.size(), 1);
94 #ifdef EDM_ML_DEBUG
95  edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: " << materials_.size() << " types of volumes";
96  for (unsigned int i = 0; i < names_.size(); ++i)
97  edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << names_[i] << " of thickness " << thick_[i]
98  << " filled with " << materials_[i] << " first copy number " << copyNumber_[i];
99 #endif
100  layers_ = dbl_to_int(vArgs["Layers"]);
101  layerThick_ = vArgs["LayerThick"];
102 #ifdef EDM_ML_DEBUG
103  edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: " << layers_.size() << " blocks";
104  for (unsigned int i = 0; i < layers_.size(); ++i)
105  edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] of thickness " << layerThick_[i] << " with " << layers_[i]
106  << " layers";
107 #endif
108  layerType_ = dbl_to_int(vArgs["LayerType"]);
109  layerSense_ = dbl_to_int(vArgs["LayerSense"]);
110 #ifdef EDM_ML_DEBUG
111  edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: " << layerType_.size() << " layers";
112  for (unsigned int i = 0; i < layerType_.size(); ++i)
113  edm::LogVerbatim("HGCalGeom") << "Layer [" << i << "] with material type " << layerType_[i] << " sensitive class "
114  << layerSense_[i];
115 #endif
116  zMinBlock_ = nArgs["zMinBlock"];
117  rMaxFine_ = nArgs["rMaxFine"];
118  waferW_ = nArgs["waferW"];
119  sectors_ = (int)(nArgs["Sectors"]);
120 #ifdef EDM_ML_DEBUG
121  edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: zStart " << zMinBlock_ << " rFineCoarse " << rMaxFine_
122  << " wafer width " << waferW_ << " sectors " << sectors_;
123 #endif
124  slopeB_ = vArgs["SlopeBottom"];
125  slopeT_ = vArgs["SlopeTop"];
126  zFront_ = vArgs["ZFront"];
127  rMaxFront_ = vArgs["RMaxFront"];
128 #ifdef EDM_ML_DEBUG
129  edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: Bottom slopes " << slopeB_[0] << ":" << slopeB_[1] << " and "
130  << slopeT_.size() << " slopes for top";
131  for (unsigned int i = 0; i < slopeT_.size(); ++i)
132  edm::LogVerbatim("HGCalGeom") << "Block [" << i << "] Zmin " << zFront_[i] << " Rmax " << rMaxFront_[i] << " Slope "
133  << slopeT_[i];
134 #endif
136 #ifdef EDM_ML_DEBUG
137  edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: NameSpace " << idNameSpace_;
138 #endif
139 }
Log< level::Info, true > LogVerbatim
std::vector< std::string > names_
std::vector< double > slopeT_
std::string idNameSpace_
std::vector< std::string > materials_
static std::string & ns()
std::vector< int > copyNumber_
std::vector< double > zFront_
std::vector< std::string > wafer_
std::vector< int > layerSense_
std::vector< int > layerType_
std::vector< double > slopeB_
std::vector< double > thick_
std::vector< int > layers_
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 > rMaxFront_
std::vector< double > layerThick_

◆ positionSensitive()

void DDHGCalModule::positionSensitive ( DDLogicalPart glog,
double  rin,
double  rout,
DDCompactView cpv 
)
protected

Definition at line 265 of file DDHGCalModule.cc.

References filterCSVwithJSON::copy, TCMET_cfi::corner, DDBase< N, C >::ddname(), DDSplit(), PVValHelper::dx, PVValHelper::dy, createfilelist::int, HGCalParameters::k_CornerSize, Skims_PA_cff::name, EgHLTOffHistBins_cfi::nr, ALPAKA_ACCELERATOR_NAMESPACE::caPixelDoublets::ntot, HGCalTypes::packTypeUV(), DDCompactView::position(), idealTransformation::rotation, findQualityFiles::rr, mathSSE::sqrt(), funct::tan(), and HGCalGeomTools::waferCorner().

265  {
266  double dx = 0.5 * waferW_;
267  double dy = 3.0 * dx * tan(30._deg);
268  double rr = 2.0 * dx * tan(30._deg);
269  int ncol = (int)(2.0 * rout / waferW_) + 1;
270  int nrow = (int)(rout / (waferW_ * tan(30._deg))) + 1;
271  int incm(0), inrm(0);
272 #ifdef EDM_ML_DEBUG
273  int kount(0), ntot(0), nin(0), nfine(0), ncoarse(0);
274  edm::LogVerbatim("HGCalGeom") << glog.ddname() << " rout " << rout << " Row " << nrow << " Column " << ncol;
275 #endif
276  for (int nr = -nrow; nr <= nrow; ++nr) {
277  int inr = (nr >= 0) ? nr : -nr;
278  for (int nc = -ncol; nc <= ncol; ++nc) {
279  int inc = (nc >= 0) ? nc : -nc;
280  if (inr % 2 == inc % 2) {
281  double xpos = nc * dx;
282  double ypos = nr * dy;
283  auto const& corner = HGCalGeomTools::waferCorner(xpos, ypos, dx, rr, rin, rout, true);
284 #ifdef EDM_ML_DEBUG
285  ++ntot;
286 #endif
287  if (corner.first > 0) {
288  int copy = HGCalTypes::packTypeUV(0, nc, nr);
289  if (inc > incm)
290  incm = inc;
291  if (inr > inrm)
292  inrm = inr;
293 #ifdef EDM_ML_DEBUG
294  kount++;
295 #endif
296  if (copies_.count(copy) == 0)
297  copies_.insert(copy);
298  if (corner.first == (int)(HGCalParameters::k_CornerSize)) {
299  double rpos = std::sqrt(xpos * xpos + ypos * ypos);
300  DDTranslation tran(xpos, ypos, 0.0);
302 #ifdef EDM_ML_DEBUG
303  ++nin;
304 #endif
305  DDName name = (rpos < rMaxFine_) ? DDName(DDSplit(wafer_[0]).first, DDSplit(wafer_[0]).second)
306  : DDName(DDSplit(wafer_[1]).first, DDSplit(wafer_[1]).second);
307  cpv.position(name, glog.ddname(), copy, tran, rotation);
308 #ifdef EDM_ML_DEBUG
309  if (rpos < rMaxFine_)
310  ++nfine;
311  else
312  ++ncoarse;
313  edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: " << name << " number " << copy << " positioned in "
314  << glog.ddname() << " at " << tran << " with " << rotation;
315 #endif
316  }
317  }
318  }
319  }
320  }
321 #ifdef EDM_ML_DEBUG
322  edm::LogVerbatim("HGCalGeom") << "DDHGCalModule: # of columns " << incm << " # of rows " << inrm << " and " << nin
323  << ":" << kount << ":" << ntot << " wafers (" << nfine << ":" << ncoarse << ") for "
324  << glog.ddname() << " R " << rin << ":" << rout;
325 #endif
326 }
Log< level::Info, true > LogVerbatim
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
std::unordered_set< int > copies_
static constexpr uint32_t k_CornerSize
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
static std::pair< int32_t, int32_t > waferCorner(double xpos, double ypos, double r, double R, double rMin, double rMax, bool oldBug=false)
std::vector< std::string > wafer_
T sqrt(T t)
Definition: SSEVec.h:19
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
const N & ddname() const
Definition: DDBase.h:61
static int32_t packTypeUV(int type, int u, int v)
Definition: HGCalTypes.cc:3
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7

◆ rMax()

double DDHGCalModule::rMax ( double  z)
protected

Definition at line 246 of file DDHGCalModule.cc.

References dqmdumpme::k.

246  {
247  double r(0);
248 #ifdef EDM_ML_DEBUG
249  unsigned int ik(0);
250 #endif
251  for (unsigned int k = 0; k < slopeT_.size(); ++k) {
252  if (z < zFront_[k])
253  break;
254  r = rMaxFront_[k] + (z - zFront_[k]) * slopeT_[k];
255 #ifdef EDM_ML_DEBUG
256  ik = k;
257 #endif
258  }
259 #ifdef EDM_ML_DEBUG
260  edm::LogVerbatim("HGCalGeom") << "rMax : " << z << ":" << ik << ":" << r;
261 #endif
262  return r;
263 }
Log< level::Info, true > LogVerbatim
std::vector< double > slopeT_
std::vector< double > zFront_
std::vector< double > rMaxFront_

Member Data Documentation

◆ copies_

std::unordered_set<int> DDHGCalModule::copies_
private

Definition at line 70 of file DDHGCalModule.cc.

◆ copyNumber_

std::vector<int> DDHGCalModule::copyNumber_
private

Definition at line 56 of file DDHGCalModule.cc.

◆ idNameSpace_

std::string DDHGCalModule::idNameSpace_
private

Definition at line 69 of file DDHGCalModule.cc.

◆ layers_

std::vector<int> DDHGCalModule::layers_
private

Definition at line 57 of file DDHGCalModule.cc.

◆ layerSense_

std::vector<int> DDHGCalModule::layerSense_
private

Definition at line 60 of file DDHGCalModule.cc.

◆ layerThick_

std::vector<double> DDHGCalModule::layerThick_
private

Definition at line 58 of file DDHGCalModule.cc.

◆ layerType_

std::vector<int> DDHGCalModule::layerType_
private

Definition at line 59 of file DDHGCalModule.cc.

◆ materials_

std::vector<std::string> DDHGCalModule::materials_
private

Definition at line 53 of file DDHGCalModule.cc.

◆ names_

std::vector<std::string> DDHGCalModule::names_
private

Definition at line 54 of file DDHGCalModule.cc.

◆ rMaxFine_

double DDHGCalModule::rMaxFine_
private

Definition at line 62 of file DDHGCalModule.cc.

◆ rMaxFront_

std::vector<double> DDHGCalModule::rMaxFront_
private

Definition at line 68 of file DDHGCalModule.cc.

◆ sectors_

int DDHGCalModule::sectors_
private

Definition at line 64 of file DDHGCalModule.cc.

◆ slopeB_

std::vector<double> DDHGCalModule::slopeB_
private

Definition at line 65 of file DDHGCalModule.cc.

◆ slopeT_

std::vector<double> DDHGCalModule::slopeT_
private

Definition at line 66 of file DDHGCalModule.cc.

◆ thick_

std::vector<double> DDHGCalModule::thick_
private

Definition at line 55 of file DDHGCalModule.cc.

◆ tol_

constexpr double DDHGCalModule::tol_ = 0.00001
staticprivate

Definition at line 50 of file DDHGCalModule.cc.

◆ wafer_

std::vector<std::string> DDHGCalModule::wafer_
private

Definition at line 52 of file DDHGCalModule.cc.

◆ waferW_

double DDHGCalModule::waferW_
private

Definition at line 63 of file DDHGCalModule.cc.

◆ zFront_

std::vector<double> DDHGCalModule::zFront_
private

Definition at line 67 of file DDHGCalModule.cc.

◆ zMinBlock_

double DDHGCalModule::zMinBlock_
private

Definition at line 61 of file DDHGCalModule.cc.