Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:25:52

0001 #ifndef __RecoLocalCalo_HGCalRecAlgos_RecHitTools_h__
0002 #define __RecoLocalCalo_HGCalRecAlgos_RecHitTools_h__
0003 
0004 #include <array>
0005 #include <cmath>
0006 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0007 #include "DataFormats/DetId/interface/DetId.h"
0008 #include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"
0009 #include "DataFormats/ForwardDetId/interface/HFNoseDetId.h"
0010 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0011 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0012 
0013 class CaloGeometry;
0014 class CaloSubdetectorGeometry;
0015 class DetId;
0016 
0017 namespace edm {
0018   class Event;
0019   class EventSetup;
0020 }  // namespace edm
0021 
0022 namespace hgcal {
0023   class RecHitTools {
0024   public:
0025     RecHitTools()
0026         : geom_(nullptr),
0027           eeOffset_(0),
0028           fhOffset_(0),
0029           bhFirstLayer_(0),
0030           bhOffset_(0),
0031           fhLastLayer_(0),
0032           noseLastLayer_(0),
0033           geometryType_(0) {}
0034     ~RecHitTools() {}
0035 
0036     void setGeometry(CaloGeometry const&);
0037     const CaloSubdetectorGeometry* getSubdetectorGeometry(const DetId& id) const;
0038 
0039     GlobalPoint getPosition(const DetId& id) const;
0040     GlobalPoint getPositionLayer(int layer, bool nose = false) const;
0041     // zside returns +/- 1
0042     int zside(const DetId& id) const;
0043 
0044     std::float_t getSiThickness(const DetId&) const;
0045     std::float_t getRadiusToSide(const DetId&) const;
0046     int getSiThickIndex(const DetId&) const;
0047 
0048     std::pair<float, float> getScintDEtaDPhi(const DetId&) const;
0049 
0050     unsigned int getLayer(DetId::Detector type, bool nose = false) const;
0051     unsigned int getLayer(ForwardSubdetector type) const;
0052     unsigned int getLayer(const DetId&) const;
0053     unsigned int getLayerWithOffset(const DetId&) const;
0054     int getCellType(const DetId& id) const;
0055     std::pair<int, int> getWafer(const DetId&) const;
0056     std::pair<int, int> getCell(const DetId&) const;
0057 
0058     bool isHalfCell(const DetId&) const;
0059 
0060     bool isSilicon(const DetId&) const;
0061     bool isScintillator(const DetId&) const;
0062 
0063     bool isOnlySilicon(const unsigned int layer) const;
0064 
0065     // 4-vector helper functions using GlobalPoint
0066     float getEta(const GlobalPoint& position, const float& vertex_z = 0.) const;
0067     float getPhi(const GlobalPoint& position) const;
0068     float getPt(const GlobalPoint& position, const float& hitEnergy, const float& vertex_z = 0.) const;
0069 
0070     // 4-vector helper functions using DetId
0071     float getEta(const DetId& id, const float& vertex_z = 0.) const;
0072     float getPhi(const DetId& id) const;
0073     float getPt(const DetId& id, const float& hitEnergy, const float& vertex_z = 0.) const;
0074 
0075     inline const CaloGeometry* getGeometry() const { return geom_; };
0076     unsigned int lastLayerEE(bool nose = false) const { return (nose ? HFNoseDetId::HFNoseLayerEEmax : fhOffset_); }
0077     unsigned int lastLayerFH() const { return fhLastLayer_; }
0078     unsigned int firstLayerBH() const { return bhFirstLayer_; }
0079     unsigned int lastLayerBH() const { return bhLastLayer_; }
0080     unsigned int lastLayer(bool nose = false) const { return (nose ? noseLastLayer_ : bhLastLayer_); }
0081     std::pair<uint32_t, uint32_t> firstAndLastLayer(DetId::Detector det, int subdet) const;
0082     unsigned int maxNumberOfWafersPerLayer(bool nose = false) const {
0083       return (nose ? maxNumberOfWafersNose_ : maxNumberOfWafersPerLayer_);
0084     }
0085     inline int getScintMaxIphi() const { return bhMaxIphi_; }
0086     inline int getGeometryType() const { return geometryType_; }
0087     bool maskCell(const DetId& id, int corners = 3) const;
0088 
0089   private:
0090     const CaloGeometry* geom_;
0091     unsigned int eeOffset_, fhOffset_, bhFirstLayer_, bhLastLayer_, bhOffset_, fhLastLayer_, noseLastLayer_;
0092     unsigned int maxNumberOfWafersPerLayer_, maxNumberOfWafersNose_;
0093     int geometryType_;
0094     int bhMaxIphi_;
0095   };
0096 }  // namespace hgcal
0097 
0098 #endif