ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/HbbAnalysis/src/Objects.cc
Revision: 1.1
Committed: Fri Oct 2 11:06:56 2009 UTC (15 years, 7 months ago) by amagnan
Content type: text/plain
Branch: MAIN
Log Message:
missing src file

File Contents

# User Rev Content
1 amagnan 1.1 #include "UserCode/HbbAnalysis/interface/Objects.hh"
2    
3     namespace HbbAnalysis {
4    
5     double DeltaPhi(const double phi1, const double phi2)
6     {
7    
8     double dPhi = phi1 - phi2;
9     if (dPhi<0) dPhi += 2*TMath::Pi();
10    
11     return dPhi;
12     }
13    
14     double DeltaR(const BaseVars & v1, const BaseVars & v2)
15     {
16    
17     double dEta = v1.eta - v2.eta;
18     double dPhi = v1.phi - v2.phi;
19     if (dPhi<0) dPhi += 2*TMath::Pi();
20    
21     return sqrt(dEta*dEta+dPhi*dPhi);
22     }
23    
24     double SameSign(const BaseVars & v1, const BaseVars & v2)
25     {
26    
27     return v1.charge == v2.charge;
28     }
29    
30     double OppSign(const BaseVars & v1, const BaseVars & v2)
31     {
32    
33     return (v1.charge != v2.charge &&
34     v1.charge != 0 &&
35     v2.charge != 0);
36     }
37    
38     TLorentzVector FourMomentum(const BaseVars & v, const double scale)
39     {
40     double lpx = v.pT*cos(v.phi);
41     double lpy = v.pT*sin(v.phi);
42     //double lp = v.pT/sin(2*atan(exp(-v.eta)));
43     //double lpz = sqrt(lp*lp - v.pT*v.pT);
44     double lpz = v.pT*sinh(v.eta);
45     double lE = v.pT*cosh(v.eta);//v.E
46    
47     return TLorentzVector(lpx/scale,lpy/scale,lpz/scale,lE/scale);
48    
49     }
50    
51     double TransverseMass(const BaseVars & leg1,
52     const BaseVars & leg2,
53     const double mEx,
54     const double mEy)
55     {
56     double px = leg1.pT*cos(leg1.phi) + leg2.pT*cos(leg2.phi) + mEx;
57     double py = leg1.pT*sin(leg1.phi) + leg2.pT*sin(leg2.phi) + mEy;
58     double et = leg1.pT + leg2.pT + TMath::Sqrt(mEx*mEx + mEy*mEy);
59     double mt2 = et*et - (px*px + py*py);
60     if ( mt2 < 0 ) {
61     std::cout << " --- WARNING : mt2 = " << mt2 << " is negative... Set to 0.";
62     return 0.;
63     }
64     return sqrt(mt2);
65     }
66    
67     double TransverseMass(const BaseVars & leg1,
68     const double mEx,
69     const double mEy)
70     {
71     double px = leg1.pT*cos(leg1.phi) + mEx;
72     double py = leg1.pT*sin(leg1.phi) + mEy;
73     double et = leg1.pT + TMath::Sqrt(mEx*mEx + mEy*mEy);
74     double mt = et*et - (px*px + py*py);
75     if ( mt < 0 ) {
76     std::cout << " --- WARNING : mt = " << mt << " is negative... Set to 0.";
77     return 0.;
78     }
79     return sqrt(mt);
80     }
81    
82     TLorentzVector FourMomentumCDFmethod(const BaseVars & leg1,
83     const BaseVars & leg2,
84     double mEx,
85     double mEy)
86     {
87     double lpx = leg1.pT*cos(leg1.phi) + leg2.pT*cos(leg2.phi) + mEx;
88     double lpy = leg1.pT*sin(leg1.phi) + leg2.pT*sin(leg2.phi) + mEy;
89     double lpz = leg1.pT*sinh(leg1.eta) + leg2.pT*sinh(leg2.eta);
90     double le = leg1.pT*cosh(leg1.eta) + leg2.pT*cosh(leg2.eta) + TMath::Sqrt(mEx*mEx + mEy*mEy);
91     return TLorentzVector(lpx, lpy, lpz, le);
92     }
93    
94     TLorentzVector FourMomentumCollinearApprox(const BaseVars & leg1,
95     const BaseVars & leg2,
96     double mEx,
97     double mEy)
98     {
99     double px1 = leg1.pT*cos(leg1.phi);
100     double px2 = leg2.pT*cos(leg2.phi);
101     double py1 = leg1.pT*sin(leg1.phi);
102     double py2 = leg2.pT*sin(leg2.phi);
103    
104    
105     double x1_numerator = px1*py2 - px2*py1;
106     double x1_denominator = py2*(px1 + mEx) - px2*(py1 + mEy);
107     double x1 = ( x1_denominator != 0. ) ? x1_numerator/x1_denominator : -1.;
108    
109     double x2_numerator = x1_numerator;
110     double x2_denominator = px1*(py2 + mEy) - py1*(px2 + mEx);
111     double x2 = ( x2_denominator != 0. ) ? x2_numerator/x2_denominator : -1.;
112    
113     if ( (x1 > 0. && x1 < 1.) &&
114     (x2 > 0. && x2 < 1.) ) {
115     TLorentzVector p4 = FourMomentum(leg1,1/x1) + FourMomentum(leg2,1/x2);
116     return p4;
117     } else {
118     return TLorentzVector(0,0,0,0);
119     }
120     }
121    
122     }//namespace
123