CMS 3D CMS Logo

EgammaPCAHelper.h
Go to the documentation of this file.
1 //--------------------------------------------------------------------------------------------------
2 //
3 // EGammaPCAHelper
4 //
5 // Helper Class to compute PCA
6 //
7 //
8 //--------------------------------------------------------------------------------------------------
9 #ifndef RecoEgamma_EgammaTools_EGammaPCAHelper_h
10 #define RecoEgamma_EgammaTools_EGammaPCAHelper_h
11 
13 
19 
24 #include "Math/Transform3D.h"
25 #include <unordered_map>
26 
27 #include "TPrincipal.h"
28 
29 class HGCalRecHit;
30 
31 namespace hgcal {
32 
34  public:
35  typedef ROOT::Math::Transform3D Transform3D;
37 
39 
40  // for the GsfElectrons
41  void storeRecHits(const reco::CaloCluster &theCluster);
42  void storeRecHits(const reco::HGCalMultiCluster &cluster);
43 
44  const TPrincipal &pcaResult();
46  void setHitMap(const std::unordered_map<DetId, const HGCRecHit *> *hitMap);
47  const std::unordered_map<DetId, const HGCRecHit *> *getHitMap() { return hitMap_; }
48 
49  void setRecHitTools(const hgcal::RecHitTools *recHitTools);
50 
51  inline void setdEdXWeights(const std::vector<double> &dEdX) { dEdXWeights_ = dEdX; }
52 
53  void pcaInitialComputation() { computePCA(-1., false); }
54 
55  void computePCA(float radius, bool withHalo = true);
56  const math::XYZPoint &barycenter() const { return barycenter_; }
57  const math::XYZVector &axis() const { return axis_; }
58 
59  void computeShowerWidth(float radius, bool withHalo = true);
60 
61  inline double sigmaUU() const { return checkIteration() ? sigu_ : -1.; }
62  inline double sigmaVV() const { return checkIteration() ? sigv_ : -1.; }
63  inline double sigmaEE() const { return checkIteration() ? sige_ : -1.; }
64  inline double sigmaPP() const { return checkIteration() ? sigp_ : -1.; }
65 
66  inline const TVectorD &eigenValues() const { return *pca_->GetEigenValues(); }
67  inline const TVectorD &sigmas() const { return *pca_->GetSigmas(); }
68  // contains maxlayer+1 values, first layer is [1]
69  LongDeps energyPerLayer(float radius, bool withHalo = true);
70 
71  float clusterDepthCompatibility(const LongDeps &, float &measuredDepth, float &expectedDepth, float &expectedSigma);
72  void printHits(float radius) const;
73  void clear();
74 
75  private:
76  bool checkIteration() const;
77  void storeRecHits(const std::vector<std::pair<DetId, float>> &hf);
78  float findZFirstLayer(const LongDeps &) const;
79 
81  bool debug_;
82 
83  //parameters
84  std::vector<double> dEdXWeights_;
85  std::vector<double> invThicknessCorrection_;
86 
88  const std::unordered_map<DetId, const HGCRecHit *> *hitMap_;
89  std::vector<Spot> theSpots_;
91  unsigned int maxlayer_;
92 
93  // output quantities
96 
98  double sigu_, sigv_, sige_, sigp_;
99 
100  // helper
101  std::unique_ptr<TPrincipal> pca_;
104  };
105 
106 } // namespace hgcal
107 
108 #endif
void computeShowerWidth(float radius, bool withHalo=true)
const TVectorD & sigmas() const
void printHits(float radius) const
math::XYZPoint barycenter_
void computePCA(float radius, bool withHalo=true)
LongDeps energyPerLayer(float radius, bool withHalo=true)
const std::unordered_map< DetId, const HGCRecHit * > * getHitMap()
double sigmaEE() const
std::unique_ptr< TPrincipal > pca_
double sigmaVV() const
void setdEdXWeights(const std::vector< double > &dEdX)
const math::XYZPoint & barycenter() const
const TVectorD & eigenValues() const
void storeRecHits(const reco::CaloCluster &theCluster)
math::XYZPoint Point
std::vector< Spot > theSpots_
ROOT::Math::Transform3D Transform3D
double sigmaPP() const
const math::XYZVector & axis() const
void setRecHitTools(const hgcal::RecHitTools *recHitTools)
float clusterDepthCompatibility(const LongDeps &, float &measuredDepth, float &expectedDepth, float &expectedSigma)
float findZFirstLayer(const LongDeps &) const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
math::XYZVector axis_
std::vector< double > invThicknessCorrection_
void setHitMap(const std::unordered_map< DetId, const HGCRecHit *> *hitMap)
to set once per event
std::vector< double > dEdXWeights_
const reco::CaloCluster * theCluster_
const TPrincipal & pcaResult()
const std::unordered_map< DetId, const HGCRecHit * > * hitMap_
ROOT::Math::Transform3D::Point Point
double sigmaUU() const
const hgcal::RecHitTools * recHitTools_