CMS 3D CMS Logo

FastTimeGeometryLoader.cc
Go to the documentation of this file.
9 
10 #define EDM_ML_DEBUG
11 
13 typedef std::vector<float> ParmVec;
14 
17 
19 
20  // allocate geometry
21  FastTimeGeometry* geom = new FastTimeGeometry (topology);
22  unsigned int numberOfCells = topology.totalGeomModules(); // both sides
23  int detType = topology.detectorType();
24 #ifdef EDM_ML_DEBUG
25  std::cout << "Number of Cells " << numberOfCells << " for type " << detType
26  << " of sub-detector " << topology.subDetector()
27  << " Shape parameters " << FastTimeGeometry::k_NumberOfShapes
29  << std::endl;
30 #endif
31  geom->allocateCorners( numberOfCells ) ;
34 
35  // loop over modules
37  unsigned int counter(0);
38 #ifdef EDM_ML_DEBUG
39  std::cout << "FastTimeGeometryLoader with # of transformation matrices "
40  << numberOfCells << std::endl;
41 #endif
42  for (unsigned itr=0; itr<numberOfCells; ++itr) {
43  int zside = (itr == 0) ? 1 : -1;
44 #ifdef EDM_ML_DEBUG
45  std::cout << "FastTimeGeometryLoader:: Z:Layer:Type " << zside
46  << ":" << detType <<std::endl;
47 #endif
48  double zv = zside*(topology.dddConstants().getZPos(detType));
49  const CLHEP::HepRep3x3 rotation = (zside > 0) ?
50  CLHEP::HepRep3x3(1,0,0,0,1,0,0,0,1) :
51  CLHEP::HepRep3x3(-1,0,0,0,1,0,0,0,-1);
52  const CLHEP::HepRotation hr ( rotation );
53  const CLHEP::Hep3Vector h3v(0,0,zv);
54  const HepGeom::Transform3D ht3d (hr, h3v);
55  DetId detId = (DetId)(FastTimeDetId(detType,0,0,zside));
56 #ifdef EDM_ML_DEBUG
57  std::cout << "FastTimeGeometryLoader:: transf " << ht3d.getTranslation()
58  << " and " << ht3d.getRotation();
59 #endif
60  params[0] = topology.dddConstants().getZHalf(detType);
61  params[1] = params[2] = 0;
62  params[3] = params[7] = topology.dddConstants().getRin(detType);
63  params[4] = params[8] = topology.dddConstants().getRout(detType);
64  params[5] = params[9] = topology.dddConstants().getRout(detType);
65  params[6] = params[10]= 0;
66  params[11]= zside;
67  buildGeom(params, ht3d, detId, topology, geom);
68  counter++;
69  }
70 
71  geom->sortDetIds();
72 
73  if (counter != numberOfCells) {
74  std::cerr << "inconsistent # of cells: expected " << numberOfCells
75  << " , inited " << counter << std::endl;
76  assert( counter == numberOfCells ) ;
77  }
78 
79  return geom;
80 }
81 
83  const HepGeom::Transform3D& ht3d,
84  const DetId& detId,
87 
88 #ifdef EDM_ML_DEBUG
89  std::cout << "Volume Parameters";
90  for (unsigned int i=0; i<12; ++i) std::cout << " : " << params[i];
91  std::cout << std::endl;
92 #endif
93  FastTimeDetId id = FastTimeDetId(detId);
94  std::vector<GlobalPoint> corners = topology.dddConstants().getCorners(id.type(),1,1,id.zside());
95 
96  FlatTrd::createCorners( params, ht3d, corners ) ;
97 
98  const CCGFloat* parmPtr (CaloCellGeometry::getParmPtr(params,
99  geom->parMgr(),
100  geom->parVecVec() ) ) ;
101 
102  GlobalPoint front ( 0.25*( corners[0].x() +
103  corners[1].x() +
104  corners[2].x() +
105  corners[3].x() ),
106  0.25*( corners[0].y() +
107  corners[1].y() +
108  corners[2].y() +
109  corners[3].y() ),
110  0.25*( corners[0].z() +
111  corners[1].z() +
112  corners[2].z() +
113  corners[3].z() ) ) ;
114 
115  GlobalPoint back ( 0.25*( corners[4].x() +
116  corners[5].x() +
117  corners[6].x() +
118  corners[7].x() ),
119  0.25*( corners[4].y() +
120  corners[5].y() +
121  corners[6].y() +
122  corners[7].y() ),
123  0.25*( corners[4].z() +
124  corners[5].z() +
125  corners[6].z() +
126  corners[7].z() ) ) ;
127 
128  if (front.mag2() > back.mag2()) { // front should always point to the center, so swap front and back
129  std::swap (front, back);
130  std::swap_ranges (corners.begin(), corners.begin()+4, corners.begin()+4);
131  }
132 
133  geom->newCell(front, back, corners[0], parmPtr, detId) ;
134 }
type
Definition: HCALResponse.h:21
T mag2() const
Definition: PV3DBase.h:66
double getZPos(int type) const
CaloCellGeometry::CCGFloat CCGFloat
unsigned int totalGeomModules() const
CaloTopology const * topology(0)
ForwardSubdetector subDetector() const
CaloCellGeometry::CCGFloat CCGFloat
int detectorType() const
void allocatePar(ParVec::size_type n, unsigned int m)
void buildGeom(const ParmVec &, const HepGeom::Transform3D &, const DetId &, const FastTimeTopology &, FastTimeGeometry *)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
susybsm::HSCParticleRef hr
Definition: classes.h:26
static const CCGFloat * getParmPtr(const std::vector< CCGFloat > &vd, ParMgr *mgr, ParVecVec &pvv)
std::vector< GlobalPoint > getCorners(int type, int izeta, int iphi, int zside) const
FastTimeGeometry * build(const FastTimeTopology &)
Definition: DetId.h:18
double getRin(int type) const
void newCell(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId) override
static void createCorners(const std::vector< CCGFloat > &pv, const Tr3D &tr, std::vector< GlobalPoint > &co)
Definition: FlatTrd.cc:140
std::vector< float > ParmVec
double getRout(int type) const
static std::atomic< unsigned int > counter
double getZHalf(int type) const
void allocateCorners(CaloCellGeometry::CornersVec::size_type n)
const FastTimeDDDConstants & dddConstants() const
std::vector< float > ParmVec