CMS 3D CMS Logo

DDHCalFibreBundle.cc
Go to the documentation of this file.
1 // File: DDHCalFibreBundle.cc
3 // Description: Create & Position fibre bundles in mother
5 
6 #include <cmath>
7 #include <algorithm>
8 
18 
19 //#define EDM_ML_DEBUG
20 using namespace geant_units::operators;
21 
23 #ifdef EDM_ML_DEBUG
24  edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: Creating an instance";
25 #endif
26 }
27 
29 
31  const DDVectorArguments & vArgs,
32  const DDMapArguments & ,
33  const DDStringArguments & sArgs,
34  const DDStringVectorArguments & ) {
35 
36  deltaPhi = nArgs["DeltaPhi"];
37  deltaZ = nArgs["DeltaZ"];
38  numberPhi = int(nArgs["NumberPhi"]);
39  material = sArgs["Material"];
40  areaSection = vArgs["AreaSection"];
41  rStart = vArgs["RadiusStart"];
42  rEnd = vArgs["RadiusEnd"];
43  bundle = dbl_to_int(vArgs["Bundles"]);
44  tilt = nArgs["TiltAngle"];
45 
46  idNameSpace = DDCurrentNamespace::ns();
47  childPrefix = sArgs["Child"];
48 #ifdef EDM_ML_DEBUG
49  edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: Parent "
50  << parent().name() << " with " << bundle.size()
51  << " children with prefix " << childPrefix
52  << ", material " << material << " with "
53  << numberPhi << " bundles along phi; width of"
54  << " mother " << deltaZ << " along Z, "
56  << " along phi and with " << rStart.size()
57  << " different bundle types";
58  for (unsigned int i=0; i<areaSection.size(); ++i)
59  edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: Child[" << i
60  << "] Area " << areaSection[i]
61  << " R at Start " << rStart[i]
62  << " R at End " << rEnd[i];
63  edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: NameSpace "
64  << idNameSpace << " Tilt Angle "
65  << convertRadToDeg(tilt)
66  << " Bundle type at different positions";
67  for (unsigned int i=0; i<bundle.size(); ++i) {
68  edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: Position[" << i << "] "
69  << " with Type " << bundle[i];
70  }
71 #endif
72 }
73 
75 
76  DDName mother = parent().name();
77  DDName matname(DDSplit(material).first, DDSplit(material).second);
78  DDMaterial matter(matname);
79 
80  // Create the rotation matrices
81  double dPhi = deltaPhi/numberPhi;
82  std::vector<DDRotation> rotation;
83  for (int i=0; i<numberPhi; ++i) {
84  double phi = -0.5*deltaPhi+(i+0.5)*dPhi;
85  double phideg = convertRadToDeg(phi);
86  std::string rotstr = "R0"+ std::to_string(phideg);
87  DDRotation rot = DDRotation(DDName(rotstr, idNameSpace));
88  if (!rot) {
89 #ifdef EDM_ML_DEBUG
90  edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: Creating a new "
91  << "rotation " << rotstr << "\t" << 90
92  << "," << phideg << "," << 90 << ","
93  << (phideg+90) << ", 0, 0";
94 #endif
95  rot = DDrot(DDName(rotstr, idNameSpace), 90._deg, phi,
96  90._deg, (90._deg+phi), 0, 0);
97  }
98  rotation.emplace_back(rot);
99  }
100 
101  // Create the solids and logical parts
102  std::vector<DDLogicalPart> logs;
103  for (unsigned int i=0; i<areaSection.size(); ++i) {
104  double r0 = rEnd[i]/std::cos(tilt);
105  double dStart = areaSection[i]/(2*dPhi*rStart[i]);
106  double dEnd = areaSection[i]/(2*dPhi*r0);
107  std::string name = childPrefix + std::to_string(i);
108  DDSolid solid = DDSolidFactory::cons(DDName(name, idNameSpace), 0.5*deltaZ,
109  rStart[i]-dStart, rStart[i]+dStart,
110  r0-dEnd, r0+dEnd, -0.5*dPhi, dPhi);
111 #ifdef EDM_ML_DEBUG
112  edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: Creating a new solid "
113  << name << " a cons with dZ " << deltaZ
114  << " rStart " << rStart[i]-dStart << ":"
115  << rStart[i]+dStart << " rEnd " << r0-dEnd
116  << ":" << r0+dEnd << " Phi "
117  << convertRadToDeg(-0.5*dPhi) << ":"
118  << convertRadToDeg(0.5*dPhi);
119 #endif
120  DDLogicalPart log(DDName(name, idNameSpace), matter, solid);
121  logs.emplace_back(log);
122  }
123 
124  // Now posiiton them
125  int copy = 0;
126  int nY = (int)(bundle.size())/numberPhi;
127  for (unsigned int i=0; i<bundle.size(); i++) {
128  DDTranslation tran(0,0,0);
129  int ir = (int)(i)/nY;
130  if (ir >= numberPhi) ir = numberPhi-1;
131  int ib = bundle[i];
132  copy++;
133  if (ib>=0 && ib<(int)(logs.size())) {
134  cpv.position(logs[ib], mother, copy, tran, rotation[ir]);
135 #ifdef EDM_ML_DEBUG
136  edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: " << logs[ib].name()
137  << " number " << copy << " positioned in "
138  << mother << " at " << tran << " with "
139  << rotation[ir];
140 #endif
141  }
142  }
143 }
def copy(args, dbName)
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:43
static DDSolid cons(const DDName &name, double zhalf, double rInMinusZ, double rOutMinusZ, double rInPlusZ, double rOutPlusZ, double phiFrom, double deltaPhi)
Definition: DDSolid.cc:838
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
constexpr NumType convertRadToDeg(NumType radians)
Definition: GeantUnits.h:98
static std::string & ns()
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
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
~DDHCalFibreBundle() override
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
void execute(DDCompactView &cpv) override
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
DDRotation DDrot(const DDName &name, std::unique_ptr< DDRotationMatrix > rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:80
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
ib
Definition: cuy.py:662
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override