CMS 3D CMS Logo

ProvenanceAnalyzer.py
Go to the documentation of this file.
1 from __future__ import print_function
2 from builtins import range
3 import itertools
4 
5 from PhysicsTools.Heppy.analyzers.core.Analyzer import Analyzer
6 from PhysicsTools.Heppy.analyzers.core.AutoHandle import AutoHandle
7 from PhysicsTools.HeppyCore.framework.event import Event
8 from PhysicsTools.HeppyCore.statistics.counter import Counter, Counters
9 
10 from DataFormats.FWLite import Events, Handle,Lumis
11 
12 class ProvenanceAnalyzer( Analyzer ):
13  #---------------------------------------------
14  # TO FINDS THE INITIAL EVENTS BEFORE THE SKIM
15  #---------------------------------------------
16 
17  def __init__(self, cfg_ana, cfg_comp, looperName):
18  super(ProvenanceAnalyzer, self).__init__(cfg_ana, cfg_comp, looperName)
19  self.lastId = (0,0)
20  self.provenance = []
21 
22  def declareHandles(self):
23  super(ProvenanceAnalyzer, self).declareHandles()
24 
25  def cmsswVNums(self, release):
26  vpieces = release.split("_")[1:]
27  vnums = [ int(v) for v in vpieces[:3] ]
28  if len(vpieces) > 3:
29  if "patch" in vpieces[3]:
30  vnums.append(int(vpieces[3].replace("patch","")))
31  elif "pre" in vpieces[3]:
32  vnums.append(-100+int(vpieces[3].replace("pre","")))
33  else:
34  vnums.append(0)
35  return tuple(vnums)
36  def miniAODVersion(self, vnums):
37  if vnums[:2] == (7,4):
38  if vnums >= (7,4,14,0): return (2015,2.1)
39  if vnums >= (7,4,12,0): return (2015,2.0)
40  if vnums >= (7,4, 8,1): return (2015,1.1)
41  return (2015,1.0)
42  elif vnums[:2] == (7,2):
43  return (2014,2.1)
44  elif vnums[:2] == (7,0):
45  if vnums >= (7,0,9,1): return (2014,2.0)
46  return (2014,1.0)
47  else:
48  return (-999,-999)
49 
50  def process(self, event):
51  eid = ( event.input.eventAuxiliary().id().run(),
52  event.input.eventAuxiliary().id().luminosityBlock() )
53  if eid != self.lastId:
54  #import pdb; pdb.set_trace()
55  history = event.input.object().processHistory()
56  for i in reversed(list(range(history.size()))):
57  conf = history.at(i)
58  release = conf.releaseVersion().replace('"',"")
59  vnums = self.cmsswVNums(release)
60  if conf.processName() in ("PAT", "RECO","REC2"):
61  print("processing step %d: process %s, release %r %s, miniAOD %s" % (i, conf.processName(), release, vnums, self.miniAODVersion(vnums)))
62  self.provenance = [
63  ('release', release),
64  ('releaseVersion', vnums),
65  ('miniAODVersion', self.miniAODVersion(vnums)),
66  ]
67  break
68  self.lastId = eid
69  for key,value in self.provenance:
70  setattr(event, key, value)
71  return True
72 
73 import PhysicsTools.HeppyCore.framework.config as cfg
74 setattr(ProvenanceAnalyzer,"defaultConfig", cfg.Analyzer(
75  class_object = ProvenanceAnalyzer
76 ))
77 
def replace(string, replacements)
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def __init__(self, cfg_ana, cfg_comp, looperName)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run