CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Attributes
DDHGCalModuleAlgo Class Reference

#include <DDHGCalModuleAlgo.h>

Inheritance diagram for DDHGCalModuleAlgo:

Public Member Functions

 DDHGCalModuleAlgo ()
 
void execute (DDCompactView &cpv) override
 
void initialize (const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
 
 ~DDHGCalModuleAlgo () 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 idName
 
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 waferGap
 
double waferW
 
std::vector< double > zFront
 
double zMinBlock
 

Detailed Description

Definition at line 11 of file DDHGCalModuleAlgo.h.

Constructor & Destructor Documentation

DDHGCalModuleAlgo::DDHGCalModuleAlgo ( )

Definition at line 24 of file DDHGCalModuleAlgo.cc.

References gather_cfg::cout.

24  {
25 #ifdef EDM_ML_DEBUG
26  std::cout << "DDHGCalModuleAlgo info: Creating an instance" << std::endl;
27 #endif
28 }
DDHGCalModuleAlgo::~DDHGCalModuleAlgo ( )
override

Definition at line 30 of file DDHGCalModuleAlgo.cc.

30 {}

Member Function Documentation

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

Definition at line 123 of file DDHGCalModuleAlgo.cc.

References alpha, popcon2dropbox::copy(), copyNumber, funct::cos(), gather_cfg::cout, DDBase< N, C >::ddname(), DDSplit(), plotBeamSpotDB::first, mps_fire::i, idNameSpace, cuy::ii, gen::k, layers, layerSense, layerThick, layerType, materials, dataset::name, DDBase< N, C >::name(), names, pi, DDSolidFactory::polyhedra(), DDCompactView::position(), positionSensitive(), diffTwoXMLs::r1, rMax(), makeMuonMisalignmentScenario::rot, edm::second(), sectors, slopeB, AlCaHLTBitMon_QueryRunRegistry::string, thick, DDSolidFactory::tubs(), zMinBlock, and geometryCSVtoXML::zz.

Referenced by execute().

124  {
125 
126 #ifdef EDM_ML_DEBUG
127  std::cout << "DDHGCalModuleAlgo test: \t\tInside Layers" << std::endl;
128 #endif
129  double zi(zMinBlock);
130  int laymin(0);
131  const double tol(0.01);
132  for (unsigned int i=0; i<layers.size(); i++) {
133  double zo = zi + layerThick[i];
134  double routF = rMax(zi);
135  int laymax = laymin+layers[i];
136  double zz = zi;
137  double thickTot(0);
138  for (int ly=laymin; ly<laymax; ++ly) {
139  int ii = layerType[ly];
140  int copy = copyNumber[ii];
141  double rinB = (layerSense[ly] == 0) ? (zo*slopeB[0]) : (zo*slopeB[1]);
142  zz += (0.5*thick[ii]);
143  thickTot += thick[ii];
144 
145  std::string name = "HGCal"+names[ii]+std::to_string(copy);
146 #ifdef EDM_ML_DEBUG
147  std::cout << "DDHGCalModuleAlgo test: Layer " << ly << ":" << ii
148  << " Front " << zi << ", " << routF << " Back " << zo << ", "
149  << rinB << " superlayer thickness " << layerThick[i]
150  << std::endl;
151 #endif
152  DDName matName(DDSplit(materials[ii]).first,
153  DDSplit(materials[ii]).second);
154  DDMaterial matter(matName);
155  DDLogicalPart glog;
156  if (layerSense[ly] == 0) {
157  double alpha = CLHEP::pi/sectors;
158  double rmax = routF*cos(alpha) - tol;
159  std::vector<double> pgonZ, pgonRin, pgonRout;
160  pgonZ.emplace_back(-0.5*thick[ii]); pgonZ.emplace_back(0.5*thick[ii]);
161  pgonRin.emplace_back(rinB); pgonRin.emplace_back(rinB);
162  pgonRout.emplace_back(rmax); pgonRout.emplace_back(rmax);
164  sectors, -alpha, CLHEP::twopi,
165  pgonZ, pgonRin, pgonRout);
166  glog = DDLogicalPart(solid.ddname(), matter, solid);
167 #ifdef EDM_ML_DEBUG
168  std::cout << "DDHGCalModuleAlgo test: " << solid.name()
169  << " polyhedra of " << sectors << " sectors covering "
170  << -alpha/CLHEP::deg << ":"
171  << (-alpha+CLHEP::twopi)/CLHEP::deg
172  << " with " << pgonZ.size() << " sections" << std::endl;
173  for (unsigned int k=0; k<pgonZ.size(); ++k)
174  std::cout << "[" << k << "] z " << pgonZ[k] << " R " << pgonRin[k]
175  << ":" << pgonRout[k] << std::endl;
176 #endif
177  } else {
179  0.5*thick[ii], rinB, routF, 0.0,
180  CLHEP::twopi);
181  glog = DDLogicalPart(solid.ddname(), matter, solid);
182 #ifdef EDM_ML_DEBUG
183  std::cout << "DDHGCalModuleAlgo test: " << solid.name()
184  << " Tubs made of " << matName << " of dimensions " << rinB
185  << ", " << routF << ", " << 0.5*thick[ii] << ", 0.0, "
186  << CLHEP::twopi/CLHEP::deg << std::endl;
187 #endif
188  positionSensitive(glog,rinB,routF,cpv);
189  }
190  DDTranslation r1(0,0,zz);
191  DDRotation rot;
192  cpv.position(glog, module, copy, r1, rot);
193  ++copyNumber[ii];
194 #ifdef EDM_ML_DEBUG
195  std::cout << "DDHGCalModuleAlgo test: " << glog.name() << " number "
196  << copy << " positioned in " << module.name() << " at " << r1
197  << " with " << rot << std::endl;
198 #endif
199  zz += (0.5*thick[ii]);
200  } // End of loop over layers in a block
201  zi = zo;
202  laymin = laymax;
203  if (fabs(thickTot-layerThick[i]) < 0.00001) {
204  } else if (thickTot > layerThick[i]) {
205  edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick[i]
206  << " is smaller than thickness " << thickTot
207  << " of all its components **** ERROR ****\n";
208  } else if (thickTot < layerThick[i]) {
209  edm::LogWarning("HGCalGeom") << "Thickness of the partition "
210  << layerThick[i] << " does not match with "
211  << thickTot << " of the components\n";
212  }
213  } // End of loop over blocks
214 }
std::vector< int > copyNumber
std::vector< double > thick
float alpha
Definition: AMPTWrapper.h:95
const N & name() const
Definition: DDBase.h:74
void positionSensitive(DDLogicalPart &glog, double rin, double rout, DDCompactView &cpv)
def copy(args, dbName)
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:43
std::vector< std::string > names
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
const Double_t pi
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:68
std::vector< std::string > materials
U second(std::pair< T, U > const &p)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
static DDSolid tubs(const DDName &name, double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)
Definition: DDSolid.cc:865
ii
Definition: cuy.py:590
int k[5][pyjets_maxn]
std::vector< double > slopeB
std::string idNameSpace
std::vector< int > layerType
std::vector< int > layers
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=0)
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
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
std::vector< double > layerThick
double rMax(double z)
std::vector< int > layerSense
const N & ddname() const
Definition: DDBase.h:76
void DDHGCalModuleAlgo::execute ( DDCompactView cpv)
override

Definition at line 107 of file DDHGCalModuleAlgo.cc.

References constructLayers(), copies, gather_cfg::cout, and class-composition::parent.

107  {
108 
109 #ifdef EDM_ML_DEBUG
110  std::cout << "==>> Constructing DDHGCalModuleAlgo..." << std::endl;
111 #endif
112  copies.clear();
113  constructLayers (parent(), cpv);
114 #ifdef EDM_ML_DEBUG
115  std::cout << copies.size() << " different wafer copy numbers" << std::endl;
116 #endif
117  copies.clear();
118 #ifdef EDM_ML_DEBUG
119  std::cout << "<<== End of DDHGCalModuleAlgo construction ..." << std::endl;
120 #endif
121 }
std::unordered_set< int > copies
void constructLayers(const DDLogicalPart &, DDCompactView &cpv)
void DDHGCalModuleAlgo::initialize ( const DDNumericArguments nArgs,
const DDVectorArguments vArgs,
const DDMapArguments mArgs,
const DDStringArguments sArgs,
const DDStringVectorArguments vsArgs 
)
override

Definition at line 32 of file DDHGCalModuleAlgo.cc.

References copyNumber, gather_cfg::cout, dbl_to_int(), mps_fire::i, idNameSpace, createfilelist::int, layers, layerSense, layerThick, layerType, materials, names, DDCurrentNamespace::ns(), rMaxFine, rMaxFront, sectors, slopeB, slopeT, thick, wafer, waferGap, waferW, zFront, and zMinBlock.

36  {
37 
38  wafer = vsArgs["WaferName"];
39 #ifdef EDM_ML_DEBUG
40  std::cout << "DDHGCalModuleAlgo: " << wafer.size() << " wafers" << std::endl;
41  for (unsigned int i=0; i<wafer.size(); ++i)
42  std::cout << "Wafer[" << i << "] " << wafer[i] << std::endl;
43 #endif
44  materials = vsArgs["MaterialNames"];
45  names = vsArgs["VolumeNames"];
46  thick = vArgs["Thickness"];
47  for (unsigned int i=0; i<materials.size(); ++i) {
48  copyNumber.emplace_back(1);
49  }
50 #ifdef EDM_ML_DEBUG
51  std::cout << "DDHGCalModuleAlgo: " << materials.size()
52  << " types of volumes" << std::endl;
53  for (unsigned int i=0; i<names.size(); ++i)
54  std::cout << "Volume [" << i << "] " << names[i] << " of thickness "
55  << thick[i] << " filled with " << materials[i]
56  << " first copy number " << copyNumber[i] << std::endl;
57 #endif
58  layers = dbl_to_int(vArgs["Layers"]);
59  layerThick = vArgs["LayerThick"];
60 #ifdef EDM_ML_DEBUG
61  std::cout << "DDHGCalModuleAlgo: " << layers.size() << " blocks" <<std::endl;
62  for (unsigned int i=0; i<layers.size(); ++i)
63  std::cout << "Block [" << i << "] of thickness " << layerThick[i]
64  << " with " << layers[i] << " layers" << std::endl;
65 #endif
66  layerType = dbl_to_int(vArgs["LayerType"]);
67  layerSense = dbl_to_int(vArgs["LayerSense"]);
68 #ifdef EDM_ML_DEBUG
69  std::cout << "DDHGCalModuleAlgo: " << layerType.size() << " layers"
70  << std::endl;
71  for (unsigned int i=0; i<layerType.size(); ++i)
72  std::cout << "Layer [" << i << "] with material type " << layerType[i]
73  << " sensitive class " << layerSense[i] << std::endl;
74 #endif
75  zMinBlock = nArgs["zMinBlock"];
76  rMaxFine = nArgs["rMaxFine"];
77  waferW = nArgs["waferW"];
78  waferGap = nArgs["waferGap"];
79  sectors = (int)(nArgs["Sectors"]);
80 #ifdef EDM_ML_DEBUG
81  std::cout << "DDHGCalModuleAlgo: zStart " << zMinBlock << " rFineCoarse "
82  << rMaxFine << " wafer width " << waferW << " gap among wafers "
83  << waferGap << " sectors " << sectors << std::endl;
84 #endif
85  slopeB = vArgs["SlopeBottom"];
86  slopeT = vArgs["SlopeTop"];
87  zFront = vArgs["ZFront"];
88  rMaxFront = vArgs["RMaxFront"];
89 #ifdef EDM_ML_DEBUG
90  std::cout << "DDHGCalModuleAlgo: Bottom slopes " << slopeB[0] << ":"
91  << slopeB[1] << " and " << slopeT.size() << " slopes for top"
92  << std::endl;
93  for (unsigned int i=0; i<slopeT.size(); ++i)
94  std::cout << "Block [" << i << "] Zmin " << zFront[i] << " Rmax "
95  << rMaxFront[i] << " Slope " << slopeT[i] << std::endl;
96 #endif
98 #ifdef EDM_ML_DEBUG
99  std::cout << "DDHGCalModuleAlgo: NameSpace " << idNameSpace << std::endl;
100 #endif
101 }
std::vector< int > copyNumber
std::vector< double > thick
std::vector< std::string > names
static std::string & ns()
std::vector< std::string > materials
std::vector< double > rMaxFront
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 > slopeB
std::string idNameSpace
std::vector< int > layerType
std::vector< int > layers
std::vector< double > slopeT
std::vector< std::string > wafer
std::vector< double > zFront
std::vector< double > layerThick
std::vector< int > layerSense
void DDHGCalModuleAlgo::positionSensitive ( DDLogicalPart glog,
double  rin,
double  rout,
DDCompactView cpv 
)
protected

Definition at line 234 of file DDHGCalModuleAlgo.cc.

References copies, popcon2dropbox::copy(), TCMET_cfi::corner, gather_cfg::cout, DDBase< N, C >::ddname(), DDSplit(), PVValHelper::dx, PVValHelper::dy, createfilelist::int, HGCalParameters::k_CornerSize, dataset::name, create_public_lumi_plots::ncol, DDCompactView::position(), rMaxFine, idealTransformation::rotation, findQualityFiles::rr, mathSSE::sqrt(), funct::tan(), wafer, HGCalGeomTools::waferCorner(), waferGap, and waferW.

Referenced by constructLayers().

235  {
236  double ww = (waferW+waferGap);
237  double dx = 0.5*ww;
238  double dy = 3.0*dx*tan(30.0*CLHEP::deg);
239  double rr = 2.0*dx*tan(30.0*CLHEP::deg);
240  int ncol = (int)(2.0*rout/ww) + 1;
241  int nrow = (int)(rout/(ww*tan(30.0*CLHEP::deg))) + 1;
242  int incm(0), inrm(0), kount(0);
243 #ifdef EDM_ML_DEBUG
244  std::cout << glog.ddname() << " rout " << rout << " Row " << nrow
245  << " Column " << ncol << std::endl;
246 #endif
247  for (int nr=-nrow; nr <= nrow; ++nr) {
248  int inr = (nr >= 0) ? nr : -nr;
249  for (int nc=-ncol; nc <= ncol; ++nc) {
250  int inc = (nc >= 0) ? nc : -nc;
251  if (inr%2 == inc%2) {
252  double xpos = nc*dx;
253  double ypos = nr*dy;
254  std::pair<int,int> corner =
255  HGCalGeomTools::waferCorner(xpos, ypos, dx, rr, rin, rout, true);
256  if (corner.first == (int)(HGCalParameters::k_CornerSize)) {
257  double rpos = std::sqrt(xpos*xpos+ypos*ypos);
258  DDTranslation tran(xpos, ypos, 0.0);
260  int copy = inr*100 + inc;
261  if (nc < 0) copy += 10000;
262  if (nr < 0) copy += 100000;
263  DDName name = (rpos < rMaxFine) ?
264  DDName(DDSplit(wafer[0]).first, DDSplit(wafer[0]).second) :
265  DDName(DDSplit(wafer[1]).first, DDSplit(wafer[1]).second);
266  cpv.position(name, glog.ddname(), copy, tran, rotation);
267  if (inc > incm) incm = inc;
268  if (inr > inrm) inrm = inr;
269  kount++;
270  if (copies.count(copy) == 0)
271  copies.insert(copy);
272 #ifdef EDM_ML_DEBUG
273  std::cout << "DDHGCalModuleAlgo: " << name << " number " << copy
274  << " positioned in " << glog.ddname() << " at " << tran
275  << " with " << rotation << std::endl;
276 #endif
277  }
278  }
279  }
280  }
281 #ifdef EDM_ML_DEBUG
282  std::cout << "DDHGCalModuleAlgo: # of columns " << incm << " # of rows "
283  << inrm << " and " << kount << " wafers for " << glog.ddname()
284  << std::endl;
285 #endif
286 }
std::unordered_set< int > copies
def copy(args, dbName)
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:68
static std::pair< int32_t, int32_t > waferCorner(double xpos, double ypos, double r, double R, double rMin, double rMax, bool oldBug=false)
T sqrt(T t)
Definition: SSEVec.h:18
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
static uint32_t k_CornerSize
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=0)
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 > wafer
const N & ddname() const
Definition: DDBase.h:76
double DDHGCalModuleAlgo::rMax ( double  z)
protected

Definition at line 216 of file DDHGCalModuleAlgo.cc.

References gather_cfg::cout, gen::k, alignCSCRings::r, rMaxFront, slopeT, and zFront.

Referenced by constructLayers().

216  {
217  double r(0);
218 #ifdef EDM_ML_DEBUG
219  unsigned int ik(0);
220 #endif
221  for (unsigned int k=0; k<slopeT.size(); ++k) {
222  if (z < zFront[k]) break;
223  r = rMaxFront[k] + (z - zFront[k]) * slopeT[k];
224 #ifdef EDM_ML_DEBUG
225  ik = k;
226 #endif
227  }
228 #ifdef EDM_ML_DEBUG
229  std::cout << "rMax : " << z << ":" << ik << ":" << r << std::endl;
230 #endif
231  return r;
232 }
std::vector< double > rMaxFront
int k[5][pyjets_maxn]
std::vector< double > slopeT
std::vector< double > zFront

Member Data Documentation

std::unordered_set<int> DDHGCalModuleAlgo::copies
private

Definition at line 54 of file DDHGCalModuleAlgo.h.

Referenced by execute(), and positionSensitive().

std::vector<int> DDHGCalModuleAlgo::copyNumber
private

Definition at line 38 of file DDHGCalModuleAlgo.h.

Referenced by constructLayers(), and initialize().

std::string DDHGCalModuleAlgo::idName
private

Definition at line 52 of file DDHGCalModuleAlgo.h.

std::string DDHGCalModuleAlgo::idNameSpace
private

Definition at line 53 of file DDHGCalModuleAlgo.h.

Referenced by constructLayers(), and initialize().

std::vector<int> DDHGCalModuleAlgo::layers
private

Definition at line 39 of file DDHGCalModuleAlgo.h.

Referenced by constructLayers(), and initialize().

std::vector<int> DDHGCalModuleAlgo::layerSense
private

Definition at line 42 of file DDHGCalModuleAlgo.h.

Referenced by constructLayers(), and initialize().

std::vector<double> DDHGCalModuleAlgo::layerThick
private

Definition at line 40 of file DDHGCalModuleAlgo.h.

Referenced by constructLayers(), and initialize().

std::vector<int> DDHGCalModuleAlgo::layerType
private

Definition at line 41 of file DDHGCalModuleAlgo.h.

Referenced by constructLayers(), and initialize().

std::vector<std::string> DDHGCalModuleAlgo::materials
private

Definition at line 35 of file DDHGCalModuleAlgo.h.

Referenced by constructLayers(), and initialize().

std::vector<std::string> DDHGCalModuleAlgo::names
private

Definition at line 36 of file DDHGCalModuleAlgo.h.

Referenced by constructLayers(), and initialize().

double DDHGCalModuleAlgo::rMaxFine
private

Definition at line 44 of file DDHGCalModuleAlgo.h.

Referenced by initialize(), and positionSensitive().

std::vector<double> DDHGCalModuleAlgo::rMaxFront
private

Definition at line 51 of file DDHGCalModuleAlgo.h.

Referenced by initialize(), and rMax().

int DDHGCalModuleAlgo::sectors
private

Definition at line 47 of file DDHGCalModuleAlgo.h.

Referenced by constructLayers(), and initialize().

std::vector<double> DDHGCalModuleAlgo::slopeB
private

Definition at line 48 of file DDHGCalModuleAlgo.h.

Referenced by constructLayers(), and initialize().

std::vector<double> DDHGCalModuleAlgo::slopeT
private

Definition at line 49 of file DDHGCalModuleAlgo.h.

Referenced by initialize(), and rMax().

std::vector<double> DDHGCalModuleAlgo::thick
private

Definition at line 37 of file DDHGCalModuleAlgo.h.

Referenced by constructLayers(), and initialize().

std::vector<std::string> DDHGCalModuleAlgo::wafer
private

Definition at line 34 of file DDHGCalModuleAlgo.h.

Referenced by initialize(), and positionSensitive().

double DDHGCalModuleAlgo::waferGap
private

Definition at line 46 of file DDHGCalModuleAlgo.h.

Referenced by initialize(), and positionSensitive().

double DDHGCalModuleAlgo::waferW
private

Definition at line 45 of file DDHGCalModuleAlgo.h.

Referenced by initialize(), and positionSensitive().

std::vector<double> DDHGCalModuleAlgo::zFront
private

Definition at line 50 of file DDHGCalModuleAlgo.h.

Referenced by initialize(), and rMax().

double DDHGCalModuleAlgo::zMinBlock
private

Definition at line 43 of file DDHGCalModuleAlgo.h.

Referenced by constructLayers(), and initialize().