CMS 3D CMS Logo

Functions
customiseTrackingNtuple Namespace Reference

Functions

def _label (tag)
 
def customiseTrackingNtuple (process)
 
def customiseTrackingNtupleHLT (process)
 
def customiseTrackingNtupleMergeIters (process)
 
def customiseTrackingNtupleTool (process, isRECO=True, mergeIters=False)
 
def extendedContent (process)
 

Function Documentation

◆ _label()

def customiseTrackingNtuple._label (   tag)
private

Definition at line 3 of file customiseTrackingNtuple.py.

Referenced by customiseTrackingNtupleTool().

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 

◆ customiseTrackingNtuple()

def customiseTrackingNtuple.customiseTrackingNtuple (   process)

Definition at line 99 of file customiseTrackingNtuple.py.

References customiseTrackingNtupleTool().

99 def customiseTrackingNtuple(process):
100  customiseTrackingNtupleTool(process, isRECO = True)
101  return process
102 
def customiseTrackingNtupleTool(process, isRECO=True, mergeIters=False)

◆ customiseTrackingNtupleHLT()

def customiseTrackingNtuple.customiseTrackingNtupleHLT (   process)

Definition at line 107 of file customiseTrackingNtuple.py.

References clone(), and customiseTrackingNtupleTool().

107 def customiseTrackingNtupleHLT(process):
108  import Validation.RecoTrack.TrackValidation_cff as _TrackValidation_cff
109  _seedProducers = [
110  "hltIter0PFLowPixelSeedsFromPixelTracks",
111  "hltIter1PFLowPixelSeedsFromPixelTracks",
112  "hltIter2PFlowPixelSeeds",
113  "hltDoubletRecoveryPFlowPixelSeeds"
114  ]
115  _candidatesProducers = [
116  "hltIter0PFlowCkfTrackCandidates",
117  "hltIter1PFlowCkfTrackCandidates",
118  "hltIter2PFlowCkfTrackCandidates",
119  "hltDoubletRecoveryPFlowCkfTrackCandidates"
120  ]
121  (_seedSelectors, _tmpTask) = _TrackValidation_cff._addSeedToTrackProducers(_seedProducers, globals())
122  _seedSelectorsTask = cms.Task()
123  for modName in _seedSelectors:
124  if not hasattr(process, modName):
125  setattr(process,modName, globals()[modName].clone(beamSpot = "hltOnlineBeamSpot"))
126  _seedSelectorsTask.add(getattr(process, modName))
127 
128  customiseTrackingNtupleTool(process, isRECO = False)
129 
130  process.trackingNtupleSequence.insert(0,cms.Sequence(_seedSelectorsTask))
131  if process.hltSiStripRawToClustersFacility.onDemand.value():
132  #make sure that all iter tracking is done before running the ntuple-related modules
133  process.trackingNtupleSequence.insert(0,process.hltMergedTracks)
134 
135  process.trackingNtuple.tracks = "hltMergedTracks"
136  process.trackingNtuple.seedTracks = _seedSelectors
137  process.trackingNtuple.trackCandidates = _candidatesProducers
138  process.trackingNtuple.clusterTPMap = "hltTPClusterProducer"
139  process.trackingNtuple.trackAssociator = "hltTrackAssociatorByHits"
140  process.trackingNtuple.beamSpot = "hltOnlineBeamSpot"
141  process.trackingNtuple.pixelRecHits = "hltSiPixelRecHits"
142  process.trackingNtuple.stripRphiRecHits = "hltSiStripRecHits:rphiRecHit"
143  process.trackingNtuple.stripStereoRecHits = "hltSiStripRecHits:stereoRecHit"
144  process.trackingNtuple.stripMatchedRecHits = "hltSiStripRecHits:matchedRecHit"
145  process.trackingNtuple.vertices = "hltPixelVertices"
146  process.trackingNtuple.TTRHBuilder = "hltESPTTRHBWithTrackAngle"
147  process.trackingNtuple.parametersDefiner = "hltLhcParametersDefinerForTP"
148  process.trackingNtuple.includeMVA = False
149 
150  return process
151 
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
def customiseTrackingNtupleTool(process, isRECO=True, mergeIters=False)

◆ customiseTrackingNtupleMergeIters()

def customiseTrackingNtuple.customiseTrackingNtupleMergeIters (   process)

Definition at line 103 of file customiseTrackingNtuple.py.

References customiseTrackingNtupleTool().

104  customiseTrackingNtupleTool(process, isRECO = True, mergeIters = True)
105  return process
106 
def customiseTrackingNtupleMergeIters(process)
def customiseTrackingNtupleTool(process, isRECO=True, mergeIters=False)

◆ customiseTrackingNtupleTool()

def customiseTrackingNtuple.customiseTrackingNtupleTool (   process,
  isRECO = True,
  mergeIters = False 
)

Definition at line 10 of file customiseTrackingNtuple.py.

References _label(), python.rootplot.root2matplotlib.replace(), and contentValuesCheck.values.

Referenced by customiseTrackingNtuple(), customiseTrackingNtupleHLT(), and customiseTrackingNtupleMergeIters().

10 def customiseTrackingNtupleTool(process, isRECO = True, mergeIters = False):
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 isRECO:
18  if not hasattr(process, "reconstruction_step"):
19  raise Exception("TrackingNtuple includeSeeds=True needs reconstruction which is missing")
20  else: #assumes HLT with PF iter
21  if not hasattr(process, "HLTIterativeTrackingIter02"):
22  raise Exception("TrackingNtuple includeSeeds=True needs HLTIterativeTrackingIter02 which is missing")
23 
24  # Replace validation_step with ntuplePath
25  if not hasattr(process, "validation_step"):
26  raise Exception("TrackingNtuple customise assumes process.validation_step exists")
27 
28 
29  # Should replay mixing for pileup simhits?
30  usePileupSimHits = hasattr(process, "mix") and hasattr(process.mix, "input") and len(process.mix.input.fileNames) > 0
31 # process.eda = cms.EDAnalyzer("EventContentAnalyzer")
32 
33  if not isRECO:
34  if not hasattr(process,"hltMultiTrackValidation"):
35  process.load("Validation.RecoTrack.HLTmultiTrackValidator_cff")
36  process.trackingNtupleSequence = process.hltMultiTrackValidation.copy()
38  process.hltSiStripRecHits = SiStripRecHitConverter_cfi.siStripMatchedRecHits.clone(
39  ClusterProducer = "hltSiStripRawToClustersFacility",
40  StripCPE = "hltESPStripCPEfromTrackAngle:hltESPStripCPEfromTrackAngle"
41  )
42  process.trackingNtupleSequence.insert(0,process.trackingParticlesIntime+process.simHitTPAssocProducer)
43  process.trackingNtupleSequence.remove(process.hltTrackValidator)
44  process.trackingNtupleSequence += process.hltSiStripRecHits + process.trackingNtuple
45 
46  #combine all *StepTracks (TODO: write one for HLT)
47  if mergeIters and isRECO:
49  process.mergedStepTracks = _mod.TrackCollectionMerger.clone(
50  trackProducers = cms.VInputTag(m.replace("Seeds", "Tracks").replace("seedTracks", "") for m in process.trackingNtuple.seedTracks),
51  inputClassifiers = cms.vstring(m.replace("StepSeeds", "Step").replace("seedTracks", "").replace("dSeeds", "dTracks")
52  .replace("InOut", "InOutClassifier").replace("tIn", "tInClassifier")
53  for m in process.trackingNtuple.seedTracks),
54  minQuality = "any",
55  enableMerging = False
56  )
57  process.trackingNtupleSequence.insert(0,process.mergedStepTracks)
58  process.trackingNtuple.tracks = "mergedStepTracks"
59  process.trackingNtuple.includeMVA = True
60  process.trackingNtuple.trackMVAs = ["mergedStepTracks"]
61 
62  ntuplePath = cms.Path(process.trackingNtupleSequence)
63 
64  if process.trackingNtuple.includeAllHits and process.trackingNtuple.includeTrackingParticles and usePileupSimHits:
65  ntuplePath.insert(0, cms.SequencePlaceholder("mix"))
66 
67  process.load("Validation.RecoTrack.crossingFramePSimHitToPSimHits_cfi")
68  instanceLabels = [_label(tag) for tag in process.simHitTPAssocProducer.simHitSrc]
69  process.crossingFramePSimHitToPSimHits.src = ["mix:"+l for l in instanceLabels]
70  process.simHitTPAssocProducer.simHitSrc = ["crossingFramePSimHitToPSimHits:"+l for l in instanceLabels]
71  process.trackingNtupleSequence.insert(0, process.crossingFramePSimHitToPSimHits)
72 
73  # Bit of a hack but works
74  modifier = cms.Modifier()
75  modifier._setChosen()
76  modifier.toReplaceWith(process.prevalidation_step, ntuplePath)
77  modifier.toReplaceWith(process.validation_step, cms.EndPath())
78 
79  # remove the validation_stepN and prevalidatin_stepN of phase2 validation...
80  for p in [process.paths_(), process.endpaths_()]:
81  for pathName, path in p.items():
82  if "prevalidation_step" in pathName:
83  if len(pathName.replace("prevalidation_step", "")) > 0:
84  modifier.toReplaceWith(path, cms.Path())
85  elif "validation_step" in pathName:
86  if len(pathName.replace("validation_step", "")) > 0:
87  modifier.toReplaceWith(path, cms.EndPath())
88 
89  # Remove all output modules
90  for outputModule in process.outputModules_().values():
91  for path in process.paths_().values():
92  path.remove(outputModule)
93  for path in process.endpaths_().values():
94  path.remove(outputModule)
95 
96 
97  return process
98 
def replace(string, replacements)
def customiseTrackingNtupleTool(process, isRECO=True, mergeIters=False)

◆ extendedContent()

def customiseTrackingNtuple.extendedContent (   process)

Definition at line 152 of file customiseTrackingNtuple.py.

152 def extendedContent(process):
153  process.trackingParticlesIntime.intimeOnly = False
154  process.trackingNtuple.includeOOT = True
155  process.trackingNtuple.keepEleSimHits = True
156 
157  process.trackingNtuple.saveSimHitsP3 = True
158  process.trackingNtuple.addSeedCurvCov = True
159 
160  process.trackingNtuple.includeOnTrackHitData = True
161  process.trackingNtuple.includeTrackCandidates = True
162 
163  return process
164