ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/HbbAnalysis/src/Objects.cc
Revision: 1.3
Committed: Fri Mar 26 15:26:10 2010 UTC (15 years, 1 month ago) by amagnan
Content type: text/plain
Branch: MAIN
CVS Tags: HbbAnaFor35X, v00-04-02, v00-04-01, v00-04-00
Changes since 1.2: +10 -0 lines
Log Message:
bug fix and analysis updates

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 amagnan 1.3 double DeltaR(const BaseVars & v1, const GenVars & v2)
25     {
26    
27     double dEta = v1.eta - v2.eta;
28     double dPhi = v1.phi - v2.phi;
29     if (dPhi<0) dPhi += 2*TMath::Pi();
30    
31     return sqrt(dEta*dEta+dPhi*dPhi);
32     }
33    
34 amagnan 1.1 double SameSign(const BaseVars & v1, const BaseVars & v2)
35     {
36    
37     return v1.charge == v2.charge;
38     }
39    
40     double OppSign(const BaseVars & v1, const BaseVars & v2)
41     {
42    
43     return (v1.charge != v2.charge &&
44     v1.charge != 0 &&
45     v2.charge != 0);
46     }
47    
48     TLorentzVector FourMomentum(const BaseVars & v, const double scale)
49     {
50     double lpx = v.pT*cos(v.phi);
51     double lpy = v.pT*sin(v.phi);
52     //double lp = v.pT/sin(2*atan(exp(-v.eta)));
53     //double lpz = sqrt(lp*lp - v.pT*v.pT);
54     double lpz = v.pT*sinh(v.eta);
55     double lE = v.pT*cosh(v.eta);//v.E
56    
57     return TLorentzVector(lpx/scale,lpy/scale,lpz/scale,lE/scale);
58    
59     }
60    
61     double TransverseMass(const BaseVars & leg1,
62     const BaseVars & leg2,
63     const double mEx,
64     const double mEy)
65     {
66     double px = leg1.pT*cos(leg1.phi) + leg2.pT*cos(leg2.phi) + mEx;
67     double py = leg1.pT*sin(leg1.phi) + leg2.pT*sin(leg2.phi) + mEy;
68     double et = leg1.pT + leg2.pT + TMath::Sqrt(mEx*mEx + mEy*mEy);
69     double mt2 = et*et - (px*px + py*py);
70     if ( mt2 < 0 ) {
71     std::cout << " --- WARNING : mt2 = " << mt2 << " is negative... Set to 0.";
72     return 0.;
73     }
74     return sqrt(mt2);
75     }
76    
77     double TransverseMass(const BaseVars & leg1,
78     const double mEx,
79     const double mEy)
80     {
81     double px = leg1.pT*cos(leg1.phi) + mEx;
82     double py = leg1.pT*sin(leg1.phi) + mEy;
83     double et = leg1.pT + TMath::Sqrt(mEx*mEx + mEy*mEy);
84     double mt = et*et - (px*px + py*py);
85     if ( mt < 0 ) {
86     std::cout << " --- WARNING : mt = " << mt << " is negative... Set to 0.";
87     return 0.;
88     }
89     return sqrt(mt);
90     }
91    
92     TLorentzVector FourMomentumCDFmethod(const BaseVars & leg1,
93     const BaseVars & leg2,
94     double mEx,
95     double mEy)
96     {
97     double lpx = leg1.pT*cos(leg1.phi) + leg2.pT*cos(leg2.phi) + mEx;
98     double lpy = leg1.pT*sin(leg1.phi) + leg2.pT*sin(leg2.phi) + mEy;
99     double lpz = leg1.pT*sinh(leg1.eta) + leg2.pT*sinh(leg2.eta);
100     double le = leg1.pT*cosh(leg1.eta) + leg2.pT*cosh(leg2.eta) + TMath::Sqrt(mEx*mEx + mEy*mEy);
101     return TLorentzVector(lpx, lpy, lpz, le);
102     }
103    
104     TLorentzVector FourMomentumCollinearApprox(const BaseVars & leg1,
105     const BaseVars & leg2,
106     double mEx,
107     double mEy)
108     {
109     double px1 = leg1.pT*cos(leg1.phi);
110     double px2 = leg2.pT*cos(leg2.phi);
111     double py1 = leg1.pT*sin(leg1.phi);
112     double py2 = leg2.pT*sin(leg2.phi);
113    
114     double x1_numerator = px1*py2 - px2*py1;
115     double x1_denominator = py2*(px1 + mEx) - px2*(py1 + mEy);
116     double x1 = ( x1_denominator != 0. ) ? x1_numerator/x1_denominator : -1.;
117    
118     double x2_numerator = x1_numerator;
119     double x2_denominator = px1*(py2 + mEy) - py1*(px2 + mEx);
120     double x2 = ( x2_denominator != 0. ) ? x2_numerator/x2_denominator : -1.;
121    
122     if ( (x1 > 0. && x1 < 1.) &&
123     (x2 > 0. && x2 < 1.) ) {
124     TLorentzVector p4 = FourMomentum(leg1,1/x1) + FourMomentum(leg2,1/x2);
125     return p4;
126     } else {
127     return TLorentzVector(0,0,0,0);
128     }
129     }
130    
131     }//namespace
132