ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/HbbAnalysis/src/Objects.cc
(Generate patch)

Comparing UserCode/HbbAnalysis/src/Objects.cc (file contents):
Revision 1.4 by amagnan, Mon May 10 18:45:10 2010 UTC vs.
Revision 1.7 by amagnan, Thu Sep 15 09:46:20 2011 UTC

# Line 1 | Line 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();
4  
5 +  double DeltaR(const TLorentzVector & v1, const TLorentzVector & v2){
6 +    double dEta = v1.Eta() - v2.Eta();
7 +    double dPhi = fabs(v1.Phi() - v2.Phi());
8 +    if (dPhi > TMath::Pi()) dPhi = (2.0*TMath::Pi() - dPhi);
9      return sqrt(dEta*dEta+dPhi*dPhi);
10    }
11  
12 <  double DeltaR(const BaseVars & v1, const GenVars & v2)
12 >  double DeltaPhi(const double phi1, const double phi2)
13    {
14 +    double dPhi = fabs(phi1 - phi2);
15 +    if (dPhi > TMath::Pi()) dPhi = (2.0*TMath::Pi() - dPhi);
16 +    //double dPhi = phi1 - phi2;
17      
18 <    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);
18 >    return dPhi;
19    }
20  
21    double SameSign(const BaseVars & v1, const BaseVars & v2)
# Line 58 | Line 45 | namespace HbbAnalysis {
45  
46    }
47  
48 <  double TransverseMass(const BaseVars & leg1,
49 <                        const BaseVars & leg2,
48 >  double TransverseMass(//const BaseVars & leg1,
49 >                        //const BaseVars & leg2,
50 >                        const TLorentzVector & leg1,
51 >                        const TLorentzVector & leg2,
52                          const double mEx,
53                          const double mEy)
54    {
55 <    double px = leg1.pT*cos(leg1.phi) + leg2.pT*cos(leg2.phi) + mEx;
56 <    double py = leg1.pT*sin(leg1.phi) + leg2.pT*sin(leg2.phi) + mEy;
57 <    double et = leg1.pT + leg2.pT + TMath::Sqrt(mEx*mEx + mEy*mEy);
55 >    double px = leg1.Pt()*cos(leg1.Phi()) + leg2.Pt()*cos(leg2.Phi()) + mEx;
56 >    double py = leg1.Pt()*sin(leg1.Phi()) + leg2.Pt()*sin(leg2.Phi()) + mEy;
57 >    double et = leg1.Pt() + leg2.Pt() + TMath::Sqrt(mEx*mEx + mEy*mEy);
58      double mt2 = et*et - (px*px + py*py);
59      if ( mt2 < 0 ) {
60 <      std::cout << " --- WARNING : mt2 = " << mt2 << " is negative... Set to 0.";
60 >      //std::cout << " --- WARNING : mt2 = " << mt2 << " is negative... Set to 0.";
61        return 0.;
62      }
63      return sqrt(mt2);
64    }
65  
66 <  double TransverseMass(const BaseVars & leg1,
66 >  double TransverseMass(//const BaseVars & leg1,
67 >                        const TLorentzVector & 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);
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.";
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,
82 >  TLorentzVector FourMomentumCDFmethod(//const BaseVars & leg1,
83 >                                       //const BaseVars & leg2,
84 >                                       const TLorentzVector & leg1,
85 >                                       const TLorentzVector & leg2,
86                                         double mEx,
87                                         double mEy)
88    {
89 <    double lpx = leg1.pT*cos(leg1.phi) + leg2.pT*cos(leg2.phi) + mEx;
90 <    double lpy = leg1.pT*sin(leg1.phi) + leg2.pT*sin(leg2.phi) + mEy;
91 <    double lpz = leg1.pT*sinh(leg1.eta) + leg2.pT*sinh(leg2.eta);
92 <    double le =  leg1.pT*cosh(leg1.eta) + leg2.pT*cosh(leg2.eta) + TMath::Sqrt(mEx*mEx + mEy*mEy);
89 >    double lpx = leg1.Pt()*cos(leg1.Phi()) + leg2.Pt()*cos(leg2.Phi()) + mEx;
90 >    double lpy = leg1.Pt()*sin(leg1.Phi()) + leg2.Pt()*sin(leg2.Phi()) + mEy;
91 >    double lpz = leg1.Pt()*sinh(leg1.Eta()) + leg2.Pt()*sinh(leg2.Eta());
92 >    double le =  leg1.Pt()*cosh(leg1.Eta()) + leg2.Pt()*cosh(leg2.Eta()) + TMath::Sqrt(mEx*mEx + mEy*mEy);
93      return TLorentzVector(lpx, lpy, lpz, le);
94    }
95  
96 <  TLorentzVector FourMomentumCollinearApprox(const BaseVars & leg1,
97 <                                             const BaseVars & leg2,
96 >  TLorentzVector FourMomentumCollinearApprox(//const BaseVars & leg1,
97 >                                             //const BaseVars & leg2,
98 >                                             const TLorentzVector & leg1,
99 >                                             const TLorentzVector & leg2,
100                                               double mEx,
101                                               double mEy)
102    {
103 <    double px1 = leg1.pT*cos(leg1.phi);
104 <    double px2 = leg2.pT*cos(leg2.phi);
105 <    double py1 = leg1.pT*sin(leg1.phi);
106 <    double py2 = leg2.pT*sin(leg2.phi);
103 >    double px1 = leg1.Pt()*cos(leg1.Phi());
104 >    double px2 = leg2.Pt()*cos(leg2.Phi());
105 >    double py1 = leg1.Pt()*sin(leg1.Phi());
106 >    double py2 = leg2.Pt()*sin(leg2.Phi());
107  
108      double x1_numerator = px1*py2 - px2*py1;
109      double x1_denominator = py2*(px1 + mEx) - px2*(py1 + mEy);
# Line 121 | Line 115 | namespace HbbAnalysis {
115  
116      if ( (x1 > 0. && x1 < 1.) &&
117           (x2 > 0. && x2 < 1.) ) {
118 <      TLorentzVector p4 = FourMomentum(leg1,1/x1) + FourMomentum(leg2,1/x2);
118 >      TLorentzVector p4 = leg1*x1 + leg2*x2;
119        return p4;
120      } else {
121        return TLorentzVector(0,0,0,0);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines