CMS 3D CMS Logo

ZdcGeometry.cc
Go to the documentation of this file.
7 #include <algorithm>
8 
9 #include <Math/Transform3D.h>
10 #include <Math/EulerAngles.h>
11 
12 #include <algorithm>
13 
17 
19 
20 //#define EDM_ML_DEBUG
21 
23  : theTopology(new ZdcTopology),
24  lastReqDet_(DetId::Detector(0)),
25  lastReqSubdet_(0),
26  m_ownsTopology(true),
27  m_cellVec(k_NumberOfCellsForCorners) {}
28 
30  : theTopology(topology),
31  lastReqDet_(DetId::Detector(0)),
32  lastReqSubdet_(0),
33  m_ownsTopology(false),
34  m_cellVec(k_NumberOfCellsForCorners) {}
35 
37  if (m_ownsTopology)
38  delete theTopology;
39 }
40 /*
41 DetId ZdcGeometry::getClosestCell(const GlobalPoint& r) const
42 {
43  DetId returnId ( 0 ) ;
44  const std::vector<DetId>& detIds ( getValidDetIds() ) ;
45  for( std::vector<DetId>::const_iterator it ( detIds.begin() ) ;
46  it != detIds.end(); ++it )
47  {
48  auto cell = ( getGeometry( *it ) ) ;
49  if( 0 != cell &&
50  cell->inside( r ) )
51  {
52  returnId = *it ;
53  break ;
54  }
55  }
56  return returnId ;
57 }
58 */
60  const CaloGenericDetId gid(id);
61  assert(gid.isZDC());
62 
63  return (0 > HcalZDCDetId(id).zside() ? 0 : 1);
64 }
65 
66 unsigned int ZdcGeometry::alignmentTransformIndexGlobal(const DetId& /*id*/) { return (unsigned int)DetId::Calo - 1; }
67 
68 void ZdcGeometry::localCorners(Pt3DVec& lc, const CCGFloat* pv, unsigned int /*i*/, Pt3D& ref) {
70 }
71 
73  const GlobalPoint& /*f2*/,
74  const GlobalPoint& /*f3*/,
75  const CCGFloat* parm,
76  const DetId& detId) {
77  const CaloGenericDetId cgid(detId);
78 #ifdef EDM_ML_DEBUG
79  edm::LogVerbatim("ZDCGeom") << "ZDCGeometry " << HcalZDCDetId(detId) << " Generic ID " << std::hex << cgid.rawId()
80  << std::dec << " ZDC? " << cgid.isZDC();
81 #endif
82  assert(cgid.isZDC());
83 
84  const unsigned int di(cgid.denseIndex());
85 
86  m_cellVec[di] = IdealZDCTrapezoid(f1, cornersMgr(), parm);
88 }
89 
91  // Modify the RawPtr class
92  if (m_cellVec.size() < index)
93  return nullptr;
94  const CaloCellGeometry* cell(&m_cellVec[index]);
95  return (((cell == nullptr) || (nullptr == cell->param())) ? nullptr : cell);
96 }
97 
101  CaloSubdetectorGeometry::IVec& /*dins*/) const {
102  tVec.reserve(m_validIds.size() * numberOfTransformParms());
103  iVec.reserve(numberOfShapes() == 1 ? 1 : m_validIds.size());
105 
106  for (const auto& pv : parVecVec()) {
107  for (float iv : pv) {
108  dVec.emplace_back(iv);
109  }
110  }
111 
112  for (uint32_t i(0); i != m_validIds.size(); ++i) {
113  Tr3D tr;
114  std::shared_ptr<const CaloCellGeometry> ptr(cellGeomPtr(i));
115 #ifdef EDM_ML_DEBUG
116  edm::LogVerbatim("ZDCGeom") << "ZDCGeometry:Summary " << i << ":" << HcalZDCDetId::kSizeForDenseIndexingRun1
117  << " Pointer " << ptr << ":" << (nullptr != ptr);
118 #endif
119  if (i < static_cast<int32_t>(HcalZDCDetId::kSizeForDenseIndexingRun1))
120  assert(nullptr != ptr);
121  if (ptr != nullptr) {
122  ptr->getTransform(tr, (Pt3DVec*)nullptr);
123 
124  if (Tr3D() == tr) { // for preshower there is no rotation
125  const GlobalPoint& gp(ptr->getPosition());
126  tr = HepGeom::Translate3D(gp.x(), gp.y(), gp.z());
127  }
128 
129  const CLHEP::Hep3Vector tt(tr.getTranslation());
130  tVec.emplace_back(tt.x());
131  tVec.emplace_back(tt.y());
132  tVec.emplace_back(tt.z());
133  if (6 == numberOfTransformParms()) {
134  const CLHEP::HepRotation rr(tr.getRotation());
135  const ROOT::Math::Transform3D rtr(
136  rr.xx(), rr.xy(), rr.xz(), tt.x(), rr.yx(), rr.yy(), rr.yz(), tt.y(), rr.zx(), rr.zy(), rr.zz(), tt.z());
138  rtr.GetRotation(ea);
139  tVec.emplace_back(ea.Phi());
140  tVec.emplace_back(ea.Theta());
141  tVec.emplace_back(ea.Psi());
142  }
143 
144  const CCGFloat* par(ptr->param());
145 
146  unsigned int ishape(9999);
147  for (unsigned int ivv(0); ivv != parVecVec().size(); ++ivv) {
148  bool ok(true);
149  const CCGFloat* pv(&(*parVecVec()[ivv].begin()));
150  for (unsigned int k(0); k != numberOfParametersPerShape(); ++k) {
151  ok = ok && (fabs(par[k] - pv[k]) < 1.e-6);
152  }
153  if (ok) {
154  ishape = ivv;
155  break;
156  }
157  }
158  assert(9999 != ishape);
159 
160  const unsigned int nn((numberOfShapes() == 1) ? (unsigned int)1 : m_validIds.size());
161  if (iVec.size() < nn)
162  iVec.emplace_back(ishape);
163  }
164  }
165 }
Log< level::Info, true > LogVerbatim
void newCell(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId) override
Definition: ZdcGeometry.cc:72
static unsigned int alignmentTransformIndexLocal(const DetId &id)
Definition: ZdcGeometry.cc:59
static void localCorners(Pt3DVec &lc, const CCGFloat *pv, unsigned int i, Pt3D &ref)
Definition: ZdcGeometry.cc:68
CellVec m_cellVec
Definition: ZdcGeometry.h:77
std::vector< CCGFloat > DimVec
const CaloCellGeometry * getGeometryRawPtr(uint32_t index) const override
Definition: ZdcGeometry.cc:90
CaloCellGeometry::Pt3D Pt3D
Definition: ZdcGeometry.h:17
virtual unsigned int numberOfTransformParms() const
static unsigned int alignmentTransformIndexGlobal(const DetId &id)
Definition: ZdcGeometry.cc:66
std::vector< unsigned int > IVec
uint32_t denseIndex() const
std::vector< CCGFloat > TrVec
void getSummary(CaloSubdetectorGeometry::TrVec &tVec, CaloSubdetectorGeometry::IVec &iVec, CaloSubdetectorGeometry::DimVec &dVec, CaloSubdetectorGeometry::IVec &dins) const override
Definition: ZdcGeometry.cc:98
HepGeom::Transform3D Tr3D
CaloCellGeometry::Pt3DVec Pt3DVec
Definition: ZdcGeometry.h:18
std::vector< Pt3D > Pt3DVec
CaloCellGeometry::Tr3D Tr3D
Definition: ZdcGeometry.h:19
static constexpr int32_t kSizeForDenseIndexingRun1
Definition: HcalZDCDetId.h:201
assert(be >=bs)
CaloCellGeometry::Pt3D Pt3D
Definition: ZdcGeometry.cc:14
CaloCellGeometry::CCGFloat CCGFloat
Definition: TTTypes.h:54
std::vector< DetId > m_validIds
bool m_ownsTopology
Definition: ZdcGeometry.h:75
def pv(vc)
Definition: MetAnalyzer.py:7
const ZdcTopology * theTopology
Definition: ZdcGeometry.h:72
~ZdcGeometry() override
Definition: ZdcGeometry.cc:36
Definition: DetId.h:17
AlgebraicVector EulerAngles
Definition: Definitions.h:34
void addValidID(const DetId &id)
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
CaloCellGeometry::CornersMgr * cornersMgr()
HepGeom::Point3D< CCGFloat > Pt3D
CaloCellGeometry::Pt3DVec Pt3DVec
Definition: ZdcGeometry.cc:15
CaloCellGeometry::Tr3D Tr3D
Definition: ZdcGeometry.cc:16
virtual std::shared_ptr< const CaloCellGeometry > cellGeomPtr(uint32_t index) const
constexpr int32_t zside() const
get the z-side of the cell (1/-1)
Definition: HcalZDCDetId.h:90
CaloSubdetectorGeometry::CCGFloat CCGFloat
Definition: ZdcGeometry.cc:18
const CCGFloat * param() const
unsigned int numberOfParametersPerShape() const override
Definition: ZdcGeometry.h:35
bool isZDC() const
unsigned int numberOfShapes() const override
Definition: ZdcGeometry.h:34