CMS 3D CMS Logo

Classes | Functions
vid_id_tools Namespace Reference

Classes

class  DataFormat
 

Functions

def addVIDSelectionToPATProducer (patProducer, idProducer, idName, addUserData=True)
 
def setupAllVIDIdsInModule (process, id_module_name, setupFunction, patProducer=None, addUserData=True, task=None)
 
def setupVIDElectronSelection (process, cutflow, patProducer=None, addUserData=True, task=None)
 
def setupVIDMuonSelection (process, cutflow, patProducer=None)
 
def setupVIDPhotonSelection (process, cutflow, patProducer=None, addUserData=True, task=None)
 
def setupVIDSelection (vidproducer, cutflow)
 
def switchOnVIDElectronIdProducer (process, dataFormat, task=None)
 
def switchOnVIDMuonIdProducer (process, dataFormat, task=None)
 Muons. More...
 
def switchOnVIDPhotonIdProducer (process, dataFormat, task=None)
 Photons. More...
 

Function Documentation

def vid_id_tools.addVIDSelectionToPATProducer (   patProducer,
  idProducer,
  idName,
  addUserData = True 
)

Definition at line 28 of file vid_id_tools.py.

References reco.if().

Referenced by setupVIDElectronSelection(), and setupVIDPhotonSelection().

28 def addVIDSelectionToPATProducer(patProducer,idProducer,idName,addUserData=True):
29  patProducerIDs = None
30  userDatas = None
31  for key in patProducer.__dict__.keys():
32  if 'IDSources' in key:
33  patProducerIDs = getattr(patProducer,key)
34  if 'userData' in key:
35  userDatas = getattr(patProducer,key)
36  if patProducerIDs is None:
37  raise Exception('StrangePatModule','%s does not have ID sources!'%patProducer.label())
38  if userDatas is None:
39  raise Exception('StrangePatModule','%s does not have UserData sources!'%patProducer.label())
40  setattr(patProducerIDs,idName,cms.InputTag('%s:%s'%(idProducer,idName)))
41  if( addUserData ):
42  if( len(userDatas.userClasses.src) == 1 and
43  type(userDatas.userClasses.src[0]) is str and
44  userDatas.userClasses.src[0] == '' ):
45  userDatas.userClasses.src = cms.VInputTag(cms.InputTag('%s:%s'%(idProducer,idName)))
46  else:
47  userDatas.userClasses.src.append(cms.InputTag('%s:%s'%(idProducer,idName)))
48  sys.stderr.write('\t--- %s:%s added to %s\n'%(idProducer,idName,patProducer.label()))
49 
if(dp >Float(M_PI)) dp-
def addVIDSelectionToPATProducer(patProducer, idProducer, idName, addUserData=True)
Definition: vid_id_tools.py:28
def vid_id_tools.setupAllVIDIdsInModule (   process,
  id_module_name,
  setupFunction,
  patProducer = None,
  addUserData = True,
  task = None 
)

Definition at line 50 of file vid_id_tools.py.

References dir.

Referenced by customiseL1CustomReco.L1NtupleCustomReco(), miniAOD_tools.miniAOD_customizeCommon(), PhotonPuppi_cff.setupPuppiPhoton(), and PhotonPuppi_cff.setupPuppiPhotonMiniAOD().

50 def setupAllVIDIdsInModule(process,id_module_name,setupFunction,patProducer=None,addUserData=True,task=None):
51 # idmod = importlib.import_module(id_module_name)
52  idmod= __import__(id_module_name, globals(), locals(), ['idName','cutFlow'])
53  for name in dir(idmod):
54  item = getattr(idmod,name)
55  if hasattr(item,'idName') and hasattr(item,'cutFlow'):
56  setupFunction(process,item,patProducer,addUserData,task)
57 
58 # Supported data formats defined via "enum"
def setupAllVIDIdsInModule(process, id_module_name, setupFunction, patProducer=None, addUserData=True, task=None)
Definition: vid_id_tools.py:50
dbl *** dir
Definition: mlp_gen.cc:35
def vid_id_tools.setupVIDElectronSelection (   process,
  cutflow,
  patProducer = None,
  addUserData = True,
  task = None 
)

Definition at line 90 of file vid_id_tools.py.

References heepElectronID_tools.addHEEPProducersToSeq(), addVIDSelectionToPATProducer(), spr.find(), and setupVIDSelection().

90 def setupVIDElectronSelection(process,cutflow,patProducer=None,addUserData=True,task=None):
91  if not hasattr(process,'egmGsfElectronIDs'):
92  raise Exception('VIDProducerNotAvailable','egmGsfElectronIDs producer not available in process!')
93  setupVIDSelection(process.egmGsfElectronIDs,cutflow)
94  #add to PAT electron producer if available or specified
95  if hasattr(process,'patElectrons') or patProducer is not None:
96  if patProducer is None:
97  patProducer = process.patElectrons
98  idName = cutflow.idName.value()
99  addVIDSelectionToPATProducer(patProducer,'egmGsfElectronIDs',idName,addUserData)
100 
101  #we know cutflow has a name otherwise an exception would have been thrown in setupVIDSelection
102  #run this for all heep IDs except V60 standard for which it is not needed
103  #it is needed for V61 and V70
104  if (cutflow.idName.value().find("HEEP")!=-1 and
105  cutflow.idName.value()!="heepElectronID-HEEPV60"):
106 
107  #not the ideal way but currently the easiest
108  useMiniAOD = process.egmGsfElectronIDs.physicsObjectSrc == cms.InputTag('slimmedElectrons')
109 
111  addHEEPProducersToSeq(process=process,seq=process.egmGsfElectronIDSequence,
112  useMiniAOD=useMiniAOD,task=task)
113 
def addHEEPProducersToSeq(process, seq, useMiniAOD, task=None)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
def setupVIDSelection(vidproducer, cutflow)
Definition: vid_id_tools.py:11
def setupVIDElectronSelection(process, cutflow, patProducer=None, addUserData=True, task=None)
Definition: vid_id_tools.py:90
def addVIDSelectionToPATProducer(patProducer, idProducer, idName, addUserData=True)
Definition: vid_id_tools.py:28
def vid_id_tools.setupVIDMuonSelection (   process,
  cutflow,
  patProducer = None 
)

Definition at line 141 of file vid_id_tools.py.

References setupVIDSelection().

141 def setupVIDMuonSelection(process,cutflow,patProducer=None):
142  moduleName = "muoMuonIDs"
143  if not hasattr(process, moduleName):
144  raise Exception("VIDProducerNotAvailable", "%s producer not available in process!" % moduleName)
145  module = getattr(process, moduleName)
146 
147  setupVIDSelection(module, cutflow)
148  #add to PAT electron producer if available or specified
149  #if hasattr(process,'patMuons') or patProducer is not None:
150  # if patProducer is None:
151  # patProducer = process.patMuons
152  # idName = cutflow.idName.value()
153  # addVIDSelectionToPATProducer(patProducer, moduleName, idName)
154 
def setupVIDSelection(vidproducer, cutflow)
Definition: vid_id_tools.py:11
def setupVIDMuonSelection(process, cutflow, patProducer=None)
def vid_id_tools.setupVIDPhotonSelection (   process,
  cutflow,
  patProducer = None,
  addUserData = True,
  task = None 
)

Definition at line 182 of file vid_id_tools.py.

References addVIDSelectionToPATProducer(), and setupVIDSelection().

182 def setupVIDPhotonSelection(process,cutflow,patProducer=None,addUserData=True,task=None):
183  if not hasattr(process,'egmPhotonIDs'):
184  raise Exception('VIDProducerNotAvailable','egmPhotonIDs producer not available in process!\n')
185  setupVIDSelection(process.egmPhotonIDs,cutflow)
186  #add to PAT photon producer if available or specified
187  if hasattr(process,'patPhotons') or patProducer is not None:
188  if patProducer is None:
189  patProducer = process.patPhotons
190  idName = cutflow.idName.value()
191  addVIDSelectionToPATProducer(patProducer,'egmPhotonIDs',idName,addUserData)
192 
193 
194 
def setupVIDSelection(vidproducer, cutflow)
Definition: vid_id_tools.py:11
def addVIDSelectionToPATProducer(patProducer, idProducer, idName, addUserData=True)
Definition: vid_id_tools.py:28
def setupVIDPhotonSelection(process, cutflow, patProducer=None, addUserData=True, task=None)
def vid_id_tools.setupVIDSelection (   vidproducer,
  cutflow 
)

Definition at line 11 of file vid_id_tools.py.

Referenced by setupVIDElectronSelection(), setupVIDMuonSelection(), and setupVIDPhotonSelection().

11 def setupVIDSelection(vidproducer,cutflow):
12  if not hasattr(cutflow,'idName'):
13  raise Exception('InvalidVIDCutFlow', 'The cutflow configuation provided is malformed and does not have a specified name!')
14  if not hasattr(cutflow,'cutFlow'):
15  raise Exception('InvalidVIDCutFlow', 'The cutflow configuration provided is malformed and does not have a specific cutflow!')
16  cutflow_md5 = central_id_registry.getMD5FromName(cutflow.idName)
17  isPOGApproved = cms.untracked.bool(False)
18  if hasattr(cutflow,'isPOGApproved'):
19  isPOGApproved = cutflow.isPOGApproved
20  del cutflow.isPOGApproved
21  vidproducer.physicsObjectIDs.append(
22  cms.PSet( idDefinition = cutflow,
23  isPOGApproved = isPOGApproved,
24  idMD5 = cms.string(cutflow_md5) )
25  )
26 # sys.stderr.write('Added ID \'%s\' to %s\n'%(cutflow.idName.value(),vidproducer.label()))
27 
def setupVIDSelection(vidproducer, cutflow)
Definition: vid_id_tools.py:11
def vid_id_tools.switchOnVIDElectronIdProducer (   process,
  dataFormat,
  task = None 
)

Definition at line 69 of file vid_id_tools.py.

References reco.if().

Referenced by customiseL1CustomReco.L1NtupleCustomReco(), and miniAOD_tools.miniAOD_customizeCommon().

69 def switchOnVIDElectronIdProducer(process, dataFormat, task=None):
70  process.load('RecoEgamma.ElectronIdentification.egmGsfElectronIDs_cff')
71  if task is not None:
72  task.add(process.egmGsfElectronIDTask)
73  #*always* reset to an empty configuration
74  if( len(process.egmGsfElectronIDs.physicsObjectIDs) > 0 ):
75  process.egmGsfElectronIDs.physicsObjectIDs = cms.VPSet()
76  dataFormatString = "Undefined"
77  if dataFormat == DataFormat.AOD:
78  # No reconfiguration is required, default settings are for AOD
79  dataFormatString = "AOD"
80  elif dataFormat == DataFormat.MiniAOD:
81  # If we are dealing with MiniAOD, we overwrite the electron collection
82  # name appropriately, for the fragment we just loaded above.
83  process.egmGsfElectronIDs.physicsObjectSrc = cms.InputTag('slimmedElectrons')
84  dataFormatString = "MiniAOD"
85  else:
86  raise Exception('InvalidVIDDataFormat', 'The requested data format is different from AOD or MiniAOD')
87  #
88 # sys.stderr.write('Added \'egmGsfElectronIDs\' to process definition (%s format)!\n' % dataFormatString)
89 
def switchOnVIDElectronIdProducer(process, dataFormat, task=None)
Definition: vid_id_tools.py:69
if(dp >Float(M_PI)) dp-
def vid_id_tools.switchOnVIDMuonIdProducer (   process,
  dataFormat,
  task = None 
)

Muons.

Definition at line 120 of file vid_id_tools.py.

References reco.if().

120 def switchOnVIDMuonIdProducer(process, dataFormat, task=None):
121  process.load('RecoMuon.MuonIdentification.muoMuonIDs_cff')
122  if task is not None:
123  task.add(process.muoMuonIDTask)
124  #*always* reset to an empty configuration
125  if( len(process.muoMuonIDs.physicsObjectIDs) > 0 ):
126  process.muoMuonIDs.physicsObjectIDs = cms.VPSet()
127  dataFormatString = "Undefined"
128  if dataFormat == DataFormat.AOD:
129  # No reconfiguration is required, default settings are for AOD
130  dataFormatString = "AOD"
131  elif dataFormat == DataFormat.MiniAOD:
132  # If we are dealing with MiniAOD, we overwrite the muon collection
133  # name appropriately, for the fragment we just loaded above.
134  process.muoMuonIDs.physicsObjectSrc = cms.InputTag('slimmedMuons')
135  dataFormatString = "MiniAOD"
136  else:
137  raise Exception('InvalidVIDDataFormat', 'The requested data format is different from AOD or MiniAOD')
138  #
139 # sys.stderr.write('Added \'muoMuonIDs\' to process definition (%s format)!\n' % dataFormatString)
140 
def switchOnVIDMuonIdProducer(process, dataFormat, task=None)
Muons.
if(dp >Float(M_PI)) dp-
def vid_id_tools.switchOnVIDPhotonIdProducer (   process,
  dataFormat,
  task = None 
)

Photons.

Definition at line 161 of file vid_id_tools.py.

References reco.if().

Referenced by miniAOD_tools.miniAOD_customizeCommon(), PhotonPuppi_cff.setupPuppiPhoton(), and PhotonPuppi_cff.setupPuppiPhotonMiniAOD().

161 def switchOnVIDPhotonIdProducer(process, dataFormat, task=None):
162  process.load('RecoEgamma.PhotonIdentification.egmPhotonIDs_cff')
163  if task is not None:
164  task.add(process.egmPhotonIDTask)
165  #*always* reset to an empty configuration
166  if( len(process.egmPhotonIDs.physicsObjectIDs) > 0 ):
167  process.egmPhotonIDs.physicsObjectIDs = cms.VPSet()
168  dataFormatString = "Undefined"
169  if dataFormat == DataFormat.AOD:
170  # No reconfiguration is required, default settings are for AOD
171  dataFormatString = "AOD"
172  elif dataFormat == DataFormat.MiniAOD:
173  # If we are dealing with MiniAOD, we overwrite the electron collection
174  # name appropriately, for the fragment we just loaded above.
175  process.egmPhotonIDs.physicsObjectSrc = cms.InputTag('slimmedPhotons')
176  dataFormatString = "MiniAOD"
177  else:
178  raise Exception('InvalidVIDDataFormat', 'The requested data format is different from AOD or MiniAOD')
179  #
180  sys.stderr.write('Added \'egmPhotonIDs\' to process definition (%s format)!\n' % dataFormatString)
181 
if(dp >Float(M_PI)) dp-
def switchOnVIDPhotonIdProducer(process, dataFormat, task=None)
Photons.