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 88 of file significanceAlgo.h.

Constructor & Destructor Documentation

metsig::significanceAlgo::significanceAlgo ( )

Definition at line 28 of file significanceAlgo.cc.

References signifmatrix_.

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

Definition at line 67 of file significanceAlgo.cc.

67  {
68 }

Member Function Documentation

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

Definition at line 123 of file significanceAlgo.cc.

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

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

124 {
125  TMatrixD v_tot = signifmatrix_;
126  //--- Loop over physics objects in the event ---//
127  // for(unsigned int objnum=1; objnum < EventVec.size(); objnum++ ) {
128  for(std::vector<SigInputObj>::const_iterator obj = eventVec.begin(); obj!= eventVec.end(); ++obj){
129  double et_tmp = obj->get_energy();
130  double phi_tmp = obj->get_phi();
131  double sigma_et = obj->get_sigma_e();
132  double sigma_tan = obj->get_sigma_tan();
133 
134  double cosphi=cos(phi_tmp);
135  double sinphi=sin(phi_tmp);
136  double xval = et_tmp * cosphi;
137  double yval = et_tmp * sinphi;
138  xmet_ -= xval;
139  ymet_ -= yval;
140  set_worker_ += et_tmp;
141 
142  double sigma0_2=sigma_et*sigma_et;
143  double sigma1_2=sigma_tan*sigma_tan;
144 
145  v_tot(0,0)+= sigma0_2*cosphi*cosphi + sigma1_2*sinphi*sinphi;
146  v_tot(0,1)+= cosphi*sinphi*(sigma0_2 - sigma1_2);
147  v_tot(1,0)+= cosphi*sinphi*(sigma0_2 - sigma1_2);
148  v_tot(1,1)+= sigma1_2*cosphi*cosphi + sigma0_2*sinphi*sinphi;
149 
150  }
151  signifmatrix_=v_tot;
152 }
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 43 of file significanceAlgo.cc.

References LaserDQM_cfg::input.

Referenced by SignCaloSpecificAlgo::calculateBaseCaloMET().

43  {
44  // check that the matrix is size 2:
45  if(input.GetNrows()==2 && input.GetNcols()==2) {
47  }
48  return;
49 }
TMatrixD metsig::significanceAlgo::getSignifMatrix ( ) const
inline
void metsig::significanceAlgo::rotateMatrix ( Double_t  theta,
TMatrixD &  v 
)
private

Definition at line 73 of file significanceAlgo.cc.

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

74 {
75  // I suggest not using this to rotate trivial matrices.
76  TMatrixD r(2,2);
77  TMatrixD rInv(2,2);
78 
79  r(0,0) = cos(theta); r(0,1) = sin(theta); r(1,0) = -sin(theta); r(1,1) = cos(theta);
80  rInv = r;
81  rInv.Invert();
82  //-- Rotate v --//
83  v = rInv * v * r;
84 }
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
mathSSE::Vec4< T > v
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 54 of file significanceAlgo.cc.

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

54  {
55  // check that the matrix is size 2:
56  if(input.GetNrows()==2 && input.GetNcols()==2) {
58  set_worker_=met_set;
59  xmet_=met_r*cos(met_phi);
60  ymet_=met_r*sin(met_phi);
61  }
62  return;
63 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
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 156 of file significanceAlgo.cc.

References mathSSE::sqrt().

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

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

Definition at line 89 of file significanceAlgo.cc.

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

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

TMatrixD metsig::significanceAlgo::signifmatrix_
private

Definition at line 104 of file significanceAlgo.h.

Referenced by getSignifMatrix(), and significanceAlgo().

double metsig::significanceAlgo::xmet_
private

Definition at line 107 of file significanceAlgo.h.

double metsig::significanceAlgo::ymet_
private

Definition at line 108 of file significanceAlgo.h.