CMS 3D CMS Logo

DDHCalLinearXY.cc
Go to the documentation of this file.
1 // File: DDHCalLinearXY.cc
3 // Description: Position nxXny copies at given intervals along x and y axis
5 
6 #include <cmath>
7 #include <algorithm>
8 #include <map>
9 #include <string>
10 #include <vector>
11 
19 
20 //#define EDM_ML_DEBUG
21 
22 class DDHCalLinearXY : public DDAlgorithm {
23 public:
24  //Constructor and Destructor
26  ~DDHCalLinearXY() override;
27 
28  void initialize(const DDNumericArguments& nArgs,
29  const DDVectorArguments& vArgs,
30  const DDMapArguments& mArgs,
31  const DDStringArguments& sArgs,
32  const DDStringVectorArguments& vsArgs) override;
33 
34  void execute(DDCompactView& cpv) override;
35 
36 private:
37  std::string idNameSpace; //Namespace of this and ALL sub-parts
38  std::vector<std::string> childName; //Child name
39  int numberX; //Number of positioning along X-axis
40  double deltaX; //Increment .........
41  int numberY; //Number of positioning along Y-axis
42  double deltaY; //Increment .........
43  std::vector<double> centre; //Centre
44 };
45 
47 #ifdef EDM_ML_DEBUG
48  edm::LogVerbatim("HCalGeom") << "DDHCalLinearXY: Creating an instance";
49 #endif
50 }
51 
53 
55  const DDVectorArguments& vArgs,
56  const DDMapArguments&,
57  const DDStringArguments& sArgs,
58  const DDStringVectorArguments& vsArgs) {
59  numberX = int(nArgs["NumberX"]);
60  deltaX = nArgs["DeltaX"];
61  numberY = int(nArgs["NumberY"]);
62  deltaY = nArgs["DeltaY"];
63  centre = vArgs["Center"];
64 
66  childName = vsArgs["Child"];
67 #ifdef EDM_ML_DEBUG
68  edm::LogVerbatim("HCalGeom") << "DDHCalLinearXY: Parent " << parent().name() << "\twith " << childName.size()
69  << " children";
70  for (unsigned int i = 0; i < childName.size(); ++i)
71  edm::LogVerbatim("HCalGeom") << "DDHCalLinearXY: Child[" << i << "] = " << childName[i];
72  edm::LogVerbatim("HCalGeom") << "DDHCalLinearXY: NameSpace " << idNameSpace << "\tNumber along X/Y " << numberX << "/"
73  << numberY << "\tDelta along X/Y " << deltaX << "/" << deltaY << "\tCentre " << centre[0]
74  << ", " << centre[1] << ", " << centre[2];
75 #endif
76 }
77 
79  DDName mother = parent().name();
80  DDName child;
82  double xoff = centre[0] - (numberX - 1) * deltaX / 2.;
83  double yoff = centre[1] - (numberY - 1) * deltaY / 2.;
84  int copy = 0;
85 
86  for (int i = 0; i < numberX; i++) {
87  for (int j = 0; j < numberY; j++) {
88  DDTranslation tran(xoff + i * deltaX, yoff + j * deltaY, centre[2]);
89  bool place = true;
90  unsigned int k = copy;
91  if (childName.size() == 1)
92  k = 0;
93  if (k < childName.size() && (childName[k] != " " && childName[k] != "Null")) {
95  } else {
96  place = false;
97  }
98  copy++;
99  if (place) {
100  cpv.position(child, mother, copy, tran, rot);
101 #ifdef EDM_ML_DEBUG
102  edm::LogVerbatim("HCalGeom") << "DDHCalLinearXY: " << child << " number " << copy << " positioned in " << mother
103  << " at " << tran << " with " << rot;
104 #endif
105  } else {
106 #ifdef EDM_ML_DEBUG
107  edm::LogVerbatim("HCalGeom") << "DDHCalLinearXY: No child placed for [" << copy << "]";
108 #endif
109  }
110  }
111  }
112 }
113 
114 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHCalLinearXY, "hcal:DDHCalLinearXY");
PluginFactory.h
DDHCalLinearXY::execute
void execute(DDCompactView &cpv) override
Definition: DDHCalLinearXY.cc:78
DDCurrentNamespace.h
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
DDHCalLinearXY::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDHCalLinearXY.cc:54
DDSplit.h
DDHCalLinearXY::deltaX
double deltaX
Definition: DDHCalLinearXY.cc:40
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
DDHCalLinearXY::childName
std::vector< std::string > childName
Definition: DDHCalLinearXY.cc:38
DDHCalLinearXY::centre
std::vector< double > centre
Definition: DDHCalLinearXY.cc:43
DDHCalLinearXY::numberY
int numberY
Definition: DDHCalLinearXY.cc:41
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DDHCalLinearXY
Definition: DDHCalLinearXY.cc:22
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDHCalLinearXY::idNameSpace
std::string idNameSpace
Definition: DDHCalLinearXY.cc:37
dqmdumpme.k
k
Definition: dqmdumpme.py:60
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDHCalLinearXY::~DDHCalLinearXY
~DDHCalLinearXY() override
Definition: DDHCalLinearXY.cc:52
DDTypes.h
createfilelist.int
int
Definition: createfilelist.py:10
DDHCalLinearXY::numberX
int numberX
Definition: DDHCalLinearXY.cc:39
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ReadMapType< double >
DDAlgorithm.h
submitPVValidationJobs.child
child
Definition: submitPVValidationJobs.py:119
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
DDHCalLinearXY::DDHCalLinearXY
DDHCalLinearXY()
Definition: DDHCalLinearXY.cc:46
DDHCalLinearXY::deltaY
double deltaY
Definition: DDHCalLinearXY.cc:42
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
child
Definition: simpleInheritance.h:11
DDAlgorithmFactory.h
edm::Log
Definition: MessageLogger.h:70
class-composition.parent
parent
Definition: class-composition.py:98
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:76