CMS 3D CMS Logo

DDHGCalWafer.cc
Go to the documentation of this file.
1 #include <cmath>
2 #include <algorithm>
3 
10 #include "CLHEP/Units/GlobalSystemOfUnits.h"
11 
12 //#define EDM_ML_DEBUG
13 
15 #ifdef EDM_ML_DEBUG
16  edm::LogInfo("HGCalGeom") << "DDHGCalWafer test: Creating an instance";
17 #endif
18 }
19 
21 
23  const DDVectorArguments & vArgs,
24  const DDMapArguments & ,
25  const DDStringArguments & sArgs,
26  const DDStringVectorArguments & vsArgs) {
27 
28  waferSize_ = nArgs["WaferSize"];
29  cellType_ = (int)(nArgs["CellType"]);
30  nColumns_ = (int)(nArgs["NColumns"]);
31  nBottomY_ = (int)(nArgs["NBottomY"]);
32  childNames_ = vsArgs["ChildNames"];
33  nCellsRow_ = dbl_to_int(vArgs["NCellsRow"]);
34  angleEdges_ = dbl_to_int(vArgs["AngleEdges"]);
35  detectorType_= dbl_to_int(vArgs["DetectorType"]);
37  parentName_ = parent().name();
38 #ifdef EDM_ML_DEBUG
39  std::cout << childNames_.size() << " children: " << childNames_[0] << "; "
40  << childNames_[1] << " in namespace " << idNameSpace_
41  << " positioned in " << nCellsRow_.size() << " rows and "
42  << nColumns_ << " columns with lowest column at " << nBottomY_
43  << " in mother " << parentName_ << " of size " << waferSize_
44  << std::endl;
45  for (unsigned int k=0; k<nCellsRow_.size(); ++k)
46  std::cout << "[" << k << "] Ncells " << nCellsRow_[k] << " Edge rotations "
47  << angleEdges_[2*k] << ":" << angleEdges_[2*k+1]
48  << " Type of edge cells " << detectorType_[2*k] << ":"
49  << detectorType_[2*k+1] << std::endl;
50 #endif
51 }
52 
54 
55 #ifdef EDM_ML_DEBUG
56  edm::LogInfo("HGCalGeom") << "==>> Constructing DDHGCalWafer...";
57 #endif
58  double dx = 0.5*waferSize_/nColumns_;
59  double dy = 0.5*dx*tan(30.0*CLHEP::deg);
60  int ny = nBottomY_;
61  int kount(0);
62 
63  for (unsigned int ir=0; ir<nCellsRow_.size(); ++ir) {
64  int nx = 1 - nCellsRow_[ir];
65  double ypos = dy*ny;
66  for (int ic=0; ic<nCellsRow_[ir]; ++ic) {
67  std::string name(childNames_[0]), rotstr("NULL");
68  int irot(0);
69  if (ic == 0) {
71  irot = angleEdges_[2*ir];
72  } else if (ic+1== nCellsRow_[ir]) {
73  name = childNames_[detectorType_[2*ir+1]];
74  irot = angleEdges_[2*ir+1];
75  }
77  if (irot != 0) {
78  if (irot >=0 && irot < 100) rotstr = "R0";
79  else rotstr = "R";
80  rotstr = rotstr + std::to_string(irot);
81  rot = DDRotation(DDName(rotstr, idNameSpace_));
82  if (!rot) {
83 #ifdef EDM_ML_DEBUG
84  std::cout << "DDHGCalWaferAlgo: Creating new rotation "
85  << DDName(rotstr, idNameSpace_) << "\t90, " << irot
86  << ", 90, " << (irot+90) << ", 0, 0" << std::endl;
87 #endif
88  rot = DDrot(DDName(rotstr, idNameSpace_), 90*CLHEP::deg,
89  irot*CLHEP::deg, 90*CLHEP::deg, (90+irot)*CLHEP::deg,
90  0*CLHEP::deg,0*CLHEP::deg);
91  }
92  }
93  double xpos = dx*nx;
94  nx += 2;
95  DDTranslation tran(xpos, ypos, 0);
96  int copy = cellType_*1000+kount;
97  cpv.position(DDName(name,idNameSpace_), parentName_, copy, tran, rot);
98  ++kount;
99 #ifdef EDM_ML_DEBUG
100  std::cout << "DDHGCalWafer: " << DDName(name,idNameSpace_) << " number "
101  << copy << " positioned in " << parentName_ << " at " << tran
102  << " with " << rot << std::endl;
103 #endif
104  }
105  ny += 6;
106  }
107 }
virtual ~DDHGCalWafer()
Definition: DDHGCalWafer.cc:20
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs)
Definition: DDHGCalWafer.cc:22
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:15
static std::string & ns()
std::vector< int > detectorType_
Definition: DDHGCalWafer.h:33
type of data representation of DDCompactView
Definition: DDCompactView.h:90
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:64
double waferSize_
Definition: DDHGCalWafer.h:26
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< std::string > childNames_
Definition: DDHGCalWafer.h:30
std::vector< int > nCellsRow_
Definition: DDHGCalWafer.h:31
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:90
int k[5][pyjets_maxn]
std::vector< int > angleEdges_
Definition: DDHGCalWafer.h:32
void execute(DDCompactView &cpv)
Definition: DDHGCalWafer.cc:53
std::string idNameSpace_
Definition: DDHGCalWafer.h:34
DDName parentName_
Definition: DDHGCalWafer.h:35