Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:14:16

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