1 import FWCore.ParameterSet.Config
as cms
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) )
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,task)
70 process.load(
'RecoEgamma.ElectronIdentification.egmGsfElectronIDs_cff')
72 task.add(process.egmGsfElectronIDTask)
74 if( len(process.egmGsfElectronIDs.physicsObjectIDs) > 0 ):
75 process.egmGsfElectronIDs.physicsObjectIDs = cms.VPSet()
76 dataFormatString =
"Undefined" 77 if dataFormat == DataFormat.AOD:
79 dataFormatString =
"AOD" 80 elif dataFormat == DataFormat.MiniAOD:
83 process.egmGsfElectronIDs.physicsObjectSrc = cms.InputTag(
'slimmedElectrons')
84 dataFormatString =
"MiniAOD" 86 raise Exception(
'InvalidVIDDataFormat',
'The requested data format is different from AOD or MiniAOD')
91 if not hasattr(process,
'egmGsfElectronIDs'):
92 raise Exception(
'VIDProducerNotAvailable',
'egmGsfElectronIDs producer not available in process!')
95 if hasattr(process,
'patElectrons')
or patProducer
is not None:
96 if patProducer
is None:
97 patProducer = process.patElectrons
98 idName = cutflow.idName.value()
104 if (cutflow.idName.value().
find(
"HEEP")!=-1
and 105 cutflow.idName.value()!=
"heepElectronID-HEEPV60"):
108 useMiniAOD = process.egmGsfElectronIDs.physicsObjectSrc == cms.InputTag(
'slimmedElectrons')
112 useMiniAOD=useMiniAOD,task=task)
121 process.load(
'RecoMuon.MuonIdentification.muoMuonIDs_cff')
123 task.add(process.muoMuonIDTask)
125 if( len(process.muoMuonIDs.physicsObjectIDs) > 0 ):
126 process.muoMuonIDs.physicsObjectIDs = cms.VPSet()
127 dataFormatString =
"Undefined" 128 if dataFormat == DataFormat.AOD:
130 dataFormatString =
"AOD" 131 elif dataFormat == DataFormat.MiniAOD:
134 process.muoMuonIDs.physicsObjectSrc = cms.InputTag(
'slimmedMuons')
135 dataFormatString =
"MiniAOD" 137 raise Exception(
'InvalidVIDDataFormat',
'The requested data format is different from AOD or MiniAOD')
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)
162 process.load(
'RecoEgamma.PhotonIdentification.egmPhotonIDs_cff')
164 task.add(process.egmPhotonIDTask)
166 if( len(process.egmPhotonIDs.physicsObjectIDs) > 0 ):
167 process.egmPhotonIDs.physicsObjectIDs = cms.VPSet()
168 dataFormatString =
"Undefined" 169 if dataFormat == DataFormat.AOD:
171 dataFormatString =
"AOD" 172 elif dataFormat == DataFormat.MiniAOD:
175 process.egmPhotonIDs.physicsObjectSrc = cms.InputTag(
'slimmedPhotons')
176 dataFormatString =
"MiniAOD" 178 raise Exception(
'InvalidVIDDataFormat',
'The requested data format is different from AOD or MiniAOD')
180 sys.stderr.write(
'Added \'egmPhotonIDs\' to process definition (%s format)!\n' % dataFormatString)
183 if not hasattr(process,
'egmPhotonIDs'):
184 raise Exception(
'VIDProducerNotAvailable',
'egmPhotonIDs producer not available in process!\n')
187 if hasattr(process,
'patPhotons')
or patProducer
is not None:
188 if patProducer
is None:
189 patProducer = process.patPhotons
190 idName = cutflow.idName.value()
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)