CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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)
math::XYZPoint barycenter_
void computePCA(float radius, bool withHalo=true)
LongDeps energyPerLayer(float radius, bool withHalo=true)
float findZFirstLayer(const LongDeps &) const
const std::unordered_map< DetId, const HGCRecHit * > * getHitMap()
const math::XYZPoint & barycenter() const
std::unique_ptr< TPrincipal > pca_
void setHitMap(const std::unordered_map< DetId, const HGCRecHit * > *hitMap)
to set once per event
const TVectorD & eigenValues() const
void setdEdXWeights(const std::vector< double > &dEdX)
const TVectorD & sigmas() const
void storeRecHits(const reco::CaloCluster &theCluster)
math::XYZPoint Point
std::vector< Spot > theSpots_
ROOT::Math::Transform3D Transform3D
double sigmaUU() const
double sigmaPP() const
void setRecHitTools(const hgcal::RecHitTools *recHitTools)
float clusterDepthCompatibility(const LongDeps &, float &measuredDepth, float &expectedDepth, float &expectedSigma)
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
void printHits(float radius) const
math::XYZVector axis_
double sigmaEE() const
double sigmaVV() const
std::vector< double > invThicknessCorrection_
std::vector< double > dEdXWeights_
const reco::CaloCluster * theCluster_
const TPrincipal & pcaResult()
bool checkIteration() const
const std::unordered_map< DetId, const HGCRecHit * > * hitMap_
const math::XYZVector & axis() const
ROOT::Math::Transform3D::Point Point
const hgcal::RecHitTools * recHitTools_