13 return s.find(pat) != string::npos;
17 return sqrt(a.mass2()+b.mass2()+2.*(a.E()*b.E()-a.Px()*b.Px()-a.Py()*b.Py()-a.Pz()*b.Pz()));
21 return sqrt(pow((a.Px()+b.Px()),2) +pow((a.Py()+b.Py()),2));
24 float dPhi(
float phi1,
float phi2){
25 float delphi = TMath::Abs(TMath::Abs(TMath::Abs(phi1 - phi2) - TMath::Pi())-TMath::Pi());
29 float dR(
float phi1,
float phi2,
float eta1,
float eta2){
30 float dr = sqrt(pow(eta1-eta2,2)+pow(
dPhi(phi1,phi2),2));
36 bool greaterPt(
const reco::Candidate *a,
const reco::Candidate *b) {
37 return a->pt() > b->pt();
40 bool greaterM(
const fastjet::PseudoJet &a,
const fastjet::PseudoJet &b){
44 float getMT(
float pt1,
float phi1,
float pt2,
float phi2){
46 return sqrt(2.*pt1*pt2*(1.-cos(phi2-phi1)));
49 float getMT(
float m1,
float pt1,
float phi1,
50 float m2,
float pt2,
float phi2){
51 return sqrt(m1*m1+m2*m2+2.*(sqrt((m1*m1+pt1*pt1)*(m2*m2+pt2*pt2))-pt1*pt2*cos(phi1-phi2)));
54 float getMT2(
float pt1,
float phi1,
float pt2,
float phi2,
float met,
float met_phi){
55 return getMT2(0., pt1, phi1, 0., pt2, phi2, met, met_phi);
58 float getMT2(
float m1,
float pt1,
float phi1,
59 float m2,
float pt2,
float phi2,
60 float met,
float met_phi){
63 double pxA = pt1*cos(phi1);
64 double pyA = pt1*sin(phi1);
67 double pxB = pt2*cos(phi2);
68 double pyB = pt2*sin(phi2);
70 double pxMiss = met*cos(met_phi);
71 double pyMiss = met*sin(met_phi);
75 double desiredPrecisionOnMt2 = 0;
82 desiredPrecisionOnMt2);
91 FILE *pipe = popen(cmd.c_str(),
"r");
92 if(!pipe)
ERROR(
"Could not open pipe.");
93 const size_t buffer_size = 128;
94 char buffer[buffer_size];
97 if(fgets(buffer, buffer_size, pipe) != NULL) result += buffer;
105 if(denom==0)
return " - ";
106 double neg = 1;
if(num*denom<0) neg = -1;
107 num /= neg*denom; num += 0.5*pow(10.,-decimals);
108 long num_int =
static_cast<long>(num);
109 long num_dec =
static_cast<long>((1+num-num_int)*pow(10.,decimals));
110 TString s_dec =
""; s_dec += num_dec; s_dec.Remove(0,1);
112 if(neg<0) result+=
"-";
115 result+=
"."; result+=s_dec;
118 TString afterdot = result;
119 afterdot.Remove(0,afterdot.First(
".")+1);
120 for(
int i=0; i<decimals-afterdot.Length(); i++)
126 TString result(
""); result += num;
127 int posdot(result.First(
'.'));
128 if(posdot==-1) posdot = result.Length();
129 for(
int ind(posdot-3);
ind > 0;
ind -= 3)
130 result.Insert(
ind,
",");
bool greaterM(const fastjet::PseudoJet &a, const fastjet::PseudoJet &b)
TString addCommas(double num)
static double get_mT2(const double mVis1, const double pxVis1, const double pyVis1, const double mVis2, const double pxVis2, const double pyVis2, const double pxMiss, const double pyMiss, const double mInvis1, const double mInvis2, const double desiredPrecisionOnMT2=0, const bool useDeciSectionsInitially=true)
string execute(const string &cmd)
TString roundNumber(double num, int decimals, double denom)
float getMT(float pt1, float phi1, float pt2, float phi2)
float dR(float eta1, float eta2, float phi1, float phi2)
bool contains(const string &s, const string &pat)
bool greaterPt(const reco::Candidate *a, const reco::Candidate *b)
float sumMass(const LVector &a, const LVector &b)
reco::Candidate::LorentzVector LVector
float dPhi(float phi1, float phi2)
float getMT2(float pt1, float phi1, float pt2, float phi2, float met, float met_phi)
float sumPt(const LVector &a, const LVector &b)
static void disableCopyrightMessage(const bool printIfFirst=false)