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 
13 
14 //#define EDM_ML_DEBUG
15 
17 #ifdef EDM_ML_DEBUG
18  edm::LogVerbatim("HCalGeom") << "DDHCalLinearXY: Creating an instance";
19 #endif
20 }
21 
23 
25  const DDVectorArguments & vArgs,
26  const DDMapArguments & ,
27  const DDStringArguments & sArgs,
28  const DDStringVectorArguments & vsArgs) {
29 
30  numberX = int(nArgs["NumberX"]);
31  deltaX = nArgs["DeltaX"];
32  numberY = int(nArgs["NumberY"]);
33  deltaY = nArgs["DeltaY"];
34  centre = vArgs["Center"];
35 
37  childName = vsArgs["Child"];
38 #ifdef EDM_ML_DEBUG
39  edm::LogVerbatim("HCalGeom") << "DDHCalLinearXY: Parent " << parent().name()
40  << "\twith " << childName.size() << " children";
41  for (unsigned int i=0; i<childName.size(); ++i)
42  edm::LogVerbatim("HCalGeom") << "DDHCalLinearXY: Child[" << i << "] = "
43  << childName[i];
44  edm::LogVerbatim("HCalGeom") << "DDHCalLinearXY: NameSpace " << idNameSpace
45  << "\tNumber along X/Y " << numberX << "/"
46  << numberY << "\tDelta along X/Y " << deltaX
47  << "/" << deltaY << "\tCentre " << centre[0]
48  << ", " << centre[1] << ", " << centre[2];
49 #endif
50 }
51 
53 
54  DDName mother = parent().name();
55  DDName child;
57  double xoff = centre[0] - (numberX-1)*deltaX/2.;
58  double yoff = centre[1] - (numberY-1)*deltaY/2.;
59  int copy = 0;
60 
61  for (int i=0; i<numberX; i++) {
62  for (int j=0; j<numberY; j++) {
63 
64  DDTranslation tran(xoff+i*deltaX,yoff+j*deltaY,centre[2]);
65  bool place = true;
66  unsigned int k = copy;
67  if (childName.size() == 1) k = 0;
68  if (k < childName.size() && (childName[k] != " " &&
69  childName[k] != "Null")) {
71  } else {
72  place = false;
73  }
74  copy++;
75  if (place) {
76  cpv.position(child, mother, copy, tran, rot);
77 #ifdef EDM_ML_DEBUG
78  edm::LogVerbatim("HCalGeom") << "DDHCalLinearXY: " << child
79  << " number " << copy << " positioned in "
80  << mother << " at " << tran << " with "
81  << rot;
82 #endif
83  } else {
84 #ifdef EDM_ML_DEBUG
85  edm::LogVerbatim("HCalGeom") << "DDHCalLinearXY: No child placed for ["
86  << copy << "]";
87 #endif
88  }
89  }
90  }
91 }
def copy(args, dbName)
void execute(DDCompactView &cpv) override
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
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< std::string > childName
~DDHCalLinearXY() override
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
std::string idNameSpace
int k[5][pyjets_maxn]
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=0)
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
std::vector< double > centre