CMS 3D CMS Logo

MetAnalyzer.py
Go to the documentation of this file.
1 from __future__ import print_function
2 import copy
3 from PhysicsTools.HeppyCore.framework.analyzer import Analyzer
4 from PhysicsTools.Heppy.analyzers.AutoHandle import AutoHandle
5 import random
6 
7 def pv(vc):
8  print('x = {x:5.4f}, y = {y:5.4f}, z = {z:5.4f}'.format(x=vc.X(),
9  y=vc.Y(),
10  z=vc.Z()))
11 
13  '''Analyze MET in Z+jet events.
14  Need a to provide a module creating event.diLepton
15  earlier in the sequence.
16  '''
17 
18  def declareHandles(self):
19  super(MetAnalyzer, self).declareHandles()
20  self.handles['met'] = AutoHandle(
21  self.cfg_ana.metCol,
22  self.cfg_ana.metType
23  )
24 
25 
26  def beginLoop(self, setup):
27  super(MetAnalyzer,self).beginLoop(setup)
28 
29 
30  def process(self, iEvent, event):
31  self.readCollections( iEvent )
32  event.met = self.handles['met'].product()[0]
33  met = event.met
34  # here, do pure met stuff
35 
36  if not hasattr(event, 'diLepton'):
37  return False
38 
39  diL = event.diLepton
40 
41 
45 
46 
47  # here, do recoil stuff
48 
49  mVect = met.p4().Vect()
50  mVect.SetZ(0.)
51  vVect = diL.p4().Vect()
52  vVect.SetZ(0.)
53  recoilVect = copy.deepcopy(mVect)
54  recoilVect -= vVect
55 
56  uvVect = vVect.Unit()
57  zAxis = type(vVect)(0,0,1)
58  uvVectPerp = vVect.Cross(zAxis).Unit()
59 
60  u1 = - recoilVect.Dot(uvVect)
61  u2 = recoilVect.Dot(uvVectPerp)
62 
63  event.u1 = u1
64  event.u2 = u2
65 
66  if self.cfg_ana.verbose:
67  print('met', met.pt())
68  print('diL', diL)
69  print('vVect')
70  pv(vVect)
71  print('uvVect')
72  pv(uvVect)
73  print('uvVectPerp')
74  pv(uvVectPerp)
75  print(u1, u2)
76 
77  return True
78 
79 
80 
81 
82 
MetAnalyzer.MetAnalyzer
Definition: MetAnalyzer.py:12
MetAnalyzer.MetAnalyzer.beginLoop
def beginLoop(self, setup)
Definition: MetAnalyzer.py:26
remoteMonitoring_LED_IterMethod_cfg.Analyzer
Analyzer
Definition: remoteMonitoring_LED_IterMethod_cfg.py:32
MetAnalyzer.MetAnalyzer.declareHandles
def declareHandles(self)
Definition: MetAnalyzer.py:18
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
edm::print
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
format
MetAnalyzer.MetAnalyzer.process
def process(self, iEvent, event)
Definition: MetAnalyzer.py:30