File indexing completed on 2024-04-06 12:25:10
0001 import FWCore.ParameterSet.Config as cms
0002 from PhysicsTools.SelectorUtils.centralIDRegistry import central_id_registry
0003 from os import path
0004
0005 weightFileBaseDir = "RecoEgamma/PhotonIdentification/data/MVA"
0006
0007
0008 ebeeSplit = 1.479
0009
0010 category_cuts = cms.vstring(
0011 "abs(superCluster.eta) < 1.479",
0012 "abs(superCluster.eta) >= 1.479",
0013 )
0014
0015
0016 mvaClassName = "PhotonMVAEstimator"
0017
0018
0019
0020
0021
0022 mvaProducerModuleLabel = "photonMVAValueMapProducer"
0023
0024
0025
0026
0027
0028 class PhoMVA_2Categories_WP:
0029 """
0030 This is a container class to hold MVA cut values for a 2-category MVA
0031 as well as the names of the value maps that contain the MVA values computed
0032 for all particles in a producer upstream.
0033 """
0034 def __init__(self,
0035 idName,
0036 mvaValueMapName,
0037 mvaCategoriesMapName,
0038 cutCategory0,
0039 cutCategory1
0040 ):
0041 self.idName = idName
0042 self.mvaValueMapName = mvaValueMapName
0043 self.mvaCategoriesMapName = mvaCategoriesMapName
0044 self.cutCategory0 = cutCategory0
0045 self.cutCategory1 = cutCategory1
0046
0047 def getCutValues(self):
0048 return [self.cutCategory0, self.cutCategory1]
0049
0050
0051
0052
0053
0054 def configureVIDMVAPhoID_V1( mvaWP ):
0055 """
0056 This function configures the full cms.PSet for a VID ID and returns it.
0057 The inputs: an object of the class PhoMVA_2Categories_WP or similar
0058 that contains all necessary parameters for this MVA.
0059 """
0060 parameterSet = cms.PSet(
0061
0062 idName = cms.string( mvaWP.idName ),
0063 cutFlow = cms.VPSet(
0064 cms.PSet( cutName = cms.string("PhoMVACut"),
0065 mvaCuts = cms.vdouble( mvaWP.getCutValues() ),
0066 mvaValueMapName = cms.InputTag( mvaWP.mvaValueMapName ),
0067 mvaCategoriesMapName =cms.InputTag( mvaWP.mvaCategoriesMapName ),
0068 needsAdditionalProducts = cms.bool(True),
0069 isIgnored = cms.bool(False)
0070 )
0071 )
0072 )
0073
0074 return parameterSet
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093 def configureFullVIDMVAPhoID(mvaTag, variablesFile, weightFiles, wpConfig, **addKwargsForValueProducer):
0094
0095 mvaValueMapName = mvaProducerModuleLabel + ":" + mvaClassName + mvaTag + "Values"
0096 mvaCategoriesMapName = mvaProducerModuleLabel + ":" + mvaClassName + mvaTag + "Categories"
0097
0098
0099 producer_config = cms.PSet(
0100 mvaName = cms.string(mvaClassName),
0101 mvaTag = cms.string(mvaTag),
0102 weightFileNames = cms.vstring(*weightFiles),
0103 variableDefinition = cms.string(variablesFile),
0104 **addKwargsForValueProducer
0105 )
0106
0107
0108 VID_config = {}
0109 for wpc in wpConfig:
0110 idName = wpc["idName"]
0111 VID_config[idName] = configureVIDMVAPhoID_V1(
0112 PhoMVA_2Categories_WP(
0113 idName = idName,
0114 mvaValueMapName = mvaValueMapName,
0115 mvaCategoriesMapName = mvaCategoriesMapName,
0116 cutCategory0 = wpc["cuts"]["EB"],
0117 cutCategory1 = wpc["cuts"]["EE"]
0118 )
0119 )
0120
0121 configs = {"producer_config": producer_config, "VID_config": VID_config}
0122 return configs