Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-07-17 22:23:13

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     struct siliconWaferInfo {
0026       int32_t type, partialType, orientation, placementIndex, cassette;
0027       siliconWaferInfo(int32_t t = 0, int32_t p = 0, int32_t o = 0, int32_t i = 0, int32_t c = 0)
0028           : type(t), partialType(p), orientation(o), placementIndex(i), cassette(c) {}
0029     };
0030     struct scintillatorTileInfo {
0031       int32_t type, sipm, cassette;
0032       scintillatorTileInfo(int32_t t = 0, int32_t s = 0, int32_t c = 0) : type(t), sipm(s), cassette(c) {}
0033     };
0034     RecHitTools()
0035         : geom_(nullptr),
0036           eeOffset_(0),
0037           fhOffset_(0),
0038           bhFirstLayer_(0),
0039           bhOffset_(0),
0040           fhLastLayer_(0),
0041           noseLastLayer_(0),
0042           hcalBarrelFirstLayer_(1),
0043           hcalBarrelLastLayer_(4),
0044           ecalBarrelFirstLayer_(0),
0045           ecalBarrelLastLayer_(0),
0046           geometryType_(0) {}
0047     ~RecHitTools() {}
0048 
0049     void setGeometry(CaloGeometry const&);
0050     const CaloSubdetectorGeometry* getSubdetectorGeometry(const DetId& id) const;
0051 
0052     GlobalPoint getPosition(const DetId& id) const;
0053     GlobalPoint getPositionLayer(int layer, bool nose = false, bool barrel = false) const;
0054     // zside returns +/- 1
0055     int zside(const DetId& id) const;
0056 
0057     std::float_t getSiThickness(const DetId&) const;
0058     std::float_t getRadiusToSide(const DetId&) const;
0059     int getSiThickIndex(const DetId&) const;
0060 
0061     std::pair<float, float> getScintDEtaDPhi(const DetId&) const;
0062 
0063     unsigned int getLayer(DetId::Detector type, bool nose = false) const;
0064     unsigned int getLayer(ForwardSubdetector type) const;
0065     unsigned int getLayer(const DetId&) const;
0066     unsigned int getLayerWithOffset(const DetId&) const;
0067     int getCellType(const DetId& id) const;
0068     std::pair<int, int> getWafer(const DetId&) const;
0069     std::pair<int, int> getCell(const DetId&) const;
0070 
0071     bool isHalfCell(const DetId&) const;
0072 
0073     bool isSilicon(const DetId&) const;
0074     bool isScintillator(const DetId&) const;
0075     bool isScintillatorFine(const DetId& id) const;
0076     bool isBarrel(const DetId&) const;
0077 
0078     bool isOnlySilicon(const unsigned int layer) const;
0079 
0080     // 4-vector helper functions using GlobalPoint
0081     float getEta(const GlobalPoint& position, const float& vertex_z = 0.) const;
0082     float getPhi(const GlobalPoint& position) const;
0083     float getPt(const GlobalPoint& position, const float& hitEnergy, const float& vertex_z = 0.) const;
0084 
0085     // 4-vector helper functions using DetId
0086     float getEta(const DetId& id, const float& vertex_z = 0.) const;
0087     float getPhi(const DetId& id) const;
0088     float getPt(const DetId& id, const float& hitEnergy, const float& vertex_z = 0.) const;
0089     int getScintMaxIphi(const DetId& id) const;
0090 
0091     inline const CaloGeometry* getGeometry() const { return geom_; };
0092     unsigned int lastLayerEE(bool nose = false) const { return (nose ? HFNoseDetId::HFNoseLayerEEmax : fhOffset_); }
0093     unsigned int lastLayerFH() const { return fhLastLayer_; }
0094     unsigned int firstLayerBH() const { return bhFirstLayer_; }
0095     unsigned int lastLayerBH() const { return bhLastLayer_; }
0096     unsigned int lastLayer(bool nose = false) const { return (nose ? noseLastLayer_ : bhLastLayer_); }
0097     unsigned int lastLayerECAL() const { return ecalBarrelLastLayer_; }
0098     unsigned int lastLayerBarrel() const { return hcalBarrelLastLayer_; }
0099     std::pair<uint32_t, uint32_t> firstAndLastLayer(DetId::Detector det, int subdet) const;
0100     unsigned int maxNumberOfWafersPerLayer(bool nose = false) const {
0101       return (nose ? maxNumberOfWafersNose_ : maxNumberOfWafersPerLayer_);
0102     }
0103     inline int getScintMaxIphi() const { return bhMaxIphi_; }
0104     inline int getGeometryType() const { return geometryType_; }
0105     bool maskCell(const DetId& id, int corners = 3) const;
0106 
0107     // Informaion of the wafer/tile
0108     siliconWaferInfo getWaferInfo(const DetId& id) const;
0109     scintillatorTileInfo getTileInfo(const DetId& id) const;
0110     int getWaferTypes(DetId::Detector det, int subdet = ForwardSubdetector::ForwardEmpty) const;
0111     std::vector<double> getSiThickness(DetId::Detector det, int subdet = ForwardSubdetector::ForwardEmpty) const;
0112 
0113   private:
0114     const CaloGeometry* geom_;
0115     unsigned int eeOffset_, fhOffset_, bhFirstLayer_, bhLastLayer_, bhOffset_, fhLastLayer_, noseLastLayer_;
0116     unsigned int hcalBarrelFirstLayer_, hcalBarrelLastLayer_, ecalBarrelFirstLayer_, ecalBarrelLastLayer_;
0117     unsigned int maxNumberOfWafersPerLayer_, maxNumberOfWafersNose_;
0118     int geometryType_;
0119     int bhMaxIphi_;
0120   };
0121 }  // namespace hgcal
0122 
0123 #endif