ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/lucieg/macros/aux.py
Revision: 1.2
Committed: Mon Jul 11 19:21:18 2011 UTC (13 years, 9 months ago) by lucieg
Content type: text/x-python
Branch: MAIN
Changes since 1.1: +6 -4 lines
Log Message:
resync

File Contents

# User Rev Content
1 lucieg 1.1 import FWCore.ParameterSet.Config as cms
2     from math import pi, sqrt
3    
4     def deltaPhi(phi0, phi1):
5     res = phi0 - phi1
6     while (res > pi):
7     res -= 2*pi
8     while (res <= - pi ):
9     res += 2*pi
10     return res
11    
12     def deltaR(phi0, eta0, phi1, eta1):
13     dPhi = deltaPhi(phi0, phi1)
14     dEta = eta0 - eta1
15     dR = sqrt(dPhi*dPhi + dEta*dEta)
16     return dR
17    
18     def deltaRmin(obj0, coll):
19     dRmin = 9999.
20     index = -1 # will remain = -1 if coll is empty
21     dPt = -1
22 lucieg 1.2 diffCharge = -10
23 lucieg 1.1 it = 0
24     for obj1 in coll :
25     dR = deltaR(obj0.phi(), obj0.eta(), obj1.phi(), obj1.eta())
26     if dR < dRmin :
27     dRmin = dR
28     index = it
29     dPt = abs(obj0.pt() - obj1.pt()) / obj0.pt()
30 lucieg 1.2 diffCharge = obj0.charge() - obj1.charge()
31 lucieg 1.1 it += 1
32    
33     if (dRmin == 9999.) :
34     dRmin = -1.
35    
36 lucieg 1.2 return dRmin, dPt, diffCharge, index
37 lucieg 1.1
38    
39 lucieg 1.2 def matched(dRmin, dPt, diffCharge, dRmatched, dPtMatched):
40    
41     return ((dRmin < dRmatched) and (dPt < dPtMatched) and (diffCharge == 0))