示例#1
0
    def makeAnalysisStep(self, stepName, **inputs):
        step = super(ZZLeptonCounters,
                     self).makeAnalysisStep(stepName, **inputs)

        if stepName == 'initialStateEmbedding':
            counters = {
                'Loose':
                'userFloat("{}") > 0.5'.format(self.getZZIDLabel()),
                'Tight':
                'userFloat("{}") > 0.5'.format(self.getZZIDLabel() + 'Tight'),
                'TightIso':
                ('userFloat("{}") > 0.5 && '
                 'userFloat("{}") > 0.5').format(self.getZZIDLabel() + 'Tight',
                                                 self.getZZIsoLabel())
            }
            countTags = []
            countLabels = []
            for lep in 'e', 'm':
                labels = [
                    'nZZ' + name + getObjName(lep, True) + 's'
                    for name in counters.keys()
                ]
                countLabels += labels
                mod = cms.EDProducer(
                    "PAT{}Counter".format(getObjName(lep, True)),
                    src=step.getObjTag(lep),
                    labels=cms.vstring(*labels),
                    cuts=cms.vstring(
                        *[counters[label] for label in counters.keys()]),
                )
                moduleName = 'zz{0}Counter'.format('Elec' if lep ==
                                                   'e' else 'Mu')
                step.addModule(moduleName, mod)

                countTags += [
                    cms.InputTag('{name}:{label}'.format(name=moduleName,
                                                         label=l))
                    for l in labels
                ]

            for chan in parseChannels('zz') + parseChannels(
                    'zl') + parseChannels('z'):
                if chan not in step.outputs:
                    continue
                countEmbedding = cms.EDProducer(
                    'PATCompositeCandidateValueEmbedder',
                    src=step.getObjTag(chan),
                    intLabels=cms.vstring(*countLabels),
                    intSrc=cms.VInputTag(*countTags),
                )
                step.addModule(chan + 'ZZCountEmbedding', countEmbedding, chan)

        return step
示例#2
0
    def makeAnalysisStep(self, stepName, **inputs):
        step = super(BJetCounters, self).makeAnalysisStep(stepName, **inputs)
        
        if stepName == 'initialStateEmbedding':
            jetCounters = {
                # Recommendations via https://twiki.cern.ch/twiki/bin/viewauth/CMS/BtagRecommendation80XReReco
                #https://twiki.cern.ch/twiki/bin/viewauth/CMS/HiggsZZ4lRunIILegacy#b_tagging
                "DeepCSV_2016" : '? bDiscriminator("pfDeepCSVJetTags:probb + pfDeepCSVJetTags:probbb") > 0.6321 ? 1 : 0',  #medium
                "DeepCSV_2017" : '? bDiscriminator("pfDeepCSVJetTags:probb + pfDeepCSVJetTags:probbb") > 0.4941 ? 1 : 0',  #medium
                "DeepCSV_2018" : '? bDiscriminator("pfDeepCSVJetTags:probb + pfDeepCSVJetTags:probbb") > 0.4184 ? 1 : 0',  #medium
            }
            mod = cms.EDProducer(
                "PATJetCounter",
                src = step.getObjTag('j'),
                labels = cms.vstring(*['nJet'+label for label in jetCounters.keys()]),
                cuts = cms.vstring(*[jetCounters[key] for key in jetCounters.keys()])
                )
            step.addModule("jetCounter", mod)

            labels = ['nJet'+name for name in jetCounters.keys()]
            tags = [cms.InputTag("jetCounter:nJet"+name) for name in jetCounters.keys()]

            for chan in parseChannels('zl'):
                countEmbedding = cms.EDProducer(
                    'PATCompositeCandidateValueEmbedder',
                    src = step.getObjTag(chan),
                    intLabels = cms.vstring(*labels),
                    intSrc = cms.VInputTag(*tags),
                    )
                step.addModule(chan+'JetCountEmbedding', countEmbedding, chan)

        return step
示例#3
0
    def makeAnalysisStep(self, stepName, **inputs):
        step = super(BJetCounters, self).makeAnalysisStep(stepName, **inputs)
        
        if stepName == 'initialStateEmbedding':
            jetCounters = {'JPL' : '? bDiscriminator("pfJetProbabilityBJetTags")>0.245 ? 1 : 0',
                "JPM" : '? bDiscriminator("pfJetProbabilityBJetTags")>0.515 ? 1 : 0',
                "JPT" : '? bDiscriminator("pfJetProbabilityBJetTags")>0.760 ? 1 : 0',
                "CSVv2L" : '? bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags")>0.460 ? 1 : 0',
                "CSVv2M" : '? bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags")>0.800 ? 1 : 0',
                "CSVv2T" : '? bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags")>0.935 ? 1 : 0',
                "CMVAv2L" : '? bDiscriminator("pfCombinedMVAV2BJetTags")>-0.715 ? 1 : 0',
                "CMVAv2M" : '? bDiscriminator("pfCombinedMVAV2BJetTags")>0.185 ? 1 : 0',
                "CMVAv2T" : '? bDiscriminator("pfCombinedMVAV2BJetTags")>0.875 ? 1 : 0',
            }
            mod = cms.EDProducer(
                "PATJetCounter",
                src = step.getObjTag('j'),
                labels = cms.vstring(*['nJet'+label for label in jetCounters.keys()]),
                cuts = cms.vstring(*[jetCounters[key] for key in jetCounters.keys()])
                )
            step.addModule("jetCounter", mod)

            labels = ['nJet'+name for name in jetCounters.keys()]
            tags = [cms.InputTag("jetCounter:nJet"+name) for name in jetCounters.keys()]

            for chan in parseChannels('zl'):
                countEmbedding = cms.EDProducer(
                    'PATCompositeCandidateValueEmbedder',
                    src = step.getObjTag(chan),
                    intLabels = cms.vstring(*labels),
                    intSrc = cms.VInputTag(*tags),
                    )
                step.addModule(chan+'JetCountEmbedding', countEmbedding, chan)

        return step
示例#4
0
    def makeAnalysisStep(self, stepName, **inputs):
        step = super(BJetCounters, self).makeAnalysisStep(stepName, **inputs)
        
        if stepName == 'initialStateEmbedding':
            # Recommendations via https://twiki.cern.ch/twiki/bin/viewauth/CMS/BtagRecommendation80XReReco
            jetCounters = {
                "CSVv2L" : '? bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags") > 0.5426 ? 1 : 0',
                "CSVv2M" : '? bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags") > 0.8484 ? 1 : 0',
                "CSVv2T" : '? bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags") > 0.9535 ? 1 : 0',
                "CMVAv2L" : '? bDiscriminator("pfCombinedMVAV2BJetTags") > -0.5884 ? 1 : 0',
                "CMVAv2M" : '? bDiscriminator("pfCombinedMVAV2BJetTags") > 0.4432 ? 1 : 0',
                "CMVAv2T" : '? bDiscriminator("pfCombinedMVAV2BJetTags") > 0.9432 ? 1 : 0',
            }
            mod = cms.EDProducer(
                "PATJetCounter",
                src = step.getObjTag('j'),
                labels = cms.vstring(*['nJet'+label for label in jetCounters.keys()]),
                cuts = cms.vstring(*[jetCounters[key] for key in jetCounters.keys()])
                )
            step.addModule("jetCounter", mod)

            labels = ['nJet'+name for name in jetCounters.keys()]
            tags = [cms.InputTag("jetCounter:nJet"+name) for name in jetCounters.keys()]

            for chan in parseChannels('zl'):
                countEmbedding = cms.EDProducer(
                    'PATCompositeCandidateValueEmbedder',
                    src = step.getObjTag(chan),
                    intLabels = cms.vstring(*labels),
                    intSrc = cms.VInputTag(*tags),
                    )
                step.addModule(chan+'JetCountEmbedding', countEmbedding, chan)

        return step
示例#5
0
    def makeAnalysisStep(self, stepName, **inputs):
        step = super(WZLeptonCounters,
                     self).makeAnalysisStep(stepName, **inputs)

        if stepName == 'initialStateEmbedding':
            muCounters = [
                "TightMuon",
                "MediumMuonICHEP",
            ]

            mod = cms.EDProducer(
                "PATMuonCounter",
                src=step.getObjTag('m'),
                labels=cms.vstring(*[label for label in muCounters]),
                cuts=cms.vstring(
                    *['userInt("is%s")' % label for label in muCounters]),
            )
            step.addModule("muCounter", mod)

            eCounters = [
                "CBVIDtight",
                "CBVIDmedium",
                "CBVIDloose",
            ]

            mod = cms.EDProducer(
                "PATElectronCounter",
                src=step.getObjTag('e'),
                labels=cms.vstring(*[label for label in eCounters]),
                cuts=cms.vstring(
                    *
                    ['userFloat("is%s") > 0.5' % label
                     for label in eCounters]),
            )
            step.addModule("elecCounter", mod)

            counters = {
                'n' + label: 'muCounter:' + label
                for label in muCounters
            }
            counters.update({
                'n' + label + 'Elec': 'elecCounter:' + label
                for label in eCounters
            })

            labels = list(counters.keys())
            tags = [cms.InputTag(counters[label]) for label in labels]

            for chan in parseChannels('zl'):
                countEmbedding = cms.EDProducer(
                    'PATCompositeCandidateValueEmbedder',
                    src=step.getObjTag(chan),
                    intLabels=cms.vstring(*labels),
                    intSrc=cms.VInputTag(*tags),
                )
                step.addModule(chan + 'CountEmbedding', countEmbedding, chan)

        return step
示例#6
0
 def addAlternatePairInfo(self, step):
     '''
     Add modules to embed alternate lepton pair (e.g. e1+m1) info.
     '''
     for chan in parseChannels('zz'):
         mod = cms.EDProducer(
             'AlternateDaughterInfoEmbedder',
             src = step.getObjTag(chan),
             names = cms.vstring(*mapObjects(chan)),
             fsrLabel = cms.string("fsr"),
             )
         step.addModule(chan+'AlternatePairs', mod, chan)
示例#7
0
 def addAlternatePairInfo(self, step):
     '''
     Add modules to embed alternate lepton pair (e.g. e1+m1) info.
     '''
     for chan in parseChannels('zz'):
         mod = cms.EDProducer(
             'AlternateDaughterInfoEmbedder',
             src=step.getObjTag(chan),
             names=cms.vstring(*mapObjects(chan)),
             fsrLabel=cms.string("fsr"),
         )
         step.addModule(chan + 'AlternatePairs', mod, chan)
示例#8
0
    def makeAnalysisStep(self, stepName, **inputs):
        step = super(ZZLeptonCounters, self).makeAnalysisStep(stepName, **inputs)
        
        if stepName == 'initialStateEmbedding':
            counters = {
                'Loose' : 'userFloat("{}") > 0.5'.format(self.getZZIDLabel()),
                'Tight' : 'userFloat("{}") > 0.5'.format(self.getZZIDLabel()+'Tight'),
                'TightIso' : ('userFloat("{}") > 0.5 && '
                              'userFloat("{}") > 0.5').format(self.getZZIDLabel()+'Tight', 
                                                              self.getZZIsoLabel())
                }
            countTags = []
            countLabels = []
            for lep in 'e','m':
                labels = ['nZZ'+name+getObjName(lep, True)+'s' for name in counters.keys()]
                countLabels += labels
                mod = cms.EDProducer(
                    "PAT{}Counter".format(getObjName(lep, True)),
                    src = step.getObjTag(lep),
                    labels = cms.vstring(*labels),
                    cuts = cms.vstring(*[counters[label] for label in counters.keys()]),
                    )
                moduleName = 'zz{0}Counter'.format('Elec' if lep == 'e' else 'Mu')
                step.addModule(moduleName, mod)

                countTags += [cms.InputTag('{name}:{label}'.format(name=moduleName,label=l)) for l in labels]

            for chan in parseChannels('zz')+parseChannels('zl')+parseChannels('z'):
                if chan not in step.outputs:
                    continue
                countEmbedding = cms.EDProducer(
                    'PATCompositeCandidateValueEmbedder',
                    src = step.getObjTag(chan),
                    intLabels = cms.vstring(*countLabels),
                    intSrc = cms.VInputTag(*countTags),
                    )
                step.addModule(chan+'ZZCountEmbedding', countEmbedding, chan)

        return step
示例#9
0
 def addZPlusXCreation(self, step):
     '''
     Add modules to combine Zs into 3l candidates
     '''
     for chan in parseChannels('zl'):
         mod = cms.EDProducer(
             'PATCandViewShallowCloneCombiner',
             decay = cms.string('{0} {1}'.format(step.getObjTagString('ee' if chan.count('e') > 1 else 'mm'),
                                                 step.getObjTagString('e' if chan.count('e') in [1,3] else 'm'))),
             cut = cms.string(""),
             checkCharge = cms.bool(False),
             setPdgId = cms.int32(25),
             )
         
         step.addModule(chan+'Producer', mod, chan)
示例#10
0
 def addZZCreation(self, step):
     '''
     Add modules to combine Zs into 4l candidates
     '''
     for chan in parseChannels('zz'):
         z1Name = 'z{}1'.format(chan[0])
         z2Name = 'z{}{}'.format(chan[2], 2 if chan[0] == chan[2] else 1)
         mod = cms.EDProducer(
             'PATCandViewShallowCloneCombiner',
             decay = cms.string('{0} {1}'.format(step.getObjTagString(chan[:2]),
                                                 step.getObjTagString(chan[2:]))),
             roles = cms.vstring(z1Name, z2Name),
             cut = cms.string(('daughter("{}").masterClone.mass < 150. && '
                               'daughter("{}").masterClone.mass < 150.').format(z1Name, z2Name)),
             checkCharge = cms.bool(False),
             setPdgId = cms.int32(25),
             )
         
         step.addModule(chan+'Producer', mod, chan)
示例#11
0
    def addZZCreation(self, step):
        '''
        Add modules to combine Zs into 4l candidates
        '''
        for chan in parseChannels('zz'):
            z1Name = 'z{}1'.format(chan[0])
            z2Name = 'z{}{}'.format(chan[2], 2 if chan[0] == chan[2] else 1)
            mod = cms.EDProducer(
                'PATCandViewShallowCloneCombiner',
                decay=cms.string('{0} {1}'.format(
                    step.getObjTagString(chan[:2]),
                    step.getObjTagString(chan[2:]))),
                roles=cms.vstring(z1Name, z2Name),
                cut=cms.string(
                    ('daughter("{}").masterClone.mass < 150. && '
                     'daughter("{}").masterClone.mass < 150.').format(
                         z1Name, z2Name)),
                checkCharge=cms.bool(False),
                setPdgId=cms.int32(25),
            )

            step.addModule(chan + 'Producer', mod, chan)
示例#12
0
 def embedCleanedJets(self, step):
     '''
     Add modules to embed jet collection cleaned leptons 
     selected in the initial state object
     '''
     for chan in parseChannels('zz'):
         try:
             mod = cms.EDProducer(
                 'CleanedJetCollectionEmbedder',
                 src=step.getObjTag(chan),
                 jetSrc=step.getObjTag('j'),
                 jesUpJetSrc=step.getObjTag('j_jesUp'),
                 jesDownJetSrc=step.getObjTag('j_jesDown'),
                 jerUpJetSrc=step.getObjTag('j_jerUp'),
                 jerDownJetSrc=step.getObjTag('j_jerDown'),
             )
         except KeyError:
             mod = cms.EDProducer(
                 'CleanedJetCollectionEmbedder',
                 src=step.getObjTag(chan),
                 jetSrc=step.getObjTag('j'),
             )
         step.addModule(chan + 'CleanedJetsEmbed', mod, chan)
示例#13
0
 def embedCleanedJets(self, step):
     '''
     Add modules to embed jet collection cleaned leptons 
     selected in the initial state object
     '''
     for chan in parseChannels('zz'):
         try:
             mod = cms.EDProducer(
                 'CleanedJetCollectionEmbedder',
                 src = step.getObjTag(chan),
                 jetSrc = step.getObjTag('j'),
                 jesUpJetSrc = step.getObjTag('j_jesUp'),
                 jesDownJetSrc = step.getObjTag('j_jesDown'),
                 jerUpJetSrc = step.getObjTag('j_jerUp'),
                 jerDownJetSrc = step.getObjTag('j_jerDown'),
             )
         except KeyError:
             mod = cms.EDProducer(
                 'CleanedJetCollectionEmbedder',
                 src = step.getObjTag(chan),
                 jetSrc = step.getObjTag('j'),
             )
         step.addModule(chan+'CleanedJetsEmbed', mod, chan)
示例#14
0
文件: GenZZBase.py 项目: kdlong/UWVV
    def makeAnalysisStep(self, stepName, **inputs):
        step = super(GenZZBase, self).makeAnalysisStep(stepName, **inputs)

        if stepName == 'initialStateCreation':

            for chan in parseChannels('zz'):
                z1Name = 'z{}1'.format(chan[0])
                z2Name = 'z{}{}'.format(chan[2], 2 if chan[0] == chan[2] else 1)
                mod = cms.EDProducer(
                    'PATCandViewShallowCloneCombiner',
                    decay = cms.string('{0} {1}'.format(step.getObjTagString(chan[:2]),
                                                        step.getObjTagString(chan[2:]))),
                    roles = cms.vstring(z1Name, z2Name),
                    cut = cms.string(('4. < daughter("{}").mass && '
                                      '4. < daughter("{}").mass').format(z1Name, z2Name)),
                    checkCharge = cms.bool(False),
                    setPdgId = cms.int32(25),
                    )

                step.addModule(chan+'GenProducer', mod, chan)

                cleaner = cms.EDProducer(
                    "GenZZCleaner",
                    src = step.getObjTag(chan),
                    l1PtCut = cms.double(20.),
                    l2PtCut = cms.double(10.),
                    l3PtCut = cms.double(5.),
                    l4PtCut = cms.double(5.),
                    etaCut = cms.double(2.5),
                    ossfMassCut = cms.double(4.),
                    z1MassMin = cms.double(40.),
                    z1MassMax = cms.double(120.),
                    z2MassMin = cms.double(4.),
                    z2MassMax = cms.double(120.),
                    )
                step.addModule(chan+'GenZZCleaner', cleaner, chan)

        if stepName == 'initialStateEmbedding':
            for chan in parseChannels('zz'):
                mod = cms.EDProducer(
                    'AlternateDaughterInfoEmbedder',
                    src = step.getObjTag(chan),
                    names = cms.vstring(*mapObjects(chan)),
                    fsrLabel = cms.string(""),
                    )
                step.addModule(chan+'AlternatePairs', mod, chan)


        if stepName == 'selection':
            # select and cross clean gen jets
            mod = cms.EDProducer(
                "GenJetCleaner",
                src=step.getObjTag('j'),
                preselection=cms.string('pt > 30. && abs(eta) < 4.7'),
                checkOverlaps = cms.PSet(
                    electrons = cms.PSet(
                        src=step.getObjTag('e'),
                        preselection=cms.string(''),
                        deltaR=cms.double(0.4),
                        ),
                    muons = cms.PSet(
                        src=step.getObjTag('m'),
                        preselection=cms.string(''),
                        deltaR=cms.double(0.4),
                        ),
                    ),
                finalCut = cms.string(''),
                )
            step.addModule('genJetCleaner', mod, 'j')

        return step
示例#15
0
        description='Merge many data files, removing duplicate events.')
    parser.add_argument(
        'channels',
        type=str,
        nargs=1,
        help='Comma-separated list of channels or channel shorthands.')
    parser.add_argument(
        'input',
        type=str,
        nargs=1,
        help='Comma-separated list of input files. May contain wildcars.')
    parser.add_argument('output', type=str, nargs=1, help='Output file name')

    args = parser.parse_args()

    channels = parseChannels(args.channels)

    infiles = []
    for fset in args.input[0].split(','):
        infiles += glob(fset)

    if not len(infiles):
        raise IOError("No files found matching {}".format(args.input[0]))

    with root_open(args.output[0], 'recreate') as f:
        for c in channels:
            f.cd()
            d = f.mkdir(c)
            d.cd()
            n = mergeChannel(c, infiles)
            n.write()
示例#16
0
        "promptFS" : "isPromptFinalState()",
        "dressedHPFS" : "fromHardProcessFinalState()",
        "dressedFS" : "status() == 1",
        "dressedPromptFS" : "isPromptFinalState()",
}
if options.genLeptonType not in genLepChoices:
    print "ERROR: Invalid GEN-lepton type %s" % options.genLeptonType
    print "Valid optons and corresponding status flags are"
    print "    Format: keyword: status flag"
    print "    Default: hardProcessFS: fromHardProcessFinalState()"
    print "-"*80
    for key, value in genLepChoices.iteritems():
        print "    %s: %s" % (key, value)
    exit(1)

channels = parseChannels(options.channels)
zz = any(len(c) == 4 for c in channels)
zl = any(len(c) == 3 for c in channels)
wz = "wz" in options.channels 
z  = any(len(c) == 2 for c in channels)
l  = any(len(c) == 1 for c in channels)


### To use IgProf's neat memory profiling tools, run with the profile
### option and igprof like so:
###      $ igprof -d -mp -z -o igprof.mp.gz cmsRun profile=1 ...
### this will create a memory profile every 250 events so you can track use
### Turn the profile into text with
###      $ igprof-analyse -d -v -g -r MEM_LIVE igprof.yourOutputFile.gz > igreport_live.res
### To do a performance profile instead of a memory profile, change -mp to -pp
### in the first command and remove  -r MEM_LIVE from the second
示例#17
0
    def makeAnalysisStep(self, stepName, **inputs):
        step = super(GenZZBase, self).makeAnalysisStep(stepName, **inputs)

        if stepName == 'initialStateCreation':

            for chan in parseChannels('zz'):
                z1Name = 'z{}1'.format(chan[0])
                z2Name = 'z{}{}'.format(chan[2],
                                        2 if chan[0] == chan[2] else 1)
                mod = cms.EDProducer(
                    'PATCandViewShallowCloneCombiner',
                    decay=cms.string('{0} {1}'.format(
                        step.getObjTagString(chan[:2]),
                        step.getObjTagString(chan[2:]))),
                    roles=cms.vstring(z1Name, z2Name),
                    cut=cms.string(
                        ('4. < daughter("{}").mass && '
                         '4. < daughter("{}").mass').format(z1Name, z2Name)),
                    checkCharge=cms.bool(False),
                    setPdgId=cms.int32(25),
                )

                step.addModule(chan + 'GenProducer', mod, chan)

                cleaner = cms.EDProducer(
                    "GenZZCleaner",
                    src=step.getObjTag(chan),
                    l1PtCut=cms.double(20.),
                    l2PtCut=cms.double(10.),
                    l3PtCut=cms.double(5.),
                    l4PtCut=cms.double(5.),
                    etaCut=cms.double(2.5),
                    ossfMassCut=cms.double(4.),
                    z1MassMin=cms.double(40.),
                    z1MassMax=cms.double(120.),
                    z2MassMin=cms.double(4.),
                    z2MassMax=cms.double(120.),
                )
                step.addModule(chan + 'GenZZCleaner', cleaner, chan)

        if stepName == 'initialStateEmbedding':
            for chan in parseChannels('zz'):
                mod = cms.EDProducer(
                    'AlternateDaughterInfoEmbedder',
                    src=step.getObjTag(chan),
                    names=cms.vstring(*mapObjects(chan)),
                    fsrLabel=cms.string(""),
                )
                step.addModule(chan + 'AlternatePairs', mod, chan)

        if stepName == 'selection':
            # select and cross clean gen jets
            mod = cms.EDProducer(
                "GenJetCleaner",
                src=step.getObjTag('j'),
                preselection=cms.string('pt > 30. && abs(eta) < 4.7'),
                checkOverlaps=cms.PSet(
                    electrons=cms.PSet(
                        src=step.getObjTag('e'),
                        preselection=cms.string(''),
                        deltaR=cms.double(0.4),
                    ),
                    muons=cms.PSet(
                        src=step.getObjTag('m'),
                        preselection=cms.string(''),
                        deltaR=cms.double(0.4),
                    ),
                ),
                finalCut=cms.string(''),
            )
            step.addModule('genJetCleaner', mod, 'j')

        return step
示例#18
0
    def makeAnalysisStep(self, stepName, **inputs):
        step = super(WZLeptonCounters,
                     self).makeAnalysisStep(stepName, **inputs)

        if stepName == 'initialStateEmbedding':
            muCounters = {
                "WZLooseMuon": self.getWZLooseMuonID(),
                "WZMediumMuon": self.getWZMediumMuonID(),
                "WZTightMuon": self.getWZTightMuonID(),
            }

            mod = cms.EDProducer(
                "PATMuonCounter",
                src=step.getObjTag('m'),
                labels=cms.vstring(*muCounters.keys()),
                cuts=cms.vstring(*muCounters.values()),
            )
            step.addModule("muCounter", mod)

            eCounters = {
                "CBVIDTightElec":
                'pt() > 10 && abs(eta) < 2.5 && userFloat("IsCBVIDTightwIP")',
                "CBVIDMediumElec":
                'pt() > 10 && abs(eta) < 2.5 && userFloat("IsCBVIDMediumwIP")',
                "CBVIDLooseElec":
                'pt() > 10 && abs(eta) < 2.5 && userFloat("IsCBVIDLoosewIP")',
                "CBVIDVetoElec":
                'pt() > 10 && abs(eta) < 2.5 && userFloat("IsCBVIDVetowIP")',
                "CBVIDVetoElecNoIP":
                'pt() > 10 && abs(eta) < 2.5 && userFloat("IsCBVIDVeto")',
                "CBVIDHLTSafeElec":
                'pt() > 10 && abs(eta) < 2.5 && userFloat("IsCBVIDHLTSafewIP")',
                "CBVIDHLTSafeElecNoIP":
                'pt() > 10 && abs(eta) < 2.5 && userFloat("IsCBVIDHLTSafe")',
                "WWLooseCBVIDMedElec":
                'pt() > 10 && abs(eta) < 2.5 && userInt("IsWWLoose") && userFloat("IsCBVIDMediumwIP")',
                "WWLooseElec":
                'pt() > 10 && abs(eta) < 2.5 && userInt("IsWWLoose")',
            }

            mod = cms.EDProducer(
                "PATElectronCounter",
                src=step.getObjTag('e'),
                labels=cms.vstring(*eCounters.keys()),
                cuts=cms.vstring(*eCounters.values()),
            )
            step.addModule("elecCounter", mod)

            counters = {
                'n' + label: 'muCounter:' + label
                for label in muCounters.keys()
            }
            counters.update({
                'n' + label: 'elecCounter:' + label
                for label in eCounters.keys()
            })

            labels = list(counters.keys())
            tags = [cms.InputTag(counters[label]) for label in labels]

            for chan in parseChannels('zl'):
                countEmbedding = cms.EDProducer(
                    'PATCompositeCandidateValueEmbedder',
                    src=step.getObjTag(chan),
                    intLabels=cms.vstring(*labels),
                    intSrc=cms.VInputTag(*tags),
                )
                step.addModule(chan + 'CountEmbedding', countEmbedding, chan)

        return step
示例#19
0
if __name__ == "__main__":
    from argparse import ArgumentParser
    from glob import glob

    parser = ArgumentParser(description='Merge many data files, removing duplicate events.')
    parser.add_argument('channels', type=str, nargs=1,
                        help='Comma-separated list of channels or channel shorthands.')
    parser.add_argument('input', type=str, nargs=1,
                        help='Comma-separated list of input files. May contain wildcars.')
    parser.add_argument('output', type=str, nargs=1,
                        help='Output file name')

    args = parser.parse_args()

    channels = parseChannels(args.channels)

    infiles = []
    for fset in args.input[0].split(','):
        infiles += glob(fset)

    if not len(infiles):
        raise IOError("No files found matching {}".format(args.input[0]))

    with root_open(args.output[0], 'recreate') as f:
        for c in channels:
            f.cd()
            d = f.mkdir(c)
            d.cd()
            n = mergeChannel(c, infiles)
            n.write()
示例#20
0
    "promptFS": "isPromptFinalState()",
    "dressedHPFS": "fromHardProcessFinalState()",
    "dressedFS": "status() == 1",
    "dressedPromptFS": "isPromptFinalState()",
}
if options.genLeptonType not in genLepChoices:
    print "ERROR: Invalid GEN-lepton type %s" % options.genLeptonType
    print "Valid optons and corresponding status flags are"
    print "    Format: keyword: status flag"
    print "    Default: hardProcessFS: fromHardProcessFinalState()"
    print "-" * 80
    for key, value in genLepChoices.iteritems():
        print "    %s: %s" % (key, value)
    exit(1)

channels = parseChannels(options.channels)
zz = any(len(c) == 4 for c in channels)
zl = any(len(c) == 3 for c in channels)
wz = "wz" in options.channels
z = any(len(c) == 2 for c in channels)
l = any(len(c) == 1 for c in channels)

### To use IgProf's neat memory profiling tools, run with the profile
### option and igprof like so:
###      $ igprof -d -mp -z -o igprof.mp.gz cmsRun profile=1 ...
### this will create a memory profile every 250 events so you can track use
### Turn the profile into text with
###      $ igprof-analyse -d -v -g -r MEM_LIVE igprof.yourOutputFile.gz > igreport_live.res
### To do a performance profile instead of a memory profile, change -mp to -pp
### in the first command and remove  -r MEM_LIVE from the second
### For interpretation of the output, see http://igprof.org/text-output-format.html