Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:07:37

0001 #ifndef GEOMETRY_CALOGEOMETRY_CALOSUBDETECTORGEOMETRY_H
0002 #define GEOMETRY_CALOGEOMETRY_CALOSUBDETECTORGEOMETRY_H 1
0003 
0004 #include <memory>
0005 #include <vector>
0006 #include <set>
0007 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
0008 #include <atomic>
0009 #endif
0010 #include "DataFormats/DetId/interface/DetId.h"
0011 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0012 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
0013 #include "DataFormats/Math/interface/deltaR.h"
0014 
0015 /** \class CaloSubdetectorGeometry
0016       
0017 Base class for a geometry container for a specific calorimetry subdetector.
0018 
0019 
0020 \author J. Mans - Minnesota
0021 */
0022 class CaloSubdetectorGeometry {
0023 public:
0024   typedef std::vector<std::shared_ptr<const CaloCellGeometry> > CellSet;
0025   typedef CaloCellGeometry::CCGFloat CCGFloat;
0026 
0027   typedef std::set<DetId> DetIdSet;
0028 
0029   typedef CaloCellGeometry::ParMgr ParMgr;
0030   typedef CaloCellGeometry::ParVec ParVec;
0031   typedef CaloCellGeometry::ParVecVec ParVecVec;
0032 
0033   typedef std::vector<CCGFloat> TrVec;
0034   typedef std::vector<unsigned int> IVec;
0035   typedef std::vector<CCGFloat> DimVec;
0036 
0037   CaloSubdetectorGeometry();
0038 
0039   /// The base class DOES assume that it owns the CaloCellGeometry objects
0040   virtual ~CaloSubdetectorGeometry();
0041 
0042   /// avoid copies
0043   CaloSubdetectorGeometry(const CaloSubdetectorGeometry&) = delete;
0044   CaloSubdetectorGeometry& operator=(const CaloSubdetectorGeometry&) = delete;
0045 
0046   virtual void newCell(const GlobalPoint& f1,
0047                        const GlobalPoint& f2,
0048                        const GlobalPoint& f3,
0049                        const CCGFloat* parm,
0050                        const DetId& detId) = 0;
0051 
0052   /// is this detid present in the geometry?
0053   virtual bool present(const DetId& id) const;
0054 
0055   /// Get the cell geometry of a given detector id.  Should return false if not found.
0056   virtual std::shared_ptr<const CaloCellGeometry> getGeometry(const DetId& id) const;
0057 
0058   /** \brief Get a list of valid detector ids (for the given subdetector)
0059       \note The implementation in this class is relevant for SubdetectorGeometries which handle only
0060       a single subdetector at a time.  It does not look at the det and subdet arguments.
0061   */
0062   virtual const std::vector<DetId>& getValidDetIds(DetId::Detector det = DetId::Detector(0), int subdet = 0) const;
0063 
0064   // Get closest cell, etc...
0065   virtual DetId getClosestCell(const GlobalPoint& r) const;
0066 
0067   /** \brief Get a list of all cells within a dR of the given cell
0068       
0069       The default implementation makes a loop over all cell geometries.
0070       Cleverer implementations are suggested to use rough conversions between
0071       eta/phi and ieta/iphi and test on the boundaries.
0072   */
0073   virtual DetIdSet getCells(const GlobalPoint& r, double dR) const;
0074   virtual CellSet getCellSet(const GlobalPoint& r, double dR) const;
0075 
0076   CCGFloat deltaPhi(const DetId& detId) const;
0077 
0078   CCGFloat deltaEta(const DetId& detId) const;
0079 
0080   void allocateCorners(CaloCellGeometry::CornersVec::size_type n);
0081 
0082   CaloCellGeometry::CornersMgr* cornersMgr() { return m_cmgr; }
0083 
0084   void allocatePar(ParVec::size_type n, unsigned int m);
0085 
0086   ParMgr* parMgr() { return m_parMgr; }
0087   const ParMgr* parMgrConst() const { return m_parMgr; }
0088 
0089   ParVecVec& parVecVec() { return m_parVecVec; }
0090   const ParVecVec& parVecVec() const { return m_parVecVec; }
0091 
0092   virtual unsigned int numberOfShapes() const { return 1; }
0093   virtual unsigned int numberOfParametersPerShape() const { return 1; }
0094   virtual unsigned int numberOfTransformParms() const { return 6; }
0095 
0096   virtual void fillDefaultNamedParameters() const { return; }
0097 
0098   virtual void getSummary(TrVec& trVector, IVec& iVector, DimVec& dimVector, IVec& dinsVector) const;
0099 
0100   virtual void initializeParms() { return; }
0101 
0102 protected:
0103   virtual unsigned int indexFor(const DetId& id) const;
0104   virtual unsigned int sizeForDenseIndex(const DetId& id) const;
0105 
0106   virtual const CaloCellGeometry* getGeometryRawPtr(uint32_t index) const = 0;
0107   virtual std::shared_ptr<const CaloCellGeometry> cellGeomPtr(uint32_t index) const;
0108 
0109   ParVecVec m_parVecVec;
0110 
0111   static CCGFloat deltaR(const GlobalPoint& p1, const GlobalPoint& p2) { return reco::deltaR(p1, p2); }
0112 
0113   void addValidID(const DetId& id);
0114 
0115   std::vector<DetId> m_validIds;
0116 
0117 private:
0118   ParMgr* m_parMgr;
0119 
0120   CaloCellGeometry::CornersMgr* m_cmgr;
0121 
0122   bool m_sortedIds;
0123 
0124 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
0125   mutable std::atomic<std::vector<CCGFloat>*> m_deltaPhi;
0126   mutable std::atomic<std::vector<CCGFloat>*> m_deltaEta;
0127 #else
0128   mutable std::vector<CCGFloat>* m_deltaPhi;
0129   mutable std::vector<CCGFloat>* m_deltaEta;
0130 #endif
0131 };
0132 
0133 #endif