Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:34:20

0001 //--------------------------------------------------------------------------------------------------
0002 //
0003 // EGammaPCAHelper
0004 //
0005 // Helper Class to compute PCA
0006 //
0007 //
0008 //--------------------------------------------------------------------------------------------------
0009 #ifndef RecoEgamma_EgammaTools_EGammaPCAHelper_h
0010 #define RecoEgamma_EgammaTools_EGammaPCAHelper_h
0011 
0012 #include "FWCore/Framework/interface/Frameworkfwd.h"
0013 
0014 #include "DataFormats/CaloRecHit/interface/CaloCluster.h"
0015 #include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h"
0016 #include "DataFormats/ForwardDetId/interface/HGCalDetId.h"
0017 #include "DataFormats/Math/interface/Vector3D.h"
0018 #include "DataFormats/ParticleFlowReco/interface/HGCalMultiCluster.h"
0019 
0020 #include "RecoEgamma/EgammaTools/interface/Spot.h"
0021 #include "RecoEgamma/EgammaTools/interface/LongDeps.h"
0022 #include "RecoEgamma/EgammaTools/interface/ShowerDepth.h"
0023 #include "RecoLocalCalo/HGCalRecAlgos/interface/RecHitTools.h"
0024 #include "Math/Transform3D.h"
0025 #include <unordered_map>
0026 
0027 #include "TPrincipal.h"
0028 
0029 class HGCalRecHit;
0030 
0031 namespace hgcal {
0032 
0033   class EGammaPCAHelper {
0034   public:
0035     typedef ROOT::Math::Transform3D Transform3D;
0036     typedef ROOT::Math::Transform3D::Point Point;
0037 
0038     EGammaPCAHelper();
0039 
0040     // for the GsfElectrons
0041     void storeRecHits(const reco::CaloCluster &theCluster);
0042     void storeRecHits(const reco::HGCalMultiCluster &cluster);
0043 
0044     const TPrincipal &pcaResult();
0045     /// to set once per event
0046     void setHitMap(const std::unordered_map<DetId, const HGCRecHit *> *hitMap);
0047     const std::unordered_map<DetId, const HGCRecHit *> *getHitMap() { return hitMap_; }
0048 
0049     void setRecHitTools(const hgcal::RecHitTools *recHitTools);
0050 
0051     inline void setdEdXWeights(const std::vector<double> &dEdX) { dEdXWeights_ = dEdX; }
0052 
0053     void pcaInitialComputation() { computePCA(-1., false); }
0054 
0055     void computePCA(float radius, bool withHalo = true);
0056     const math::XYZPoint &barycenter() const { return barycenter_; }
0057     const math::XYZVector &axis() const { return axis_; }
0058 
0059     void computeShowerWidth(float radius, bool withHalo = true);
0060 
0061     inline double sigmaUU() const { return checkIteration() ? sigu_ : -1.; }
0062     inline double sigmaVV() const { return checkIteration() ? sigv_ : -1.; }
0063     inline double sigmaEE() const { return checkIteration() ? sige_ : -1.; }
0064     inline double sigmaPP() const { return checkIteration() ? sigp_ : -1.; }
0065 
0066     inline const TVectorD &eigenValues() const { return *pca_->GetEigenValues(); }
0067     inline const TVectorD &sigmas() const { return *pca_->GetSigmas(); }
0068     // contains maxlayer+1 values, first layer is [1]
0069     LongDeps energyPerLayer(float radius, bool withHalo = true);
0070 
0071     float clusterDepthCompatibility(const LongDeps &, float &measuredDepth, float &expectedDepth, float &expectedSigma);
0072     void printHits(float radius) const;
0073     void clear();
0074 
0075   private:
0076     bool checkIteration() const;
0077     void storeRecHits(const std::vector<std::pair<DetId, float>> &hf);
0078     float findZFirstLayer(const LongDeps &) const;
0079 
0080     bool recHitsStored_;
0081     bool debug_;
0082 
0083     //parameters
0084     std::vector<double> dEdXWeights_;
0085     std::vector<double> invThicknessCorrection_;
0086 
0087     const reco::CaloCluster *theCluster_;
0088     const std::unordered_map<DetId, const HGCRecHit *> *hitMap_;
0089     std::vector<Spot> theSpots_;
0090     int pcaIteration_;
0091     unsigned int maxlayer_;
0092 
0093     // output quantities
0094     math::XYZPoint barycenter_;
0095     math::XYZVector axis_;
0096 
0097     Transform3D trans_;
0098     double sigu_, sigv_, sige_, sigp_;
0099 
0100     // helper
0101     std::unique_ptr<TPrincipal> pca_;
0102     const hgcal::RecHitTools *recHitTools_;
0103     ShowerDepth showerDepth_;
0104   };
0105 
0106 }  // namespace hgcal
0107 
0108 #endif