Beispiel #1
0
 def declareHandles(self):
     super(EmbedWeighter,self).declareHandles()
     #import pdb ; pdb.set_trace()
     if self.cfg_comp.isEmbed:
         isRHEmbedded = self.cfg_ana.isRecHit
         if 'PFembedded' in self.cfg_comp.name and isRHEmbedded :
           'WARNING: in the cfg you set RecHit, but this appears to be PF embedded'
         if 'RHembedded' in self.cfg_comp.name and not isRHEmbedded :
           'WARNING: in the cfg you set PF, but this appears to be RecHit embedded'
         if cmsswIs52X():
             self.embhandles['minVisPtFilter'] = AutoHandle(
                 ('generator', 'minVisPtFilter'),
                 'GenFilterInfo'
                 )
             self.embhandles['genpart'] =  AutoHandle(
                     'genParticles',
                     'std::vector<reco::GenParticle>'
                     )
             if isRHEmbedded:
                 self.embhandles['TauSpinnerReco'] = AutoHandle(
                     ('TauSpinnerReco', 'TauSpinnerWT'),
                     'double'
                     )
                 self.embhandles['ZmumuEvtSelEffCorrWeightProducer'] = AutoHandle(
                     ('ZmumuEvtSelEffCorrWeightProducer', 'weight'),
                     'double'
                     )
                 self.embhandles['muonRadiationCorrWeightProducer'] = AutoHandle(
                     ('muonRadiationCorrWeightProducer', 'weight'),
                     'double'
                     )
                 self.embhandles['genTau2PtVsGenTau1Pt'] = AutoHandle(
                     ('embeddingKineReweightRECembedding', 'genTau2PtVsGenTau1Pt'),
                     'double'
                     )
                 self.embhandles['genTau2EtaVsGenTau1Eta'] = AutoHandle(
                     ('embeddingKineReweightRECembedding', 'genTau2EtaVsGenTau1Eta'),
                     'double'
                     )
                 self.embhandles['genDiTauMassVsGenDiTauPt'] = AutoHandle(
                     ('embeddingKineReweightRECembedding', 'genDiTauMassVsGenDiTauPt'),
                     'double'
                     )
                 
         else:
             self.embhandles['minVisPtFilter'] = AutoHandle(
                 ('generator', 'weight'),
                 'double'
                 )
Beispiel #2
0
    def declareHandles(self):
        super(EmbedWeighter, self).declareHandles()
        #import pdb ; pdb.set_trace()
        if self.cfg_comp.isEmbed:
            isRHEmbedded = self.cfg_ana.isRecHit
            if 'PFembedded' in self.cfg_comp.name and isRHEmbedded:
                'WARNING: in the cfg you set RecHit, but this appears to be PF embedded'
            if 'RHembedded' in self.cfg_comp.name and not isRHEmbedded:
                'WARNING: in the cfg you set PF, but this appears to be RecHit embedded'
            if cmsswIs52X():
                self.embhandles['minVisPtFilter'] = AutoHandle(
                    ('generator', 'minVisPtFilter'), 'GenFilterInfo')
                self.embhandles['genpart'] = AutoHandle(
                    'genParticles', 'std::vector<reco::GenParticle>')
                if isRHEmbedded:
                    self.embhandles['TauSpinnerReco'] = AutoHandle(
                        ('TauSpinnerReco', 'TauSpinnerWT'), 'double')
                    self.embhandles[
                        'ZmumuEvtSelEffCorrWeightProducer'] = AutoHandle(
                            ('ZmumuEvtSelEffCorrWeightProducer', 'weight'),
                            'double')
                    self.embhandles[
                        'muonRadiationCorrWeightProducer'] = AutoHandle(
                            ('muonRadiationCorrWeightProducer', 'weight'),
                            'double')
                    self.embhandles['genTau2PtVsGenTau1Pt'] = AutoHandle(
                        ('embeddingKineReweightRECembedding',
                         'genTau2PtVsGenTau1Pt'), 'double')
                    self.embhandles['genTau2EtaVsGenTau1Eta'] = AutoHandle(
                        ('embeddingKineReweightRECembedding',
                         'genTau2EtaVsGenTau1Eta'), 'double')
                    self.embhandles['genDiTauMassVsGenDiTauPt'] = AutoHandle(
                        ('embeddingKineReweightRECembedding',
                         'genDiTauMassVsGenDiTauPt'), 'double')

            else:
                self.embhandles['minVisPtFilter'] = AutoHandle(
                    ('generator', 'weight'), 'double')
# set up JSON ---------------------------------------------------------------
if runOnMC==False:
    from CMGTools.H2TauTau.tools.setupJSON import setupJSON
    json = setupJSON(process)



# load the channel paths -------------------------------------------
process.load('CMGTools.H2TauTau.h2TauTau_cff')

# setting up the recoil correction according to the input file ---------------

print sep_line
from CMGTools.H2TauTau.tools.setupRecoilCorrection import setupRecoilCorrection
# WARNING DISABLING RECOIL CORRECTIONS FOR 2012!!!
setupRecoilCorrection( process, runOnMC, True, cmsswIs52X(), 'WJetsToLNu')

# OUTPUT definition ----------------------------------------------------------
process.outpath = cms.EndPath()

# generator ----------------------------------------------
if not runOnMC:
    process.tauMuPath.remove( process.genSequence )
    process.tauElePath.remove( process.genSequence )
    process.diTauPath.remove( process.genSequence )


# muon removal sequence
# ----

# need to clean that up a bit...
    process.EcalDeadCellTriggerPrimitiveFilterPath,
    process.greedyMuonPFCandidateFilterPath,
############# <-
    process.hcalLaserEventFilterPath,
    process.inconsistentMuonPFCandidateFilterPath,
    process.trackingFailureFilterPath,
############# ->
    process.CSCTightHaloFilterPath,
############# <-
    process.HBHENoiseFilterPath,
    process.primaryVertexFilterPath,
    process.noscrapingFilterPath
    )

from CMGTools.Common.Tools.cmsswRelease import cmsswIs52X
if cmsswIs52X():
    process.fullPath.append(process.hcalLaserFilterFromAODPath)
else:
    print 'NO hcalLaserFilterFromAOD available for releases < 5.2'

#this is needed only for Madgraph MC:
if runOnMC:
    process.fullPath.append(process.totalKinematicsFilterPath)
else:
    del process.totalKinematicsFilterPath

### OUTPUT DEFINITION #############################################

# PFBRECO+PAT ---

# Add PFBRECO output to the created file
Beispiel #5
0
    def process(self, iEvent, event):
        self.readCollections( iEvent )
        self.weight = 1
        isRHEmbedded = self.cfg_ana.isRecHit
        if 'PFembedded' in self.cfg_comp.name and isRHEmbedded :
          'WARNING: in the cfg you set RecHit, but this appears to be PF embedded'
        if 'RHembedded' in self.cfg_comp.name and not isRHEmbedded :
          'WARNING: in the cfg you set PF, but this appears to be RecHit embedded'
        event.genfilter                = 1.
        event.tauspin                  = 1.
        event.zmumusel                 = 1.
        event.muradcorr                = 1.
        event.genTau2PtVsGenTau1Pt     = 1.
        event.genTau2EtaVsGenTau1Eta   = 1.
        event.genDiTauMassVsGenDiTauPt = 1.
        if self.cfg_comp.isEmbed or self.cfg_comp.name == 'TTJets_emb' :
            try: 
                genfilter = self.embhandles['minVisPtFilter'].product()
                if isRHEmbedded:
                    tauspin                  = self.embhandles['TauSpinnerReco'].product()
                    zmumusel                 = self.embhandles['ZmumuEvtSelEffCorrWeightProducer'].product()
                    muradcorr                = self.embhandles['muonRadiationCorrWeightProducer'].product()
                    genTau2PtVsGenTau1Pt     = self.embhandles['genTau2PtVsGenTau1Pt'].product()
                    genTau2EtaVsGenTau1Eta   = self.embhandles['genTau2EtaVsGenTau1Eta'].product()
                    genDiTauMassVsGenDiTauPt = self.embhandles['genDiTauMassVsGenDiTauPt'].product()
            except RuntimeError:
                print 'WARNING EmbedWeighter, cannot find the weight in the event'
                return False	
            if cmsswIs52X():
                self.weight = genfilter.filterEfficiency()
                if isRHEmbedded:
                    self.weight *= tauspin[0]
                    self.weight *= zmumusel[0]
                    self.weight *= muradcorr[0]
                    self.weight *= genTau2PtVsGenTau1Pt[0]
                    self.weight *= genTau2EtaVsGenTau1Eta[0]
                    self.weight *= genDiTauMassVsGenDiTauPt[0]

                event.genfilter                = genfilter.filterEfficiency()

                if isRHEmbedded:
                  event.tauspin                  = tauspin[0]
                  event.zmumusel                 = zmumusel[0]
                  event.muradcorr                = muradcorr[0]
                  event.genTau2PtVsGenTau1Pt     = genTau2PtVsGenTau1Pt[0]
                  event.genTau2EtaVsGenTau1Eta   = genTau2EtaVsGenTau1Eta[0]
                  event.genDiTauMassVsGenDiTauPt = genDiTauMassVsGenDiTauPt[0]

                self.counters.counter('EmbedWeighter').inc('all events')

                event.genParticles = map( GenParticle, self.embhandles['genpart'].product() )
                genTaus = [p for p in event.genParticles if abs(p.pdgId()) == 15]
                if len(genTaus) != 2:
                    print 'WARNING EmbedWeighter, not 2 gen taus in the event'
                genZMass = (genTaus[0].p4() + genTaus[1].p4()).mass()
                
                if genZMass < 50.:
                    return False
                self.counters.counter('EmbedWeighter').inc('gen Z mass > 50')
            else: 
                self.weight = genfilter[0]
        if self.cfg_ana.verbose:
            print self.name, 'efficiency =', self.weight
        event.eventWeight *= self.weight
        event.embedWeight = self.weight
        self.averages['weight'].add( self.weight )
        return True
Beispiel #6
0
    json = setupJSON(process)

# load the channel paths -------------------------------------------
process.load('CMGTools.H2TauTau.h2TauTau_cff')

# REMOVING SKIMMING CUTS
process.diTauCuts.baseline.mass = ''
process.cmgDiTauPreSel.cut = ''
process.diTauFullSelCount.minNumber = 0

# setting up the recoil correction according to the input file ---------------

print sep_line
from CMGTools.H2TauTau.tools.setupRecoilCorrection import setupRecoilCorrection
# WARNING DISABLING RECOIL CORRECTIONS FOR 2012!!!
setupRecoilCorrection(process, runOnMC, True, cmsswIs52X())

# OUTPUT definition ----------------------------------------------------------
process.outpath = cms.EndPath()

# generator ----------------------------------------------
if not runOnMC:
    process.tauMuPath.remove(process.genSequence)
    process.tauElePath.remove(process.genSequence)
    process.diTauPath.remove(process.genSequence)

#Jose: process.schedule doesn't have a += operator?
if channel == 'all':
    process.schedule = cms.Schedule(
        process.tauMuPath,
        process.tauElePath,
Beispiel #7
0
    def process(self, iEvent, event):
        self.readCollections(iEvent)
        self.weight = 1
        isRHEmbedded = False
        event.genfilter = 1.
        event.tauspin = 1.
        event.zmumusel = 1.
        event.muradcorr = 1.
        event.genTau2PtVsGenTau1Pt = 1.
        event.genTau2EtaVsGenTau1Eta = 1.
        event.genDiTauMassVsGenDiTauPt = 1.
        if self.cfg_comp.isEmbed:
            try:
                genfilter = self.embhandles['minVisPtFilter'].product()
                if isRHEmbedded:
                    tauspin = self.embhandles['TauSpinnerReco'].product()
                    zmumusel = self.embhandles[
                        'ZmumuEvtSelEffCorrWeightProducer'].product()
                    muradcorr = self.embhandles[
                        'muonRadiationCorrWeightProducer'].product()
                    genTau2PtVsGenTau1Pt = self.embhandles[
                        'genTau2PtVsGenTau1Pt'].product()
                    genTau2EtaVsGenTau1Eta = self.embhandles[
                        'genTau2EtaVsGenTau1Eta'].product()
                    genDiTauMassVsGenDiTauPt = self.embhandles[
                        'genDiTauMassVsGenDiTauPt'].product()
            except RuntimeError:
                print 'WARNING EmbedWeighter, cannot find the weight in the event'
                return False
            if cmsswIs52X():
                self.weight = genfilter.filterEfficiency()
                if isRHEmbedded:
                    self.weight *= tauspin[0]
                    self.weight *= zmumusel[0]
                    self.weight *= muradcorr[0]
                    self.weight *= genTau2PtVsGenTau1Pt[0]
                    self.weight *= genTau2EtaVsGenTau1Eta[0]
                    self.weight *= genDiTauMassVsGenDiTauPt[0]

                event.genfilter = genfilter.filterEfficiency()

                if isRHEmbedded:
                    event.tauspin = tauspin[0]
                    event.zmumusel = zmumusel[0]
                    event.muradcorr = muradcorr[0]
                    event.genTau2PtVsGenTau1Pt = genTau2PtVsGenTau1Pt[0]
                    event.genTau2EtaVsGenTau1Eta = genTau2EtaVsGenTau1Eta[0]
                    event.genDiTauMassVsGenDiTauPt = genDiTauMassVsGenDiTauPt[
                        0]

                self.counters.counter('EmbedWeighter').inc('all events')

                event.genParticles = map(GenParticle,
                                         self.embhandles['genpart'].product())
                genTaus = [
                    p for p in event.genParticles if abs(p.pdgId()) == 15
                ]
                if len(genTaus) != 2:
                    print 'WARNING EmbedWeighter, not 2 gen taus in the event'
                genZMass = (genTaus[0].p4() + genTaus[1].p4()).mass()
                # import pdb; pdb.set_trace()

                if genZMass < 50.:
                    return False
                self.counters.counter('EmbedWeighter').inc('gen Z mass > 50')
            else:
                self.weight = genfilter[0]
        if self.cfg_ana.verbose:
            print self.name, 'efficiency =', self.weight
        event.eventWeight *= self.weight
        event.embedWeight = self.weight
        self.averages['weight'].add(self.weight)
        return True
Beispiel #8
0
import copy

from CMGTools.H2TauTau.proto.plotter.categories_common import *
from CMGTools.H2TauTau.proto.plotter.cut import *

from CMGTools.Common.Tools.cmsswRelease import cmsswIs44X, cmsswIs52X

pt1 = 20
pt2 = 17  # 2011
if cmsswIs52X():
    pt2 = 20  # 2012, check that

#inc_sig_tau = Cut('l1_looseMvaIso>0.5 && (l1_EOverp>0.2 || l1_decayMode!=0) && l1_againstMuonTight>0.5 && l1_againstElectronLoose>0.5 && l1_dxy<0.045 && l1_dz<0.2 && l1_pt>{pt1}'.format(pt1=pt1))
#inc_sig_tau = Cut('l1_looseMvaIso>0.5 && l1_againstMuonTight>0.5 && l1_againstElectronLoose>0.5 && l1_dxy<0.045 && l1_dz<0.2 && l1_pt>{pt1}'.format(pt1=pt1))

# NEW one - to be implemented as soon as trees are there
inc_sig_tau = Cut(
    'leptonAccept && thirdLeptonVeto && l1_threeHitIso<1.5 && l1_againstMuonTight>0.5 && l1_againstElectronLoose>0.5 && l1_dxy<0.045 && l1_dz<0.2 && l1_pt>{pt1}'
    .format(pt1=pt1))

inc_sig_mu = Cut(
    'l2_relIso05<0.1 && l2_tightId>0.5 && l2_dxy<0.045 && l2_dz<0.2 && l2_pt>{pt2}'
    .format(pt2=pt2))
inc_sig = inc_sig_mu & inc_sig_tau

inc_sig_mu_elelike = Cut(
    'l2_relIso05<0.1 && l2_tightId>0.5 && l2_dxy<0.045 && l2_dz<0.2 && l2_pt>{pt2}'
    .format(pt2=24.))

inc_sig_elelike = inc_sig_mu_elelike & inc_sig_tau
Beispiel #9
0
# set up JSON ---------------------------------------------------------------
if runOnMC == False:
    from CMGTools.Common.Tools.applyJSON_cff import applyJSON
    json = "/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions12/8TeV/Prompt/Cert_190456-208686_8TeV_PromptReco_Collisions12_JSON.txt"
    #json="/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions12/8TeV/Reprocessing/Cert_190456-196531_8TeV_13Jul2012ReReco_Collisions12_JSON_v2.txt"
    applyJSON(process, json)

# load the channel paths -------------------------------------------
process.load('CMGTools.H2TauTau.h2TauTau_cff')

# setting up the recoil correction according to the input file ---------------

print sep_line
from CMGTools.H2TauTau.tools.setupRecoilCorrection import setupRecoilCorrection, lookup, rootfile_dir
# WARNING DISABLING RECOIL CORRECTIONS FOR 2012!!!
setupRecoilCorrection(process, runOnMC, True, cmsswIs52X(), None, channel)

# OUTPUT definition ----------------------------------------------------------
process.outpath = cms.EndPath()

# generator ----------------------------------------------
if not runOnMC:
    process.tauMuPath.remove(process.genSequence)
    process.tauElePath.remove(process.genSequence)
    process.diTauPath.remove(process.genSequence)

if channel == 'all':
    process.schedule = cms.Schedule(
        process.tauMuPath,
        process.tauElePath,
        # process.muElePath,
# load the channel paths -------------------------------------------
process.load('CMGTools.H2TauTau.h2TauTau_cff')


# REMOVING SKIMMING CUTS
process.diTauCuts.baseline.mass=''
process.cmgDiTauPreSel.cut=''
process.diTauFullSelCount.minNumber=0

# setting up the recoil correction according to the input file ---------------

print sep_line
from CMGTools.H2TauTau.tools.setupRecoilCorrection import setupRecoilCorrection
# WARNING DISABLING RECOIL CORRECTIONS FOR 2012!!!
setupRecoilCorrection( process, runOnMC, True, cmsswIs52X())

# OUTPUT definition ----------------------------------------------------------
process.outpath = cms.EndPath()

# generator ----------------------------------------------
if not runOnMC:
    process.tauMuPath.remove( process.genSequence )
    process.tauElePath.remove( process.genSequence )
    process.diTauPath.remove( process.genSequence )
    

#Jose: process.schedule doesn't have a += operator?
if channel=='all':
    process.schedule = cms.Schedule(
        process.tauMuPath,
    from CMGTools.Common.Tools.applyJSON_cff import applyJSON
    json="/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions12/8TeV/Prompt/Cert_190456-208686_8TeV_PromptReco_Collisions12_JSON.txt"
    #json="/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions12/8TeV/Reprocessing/Cert_190456-196531_8TeV_13Jul2012ReReco_Collisions12_JSON_v2.txt"
    applyJSON(process, json )



# load the channel paths -------------------------------------------
process.load('CMGTools.H2TauTau.h2TauTau_cff')

# setting up the recoil correction according to the input file ---------------

print sep_line
from CMGTools.H2TauTau.tools.setupRecoilCorrection import setupRecoilCorrection,lookup,rootfile_dir
# WARNING DISABLING RECOIL CORRECTIONS FOR 2012!!!
setupRecoilCorrection( process, runOnMC, True, cmsswIs52X(), None, channel)

# OUTPUT definition ----------------------------------------------------------
process.outpath = cms.EndPath()

# generator ----------------------------------------------
if not runOnMC:
    process.tauMuPath.remove( process.genSequence )
    process.tauElePath.remove( process.genSequence )
    process.diTauPath.remove( process.genSequence )
    

if channel=='all':
    process.schedule = cms.Schedule(
        process.tauMuPath,
        process.tauElePath,
Beispiel #12
0
# Sequence & path definition -------------------------------------------------

# set up JSON ---------------------------------------------------------------
if runOnMC == False:
    from CMGTools.H2TauTau.tools.setupJSON import setupJSON
    json = setupJSON(process)

# load the channel paths -------------------------------------------
process.load('CMGTools.H2TauTau.h2TauTau_cff')

# setting up the recoil correction according to the input file ---------------

print sep_line
from CMGTools.H2TauTau.tools.setupRecoilCorrection import setupRecoilCorrection
# WARNING DISABLING RECOIL CORRECTIONS FOR 2012!!!
setupRecoilCorrection(process, runOnMC, True, cmsswIs52X(), 'WJetsToLNu')

# OUTPUT definition ----------------------------------------------------------
process.outpath = cms.EndPath()

# generator ----------------------------------------------
if not runOnMC:
    process.tauMuPath.remove(process.genSequence)
    process.tauElePath.remove(process.genSequence)
    process.diTauPath.remove(process.genSequence)

# muon removal sequence
# ----

# need to clean that up a bit...
# mu faking tau small, but we could think of removing tau candidates corresponding to the removed mu