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 <map>
26 
27 #include "TPrincipal.h"
28 
29 class HGCalRecHit;
30 
31 namespace hgcal {
32 
34  public:
35  typedef ROOT::Math::Transform3D Transform3D;
37 
40 
41  // for the GsfElectrons
42  void storeRecHits(const reco::CaloCluster &theCluster);
43  void storeRecHits(const reco::HGCalMultiCluster &cluster);
44 
45  const TPrincipal &pcaResult();
47  void setHitMap(std::map<DetId, const HGCRecHit *> *hitMap);
49  void fillHitMap(const HGCRecHitCollection &HGCEERecHits,
50  const HGCRecHitCollection &HGCFHRecHits,
51  const HGCRecHitCollection &HGCBHRecHits);
52 
53  std::map<DetId, const HGCRecHit *> *getHitMap() { return hitMap_; }
54 
55  void setRecHitTools(const hgcal::RecHitTools *recHitTools);
56 
57  inline void setdEdXWeights(const std::vector<double> &dEdX) { dEdXWeights_ = dEdX; }
58 
59  void pcaInitialComputation() { computePCA(-1., false); }
60 
61  void computePCA(float radius, bool withHalo = true);
62  const math::XYZPoint &barycenter() const { return barycenter_; }
63  const math::XYZVector &axis() const { return axis_; }
64 
65  void computeShowerWidth(float radius, bool withHalo = true);
66 
67  inline double sigmaUU() const { return checkIteration() ? sigu_ : -1.; }
68  inline double sigmaVV() const { return checkIteration() ? sigv_ : -1.; }
69  inline double sigmaEE() const { return checkIteration() ? sige_ : -1.; }
70  inline double sigmaPP() const { return checkIteration() ? sigp_ : -1.; }
71 
72  inline const TVectorD &eigenValues() const { return *pca_->GetEigenValues(); }
73  inline const TVectorD &sigmas() const { return *pca_->GetSigmas(); }
74  // contains maxlayer+1 values, first layer is [1]
75  LongDeps energyPerLayer(float radius, bool withHalo = true);
76 
77  float clusterDepthCompatibility(const LongDeps &, float &measuredDepth, float &expectedDepth, float &expectedSigma);
78  void printHits(float radius) const;
79  void clear();
80 
81  private:
82  bool checkIteration() const;
83  void storeRecHits(const std::vector<std::pair<DetId, float>> &hf);
84  float findZFirstLayer(const LongDeps &) const;
85 
87  bool debug_;
88 
89  //parameters
90  std::vector<double> dEdXWeights_;
91  std::vector<double> invThicknessCorrection_;
92 
93  int hitMapOrigin_; // 0 not initialized; 1 set from outside ; 2 set from inside
95  std::map<DetId, const HGCRecHit *> *hitMap_;
96  std::vector<Spot> theSpots_;
98  unsigned int maxlayer_;
99 
100  // output quantities
103 
104  Transform3D trans_;
105  double sigu_, sigv_, sige_, sigp_;
106 
107  // helper
108  std::unique_ptr<TPrincipal> pca_;
111  };
112 
113 } // namespace hgcal
114 
115 #endif
void computeShowerWidth(float radius, bool withHalo=true)
math::XYZPoint barycenter_
void computePCA(float radius, bool withHalo=true)
std::map< DetId, const HGCRecHit * > * hitMap_
LongDeps energyPerLayer(float radius, bool withHalo=true)
float findZFirstLayer(const LongDeps &) const
const math::XYZPoint & barycenter() const
std::unique_ptr< TPrincipal > pca_
const TVectorD & eigenValues() const
void setdEdXWeights(const std::vector< double > &dEdX)
const TVectorD & sigmas() const
void storeRecHits(const reco::CaloCluster &theCluster)
math::XYZPoint Point
void setHitMap(std::map< DetId, const HGCRecHit * > *hitMap)
to set from outside - once per event
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
double sigmaEE() const
double sigmaVV() const
std::vector< double > invThicknessCorrection_
void fillHitMap(const HGCRecHitCollection &HGCEERecHits, const HGCRecHitCollection &HGCFHRecHits, const HGCRecHitCollection &HGCBHRecHits)
to compute from inside - once per event
std::vector< double > dEdXWeights_
const reco::CaloCluster * theCluster_
const TPrincipal & pcaResult()
std::map< DetId, const HGCRecHit * > * getHitMap()
bool checkIteration() const
const math::XYZVector & axis() const
ROOT::Math::Transform3D::Point Point
const hgcal::RecHitTools * recHitTools_