CMS 3D CMS Logo

customiseTrackingNtuple.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 import six
3 
4 def _label(tag):
5  if hasattr(tag, "getModuleLabel"):
6  t = tag
7  else:
8  t = cms.InputTag(tag)
9  return t.getModuleLabel()+t.getProductInstanceLabel()
10 
12  process.load("Validation.RecoTrack.trackingNtuple_cff")
13  process.TFileService = cms.Service("TFileService",
14  fileName = cms.string('trackingNtuple.root')
15  )
16 
17  if process.trackingNtuple.includeSeeds.value():
18  if not hasattr(process, "reconstruction_step"):
19  raise Exception("TrackingNtuple includeSeeds=True needs reconstruction which is missing")
20 
21  # Replace validation_step with ntuplePath
22  if not hasattr(process, "validation_step"):
23  raise Exception("TrackingNtuple customise assumes process.validation_step exists")
24 
25 
26  # Should replay mixing for pileup simhits?
27  usePileupSimHits = hasattr(process, "mix") and hasattr(process.mix, "input") and len(process.mix.input.fileNames) > 0
28 # process.eda = cms.EDAnalyzer("EventContentAnalyzer")
29 
30  ntuplePath = cms.Path(process.trackingNtupleSequence)
31  if process.trackingNtuple.includeAllHits and process.trackingNtuple.includeTrackingParticles and usePileupSimHits:
32  ntuplePath.insert(0, cms.SequencePlaceholder("mix"))
33 
34  process.load("Validation.RecoTrack.crossingFramePSimHitToPSimHits_cfi")
35  instanceLabels = [_label(tag) for tag in process.simHitTPAssocProducer.simHitSrc]
36  process.crossingFramePSimHitToPSimHits.src = ["mix:"+l for l in instanceLabels]
37  process.simHitTPAssocProducer.simHitSrc = ["crossingFramePSimHitToPSimHits:"+l for l in instanceLabels]
38  process.trackingNtupleSequence.insert(0, process.crossingFramePSimHitToPSimHits)
39 
40  # Bit of a hack but works
41  modifier = cms.Modifier()
42  modifier._setChosen()
43  modifier.toReplaceWith(process.prevalidation_step, ntuplePath)
44  modifier.toReplaceWith(process.validation_step, cms.EndPath())
45 
46  # remove the validation_stepN and prevalidatin_stepN of phase2 validation...
47  for p in [process.paths_(), process.endpaths_()]:
48  for pathName, path in six.iteritems(p):
49  if "prevalidation_step" in pathName:
50  if len(pathName.replace("prevalidation_step", "")) > 0:
51  modifier.toReplaceWith(path, cms.Path())
52  elif "validation_step" in pathName:
53  if len(pathName.replace("validation_step", "")) > 0:
54  modifier.toReplaceWith(path, cms.EndPath())
55 
56  # Remove all output modules
57  for outputModule in six.itervalues(process.outputModules_()):
58  for path in six.itervalues(process.paths_()):
59  path.remove(outputModule)
60  for path in six.itervalues(process.endpaths_()):
61  path.remove(outputModule)
62 
63 
64  return process
Exception
customiseTrackingNtuple.customiseTrackingNtuple
def customiseTrackingNtuple(process)
Definition: customiseTrackingNtuple.py:11
customiseTrackingNtuple._label
def _label(tag)
Definition: customiseTrackingNtuple.py:4