def _BuildHistogram(self, tree, comp, compName, varName, cut, layer ): '''Build one histogram, for a given component''' if not hasattr( comp, 'tree'): comp.tree = tree histName = '_'.join( [compName, self.varName] ) hist = None if self.xmin is not None and self.xmax is not None: hist = TH1F( histName, '', self.bins, self.xmin, self.xmax ) else: hist = TH1F( histName, '', len(self.bins)-1, self.bins ) hist.Sumw2() weight = self.eventWeight ## to do the following, modify the eventWeight before giving it to self ## if not comp.isData: ## weight = ' * '.join( [self.eventWeight, recEffId.weight(), recEffIso.weight()]) if tree == None: raise ValueError('tree does not exist for component '+compName) var = varName if not comp.isData and self.shift: if self.shift == 'Up': if varName == 'visMass' or varName == 'svfitMass': print 'Shifting visMass and svfitMass by sqrt(1.03) for', comp.name var = varName + '* sqrt(1.03)' elif self.shift == 'Down': if varName == 'visMass' or varName == 'svfitMass': print 'Shifting visMass and svfitMass by sqrt(0.97) for', comp.name var = varName + '* sqrt(0.97)' else: raise ValueError( self.shift + ' is not recognized. Use None, "Up" or "Down".') # hack to account for the shift determined for HCP, see: # https://indico.cern.ch/getFile.py/access?contribId=38&resId=0&materialId=slides&confId=212612 if isNewerThan('CMSSW_5_2_0'): # Andrew doesn't do the shift in 2011. if compName == 'Ztt_ZL' and self.treeName.find('TauEle') != -1: if varName == 'visMass' or varName == 'svfitMass': print 'Shifting visMass and svfitMass by 1.015 for', compName var = varName + '* 1.015' tree.Project( histName, var, '{weight}*({cut})'.format(cut=cut, weight=weight) ) hist.SetStats(0) componentName = compName legendLine = self._GetHistPref(compName)['legend'] if legendLine is None: legendLine = compName self.AddHistogram( componentName, hist, layer, legendLine) self.Hist(componentName).realName = comp.realName if comp.isData: self.Hist(componentName).stack = False
process.recoilCorMETDiTau.enable = True process.recoilCorMETDiTau.fileCorrectTo = correctFileName process.recoilCorMETDiTau.leptonLeg = leptonLeg process.recoilCorMETDiTau.fileZmmData = fileZmmData process.recoilCorMETDiTau.fileZmmMC = fileZmmMC process.recoilCorMETDiTau.correctionType = correctionType else: print '\tDISABLED' if runOnMC: process.metRecoilCorrectionInputSequence.remove( process.genWorZ ) if hasattr( process, 'recoilCorMETTauMu'): process.recoilCorMETTauMu.enable = False if hasattr( process, 'recoilCorMETTauEle'): process.recoilCorMETTauEle.enable = False if hasattr( process, 'recoilCorMETDiTau'): process.recoilCorMETDiTau.enable = False if __name__ == '__main__': import sys from CMGTools.Common.Tools.cmsswRelease import isNewerThan data, mc, type = basicParameters(isNewerThan('CMSSW_5_2_X')) for line in sys.stdin: print line = line.rstrip() print line print fileAndLeg(line, True, None, 'di-tau')
process.tobtecfakesfilterPath = cms.Path(~process.tobtecfakesfilter) process.schedule.append(process.tobtecfakesfilterPath) ## Close the schedule process.schedule.append(process.outpath) ## MessageLogger process.load("FWCore.MessageLogger.MessageLogger_cfi") process.MessageLogger.cerr.FwkReport.reportEvery = 10 process.MessageLogger.suppressWarning = cms.untracked.vstring( 'ecalLaserCorrFilter') ## Options and Output Report process.options = cms.untracked.PSet(wantSummary=cms.untracked.bool(True)) ## Print the schedule print process.schedule print sep_line print 'Fastjet instances (dominating our processing time...):' from CMGTools.Common.Tools.visitorUtils import SeqVisitor v = SeqVisitor('FastjetJetProducer') process.p.visit(v) print sep_line print 'starting CMSSW' if not runOnMC and isNewerThan('CMSSW_5_2_0'): process.pfJetMETcorr.jetCorrLabel = cms.string("ak5PFL1FastL2L3Residual")
# removing MC stuff print 'removing MC stuff, as we are running on Data' process.patElectrons.addGenMatch = False process.makePatElectrons.remove( process.electronMatch ) process.patMuons.addGenMatch = False process.makePatMuons.remove( process.muonMatch ) process.PATCMGSequence.remove( process.PATCMGGenSequence ) process.PATCMGJetSequence.remove( process.jetMCSequence ) process.PATCMGJetSequence.remove( process.patJetFlavourId ) process.patJets.addGenJetMatch = False process.patJets.addGenPartonMatch = False if isNewerThan('CMSSW_5_2_0'): process.PATCMGJetSequenceCHSpruned.remove( process.jetMCSequenceCHSpruned ) process.patJetsCHSpruned.addGenJetMatch = False process.patJetsCHSpruned.addGenPartonMatch = False process.PATCMGTauSequence.remove( process.tauGenJets ) process.PATCMGTauSequence.remove( process.tauGenJetsSelectorAllHadrons ) process.PATCMGTauSequence.remove( process.tauGenJetMatch ) process.PATCMGTauSequence.remove( process.tauMatch ) process.patTaus.addGenJetMatch = False process.patTaus.addGenMatch = False process.patMETs.addGenMET = False process.patMETsRaw.addGenMET = False # adding L2L3Residual corrections
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 recoilEnabled = True setupRecoilCorrection( process, runOnMC, enable=recoilEnabled, is53X=isNewerThan('CMSSW_5_2_X'),channel=channel) # Kinematic reweighting for the embedded samples from here https://twiki.cern.ch/twiki/bin/viewauth/CMS/MuonTauReplacementRecHit # Can also put this into a separate file under tools isEmbedded = process.source.fileNames[0].find('embedded') != -1 if isEmbedded: process.load('TauAnalysis.MCEmbeddingTools.embeddingKineReweight_cff') if channel == 'all': print 'ERROR: not possible to run all the channels for the embedded samples right now' # for "standard" e+tau channel if channel == 'tau-ele':
trackingFailureFilter.JetSource = 'ak5PFJets' trackingFailureSequence = cms.Sequence(goodVertices * trackingFailureFilter) trackingFailureFilterPath = cms.Path(trackingFailureSequence) metNoiseCleaning = cms.Sequence( primaryVertexFilter + noscraping + CSCTightHaloFilter + HBHENoiseFilter + hcalLaserEventFilter + EcalDeadCellTriggerPrimitiveFilter + trackingFailureSequence # eeBadScSequence+ # ecalLaserCorrSequence ) metNoiseCleaningPath = cms.Path(metNoiseCleaning) from CMGTools.Common.Tools.cmsswRelease import isNewerThan if isNewerThan('CMSSW_5_2_0'): #the HCal noise filter works on AOD in 5.2. in 44, a list of events was used. hcalLaserEventFilter.vetoByRunEventNumber = cms.untracked.bool(False) hcalLaserEventFilter.vetoByHBHEOccupancy = cms.untracked.bool(True) #the ee bad sc filter is only available in 5X ## Bad EE Supercrystal filter from RecoMET.METFilters.eeBadScFilter_cfi import eeBadScFilter eeBadScFilterPath = cms.Path(eeBadScFilter) metNoiseCleaning += eeBadScFilter ## EB or EE Xtals with large laser calibration correction from RecoMET.METFilters.ecalLaserCorrFilter_cfi import ecalLaserCorrFilter ecalLaserFilterPath = cms.Path(ecalLaserCorrFilter) metNoiseCleaning += ecalLaserCorrFilter else: print >> sys.stderr, 'hcalLaserFilterFromAOD, eeBadScFilter and ecalLaserFilter only available in releases >= 5.2'
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 from CMGTools.Common.Tools.cmsswRelease import isNewerThan pt1 = 20 pt2 = 20 # 2011 if isNewerThan('CMSSW_5_2_0'): pt2 = 24 #2012 # ELECTRON = lepton 1 # TAU = lepton 2 # this has to be in sync with: # - H2TauTau/python/proto/analyzers/TauEleAnalyzer.py # - H2TauTau/Colin/tauEle_2012_cfg.py # - H2TauTau/python/objects/eleCuts_cff.py # - H2TauTau/python/objects/tauCuts_cff.py # - H2TauTau/python/objects/tauEleCuts_cff.py # inc_sig_tau = Cut('l1_looseMvaIso>0.5 && l1_againstElectronMVA > 0.5 && l1_againstElectronTightMVA2 > 0.5 && l1_againstElectronMedium > 0.5 && l1_againstMuonLoose > 0.5 && l1_dxy<0.045 && l1_dz<0.2 && l1_pt>{pt1}'.format(pt1=pt1)) inc_sig_tau = Cut('leptonAccept && thirdLeptonVeto && l1_threeHitIso<1.5 && l1_againstElectronMVA3Medium > 0.5 && l1_againstMuonLoose > 0.5 && l1_dxy<0.045 && l1_dz<0.2 && l1_pt>{pt1}'.format(pt1=pt1)) inc_sig_ele = Cut('l2_relIso05<0.1 && l2_tightId>0.5 && l2_dxy<0.045 && l2_dz<0.2 && l2_pt>{pt2}'.format(pt2=pt2)) passleptonvetoes = Cut('leptonAccept > 0.5 && thirdLeptonVeto > 0.5') #inc_sig = inc_sig_ele & inc_sig_tau
) patJets.userData.userFunctionLabels = cms.vstring('secvtxMass','Lxy','LxyErr') # parton and gen jet matching from CommonTools.ParticleFlow.genForPF2PAT_cff import * from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import * patJetPartonMatch.src = jetSource patJetGenJetMatch.src = jetSource patJetGenJetMatch.matched = 'ak5GenJetsNoNu' from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import * patJetPartonAssociation.jets = jetSource jetsPtGt1Cut = '(neutralHadronEnergy())/(correctedJet(0).pt()/pt()*energy()) < 0.99 && (neutralEmEnergy()/(correctedJet(0).pt()/pt()*energy())) < 0.99 && (nConstituents()) > 1 && ((abs(eta()) < 2.4 && chargedHadronEnergy()/(correctedJet(0).pt()/pt()*energy()) > 0 && chargedEmEnergy() /(correctedJet(0).pt()/pt()*energy()) < 0.99 && chargedMultiplicity() > 0) || abs(eta()) > 2.4) ' if not isNewerThan('CMSSW_5_2_0'): # addtl cut needed due to different MVA MET training in 44X jetsPtGt1Cut = ' && '.join([jetsPtGt1Cut,'pt()>1']) jetsPtGt1 = cmgCandSel.clone( src = 'patJets', cut = jetsPtGt1Cut ) from CMGTools.Common.miscProducers.collectionSize.candidateSize_cfi import candidateSize nJetsPtGt1 = candidateSize.clone( src = 'jetsPtGt1' ) # jet extender patJetsWithVar = cms.EDProducer('JetExtendedProducer', jets = cms.InputTag('selectedPatJets'), vertices = cms.InputTag('goodOfflinePrimaryVertices'), #debug = cms.untracked.bool(True), payload = cms.string('AK5PF') )
def __init__(self, cfg_ana, cfg_comp, looperName): super(VBFAnalyzer,self).__init__(cfg_ana, cfg_comp, looperName) self.btagSF = BTagSF (cfg_ana.btagSFseed) # import pdb; pdb.set_trace() self.is2012 = isNewerThan('CMSSW_5_2_0')
process.schedule = getSchedule(process, runOnMC, runOnFastSim) process.schedule.append(process.outpath) ## MessageLogger process.load("FWCore.MessageLogger.MessageLogger_cfi") process.MessageLogger.cerr.FwkReport.reportEvery = 10 process.MessageLogger.suppressWarning = cms.untracked.vstring( "ecalLaserCorrFilter", "manystripclus53X", "toomanystripclus53X" ) ## Options and Output Report process.options = cms.untracked.PSet(wantSummary=cms.untracked.bool(False)) if not runOnMC and isNewerThan("CMSSW_5_2_0"): process.pfJetMETcorr.jetCorrLabel = cms.string("ak5PFL1FastL2L3Residual") if runOnFastSim: process.patElectronsWithRegression.rhoCollection = cms.InputTag("kt6PFJets", "rho", "HLT") ## Last minute fixes # process.PATJetSequenceCHS.remove(process.outTracksCHS) # process.PATJetSequenceCHS.remove(process.ak5SoftTrackJetsForVbfHbbCHS) print sep_line print "Fastjet instances (dominating our processing time...):" from CMGTools.Common.Tools.visitorUtils import SeqVisitor
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 recoilEnabled = True setupRecoilCorrection(process, runOnMC, enable=recoilEnabled, is53X=isNewerThan("CMSSW_5_2_X"), channel=channel) # Kinematic reweighting for the embedded samples from here https://twiki.cern.ch/twiki/bin/viewauth/CMS/MuonTauReplacementRecHit # Can also put this into a separate file under tools isEmbedded = process.source.fileNames[0].find("embedded") != -1 if isEmbedded: process.load("TauAnalysis.MCEmbeddingTools.embeddingKineReweight_cff") if channel == "all": print "ERROR: not possible to run all the channels for the embedded samples right now" # for "standard" e+tau channel if channel == "tau-ele":
) patJets.userData.userFunctionLabels = cms.vstring('secvtxMass','Lxy','LxyErr') # parton and gen jet matching from CommonTools.ParticleFlow.genForPF2PAT_cff import * from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import * patJetPartonMatch.src = jetSource patJetGenJetMatch.src = jetSource patJetGenJetMatch.matched = 'ak5GenJetsNoNu' from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import * patJetPartonAssociation.jets = jetSource jetsPtGt1Cut = '(neutralHadronEnergy())/(correctedJet(0).pt()/pt()*energy()) < 0.99 && (neutralEmEnergy()/(correctedJet(0).pt()/pt()*energy())) < 0.99 && (nConstituents()) > 1 && ((abs(eta()) < 2.4 && chargedHadronEnergy()/(correctedJet(0).pt()/pt()*energy()) > 0 && chargedEmEnergy() /(correctedJet(0).pt()/pt()*energy()) < 0.99 && chargedMultiplicity() > 0) || abs(eta()) > 2.4) ' if not isNewerThan('CMSSW_5_2_0'): # addtl cut needed due to different MVA MET training in 44X jetsPtGt1Cut = ' && '.join([jetsPtGt1Cut,'pt()>1']) jetsPtGt1 = cmgCandSel.clone( src = 'patJets', cut = jetsPtGt1Cut ) from CMGTools.Common.miscProducers.collectionSize.candidateSize_cfi import candidateSize nJetsPtGt1 = candidateSize.clone( src = 'jetsPtGt1' ) # QG Tagger QGTagger = cms.EDProducer('QGTagger', srcJets = cms.InputTag('selectedPatJets'), isPatJet = cms.untracked.bool(True), useCHS = cms.untracked.bool(False), srcRho = cms.InputTag('kt6PFJets','rho'), srcRhoIso = cms.InputTag('kt6PFJetsIsoQG','rho'), )
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 recoilEnabled = True setupRecoilCorrection(process, runOnMC, enable=recoilEnabled, is53X=isNewerThan('CMSSW_5_2_X')) # Kinematic reweighting for the embedded samples from here https://twiki.cern.ch/twiki/bin/viewauth/CMS/MuonTauReplacementRecHit # Can also put this into a separate file under tools isEmbedded = process.source.fileNames[0].find('embedded') != -1 if isEmbedded: process.load('TauAnalysis.MCEmbeddingTools.embeddingKineReweight_cff') if channel == 'all': print 'ERROR: not possible to run all the channels for the embedded samples right now' # for "standard" e+tau channel if channel == 'tau-ele': process.embeddingKineReweightRECembedding.inputFileName = cms.FileInPath(
import FWCore.ParameterSet.Config as cms from CMGTools.Common.Tools.cmsswRelease import isNewerThan is53X = isNewerThan('CMSSW_5_2_X') def getEleCuts(leg, channel='tauEle', skim=False): ptCut = None etaCut = None # lmvaID = -99999 lmvaID1 = -99999 lmvaID2 = -99999 lmvaID3 = -99999 # isoCut = 100 if channel == 'tauEle': ptCut = 20. if is53X: ptCut = 24. etaCut = 2.1 # lmvaID = 0.9 lmvaID1 = 0.925 lmvaID2 = 0.975 lmvaID3 = 0.985 # isoCut = 0.3 elif channel == 'muEle': ptCut = 20. etaCut = 2.3 else: raise ValueError('bad channel specification:'+channel) if skim: