CMS 3D CMS Logo

Functions
customiseTrackingNtuple Namespace Reference

Functions

def _label (tag)
 
def customiseTrackingNtuple (process)
 

Function Documentation

def customiseTrackingNtuple._label (   tag)
private

Definition at line 3 of file customiseTrackingNtuple.py.

Referenced by customiseTrackingNtuple().

3 def _label(tag):
4  t = cms.InputTag(tag)
5  return t.getModuleLabel()+t.getProductInstanceLabel()
6 
def customiseTrackingNtuple.customiseTrackingNtuple (   process)

Definition at line 7 of file customiseTrackingNtuple.py.

References _label().

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