CMS 3D CMS Logo

Functions
extraJets_MuEGFixMoriond2017 Namespace Reference

Functions

def backupJetsFirstStep (process)
 
def backupJetsSecondStep (process, sequences, badMuons, verbose=False)
 
def makeRecoJetCollection (process, pfCandCollection, coneSize, useCHSAlgo, postfix)
 
def reduceFinalJetCollection (process, jetCollection, badMuons)
 
def reduceInputJetCollection (process, jetCollection, badMuons)
 

Function Documentation

◆ backupJetsFirstStep()

def extraJets_MuEGFixMoriond2017.backupJetsFirstStep (   process)

Definition at line 71 of file extraJets_MuEGFixMoriond2017.py.

71 def backupJetsFirstStep(process):
72 
73  task = getPatAlgosToolsTask(process)
74 
75  """Take snapshots of the sequences before we change the PFCandidates"""
76  process.originalAK4JetTask, process.originalAK4JetSequence = listDependencyChain(process, getattr(process,"slimmedJets"), ('particleFlow', 'muons'))
77  backupAK4JetSequence = cloneProcessingSnippet(process, getattr(process,"originalAK4JetSequence"), "Backup", addToTask = True )
78  process.originalAK4PuppiJetTask, process.originalAK4PuppiJetSequence = listDependencyChain(process,getattr(process,"slimmedJetsPuppi"), ('particleFlow', 'muons'))
79  backupAK4PuppiJetSequence = cloneProcessingSnippet(process, getattr(process,"originalAK4PuppiJetSequence"), "Backup", addToTask = True )
80  process.originalAK8JetTask,process.originalAK8JetSequence = listDependencyChain(process, getattr(process,"slimmedJetsAK8"), ('particleFlow', 'muons'))
81  backupAK8JetSequence = cloneProcessingSnippet(process, getattr(process,"originalAK8JetSequence"), "Backup", addToTask = True )
82 
83  task.add(process.originalAK4JetTask)
84  task.add(process.originalAK4PuppiJetTask)
85  task.add(process.originalAK8JetTask)
86 
87  return { 'AK4':backupAK4JetSequence, 'AK4Puppi':backupAK4PuppiJetSequence, 'AK8':backupAK8JetSequence }
88 
89 

References helpers.cloneProcessingSnippet(), helpers.getPatAlgosToolsTask(), and helpers.listDependencyChain().

Referenced by customizeMiniAOD_MuEGFixMoriond2017.customizeAll().

◆ backupJetsSecondStep()

def extraJets_MuEGFixMoriond2017.backupJetsSecondStep (   process,
  sequences,
  badMuons,
  verbose = False 
)
Deploy the snapshots after the change of PFCandidates

Definition at line 90 of file extraJets_MuEGFixMoriond2017.py.

90 def backupJetsSecondStep(process, sequences, badMuons, verbose=False):
91  """Deploy the snapshots after the change of PFCandidates"""
92 
93  task = getPatAlgosToolsTask(process)
94 
95  # put back the old input tags and copy in task
96  for sequence in six.itervalues(sequences):
97  massSearchReplaceAnyInputTag(sequence, "pfCandidatesBadMuonsCleaned", "particleFlow")
98  massSearchReplaceAnyInputTag(sequence, "muonsCleaned", "muons")
99  for mod in listModules(sequence):
100  task.add(mod)
101  # gate the input collections to avoid re-running most of PAT on good events
102  reduceInputJetCollection(process, process.ak4PFJetsCHSBackup, badMuons)
103  reduceInputJetCollection(process, process.ak4PFJetsPuppiBackup, badMuons)
104  # fix names in the valuemaps
105  process.patJetsBackup.userData.userInts.labelPostfixesToStrip = cms.vstring("Backup",)
106  process.patJetsBackup.userData.userFloats.labelPostfixesToStrip = cms.vstring("Backup",)
107  process.patJetsAK8Backup.userData.userFloats.labelPostfixesToStrip = cms.vstring("Backup",)
108  process.patJetsAK8PuppiBackup.userData.userFloats.labelPostfixesToStrip = cms.vstring("Backup",)
109  #
110  # now deal with daughter links
111  # for these we can keep the daughters
112  if hasattr(process,"slimmedJetsBackup"):
113  process.slimmedJetsBackup.mixedDaughters = True
114  process.slimmedJetsBackup.packedPFCandidates = cms.InputTag("oldPFCandToPackedOrDiscarded")
115  process.packedPatJetsAK8Backup.fixDaughters = False
116  #for this one the link is broken using oldPFCandToPackedOrDiscarded...
117  #not sure why, but result is the same
118  process.slimmedJetsAK8Backup.rekeyDaughters = '1'
119  process.slimmedJetsAK8Backup.mixedDaughters = False
120  process.slimmedJetsAK8Backup.packedPFCandidates = cms.InputTag("packedPFCandidatesBackup") #oldPFCandToPackedOrDiscarded
121  reduceFinalJetCollection(process, process.slimmedJetsBackup, badMuons)
122 
123  if hasattr(process,"slimmedJetsAK8PFCHSSoftDropSubjetsBackup"):
124  process.slimmedJetsAK8PFCHSSoftDropSubjetsBackup.mixedDaughters = True
125  process.slimmedJetsAK8PFCHSSoftDropSubjetsBackup.packedPFCandidates = cms.InputTag("oldPFCandToPackedOrDiscarded")
126  reduceFinalJetCollection(process, process.slimmedJetsAK8Backup, badMuons)
127  #for this one the link is broken using oldPFCandToPackedOrDiscarded...
128  #not sure why, but result is the same
129  process.slimmedJetsAK8BackupAllEvents.packedPFCandidates = cms.InpuTag("packedPFCandidatesBackup")
130 
131  # for these we can't
132  if hasattr(process,"slimmedJetsPuppiBackup"):
133  process.slimmedJetsPuppiBackup.dropDaughters = '1'
134  process.slimmedJetsAK8PFPuppiSoftDropSubjetsBackup.dropDaughters = '1'
135  reduceFinalJetCollection(process, process.slimmedJetsPuppiBackup, badMuons)
136 
137  #
138  addKeepStatement(process,
139  "keep *_slimmedJets_*_*",
140  ["keep *_slimmedJetsBackup_*_*"],
141  verbose=verbose)
142  addKeepStatement(process, "keep *_slimmedJetsPuppi_*_*",
143  ["keep *_slimmedJetsPuppiBackup_*_*"],
144  verbose=verbose)
145  addKeepStatement(process,
146  "keep *_slimmedJetsAK8_*_*",
147  ["keep *_slimmedJetsAK8Backup_*_*"],
148  verbose=verbose)
149  addKeepStatement(process,"keep *_slimmedJetsAK8PFCHSSoftDropPacked_SubJets_*",
150  ["keep *_slimmedJetsAK8PFCHSSoftDropPackedBackup_SubJets_*"],
151  verbose=verbose)
152  addKeepStatement(process,"keep *_slimmedJetsAK8PFPuppiSoftDropPacked_SubJets_*",
153  ["keep *_slimmedJetsAK8PFPuppiSoftDropPackedBackup_SubJets_*"],
154  verbose=verbose)
155 
156 

References helpers.addKeepStatement(), helpers.getPatAlgosToolsTask(), helpers.listModules(), MassReplace.massSearchReplaceAnyInputTag(), reduceFinalJetCollection(), and reduceInputJetCollection().

Referenced by customizeMiniAOD_MuEGFixMoriond2017.customizeAll().

◆ makeRecoJetCollection()

def extraJets_MuEGFixMoriond2017.makeRecoJetCollection (   process,
  pfCandCollection,
  coneSize,
  useCHSAlgo,
  postfix 
)

Definition at line 7 of file extraJets_MuEGFixMoriond2017.py.

7 def makeRecoJetCollection(process,
8  pfCandCollection,
9  coneSize,
10  useCHSAlgo,
11  postfix):
12 
13  task = getPatAlgosToolsTask(process)
14 
15  jetColName="ak"+str(int(coneSize*10))+"PFJets"
16  internalPfCandColl=pfCandCollection
17  if useCHSAlgo:
18  addToProcessAndTask("tmpPFCandCollPtr"+postfix,
19  cms.EDProducer("PFCandidateFwdPtrProducer",
20  src = cms.InputTag(pfCandCollection) ),
21  process, task )
22  process.load("CommonTools.ParticleFlow.pfNoPileUpJME_cff")
23  task.add(process.pfNoPileUpJMETask)
24  cloneProcessingSnippet(process, getattr(process,"pfNoPileUpJMESequence"), postfix, addToTask = True )
25  getattr(process, "pfPileUpJME"+postfix).PFCandidates = cms.InputTag("tmpPFCandCollPtr"+postfix)
26  getattr(process, "pfNoPileUpJME"+postfix).bottomCollection = cms.InputTag("tmpPFCandCollPtr"+postfix)
27 
28  internalPfCandColl = "pfNoPileUpJME"+postfix
29  jetColName+="CHS"
30 
31  addToProcessAndTask(jetColName+postfix,
32  getattr(process,jetColName).clone(
33  src = cms.InputTag(internalPfCandColl),
34  rParam=cms.double(coneSize),
35  doAreaFastjet = True),
36  process, task )
37 

References helpers.addToProcessAndTask(), clone(), helpers.cloneProcessingSnippet(), helpers.getPatAlgosToolsTask(), createfilelist.int, and str.

◆ reduceFinalJetCollection()

def extraJets_MuEGFixMoriond2017.reduceFinalJetCollection (   process,
  jetCollection,
  badMuons 
)

Definition at line 54 of file extraJets_MuEGFixMoriond2017.py.

54 def reduceFinalJetCollection(process, jetCollection, badMuons):
55 
56  task = getPatAlgosToolsTask(process)
57 
58  label = jetCollection.label()
59  addToProcessAndTask(label+"AllEvents",
60  jetCollection.clone(),
61  process, task )
62  process.globalReplace(label,
63  cms.EDProducer("PATJetCollectionReducer",
64  writeEmptyCollection = cms.bool(False),
65  jetCollection = cms.InputTag(label+"AllEvents"),
66  triggeringCollections=badMuons,
67  )
68  )
69 
70 

References helpers.addToProcessAndTask(), and helpers.getPatAlgosToolsTask().

Referenced by backupJetsSecondStep().

◆ reduceInputJetCollection()

def extraJets_MuEGFixMoriond2017.reduceInputJetCollection (   process,
  jetCollection,
  badMuons 
)

Definition at line 38 of file extraJets_MuEGFixMoriond2017.py.

38 def reduceInputJetCollection(process, jetCollection, badMuons):
39 
40  task = getPatAlgosToolsTask(process)
41 
42  label = jetCollection.label()
43  addToProcessAndTask(label+"AllEvents",
44  jetCollection.clone(),
45  process, task )
46  process.globalReplace(label,
47  cms.EDProducer("PFJetCollectionReducer",
48  writeEmptyCollection = cms.bool(True),
49  jetCollection = cms.InputTag(label+"AllEvents"),
50  triggeringCollections=badMuons,
51  )
52  )
53 

References helpers.addToProcessAndTask(), and helpers.getPatAlgosToolsTask().

Referenced by backupJetsSecondStep().

helpers.addKeepStatement
def addKeepStatement(process, oldKeep, newKeeps, verbose=False)
Definition: helpers.py:355
helpers.getPatAlgosToolsTask
def getPatAlgosToolsTask(process)
Definition: helpers.py:14
extraJets_MuEGFixMoriond2017.backupJetsSecondStep
def backupJetsSecondStep(process, sequences, badMuons, verbose=False)
Definition: extraJets_MuEGFixMoriond2017.py:90
extraJets_MuEGFixMoriond2017.makeRecoJetCollection
def makeRecoJetCollection(process, pfCandCollection, coneSize, useCHSAlgo, postfix)
Definition: extraJets_MuEGFixMoriond2017.py:7
clone
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
str
#define str(s)
Definition: TestProcessor.cc:51
extraJets_MuEGFixMoriond2017.reduceInputJetCollection
def reduceInputJetCollection(process, jetCollection, badMuons)
Definition: extraJets_MuEGFixMoriond2017.py:38
helpers.listModules
def listModules(sequence)
Definition: helpers.py:208
createfilelist.int
int
Definition: createfilelist.py:10
helpers.listDependencyChain
def listDependencyChain(process, module, sources, verbose=False)
Definition: helpers.py:273
MassReplace.massSearchReplaceAnyInputTag
def massSearchReplaceAnyInputTag(sequence, oldInputTag, newInputTag, verbose=False, moduleLabelOnly=False, skipLabelTest=False)
Definition: MassReplace.py:79
extraJets_MuEGFixMoriond2017.backupJetsFirstStep
def backupJetsFirstStep(process)
Definition: extraJets_MuEGFixMoriond2017.py:71
extraJets_MuEGFixMoriond2017.reduceFinalJetCollection
def reduceFinalJetCollection(process, jetCollection, badMuons)
Definition: extraJets_MuEGFixMoriond2017.py:54
helpers.addToProcessAndTask
def addToProcessAndTask(label, module, process, task)
Definition: helpers.py:29
helpers.cloneProcessingSnippet
def cloneProcessingSnippet(process, sequence, postfix, removePostfix="", noClones=[], addToTask=False, verbose=False)
Definition: helpers.py:258