CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
jetCollectionTools.GenJetAdder Class Reference
Inheritance diagram for jetCollectionTools.GenJetAdder:

Public Member Functions

def __init__ (self)
 
def addGenJetCollection (self, proc, jet, inputCollection="", genName="", minPt=5.)
 
def getSequence (self, proc)
 

Public Attributes

 gpLabel
 
 main
 
 prerequisites
 

Detailed Description

Tool to schedule modules for building a genjet collection with input MiniAODs

Definition at line 62 of file jetCollectionTools.py.

Constructor & Destructor Documentation

def jetCollectionTools.GenJetAdder.__init__ (   self)

Member Function Documentation

def jetCollectionTools.GenJetAdder.addGenJetCollection (   self,
  proc,
  jet,
  inputCollection = "",
  genName = "",
  minPt = 5. 
)

Definition at line 88 of file jetCollectionTools.py.

References jetCollectionTools.GenJetAdder.prerequisites, and edm.print().

Referenced by jetCollectionTools.GenJetAdder.getSequence().

88  ):
89  print("jetCollectionTools::GenJetAdder::addGenJetCollection: Adding Gen Jet Collection: {}".format(jet))
90  currentTasks = []
91 
92  #
93  # Decide which jet collection we're dealing with
94  #
95  jetLower = jet.lower()
96  jetUpper = jet.upper()
97  tagName = jetUpper
98  genJetInfo = GenJetInfo(jet,inputCollection)
99 
100  #=======================================================
101  #
102  # If gen jet collection in MiniAOD is not
103  # specified, build the genjet collection.
104  #
105  #========================================================
106  if not inputCollection:
107  print("jetCollectionTools::GenJetAdder::addGenJetCollection: inputCollection not specified. Building genjet collection now")
108  #
109  # Setup GenParticles
110  #
111  packedGenPartNoNu = "packedGenParticlesForJetsNoNu"
112  if packedGenPartNoNu not in self.prerequisites:
113  setattr(proc, packedGenPartNoNu, cms.EDFilter("CandPtrSelector",
114  src = cms.InputTag("packedGenParticles"),
115  cut = cms.string("abs(pdgId) != 12 && abs(pdgId) != 14 && abs(pdgId) != 16"),
116  )
117  )
118  self.prerequisites.append(packedGenPartNoNu)
119  #
120  # Create the GenJet collection
121  #
122  genJetsCollection = "{}{}{}".format(genJetInfo.jetAlgo.upper(), genJetInfo.jetSize, 'GenJetsNoNu')
123  setattr(proc, genJetsCollection, ak4GenJets.clone(
124  src = packedGenPartNoNu,
125  jetAlgorithm = cms.string(supportedJetAlgos[genJetInfo.jetAlgo]),
126  rParam = cms.double(genJetInfo.jetSizeNr),
127  )
128  )
129  self.prerequisites.append(genJetsCollection)
130  #
131  # GenJet Flavour Labelling
132  #
133  genFlavour = "{}Flavour".format(genJetInfo.jetTagName)
134  setattr(proc, genFlavour, patJetFlavourAssociation.clone(
135  jets = cms.InputTag(genJetsCollection),
136  jetAlgorithm = cms.string(supportedJetAlgos[genJetInfo.jetAlgo]),
137  rParam = cms.double(genJetInfo.jetSizeNr),
138  )
139  )
140 
141  currentTasks.append(genFlavour)
142  self.main.extend(currentTasks)
143 
144  return genJetInfo
145 
146 #============================================
147 #
148 # RecoJetInfo
149 #
150 #============================================
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def jetCollectionTools.GenJetAdder.getSequence (   self,
  proc 
)

Definition at line 71 of file jetCollectionTools.py.

References jetCollectionTools.GenJetAdder.addGenJetCollection(), jetCollectionTools.GenJetAdder.main, custom_jme_cff.TableGenJetAdder.main, custom_jme_cff.TableRecoJetAdder.main, and jetCollectionTools.GenJetAdder.prerequisites.

71  def getSequence(self, proc):
72  tasks = self.prerequisites + self.main
73 
74  resultSequence = cms.Sequence()
75  for idx, task in enumerate(tasks):
76  if idx == 0:
77  resultSequence = cms.Sequence(getattr(proc, task))
78  else:
79  resultSequence.insert(idx, getattr(proc, task))
80  return resultSequence
81 

Member Data Documentation

jetCollectionTools.GenJetAdder.gpLabel
jetCollectionTools.GenJetAdder.main
jetCollectionTools.GenJetAdder.prerequisites