Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-13 03:31:09

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     std::pair<int, int> getWafer(const DetId&) const;
0055     std::pair<int, int> getCell(const DetId&) const;
0056 
0057     bool isHalfCell(const DetId&) const;
0058 
0059     bool isSilicon(const DetId&) const;
0060     bool isScintillator(const DetId&) const;
0061 
0062     bool isOnlySilicon(const unsigned int layer) const;
0063 
0064     // 4-vector helper functions using GlobalPoint
0065     float getEta(const GlobalPoint& position, const float& vertex_z = 0.) const;
0066     float getPhi(const GlobalPoint& position) const;
0067     float getPt(const GlobalPoint& position, const float& hitEnergy, const float& vertex_z = 0.) const;
0068 
0069     // 4-vector helper functions using DetId
0070     float getEta(const DetId& id, const float& vertex_z = 0.) const;
0071     float getPhi(const DetId& id) const;
0072     float getPt(const DetId& id, const float& hitEnergy, const float& vertex_z = 0.) const;
0073 
0074     inline const CaloGeometry* getGeometry() const { return geom_; };
0075     unsigned int lastLayerEE(bool nose = false) const { return (nose ? HFNoseDetId::HFNoseLayerEEmax : fhOffset_); }
0076     unsigned int lastLayerFH() const { return fhLastLayer_; }
0077     unsigned int firstLayerBH() const { return bhFirstLayer_; }
0078     unsigned int lastLayerBH() const { return bhLastLayer_; }
0079     unsigned int lastLayer(bool nose = false) const { return (nose ? noseLastLayer_ : bhLastLayer_); }
0080     std::pair<uint32_t, uint32_t> firstAndLastLayer(DetId::Detector det, int subdet) const;
0081     unsigned int maxNumberOfWafersPerLayer(bool nose = false) const {
0082       return (nose ? maxNumberOfWafersNose_ : maxNumberOfWafersPerLayer_);
0083     }
0084     inline int getScintMaxIphi() const { return bhMaxIphi_; }
0085     inline int getGeometryType() const { return geometryType_; }
0086     bool maskCell(const DetId& id, int corners = 3) const;
0087 
0088   private:
0089     const CaloGeometry* geom_;
0090     unsigned int eeOffset_, fhOffset_, bhFirstLayer_, bhLastLayer_, bhOffset_, fhLastLayer_, noseLastLayer_;
0091     unsigned int maxNumberOfWafersPerLayer_, maxNumberOfWafersNose_;
0092     int geometryType_;
0093     int bhMaxIphi_;
0094   };
0095 }  // namespace hgcal
0096 
0097 #endif