ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/lucieg/macros/aux.py
Revision: 1.1
Committed: Thu Jul 7 11:53:03 2011 UTC (13 years, 9 months ago) by lucieg
Content type: text/x-python
Branch: MAIN
Log Message:
added directory to store macros. bad habit with rm -rf :)

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     it = 0
23     for obj1 in coll :
24     dR = deltaR(obj0.phi(), obj0.eta(), obj1.phi(), obj1.eta())
25     if dR < dRmin :
26     dRmin = dR
27     index = it
28     dPt = abs(obj0.pt() - obj1.pt()) / obj0.pt()
29     it += 1
30    
31     if (dRmin == 9999.) :
32     dRmin = -1.
33    
34     return dRmin, dPt, index
35    
36    
37     def matched(dRmin, dPt, dRmatched, dPtMatched):
38    
39     return (dRmin < dRmatched) and (dPt < dPtMatched)