CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ClusterShapes.cc
Go to the documentation of this file.
2 #include <cmath>
3 
4 using namespace l1t;
5 
7  ClusterShapes cs(*this); // copy constructor
8  cs += x;
9  return cs;
10 }
11 
13  sum_e_ += x.sum_e_;
14  sum_e2_ += x.sum_e2_;
15  sum_logE_ += x.sum_logE_;
16  n_ += x.n_;
17 
18  sum_w_ += x.sum_w_;
19 
20  emax_ = (emax_ > x.emax_) ? emax_ : x.emax_;
21 
22  // mid-point
23  sum_eta_ += x.sum_eta_;
24  sum_phi_0_ += x.sum_phi_0_; //
25  sum_phi_1_ += x.sum_phi_1_; //
26  sum_r_ += x.sum_r_;
27 
28  // square
29  sum_eta2_ += x.sum_eta2_;
32  sum_r2_ += x.sum_r2_;
33 
34  // off diagonal
40 }
41 
42 // -------------- CLUSTER SHAPES ---------------
43 void ClusterShapes::Init(float e, float eta, float phi, float r) {
44  if (e <= 0)
45  return;
46  sum_e_ = e;
47  sum_e2_ = e * e;
48  sum_logE_ = std::log(e);
49 
50  float w = e;
51 
52  n_ = 1;
53 
54  sum_w_ = w;
55 
56  sum_phi_0_ = w * (phi);
57  sum_phi_1_ = w * (phi + M_PI);
58  sum_r_ = w * r;
59  sum_eta_ = w * eta;
60 
61  //--
62  sum_r2_ += w * (r * r);
63  sum_eta2_ += w * (eta * eta);
64  sum_phi2_0_ += w * (phi * phi);
65  sum_phi2_1_ += w * (phi + M_PI) * (phi + M_PI);
66 
67  // -- off diagonal
68  sum_eta_r_ += w * (r * eta);
69  sum_r_phi_0_ += w * (r * phi);
70  sum_r_phi_1_ += w * r * (phi + M_PI);
71  sum_eta_phi_0_ += w * (eta * phi);
72  sum_eta_phi_1_ += w * eta * (phi + M_PI);
73 }
74 // ------
75 float ClusterShapes::Eta() const { return sum_eta_ / sum_w_; }
76 float ClusterShapes::R() const { return sum_r_ / sum_w_; }
77 
78 float ClusterShapes::SigmaEtaEta() const { return sum_eta2_ / sum_w_ - Eta() * Eta(); }
79 
80 float ClusterShapes::SigmaRR() const { return sum_r2_ / sum_w_ - R() * R(); }
81 
83  float phi_0 = (sum_phi_0_ / sum_w_);
84  float phi_1 = (sum_phi_1_ / sum_w_);
85  float spp_0 = sum_phi2_0_ / sum_w_ - phi_0 * phi_0;
86  float spp_1 = sum_phi2_1_ / sum_w_ - phi_1 * phi_1;
87 
88  if (spp_0 < spp_1) {
89  isPhi0_ = true;
90  return spp_0;
91  } else {
92  isPhi0_ = false;
93  return spp_1;
94  }
95 }
96 
97 float ClusterShapes::Phi() const {
98  SigmaPhiPhi(); //update phi
99  if (isPhi0_)
100  return (sum_phi_0_ / sum_w_);
101  else
102  return (sum_phi_1_ / sum_w_);
103 }
104 
105 // off - diagonal
106 float ClusterShapes::SigmaEtaR() const { return -(sum_eta_r_ / sum_w_ - Eta() * R()); }
107 
109  SigmaPhiPhi(); // decide which phi use, update phi
110 
111  if (isPhi0_)
112  return -(sum_eta_phi_0_ / sum_w_ - Eta() * (sum_phi_0_ / sum_w_));
113  else
114  return -(sum_eta_phi_1_ / sum_w_ - Eta() * (sum_phi_1_ / sum_w_));
115 }
116 
118  SigmaPhiPhi(); // decide which phi use, update phi
119  if (isPhi0_)
120  return -(sum_r_phi_0_ / sum_w_ - R() * (sum_phi_0_ / sum_w_));
121  else
122  return -(sum_r_phi_1_ / sum_w_ - R() * (sum_phi_1_ / sum_w_));
123 }
static std::vector< std::string > checklist log
unique_ptr< ClusterSequence > cs
float SigmaPhiPhi() const
float SigmaEtaR() const
void Init(float e, float eta, float phi, float r=0.)
float SigmaRR() const
float Eta() const
float SigmaRPhi() const
ClusterShapes operator+(const ClusterShapes &)
Definition: ClusterShapes.cc:6
float SigmaEtaEta() const
#define M_PI
float SigmaEtaPhi() const
float R() const
T w() const
void operator+=(const ClusterShapes &)
float Phi() const