CMS 3D CMS Logo

List of all members | Public Member Functions
gen.LHEWeightAnalyzer.LHEWeightAnalyzer Class Reference
Inheritance diagram for gen.LHEWeightAnalyzer.LHEWeightAnalyzer:

Public Member Functions

def __init__ (self, cfg_ana, cfg_comp, looperName)
 
def beginLoop (self, setup)
 
def declareHandles (self)
 
def process (self, event)
 

Detailed Description

Read the WeightsInfo objects of the LHE branch and store them
   in event.LHE_weights list.

   If the WeightsInfo.id is a string, replace it with an integer.

   So far the only allowed string format is "mg_reweight_X",
   which gets stored as str(10000+int(X))

   If w.id is an unknown string or anything but a string or int,
   a RuntimeError is raised.

Definition at line 7 of file LHEWeightAnalyzer.py.

Constructor & Destructor Documentation

def gen.LHEWeightAnalyzer.LHEWeightAnalyzer.__init__ (   self,
  cfg_ana,
  cfg_comp,
  looperName 
)

Definition at line 19 of file LHEWeightAnalyzer.py.

19  def __init__(self, cfg_ana, cfg_comp, looperName ):
20  super(LHEWeightAnalyzer,self).__init__(cfg_ana,cfg_comp,looperName)
21 
def __init__(self, cfg_ana, cfg_comp, looperName)

Member Function Documentation

def gen.LHEWeightAnalyzer.LHEWeightAnalyzer.beginLoop (   self,
  setup 
)

Definition at line 30 of file LHEWeightAnalyzer.py.

30  def beginLoop(self, setup):
31  super(LHEWeightAnalyzer,self).beginLoop(setup)
32 
def gen.LHEWeightAnalyzer.LHEWeightAnalyzer.declareHandles (   self)

Definition at line 22 of file LHEWeightAnalyzer.py.

References core.Analyzer.Analyzer.mchandles.

22  def declareHandles(self):
23  super(LHEWeightAnalyzer, self).declareHandles()
24  self.mchandles['LHEweights'] = AutoHandle('externalLHEProducer',
25  'LHEEventProduct',
26  mayFail=True,
27  fallbackLabel='source',
28  lazy=False )
29 
def gen.LHEWeightAnalyzer.LHEWeightAnalyzer.process (   self,
  event 
)

Definition at line 33 of file LHEWeightAnalyzer.py.

References createfilelist.int, core.Analyzer.Analyzer.mchandles, core.Analyzer.Analyzer.readCollections(), harvestTrackValidationPlots.str, and create_public_lumi_plots.weights.

Referenced by ConfigBuilder.ConfigBuilder.addExtraStream(), ConfigBuilder.ConfigBuilder.completeInputCommand(), ConfigBuilder.ConfigBuilder.doNotInlineEventContent(), ConfigBuilder.ConfigBuilder.PrintAllModules.leave(), ConfigBuilder.ConfigBuilder.prepare(), ConfigBuilder.ConfigBuilder.prepare_ALCA(), ConfigBuilder.ConfigBuilder.prepare_DQM(), ConfigBuilder.ConfigBuilder.prepare_HLT(), ConfigBuilder.ConfigBuilder.prepare_LHE(), ConfigBuilder.ConfigBuilder.prepare_PATFILTER(), ConfigBuilder.ConfigBuilder.prepare_VALIDATION(), ConfigBuilder.ConfigBuilder.renameHLTprocessInSequence(), ConfigBuilder.ConfigBuilder.renameInputTagsInSequence(), and ConfigBuilder.ConfigBuilder.scheduleSequence().

33  def process(self, event):
34  self.readCollections( event.input )
35 
36  # if not MC, nothing to do
37  if not self.cfg_comp.isMC:
38  return True
39 
40  # Add LHE weight info
41  event.LHE_weights = []
42  event.LHE_originalWeight = 1.0
43  if self.mchandles['LHEweights'].isValid():
44  event.LHE_originalWeight = self.mchandles['LHEweights'].product().originalXWGTUP()
45 
46  for w in self.mchandles['LHEweights'].product().weights():
47  # Check if id is string or int and convert to int if it's a string
48  try:
49  int(w.id)
50  event.LHE_weights.append(w)
51  except ValueError:
52  if not type(w.id) == str:
53  raise RuntimeError('Non int or string type for LHE weight id')
54 
55  newweight = WeightsInfo()
56  newweight.wgt = w.wgt
57  if w.id.startswith('mg_reweight'):
58  newid = str(10000 + int(w.id.rsplit('_',1)[1]))
59  newweight.id = newid
60 
61  else: raise RuntimeError('Unknown string id in LHE weights')
62  event.LHE_weights.append(newweight)
63 
64  return True
65 
66 setattr(LHEWeightAnalyzer,"defaultConfig",