CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
metsig::significanceAlgo Class Reference

#include <significanceAlgo.h>

Public Member Functions

const void addObjects (const std::vector< metsig::SigInputObj > &EventVec)
 
const void addSignifMatrix (const TMatrixD &input)
 
TMatrixD getSignifMatrix () const
 
const void setSignifMatrix (const TMatrixD &input, const double &met_r, const double &met_phi, const double &met_set)
 reset the signficance matrix (this is the most likely case), so that the vector sum can be continued More...
 
const double significance (double &met_r, double &met_phi, double &met_set)
 
 significanceAlgo ()
 
const void subtractObjects (const std::vector< metsig::SigInputObj > &EventVec)
 
 ~significanceAlgo ()
 

Private Member Functions

void rotateMatrix (Double_t theta, TMatrixD &v)
 

Private Attributes

double set_worker_
 
TMatrixD signifmatrix_
 
double xmet_
 
double ymet_
 

Detailed Description

Definition at line 85 of file significanceAlgo.h.

Constructor & Destructor Documentation

metsig::significanceAlgo::significanceAlgo ( )

Definition at line 27 of file significanceAlgo.cc.

References signifmatrix_.

27  :
28  // eventVec_(0),
29  signifmatrix_(2,2),
30  set_worker_(0),
31  xmet_(0),
32  ymet_(0)
33 
34 {
35  // std::cout << "in constructor ! " << std::endl;
37 }
metsig::significanceAlgo::~significanceAlgo ( )

Definition at line 66 of file significanceAlgo.cc.

66  {
67 }

Member Function Documentation

const void metsig::significanceAlgo::addObjects ( const std::vector< metsig::SigInputObj > &  EventVec)

Definition at line 122 of file significanceAlgo.cc.

References funct::cos(), getGTfromDQMFile::obj, and funct::sin().

Referenced by SignCaloSpecificAlgo::calculateBaseCaloMET(), and pat::PATMHTProducer::produce().

123 {
124  TMatrixD v_tot = signifmatrix_;
125  //--- Loop over physics objects in the event ---//
126  // for(unsigned int objnum=1; objnum < EventVec.size(); objnum++ ) {
127  for(std::vector<SigInputObj>::const_iterator obj = eventVec.begin(); obj!= eventVec.end(); ++obj){
128  double et_tmp = obj->get_energy();
129  double phi_tmp = obj->get_phi();
130  double sigma_et = obj->get_sigma_e();
131  double sigma_tan = obj->get_sigma_tan();
132 
133  double cosphi=cos(phi_tmp);
134  double sinphi=sin(phi_tmp);
135  double xval = et_tmp * cosphi;
136  double yval = et_tmp * sinphi;
137  xmet_ -= xval;
138  ymet_ -= yval;
139  set_worker_ += et_tmp;
140 
141  double sigma0_2=sigma_et*sigma_et;
142  double sigma1_2=sigma_tan*sigma_tan;
143 
144  v_tot(0,0)+= sigma0_2*cosphi*cosphi + sigma1_2*sinphi*sinphi;
145  v_tot(0,1)+= cosphi*sinphi*(sigma0_2 - sigma1_2);
146  v_tot(1,0)+= cosphi*sinphi*(sigma0_2 - sigma1_2);
147  v_tot(1,1)+= sigma1_2*cosphi*cosphi + sigma0_2*sinphi*sinphi;
148 
149  }
150  signifmatrix_=v_tot;
151 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const void metsig::significanceAlgo::addSignifMatrix ( const TMatrixD &  input)

Definition at line 42 of file significanceAlgo.cc.

References input.

Referenced by SignCaloSpecificAlgo::calculateBaseCaloMET().

42  {
43  // check that the matrix is size 2:
44  if(input.GetNrows()==2 && input.GetNcols()==2) {
46  }
47  return;
48 }
static std::string const input
Definition: EdmProvDump.cc:44
TMatrixD metsig::significanceAlgo::getSignifMatrix ( ) const
inline
void metsig::significanceAlgo::rotateMatrix ( Double_t  theta,
TMatrixD &  v 
)
private

Definition at line 72 of file significanceAlgo.cc.

References funct::cos(), alignCSCRings::r, and funct::sin().

73 {
74  // I suggest not using this to rotate trivial matrices.
75  TMatrixD r(2,2);
76  TMatrixD rInv(2,2);
77 
78  r(0,0) = cos(theta); r(0,1) = sin(theta); r(1,0) = -sin(theta); r(1,1) = cos(theta);
79  rInv = r;
80  rInv.Invert();
81  //-- Rotate v --//
82  v = rInv * v * r;
83 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const void metsig::significanceAlgo::setSignifMatrix ( const TMatrixD &  input,
const double &  met_r,
const double &  met_phi,
const double &  met_set 
)

reset the signficance matrix (this is the most likely case), so that the vector sum can be continued

Definition at line 53 of file significanceAlgo.cc.

References funct::cos(), input, and funct::sin().

53  {
54  // check that the matrix is size 2:
55  if(input.GetNrows()==2 && input.GetNcols()==2) {
57  set_worker_=met_set;
58  xmet_=met_r*cos(met_phi);
59  ymet_=met_r*sin(met_phi);
60  }
61  return;
62 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
static std::string const input
Definition: EdmProvDump.cc:44
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const double metsig::significanceAlgo::significance ( double &  met_r,
double &  met_phi,
double &  met_set 
)

Definition at line 155 of file significanceAlgo.cc.

References mathSSE::sqrt().

Referenced by SignCaloSpecificAlgo::calculateBaseCaloMET(), and pat::PATMHTProducer::produce().

156 {
157 
158  if(signifmatrix_(0,0)==0 && signifmatrix_(1,1)==0 && signifmatrix_(1,0)==0 && signifmatrix_(0,1)==0){
159  //edm::LogWarning("SignCaloSpecificAlgo") << "Event Vector is empty! Return significance -1";
160  return(-1);
161  }
162 
163  //--- Temporary variables ---//
164 
165  TMatrixD v_tot(2,2);
166  TVectorD metvec(2);
167 
168  //--- Initialize sum of rotated covariance matrices ---//
169  v_tot=signifmatrix_;
170  // std::cout << "INPUT:\n"<< v_tot(0,0) << "," << v_tot(0,1) << "\n" << v_tot(1,0) << "," << v_tot(1,1) << std::endl;
171 
172 
173 
174  //--- Calculate magnitude and angle of MET, store in returned variables ---//
175  met_r = sqrt(xmet_*xmet_ + ymet_*ymet_);
176  met_set = set_worker_;
177  met_phi= TMath::ATan2(ymet_, xmet_);
178 
179  // one other option: if particles cancel there could be small numbers.
180  // this check fixes this, added by F.Blekman
181  if(fabs(v_tot.Determinant())<0.000001)
182  return -1;
183 
184 
185  // save matrix into object:
186  // std::cout << "SAVED:\n"<< v_tot(0,0) << "," << v_tot(0,1) << "\n" << v_tot(1,0) << "," << v_tot(1,1) << std::endl;
187  v_tot.Invert();
188  // std::cout << "INVERTED:\n"<< v_tot(0,0) << "," << v_tot(0,1) << "\n" << v_tot(1,0) << "," << v_tot(1,1) << std::endl;
189 
190 
191 
192  metvec(0) = xmet_; metvec(1) = ymet_;
193  double lnSignificance = metvec * (v_tot * metvec);
194 
195  // v_tot.Invert();
196  // std::cout << "INVERTED AGAIN:\n"<< v_tot(0,0) << "," << v_tot(0,1) << "\n" << v_tot(1,0) << "," << v_tot(1,1) << std::endl;
197  return lnSignificance;
198 }
T sqrt(T t)
Definition: SSEVec.h:48
const void metsig::significanceAlgo::subtractObjects ( const std::vector< metsig::SigInputObj > &  EventVec)

Definition at line 88 of file significanceAlgo.cc.

References funct::cos(), getGTfromDQMFile::obj, and funct::sin().

89 {
90  TMatrixD v_tot = signifmatrix_;
91  //--- Loop over physics objects in the event ---//
92  // for(unsigned int objnum=1; objnum < EventVec.size(); objnum++ ) {
93  for(std::vector<SigInputObj>::const_iterator obj = eventVec.begin(); obj!= eventVec.end(); ++obj){
94  double et_tmp = obj->get_energy();
95  double phi_tmp = obj->get_phi();
96  double sigma_et = obj->get_sigma_e();
97  double sigma_tan = obj->get_sigma_tan();
98 
99  double cosphi=cos(phi_tmp);
100  double sinphi=sin(phi_tmp);
101  double xval = et_tmp * cosphi;
102  double yval = et_tmp * sinphi;
103  xmet_ += xval;
104  ymet_ += yval;
105  set_worker_ -= et_tmp;
106 
107  double sigma0_2=sigma_et*sigma_et;
108  double sigma1_2=sigma_tan*sigma_tan;
109 
110  v_tot(0,0)-= sigma0_2*cosphi*cosphi + sigma1_2*sinphi*sinphi;
111  v_tot(0,1)-= cosphi*sinphi*(sigma0_2 - sigma1_2);
112  v_tot(1,0)-= cosphi*sinphi*(sigma0_2 - sigma1_2);
113  v_tot(1,1)-= sigma1_2*cosphi*cosphi + sigma0_2*sinphi*sinphi;
114 
115  }
116  signifmatrix_=v_tot;
117 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Cos< T >::type cos(const T &t)
Definition: Cos.h:22

Member Data Documentation

double metsig::significanceAlgo::set_worker_
private

Definition at line 103 of file significanceAlgo.h.

TMatrixD metsig::significanceAlgo::signifmatrix_
private

Definition at line 101 of file significanceAlgo.h.

Referenced by getSignifMatrix(), and significanceAlgo().

double metsig::significanceAlgo::xmet_
private

Definition at line 104 of file significanceAlgo.h.

double metsig::significanceAlgo::ymet_
private

Definition at line 105 of file significanceAlgo.h.