File indexing completed on 2024-10-25 23:57:04
0001 #ifndef GEOMETRY_CALOGEOMETRY_CALOSUBDETECTORGEOMETRY_H
0002 #define GEOMETRY_CALOGEOMETRY_CALOSUBDETECTORGEOMETRY_H 1
0003
0004 #include <algorithm>
0005 #include <memory>
0006 #include <vector>
0007 #include <set>
0008 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
0009 #include <atomic>
0010 #endif
0011 #include "DataFormats/DetId/interface/DetId.h"
0012 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0013 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
0014 #include "Geometry/CaloGeometry/interface/CaloCellGeometryPtr.h"
0015 #include "Geometry/CaloGeometry/interface/CaloCellGeometryMayOwnPtr.h"
0016 #include "DataFormats/Math/interface/deltaR.h"
0017
0018
0019
0020
0021
0022
0023
0024
0025 class CaloSubdetectorGeometry {
0026 public:
0027 typedef std::vector<std::shared_ptr<const CaloCellGeometry> > CellSet;
0028 typedef CaloCellGeometry::CCGFloat CCGFloat;
0029
0030 typedef std::set<DetId> DetIdSet;
0031
0032 typedef CaloCellGeometry::ParMgr ParMgr;
0033 typedef CaloCellGeometry::ParVec ParVec;
0034 typedef CaloCellGeometry::ParVecVec ParVecVec;
0035
0036 typedef std::vector<CCGFloat> TrVec;
0037 typedef std::vector<unsigned int> IVec;
0038 typedef std::vector<CCGFloat> DimVec;
0039
0040 using CellPtr = CaloCellGeometryPtr;
0041 using CellMayOwnPtr = CaloCellGeometryMayOwnPtr;
0042
0043 CaloSubdetectorGeometry();
0044
0045
0046 virtual ~CaloSubdetectorGeometry();
0047
0048
0049 CaloSubdetectorGeometry(const CaloSubdetectorGeometry&) = delete;
0050 CaloSubdetectorGeometry& operator=(const CaloSubdetectorGeometry&) = delete;
0051
0052 virtual void newCell(const GlobalPoint& f1,
0053 const GlobalPoint& f2,
0054 const GlobalPoint& f3,
0055 const CCGFloat* parm,
0056 const DetId& detId) = 0;
0057
0058
0059 virtual bool present(const DetId& id) const;
0060
0061
0062 virtual CellMayOwnPtr getGeometry(const DetId& id) const;
0063
0064
0065
0066
0067
0068 virtual const std::vector<DetId>& getValidDetIds(DetId::Detector det = DetId::Detector(0), int subdet = 0) const;
0069
0070
0071 virtual DetId getClosestCell(const GlobalPoint& r) const;
0072
0073
0074
0075
0076
0077
0078
0079 virtual DetIdSet getCells(const GlobalPoint& r, double dR) const;
0080 virtual CellSet getCellSet(const GlobalPoint& r, double dR) const;
0081
0082 CCGFloat deltaPhi(const DetId& detId) const;
0083
0084 CCGFloat deltaEta(const DetId& detId) const;
0085
0086 void allocateCorners(CaloCellGeometry::CornersVec::size_type n);
0087
0088 CaloCellGeometry::CornersMgr* cornersMgr() { return m_cmgr; }
0089
0090 void allocatePar(ParVec::size_type n, unsigned int m);
0091
0092 ParMgr* parMgr() { return m_parMgr; }
0093 const ParMgr* parMgrConst() const { return m_parMgr; }
0094
0095 ParVecVec& parVecVec() { return m_parVecVec; }
0096 const ParVecVec& parVecVec() const { return m_parVecVec; }
0097
0098 virtual unsigned int numberOfShapes() const { return 1; }
0099 virtual unsigned int numberOfParametersPerShape() const { return 1; }
0100 virtual unsigned int numberOfTransformParms() const { return 6; }
0101
0102 virtual void fillDefaultNamedParameters() const { return; }
0103
0104 virtual void getSummary(TrVec& trVector, IVec& iVector, DimVec& dimVector, IVec& dinsVector) const;
0105
0106 virtual void initializeParms() { return; }
0107
0108 virtual bool valid(const DetId& id) const {
0109 return (std::find(m_validIds.begin(), m_validIds.end(), id) != m_validIds.end());
0110 }
0111
0112 protected:
0113 virtual unsigned int indexFor(const DetId& id) const;
0114 virtual unsigned int sizeForDenseIndex(const DetId& id) const;
0115
0116 virtual CellPtr getGeometryRawPtr(uint32_t index) const = 0;
0117 virtual CellPtr cellGeomPtr(uint32_t index) const;
0118
0119 ParVecVec m_parVecVec;
0120
0121 static CCGFloat deltaR(const GlobalPoint& p1, const GlobalPoint& p2) { return reco::deltaR(p1, p2); }
0122
0123 void addValidID(const DetId& id);
0124
0125 std::vector<DetId> m_validIds;
0126
0127 private:
0128 ParMgr* m_parMgr;
0129
0130 CaloCellGeometry::CornersMgr* m_cmgr;
0131
0132 bool m_sortedIds;
0133
0134 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
0135 mutable std::atomic<std::vector<CCGFloat>*> m_deltaPhi;
0136 mutable std::atomic<std::vector<CCGFloat>*> m_deltaEta;
0137 #else
0138 mutable std::vector<CCGFloat>* m_deltaPhi;
0139 mutable std::vector<CCGFloat>* m_deltaEta;
0140 #endif
0141 };
0142
0143 #endif