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)
18 if hasattr(cutflow,
'isPOGApproved'):
19 isPOGApproved = cutflow.isPOGApproved.value()
20 vidproducer.physicsObjectIDs.append(
21 cms.PSet( idDefinition = cutflow,
22 isPOGApproved = cms.untracked.bool(isPOGApproved),
23 idMD5 = cms.string(cutflow_md5) )
30 for key
in patProducer.__dict__.keys():
31 if 'IDSources' in key:
32 patProducerIDs = getattr(patProducer,key)
34 userDatas = getattr(patProducer,key)
35 if patProducerIDs
is None:
36 raise Exception(
'StrangePatModule',
'%s does not have ID sources!'%patProducer.label())
38 raise Exception(
'StrangePatModule',
'%s does not have UserData sources!'%patProducer.label())
39 setattr(patProducerIDs,idName,cms.InputTag(
'%s:%s'%(idProducer,idName)))
41 if( len(userDatas.userClasses.src) == 1
and 42 isinstance(userDatas.userClasses.src[0], str)
and 43 userDatas.userClasses.src[0] ==
'' ):
44 userDatas.userClasses.src = cms.VInputTag(cms.InputTag(
'%s:%s'%(idProducer,idName)))
46 userDatas.userClasses.src.append(cms.InputTag(
'%s:%s'%(idProducer,idName)))
47 sys.stderr.write(
'\t--- %s:%s added to %s\n'%(idProducer,idName,patProducer.label()))
51 idmod= __import__(id_module_name, globals(), locals(), [
'idName',
'cutFlow'])
52 for name
in dir(idmod):
53 item = getattr(idmod,name)
54 if hasattr(item,
'idName')
and hasattr(item,
'cutFlow'):
55 setupFunction(process,item,patProducer,addUserData,task)
58 from PhysicsTools.SelectorUtils.tools.DataFormat
import DataFormat
67 process.load(
'RecoEgamma.ElectronIdentification.egmGsfElectronIDs_cff')
69 task.add(process.egmGsfElectronIDTask)
71 if( len(process.egmGsfElectronIDs.physicsObjectIDs) > 0 ):
72 process.egmGsfElectronIDs.physicsObjectIDs = cms.VPSet()
73 dataFormatString =
"Undefined" 74 if dataFormat == DataFormat.AOD:
76 dataFormatString =
"AOD" 77 elif dataFormat == DataFormat.MiniAOD:
80 process.egmGsfElectronIDs.physicsObjectSrc = cms.InputTag(
'slimmedElectrons')
81 dataFormatString =
"MiniAOD" 83 raise Exception(
'InvalidVIDDataFormat',
'The requested data format is different from AOD or MiniAOD')
88 if not hasattr(process,
'egmGsfElectronIDs'):
89 raise Exception(
'VIDProducerNotAvailable',
'egmGsfElectronIDs producer not available in process!')
92 if hasattr(process,
'patElectrons')
or patProducer
is not None:
93 if patProducer
is None:
94 patProducer = process.patElectrons
95 idName = cutflow.idName.value()
101 if (cutflow.idName.value().
find(
"HEEP")!=-1
and 102 cutflow.idName.value()!=
"heepElectronID-HEEPV60"):
105 useMiniAOD = process.egmGsfElectronIDs.physicsObjectSrc == cms.InputTag(
'slimmedElectrons')
109 useMiniAOD=useMiniAOD,task=task)
118 process.load(
'RecoMuon.MuonIdentification.muoMuonIDs_cff')
120 task.add(process.muoMuonIDTask)
122 if( len(process.muoMuonIDs.physicsObjectIDs) > 0 ):
123 process.muoMuonIDs.physicsObjectIDs = cms.VPSet()
124 dataFormatString =
"Undefined" 125 if dataFormat == DataFormat.AOD:
127 dataFormatString =
"AOD" 128 elif dataFormat == DataFormat.MiniAOD:
131 process.muoMuonIDs.physicsObjectSrc = cms.InputTag(
'slimmedMuons')
132 dataFormatString =
"MiniAOD" 134 raise Exception(
'InvalidVIDDataFormat',
'The requested data format is different from AOD or MiniAOD')
139 moduleName =
"muoMuonIDs" 140 if not hasattr(process, moduleName):
141 raise Exception(
"VIDProducerNotAvailable",
"%s producer not available in process!" % moduleName)
142 module = getattr(process, moduleName)
159 from RecoEgamma.PhotonIdentification.egmPhotonIDs_cff
import loadEgmIdSequence
163 task.add(process.egmPhotonIDTask)
165 if( len(process.egmPhotonIDs.physicsObjectIDs) > 0 ):
166 process.egmPhotonIDs.physicsObjectIDs = cms.VPSet()
167 dataFormatString =
"Undefined" 168 if dataFormat == DataFormat.AOD:
170 dataFormatString =
"AOD" 171 elif dataFormat == DataFormat.MiniAOD:
174 process.egmPhotonIDs.physicsObjectSrc = cms.InputTag(
'slimmedPhotons')
175 dataFormatString =
"MiniAOD" 177 raise Exception(
'InvalidVIDDataFormat',
'The requested data format is different from AOD or MiniAOD')
182 if not hasattr(process,
'egmPhotonIDs'):
183 raise Exception(
'VIDProducerNotAvailable',
'egmPhotonIDs producer not available in process!\n')
186 if hasattr(process,
'patPhotons')
or patProducer
is not None:
187 if patProducer
is None:
188 patProducer = process.patPhotons
189 idName = cutflow.idName.value()
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
def loadEgmIdSequence(process, dataFormat)