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