CMS 3D CMS Logo

FastTimeGeometryLoader.cc
Go to the documentation of this file.
8 
9 #include <sstream>
10 
11 //#define EDM_ML_DEBUG
12 
14 typedef std::vector<float> ParmVec;
15 
18 
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  edm::LogVerbatim("FastTimeGeom") << "Number of Cells " << numberOfCells << " for type " << detType
26  << " of sub-detector " << topology.subDetector() << " Shape parameters "
29 #endif
30  geom->allocateCorners(numberOfCells);
32 
33  // loop over modules
35  unsigned int counter(0);
36 #ifdef EDM_ML_DEBUG
37  edm::LogVerbatim("FastTimeGeom") << "FastTimeGeometryLoader with # of transformation matrices " << numberOfCells;
38 #endif
39  for (unsigned itr = 0; itr < numberOfCells; ++itr) {
40  int zside = (itr == 0) ? 1 : -1;
41 #ifdef EDM_ML_DEBUG
42  edm::LogVerbatim("FastTimeGeom") << "FastTimeGeometryLoader:: Z:Layer:Type " << zside << ":" << detType;
43 #endif
44  double zv = zside * (topology.dddConstants().getZPos(detType));
45  const CLHEP::HepRep3x3 rotation =
46  (zside > 0) ? CLHEP::HepRep3x3(1, 0, 0, 0, 1, 0, 0, 0, 1) : CLHEP::HepRep3x3(-1, 0, 0, 0, 1, 0, 0, 0, -1);
47  const CLHEP::HepRotation hr(rotation);
48  const CLHEP::Hep3Vector h3v(0, 0, zv);
49  const HepGeom::Transform3D ht3d(hr, h3v);
50  DetId detId = (DetId)(FastTimeDetId(detType, 0, 0, zside));
51 #ifdef EDM_ML_DEBUG
52  edm::LogVerbatim("FastTimeGeom") << "FastTimeGeometryLoader:: transf " << ht3d.getTranslation() << " and "
53  << ht3d.getRotation();
54 #endif
55  params[0] = topology.dddConstants().getZHalf(detType);
56  params[1] = params[2] = 0;
57  params[3] = params[7] = topology.dddConstants().getRin(detType);
58  params[4] = params[8] = topology.dddConstants().getRout(detType);
59  params[5] = params[9] = topology.dddConstants().getRout(detType);
60  params[6] = params[10] = 0;
61  params[11] = zside;
62  buildGeom(params, ht3d, detId, topology, geom);
63  counter++;
64  }
65 
66  geom->sortDetIds();
67 
68  if (counter != numberOfCells) {
69  edm::LogWarning("FastTimeGeom") << "inconsistent # of cells: expected " << numberOfCells << " , inited " << counter;
70  assert(counter == numberOfCells);
71  }
72 
73  return geom;
74 }
75 
77  const HepGeom::Transform3D& ht3d,
78  const DetId& detId,
79  const FastTimeTopology& topology,
81 #ifdef EDM_ML_DEBUG
82  std::ostringstream st1;
83  st1 << "Volume Parameters";
84  for (unsigned int i = 0; i < 12; ++i)
85  st1 << " : " << params[i];
86  edm::LogVerbatim("FastTimeGeom") << st1.str();
87 #endif
88  FastTimeDetId id = FastTimeDetId(detId);
89  std::vector<GlobalPoint> corners = topology.dddConstants().getCorners(id.type(), 1, 1, id.zside());
90 
91  FlatTrd::createCorners(params, ht3d, corners);
92 
93  const CCGFloat* parmPtr(CaloCellGeometry::getParmPtr(params, geom->parMgr(), geom->parVecVec()));
94 
95  GlobalPoint front(0.25 * (corners[0].x() + corners[1].x() + corners[2].x() + corners[3].x()),
96  0.25 * (corners[0].y() + corners[1].y() + corners[2].y() + corners[3].y()),
97  0.25 * (corners[0].z() + corners[1].z() + corners[2].z() + corners[3].z()));
98 
99  GlobalPoint back(0.25 * (corners[4].x() + corners[5].x() + corners[6].x() + corners[7].x()),
100  0.25 * (corners[4].y() + corners[5].y() + corners[6].y() + corners[7].y()),
101  0.25 * (corners[4].z() + corners[5].z() + corners[6].z() + corners[7].z()));
102 
103  if (front.mag2() > back.mag2()) { // front should always point to the center, so swap front and back
104  std::swap(front, back);
105  std::swap_ranges(corners.begin(), corners.begin() + 4, corners.begin() + 4);
106  }
107 
108  geom->newCell(front, back, corners[0], parmPtr, detId);
109 }
Log< level::Info, true > LogVerbatim
double getRin(int type) const
double getZHalf(int type) const
CaloCellGeometry::CCGFloat CCGFloat
int detectorType() const
unsigned int totalGeomModules() const
float *__restrict__ zv
CaloCellGeometry::CCGFloat CCGFloat
int zside(DetId const &)
T mag2() const
Definition: PV3DBase.h:63
assert(be >=bs)
void buildGeom(const ParmVec &, const HepGeom::Transform3D &, const DetId &, const FastTimeTopology &, FastTimeGeometry *)
double getRout(int type) const
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
ForwardSubdetector subDetector() const
static const CCGFloat * getParmPtr(const std::vector< CCGFloat > &vd, ParMgr *mgr, ParVecVec &pvv)
const FastTimeDDDConstants & dddConstants() const
FastTimeGeometry * build(const FastTimeTopology &)
Definition: DetId.h:17
double getZPos(int type) const
static void createCorners(const std::vector< CCGFloat > &pv, const Tr3D &tr, std::vector< GlobalPoint > &co)
Definition: FlatTrd.cc:133
std::vector< GlobalPoint > getCorners(int type, int izeta, int iphi, int zside) const
std::vector< float > ParmVec
static std::atomic< unsigned int > counter
Log< level::Warning, false > LogWarning
std::vector< float > ParmVec