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  if hasattr(tag, "getModuleLabel"):
5  t = tag
6  else:
7  t = cms.InputTag(tag)
8  return t.getModuleLabel()+t.getProductInstanceLabel()
9 
def customiseTrackingNtuple.customiseTrackingNtuple (   process)

Definition at line 10 of file customiseTrackingNtuple.py.

References _label().

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