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 #include <map>
9 #include <string>
10 #include <vector>
11 
24 
25 //#define EDM_ML_DEBUG
26 using namespace geant_units::operators;
27 
28 class DDHCalFibreBundle : public DDAlgorithm {
29 public:
30  //Constructor and Destructor
32  ~DDHCalFibreBundle() override;
33 
34  void initialize(const DDNumericArguments& nArgs,
35  const DDVectorArguments& vArgs,
36  const DDMapArguments& mArgs,
37  const DDStringArguments& sArgs,
38  const DDStringVectorArguments& vsArgs) override;
39 
40  void execute(DDCompactView& cpv) override;
41 
42 private:
43  std::string idNameSpace; //Namespace of this and ALL sub-parts
44  std::string childPrefix; //Prefix to child name
45  std::string material; //Name of the material for bundles
46  double deltaZ; //Width in Z for mother
47  double deltaPhi; //Width in phi for mother
48  int numberPhi; //Number of sections in phi
49  double tilt; //Tilt angle of the readout box
50  std::vector<double> areaSection; //Area of a bundle
51  std::vector<double> rStart; //Radius at start
52  std::vector<double> rEnd; //Radius at End
53  std::vector<int> bundle; //Bundle to be positioned
54 };
55 
57 #ifdef EDM_ML_DEBUG
58  edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: Creating an instance";
59 #endif
60 }
61 
63 
65  const DDVectorArguments& vArgs,
66  const DDMapArguments&,
67  const DDStringArguments& sArgs,
68  const DDStringVectorArguments&) {
69  deltaPhi = nArgs["DeltaPhi"];
70  deltaZ = nArgs["DeltaZ"];
71  numberPhi = int(nArgs["NumberPhi"]);
72  material = sArgs["Material"];
73  areaSection = vArgs["AreaSection"];
74  rStart = vArgs["RadiusStart"];
75  rEnd = vArgs["RadiusEnd"];
76  bundle = dbl_to_int(vArgs["Bundles"]);
77  tilt = nArgs["TiltAngle"];
78 
79  idNameSpace = DDCurrentNamespace::ns();
80  childPrefix = sArgs["Child"];
81 #ifdef EDM_ML_DEBUG
82  edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: Parent " << parent().name() << " with " << bundle.size()
83  << " children with prefix " << childPrefix << ", material " << material << " with "
84  << numberPhi << " bundles along phi; width of"
85  << " mother " << deltaZ << " along Z, " << convertRadToDeg(deltaPhi)
86  << " along phi and with " << rStart.size() << " different bundle types";
87  for (unsigned int i = 0; i < areaSection.size(); ++i)
88  edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: Child[" << i << "] Area " << areaSection[i] << " R at Start "
89  << rStart[i] << " R at End " << rEnd[i];
90  edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: NameSpace " << idNameSpace << " Tilt Angle "
91  << convertRadToDeg(tilt) << " Bundle type at different positions";
92  for (unsigned int i = 0; i < bundle.size(); ++i) {
93  edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: Position[" << i << "] "
94  << " with Type " << bundle[i];
95  }
96 #endif
97 }
98 
100  DDName mother = parent().name();
101  DDName matname(DDSplit(material).first, DDSplit(material).second);
102  DDMaterial matter(matname);
103 
104  // Create the rotation matrices
105  double dPhi = deltaPhi / numberPhi;
106  std::vector<DDRotation> rotation;
107  for (int i = 0; i < numberPhi; ++i) {
108  double phi = -0.5 * deltaPhi + (i + 0.5) * dPhi;
109  double phideg = convertRadToDeg(phi);
110  std::string rotstr = "R0" + std::to_string(phideg);
111  DDRotation rot = DDRotation(DDName(rotstr, idNameSpace));
112  if (!rot) {
113 #ifdef EDM_ML_DEBUG
114  edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: Creating a new "
115  << "rotation " << rotstr << "\t" << 90 << "," << phideg << "," << 90 << ","
116  << (phideg + 90) << ", 0, 0";
117 #endif
118  rot = DDrot(DDName(rotstr, idNameSpace), 90._deg, phi, 90._deg, (90._deg + phi), 0, 0);
119  }
120  rotation.emplace_back(rot);
121  }
122 
123  // Create the solids and logical parts
124  std::vector<DDLogicalPart> logs;
125  for (unsigned int i = 0; i < areaSection.size(); ++i) {
126  double r0 = rEnd[i] / std::cos(tilt);
127  double dStart = areaSection[i] / (2 * dPhi * rStart[i]);
128  double dEnd = areaSection[i] / (2 * dPhi * r0);
129  std::string name = childPrefix + std::to_string(i);
130  DDSolid solid = DDSolidFactory::cons(DDName(name, idNameSpace),
131  0.5 * deltaZ,
132  rStart[i] - dStart,
133  rStart[i] + dStart,
134  r0 - dEnd,
135  r0 + dEnd,
136  -0.5 * dPhi,
137  dPhi);
138 #ifdef EDM_ML_DEBUG
139  edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: Creating a new solid " << name << " a cons with dZ " << deltaZ
140  << " rStart " << rStart[i] - dStart << ":" << rStart[i] + dStart << " rEnd "
141  << r0 - dEnd << ":" << r0 + dEnd << " Phi " << convertRadToDeg(-0.5 * dPhi) << ":"
142  << convertRadToDeg(0.5 * dPhi);
143 #endif
144  DDLogicalPart log(DDName(name, idNameSpace), matter, solid);
145  logs.emplace_back(log);
146  }
147 
148  // Now posiiton them
149  int copy = 0;
150  int nY = (int)(bundle.size()) / numberPhi;
151  for (unsigned int i = 0; i < bundle.size(); i++) {
152  DDTranslation tran(0, 0, 0);
153  int ir = (int)(i) / nY;
154  if (ir >= numberPhi)
155  ir = numberPhi - 1;
156  int ib = bundle[i];
157  copy++;
158  if (ib >= 0 && ib < (int)(logs.size())) {
159  cpv.position(logs[ib], mother, copy, tran, rotation[ir]);
160 #ifdef EDM_ML_DEBUG
161  edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: " << logs[ib].name() << " number " << copy
162  << " positioned in " << mother << " at " << tran << " with " << rotation[ir];
163 #endif
164  }
165  }
166 }
167 
168 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHCalFibreBundle, "hcal:DDHCalFibreBundle");
PluginFactory.h
DDHCalFibreBundle::bundle
std::vector< int > bundle
Definition: DDHCalFibreBundle.cc:53
DDCurrentNamespace.h
DDHCalFibreBundle::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDHCalFibreBundle.cc:64
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
DDrot
DDRotation DDrot(const DDName &name, std::unique_ptr< DDRotationMatrix > rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:67
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
DDSplit.h
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
DDHCalFibreBundle::deltaZ
double deltaZ
Definition: DDHCalFibreBundle.cc:46
DDSolidFactory::cons
static DDSolid cons(const DDName &name, double zhalf, double rInMinusZ, double rOutMinusZ, double rInPlusZ, double rOutPlusZ, double phiFrom, double deltaPhi)
Definition: DDSolid.cc:636
geant_units::operators
Definition: GeantUnits.h:18
dbl_to_int
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
dqmdumpme.first
first
Definition: dqmdumpme.py:55
DDHCalFibreBundle::DDHCalFibreBundle
DDHCalFibreBundle()
Definition: DDHCalFibreBundle.cc:56
DDMaterial
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
HLT_2018_cff.dPhi
dPhi
Definition: HLT_2018_cff.py:12290
DDSolid.h
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
DDHCalFibreBundle::~DDHCalFibreBundle
~DDHCalFibreBundle() override
Definition: DDHCalFibreBundle.cc:62
DDHCalFibreBundle::areaSection
std::vector< double > areaSection
Definition: DDHCalFibreBundle.cc:50
GeantUnits.h
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDLogicalPart
A DDLogicalPart aggregates information concerning material, solid and sensitveness ....
Definition: DDLogicalPart.h:93
DDTypes.h
DDMaterial.h
createfilelist.int
int
Definition: createfilelist.py:10
DDutils.h
edm::LogVerbatim
Definition: MessageLogger.h:297
DDHCalFibreBundle::idNameSpace
std::string idNameSpace
Definition: DDHCalFibreBundle.cc:43
DDHCalFibreBundle::material
std::string material
Definition: DDHCalFibreBundle.cc:45
cuy.ib
ib
Definition: cuy.py:662
DDHCalFibreBundle::execute
void execute(DDCompactView &cpv) override
Definition: DDHCalFibreBundle.cc:99
DDHCalFibreBundle::deltaPhi
double deltaPhi
Definition: DDHCalFibreBundle.cc:47
DDLogicalPart.h
DDHCalFibreBundle
Definition: DDHCalFibreBundle.cc:28
ReadMapType< double >
DDAlgorithm.h
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
DDHCalFibreBundle::rEnd
std::vector< double > rEnd
Definition: DDHCalFibreBundle.cc:52
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
DDHCalFibreBundle::rStart
std::vector< double > rStart
Definition: DDHCalFibreBundle.cc:51
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
DDSolid
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
DDHCalFibreBundle::numberPhi
int numberPhi
Definition: DDHCalFibreBundle.cc:48
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
initialize
static AlgebraicMatrix initialize()
Definition: BeamSpotTransientTrackingRecHit.cc:24
DDHCalFibreBundle::tilt
double tilt
Definition: DDHCalFibreBundle.cc:49
DDHCalFibreBundle::childPrefix
std::string childPrefix
Definition: DDHCalFibreBundle.cc:44
DDAlgorithmFactory.h
class-composition.parent
parent
Definition: class-composition.py:88
DDSplit
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'
Definition: DDSplit.cc:3
DDCompactView::position
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
Definition: DDCompactView.cc:66
DDRotation
ROOT::Math::Rotation3D DDRotation
Definition: DDEcalEndcapAlgo.cc:18