CMS 3D CMS Logo

HGCalShowerShape.h
Go to the documentation of this file.
1 #ifndef __L1Trigger_L1THGCal_HGCalShowerShape_h__
2 #define __L1Trigger_L1THGCal_HGCalShowerShape_h__
3 #include <vector>
4 #include <functional>
5 #include <cmath>
11 
13 public:
15 
18 
20 
22 
23  int firstLayer(const l1t::HGCalMulticluster& c3d) const;
24  int lastLayer(const l1t::HGCalMulticluster& c3d) const;
25  int maxLayer(const l1t::HGCalMulticluster& c3d) const;
26  int showerLength(const l1t::HGCalMulticluster& c3d) const {
27  return lastLayer(c3d) - firstLayer(c3d) + 1;
28  } //in number of layers
29  // Maximum number of consecutive layers in the cluster
30  int coreShowerLength(const l1t::HGCalMulticluster& c3d, const HGCalTriggerGeometryBase& triggerGeometry) const;
31  float percentileLayer(const l1t::HGCalMulticluster& c3d,
32  const HGCalTriggerGeometryBase& triggerGeometry,
33  float quantile = 0.5) const;
34 
35  float percentileTriggerCells(const l1t::HGCalMulticluster& c3d, float quantile = 0.5) const;
36 
37  float eMax(const l1t::HGCalMulticluster& c3d) const;
38 
39  float meanZ(const l1t::HGCalMulticluster& c3d) const;
40  float sigmaZZ(const l1t::HGCalMulticluster& c3d) const;
41  float varZZ(const l1t::HGCalMulticluster& c3d) const;
42 
43  float sigmaEtaEtaTot(const l1t::HGCalMulticluster& c3d) const;
44  float sigmaEtaEtaTot(const l1t::HGCalCluster& c2d) const;
45  float sigmaEtaEtaMax(const l1t::HGCalMulticluster& c3d) const;
46  float varEtaEta(const l1t::HGCalMulticluster& c3d) const;
47 
48  float sigmaPhiPhiTot(const l1t::HGCalMulticluster& c3d) const;
49  float sigmaPhiPhiTot(const l1t::HGCalCluster& c2d) const;
50  float sigmaPhiPhiMax(const l1t::HGCalMulticluster& c3d) const;
51  float varPhiPhi(const l1t::HGCalMulticluster& c3d) const;
52 
53  float sigmaRRTot(const l1t::HGCalMulticluster& c3d) const;
54  float sigmaRRTot(const l1t::HGCalCluster& c2d) const;
55  float sigmaRRMax(const l1t::HGCalMulticluster& c3d) const;
56  float sigmaRRMean(const l1t::HGCalMulticluster& c3d, float radius = 5.) const;
57  float varRR(const l1t::HGCalMulticluster& c3d) const;
58  float sumLayers(const l1t::HGCalMulticluster& c3d, int start = 1, int end = 0) const;
59  int bitmap(const l1t::HGCalMulticluster& c3d, int start = 1, int end = 14, float threshold = 0) const;
61 
62 private:
63  float meanX(const std::vector<pair<float, float>>& energy_X_tc) const;
64  // Compute energy-weighted RMS of any variable X in the cluster
65  // Delta(a,b) functor as template argument. Default is (a-b)
66  template <typename Delta = std::minus<float>>
67  float varXX(const std::vector<pair<float, float>>& energy_X_tc, const float X_cluster) const {
68  Delta delta;
69  float Etot = 0;
70  float deltaX2_sum = 0;
71  for (const auto& energy_X : energy_X_tc) {
72  deltaX2_sum += energy_X.first * pow(delta(energy_X.second, X_cluster), 2);
73  Etot += energy_X.first;
74  }
75  float X_MSE = 0;
76  if (Etot > 0)
77  X_MSE = deltaX2_sum / Etot;
78  return X_MSE;
79  }
80 
81  float sigmaXX(const std::vector<pair<float, float>>& energy_X_tc, const float X_cluster) const {
82  float X_RMS = sqrt(varXX(energy_X_tc, X_cluster));
83  return X_RMS;
84  }
85 
86  // Special case of delta for phi
87  float sigmaPhiPhi(const std::vector<pair<float, float>>& energy_phi_tc, const float phi_cluster) const {
88  return sqrt(varPhiPhi(energy_phi_tc, phi_cluster));
89  }
90  template <class T>
91  struct DeltaPhi {
92  T operator()(const T& x, const T& y) const { return deltaPhi(x, y); }
93  };
94  float varPhiPhi(const std::vector<pair<float, float>>& energy_phi_tc, const float phi_cluster) const {
95  return varXX<DeltaPhi<float>>(energy_phi_tc, phi_cluster);
96  }
97 
98  template <typename T, typename Tref>
99  bool pass(const T& obj, const Tref& ref) const {
100  bool pass_threshold = (obj.mipPt() > threshold_);
101  GlobalPoint proj(Basic3DVector<float>(obj.position()) / std::abs(obj.position().z()));
102  bool pass_distance = ((proj - ref.centreProj()).mag() < distance_);
103  return pass_threshold && pass_distance;
104  }
105 
107  double threshold_ = 0.;
108  double distance_ = 1.;
109 };
110 
111 #endif
float meanX(const std::vector< pair< float, float >> &energy_X_tc) const
Definition: start.py:1
float varZZ(const l1t::HGCalMulticluster &c3d) const
float varPhiPhi(const std::vector< pair< float, float >> &energy_phi_tc, const float phi_cluster) const
HGCalTriggerTools triggerTools_
float percentileTriggerCells(const l1t::HGCalMulticluster &c3d, float quantile=0.5) const
int lastLayer(const l1t::HGCalMulticluster &c3d) const
float percentileLayer(const l1t::HGCalMulticluster &c3d, const HGCalTriggerGeometryBase &triggerGeometry, float quantile=0.5) const
int showerLength(const l1t::HGCalMulticluster &c3d) const
float varEtaEta(const l1t::HGCalMulticluster &c3d) const
float sigmaEtaEtaTot(const l1t::HGCalMulticluster &c3d) const
float sigmaZZ(const l1t::HGCalMulticluster &c3d) const
void setGeometry(const HGCalTriggerGeometryBase *const)
float eMax(const l1t::HGCalMulticluster &c3d) const
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
T operator()(const T &x, const T &y) const
float sigmaXX(const std::vector< pair< float, float >> &energy_X_tc, const float X_cluster) const
float sigmaPhiPhiMax(const l1t::HGCalMulticluster &c3d) const
T sqrt(T t)
Definition: SSEVec.h:19
void setGeometry(const HGCalTriggerGeometryBase *const geom)
void fillShapes(l1t::HGCalMulticluster &, const HGCalTriggerGeometryBase &) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int coreShowerLength(const l1t::HGCalMulticluster &c3d, const HGCalTriggerGeometryBase &triggerGeometry) const
math::XYZTLorentzVector LorentzVector
bool pass(const T &obj, const Tref &ref) const
float varRR(const l1t::HGCalMulticluster &c3d) const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
int maxLayer(const l1t::HGCalMulticluster &c3d) const
float sigmaRRMax(const l1t::HGCalMulticluster &c3d) const
float sigmaRRTot(const l1t::HGCalMulticluster &c3d) const
float varXX(const std::vector< pair< float, float >> &energy_X_tc, const float X_cluster) const
float sigmaEtaEtaMax(const l1t::HGCalMulticluster &c3d) const
float sigmaPhiPhiTot(const l1t::HGCalMulticluster &c3d) const
float varPhiPhi(const l1t::HGCalMulticluster &c3d) const
float sumLayers(const l1t::HGCalMulticluster &c3d, int start=1, int end=0) const
long double T
int firstLayer(const l1t::HGCalMulticluster &c3d) const
float meanZ(const l1t::HGCalMulticluster &c3d) const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
float sigmaRRMean(const l1t::HGCalMulticluster &c3d, float radius=5.) const
int bitmap(const l1t::HGCalMulticluster &c3d, int start=1, int end=14, float threshold=0) const
float sigmaPhiPhi(const std::vector< pair< float, float >> &energy_phi_tc, const float phi_cluster) const