CMS 3D CMS Logo

LHEAnalyzer.py
Go to the documentation of this file.
1 from builtins import range
2 from PhysicsTools.Heppy.analyzers.core.Analyzer import Analyzer
3 from PhysicsTools.Heppy.analyzers.core.AutoHandle import AutoHandle
4 import PhysicsTools.HeppyCore.framework.config as cfg
5 from math import *
6 from DataFormats.FWLite import Events, Handle
7 
9  """ """
10  def __init__(self, cfg_ana, cfg_comp, looperName ):
11  super(LHEAnalyzer,self).__init__(cfg_ana,cfg_comp,looperName)
12  self.lheh=Handle('LHEEventProduct')
13 
14  def declareHandles(self):
15  super(LHEAnalyzer, self).declareHandles()
16 # self.mchandles['lhestuff'] = AutoHandle( 'externalLHEProducer','LHEEventProduct')
17 
18  def beginLoop(self, setup):
19  super(LHEAnalyzer,self).beginLoop(setup)
20 
21  def process(self, event):
22 
23  # if not MC, nothing to do
24  if not self.cfg_comp.isMC:
25  return True
26  event.lheHT=0
27  event.lheHTIncoming=0 #restrict HT computation to particles that have status<0 mothers
28  event.lheNj=0
29  event.lheNb=0
30  event.lheNc=0
31  event.lheNl=0
32  event.lheNg=0
33  event.lheV_pt = 0
34  try:
35  event.input.getByLabel( 'externalLHEProducer',self.lheh)
36  except :
37  return True
38  if not self.lheh.isValid() :
39  return True
40  self.readCollections( event.input )
41  hepeup=self.lheh.product().hepeup()
42  pup=hepeup.PUP
43  l=None
44  lBar=None
45  nu=None
46  nuBar=None
47  for i in range(0,len(pup)):
48  id=hepeup.IDUP[i]
49  status = hepeup.ISTUP[i]
50  idabs=abs(id)
51 
52  mothIdx = max(hepeup.MOTHUP[i][0]-1,0) #first and last mother as pair; first entry has index 1 in LHE; incoming particles return motherindex 0
53  mothIdxTwo = max(hepeup.MOTHUP[i][1]-1,0)
54 
55  mothStatus = hepeup.ISTUP[mothIdx]
56  mothStatusTwo = hepeup.ISTUP[mothIdxTwo]
57 
58  hasIncomingAsMother = mothStatus<0 or mothStatusTwo<0
59 
60  if status == 1 and ( ( idabs == 21 ) or (idabs > 0 and idabs < 7) ) : # gluons and quarks
61  pt = sqrt( pup[i][0]**2 + pup[i][1]**2 ) # first entry is px, second py
62  event.lheHT += pt
63  if hasIncomingAsMother: event.lheHTIncoming += pt
64  event.lheNj +=1
65  if idabs==5:
66  event.lheNb += 1
67  if idabs==4:
68  event.lheNc += 1
69  if idabs in [1,2,3]:
70  event.lheNl += 1
71  if idabs==21:
72  event.lheNg += 1
73  if idabs in [12,14,16] :
74  if id > 0 :
75  nu = i
76  else :
77  nuBar = i
78  if idabs in [11,13,15] :
79  if id > 0 :
80  l = i
81  else :
82  lBar = i
83  v=None
84  if l and lBar : #Z to LL
85  v=(l,lBar)
86  elif l and nuBar : #W
87  v=(l,nuBar)
88  elif lBar and nu : #W
89  v=(nu,lBar)
90  elif nu and nuBar : #Z to nn
91  v=(nu,nuBar)
92  if v :
93  event.lheV_pt = sqrt( (pup[v[0]][0]+pup[v[1]][0])**2 + (pup[v[0]][1]+pup[v[1]][1])**2 )
94 
95  return True
96 
97 setattr(LHEAnalyzer,"defaultConfig",
98  cfg.Analyzer(LHEAnalyzer,
99  )
100 )
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
gen.LHEAnalyzer.LHEAnalyzer.__init__
def __init__(self, cfg_ana, cfg_comp, looperName)
Definition: LHEAnalyzer.py:10
gen.LHEAnalyzer.LHEAnalyzer.declareHandles
def declareHandles(self)
Definition: LHEAnalyzer.py:14
gen.LHEAnalyzer.LHEAnalyzer.beginLoop
def beginLoop(self, setup)
Definition: LHEAnalyzer.py:18
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
sistrip::SpyUtilities::isValid
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
Definition: SiStripSpyUtilities.cc:124
remoteMonitoring_LED_IterMethod_cfg.Analyzer
Analyzer
Definition: remoteMonitoring_LED_IterMethod_cfg.py:32
gen.LHEAnalyzer.LHEAnalyzer
Definition: LHEAnalyzer.py:8
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
gen.LHEAnalyzer.LHEAnalyzer.lheh
lheh
Definition: LHEAnalyzer.py:12
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
gen.LHEAnalyzer.LHEAnalyzer.process
def process(self, event)
Definition: LHEAnalyzer.py:21