CMS 3D CMS Logo

ClusterShapes.cc
Go to the documentation of this file.
2 #include <cmath>
3 
4 using namespace l1t;
5 
7 {
8  ClusterShapes cs(*this); // copy constructor
9  cs += x;
10  return cs;
11 }
12 
13 
15 
16  sum_e_ += x.sum_e_;
17  sum_e2_ += x.sum_e2_;
18  sum_logE_ += x.sum_logE_;
19  n_ += x.n_;
20 
21  sum_w_ += x.sum_w_;
22 
23  emax_ = (emax_> x.emax_) ? emax_: x.emax_;
24 
25  // mid-point
26  sum_eta_ += x.sum_eta_;
27  sum_phi_0_ += x.sum_phi_0_; //
28  sum_phi_1_ += x.sum_phi_1_; //
29  sum_r_ += x.sum_r_;
30 
31  // square
32  sum_eta2_ += x.sum_eta2_;
35  sum_r2_ += x.sum_r2_;
36 
37  // off diagonal
38  sum_eta_r_ += x.sum_eta_r_ ;
43 
44 }
45 
46 
47 // -------------- CLUSTER SHAPES ---------------
48 void ClusterShapes::Init(float e ,float eta, float phi, float r){
49  if (e<=0 ) return;
50  sum_e_ = e;
51  sum_e2_ = e*e;
52  sum_logE_ = std::log(e);
53 
54  float w = e;
55 
56  n_=1;
57 
58  sum_w_ = w;
59 
60  sum_phi_0_ = w *( phi );
61  sum_phi_1_ = w* (phi + M_PI);
62  sum_r_ = w * r;
63  sum_eta_ = w * eta;
64 
65  //--
66  sum_r2_ += w * (r*r);
67  sum_eta2_ += w * (eta*eta);
68  sum_phi2_0_ += w * (phi*phi);
69  sum_phi2_1_ += w * (phi+M_PI)*(phi+M_PI);
70 
71  // -- off diagonal
72  sum_eta_r_ += w * (r*eta);
73  sum_r_phi_0_ += w* (r *phi);
74  sum_r_phi_1_ += w* r *(phi + M_PI);
75  sum_eta_phi_0_ += w* (eta *phi);
76  sum_eta_phi_1_ += w* eta * (phi+M_PI);
77 
78 }
79 // ------
80 float ClusterShapes::Eta()const { return sum_eta_/sum_w_;}
81 float ClusterShapes::R() const { return sum_r_/sum_w_;}
82 
83 float ClusterShapes::SigmaEtaEta()const {return sum_eta2_/sum_w_ - Eta()*Eta();}
84 
85 float ClusterShapes::SigmaRR()const { return sum_r2_/sum_w_ - R() *R();}
86 
87 
89  float phi_0 = (sum_phi_0_ / sum_w_);
90  float phi_1 = (sum_phi_1_ / sum_w_);
91  float spp_0 = sum_phi2_0_ / sum_w_ - phi_0*phi_0;
92  float spp_1 = sum_phi2_1_ / sum_w_ - phi_1*phi_1;
93 
94  if (spp_0 < spp_1 )
95  {
96  isPhi0_=true;
97  return spp_0;
98  }
99  else
100  {
101  isPhi0_=false;
102  return spp_1;
103  }
104 }
105 
106 float ClusterShapes::Phi()const {
107  SigmaPhiPhi(); //update phi
108  if (isPhi0_) return (sum_phi_0_ / sum_w_);
109  else return (sum_phi_1_ / sum_w_);
110 }
111 
112 
113 // off - diagonal
114 float ClusterShapes::SigmaEtaR() const { return -(sum_eta_r_ / sum_w_ - Eta() *R()) ;}
115 
117  SigmaPhiPhi() ; // decide which phi use, update phi
118 
119  if (isPhi0_)
120  return -(sum_eta_phi_0_ /sum_w_ - Eta()*(sum_phi_0_ / sum_w_));
121  else
122  return -(sum_eta_phi_1_ / sum_w_ - Eta()*(sum_phi_1_ / sum_w_));
123 }
124 
126  SigmaPhiPhi() ; // decide which phi use, update phi
127  if (isPhi0_)
128  return -(sum_r_phi_0_ / sum_w_ - R() *(sum_phi_0_ / sum_w_));
129  else
130  return -(sum_r_phi_1_ / sum_w_ - R() * (sum_phi_1_ / sum_w_));
131 }
132 
auto_ptr< ClusterSequence > cs
const double w
Definition: UKUtility.cc:23
float SigmaPhiPhi() const
float SigmaEtaR() const
delete x;
Definition: CaloConfig.h:22
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
void operator+=(const ClusterShapes &)
float Phi() const