CMS 3D CMS Logo

DDHCalForwardAlgo.cc
Go to the documentation of this file.
1 // File: DDHCalForwardAlgo.cc
3 // Description: Cable mockup between barrel and endcap gap
5 
6 #include <cmath>
7 #include <algorithm>
8 #include <map>
9 #include <string>
10 #include <vector>
11 
23 
24 //#define EDM_ML_DEBUG
25 
26 class DDHCalForwardAlgo : public DDAlgorithm {
27 public:
28  //Constructor and Destructor
29  DDHCalForwardAlgo(); //const std::string & name);
30  ~DDHCalForwardAlgo() override;
31 
32  void initialize(const DDNumericArguments& nArgs,
33  const DDVectorArguments& vArgs,
34  const DDMapArguments& mArgs,
35  const DDStringArguments& sArgs,
36  const DDStringVectorArguments& vsArgs) override;
37 
38  void execute(DDCompactView& cpv) override;
39 
40 private:
41  std::string cellMat; //Cell material
42  double cellDx, cellDy, cellDz; //Cell size
43  double startY; //Starting Y for Cell
44  std::vector<std::string> childName; //Children name
45  std::vector<int> number; //Number of cells
46  std::vector<int> size; //Number of children
47  std::vector<int> type; //First child
48 
49  std::string idNameSpace; //Namespace for aLL sub-parts
50 };
51 
53 #ifdef EDM_ML_DEBUG
54  edm::LogVerbatim("HCalGeom") << "DDHCalForwardAlgo: Creating an instance";
55 #endif
56 }
57 
59 
61  const DDVectorArguments& vArgs,
62  const DDMapArguments&,
63  const DDStringArguments& sArgs,
64  const DDStringVectorArguments& vsArgs) {
65  cellMat = sArgs["CellMaterial"];
66  cellDx = nArgs["CellDx"];
67  cellDy = nArgs["CellDy"];
68  cellDz = nArgs["CellDz"];
69  startY = nArgs["StartY"];
70 
71  childName = vsArgs["Child"];
72  number = dbl_to_int(vArgs["Number"]);
73  size = dbl_to_int(vArgs["Size"]);
74  type = dbl_to_int(vArgs["Type"]);
75 
76 #ifdef EDM_ML_DEBUG
77  edm::LogVerbatim("HCalGeom") << "DDHCalForwardAlgo: Cell material " << cellMat << "\tCell Size " << cellDx << ", "
78  << cellDy << ", " << cellDz << "\tStarting Y " << startY << "\tChildren " << childName[0]
79  << ", " << childName[1] << "\n "
80  << " Cell positioning done for " << number.size() << " times";
81  for (unsigned int i = 0; i < number.size(); i++)
82  edm::LogVerbatim("HCalGeom") << "\t" << i << " Number of children " << size[i] << " occurence " << number[i]
83  << " first child index " << type[i];
84 #endif
86 #ifdef EDM_ML_DEBUG
87  edm::LogVerbatim("HCalGeom") << "DDHCalForwardAlgo debug: Parent " << parent().name() << " NameSpace " << idNameSpace;
88 #endif
89 }
90 
92 #ifdef EDM_ML_DEBUG
93  edm::LogVerbatim("HCalGeom") << "==>> Constructing DDHCalForwardAlgo...";
94 #endif
95  DDName parentName = parent().name();
96  double ypos = startY;
97  int box = 0;
98 
99  for (unsigned int i = 0; i < number.size(); i++) {
100  double dx = cellDx * size[i];
101  int indx = type[i];
102  for (int j = 0; j < number[i]; j++) {
103  box++;
104  std::string name = parentName.name() + std::to_string(box);
106 #ifdef EDM_ML_DEBUG
107  edm::LogVerbatim("HCalGeom") << "DDHCalForwardAlgo: " << DDName(name, idNameSpace) << " Box made of " << cellMat
108  << " of Size " << dx << ", " << cellDy << ", " << cellDz;
109 #endif
111  DDMaterial matter(matname);
112  DDLogicalPart genlogic(solid.ddname(), matter, solid);
113 
114  DDTranslation r0(0.0, ypos, 0.0);
115  DDRotation rot;
116  cpv.position(solid.ddname(), parentName, box, r0, rot);
117 #ifdef EDM_ML_DEBUG
118  edm::LogVerbatim("HCalGeom") << "DDHCalForwardAlgo: " << solid.ddname() << " number " << box << " positioned in "
119  << parentName << " at " << r0 << " with " << rot;
120 #endif
122  double xpos = -dx + cellDx;
123  ypos += 2 * cellDy;
124  indx = 1 - indx;
125 
126  for (int k = 0; k < size[i]; k++) {
127  DDTranslation r1(xpos, 0.0, 0.0);
128  cpv.position(child, solid.ddname(), k + 1, r1, rot);
129 #ifdef EDM_ML_DEBUG
130  edm::LogVerbatim("HCalGeom") << "DDHCalForwardAlgo: " << child << " number " << k + 1 << " positioned in "
131  << solid.ddname() << " at " << r1 << " with " << rot;
132 #endif
133  xpos += 2 * cellDx;
134  }
135  }
136  }
137 #ifdef EDM_ML_DEBUG
138  edm::LogVerbatim("HCalGeom") << "<<== End of DDHCalForwardAlgo construction";
139 #endif
140 }
141 
142 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHCalForwardAlgo, "hcal:DDHCalForwardAlgo");
DDHCalForwardAlgo::idNameSpace
std::string idNameSpace
Definition: DDHCalForwardAlgo.cc:49
PluginFactory.h
DDCurrentNamespace.h
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
DDSplit.h
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
DDHCalForwardAlgo::~DDHCalForwardAlgo
~DDHCalForwardAlgo() override
Definition: DDHCalForwardAlgo.cc:58
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
DDMaterial
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
contentValuesFiles.number
number
Definition: contentValuesFiles.py:53
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDHCalForwardAlgo::cellDz
double cellDz
Definition: DDHCalForwardAlgo.cc:42
DDHCalForwardAlgo::cellMat
std::string cellMat
Definition: DDHCalForwardAlgo.cc:41
DDSolid.h
DDHCalForwardAlgo::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDHCalForwardAlgo.cc:60
dqmdumpme.k
k
Definition: dqmdumpme.py:60
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
DDHCalForwardAlgo::type
std::vector< int > type
Definition: DDHCalForwardAlgo.cc:47
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDHCalForwardAlgo::cellDy
double cellDy
Definition: DDHCalForwardAlgo.cc:42
DDBase::ddname
const N & ddname() const
Definition: DDBase.h:61
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDLogicalPart
A DDLogicalPart aggregates information concerning material, solid and sensitveness ....
Definition: DDLogicalPart.h:93
DDTypes.h
DDMaterial.h
DDutils.h
DDName::name
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
DDHCalForwardAlgo
Definition: DDHCalForwardAlgo.cc:26
DDLogicalPart.h
DDHCalForwardAlgo::DDHCalForwardAlgo
DDHCalForwardAlgo()
Definition: DDHCalForwardAlgo.cc:52
ReadMapType< double >
DDAlgorithm.h
submitPVValidationJobs.child
child
Definition: submitPVValidationJobs.py:119
diffTwoXMLs.r1
r1
Definition: diffTwoXMLs.py:53
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
DDHCalForwardAlgo::size
std::vector< int > size
Definition: DDHCalForwardAlgo.cc:46
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
DDHCalForwardAlgo::childName
std::vector< std::string > childName
Definition: DDHCalForwardAlgo.cc:44
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
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
DDHCalForwardAlgo::cellDx
double cellDx
Definition: DDHCalForwardAlgo.cc:42
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
DDSolidFactory::box
static DDSolid box(const DDName &name, double xHalf, double yHalf, double zHalf)
Creates a box with side length 2*xHalf, 2*yHalf, 2*zHalf.
Definition: DDSolid.cc:533
child
Definition: simpleInheritance.h:11
DDAlgorithmFactory.h
edm::Log
Definition: MessageLogger.h:70
class-composition.parent
parent
Definition: class-composition.py:88
DDHCalForwardAlgo::execute
void execute(DDCompactView &cpv) override
Definition: DDHCalForwardAlgo.cc:91
PVValHelper::dx
Definition: PVValidationHelpers.h:48
DDHCalForwardAlgo::startY
double startY
Definition: DDHCalForwardAlgo.cc:43
DDSplit
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'
Definition: DDSplit.cc:3
DDHCalForwardAlgo::number
std::vector< int > number
Definition: DDHCalForwardAlgo.cc:45
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:76
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443