Example #1
0
    def runTauID(self, name='NewTauIDsEmbedded'):
        self.process.rerunMvaIsolationSequence = self.cms.Sequence()
        tauIDSources = self.cms.PSet()

        # rerun the seq to obtain the 2017 nom training with 0.5 iso cone, old DM, ptph>1, trained on 2017MCv1
        if "2017v1" in self.toKeep:
            self.tauIdDiscrMVA_2017_version = "v1"
            self.tauIdDiscrMVA_trainings_run2_2017 = {
                'tauIdMVAIsoDBoldDMwLT2017': "tauIdMVAIsoDBoldDMwLT2017",
            }
            self.tauIdDiscrMVA_WPs_run2_2017 = {
                'tauIdMVAIsoDBoldDMwLT2017': {
                    'Eff95': "DBoldDMwLTEff95",
                    'Eff90': "DBoldDMwLTEff90",
                    'Eff80': "DBoldDMwLTEff80",
                    'Eff70': "DBoldDMwLTEff70",
                    'Eff60': "DBoldDMwLTEff60",
                    'Eff50': "DBoldDMwLTEff50",
                    'Eff40': "DBoldDMwLTEff40"
                }
            }
            # update the list of available in DB samples
            if not self.is_above_cmssw_version(11, 0, 0, self.debug):
                if self.debug:
                    print "runTauID: not is_above_cmssw_version(10, 0, 0). Will update the list of available in DB samples to access 2017v1"
                self.loadMVA_WPs_run2_2017()

            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1raw = patDiscriminationByIsolationMVArun2v1raw.clone(
                PATTauProducer=self.cms.InputTag('slimmedTaus'),
                Prediscriminants=noPrediscriminants,
                loadMVAfromDB=self.cms.bool(True),
                mvaName=self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1"
                ),  #RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1 writeTauIdDiscrMVAs
                mvaOpt=self.cms.string("DBoldDMwLTwGJ"),
                #requireDecayMode = self.cms.bool(True),
                verbosity=self.cms.int32(0))

            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose = patDiscriminationByIsolationMVArun2v1VLoose.clone(
                PATTauProducer=self.cms.InputTag('slimmedTaus'),
                Prediscriminants=noPrediscriminants,
                toMultiplex=self.cms.InputTag(
                    'rerunDiscriminationByIsolationOldDMMVArun2017v1raw'),
                key=self.cms.InputTag(
                    'rerunDiscriminationByIsolationOldDMMVArun2017v1raw:category'
                ),  #?
                loadMVAfromDB=self.cms.bool(True),
                mvaOutput_normalization=self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_mvaOutput_normalization"
                ),  #writeTauIdDiscrMVAoutputNormalizations
                mapping=self.cms.VPSet(
                    self.cms.PSet(
                        category=self.cms.uint32(0),
                        cut=self.cms.string(
                            "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_WPEff90"
                        ),  #writeTauIdDiscrWPs
                        variable=self.cms.string("pt"),
                    )))

            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VVLoose = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VVLoose.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_WPEff95")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1Loose = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1Loose.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_WPEff80")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1Medium = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1Medium.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_WPEff70")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1Tight = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1Tight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_WPEff60")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VTight = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VTight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_WPEff50")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VVTight = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VVTight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_WPEff40")

            self.process.rerunMvaIsolationSequence += self.cms.Sequence(
                self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1raw
                * self.process.
                rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose *
                self.process.
                rerunDiscriminationByIsolationOldDMMVArun2017v1VVLoose * self.
                process.rerunDiscriminationByIsolationOldDMMVArun2017v1Loose *
                self.process.
                rerunDiscriminationByIsolationOldDMMVArun2017v1Medium * self.
                process.rerunDiscriminationByIsolationOldDMMVArun2017v1Tight *
                self.process.
                rerunDiscriminationByIsolationOldDMMVArun2017v1VTight * self.
                process.rerunDiscriminationByIsolationOldDMMVArun2017v1VVTight)

            tauIDSources.byIsolationMVArun2017v1DBoldDMwLTraw2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v1raw')
            tauIDSources.byVVLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v1VVLoose')
            tauIDSources.byVLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose')
            tauIDSources.byLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v1Loose')
            tauIDSources.byMediumIsolationMVArun2017v1DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v1Medium')
            tauIDSources.byTightIsolationMVArun2017v1DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v1Tight')
            tauIDSources.byVTightIsolationMVArun2017v1DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v1VTight')
            tauIDSources.byVVTightIsolationMVArun2017v1DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v1VVTight')

        if "2017v2" in self.toKeep:
            self.tauIdDiscrMVA_2017_version = "v2"
            self.tauIdDiscrMVA_trainings_run2_2017 = {
                'tauIdMVAIsoDBoldDMwLT2017': "tauIdMVAIsoDBoldDMwLT2017",
            }
            self.tauIdDiscrMVA_WPs_run2_2017 = {
                'tauIdMVAIsoDBoldDMwLT2017': {
                    'Eff95': "DBoldDMwLTEff95",
                    'Eff90': "DBoldDMwLTEff90",
                    'Eff80': "DBoldDMwLTEff80",
                    'Eff70': "DBoldDMwLTEff70",
                    'Eff60': "DBoldDMwLTEff60",
                    'Eff50': "DBoldDMwLTEff50",
                    'Eff40': "DBoldDMwLTEff40"
                }
            }

            if self.debug:
                print "runTauID: not is_above_cmssw_version(10, 0, 0). Will update the list of available in DB samples to access 2017v2"
            self.loadMVA_WPs_run2_2017()

            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2raw = patDiscriminationByIsolationMVArun2v1raw.clone(
                PATTauProducer=self.cms.InputTag('slimmedTaus'),
                Prediscriminants=noPrediscriminants,
                loadMVAfromDB=self.cms.bool(True),
                mvaName=self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2"
                ),  #RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1 writeTauIdDiscrMVAs
                mvaOpt=self.cms.string("DBoldDMwLTwGJ"),
                #requireDecayMode = self.cms.bool(True),
                verbosity=self.cms.int32(0))

            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose = patDiscriminationByIsolationMVArun2v1VLoose.clone(
                PATTauProducer=self.cms.InputTag('slimmedTaus'),
                Prediscriminants=noPrediscriminants,
                toMultiplex=self.cms.InputTag(
                    'rerunDiscriminationByIsolationOldDMMVArun2017v2raw'),
                key=self.cms.InputTag(
                    'rerunDiscriminationByIsolationOldDMMVArun2017v2raw:category'
                ),  #?
                loadMVAfromDB=self.cms.bool(True),
                mvaOutput_normalization=self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_mvaOutput_normalization"
                ),  #writeTauIdDiscrMVAoutputNormalizations
                mapping=self.cms.VPSet(
                    self.cms.PSet(
                        category=self.cms.uint32(0),
                        cut=self.cms.string(
                            "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff90"
                        ),  #writeTauIdDiscrWPs
                        variable=self.cms.string("pt"),
                    )),
                verbosity=self.cms.int32(0))

            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VVLoose = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VVLoose.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff95")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Loose = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Loose.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff80")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Medium = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Medium.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff70")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Tight = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Tight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff60")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VTight = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VTight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff50")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VVTight = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VVTight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff40")

            self.process.rerunMvaIsolationSequence += self.cms.Sequence(
                self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2raw
                * self.process.
                rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose *
                self.process.
                rerunDiscriminationByIsolationOldDMMVArun2017v2VVLoose * self.
                process.rerunDiscriminationByIsolationOldDMMVArun2017v2Loose *
                self.process.
                rerunDiscriminationByIsolationOldDMMVArun2017v2Medium * self.
                process.rerunDiscriminationByIsolationOldDMMVArun2017v2Tight *
                self.process.
                rerunDiscriminationByIsolationOldDMMVArun2017v2VTight * self.
                process.rerunDiscriminationByIsolationOldDMMVArun2017v2VVTight)

            tauIDSources.byIsolationMVArun2017v2DBoldDMwLTraw2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v2raw')
            tauIDSources.byVVLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v2VVLoose')
            tauIDSources.byVLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose')
            tauIDSources.byLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v2Loose')
            tauIDSources.byMediumIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v2Medium')
            tauIDSources.byTightIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v2Tight')
            tauIDSources.byVTightIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v2VTight')
            tauIDSources.byVVTightIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v2VVTight')

        if "newDM2017v2" in self.toKeep:
            self.tauIdDiscrMVA_2017_version = "v2"
            self.tauIdDiscrMVA_trainings_run2_2017 = {
                'tauIdMVAIsoDBnewDMwLT2017': "tauIdMVAIsoDBnewDMwLT2017",
            }
            self.tauIdDiscrMVA_WPs_run2_2017 = {
                'tauIdMVAIsoDBnewDMwLT2017': {
                    'Eff95': "DBnewDMwLTEff95",
                    'Eff90': "DBnewDMwLTEff90",
                    'Eff80': "DBnewDMwLTEff80",
                    'Eff70': "DBnewDMwLTEff70",
                    'Eff60': "DBnewDMwLTEff60",
                    'Eff50': "DBnewDMwLTEff50",
                    'Eff40': "DBnewDMwLTEff40"
                }
            }

            if self.debug:
                print "runTauID: not is_above_cmssw_version(10, 0, 0). Will update the list of available in DB samples to access newDM2017v2"
            self.loadMVA_WPs_run2_2017()

            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2raw = patDiscriminationByIsolationMVArun2v1raw.clone(
                PATTauProducer=self.cms.InputTag('slimmedTaus'),
                Prediscriminants=noPrediscriminants,
                loadMVAfromDB=self.cms.bool(True),
                mvaName=self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2"
                ),  #RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1 writeTauIdDiscrMVAs
                mvaOpt=self.cms.string("DBnewDMwLTwGJ"),
                #requireDecayMode = self.cms.bool(True),
                verbosity=self.cms.int32(0))

            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose = patDiscriminationByIsolationMVArun2v1VLoose.clone(
                PATTauProducer=self.cms.InputTag('slimmedTaus'),
                Prediscriminants=noPrediscriminants,
                toMultiplex=self.cms.InputTag(
                    'rerunDiscriminationByIsolationNewDMMVArun2017v2raw'),
                key=self.cms.InputTag(
                    'rerunDiscriminationByIsolationNewDMMVArun2017v2raw:category'
                ),  #?
                loadMVAfromDB=self.cms.bool(True),
                mvaOutput_normalization=self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_mvaOutput_normalization"
                ),  #writeTauIdDiscrMVAoutputNormalizations
                mapping=self.cms.VPSet(
                    self.cms.PSet(
                        category=self.cms.uint32(0),
                        cut=self.cms.string(
                            "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff90"
                        ),  #writeTauIdDiscrWPs
                        variable=self.cms.string("pt"),
                    )),
                verbosity=self.cms.int32(0))

            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VVLoose = self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VVLoose.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff95")
            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2Loose = self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2Loose.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff80")
            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2Medium = self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2Medium.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff70")
            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2Tight = self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2Tight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff60")
            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VTight = self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VTight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff50")
            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VVTight = self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VVTight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff40")

            self.process.rerunMvaIsolationSequence += self.cms.Sequence(
                self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2raw
                * self.process.
                rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose *
                self.process.
                rerunDiscriminationByIsolationNewDMMVArun2017v2VVLoose * self.
                process.rerunDiscriminationByIsolationNewDMMVArun2017v2Loose *
                self.process.
                rerunDiscriminationByIsolationNewDMMVArun2017v2Medium * self.
                process.rerunDiscriminationByIsolationNewDMMVArun2017v2Tight *
                self.process.
                rerunDiscriminationByIsolationNewDMMVArun2017v2VTight * self.
                process.rerunDiscriminationByIsolationNewDMMVArun2017v2VVTight)

            tauIDSources.byIsolationMVArun2017v2DBnewDMwLTraw2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2017v2raw')
            tauIDSources.byVVLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2017v2VVLoose')
            tauIDSources.byVLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose')
            tauIDSources.byLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2017v2Loose')
            tauIDSources.byMediumIsolationMVArun2017v2DBnewDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2017v2Medium')
            tauIDSources.byTightIsolationMVArun2017v2DBnewDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2017v2Tight')
            tauIDSources.byVTightIsolationMVArun2017v2DBnewDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2017v2VTight')
            tauIDSources.byVVTightIsolationMVArun2017v2DBnewDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2017v2VVTight')

        if "dR0p32017v2" in self.toKeep:
            self.tauIdDiscrMVA_2017_version = "v2"
            self.tauIdDiscrMVA_trainings_run2_2017 = {
                'tauIdMVAIsoDBoldDMdR0p3wLT2017':
                "tauIdMVAIsoDBoldDMdR0p3wLT2017",
            }
            self.tauIdDiscrMVA_WPs_run2_2017 = {
                'tauIdMVAIsoDBoldDMdR0p3wLT2017': {
                    'Eff95': "DBoldDMdR0p3wLTEff95",
                    'Eff90': "DBoldDMdR0p3wLTEff90",
                    'Eff80': "DBoldDMdR0p3wLTEff80",
                    'Eff70': "DBoldDMdR0p3wLTEff70",
                    'Eff60': "DBoldDMdR0p3wLTEff60",
                    'Eff50': "DBoldDMdR0p3wLTEff50",
                    'Eff40': "DBoldDMdR0p3wLTEff40"
                }
            }

            if self.debug:
                print "runTauID: not is_above_cmssw_version(10, 0, 0). Will update the list of available in DB samples to access dR0p32017v2"
            self.loadMVA_WPs_run2_2017()

            self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2raw = patDiscriminationByIsolationMVArun2v1raw.clone(
                PATTauProducer=self.cms.InputTag('slimmedTaus'),
                Prediscriminants=noPrediscriminants,
                loadMVAfromDB=self.cms.bool(True),
                mvaName=self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2"),
                mvaOpt=self.cms.string("DBoldDMwLTwGJ"),
                #requireDecayMode = self.cms.bool(True),
                srcChargedIsoPtSum=self.cms.string('chargedIsoPtSumdR03'),
                srcFootprintCorrection=self.cms.string(
                    'footprintCorrectiondR03'),
                srcNeutralIsoPtSum=self.cms.string('neutralIsoPtSumdR03'),
                srcPhotonPtSumOutsideSignalCone=self.cms.string(
                    'photonPtSumOutsideSignalConedR03'),
                verbosity=self.cms.int32(0))

            self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VLoose = patDiscriminationByIsolationMVArun2v1VLoose.clone(
                PATTauProducer=self.cms.InputTag('slimmedTaus'),
                Prediscriminants=noPrediscriminants,
                toMultiplex=self.cms.InputTag(
                    'rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2raw'),
                key=self.cms.InputTag(
                    'rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2raw:category'
                ),  #?
                loadMVAfromDB=self.cms.bool(True),
                mvaOutput_normalization=self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_mvaOutput_normalization"
                ),  #writeTauIdDiscrMVAoutputNormalizations
                mapping=self.cms.VPSet(
                    self.cms.PSet(
                        category=self.cms.uint32(0),
                        cut=self.cms.string(
                            "RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_WPEff90"
                        ),  #writeTauIdDiscrWPs
                        variable=self.cms.string("pt"),
                    )),
                verbosity=self.cms.int32(0))

            self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VVLoose = self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VVLoose.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_WPEff95")
            self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2Loose = self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2Loose.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_WPEff80")
            self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2Medium = self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2Medium.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_WPEff70")
            self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2Tight = self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2Tight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_WPEff60")
            self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VTight = self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VTight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_WPEff50")
            self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VVTight = self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VVTight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_WPEff40")

            self.process.rerunMvaIsolationSequence += self.cms.Sequence(
                self.process.
                rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2raw *
                self.process.
                rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VLoose *
                self.process.
                rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VVLoose *
                self.process.
                rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2Loose *
                self.process.
                rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2Medium *
                self.process.
                rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2Tight *
                self.process.
                rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VTight *
                self.process.
                rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VVTight)

            tauIDSources.byIsolationMVArun2017v2DBoldDMdR0p3wLTraw2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2raw')
            tauIDSources.byVVLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VVLoose')
            tauIDSources.byVLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VLoose')
            tauIDSources.byLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2Loose')
            tauIDSources.byMediumIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2Medium')
            tauIDSources.byTightIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2Tight')
            tauIDSources.byVTightIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VTight')
            tauIDSources.byVVTightIsolationMVArun2017v2DBoldDMdR0p3wLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMdR0p3MVArun2017v2VVTight')

        # 2016 training strategy(v2) - essentially the same as 2017 training strategy (v1), trained on 2016MC, old DM - currently not implemented in the tau sequence of any release
        # self.process.rerunDiscriminationByIsolationOldDMMVArun2v2raw = patDiscriminationByIsolationMVArun2v1raw.clone(
        #     PATTauProducer = self.cms.InputTag('slimmedTaus'),
        #     Prediscriminants = noPrediscriminants,
        #     loadMVAfromDB = self.cms.bool(True),
        #     mvaName = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v2"),#RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1 writeTauIdDiscrMVAs
        #     mvaOpt = self.cms.string("DBoldDMwLTwGJ"),
        #     requireDecayMode = self.cms.bool(True),
        #     verbosity = self.cms.int32(0)
        # )
        # #
        # self.process.rerunDiscriminationByIsolationOldDMMVArun2v2VLoose = patDiscriminationByIsolationMVArun2v1VLoose.clone(
        #     PATTauProducer = self.cms.InputTag('slimmedTaus'),
        #     Prediscriminants = noPrediscriminants,
        #     toMultiplex = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2v2raw'),
        #     key = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2v2raw:category'),#?
        #     loadMVAfromDB = self.cms.bool(True),
        #     mvaOutput_normalization = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v2_mvaOutput_normalization"), #writeTauIdDiscrMVAoutputNormalizations
        #     mapping = self.cms.VPSet(
        #         self.cms.PSet(
        #             category = self.cms.uint32(0),
        #             cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v2_WPEff90"), #writeTauIdDiscrWPs
        #             variable = self.cms.string("pt"),
        #         )
        #     )
        # )

        # 2016 training strategy(v1), trained on 2016MC, old DM
        if "2016v1" in self.toKeep:
            self.process.rerunDiscriminationByIsolationOldDMMVArun2v1raw = patDiscriminationByIsolationMVArun2v1raw.clone(
                PATTauProducer=self.cms.InputTag('slimmedTaus'),
                Prediscriminants=noPrediscriminants,
                loadMVAfromDB=self.cms.bool(True),
                mvaName=self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1"),
                mvaOpt=self.cms.string("DBoldDMwLT"),
                #requireDecayMode = self.cms.bool(True),
                verbosity=self.cms.int32(0))

            self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VLoose = patDiscriminationByIsolationMVArun2v1VLoose.clone(
                PATTauProducer=self.cms.InputTag('slimmedTaus'),
                Prediscriminants=noPrediscriminants,
                toMultiplex=self.cms.InputTag(
                    'rerunDiscriminationByIsolationOldDMMVArun2v1raw'),
                key=self.cms.InputTag(
                    'rerunDiscriminationByIsolationOldDMMVArun2v1raw:category'
                ),
                loadMVAfromDB=self.cms.bool(True),
                mvaOutput_normalization=self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_mvaOutput_normalization"
                ),
                mapping=self.cms.VPSet(
                    self.cms.PSet(
                        category=self.cms.uint32(0),
                        cut=self.cms.string(
                            "RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff90"),
                        variable=self.cms.string("pt"),
                    )))

            self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Loose = self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Loose.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff80")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Medium = self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Medium.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff70")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Tight = self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Tight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff60")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VTight = self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VTight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff50")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VVTight = self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VVTight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff40")

            self.process.rerunMvaIsolationSequence += self.cms.Sequence(
                self.process.rerunDiscriminationByIsolationOldDMMVArun2v1raw *
                self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VLoose
                *
                self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Loose
                *
                self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Medium
                *
                self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Tight
                *
                self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VTight
                * self.process.
                rerunDiscriminationByIsolationOldDMMVArun2v1VVTight)

            tauIDSources.byIsolationMVArun2v1DBoldDMwLTraw2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2v1raw')
            tauIDSources.byVLooseIsolationMVArun2v1DBoldDMwLT2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2v1VLoose')
            tauIDSources.byLooseIsolationMVArun2v1DBoldDMwLT2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2v1Loose')
            tauIDSources.byMediumIsolationMVArun2v1DBoldDMwLT2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2v1Medium')
            tauIDSources.byTightIsolationMVArun2v1DBoldDMwLT2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2v1Tight')
            tauIDSources.byVTightIsolationMVArun2v1DBoldDMwLT2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2v1VTight')
            tauIDSources.byVVTightIsolationMVArun2v1DBoldDMwLT2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2v1VVTight')

        # 2016 training strategy(v1), trained on 2016MC, new DM
        if "newDM2016v1" in self.toKeep:
            self.process.rerunDiscriminationByIsolationNewDMMVArun2v1raw = patDiscriminationByIsolationMVArun2v1raw.clone(
                PATTauProducer=self.cms.InputTag('slimmedTaus'),
                Prediscriminants=noPrediscriminants,
                loadMVAfromDB=self.cms.bool(True),
                mvaName=self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1"),
                mvaOpt=self.cms.string("DBnewDMwLT"),
                #requireDecayMode = self.cms.bool(True),
                verbosity=self.cms.int32(0))

            self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VLoose = patDiscriminationByIsolationMVArun2v1VLoose.clone(
                PATTauProducer=self.cms.InputTag('slimmedTaus'),
                Prediscriminants=noPrediscriminants,
                toMultiplex=self.cms.InputTag(
                    'rerunDiscriminationByIsolationNewDMMVArun2v1raw'),
                key=self.cms.InputTag(
                    'rerunDiscriminationByIsolationNewDMMVArun2v1raw:category'
                ),
                loadMVAfromDB=self.cms.bool(True),
                mvaOutput_normalization=self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_mvaOutput_normalization"
                ),
                mapping=self.cms.VPSet(
                    self.cms.PSet(
                        category=self.cms.uint32(0),
                        cut=self.cms.string(
                            "RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_WPEff90"),
                        variable=self.cms.string("pt"),
                    )))

            self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Loose = self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Loose.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_WPEff80")
            self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Medium = self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Medium.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_WPEff70")
            self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Tight = self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Tight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_WPEff60")
            self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VTight = self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VTight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_WPEff50")
            self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VVTight = self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VVTight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_WPEff40")

            self.process.rerunMvaIsolationSequence += self.cms.Sequence(
                self.process.rerunDiscriminationByIsolationNewDMMVArun2v1raw *
                self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VLoose
                *
                self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Loose
                *
                self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Medium
                *
                self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Tight
                *
                self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VTight
                * self.process.
                rerunDiscriminationByIsolationNewDMMVArun2v1VVTight)

            tauIDSources.byIsolationMVArun2v1DBnewDMwLTraw2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2v1raw')
            tauIDSources.byVLooseIsolationMVArun2v1DBnewDMwLT2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2v1VLoose')
            tauIDSources.byLooseIsolationMVArun2v1DBnewDMwLT2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2v1Loose')
            tauIDSources.byMediumIsolationMVArun2v1DBnewDMwLT2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2v1Medium')
            tauIDSources.byTightIsolationMVArun2v1DBnewDMwLT2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2v1Tight')
            tauIDSources.byVTightIsolationMVArun2v1DBnewDMwLT2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2v1VTight')
            tauIDSources.byVVTightIsolationMVArun2v1DBnewDMwLT2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2v1VVTight')

        embedID = self.cms.EDProducer("PATTauIDEmbedder",
                                      src=self.cms.InputTag('slimmedTaus'),
                                      tauIDSources=tauIDSources)
        self.process.NewTauIDsEmbedded = embedID
Example #2
0
    def runTauID(self, name='slimmedTausNewID'):
        self.process.rerunMvaIsolationSequence = self.cms.Sequence()
        tauIDSources = self.cms.PSet()

        # rerun the seq to obtain the 2017 nom training with 0.5 iso cone, old DM, ptph>1, trained on 2017MCv1
        if "2017v1" in self.toKeep:
            self.tauIdDiscrMVA_2017_version = "v1"
            self.tauIdDiscrMVA_trainings_run2_2017 = {
                'tauIdMVAIsoDBoldDMwLT2017': "tauIdMVAIsoDBoldDMwLT2017",
            }
            self.tauIdDiscrMVA_WPs_run2_2017 = {
                'tauIdMVAIsoDBoldDMwLT2017': {
                    'Eff95': "DBoldDMwLTEff95",
                    'Eff90': "DBoldDMwLTEff90",
                    'Eff80': "DBoldDMwLTEff80",
                    'Eff70': "DBoldDMwLTEff70",
                    'Eff60': "DBoldDMwLTEff60",
                    'Eff50': "DBoldDMwLTEff50",
                    'Eff40': "DBoldDMwLTEff40"
                }
            }
            # update the list of available in DB samples
            if not self.is_above_cmssw_version(10, 0, 0, self.debug):
                if self.debug:
                    print "runTauID: not is_above_cmssw_version(10, 0, 0). Will update the list of available in DB samples to access 2017v1"
                self.loadMVA_WPs_run2_2017()

            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1raw = patDiscriminationByIsolationMVArun2v1raw.clone(
                PATTauProducer=self.cms.InputTag(
                    'slimmedTausMuonCleanedMedium'),
                #PATTauProducer = self.cms.InputTag('slimmedTaus'),
                Prediscriminants=noPrediscriminants,
                loadMVAfromDB=self.cms.bool(True),
                mvaName=self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1"
                ),  #RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1 writeTauIdDiscrMVAs
                mvaOpt=self.cms.string("DBoldDMwLTwGJ"),
                requireDecayMode=self.cms.bool(True),
                verbosity=self.cms.int32(0))

            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose = patDiscriminationByIsolationMVArun2v1VLoose.clone(
                PATTauProducer=self.cms.InputTag(
                    'slimmedTausMuonCleanedMedium'),
                #PATTauProducer = self.cms.InputTag('slimmedTaus'),
                Prediscriminants=noPrediscriminants,
                toMultiplex=self.cms.InputTag(
                    'rerunDiscriminationByIsolationOldDMMVArun2017v1raw'),
                key=self.cms.InputTag(
                    'rerunDiscriminationByIsolationOldDMMVArun2017v1raw:category'
                ),  #?
                loadMVAfromDB=self.cms.bool(True),
                mvaOutput_normalization=self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_mvaOutput_normalization"
                ),  #writeTauIdDiscrMVAoutputNormalizations
                mapping=self.cms.VPSet(
                    self.cms.PSet(
                        category=self.cms.uint32(0),
                        cut=self.cms.string(
                            "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_WPEff90"
                        ),  #writeTauIdDiscrWPs
                        variable=self.cms.string("pt"),
                    )))

            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VVLoose = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VVLoose.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_WPEff95")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1Loose = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1Loose.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_WPEff80")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1Medium = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1Medium.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_WPEff70")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1Tight = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1Tight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_WPEff60")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VTight = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VTight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_WPEff50")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VVTight = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1VVTight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_WPEff40")

            self.process.rerunMvaIsolationSequence += self.cms.Sequence(
                self.process.rerunDiscriminationByIsolationOldDMMVArun2017v1raw
                * self.process.
                rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose *
                self.process.
                rerunDiscriminationByIsolationOldDMMVArun2017v1VVLoose * self.
                process.rerunDiscriminationByIsolationOldDMMVArun2017v1Loose *
                self.process.
                rerunDiscriminationByIsolationOldDMMVArun2017v1Medium * self.
                process.rerunDiscriminationByIsolationOldDMMVArun2017v1Tight *
                self.process.
                rerunDiscriminationByIsolationOldDMMVArun2017v1VTight * self.
                process.rerunDiscriminationByIsolationOldDMMVArun2017v1VVTight)

            tauIDSources.byIsolationMVArun2017v1DBoldDMwLTraw2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v1raw')
            tauIDSources.byVVLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v1VVLoose')
            tauIDSources.byVLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v1VLoose')
            tauIDSources.byLooseIsolationMVArun2017v1DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v1Loose')
            tauIDSources.byMediumIsolationMVArun2017v1DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v1Medium')
            tauIDSources.byTightIsolationMVArun2017v1DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v1Tight')
            tauIDSources.byVTightIsolationMVArun2017v1DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v1VTight')
            tauIDSources.byVVTightIsolationMVArun2017v1DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v1VVTight')

        if "2017v2" in self.toKeep:
            self.tauIdDiscrMVA_2017_version = "v2"
            self.tauIdDiscrMVA_trainings_run2_2017 = {
                'tauIdMVAIsoDBoldDMwLT2017': "tauIdMVAIsoDBoldDMwLT2017",
            }
            self.tauIdDiscrMVA_WPs_run2_2017 = {
                'tauIdMVAIsoDBoldDMwLT2017': {
                    'Eff95': "DBoldDMwLTEff95",
                    'Eff90': "DBoldDMwLTEff90",
                    'Eff80': "DBoldDMwLTEff80",
                    'Eff70': "DBoldDMwLTEff70",
                    'Eff60': "DBoldDMwLTEff60",
                    'Eff50': "DBoldDMwLTEff50",
                    'Eff40': "DBoldDMwLTEff40"
                }
            }

            if self.debug:
                print "runTauID: not is_above_cmssw_version(10, 0, 0). Will update the list of available in DB samples to access 2017v2"
            self.loadMVA_WPs_run2_2017()

            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2raw = patDiscriminationByIsolationMVArun2v1raw.clone(
                PATTauProducer=self.cms.InputTag(
                    'slimmedTausMuonCleanedMedium'),
                #PATTauProducer = self.cms.InputTag('slimmedTaus'),
                Prediscriminants=noPrediscriminants,
                loadMVAfromDB=self.cms.bool(True),
                mvaName=self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2"
                ),  #RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1 writeTauIdDiscrMVAs
                mvaOpt=self.cms.string("DBoldDMwLTwGJ"),
                requireDecayMode=self.cms.bool(True),
                verbosity=self.cms.int32(0))

            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose = patDiscriminationByIsolationMVArun2v1VLoose.clone(
                PATTauProducer=self.cms.InputTag(
                    'slimmedTausMuonCleanedMedium'),
                #PATTauProducer = self.cms.InputTag('slimmedTaus'),
                Prediscriminants=noPrediscriminants,
                toMultiplex=self.cms.InputTag(
                    'rerunDiscriminationByIsolationOldDMMVArun2017v2raw'),
                key=self.cms.InputTag(
                    'rerunDiscriminationByIsolationOldDMMVArun2017v2raw:category'
                ),  #?
                loadMVAfromDB=self.cms.bool(True),
                mvaOutput_normalization=self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_mvaOutput_normalization"
                ),  #writeTauIdDiscrMVAoutputNormalizations
                mapping=self.cms.VPSet(
                    self.cms.PSet(
                        category=self.cms.uint32(0),
                        cut=self.cms.string(
                            "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff90"
                        ),  #writeTauIdDiscrWPs
                        variable=self.cms.string("pt"),
                    )),
                verbosity=self.cms.int32(0))

            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VVLoose = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VVLoose.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff95")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Loose = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Loose.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff80")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Medium = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Medium.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff70")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Tight = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Tight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff60")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VTight = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VTight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff50")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VVTight = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VVTight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff40")

            self.process.rerunMvaIsolationSequence += self.cms.Sequence(
                self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2raw
                * self.process.
                rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose *
                self.process.
                rerunDiscriminationByIsolationOldDMMVArun2017v2VVLoose * self.
                process.rerunDiscriminationByIsolationOldDMMVArun2017v2Loose *
                self.process.
                rerunDiscriminationByIsolationOldDMMVArun2017v2Medium * self.
                process.rerunDiscriminationByIsolationOldDMMVArun2017v2Tight *
                self.process.
                rerunDiscriminationByIsolationOldDMMVArun2017v2VTight * self.
                process.rerunDiscriminationByIsolationOldDMMVArun2017v2VVTight)

            tauIDSources.byIsolationMVArun2017v2DBoldDMwLTraw2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v2raw')
            tauIDSources.byVVLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v2VVLoose')
            tauIDSources.byVLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose')
            tauIDSources.byLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v2Loose')
            tauIDSources.byMediumIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v2Medium')
            tauIDSources.byTightIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v2Tight')
            tauIDSources.byVTightIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v2VTight')
            tauIDSources.byVVTightIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2017v2VVTight')

        if "newDM2017v2" in self.toKeep:
            self.tauIdDiscrMVA_2017_version = "v2"
            self.tauIdDiscrMVA_trainings_run2_2017 = {
                'tauIdMVAIsoDBnewDMwLT2017': "tauIdMVAIsoDBnewDMwLT2017",
            }
            self.tauIdDiscrMVA_WPs_run2_2017 = {
                'tauIdMVAIsoDBnewDMwLT2017': {
                    'Eff95': "DBnewDMwLTEff95",
                    'Eff90': "DBnewDMwLTEff90",
                    'Eff80': "DBnewDMwLTEff80",
                    'Eff70': "DBnewDMwLTEff70",
                    'Eff60': "DBnewDMwLTEff60",
                    'Eff50': "DBnewDMwLTEff50",
                    'Eff40': "DBnewDMwLTEff40"
                }
            }

            if self.debug:
                print "runTauID: not is_above_cmssw_version(10, 0, 0). Will update the list of available in DB samples to access newDM2017v2"
            self.loadMVA_WPs_run2_2017()

            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2raw = patDiscriminationByIsolationMVArun2v1raw.clone(
                PATTauProducer=self.cms.InputTag(
                    'slimmedTausMuonCleanedMedium'),
                #PATTauProducer = self.cms.InputTag('slimmedTaus'),
                Prediscriminants=noPrediscriminants,
                loadMVAfromDB=self.cms.bool(True),
                mvaName=self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2"
                ),  #RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1 writeTauIdDiscrMVAs
                mvaOpt=self.cms.string("DBnewDMwLTwGJ"),
                requireDecayMode=self.cms.bool(True),
                verbosity=self.cms.int32(0))

            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose = patDiscriminationByIsolationMVArun2v1VLoose.clone(
                PATTauProducer=self.cms.InputTag(
                    'slimmedTausMuonCleanedMedium'),
                #PATTauProducer = self.cms.InputTag('slimmedTaus'),
                Prediscriminants=noPrediscriminants,
                toMultiplex=self.cms.InputTag(
                    'rerunDiscriminationByIsolationNewDMMVArun2017v2raw'),
                key=self.cms.InputTag(
                    'rerunDiscriminationByIsolationNewDMMVArun2017v2raw:category'
                ),  #?
                loadMVAfromDB=self.cms.bool(True),
                mvaOutput_normalization=self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_mvaOutput_normalization"
                ),  #writeTauIdDiscrMVAoutputNormalizations
                mapping=self.cms.VPSet(
                    self.cms.PSet(
                        category=self.cms.uint32(0),
                        cut=self.cms.string(
                            "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff90"
                        ),  #writeTauIdDiscrWPs
                        variable=self.cms.string("pt"),
                    )),
                verbosity=self.cms.int32(0))

            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VVLoose = self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VVLoose.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff95")
            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2Loose = self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2Loose.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff80")
            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2Medium = self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2Medium.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff70")
            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2Tight = self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2Tight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff60")
            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VTight = self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VTight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff50")
            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VVTight = self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2VVTight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff40")

            self.process.rerunMvaIsolationSequence += self.cms.Sequence(
                self.process.rerunDiscriminationByIsolationNewDMMVArun2017v2raw
                * self.process.
                rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose *
                self.process.
                rerunDiscriminationByIsolationNewDMMVArun2017v2VVLoose * self.
                process.rerunDiscriminationByIsolationNewDMMVArun2017v2Loose *
                self.process.
                rerunDiscriminationByIsolationNewDMMVArun2017v2Medium * self.
                process.rerunDiscriminationByIsolationNewDMMVArun2017v2Tight *
                self.process.
                rerunDiscriminationByIsolationNewDMMVArun2017v2VTight * self.
                process.rerunDiscriminationByIsolationNewDMMVArun2017v2VVTight)

            tauIDSources.byIsolationMVArun2017v2DBnewDMwLTraw2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2017v2raw')
            tauIDSources.byVVLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2017v2VVLoose')
            tauIDSources.byVLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2017v2VLoose')
            tauIDSources.byLooseIsolationMVArun2017v2DBnewDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2017v2Loose')
            tauIDSources.byMediumIsolationMVArun2017v2DBnewDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2017v2Medium')
            tauIDSources.byTightIsolationMVArun2017v2DBnewDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2017v2Tight')
            tauIDSources.byVTightIsolationMVArun2017v2DBnewDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2017v2VTight')
            tauIDSources.byVVTightIsolationMVArun2017v2DBnewDMwLT2017 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2017v2VVTight')

# 2016 training strategy(v1), trained on 2016MC, old DM
        if "2016v1" in self.toKeep:
            self.process.rerunDiscriminationByIsolationOldDMMVArun2v1raw = patDiscriminationByIsolationMVArun2v1raw.clone(
                PATTauProducer=self.cms.InputTag(
                    'slimmedTausMuonCleanedMedium'),
                #PATTauProducer = self.cms.InputTag('slimmedTaus'),
                Prediscriminants=noPrediscriminants,
                loadMVAfromDB=self.cms.bool(True),
                mvaName=self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1"),
                mvaOpt=self.cms.string("DBoldDMwLT"),
                requireDecayMode=self.cms.bool(True),
                verbosity=self.cms.int32(0))

            self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VLoose = patDiscriminationByIsolationMVArun2v1VLoose.clone(
                PATTauProducer=self.cms.InputTag(
                    'slimmedTausMuonCleanedMedium'),
                #PATTauProducer = self.cms.InputTag('slimmedTaus'),
                Prediscriminants=noPrediscriminants,
                toMultiplex=self.cms.InputTag(
                    'rerunDiscriminationByIsolationOldDMMVArun2v1raw'),
                key=self.cms.InputTag(
                    'rerunDiscriminationByIsolationOldDMMVArun2v1raw:category'
                ),
                loadMVAfromDB=self.cms.bool(True),
                mvaOutput_normalization=self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_mvaOutput_normalization"
                ),
                mapping=self.cms.VPSet(
                    self.cms.PSet(
                        category=self.cms.uint32(0),
                        cut=self.cms.string(
                            "RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff90"),
                        variable=self.cms.string("pt"),
                    )))

            self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Loose = self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Loose.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff80")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Medium = self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Medium.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff70")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Tight = self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Tight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff60")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VTight = self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VTight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff50")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VVTight = self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VVTight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff40")

            self.process.rerunMvaIsolationSequence += self.cms.Sequence(
                self.process.rerunDiscriminationByIsolationOldDMMVArun2v1raw *
                self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VLoose
                *
                self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Loose
                *
                self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Medium
                *
                self.process.rerunDiscriminationByIsolationOldDMMVArun2v1Tight
                *
                self.process.rerunDiscriminationByIsolationOldDMMVArun2v1VTight
                * self.process.
                rerunDiscriminationByIsolationOldDMMVArun2v1VVTight)

            tauIDSources.byIsolationMVArun2v1DBoldDMwLTraw2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2v1raw')
            tauIDSources.byVLooseIsolationMVArun2v1DBoldDMwLT2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2v1VLoose')
            tauIDSources.byLooseIsolationMVArun2v1DBoldDMwLT2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2v1Loose')
            tauIDSources.byMediumIsolationMVArun2v1DBoldDMwLT2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2v1Medium')
            tauIDSources.byTightIsolationMVArun2v1DBoldDMwLT2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2v1Tight')
            tauIDSources.byVTightIsolationMVArun2v1DBoldDMwLT2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2v1VTight')
            tauIDSources.byVVTightIsolationMVArun2v1DBoldDMwLT2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationOldDMMVArun2v1VVTight')

# 2016 training strategy(v1), trained on 2016MC, new DM
        if "newDM2016v1" in self.toKeep:
            self.process.rerunDiscriminationByIsolationNewDMMVArun2v1raw = patDiscriminationByIsolationMVArun2v1raw.clone(
                PATTauProducer=self.cms.InputTag(
                    'slimmedTausMuonCleanedMedium'),
                #PATTauProducer = self.cms.InputTag('slimmedTaus'),
                Prediscriminants=noPrediscriminants,
                loadMVAfromDB=self.cms.bool(True),
                mvaName=self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1"),
                mvaOpt=self.cms.string("DBnewDMwLT"),
                requireDecayMode=self.cms.bool(True),
                verbosity=self.cms.int32(0))

            self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VLoose = patDiscriminationByIsolationMVArun2v1VLoose.clone(
                PATTauProducer=self.cms.InputTag(
                    'slimmedTausMuonCleanedMedium'),
                #PATTauProducer = self.cms.InputTag('slimmedTaus'),
                Prediscriminants=noPrediscriminants,
                toMultiplex=self.cms.InputTag(
                    'rerunDiscriminationByIsolationNewDMMVArun2v1raw'),
                key=self.cms.InputTag(
                    'rerunDiscriminationByIsolationNewDMMVArun2v1raw:category'
                ),
                loadMVAfromDB=self.cms.bool(True),
                mvaOutput_normalization=self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_mvaOutput_normalization"
                ),
                mapping=self.cms.VPSet(
                    self.cms.PSet(
                        category=self.cms.uint32(0),
                        cut=self.cms.string(
                            "RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_WPEff90"),
                        variable=self.cms.string("pt"),
                    )))

            self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Loose = self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Loose.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_WPEff80")
            self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Medium = self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Medium.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_WPEff70")
            self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Tight = self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Tight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_WPEff60")
            self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VTight = self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VTight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_WPEff50")
            self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VVTight = self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VLoose.clone(
            )
            self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VVTight.mapping[
                0].cut = self.cms.string(
                    "RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1_WPEff40")

            self.process.rerunMvaIsolationSequence += self.cms.Sequence(
                self.process.rerunDiscriminationByIsolationNewDMMVArun2v1raw *
                self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VLoose
                *
                self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Loose
                *
                self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Medium
                *
                self.process.rerunDiscriminationByIsolationNewDMMVArun2v1Tight
                *
                self.process.rerunDiscriminationByIsolationNewDMMVArun2v1VTight
                * self.process.
                rerunDiscriminationByIsolationNewDMMVArun2v1VVTight)

            tauIDSources.byIsolationMVArun2v1DBnewDMwLTraw2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2v1raw')
            tauIDSources.byVLooseIsolationMVArun2v1DBnewDMwLT2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2v1VLoose')
            tauIDSources.byLooseIsolationMVArun2v1DBnewDMwLT2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2v1Loose')
            tauIDSources.byMediumIsolationMVArun2v1DBnewDMwLT2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2v1Medium')
            tauIDSources.byTightIsolationMVArun2v1DBnewDMwLT2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2v1Tight')
            tauIDSources.byVTightIsolationMVArun2v1DBnewDMwLT2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2v1VTight')
            tauIDSources.byVVTightIsolationMVArun2v1DBnewDMwLT2016 = self.cms.InputTag(
                'rerunDiscriminationByIsolationNewDMMVArun2v1VVTight')

        embedID = self.cms.EDProducer(
            "PATTauIDEmbedder",
            src=self.cms.InputTag('slimmedTausMuonCleanedMedium'),
            #src = self.cms.InputTag('slimmedTaus'),
            tauIDSources=tauIDSources)
        self.process.slimmedTausNewID = embedID
Example #3
0
rerunDiscriminationByIsolationMVAOldDMrun2v1VLoose.PATTauProducer = cms.InputTag('slimmedTaus')
rerunDiscriminationByIsolationMVAOldDMrun2v1VLoose.Prediscriminants = noPrediscriminants
rerunDiscriminationByIsolationMVAOldDMrun2v1VLoose.toMultiplex = cms.InputTag('rerunDiscriminationByIsolationMVAOldDMrun2v1raw')
rerunDiscriminationByIsolationMVAOldDMrun2v1VLoose.key = cms.InputTag('rerunDiscriminationByIsolationMVAOldDMrun2v1raw:category')
rerunDiscriminationByIsolationMVAOldDMrun2v1VLoose.loadMVAfromDB = cms.bool(True)
rerunDiscriminationByIsolationMVAOldDMrun2v1VLoose.mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_mvaOutput_normalization")
rerunDiscriminationByIsolationMVAOldDMrun2v1VLoose.mapping = cms.VPSet(
		cms.PSet(
			category = cms.uint32(0),
			cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff90"),
			variable = cms.string("pt"),
		)
	)

rerunDiscriminationByIsolationMVAOldDMrun2v1Loose = rerunDiscriminationByIsolationMVAOldDMrun2v1VLoose.clone()
rerunDiscriminationByIsolationMVAOldDMrun2v1Loose.mapping[0].cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff80")
rerunDiscriminationByIsolationMVAOldDMrun2v1Medium = rerunDiscriminationByIsolationMVAOldDMrun2v1VLoose.clone()
rerunDiscriminationByIsolationMVAOldDMrun2v1Medium.mapping[0].cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff70")
rerunDiscriminationByIsolationMVAOldDMrun2v1Tight = rerunDiscriminationByIsolationMVAOldDMrun2v1VLoose.clone()
rerunDiscriminationByIsolationMVAOldDMrun2v1Tight.mapping[0].cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff60")
rerunDiscriminationByIsolationMVAOldDMrun2v1VTight = rerunDiscriminationByIsolationMVAOldDMrun2v1VLoose.clone()
rerunDiscriminationByIsolationMVAOldDMrun2v1VTight.mapping[0].cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff50")
rerunDiscriminationByIsolationMVAOldDMrun2v1VVTight = rerunDiscriminationByIsolationMVAOldDMrun2v1VLoose.clone()
rerunDiscriminationByIsolationMVAOldDMrun2v1VVTight.mapping[0].cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff40")

# new ids for newDMs
rerunDiscriminationByIsolationMVANewDMrun2v1raw = rerunDiscriminationByIsolationMVAOldDMrun2v1raw.clone()
rerunDiscriminationByIsolationMVANewDMrun2v1raw.mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1")
rerunDiscriminationByIsolationMVANewDMrun2v1raw.mvaOpt = cms.string("DBnewDMwLT")
Example #4
0
def runTauID(process, outputTauCollection='slimmedTausNewID', inputTauCollection='slimmedTaus', isBoosted=False,
             toKeep=["deepTau2017v2p1"], debug=False):
    for discr in toKeep:
        if discr not in availableDiscriminators:
            raise RuntimeError('TauIDEmbedder: discriminator "{}" is not supported'.format(discr))

    process.load('RecoTauTag.Configuration.loadRecoTauTagMVAsFromPrepDB_cfi')

    setattr(process, outputTauCollection + 'rerunMvaIsolationTask', cms.Task())
    setattr(process, outputTauCollection + 'rerunMvaIsolationSequence', cms.Sequence())
    tauIDSources = cms.PSet()

    mva_discrs = {
        "2017v2": {
            "mvaName": "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2",
            "mvaOpt": "DBoldDMwLTwGJ",
            "mvaOutput_normalization": "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_mvaOutput_normalization",
            "rawName": "byIsolationMVArun2017v2DBoldDMwLTraw2017",
            "wpNamePattern": "by{}IsolationMVArun2017v2DBoldDMwLT2017",
            "reducedCone": False,
            "cut_dict": {
                "VVLoose": "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff95",
                "VLoose": "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff90",
                "Loose": "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff80",
                "Medium": "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff70",
                "Tight": "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff60",
                "VTight": "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff50",
                "VVTight": "RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff40",
            },
        },
        "newDM2017v2": {
            "mvaName": "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2",
            "mvaOpt": "DBnewDMwLTwGJ",
            "mvaOutput_normalization": "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_mvaOutput_normalization",
            "rawName": "byIsolationMVArun2017v2DBnewDMwLTraw2017",
            "wpNamePattern": "by{}IsolationMVArun2017v2DBnewDMwLT2017",
            "reducedCone": False,
            "cut_dict": {
                "VVLoose": "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff95",
                "VLoose": "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff90",
                "Loose": "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff80",
                "Medium": "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff70",
                "Tight": "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff60",
                "VTight": "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff50",
                "VVTight": "RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2_WPEff40",
            },
        },
        "dR0p32017v2": {
            "mvaName": "RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2",
            "mvaOpt": "DBoldDMwLTwGJ",
            "mvaOutput_normalization": "RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_mvaOutput_normalization",
            "rawName": "byIsolationMVArun2017v2DBoldDMdR0p3wLTraw2017",
            "wpNamePattern": "by{}IsolationMVArun2017v2DBoldDMdR0p3wLT2017",
            "reducedCone": True,
            "cut_dict": {
                "VVLoose": "RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_WPEff95",
                "VLoose": "RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_WPEff90",
                "Loose": "RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_WPEff80",
                "Medium": "RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_WPEff70",
                "Tight": "RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_WPEff60",
                "VTight": "RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_WPEff50",
                "VVTight": "RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2_WPEff40",
            },
        },
    }

    for discr_name, params in mva_discrs.items():
        if discr_name not in toKeep:
            continue

        if params["reducedCone"]:
            srcChargedIsoPtSum = 'chargedIsoPtSumdR03'
            srcNeutralIsoPtSum = 'neutralIsoPtSumdR03'
            srcFootprintCorrection = 'footprintCorrectiondR03'
            srcPhotonPtSumOutsideSignalCone = 'photonPtSumOutsideSignalConedR03'
        elif isBoosted:
            srcChargedIsoPtSum = 'chargedIsoPtSumNoOverLap'
            srcNeutralIsoPtSum = 'neutralIsoPtSumNoOverLap'
            srcFootprintCorrection = 'footprintCorrection'
            srcPhotonPtSumOutsideSignalCone = 'photonPtSumOutsideSignalCone'
        else:
            srcChargedIsoPtSum = 'chargedIsoPtSum'
            srcNeutralIsoPtSum = 'neutralIsoPtSum'
            srcFootprintCorrection = 'footprintCorrection'
            srcPhotonPtSumOutsideSignalCone = 'photonPtSumOutsideSignalCone'

        setattr(process, outputTauCollection + params["rawName"],
            patDiscriminationByIsolationMVArun2v1raw.clone(
                PATTauProducer = cms.InputTag(inputTauCollection),
                srcChargedIsoPtSum = cms.string(srcChargedIsoPtSum),
                srcNeutralIsoPtSum = cms.string(srcNeutralIsoPtSum),
                srcFootprintCorrection = cms.string(srcFootprintCorrection),
                srcPhotonPtSumOutsideSignalCone = cms.string(srcPhotonPtSumOutsideSignalCone),
                Prediscriminants = noPrediscriminants,
                loadMVAfromDB = cms.bool(True),
                mvaName = cms.string(params["mvaName"]),
                mvaOpt = cms.string(params["mvaOpt"]),
                verbosity = cms.int32(0)
            )
        )

        task = cms.Task(getattr(process, outputTauCollection + params["rawName"]))
        setattr(tauIDSources, params["rawName"], cms.InputTag(outputTauCollection + params["rawName"]))

        for wp, cut in params["cut_dict"].items():
            setattr(process, outputTauCollection + params["wpNamePattern"].format(wp),
                patDiscriminationByIsolationMVArun2v1VLoose.clone(
                    PATTauProducer = cms.InputTag(inputTauCollection),
                    Prediscriminants = noPrediscriminants,
                    toMultiplex = cms.InputTag(outputTauCollection + params["rawName"]),
                    key = cms.InputTag(outputTauCollection + params["rawName"] + ':category'),
                    loadMVAfromDB = cms.bool(True),
                    mvaOutput_normalization = cms.string(params["mvaOutput_normalization"]),
                    mapping = cms.VPSet(
                        cms.PSet(
                            category = cms.uint32(0),
                            cut = cms.string(cut),
                            variable = cms.string("pt"),
                        )
                    ),
                    verbosity = cms.int32(0)
                )
            )

            task.add(getattr(process, outputTauCollection + params["wpNamePattern"].format(wp)))

            setattr(tauIDSources, params["wpNamePattern"].format(wp),
                cms.InputTag(outputTauCollection + params["wpNamePattern"].format(wp))
            )

        getattr(process, outputTauCollection + 'rerunMvaIsolationTask').add(task)
        process.__dict__[outputTauCollection + 'rerunMvaIsolationSequence'] += cms.Sequence(task)

    if "deepTau2017v2p1" in toKeep:
        if debug: print ("Adding DeepTau IDs")

        workingPoints_ = {
            "e": {
                "VVVLoose": 0.0630386,
                "VVLoose": 0.1686942,
                "VLoose": 0.3628130,
                "Loose": 0.6815435,
                "Medium": 0.8847544,
                "Tight": 0.9675541,
                "VTight": 0.9859251,
                "VVTight": 0.9928449,
            },
            "mu": {
                "VLoose": 0.1058354,
                "Loose": 0.2158633,
                "Medium": 0.5551894,
                "Tight": 0.8754835,
            },
            "jet": {
                "VVVLoose": 0.2599605,
                "VVLoose": 0.4249705,
                "VLoose": 0.5983682,
                "Loose": 0.7848675,
                "Medium": 0.8834768,
                "Tight": 0.9308689,
                "VTight": 0.9573137,
                "VVTight": 0.9733927,
            },
        }

        file_names = [
            'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_core.pb',
            'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_inner.pb',
            'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_outer.pb',
        ]
        setattr(process, outputTauCollection + 'deepTau2017v2p1',
            cms.EDProducer("DeepTauId",
                electrons                = cms.InputTag('slimmedElectrons'),
                muons                    = cms.InputTag('slimmedMuons'),
                taus                     = cms.InputTag(inputTauCollection),
                pfcands                  = cms.InputTag('packedPFCandidates'),
                vertices                 = cms.InputTag('offlineSlimmedPrimaryVertices'),
                rho                      = cms.InputTag('fixedGridRhoAll'),
                graph_file               = cms.vstring(file_names),
                mem_mapped               = cms.bool(True),
                version                  = cms.uint32(getDeepTauVersion(file_names[0])[1]),
                debug_level              = cms.int32(0),
                disable_dxy_pca          = cms.bool(True)
            )
        )

        processDeepProducer(process, 'DeepTau2017v2p1', outputTauCollection + 'deepTau2017v2p1', tauIDSources,
                            workingPoints_)

        getattr(process, outputTauCollection + 'rerunMvaIsolationTask').add(
            getattr(process, outputTauCollection + 'deepTau2017v2p1')
        )
        process.__dict__[outputTauCollection + 'rerunMvaIsolationSequence'] += \
            getattr(process, outputTauCollection + 'deepTau2017v2p1')

    ##
    if debug: print('Embedding new TauIDs into "' + outputTauCollection + '"')
    if not hasattr(process, outputTauCollection):
        embedID = cms.EDProducer("PATTauIDEmbedder",
           src = cms.InputTag(inputTauCollection),
           tauIDSources = tauIDSources
        )
        setattr(process, outputTauCollection, embedID)
    else: #assume same type
        tauIDSources = cms.PSet( getattr(process, outputTauCollection).tauIDSources, tauIDSources)
        getattr(process, outputTauCollection).tauIDSources = tauIDSources
Example #5
0
def reRunTaus(process, taus='slimmedTaus'):
    from RecoTauTag.RecoTau.TauDiscriminatorTools import noPrediscriminants
    process.load('RecoTauTag.Configuration.loadRecoTauTagMVAsFromPrepDB_cfi')
    from RecoTauTag.RecoTau.PATTauDiscriminationByMVAIsolationRun2_cff import \
        patDiscriminationByIsolationMVArun2v1raw, patDiscriminationByIsolationMVArun2v1VLoose

    process.rerunDiscriminationByIsolationMVArun2v1raw = patDiscriminationByIsolationMVArun2v1raw.clone(
        PATTauProducer=cms.InputTag(taus),
        Prediscriminants=noPrediscriminants,
        loadMVAfromDB=cms.bool(True),
        mvaName=cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1"
                           ),  # name of the training you want to use
        mvaOpt=cms.string(
            "DBoldDMwLT"
        ),  # option you want to use for your training (i.e., which variables are used to compute the BDT score)
        requireDecayMode=cms.bool(True),
        verbosity=cms.int32(0))

    process.rerunDiscriminationByIsolationMVArun2v1VLoose = patDiscriminationByIsolationMVArun2v1VLoose.clone(
        PATTauProducer=cms.InputTag(taus),
        Prediscriminants=noPrediscriminants,
        toMultiplex=cms.InputTag('rerunDiscriminationByIsolationMVArun2v1raw'),
        key=cms.InputTag(
            'rerunDiscriminationByIsolationMVArun2v1raw:category'),
        loadMVAfromDB=cms.bool(True),
        mvaOutput_normalization=cms.string(
            "RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_mvaOutput_normalization"
        ),  # normalization fo the training you want to use
        mapping=cms.VPSet(
            cms.PSet(
                category=cms.uint32(0),
                cut=cms.string(
                    "RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff90"
                ),  # this is the name of the working point you want to use
                variable=cms.string("pt"),
            )))

    # here we produce all the other working points for the training
    process.rerunDiscriminationByIsolationMVArun2v1Loose = process.rerunDiscriminationByIsolationMVArun2v1VLoose.clone(
    )
    process.rerunDiscriminationByIsolationMVArun2v1Loose.mapping[
        0].cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff80")
    process.rerunDiscriminationByIsolationMVArun2v1Medium = process.rerunDiscriminationByIsolationMVArun2v1VLoose.clone(
    )
    process.rerunDiscriminationByIsolationMVArun2v1Medium.mapping[
        0].cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff70")
    process.rerunDiscriminationByIsolationMVArun2v1Tight = process.rerunDiscriminationByIsolationMVArun2v1VLoose.clone(
    )
    process.rerunDiscriminationByIsolationMVArun2v1Tight.mapping[
        0].cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff60")
    process.rerunDiscriminationByIsolationMVArun2v1VTight = process.rerunDiscriminationByIsolationMVArun2v1VLoose.clone(
    )
    process.rerunDiscriminationByIsolationMVArun2v1VTight.mapping[
        0].cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff50")
    process.rerunDiscriminationByIsolationMVArun2v1VVTight = process.rerunDiscriminationByIsolationMVArun2v1VLoose.clone(
    )
    process.rerunDiscriminationByIsolationMVArun2v1VVTight.mapping[
        0].cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1_WPEff40")

    # this sequence has to be included in your cms.Path() before your analyzer which accesses the new variables is called.
    process.rerunMvaIsolation2SeqRun2 = cms.Sequence(
        process.rerunDiscriminationByIsolationMVArun2v1raw *
        process.rerunDiscriminationByIsolationMVArun2v1VLoose *
        process.rerunDiscriminationByIsolationMVArun2v1Loose *
        process.rerunDiscriminationByIsolationMVArun2v1Medium *
        process.rerunDiscriminationByIsolationMVArun2v1Tight *
        process.rerunDiscriminationByIsolationMVArun2v1VTight *
        process.rerunDiscriminationByIsolationMVArun2v1VVTight)

    # embed rerun MVA IDs
    process.rerunSlimmedTaus = cms.EDProducer(
        "MiniAODTauRerunIDEmbedder",
        src=cms.InputTag(taus),
        idRaw=cms.InputTag("rerunDiscriminationByIsolationMVArun2v1raw"),
        idVLoose=cms.InputTag("rerunDiscriminationByIsolationMVArun2v1VLoose"),
        idLoose=cms.InputTag("rerunDiscriminationByIsolationMVArun2v1Loose"),
        idMedium=cms.InputTag("rerunDiscriminationByIsolationMVArun2v1Medium"),
        idTight=cms.InputTag("rerunDiscriminationByIsolationMVArun2v1Tight"),
        idVTight=cms.InputTag("rerunDiscriminationByIsolationMVArun2v1VTight"),
        idVVTight=cms.InputTag(
            "rerunDiscriminationByIsolationMVArun2v1VVTight"),
    )

    #process.analysisSequence+=process.rerunMvaIsolation2SeqRun2
    process.analysisSequence = cms.Sequence(process.analysisSequence *
                                            process.rerunMvaIsolation2SeqRun2 *
                                            process.rerunSlimmedTaus)
    def runTauID(self):
        self.process.rerunMvaIsolationBoostTask = self.cms.Task()
        self.process.rerunMvaIsolationBoostSequence = self.cms.Sequence()
        tauIDSources = self.cms.PSet()

        #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        if "2017v2" in self.toKeep:
            self.tauIdDiscrMVA_2017_version = "v2"
            self.tauIdDiscrMVA_trainings_run2_2017 = {
                'tauIdMVAIsoDBoldDMwLT2017' : "tauIdMVAIsoDBoldDMwLT2017",
            }
            self.tauIdDiscrMVA_WPs_run2_2017 = {
                'tauIdMVAIsoDBoldDMwLT2017' : {
                    'Eff95' : "DBoldDMwLTEff95",
                    'Eff90' : "DBoldDMwLTEff90",
                    'Eff80' : "DBoldDMwLTEff80",
                    'Eff70' : "DBoldDMwLTEff70",
                    'Eff60' : "DBoldDMwLTEff60",
                    'Eff50' : "DBoldDMwLTEff50",
                    'Eff40' : "DBoldDMwLTEff40"
                }
            }

            if not self.is_above_cmssw_version(9, 4, 5, self.debug):
                if self.debug: print "runTauID: not is_above_cmssw_version(9, 4, 5). Will update the list of available in DB samples to access 2017v2"
                self.loadMVA_WPs_run2_2017()

            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2raw = patDiscriminationByIsolationMVArun2v1raw.clone(
#                PATTauProducer = self.PATTauProducer,
                PATTauProducer = self.PATTauProducer,
                srcChargedIsoPtSum = self.srcChargedIsoPtSum,
                srcNeutralIsoPtSum = self.srcNeutralIsoPtSum,
                Prediscriminants = noPrediscriminants,
                loadMVAfromDB = self.cms.bool(True),
                mvaName = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2"),#RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1 writeTauIdDiscrMVAs
                mvaOpt = self.cms.string("DBoldDMwLTwGJ"),
                requireDecayMode = self.cms.bool(True),
                verbosity = self.cms.int32(0)
            )

            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose = patDiscriminationByIsolationMVArun2v1VLoose.clone(
                PATTauProducer = self.PATTauProducer,
                srcChargedIsoPtSum = self.srcChargedIsoPtSum,
                srcNeutralIsoPtSum = self.srcNeutralIsoPtSum,
                Prediscriminants = noPrediscriminants,
                toMultiplex = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v2raw'),
                key = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v2raw:category'),#?
                loadMVAfromDB = self.cms.bool(True),
                mvaOutput_normalization = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_mvaOutput_normalization"), #writeTauIdDiscrMVAoutputNormalizations
                mapping = self.cms.VPSet(
                    self.cms.PSet(
                        category = self.cms.uint32(0),
                        cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff90"), #writeTauIdDiscrWPs
                        variable = self.cms.string("pt"),
                    )
                ),
                verbosity = self.cms.int32(0)
            )

            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VVLoose = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose.clone()
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VVLoose.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff95")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Loose = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose.clone()
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Loose.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff80")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Medium = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose.clone()
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Medium.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff70")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Tight = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose.clone()
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Tight.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff60")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VTight = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose.clone()
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VTight.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff50")
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VVTight = self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose.clone()
            self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VVTight.mapping[0].cut = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2_WPEff40")

            self.rerunIsolationOldDMMVArun2017v2Task = self.cms.Task(
                self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2raw,
                self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose,
                self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VVLoose,
                self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Loose,
                self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Medium,
                self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2Tight,
                self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VTight,
                self.process.rerunDiscriminationByIsolationOldDMMVArun2017v2VVTight
            )
            self.process.rerunMvaIsolationBoostTask.add(self.rerunIsolationOldDMMVArun2017v2Task)
            self.process.rerunMvaIsolationBoostSequence += self.cms.Sequence(self.rerunIsolationOldDMMVArun2017v2Task)

            tauIDSources.byIsolationMVArun2017v2DBoldDMwLTraw2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v2raw')
            tauIDSources.byVVLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v2VVLoose')
            tauIDSources.byVLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v2VLoose')
            tauIDSources.byLooseIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v2Loose')
            tauIDSources.byMediumIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v2Medium')
            tauIDSources.byTightIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v2Tight')
            tauIDSources.byVTightIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v2VTight')
            tauIDSources.byVVTightIsolationMVArun2017v2DBoldDMwLT2017 = self.cms.InputTag('rerunDiscriminationByIsolationOldDMMVArun2017v2VVTight')

        #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        if "deepTau2017v1" in self.toKeep:
            print "Adding DeepTau IDs"

            workingPoints_ = {
                "e": {
                    "VVVLoose" : 0.96424,
                    "VVLoose" : 0.98992,
                    "VLoose" : 0.99574,
                    "Loose": 0.99831,
                    "Medium": 0.99868,
                    "Tight": 0.99898,
                    "VTight": 0.99911,
                    "VVTight": 0.99918
                },
                "mu": {
                    "VVVLoose" : 0.959619,
                    "VVLoose" : 0.997687,
                    "VLoose" : 0.999392,
                    "Loose": 0.999755,
                    "Medium": 0.999854,
                    "Tight": 0.999886,
                    "VTight": 0.999944,
                    "VVTight": 0.9999971
                },

                "jet": {
                    "VVVLoose" : 0.5329,
                    "VVLoose" : 0.7645,
                    "VLoose" : 0.8623,
                    "Loose": 0.9140,
                    "Medium": 0.9464,
                    "Tight": 0.9635,
                    "VTight": 0.9760,
                    "VVTight": 0.9859
                }
            }
            file_name = 'RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v1_20L1024N_quantized.pb'
            self.process.deepTau2017v1 = self.cms.EDProducer("DeepBoostedTauId",
                electrons              = self.cms.InputTag('slimmedElectrons'),
                muons                  = self.cms.InputTag('slimmedMuons'),
                taus                   = self.PATTauProducer,
                graph_file             = self.cms.string(file_name),
                mem_mapped             = self.cms.bool(False)
            )

            self.processDeepProducer('deepTau2017v1', tauIDSources, workingPoints_)

            self.process.rerunMvaIsolationBoostTask.add(self.process.deepTau2017v1)
            self.process.rerunMvaIsolationBoostSequence += self.process.deepTau2017v1

        #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        if "againstEle2018" in self.toKeep:
            print "starting {}".format(self.toKeep)
#            antiElectronDiscrMVA6_version = "MVA6v1"
            antiElectronDiscrMVA6_version = "MVA6v3_noeveto"
            ### Define new anti-e discriminants
            ## Raw
            from RecoTauTag.RecoTau.PATTauDiscriminationAgainstElectronMVA6_cfi import patTauDiscriminationAgainstElectronMVA6
            self.process.patTauDiscriminationByElectronRejectionMVA62018Raw = patTauDiscriminationAgainstElectronMVA6.clone(
                PATTauProducer = self.PATTauProducer,
                Prediscriminants = noPrediscriminants,
                #Prediscriminants = requireLeadTrack,
                loadMVAfromDB = True,
                returnMVA = True,
                method = "BDTG",
                mvaName_NoEleMatch_wGwoGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL',
                mvaName_NoEleMatch_wGwoGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC',
                mvaName_NoEleMatch_woGwoGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL',
                mvaName_NoEleMatch_woGwoGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC',
                mvaName_wGwGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL',
                mvaName_wGwGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC',
                mvaName_woGwGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL',
                mvaName_woGwGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC',
                minMVANoEleMatchWOgWOgsfBL = 0,
                minMVANoEleMatchWgWOgsfBL  = 0,
                minMVAWOgWgsfBL            = 0,
                minMVAWgWgsfBL             = 0,
                minMVANoEleMatchWOgWOgsfEC = 0,
                minMVANoEleMatchWgWOgsfEC  = 0,
                minMVAWOgWgsfEC            = 0,
                minMVAWgWgsfEC             = 0,
                srcElectrons = 'slimmedElectrons',
                usePhiAtEcalEntranceExtrapolation = True,
            )
            ## WPs
            from RecoTauTag.RecoTau.PATTauDiscriminantCutMultiplexer_cfi import patTauDiscriminantCutMultiplexer
            
            # VLoose
            self.process.patTauDiscriminationByVLooseElectronRejectionMVA62018 = patTauDiscriminantCutMultiplexer.clone(
                PATTauProducer = self.PATTauProducer,
                Prediscriminants = self.process.patTauDiscriminationByElectronRejectionMVA62018Raw.Prediscriminants,
                toMultiplex = self.cms.InputTag("patTauDiscriminationByElectronRejectionMVA62018Raw"),
                key = self.cms.InputTag("patTauDiscriminationByElectronRejectionMVA62018Raw","category"),
                mapping = self.cms.VPSet(
                    self.cms.PSet(
                        category = self.cms.uint32(0),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL_WPeff98'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(2),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL_WPeff98'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(5),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL_WPeff98'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(7),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL_WPeff98'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(8),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC_WPeff98'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(10),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC_WPeff98'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(13),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC_WPeff98'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(15),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC_WPeff98'),
                        variable = self.cms.string('pt')
                    )
                )
            )

            # Loose
            self.process.patTauDiscriminationByLooseElectronRejectionMVA62018 = self.process.patTauDiscriminationByVLooseElectronRejectionMVA62018.clone(
                mapping = self.cms.VPSet(
                    self.cms.PSet(
                        category = self.cms.uint32(0),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL_WPeff90'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(2),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL_WPeff90'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(5),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL_WPeff90'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(7),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL_WPeff90'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(8),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC_WPeff90'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(10),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC_WPeff90'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(13),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC_WPeff90'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(15),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC_WPeff90'),
                        variable = self.cms.string('pt')
                    )
                )
            )
            # Medium
            self.process.patTauDiscriminationByMediumElectronRejectionMVA62018 = self.process.patTauDiscriminationByVLooseElectronRejectionMVA62018.clone(
                mapping = self.cms.VPSet(
                    self.cms.PSet(
                        category = self.cms.uint32(0),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL_WPeff80'),
                        variable = self.cms.string('pt')
                     ),
                    self.cms.PSet(
                        category = self.cms.uint32(2),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL_WPeff80'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(5),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL_WPeff80'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(7),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL_WPeff80'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(8),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC_WPeff80'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(10),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC_WPeff80'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(13),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC_WPeff80'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(15),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC_WPeff80'),
                        variable = self.cms.string('pt')
                    )
                )
            )
            # Tight
            self.process.patTauDiscriminationByTightElectronRejectionMVA62018 = self.process.patTauDiscriminationByVLooseElectronRejectionMVA62018.clone(
                mapping = self.cms.VPSet(
                    self.cms.PSet(
                        category = self.cms.uint32(0),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL_WPeff70'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(2),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL_WPeff70'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(5),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL_WPeff70'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(7),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL_WPeff70'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(8),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC_WPeff70'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(10),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC_WPeff70'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(13),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC_WPeff70'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(15),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC_WPeff70'),
                        variable = self.cms.string('pt')
                    )
                )
            )
            # VTight
            self.process.patTauDiscriminationByVTightElectronRejectionMVA62018 = self.process.patTauDiscriminationByVLooseElectronRejectionMVA62018.clone(
                mapping = self.cms.VPSet(
                    self.cms.PSet(
                        category = self.cms.uint32(0),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_BL_WPeff60'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(2),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_BL_WPeff60'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(5),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_BL_WPeff60'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(7),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_BL_WPeff60'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(8),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_woGwoGSF_EC_WPeff60'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(10),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_NoEleMatch_wGwoGSF_EC_WPeff60'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(13),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_woGwGSF_EC_WPeff60'),
                        variable = self.cms.string('pt')
                    ),
                    self.cms.PSet(
                        category = self.cms.uint32(15),
                        cut = self.cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_gbr_wGwGSF_EC_WPeff60'),
                        variable = self.cms.string('pt')
                    )
                )
            )
            ### Put all new anti-e discrminats to a sequence
            self.process.patTauDiscriminationByElectronRejectionMVA62018Task = self.cms.Task(
                self.process.patTauDiscriminationByElectronRejectionMVA62018Raw,
                self.process.patTauDiscriminationByVLooseElectronRejectionMVA62018,
                self.process.patTauDiscriminationByLooseElectronRejectionMVA62018,
                self.process.patTauDiscriminationByMediumElectronRejectionMVA62018,
                self.process.patTauDiscriminationByTightElectronRejectionMVA62018,
                self.process.patTauDiscriminationByVTightElectronRejectionMVA62018
            )
            self.process.patTauDiscriminationByElectronRejectionMVA62018Seq = self.cms.Sequence(self.process.patTauDiscriminationByElectronRejectionMVA62018Task)
            self.process.rerunMvaIsolationBoostTask.add(self.process.patTauDiscriminationByElectronRejectionMVA62018Task)
            self.process.rerunMvaIsolationBoostSequence += self.process.patTauDiscriminationByElectronRejectionMVA62018Seq

            _againstElectronTauIDSources = self.cms.PSet(
                againstElectronMVA6Raw2018 = self.cms.InputTag("patTauDiscriminationByElectronRejectionMVA62018Raw"),
                againstElectronMVA6category2018 = self.cms.InputTag("patTauDiscriminationByElectronRejectionMVA62018Raw","category"),
                againstElectronVLooseMVA62018 = self.cms.InputTag("patTauDiscriminationByVLooseElectronRejectionMVA62018"),
                againstElectronLooseMVA62018 = self.cms.InputTag("patTauDiscriminationByLooseElectronRejectionMVA62018"),
                againstElectronMediumMVA62018 = self.cms.InputTag("patTauDiscriminationByMediumElectronRejectionMVA62018"),
                againstElectronTightMVA62018 = self.cms.InputTag("patTauDiscriminationByTightElectronRejectionMVA62018"),
                againstElectronVTightMVA62018 = self.cms.InputTag("patTauDiscriminationByVTightElectronRejectionMVA62018")
            )
            _tauIDSourcesWithAgainistEle = self.cms.PSet(
                tauIDSources.clone(),
                _againstElectronTauIDSources
            )
            tauIDSources =_tauIDSourcesWithAgainistEle.clone()
            

        ##
        print('Embedding new TauIDs into \"'+self.updatedTauName+'\"')
        embedID = self.cms.EDProducer("PATTauIDEmbedder",
            src = self.PATTauProducer,
            tauIDSources = tauIDSources
        )
        setattr(self.process, self.updatedTauName, embedID)