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.2 by amagnan, Tue Oct 13 12:14:05 2009 UTC vs.
Revision 1.8 by agilbert, Tue Oct 25 13:26:52 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();
4  
5 <    return dPhi;
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 BaseVars & 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;
18 <    double dPhi = v1.phi - v2.phi;
19 <    if (dPhi<0) dPhi += 2*TMath::Pi();
20 <
21 <    return sqrt(dEta*dEta+dPhi*dPhi);
18 >    return dPhi;
19    }
20 <
21 <  double SameSign(const BaseVars & v1, const BaseVars & v2)
20 >  
21 >  bool SameSign(double charge1, double charge2)
22    {
23 <    
24 <    return v1.charge == v2.charge;
23 >    double product = charge1 * charge2;
24 >    return ((product > 0.5) && (product < 1.5));
25    }
26  
27 <  double OppSign(const BaseVars & v1, const BaseVars & v2)
27 >  bool OppSign(double charge1, double charge2)
28    {
29 <    
30 <    return (v1.charge != v2.charge &&
34 <            v1.charge != 0 &&
35 <            v2.charge != 0);
29 >    double product = charge1 * charge2;
30 >    return ((product < -0.5) && (product > -1.5));
31    }
32 +  /*Fix - base vars no longer exists
33  
34    TLorentzVector FourMomentum(const BaseVars & v, const double scale)
35    {
# Line 46 | Line 42 | namespace HbbAnalysis {
42  
43      return TLorentzVector(lpx/scale,lpy/scale,lpz/scale,lE/scale);
44  
45 <  }
45 >  }*/
46  
47 <  double TransverseMass(const BaseVars & leg1,
48 <                        const BaseVars & leg2,
47 >  double TransverseMass(//const BaseVars & leg1,
48 >                        //const BaseVars & leg2,
49 >                        const TLorentzVector & leg1,
50 >                        const TLorentzVector & leg2,
51                          const double mEx,
52                          const double mEy)
53    {
54 <    double px = leg1.pT*cos(leg1.phi) + leg2.pT*cos(leg2.phi) + mEx;
55 <    double py = leg1.pT*sin(leg1.phi) + leg2.pT*sin(leg2.phi) + mEy;
56 <    double et = leg1.pT + leg2.pT + TMath::Sqrt(mEx*mEx + mEy*mEy);
54 >    double px = leg1.Pt()*cos(leg1.Phi()) + leg2.Pt()*cos(leg2.Phi()) + mEx;
55 >    double py = leg1.Pt()*sin(leg1.Phi()) + leg2.Pt()*sin(leg2.Phi()) + mEy;
56 >    double et = leg1.Pt() + leg2.Pt() + TMath::Sqrt(mEx*mEx + mEy*mEy);
57      double mt2 = et*et - (px*px + py*py);
58      if ( mt2 < 0 ) {
59 <      std::cout << " --- WARNING : mt2 = " << mt2 << " is negative... Set to 0.";
59 >      //std::cout << " --- WARNING : mt2 = " << mt2 << " is negative... Set to 0.";
60        return 0.;
61      }
62      return sqrt(mt2);
63    }
64  
65 <  double TransverseMass(const BaseVars & leg1,
65 >  double TransverseMass(//const BaseVars & leg1,
66 >                        const TLorentzVector & leg1,
67                          const double mEx,
68                          const double mEy)
69    {
70 <    double px = leg1.pT*cos(leg1.phi) + mEx;
71 <    double py = leg1.pT*sin(leg1.phi) + mEy;
72 <    double et = leg1.pT + TMath::Sqrt(mEx*mEx + mEy*mEy);
70 >    double px = leg1.Pt()*cos(leg1.Phi()) + mEx;
71 >    double py = leg1.Pt()*sin(leg1.Phi()) + mEy;
72 >    double et = leg1.Pt() + TMath::Sqrt(mEx*mEx + mEy*mEy);
73      double mt = et*et - (px*px + py*py);
74      if ( mt < 0 ) {
75 <      std::cout << " --- WARNING : mt = " << mt << " is negative... Set to 0.";
75 >      //std::cout << " --- WARNING : mt = " << mt << " is negative... Set to 0.";
76        return 0.;
77      }
78      return sqrt(mt);
79    }
80  
81 <  TLorentzVector FourMomentumCDFmethod(const BaseVars & leg1,
82 <                                       const BaseVars & leg2,
81 >  TLorentzVector FourMomentumCDFmethod(//const BaseVars & leg1,
82 >                                       //const BaseVars & leg2,
83 >                                       const TLorentzVector & leg1,
84 >                                       const TLorentzVector & leg2,
85                                         double mEx,
86                                         double mEy)
87    {
88 <    double lpx = leg1.pT*cos(leg1.phi) + leg2.pT*cos(leg2.phi) + mEx;
89 <    double lpy = leg1.pT*sin(leg1.phi) + leg2.pT*sin(leg2.phi) + mEy;
90 <    double lpz = leg1.pT*sinh(leg1.eta) + leg2.pT*sinh(leg2.eta);
91 <    double le =  leg1.pT*cosh(leg1.eta) + leg2.pT*cosh(leg2.eta) + TMath::Sqrt(mEx*mEx + mEy*mEy);
88 >    double lpx = leg1.Pt()*cos(leg1.Phi()) + leg2.Pt()*cos(leg2.Phi()) + mEx;
89 >    double lpy = leg1.Pt()*sin(leg1.Phi()) + leg2.Pt()*sin(leg2.Phi()) + mEy;
90 >    double lpz = leg1.Pt()*sinh(leg1.Eta()) + leg2.Pt()*sinh(leg2.Eta());
91 >    double le =  leg1.Pt()*cosh(leg1.Eta()) + leg2.Pt()*cosh(leg2.Eta()) + TMath::Sqrt(mEx*mEx + mEy*mEy);
92      return TLorentzVector(lpx, lpy, lpz, le);
93    }
94  
95 <  TLorentzVector FourMomentumCollinearApprox(const BaseVars & leg1,
96 <                                             const BaseVars & leg2,
95 >  TLorentzVector FourMomentumCollinearApprox(//const BaseVars & leg1,
96 >                                             //const BaseVars & leg2,
97 >                                             const TLorentzVector & leg1,
98 >                                             const TLorentzVector & leg2,
99                                               double mEx,
100                                               double mEy)
101    {
102 <    double px1 = leg1.pT*cos(leg1.phi);
103 <    double px2 = leg2.pT*cos(leg2.phi);
104 <    double py1 = leg1.pT*sin(leg1.phi);
105 <    double py2 = leg2.pT*sin(leg2.phi);
102 >    double px1 = leg1.Pt()*cos(leg1.Phi());
103 >    double px2 = leg2.Pt()*cos(leg2.Phi());
104 >    double py1 = leg1.Pt()*sin(leg1.Phi());
105 >    double py2 = leg2.Pt()*sin(leg2.Phi());
106  
107      double x1_numerator = px1*py2 - px2*py1;
108      double x1_denominator = py2*(px1 + mEx) - px2*(py1 + mEy);
# Line 111 | Line 114 | namespace HbbAnalysis {
114  
115      if ( (x1 > 0. && x1 < 1.) &&
116           (x2 > 0. && x2 < 1.) ) {
117 <      TLorentzVector p4 = FourMomentum(leg1,1/x1) + FourMomentum(leg2,1/x2);
117 >      TLorentzVector p4 = leg1*x1 + leg2*x2;
118        return p4;
119      } else {
120        return TLorentzVector(0,0,0,0);
121      }
122    }
123  
124 +  /*
125 +  double EtaDetector(const BaseVars & v1){
126 +    double pDet[3];
127 +    pDet[0] = v1.pT*cos(v1.phi) + v1.vx;
128 +    pDet[1] = v1.pT*sin(v1.phi) + v1.vy;
129 +
130 +    double theta = 2*atan(exp(-v1.eta));
131 +    if (pDet[1]<0) theta = TMath::Pi()+theta;
132 +
133 +    if (tan(theta)!=0) pDet[2] = v1.pT/tan(theta) + v1.vz;
134 +    else return -10;
135 +
136 +    double pTDet = sqrt(pDet[0]*pDet[0] + pDet[1]*pDet[1]);
137 +    double pDetNorm = sqrt(pDet[0]*pDet[0] + pDet[1]*pDet[1] + pDet[2]*pDet[2]);
138 +    double thetaDet = 0;
139 +    double cosThetaDet = 0;
140 +    if (pDetNorm!=0) cosThetaDet = pDet[2]/pDetNorm;
141 +    else return -10;
142 +    if (pDet[2]!=0) thetaDet = atan(pTDet/pDet[2]);
143 +    else return -10;
144 +    if (cosThetaDet<0) thetaDet += TMath::Pi();
145 +    
146 +    return -log(tan(thetaDet/2.));
147 +  }
148 +
149 +  double EtaDetector(const GenVars & v1){
150 +    double pDet[3];
151 +    pDet[0] = v1.pT*cos(v1.phi) + v1.vx;
152 +    pDet[1] = v1.pT*sin(v1.phi) + v1.vy;
153 +
154 +    double theta = 2*atan(exp(-v1.eta));
155 +    if (pDet[1]<0) theta = TMath::Pi()+theta;
156 +
157 +    if (tan(theta)!=0) pDet[2] = v1.pT/tan(theta) + v1.vz;
158 +    else return -10;
159 +
160 +    double pTDet = sqrt(pDet[0]*pDet[0] + pDet[1]*pDet[1]);
161 +    double pDetNorm = sqrt(pDet[0]*pDet[0] + pDet[1]*pDet[1] + pDet[2]*pDet[2]);
162 +    double thetaDet = 0;
163 +    double cosThetaDet = 0;
164 +    if (pDetNorm!=0) cosThetaDet = pDet[2]/pDetNorm;
165 +    else return -10;
166 +    if (pDet[2]!=0) thetaDet = atan(pTDet/pDet[2]);
167 +    else return -10;
168 +    if (cosThetaDet<0) thetaDet += TMath::Pi();
169 +    
170 +    return -log(tan(thetaDet/2.));
171 +  }*/
172 +
173 +
174 +
175   }//namespace
176  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines