CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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"+ dbl_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.push_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);
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.push_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)
int i
Definition: DBlmapReader.cc:9
int ib
Definition: cuy.py:660
void execute(DDCompactView &cpv)
list parent
Definition: dbtoconf.py:74
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:41
static DDSolid cons(const DDName &name, double zhalf, double rInMinusZ, double rOutMinusZ, double rInPlusZ, double rOutPlusZ, double phiFrom, double deltaPhi)
Definition: DDSolid.cc:763
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:14
static std::string & ns()
std::string dbl_to_string(const double &in)
Converts only the integer part of a double to a string.
Definition: DDutils.cc:12
type of data representation of DDCompactView
Definition: DDCompactView.h:77
A DDSolid represents the shape of a part.
Definition: DDSolid.h:35
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
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.cc:4
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
std::vector< double > areaSection
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:88
std::string idNameSpace
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:90
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs)
virtual ~DDHCalFibreBundle()
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:4
std::vector< int > bundle
std::string childPrefix
tuple log
Definition: cmsBatch.py:341