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)
 
void initialize (const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs)
 
virtual ~DDHGCalModuleAlgo ()
 

Protected Member Functions

void constructLayers (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 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 22 of file DDHGCalModuleAlgo.cc.

References gather_cfg::cout.

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

Definition at line 28 of file DDHGCalModuleAlgo.cc.

28 {}

Member Function Documentation

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

Definition at line 120 of file DDHGCalModuleAlgo.cc.

References alpha, popcon2dropbox::copy(), copyNumber, funct::cos(), gather_cfg::cout, DDBase< N, C >::ddname(), DDSplit(), plotBeamSpotDB::first, 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().

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

Definition at line 104 of file DDHGCalModuleAlgo.cc.

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

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

Definition at line 30 of file DDHGCalModuleAlgo.cc.

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

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

References copies, popcon2dropbox::copy(), gather_cfg::cout, DDBase< N, C >::ddname(), DDSplit(), createfilelist::int, gen::k, dataset::name, create_public_lumi_plots::ncol, DDCompactView::position(), rMaxFine, idealTransformation::rotation, findQualityFiles::rr, mathSSE::sqrt(), funct::tan(), wafer, and waferW.

Referenced by constructLayers().

232  {
233  double dx = 0.5*waferW;
234  double dy = 3.0*dx*tan(30.0*CLHEP::deg);
235  double rr = 2.0*dx*tan(30.0*CLHEP::deg);
236  int ncol = (int)(2.0*rout/waferW) + 1;
237  int nrow = (int)(rout/(waferW*tan(30.0*CLHEP::deg))) + 1;
238  int incm(0), inrm(0), kount(0);
239  double xc[6], yc[6];
240 #ifdef EDM_ML_DEBUG
241  std::cout << glog.ddname() << " rout " << rout << " Row " << nrow
242  << " Column " << ncol << std::endl;
243 #endif
244  for (int nr=-nrow; nr <= nrow; ++nr) {
245  int inr = (nr >= 0) ? nr : -nr;
246  for (int nc=-ncol; nc <= ncol; ++nc) {
247  int inc = (nc >= 0) ? nc : -nc;
248  if (inr%2 == inc%2) {
249  double xpos = nc*dx;
250  double ypos = nr*dy;
251  xc[0] = xpos+dx; yc[0] = ypos-0.5*rr;
252  xc[1] = xpos+dx; yc[1] = ypos+0.5*rr;
253  xc[2] = xpos; yc[2] = ypos+rr;
254  xc[3] = xpos-dx; yc[3] = ypos+0.5*rr;
255  xc[4] = xpos+dx; yc[4] = ypos-0.5*rr;
256  xc[5] = xpos; yc[5] = ypos-rr;
257  bool cornerAll(true);
258  for (int k=0; k<6; ++k) {
259  double rpos = std::sqrt(xc[k]*xc[k]+yc[k]*yc[k]);
260  if (rpos < rin || rpos > rout) cornerAll = false;
261  }
262  if (cornerAll) {
263  double rpos = std::sqrt(xpos*xpos+ypos*ypos);
264  DDTranslation tran(xpos, ypos, 0.0);
266  int copy = inr*100 + inc;
267  if (nc < 0) copy += 10000;
268  if (nr < 0) copy += 100000;
269  DDName name = (rpos < rMaxFine) ?
270  DDName(DDSplit(wafer[0]).first, DDSplit(wafer[0]).second) :
271  DDName(DDSplit(wafer[1]).first, DDSplit(wafer[1]).second);
272  cpv.position(name, glog.ddname(), copy, tran, rotation);
273  if (inc > incm) incm = inc;
274  if (inr > inrm) inrm = inr;
275  kount++;
276  if (copies.count(copy) == 0)
277  copies.insert(copy);
278 #ifdef EDM_ML_DEBUG
279  std::cout << "DDHGCalModuleAlgo: " << name << " number " << copy
280  << " positioned in " << glog.ddname() << " at " << tran
281  << " with " << rotation << std::endl;
282 #endif
283  }
284  }
285  }
286  }
287 #ifdef EDM_ML_DEBUG
288  std::cout << "DDHGCalModuleAlgo: # of columns " << incm << " # of rows "
289  << inrm << " and " << kount << " wafers for " << glog.ddname()
290  << std::endl;
291 #endif
292 }
std::unordered_set< int > copies
void position(const DDLogicalPart &self, const DDLogicalPart &parent, std::string copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=NULL)
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:16
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
T sqrt(T t)
Definition: SSEVec.h:18
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
int k[5][pyjets_maxn]
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:4
std::vector< std::string > wafer
const N & ddname() const
Definition: DDBase.h:80
double DDHGCalModuleAlgo::rMax ( double  z)
protected

Definition at line 213 of file DDHGCalModuleAlgo.cc.

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

Referenced by constructLayers().

213  {
214  double r(0);
215 #ifdef EDM_ML_DEBUG
216  unsigned int ik(0);
217 #endif
218  for (unsigned int k=0; k<slopeT.size(); ++k) {
219  if (z < zFront[k]) break;
220  r = rMaxFront[k] + (z - zFront[k]) * slopeT[k];
221 #ifdef EDM_ML_DEBUG
222  ik = k;
223 #endif
224  }
225 #ifdef EDM_ML_DEBUG
226  std::cout << "rMax : " << z << ":" << ik << ":" << r << std::endl;
227 #endif
228  return r;
229 }
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 53 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 51 of file DDHGCalModuleAlgo.h.

std::string DDHGCalModuleAlgo::idNameSpace
private

Definition at line 52 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 50 of file DDHGCalModuleAlgo.h.

Referenced by initialize(), and rMax().

int DDHGCalModuleAlgo::sectors
private

Definition at line 46 of file DDHGCalModuleAlgo.h.

Referenced by constructLayers(), and initialize().

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

Definition at line 47 of file DDHGCalModuleAlgo.h.

Referenced by constructLayers(), and initialize().

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

Definition at line 48 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::waferW
private

Definition at line 45 of file DDHGCalModuleAlgo.h.

Referenced by initialize(), and positionSensitive().

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

Definition at line 49 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().