def mkRegression(name,weights,variabs):
    pset =  cms.PSet(    
        variables=cms.VPSet(),
        classifier=cms.string(name),
        weights=cms.FileInPath(weights),
        regression=cms.bool(True),
        )
    
    cfgTools.addVariables(pset.variables,variabs)
    return pset
示例#2
0
def mkRegression(name, weights, variabs):
    pset = cms.PSet(
        variables=cms.VPSet(),
        classifier=cms.string(name),
        weights=cms.FileInPath(weights),
        regression=cms.bool(True),
    )

    cfgTools.addVariables(pset.variables, variabs)
    return pset
示例#3
0
    ttHScoreThreshold=cms.double(0.0),  #to be updated
    # For standardization
    ttHKiller_mean=ttHKiller_mean,
    ttHKiller_std=ttHKiller_std,
    ttHKiller_listmean=ttHKiller_listmean,
    ttHKiller_liststd=ttHKiller_liststd)

cfgTools.addVariables(
    flashggDoubleHTag.MVAConfig.variables,
    # here the syntax is VarNameInTMVA := expression
    [
        "Mjj := dijet().M()",
        "leadingJet_DeepCSV := leadJet().bDiscriminator('pfDeepCSVJetTags:probb')+leadJet().bDiscriminator('pfDeepCSVJetTags:probbb')",  #FIXME make the btag type configurable?
        "subleadingJet_DeepCSV := subleadJet().bDiscriminator('pfDeepCSVJetTags:probb')+subleadJet().bDiscriminator('pfDeepCSVJetTags:probbb')",
        "absCosThetaStar_CS := abs(getCosThetaStar_CS)",
        "absCosTheta_bb := abs(CosThetaAngles()[1])",
        "absCosTheta_gg := abs(CosThetaAngles()[0])",
        "diphotonCandidatePtOverdiHiggsM := diphotonPtOverM()",
        "dijetCandidatePtOverdiHiggsM := dijetPtOverM()",
        "customLeadingPhotonIDMVA := diPhoton.leadingView.phoIdMvaWrtChosenVtx",
        "customSubLeadingPhotonIDMVA := diPhoton.subLeadingView.phoIdMvaWrtChosenVtx",
        "leadingPhotonSigOverE := diPhoton.leadingPhoton.sigEOverE",
        "subleadingPhotonSigOverE := diPhoton.subLeadingPhoton.sigEOverE",
        "sigmaMOverM := sqrt(0.5*(diPhoton.leadingPhoton.sigEOverE*diPhoton.leadingPhoton.sigEOverE + diPhoton.subLeadingPhoton.sigEOverE*diPhoton.subLeadingPhoton.sigEOverE))",
        "PhoJetMinDr := getPhoJetMinDr()",
        "rho := global.rho",
        "(leadingJet_bRegNNResolution*1.4826) := leadJet().userFloat('bRegNNResolution')*1.4826",
        "(subleadingJet_bRegNNResolution*1.4826) := subleadJet().userFloat('bRegNNResolution')*1.4826",
        "(sigmaMJets*1.4826) := getSigmaMOverMJets()*1.4826"
    ])
def setup_flashggDifferentialPhoIdInputsCorrection( process, metaConditions ):

    process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService",
                                                       flashggDifferentialPhoIdInputsCorrection=cms.PSet(
                                                           initialSeed=cms.untracked.uint32(
                                                               90)
                                                       )
                                                   )

    process.load("flashgg.Taggers.flashggDifferentialPhoIdInputsCorrection_cfi")
    # print(process)
    
    setattr(flashggDifferentialPhoIdInputsCorrection, "photonIdMVAweightfile_EB", cms.FileInPath(str(metaConditions['flashggPhotons']['photonIdMVAweightfile_EB'])))
    setattr(flashggDifferentialPhoIdInputsCorrection, "photonIdMVAweightfile_EE", cms.FileInPath(str(metaConditions['flashggPhotons']['photonIdMVAweightfile_EE'])))
    setattr(flashggDifferentialPhoIdInputsCorrection, "effAreasConfigFile", cms.FileInPath(str(metaConditions['flashggPhotons']['effAreasConfigFile'])))
    setattr(flashggDifferentialPhoIdInputsCorrection, "is2017", cms.bool(metaConditions['flashggPhotons']['is2017']))

    corrections_summary = {}
    with open(os.path.expandvars('$CMSSW_BASE/src/'+metaConditions['PhoIdInputCorrections']['corrections_summary'])) as json_file:
        corrections_summary = json.load(json_file)

        #---Shower shapes
    for var in corrections_summary['shower_shapes'].keys():
        for subdet in ['EB', 'EE']:
            ss_summary = corrections_summary['shower_shapes'][var][subdet]
            setattr(flashggDifferentialPhoIdInputsCorrection, var+'_corrector_config_'+subdet, 
                    cms.PSet(
                        variables = cms.VPSet(),
                        weights = cms.FileInPath(str(ss_summary['weights'])),
                        regr_output_scaling = cms.string('x[0]*(%f)+(%f)' % (ss_summary['scale'], ss_summary['center'])),
                        regression = cms.bool(True),
                        classifier = cms.string('BDTG_{}_{}'.format(var, subdet))
                    )
                )        
            xgb_config = getattr(flashggDifferentialPhoIdInputsCorrection, var+'_corrector_config_'+subdet)
            # print(list(metaConditions['PhoIdInputCorrections']['SS_variables']))
            cfgTools.addVariables(xgb_config.variables, [str(st) for st in metaConditions['PhoIdInputCorrections']['SS_variables']])
                                  # ['f0 := pt',
                               #     'f1 := superCluster.eta',
                               #     'f2 := phi',
                               #     'f3 := global.rho',
                               #     'f4 := sieip',
                               #     'f5 := s4',
                               #     'f6 := full5x5_r9',
                               #     'f7 := superCluster.phiWidth',
                               #     'f8 := full5x5_sigmaIetaIeta',
                               #     'f9 := superCluster.etaWidth'
                               # ]
                               #    )
                                   

        #---Isolations
    for subdet in ['EB', 'EE']:
        #-photon isolation
        iso_summary = corrections_summary['isolations']['phoIso'][subdet]
        setattr(flashggDifferentialPhoIdInputsCorrection, 'phoIso_corrector_config_'+subdet, 
                cms.PSet(
                    clf_data = cms.PSet(
                        variables = cms.VPSet(),
                        weights = cms.FileInPath(str(iso_summary['peak_tail_clfs']['weights_data'])),
                        classifier = cms.string('BDTG_{}_{}_p0t_data'.format("phoIso", subdet))
                    ),
                    clf_mc = cms.PSet(
                        variables = cms.VPSet(),
                        weights = cms.FileInPath(str(iso_summary['peak_tail_clfs']['weights_mc'])),
                        classifier = cms.string('BDTG_{}_{}_p0t_mc'.format("phoIso", subdet))
                    ),
                    peak2tail = cms.PSet(
                        variables = cms.VPSet(),
                        weights = cms.FileInPath(str(iso_summary['peak2tail']['weights'])),
                        regression = cms.bool(True),
                        classifier = cms.string('BDTG_{}_{}_p2t'.format("phoIso", subdet))
                    ),
                    morphing = cms.PSet(
                        variables = cms.VPSet(),
                        weights = cms.FileInPath(str(iso_summary['morphing']['weights'])),
                        regression = cms.bool(True),
                        classifier = cms.string('BDTG_{}_{}'.format("phoIso", subdet)),
                        regr_output_scaling = cms.string('x[0]*(%f)+(%f)' % (iso_summary['morphing']['scale'], iso_summary['morphing']['center']))
                    )
                )
        )
        phoIso_corrector_config = getattr(flashggDifferentialPhoIdInputsCorrection, 'phoIso_corrector_config_'+subdet)
        cfgTools.addVariables(phoIso_corrector_config.clf_data.variables, [str(x) for x in iso_summary['peak_tail_clfs']['variables']])
        cfgTools.addVariables(phoIso_corrector_config.clf_mc.variables, [str(x) for x in iso_summary['peak_tail_clfs']['variables']])
        cfgTools.addVariables(phoIso_corrector_config.peak2tail.variables, [str(x) for x in iso_summary['peak2tail']['variables']])
        cfgTools.addVariables(phoIso_corrector_config.morphing.variables, [str(x) for x in iso_summary['morphing']['variables']])    

        #-charged isolations
        iso_summary = corrections_summary['isolations']['chIso'][subdet]
        setattr(flashggDifferentialPhoIdInputsCorrection, 'chIso_corrector_config_'+subdet, 
                cms.PSet(
                    clf_data = cms.PSet(
                        variables = cms.VPSet(),
                        weights = cms.FileInPath(str(iso_summary['peak_tail_clfs']['weights_data'])),
                        multiclass = cms.bool(True),
                        classifier = cms.string('BDTG_{}_{}_3Cat_data'.format("chIso", subdet))
                    ),
                    clf_mc = cms.PSet(
                        variables = cms.VPSet(),
                        weights = cms.FileInPath(str(iso_summary['peak_tail_clfs']['weights_mc'])),
                        multiclass = cms.bool(True),
                        classifier = cms.string('BDTG_{}_{}_3Cat_mc'.format("chIso", subdet))
                    ),
                    chIso_peak2tail = cms.PSet(
                        variables = cms.VPSet(),
                        weights = cms.FileInPath(str(iso_summary['chIso_peak2tail']['weights'])),
                        regression = cms.bool(True),
                        classifier = cms.string('BDTG_{}_{}_p2t'.format("chIso", subdet))
                    ),
                    chIso_morphing = cms.PSet(
                        variables = cms.VPSet(),
                        weights = cms.FileInPath(str(iso_summary['chIso_morphing']['weights'])),
                        classifier = cms.string('BDTG_{}_{}'.format("chIso", subdet)),
                        regression = cms.bool(True),
                        regr_output_scaling = cms.string('x[0]*(%f)+(%f)' % (iso_summary['chIso_morphing']['scale'], 
                                                                             iso_summary['chIso_morphing']['center']))
                    ),
                    chIsoWorst_peak2tail = cms.PSet(
                        variables = cms.VPSet(),
                        weights = cms.FileInPath(str(iso_summary['chIsoWorst_peak2tail']['weights'])),
                        regression = cms.bool(True),
                        classifier = cms.string('BDTG_{}_{}_p2t'.format("chIsoWorst", subdet))
                    ),
                    chIsoWorst_morphing = cms.PSet(
                        variables = cms.VPSet(),
                        weights = cms.FileInPath(str(iso_summary['chIsoWorst_morphing']['weights'])),
                        classifier = cms.string('BDTG_{}_{}'.format("chIsoWorst", subdet)),
                        regression = cms.bool(True),
                        regr_output_scaling = cms.string('x[0]*(%f)+(%f)' % (iso_summary['chIsoWorst_morphing']['scale'], 
                                                                             iso_summary['chIsoWorst_morphing']['center']))
                    )
                )
            )
        chIso_corrector_config = getattr(flashggDifferentialPhoIdInputsCorrection, 'chIso_corrector_config_'+subdet)
        cfgTools.addVariables(chIso_corrector_config.clf_data.variables, [str(x) for x in iso_summary['peak_tail_clfs']['variables']])
        cfgTools.addVariables(chIso_corrector_config.clf_mc.variables, [str(x) for x in iso_summary['peak_tail_clfs']['variables']])
        cfgTools.addVariables(chIso_corrector_config.chIso_peak2tail.variables, [str(x) for x in iso_summary['chIso_peak2tail']['variables']])
        cfgTools.addVariables(chIso_corrector_config.chIso_morphing.variables, [str(x) for x in iso_summary['chIso_morphing']['variables']])    
        cfgTools.addVariables(chIso_corrector_config.chIsoWorst_peak2tail.variables, [str(x) for x in iso_summary['chIsoWorst_peak2tail']['variables']])
        cfgTools.addVariables(chIso_corrector_config.chIsoWorst_morphing.variables, [str(x) for x in iso_summary['chIsoWorst_morphing']['variables']])    
示例#5
0
import flashgg.Taggers.dumperConfigTools as cfgTools

cShapeMVA_EB = cms.PSet(
    variables=cms.VPSet(),
    classifier=cms.string("BDTCShape_EB"),
    weights=cms.FileInPath("diphotons/Analysis/data/TMVAClassification_BDTCShape_EB.weights.xml")
    ## classifier=cms.string("BDTCShape_test_EB"),
    ## weights=cms.FileInPath("diphotons/Analysis/data/TMVAClassification_BDTCShape_test_EB.weights.xml")
    )

cShapeMVA_EE = cms.PSet(
    variables=cms.VPSet(),
    classifier=cms.string("BDTCShape_EE"),
    weights=cms.FileInPath("diphotons/Analysis/data/TMVAClassification_BDTCShape_EE.weights.xml")
    ## classifier=cms.string("BDTCShape_test_EE"),
    ## weights=cms.FileInPath("diphotons/Analysis/data/TMVAClassification_BDTCShape_test_EE.weights.xml")
    )

variables = ["full5x5_sigmaIetaIeta","etaWidth := superCluster.etaWidth","phiWidth := superCluster.phiWidth",
             "covarianceIetaIphi := sieip","r9","scEta := superCluster.eta","pt", "s4"
             "hadronicOverEm"
             ]

## variables = ["full5x5_sigmaIetaIeta","etaWidth := superCluster.etaWidth","phiWidth := superCluster.phiWidth",
##              "covarianceIetaIphi := sieip","r9","scEta := superCluster.eta","scRawEnergy := superCluster.rawEnergy","hadronicOverEm"
##              ]

cfgTools.addVariables(cShapeMVA_EB.variables,variables)
cfgTools.addVariables(cShapeMVA_EE.variables,variables)