3 from PhysicsTools.SelectorUtils.centralIDRegistry
import central_id_registry
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) )
26 sys.stderr.write(
'Added ID \'%s\' to %s\n'%(cutflow.idName.value(),vidproducer.label()))
31 for key
in patProducer.__dict__.keys():
32 if 'IDSources' in key:
33 patProducerIDs = getattr(patProducer,key)
35 userDatas = getattr(patProducer,key)
36 if patProducerIDs
is None:
37 raise Exception(
'StrangePatModule',
'%s does not have ID sources!'%patProducer.label())
39 raise Exception(
'StrangePatModule',
'%s does not have UserData sources!'%patProducer.label())
40 setattr(patProducerIDs,idName,cms.InputTag(
'%s:%s'%(idProducer,idName)))
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)))
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()))
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)
70 process.load(
'RecoEgamma.ElectronIdentification.egmGsfElectronIDs_cff')
72 if( len(process.egmGsfElectronIDs.physicsObjectIDs) > 0 ):
73 process.egmGsfElectronIDs.physicsObjectIDs = cms.VPSet()
74 dataFormatString =
"Undefined"
75 if dataFormat == DataFormat.AOD:
77 dataFormatString =
"AOD"
78 elif dataFormat == DataFormat.MiniAOD:
81 process.egmGsfElectronIDs.physicsObjectSrc = cms.InputTag(
'slimmedElectrons')
82 dataFormatString =
"MiniAOD"
84 raise Exception(
'InvalidVIDDataFormat',
'The requested data format is different from AOD or MiniAOD')
86 sys.stderr.write(
'Added \'egmGsfElectronIDs\' to process definition (%s format)!\n' % dataFormatString)
89 if not hasattr(process,
'egmGsfElectronIDs'):
90 raise Exception(
'VIDProducerNotAvailable',
'egmGsfElectronIDs producer not available in process!')
93 if hasattr(process,
'patElectrons')
or patProducer
is not None:
94 if patProducer
is None:
95 patProducer = process.patElectrons
96 idName = cutflow.idName.value()
106 process.load(
'RecoMuon.MuonIdentification.muoMuonIDs_cff')
108 if( len(process.muoMuonIDs.physicsObjectIDs) > 0 ):
109 process.muoMuonIDs.physicsObjectIDs = cms.VPSet()
110 dataFormatString =
"Undefined"
111 if dataFormat == DataFormat.AOD:
113 dataFormatString =
"AOD"
114 elif dataFormat == DataFormat.MiniAOD:
117 process.muoMuonIDs.physicsObjectSrc = cms.InputTag(
'slimmedMuons')
118 dataFormatString =
"MiniAOD"
120 raise Exception(
'InvalidVIDDataFormat',
'The requested data format is different from AOD or MiniAOD')
122 sys.stderr.write(
'Added \'muoMuonIDs\' to process definition (%s format)!\n' % dataFormatString)
125 moduleName =
"muoMuonIDs"
126 if not hasattr(process, moduleName):
127 raise Exception(
"VIDProducerNotAvailable",
"%s producer not available in process!" % moduleName)
143 process.load(
'RecoEgamma.PhotonIdentification.egmPhotonIDs_cff')
145 if( len(process.egmPhotonIDs.physicsObjectIDs) > 0 ):
146 process.egmPhotonIDs.physicsObjectIDs = cms.VPSet()
147 dataFormatString =
"Undefined"
148 if dataFormat == DataFormat.AOD:
150 dataFormatString =
"AOD"
151 elif dataFormat == DataFormat.MiniAOD:
154 process.egmPhotonIDs.physicsObjectSrc = cms.InputTag(
'slimmedPhotons')
155 dataFormatString =
"MiniAOD"
157 raise Exception(
'InvalidVIDDataFormat',
'The requested data format is different from AOD or MiniAOD')
159 sys.stderr.write(
'Added \'egmPhotonIDs\' to process definition (%s format)!\n' % dataFormatString)
162 if not hasattr(process,
'egmPhotonIDs'):
163 raise Exception(
'VIDProducerNotAvailable',
'egmPhotonIDs producer not available in process!\n')
166 if hasattr(process,
'patPhotons')
or patProducer
is not None:
167 if patProducer
is None:
168 patProducer = process.patPhotons
169 idName = cutflow.idName.value()
if(conf.exists("allCellsPositionCalc"))