CMS 3D CMS Logo

EcalTBHodoscopeGeometryLoaderFromDDD.cc
Go to the documentation of this file.
2 
5 
13 
15 
16 #include <iostream>
17 #include <utility>
18 #include <vector>
19 #include <memory>
20 
21 std::unique_ptr<CaloSubdetectorGeometry>
23 {
24  std::cout << "[EcalTBHodoscopeGeometryLoaderFromDDD]:: start the construction of EcalTBHodoscope" << std::endl;
25 
26  std::unique_ptr<CaloSubdetectorGeometry> ebg
27  ( new EcalTBHodoscopeGeometry() ) ;
28 
29  makeGeometry( cpv, ebg.get() ) ;
30 
31  std::cout << "[EcalTBHodoscopeGeometryLoaderFromDDD]:: Returning EcalTBHodoscopeGeometry" << std::endl;
32 
33  return std::move(ebg);
34 }
35 
36 void
38  const DDCompactView* cpv ,
40 {
42  if( ebg->parMgr() == nullptr ) ebg->allocatePar( 10, 3 ) ;
43 
44  std::unique_ptr<DDFilter> filter{getDDFilter()};
45 
46  DDFilteredView fv(*cpv,*filter);
47 
48  bool doSubDets;
49  for (doSubDets = fv.firstChild(); doSubDets ; doSubDets = fv.nextSibling())
50  {
51 
52 #if 0
53  std::string answer = getDDDString("ReadOutName",&fv);
54  if (answer != "EcalTBH4BeamHits")
55  continue;
56 #endif
57 
58  const DDSolid & solid = fv.logicalPart().solid();
59 
60  if( solid.shape() != DDSolidShape::ddbox )
61  {
62  throw cms::Exception("DDException") << std::string(__FILE__)
63  << "\n CaloGeometryEcalTBHodoscope::upDate(...): currently only box fiber shapes supported ";
64  edm::LogWarning("EcalTBHodoscopeGeometry") << "Wrong shape for sensitive volume!" << solid;
65  }
66 
67  std::vector<double> pv = solid.parameters();
68 
69  // use preshower strip as box in space representation
70 
71  // rotate the box and then move it
72  DD3Vector x, y, z;
73  fv.rotation().GetComponents(x,y,z);
74  CLHEP::Hep3Vector hx(x.X(), x.Y(), x.Z());
75  CLHEP::Hep3Vector hy(y.X(), y.Y(), y.Z());
76  CLHEP::Hep3Vector hz(z.X(), z.Y(), z.Z());
77  CLHEP::HepRotation hrot(hx, hy, hz);
78  CLHEP::Hep3Vector htran ( fv.translation().X(),
79  fv.translation().Y(),
80  fv.translation().Z() );
81 
82  const HepGeom::Transform3D ht3d ( hrot, // only scale translation
84 
85  const HepGeom::Point3D<float> ctr (
86  ht3d*HepGeom::Point3D<float> (0,0,0) ) ;
87 
88  const GlobalPoint refPoint ( ctr.x(), ctr.y(), ctr.z() ) ;
89 
90  std::vector<CCGFloat> vv ;
91  vv.reserve( pv.size() + 1 ) ;
92  for( unsigned int i ( 0 ) ; i != pv.size() ; ++i )
93  {
94  vv.emplace_back( CaloCellGeometry::k_ScaleFromDDDtoGeant*pv[i] ) ;
95  }
96  vv.emplace_back( 0. ) ; // tilt=0 here
97  const CCGFloat* pP ( CaloCellGeometry::getParmPtr( vv,
98  ebg->parMgr(),
99  ebg->parVecVec() ) ) ;
100 
101  const DetId detId ( getDetIdForDDDNode(fv) ) ;
102 
103  //Adding cell to the Geometry
104 
105  ebg->newCell( refPoint, refPoint, refPoint,
106  pP,
107  detId ) ;
108  } // loop over all children
109 }
110 
111 unsigned int
113  const DDFilteredView &fv )
114 {
115  // perform some consistency checks
116  // get the parents and grandparents of this node
118 
119  assert(parents.size() >= 3);
120 
121  EcalBaseNumber baseNumber;
122  //baseNumber.setSize(parents.size());
123 
124  for( unsigned int i=1 ;i <= parents.size(); i++)
125  {
126  baseNumber.addLevel( parents[ parents.size() - i ].logicalPart().name().name(),
127  parents[ parents.size() - i ].copyno() ) ;
128  }
129 
130  return _scheme.getUnitID( baseNumber ) ;
131 }
132 
134 {
136  DDSpecificsMatchesValueFilter>(
137  DDSpecificsMatchesValueFilter{DDValue( "SensitiveDetector",
138  "EcalTBH4BeamDetector",
139  0 )},
140  DDSpecificsMatchesValueFilter{DDValue( "ReadOutName",
141  "EcalTBH4BeamHits",
142  0 )});
143 }
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:144
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
TPRegexp parents
Definition: eve_filter.cc:21
virtual void newCell(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId)=0
bool nextSibling()
set the current node to the next sibling ...
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
std::unique_ptr< CaloSubdetectorGeometry > load(const DDCompactView *cpv)
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
uint32_t getUnitID(const EcalBaseNumber &baseNumber) const override
#define nullptr
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:83
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
void allocatePar(ParVec::size_type n, unsigned int m)
A DDSolid represents the shape of a part.
Definition: DDSolid.h:38
std::string getDDDString(std::string s, DDFilteredView *fv)
void addLevel(const std::string &name, const int &copyNumber)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
def pv(vc)
Definition: MetAnalyzer.py:6
CaloCellGeometry::CCGFloat CCGFloat
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:138
CaloCellGeometry::CCGFloat CCGFloat
static const CCGFloat * getParmPtr(const std::vector< CCGFloat > &vd, ParMgr *mgr, ParVecVec &pvv)
static const CCGFloat k_ScaleFromDDDtoGeant
std::vector< DDExpandedNode > DDGeoHistory
Geometrical &#39;path&#39; of the current node up to the root-node.
Definition: DetId.h:18
CaloCellGeometry::CornersMgr * cornersMgr()
bool firstChild()
set the current node to the first child ...
unsigned int getDetIdForDDDNode(const DDFilteredView &fv)
A Filter accepts or rejects a DDExpandedNode based on a user-coded decision rule. ...
Definition: DDFilter.h:15
void allocateCorners(CaloCellGeometry::CornersVec::size_type n)
const DDTranslation & translation() const
The absolute translation of the current node.
def move(src, dest)
Definition: eostools.py:510
void makeGeometry(const DDCompactView *cpv, CaloSubdetectorGeometry *ebg)
answer
Definition: submit.py:44