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 
17 #include "CLHEP/Units/GlobalSystemOfUnits.h"
18 
20  LogDebug("HCalGeom") <<"DDHCalFibreBundle info: Creating an instance";
21 }
22 
24 
26  const DDVectorArguments & vArgs,
27  const DDMapArguments & ,
28  const DDStringArguments & sArgs,
29  const DDStringVectorArguments & ) {
30 
31  deltaPhi = nArgs["DeltaPhi"];
32  deltaZ = nArgs["DeltaZ"];
33  numberPhi = int(nArgs["NumberPhi"]);
34  material = sArgs["Material"];
35  areaSection = vArgs["AreaSection"];
36  rStart = vArgs["RadiusStart"];
37  rEnd = vArgs["RadiusEnd"];
38  bundle = dbl_to_int(vArgs["Bundles"]);
39  tilt = nArgs["TiltAngle"];
40 
42  childPrefix = sArgs["Child"];
43  DDName parentName = parent().name();
44  LogDebug("HCalGeom") << "DDHCalFibreBundle debug: Parent " << parentName
45  << " with " << bundle.size() << " children with prefix "
46  << childPrefix << ", material " << material << " with "
47  << numberPhi << " bundles along phi; width of mother "
48  << deltaZ << " along Z, " << deltaPhi/CLHEP::deg
49  << " along phi and with " << rStart.size()
50  << " different bundle types";
51  for (unsigned int i=0; i<areaSection.size(); ++i)
52  LogDebug("HCalGeom") << "DDHCalFibreBundle debug: Child[" << i << "] Area "
53  << areaSection[i] << " R at Start " << rStart[i]
54  << " R at End " << rEnd[i];
55  LogDebug("HCalGeom") << "DDHCalFibreBundle debug: NameSpace "
56  << idNameSpace << " Tilt Angle " << tilt/CLHEP::deg
57  << " Bundle type at different positions";
58  for (unsigned int i=0; i<bundle.size(); ++i) {
59  LogDebug("HCalGeom") << "DDHCalFibreBundle debug: Position[" << i << "] "
60  << " with Type " << bundle[i];
61  }
62 }
63 
65 
66  DDName mother = parent().name();
68  DDMaterial matter(matname);
69 
70  // Create the rotation matrices
71  double dPhi = deltaPhi/numberPhi;
72  std::vector<DDRotation> rotation;
73  for (int i=0; i<numberPhi; ++i) {
74  double phi = -0.5*deltaPhi+(i+0.5)*dPhi;
75  double phideg = phi/CLHEP::deg;
76  std::string rotstr = "R0"+ std::to_string(phideg);
78  if (!rot) {
79  LogDebug("HCalGeom") << "DDHCalFibreBundle test: Creating a new "
80  << "rotation " << rotstr << "\t" << 90 << ","
81  << phideg << "," << 90 << "," << (phideg+90)
82  << ", 0, 0";
83  rot = DDrot(DDName(rotstr, idNameSpace), 90*CLHEP::deg, phi,
84  90*CLHEP::deg, (90*CLHEP::deg+phi), 0, 0);
85  }
86  rotation.emplace_back(rot);
87  }
88 
89  // Create the solids and logical parts
90  std::vector<DDLogicalPart> logs;
91  for (unsigned int i=0; i<areaSection.size(); ++i) {
92  double r0 = rEnd[i]/std::cos(tilt);
93  double dStart = areaSection[i]/(2*dPhi*rStart[i]);
94  double dEnd = areaSection[i]/(2*dPhi*r0);
95  std::string name = childPrefix + std::to_string(i);
97  rStart[i]-dStart, rStart[i]+dStart,
98  r0-dEnd, r0+dEnd, -0.5*dPhi, dPhi);
99  LogDebug("HCalGeom") << "DDHCalFibreBundle test: Creating a new solid "
100  << name << " a cons with dZ " << deltaZ << " rStart "
101  << rStart[i]-dStart << ":" << rStart[i]+dStart
102  << " rEnd " << r0-dEnd << ":" << r0+dEnd << " Phi "
103  << -0.5*dPhi/CLHEP::deg << ":" << 0.5*dPhi/CLHEP::deg;
104  DDLogicalPart log(DDName(name, idNameSpace), matter, solid);
105  logs.emplace_back(log);
106  }
107 
108  // Now posiiton them
109  int copy = 0;
110  int nY = (int)(bundle.size())/numberPhi;
111  for (unsigned int i=0; i<bundle.size(); i++) {
112  DDTranslation tran(0,0,0);
113  int ir = (int)(i)/nY;
114  if (ir >= numberPhi) ir = numberPhi-1;
115  int ib = bundle[i];
116  copy++;
117  if (ib>=0 && ib<(int)(logs.size())) {
118  cpv.position(logs[ib], mother, copy, tran, rotation[ir]);
119  LogDebug("HCalGeom") << "DDHCalFibreBundle test: " << logs[ib].name()
120  << " number " << copy << " positioned in "
121  << mother << " at " << tran << " with "
122  << rotation[ir];
123  }
124  }
125 }
#define LogDebug(id)
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
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
std::vector< double > areaSection
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
std::string idNameSpace
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=0)
std::vector< double > rEnd
std::vector< double > rStart
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
std::vector< int > bundle
std::string childPrefix
ib
Definition: cuy.py:662
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override