import FinalStateAnalysis.NtupleTools.templates as templates # Define the branches that go in all ntuples _common_template = PSet( # Basic info about the final state templates.topology.finalstate, # templates.Event num/lumi/run templates.event.num, # templates.Rho, ntvtx, nTruePU templates.event.pileup, # information about the selected primary vertex templates.event.pv_info, # templates.Info about the MET templates.event.met, # templates.Info about the generator templates.event.gen, # templates.Vetoes on extra objects templates.cleaning.vetos, # Need to fill out photon triggers templates.trigger.mueg, templates.trigger.doublemu, templates.trigger.doublee, templates.trigger.isomu, templates.trigger.isomu24eta2p1, templates.trigger.singlemu, templates.trigger.singlee, templates.trigger.singlePho, templates.trigger.doublePho, templates.trigger.isoMuTau) # Define the branch templates for different object types. _tau_template = PSet(
""" Ntuple branch template sets for trigger selections Each string is transformed into an expression on a FinalStateEvent object. Author: Evan K. Friis """ from FinalStateAnalysis.Utilities.cfgtools import PSet _trig_template = PSet( namePass='******', nameGroup='evt.hltGroup("paths")', namePrescale='evt.hltPrescale("paths")' ) singlemu = _trig_template.replace(name="singleMu", paths=r"HLT_Mu15_v\\d+, HLT_Mu24_v\\d+, HLT_Mu30_v\\d+") isomu = _trig_template.replace( name="isoMu", paths=r"HLT_IsoMu17_v\\d+, HLT_IsoMu20_v\\d+, " r"HLT_IsoMu24_v\\d+, HLT_IsoMu24_eta2p1_v\\d+, " r"HLT_IsoMu30_v\\d+, HLT_IsoMu30_eta2p1_v\\d+", ) isomu24eta2p1 = _trig_template.replace(name="isoMu24eta2p1", paths=r"HLT_IsoMu24_eta2p1_v\\d+") doublemu = PSet( _trig_template.replace(name="doubleMu", paths=r"HLT_DoubleMu7_v\\d+,HLT_Mu13_Mu8_v\\d+,HLT_Mu17_Mu8_v\\d+"), _trig_template.replace(name="doubleMuTrk", paths=r"HLT_DoubleMu7_v\\d+,HLT_Mu13_Mu8_v\\d+,HLT_Mu17_TrkMu8_v\\d+"), _trig_template.replace(name="mu17mu8", paths=r"HLT_Mu17_Mu8_v\\d+"),
''' Ntuple branch template sets for trigger selections Each string is transformed into an expression on a FinalStateEvent object. Author: Evan K. Friis ''' from FinalStateAnalysis.Utilities.cfgtools import PSet _trig_template = PSet( namePass='******', nameGroup='evt.hltGroup("paths")', namePrescale='evt.hltPrescale("paths")', ) singlemu = _trig_template.replace( name='singleMu', paths=r'HLT_Mu15_v\\d+, HLT_Mu24_v\\d+, HLT_Mu30_v\\d+') isomu = _trig_template.replace(name='isoMu', paths=r'HLT_IsoMu17_v\\d+, HLT_IsoMu20_v\\d+, ' r'HLT_IsoMu24_v\\d+, HLT_IsoMu24_eta2p1_v\\d+, ' r'HLT_IsoMu30_v\\d+, HLT_IsoMu30_eta2p1_v\\d+') doublemu = PSet( _trig_template.replace( name='doubleMu', paths=r'HLT_DoubleMu7_v\\d+,HLT_Mu13_Mu8_v\\d+,HLT_Mu17_Mu8_v\\d+'), _trig_template.replace(
vetos = PSet( #MUON VETOS muVetoPt5='vetoMuons(0.4, "pt > 5 & abs(eta) < 2.4").size()', muGlbIsoVetoPt10= 'vetoMuons(0.4, "isGlobalMuon & isTrackerMuon & pt > 10 & abs(eta) < 2.4 & (userIso(0) + max(photonIso + neutralHadronIso - 0.5*puChargedHadronIso, 0))/pt < 0.4").size()', muVetoPt5IsoIdVtx= 'vetoMuons(0.4, "pt > 5 & abs(eta) < 2.4 & userInt(\'tightID\') > 0.5 & ((userIso(0) + max(photonIso()+neutralHadronIso()-0.5*puChargedHadronIso,0.0))/pt()) < 0.15 & userFloat(\'dz\') < 0.2").size()', muVetoPt15IsoIdVtx= 'vetoMuons(0.4, "pt > 15 & abs(eta) < 2.4 & userInt(\'tightID\') > 0.5 & ((userIso(0) + max(photonIso()+neutralHadronIso()-0.5*puChargedHadronIso,0.0))/pt()) < 0.15 & userFloat(\'dz\') < 0.2").size()', #TAU VETOS tauVetoPt20= 'vetoTaus(0.4, "pt > 20 & abs(eta) < 2.5 & tauID(\'decayModeFinding\') & tauID(\'byLooseIsolationMVA\')").size()', tauHpsVetoPt20= 'vetoTaus(0.3, "pt > 20 & abs(eta) < 2.3 & tauID(\'decayModeFinding\') & tauID(\'againstElectronLoose\') & tauID(\'againstMuonLoose\') & tauID(\'byMediumCombinedIsolationDeltaBetaCorr\')").size()', tauVetoPt20LooseMVAVtx= 'vetoTaus(0.4, "pt > 20 & abs(eta) < 2.5 & tauID(\'decayModeFinding\') & tauID(\'byLooseIsolationMVA\') & userFloat(\'dz\') < 0.2").size()', tauVetoPt20LooseMVA2Vtx= 'vetoTaus(0.4, "pt > 20 & abs(eta) < 2.5 & tauID(\'decayModeFinding\') & tauID(\'byLooseIsolationMVA2\') & userFloat(\'dz\') < 0.2").size()', tauVetoPt20Loose3HitsVtx= 'vetoTaus(0.4, "pt > 20 & abs(eta) < 2.5 & tauID(\'decayModeFinding\') & tauID(\'byLooseCombinedIsolationDeltaBetaCorr3Hits\') & userFloat(\'dz\') < 0.2").size()', tauVetoPt20VLooseHPSVtx= 'vetoTaus(0.4, "pt > 20 & abs(eta) < 2.5 & tauID(\'decayModeFinding\') & tauID(\'byVLooseCombinedIsolationDeltaBetaCorr\') & userFloat(\'dz\') < 0.2").size()', #ELECTRON VETOS eVetoMVAIsoVtx= 'vetoElectrons(0.4, "pt > 10 & abs(eta) < 2.5 & userInt(\'mvaidwp\') > 0.5 & ((userIso(0) + max(userIso(1) + neutralHadronIso - 0.5*userIso(2), 0))/pt) < 0.3 & userFloat(\'dz\') < 0.2").size()', eVetoMVAIso= 'vetoElectrons(0.4, "pt > 10 & abs(eta) < 2.5 & userInt(\'mvaidwp\') > 0.5 & (userIso(0) + max(userIso(1) + neutralHadronIso - 0.5*userIso(2), 0))/pt < 0.3").size()', eVetoCicTightIso= 'vetoElectrons(0.4, "pt > 10 & abs(eta) < 2.5 & test_bit(electronID(\'cicTight\'), 0) > 0.5 & (userIso(0) + max(userIso(1) + neutralHadronIso - 0.5*userIso(2), 0))/pt < 0.3").size()', #B-JET Vetos bjetVeto= 'vetoJets(0.4, "pt > 20 & abs(eta) < 2.4 & userInt(\'fullIdLoose\') & bDiscriminator(\'\') > 3.3").size()', bjetCSVVeto= 'vetoJets(0.4, "pt > 20 & abs(eta) < 2.4 & userInt(\'fullIdLoose\') & bDiscriminator(\'combinedSecondaryVertexBJetTags\') > 0.679").size()', bjetCSVVetoZHLike= 'vetoJets(0.4, "pt > 20 & abs(eta) < 2.4 & userInt(\'fullIdLoose\') & bDiscriminator(\'combinedSecondaryVertexBJetTags\') > 0.898").size()', bjetCSVVetoZHLikeNoJetId= 'vetoJets(0.4, "pt > 20 & abs(eta) < 2.4 & bDiscriminator(\'combinedSecondaryVertexBJetTags\') > 0.898").size()', bjetCSVVeto30= 'vetoJets(0.4, "pt > 30 & abs(eta) < 2.4 & userInt(\'fullIdLoose\') & bDiscriminator(\'combinedSecondaryVertexBJetTags\') > 0.679").size()', #JET VETOS jetVeto20= 'vetoJets(0.4, "pt > 20 & abs(eta) < 5.0 & userInt(\'fullIdLoose\')").size()', jetVeto20jes_plus= 'vetoJets(0.4, "userCand(\'jes+\').pt() > 20 & abs(eta) < 5.0 & userInt(\'fullIdLoose\')").size()', jetVeto20jes_minus= 'vetoJets(0.4, "userCand(\'jes-\').pt() > 20 & abs(eta) < 5.0 & userInt(\'fullIdLoose\')").size()', jetVeto20_DR05= 'vetoJets(0.5, "pt > 20 & abs(eta) < 5.0 & userInt(\'fullIdLoose\')").size()', jetVeto30= 'vetoJets(0.4, "pt > 30 & abs(eta) < 5.0 & userInt(\'fullIdLoose\')").size()', jetVeto30jes_plus= 'vetoJets(0.4, "userCand(\'jes+\').pt() > 30 & abs(eta) < 5.0 & userInt(\'fullIdLoose\')").size()', jetVeto30jes_minus= 'vetoJets(0.4, "userCand(\'jes-\').pt() > 30 & abs(eta) < 5.0 & userInt(\'fullIdLoose\')").size()', jetVeto30_DR05= 'vetoJets(0.5, "pt > 30 & abs(eta) < 5.0 & userInt(\'fullIdLoose\')").size()', jetVeto40= 'vetoJets(0.4, "pt > 40 & abs(eta) < 5.0 & userInt(\'fullIdLoose\')").size()', jetVeto40_DR05= 'vetoJets(0.5, "pt > 40 & abs(eta) < 5.0 & userInt(\'fullIdLoose\')").size()', #leadingJetPt = '? (vetoJets(0.4, "abs(eta) < 5.0 & userInt(\'fullIdLoose\')").size() > 0) ? vetoJets(0.4, "abs(eta) < 5.0 & userInt(\'fullIdLoose\')").at(0).pt() : -1.', )
''' Ntuple branch template sets for trigger selections Each string is transformed into an expression on a FinalStateEvent object. Author: Evan K. Friis ''' from FinalStateAnalysis.Utilities.cfgtools import PSet _trig_template = PSet( namePass = '******', nameGroup = 'evt.hltGroup("paths")', namePrescale = 'evt.hltPrescale("paths")', ) singlemu = _trig_template.replace( name='singleMu', paths=r'HLT_Mu15_v\\d+, HLT_Mu24_v\\d+, HLT_Mu30_v\\d+') isomu = _trig_template.replace(name='isoMu', paths=r'HLT_IsoMu17_v\\d+, HLT_IsoMu20_v\\d+, ' r'HLT_IsoMu24_v\\d+, HLT_IsoMu24_eta2p1_v\\d+, ' r'HLT_IsoMu30_v\\d+, HLT_IsoMu30_eta2p1_v\\d+' ) isomu24eta2p1 = _trig_template.replace(name='isoMu24eta2p1', paths=r'HLT_IsoMu24_eta2p1_v\\d+') doublemu = PSet(
def make_ntuple(*legs, **kwargs): ''' Build an ntuple for a set of input legs. You can passes extra branches by passing a dict of branch:strings using the keyword argument: branches ''' # Make sure we only use allowed leg types allowed = set(['m', 'e', 't']) assert(all(x in allowed for x in legs)) # Make object labels object_labels = [] format_labels = { } # Count how many objects of each type we put in counts = { 't' : 0, 'm' : 0, 'e' : 0 } ntuple_config = _common_template.clone() # Optionally apply extra branches in kwargs if 'branches' in kwargs: for branch, value in kwargs['branches'].iteritems(): setattr(ntuple_config, branch, cms.string(value)) for i, leg in enumerate(legs): counts[leg] += 1 # Check if we need to append an index (i.e. we have same flavor objects) label = leg if legs.count(leg) > 1: label = leg + str(counts[leg]) format_labels[label] = 'daughter(%i)' % i format_labels[label+ '_idx'] = '%i' % i object_labels.append(label) # Get a PSet describing the branches for this leg leg_branches = _leg_templates[leg].replace(object=label) # Add to the total config ntuple_config = PSet( ntuple_config, leg_branches ) #pdb.set_trace() # Now we need to add all the information about the pairs for leg_a, leg_b in itertools.combinations(object_labels, 2): ntuple_config = PSet( ntuple_config, templates.topology.pairs.replace(object1=leg_a, object2=leg_b), templates.topology.zboson.replace(object1=leg_a, object2=leg_b), ) # Now build our analyzer EDFilter skeleton output = cms.EDFilter( "PATFinalStateAnalysisFilter", weights = cms.vstring(), src = cms.InputTag("finalState" + "".join( _producer_translation[x] for x in legs)), evtSrc = cms.InputTag("patFinalStateEventProducer"), skimCounter = cms.InputTag("eventCount", "", "TUPLE"), analysis = cms.PSet( selections = cms.VPSet(), final = cms.PSet( sort = cms.string('daughter(0).pt'), # Doesn't really matter take = cms.uint32(50), plot = cms.PSet( histos = cms.VPSet(), # Don't make any final plots ntuple = ntuple_config.clone(), ) ), ) ) # Apply the basic selection to each leg for i, leg in enumerate(legs): output.analysis.selections.append( cms.PSet( name = cms.string('Leg%iPt' % i), cut = cms.string('daughter(%i).pt>%s' % ( i, _pt_cuts[legs[i]]), ) ) ) output.analysis.selections.append( cms.PSet( name = cms.string('Leg%iEta' % i), cut = cms.string('abs(daughter(%i).eta) < %s' % ( i, _eta_cuts[legs[i]])) ), ) # Apply "uniqueness requirements" to reduce final processing/storage. # This make sure there is only one ntuple entry per-final state. The # combinatorics due to different orderings are removed. # Algorithm: # if there are 2 of any given type, order them by pt # if there are 3 # first put best Z in initial position # then order first two by pt # if there are 4 # first put best Z in initial position # then order first two by pt # then order third and fourth by pt for type, count in counts.iteritems(): if count == 2: leg1_idx = format_labels['%s1_idx' % type] leg2_idx = format_labels['%s2_idx' % type] output.analysis.selections.append(cms.PSet( name = cms.string('%s_UniqueByPt' % type), cut = cms.string('orderedInPt(%s, %s)' % (leg1_idx, leg2_idx)) )) if count == 3: leg1_idx_label = format_labels['%s1_idx' % type] leg2_idx_label = format_labels['%s2_idx' % type] leg3_idx_label = format_labels['%s3_idx' % type] # Require first two leptons make the best Z output.analysis.selections.append(cms.PSet( name = cms.string('Z12_Better_Z13'), cut = cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg1_idx_label, leg3_idx_label) ) )) output.analysis.selections.append(cms.PSet( name = cms.string('Z12_Better_Z23'), cut = cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg2_idx_label, leg3_idx_label) ) )) # Require first two leptons are ordered in PT output.analysis.selections.append(cms.PSet( name = cms.string('%s_UniqueByPt' % type), cut = cms.string('orderedInPt(%s, %s)' % (leg1_idx_label, leg2_idx_label)) )) if count == 4: leg1_idx_label = format_labels['%s1_idx' % type] leg2_idx_label = format_labels['%s2_idx' % type] leg3_idx_label = format_labels['%s3_idx' % type] leg4_idx_label = format_labels['%s4_idx' % type] # Require first two leptons make the best Z output.analysis.selections.append(cms.PSet( name = cms.string('Z12_Better_Z13'), cut = cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg1_idx_label, leg3_idx_label) ) )) output.analysis.selections.append(cms.PSet( name = cms.string('Z12_Better_Z23'), cut = cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg2_idx_label, leg3_idx_label) ) )) output.analysis.selections.append(cms.PSet( name = cms.string('Z12_Better_Z14'), cut = cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg1_idx_label, leg4_idx_label) ) )) output.analysis.selections.append(cms.PSet( name = cms.string('Z12_Better_Z24'), cut = cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg2_idx_label, leg4_idx_label) ) )) output.analysis.selections.append(cms.PSet( name = cms.string('Z12_Better_Z34'), cut = cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg3_idx_label, leg4_idx_label) ) )) # Require first two leptons are ordered in PT output.analysis.selections.append(cms.PSet( name = cms.string('%s_UniqueByPt12' % type), cut = cms.string('orderedInPt(%s, %s)' % (leg1_idx_label, leg2_idx_label)) )) # Require last two leptons are ordered in PT output.analysis.selections.append(cms.PSet( name = cms.string('%s_UniqueByPt34' % type), cut = cms.string('orderedInPt(%s, %s)' % (leg3_idx_label, leg4_idx_label)) )) # Now apply our formatting operations format(output, **format_labels) return output
id = PSet( objectCBID_LOOSE='{object}.userInt("CBID_LOOSE")', objectCBID_MEDIUM='{object}.userInt("CBID_MEDIUM")', objectCBID_TIGHT='{object}.userInt("CBID_TIGHT")', # isolations objectPFChargedIso= 'getPhotonUserIsolation({object_idx},"PfChargedHadronIso")', objectPFNeutralIso= 'getPhotonUserIsolation({object_idx},"PfNeutralHadronIso")', objectPFPhotonIso='getPhotonUserIsolation({object_idx},"PfGammaIso")', objectEffectiveAreaCHad='{object}.userFloat("PhotonEA_pfchg")', objectEffectiveAreaNHad='{object}.userFloat("PhotonEA_pfneut")', objectEffectiveAreaPho='{object}.userFloat("PhotonEA_pfpho")', objectRho='{object}.userFloat("kt6PFJetsRho")', # photon id variables objectConvSafeElectronVeto='{object}.userInt("ConvSafeElectronVeto")', objectHadronicOverEM='{object}.hadronicOverEm', objectHadronicDepth1OverEm='{object}.hadronicDepth1OverEm', objectHadronicDepth2OverEm='{object}.hadronicDepth2OverEm', objectSingleTowerHadronicOverEm='{object}.userFloat("SingleTowerHoE")', objectSingleTowerHadronicDepth1OverEm= '{object}.userFloat("SingleTowerHoEDepth1")', objectSingleTowerHadronicDepth2OverEm= '{object}.userFloat("SingleTowerHoEDepth2")', objectSigmaIEtaIEta='{object}.sigmaIetaIeta', objectE1x5='{object}.e1x5', objectE2x5='{object}.e2x5', objectE3x3='{object}.e3x3', objectE5x5='{object}.e5x5', objectMaxEnergyXtal='{object}.maxEnergyXtal', objectR1x5='{object}.r1x5', objectR2x5='{object}.r2x5', objectR9='{object}.r9', # locations and gaps objectIsEB='{object}.isEB', objectIsEE='{object}.isEE', objectIsEBGap='{object}.isEBGap', objectIsEBEtaGap='{object}.isEBEtaGap', objectIsEBPhiGap='{object}.isEBPhiGap', objectIsEEGap='{object}.isEEGap', objectIsEERingGap='{object}.isEERingGap', objectIsEEDeeGap='{object}.isEEDeeGap', objectIsEBEEGap='{object}.isEBEEGap', # reco provenance objectIsPFlowPhoton='{object}.isPFlowPhoton', objectIsStandardPhoton='{object}.isStandardPhoton', objectHasPixelSeed='{object}.hasPixelSeed', # gen matching (photons can be matched to many object types) objectPdgId= '? ({object}.genParticleRef().isNonnull && {object}.genParticleRef().isAvailable) ? {object}.genParticleRef().pdgId() : -999', objectGenMotherPdgId= '? (getDaughterGenParticleMotherSmart({object_idx},22,0).isAvailable && getDaughterGenParticleMotherSmart({object_idx},22,0).isNonnull) ? getDaughterGenParticleMotherSmart({object_idx},22,0).pdgId() : -999', objectGenGrandMotherPdgId= '? (getDaughterGenParticleMotherSmart({object_idx},22,0).isAvailable && getDaughterGenParticleMotherSmart({object_idx},22,0).isNonnull && (getDaughterGenParticleMotherSmart({object_idx},22,0).numberOfMothers() != 0)) ? getDaughterGenParticleMotherSmart({object_idx},22,0).mother().pdgId() : -999', objectComesFromHiggs='comesFromHiggs({object_idx},22,0)', objectGenEnergy= '? ({object}.genParticleRef().isNonnull && {object}.genParticleRef().isAvailable) ? {object}.genParticleRef().energy() : -999', )
def make_ntuple(*legs, **kwargs): ''' Build an ntuple for a set of input legs. You can passes extra branches by passing a dict of branch:strings using the keyword argument: branches You can specify that no disambiguation can be applied (i.e. a dimuon candidate will appear twice in the mu-mu ntuple, in both orders) by setting 'noclean' to True in kwargs. ''' # Make sure we only use allowed leg types allowed = set(['m', 'e', 't', 'g','j']) assert(all(x in allowed for x in legs)) # Make object labels object_labels = [] format_labels = { } # Count how many objects of each type we put in counts = { 't': 0, 'm': 0, 'e': 0, 'g': 0, 'j': 0, } ntuple_config = _common_template.clone() if kwargs.get('runTauSpinner', False): for parName in templates.event.tauSpinner.parameterNames_(): setattr( ntuple_config, parName, getattr( templates.event.tauSpinner, parName ) ) # If we have two legs or photons, we are interested in VBF selections. if len(legs) == 2 or 'g' in legs: ntuple_config = PSet( ntuple_config, templates.topology.vbf ) # Optionally apply extra branches in kwargs if 'branches' in kwargs: for branch, value in kwargs['branches'].iteritems(): setattr(ntuple_config, branch, cms.string(value)) # Check if we want to use special versions of the FSA producers # via a suffix on the producer name. producer_suffix = kwargs.get('suffix', '') for i, leg in enumerate(legs): counts[leg] += 1 # Check if we need to append an index (we have same flavor objects) label = leg if legs.count(leg) > 1: label = leg + str(counts[leg]) format_labels[label] = 'daughter(%i)' % i format_labels[label + '_idx'] = '%i' % i object_labels.append(label) # Get a PSet describing the branches for this leg leg_branches = _leg_templates[leg].replace(object=label) # Add to the total config ntuple_config = PSet( ntuple_config, leg_branches ) #pdb.set_trace() # Now we need to add all the information about the pairs for leg_a, leg_b in itertools.combinations(object_labels, 2): ntuple_config = PSet( ntuple_config, templates.topology.pairs.replace(object1=leg_a, object2=leg_b), templates.topology.zboson.replace(object1=leg_a, object2=leg_b), ) # Check if we want to enable SVfit # Only do SVfit in states with 2 or 4 leptons do_svfit = kwargs.get("svFit", False) if not len(legs) % 2 == 0: do_svfit = False leg_a_type = leg_a[0] leg_b_type = leg_b[0] leg_a_index = legs.index(leg_a_type) \ if counts[leg_a_type] == 1 else legs.index(leg_a_type) + int(leg_a[1]) - 1 leg_b_index = legs.index(leg_b_type) \ if counts[leg_b_type] == 1 else legs.index(leg_b_type) + int(leg_b[1]) - 1 # Never do SVfit on 'non-paired' leptons (eg legs 0 & 2), or legs 1&3 # legs either adjacent or both ends (0 and 3) if leg_a_index % 2 != 0 or abs(leg_a_index - leg_b_index) % 2 != 1: do_svfit = False # Only do SVfit on mu + tau, e + tau, e + mu, & tau + tau combinations if leg_a_type == leg_b_type and leg_a_type in ('m', 'e'): do_svfit = False # Always ignore photons if 'g' in legs: do_svfit = False if do_svfit: print "SV fitting legs %s and %s in final state %s" % ( leg_a, leg_b, ''.join(legs)) ntuple_config = PSet( ntuple_config, templates.topology.svfit.replace(object1=leg_a, object2=leg_b) ) # Are we running on the ZZ-specific collections? zz_mode = kwargs.get('zz_mode', False) analyzerSrc = "finalState" + "".join( _producer_translation[x] for x in legs ) + producer_suffix if zz_mode: analyzerSrc += "Hzz" ntuple_config = PSet( ntuple_config, templates.topology.zzfsr ) # Now build our analyzer EDFilter skeleton output = cms.EDFilter( "PATFinalStateAnalysisFilter", weights=cms.vstring(), # input final state collection. src=cms.InputTag( analyzerSrc ), evtSrc=cms.InputTag("patFinalStateEventProducer"), # counter of events before any selections skimCounter=cms.InputTag("eventCount", "", "TUPLE"), analysis=cms.PSet( selections=cms.VPSet(), EventView=cms.bool(False), final=cms.PSet( sort=cms.string('daughter(0).pt'), # Doesn't really matter take=cms.uint32(50), plot=cms.PSet( histos=cms.VPSet(), # Don't make any final plots # ntuple has all generated branches in it. ntuple=ntuple_config.clone(), ) ), ) ) # Apply the basic selection to each leg for i, leg in enumerate(legs): output.analysis.selections.append( cms.PSet( name=cms.string('Leg%iPt' % i), cut=cms.string('daughter(%i).pt>%s' % ( i, _pt_cuts[legs[i]]), ) ) ) output.analysis.selections.append( cms.PSet( name=cms.string('Leg%iEta' % i), cut=cms.string('abs(daughter(%i).eta) < %s' % ( i, _eta_cuts[legs[i]])) ), ) #Apply additional selections if 'skimCuts' in kwargs and kwargs['skimCuts']: for cut in kwargs['skimCuts']: output.analysis.selections.append( cms.PSet( name = cms.string(cut), cut = cms.string(cut) ), ) # Apply "uniqueness requirements" to reduce final processing/storage. # This make sure there is only one ntuple entry per-final state. The # combinatorics due to different orderings are removed. # Algorithm: # if there are 2 of any given type, order them by pt # if there are 3 # first put best Z in initial position # then order first two by pt # if there are 4 # first put best Z in initial position # then order first two by pt # then order third and fourth by pt # # Algorithm for dblhMode: # if there are 4 # first two leptons must be positive # third and fourth leptons must be negative # order first two by pt # order third and fourth by pt noclean = kwargs.get('noclean', False) # ZZ-producer does not require this cleaning step make_unique = not noclean and not zz_mode isDblH = kwargs.get('dblhMode', False) if make_unique: for type, count in counts.iteritems(): if count == 2: leg1_idx = format_labels['%s1_idx' % type] leg2_idx = format_labels['%s2_idx' % type] output.analysis.selections.append(cms.PSet( name=cms.string('%s_UniqueByPt' % type), cut=cms.string('orderedInPt(%s, %s)' % (leg1_idx, leg2_idx)) )) if count == 3: leg1_idx_label = format_labels['%s1_idx' % type] leg2_idx_label = format_labels['%s2_idx' % type] leg3_idx_label = format_labels['%s3_idx' % type] # Require first two leptons make the best Z output.analysis.selections.append(cms.PSet( name=cms.string('Z12_Better_Z13'), cut=cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg1_idx_label, leg3_idx_label) ) )) output.analysis.selections.append(cms.PSet( name=cms.string('Z12_Better_Z23'), cut=cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg2_idx_label, leg3_idx_label) ) )) # Require first two leptons are ordered in PT output.analysis.selections.append(cms.PSet( name=cms.string('%s_UniqueByPt' % type), cut=cms.string('orderedInPt(%s, %s)' % (leg1_idx_label, leg2_idx_label)) )) if count == 4: leg1_idx_label = format_labels['%s1_idx' % type] leg2_idx_label = format_labels['%s2_idx' % type] leg3_idx_label = format_labels['%s3_idx' % type] leg4_idx_label = format_labels['%s4_idx' % type] if isDblH: output.analysis.selections.append(cms.PSet( name=cms.string('hpp12_and_hmm34'), cut=cms.string( 'hppCompatibility(%s, %s, 1) &&' 'hppCompatibility(%s, %s, -1)' % (leg1_idx_label, leg2_idx_label, leg3_idx_label, leg4_idx_label) ) )) else: # Require first two leptons make the best Z output.analysis.selections.append(cms.PSet( name=cms.string('Z12_Better_Z13'), cut=cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg1_idx_label, leg3_idx_label) ) )) output.analysis.selections.append(cms.PSet( name=cms.string('Z12_Better_Z23'), cut=cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg2_idx_label, leg3_idx_label) ) )) output.analysis.selections.append(cms.PSet( name=cms.string('Z12_Better_Z14'), cut=cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg1_idx_label, leg4_idx_label) ) )) output.analysis.selections.append(cms.PSet( name=cms.string('Z12_Better_Z24'), cut=cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg2_idx_label, leg4_idx_label) ) )) output.analysis.selections.append(cms.PSet( name=cms.string('Z12_Better_Z34'), cut=cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg3_idx_label, leg4_idx_label) ) )) # Require first two leptons are ordered in PT output.analysis.selections.append(cms.PSet( name=cms.string('%s_UniqueByPt12' % type), cut=cms.string('orderedInPt(%s, %s)' % (leg1_idx_label, leg2_idx_label)) )) # Require last two leptons are ordered in PT output.analysis.selections.append(cms.PSet( name=cms.string('%s_UniqueByPt34' % type), cut=cms.string('orderedInPt(%s, %s)' % (leg3_idx_label, leg4_idx_label)) )) # Now apply our formatting operations format(output, **format_labels) # return LHEFilter*output return output
from FinalStateAnalysis.Utilities.cfgtools import format, PSet # Import the templates used to make the branches import FinalStateAnalysis.NtupleTools.templates as templates # Define the branches that go in all ntuples _common_template = PSet( # Basic info about the final state templates.topology.finalstate, # templates.Event num/lumi/run templates.event.num, # templates.Rho, ntvtx, nTruePU templates.event.pileup, # templates.Info about the MET templates.event.met, # templates.Info about the generator templates.event.gen, # templates.Vetoes on extra objects templates.cleaning.vetos, # We only need to worry about lepton triggers templates.trigger.mueg, templates.trigger.doublemu, templates.trigger.doublee, templates.trigger.isomu, templates.trigger.singlemu, ) # Define the branch templates for different object types. _tau_template = PSet( templates.candidates.base_jet, templates.candidates.kinematics, templates.candidates.vertex_info,
''' Ntuple branch template sets for generic candidate objects. Author: Evan K. Friis ''' from FinalStateAnalysis.Utilities.cfgtools import PSet kinematics = PSet( objectPt='{object}.pt', objectEta='{object}.eta', objectAbsEta='abs({object}.eta)', objectPhi='{object}.phi', objectCharge='{object}.charge', objectMass='{object}.mass', ) vertex_info = PSet( objectDZ='{object}.userFloat("dz")', objectVZ='{object}.vz', objectIP3DS='{object}.userFloat("ip3DS")', ) # The info about the associated pat::Jet base_jet = PSet( objectJetPt='{object}.userFloat("jetPt")', objectJetBtag='? {object}.userCand("patJet").isNonnull ? ' '{object}.userCand("patJet").bDiscriminator("") : -5', objectJetCSVBtag='? {object}.userCand("patJet").isNonnull ? '
from FinalStateAnalysis.Utilities.cfgtools import PSet # ID and isolation id = PSet( objectVBTFID='{object}.userInt("VBTF")', objectWWID='{object}.userInt("WWID")', objectPFIDTight='{object}.userInt("tightID")', objectIDHZG2011='{object}.userInt("HZG2011")', objectIDHZG2012='{object}.userInt("HZG2012")', # For charged, we use ALL charged particles objectEffectiveArea2012='{object}.userFloat("ea_comb_iso04_kt6PFJCNth05")', objectEffectiveArea2011='{object}.userFloat("ea_comb_iso04_kt6PFJCth05")', objectPFChargedIso=cms.string( '{object}.userIsolation("PfChargedHadronIso")'), objectPFNeutralIso=cms.string( '{object}.userIsolation("PfNeutralHadronIso")'), objectPFPhotonIso=cms.string('{object}.userIsolation("PfGammaIso")'), objectRelPFIsoDB=cms.string("({object}.userIso(0)" "+max({object}.photonIso()" "+{object}.neutralHadronIso()" "-0.5*{object}.puChargedHadronIso,0.0))" "/{object}.pt()"), objectIsGlobal='{object}.isGlobalMuon', objectIsTracker='{object}.isTrackerMuon', objectGenMotherPdgId= '? (getDaughterGenParticleMotherSmart({object_idx}).isAvailable && getDaughterGenParticleMotherSmart({object_idx}).isNonnull) ? getDaughterGenParticleMotherSmart({object_idx}).pdgId() : -999', objectComesFromHiggs='comesFromHiggs({object_idx})', ) energyCorrections = PSet( objectERochCor2011A=
id = PSet( objectWWID='{object}.userFloat("WWID")', objectMITID='{object}.userFloat("MITID")', objectMVANonTrig='{object}.electronID("mvaNonTrigV0")', objectMVATrig='{object}.electronID("mvaTrigV0")', objectMVAIDH2TauWP='{object}.userInt("mvaidwp")', objectCiCTight='{object}.electronID("cicTight")', objectCBID_VETO='{object}.userInt("CBID_VETO")', objectCBID_LOOSE='{object}.userInt("CBID_LOOSE")', objectCBID_MEDIUM='{object}.userInt("CBID_MEDIUM")', objectCBID_TIGHT='{object}.userInt("CBID_TIGHT")', # Use cms.string so we get the parentheses formatting bonus objectRelPFIsoDB=cms.string("({object}.userIso(0)" "+max({object}.userIso(1)" "+{object}.neutralHadronIso()" "-0.5*{object}.userIso(2),0.0))" "/{object}.pt()"), objectPFChargedIso=cms.string( '{object}.userIsolation("PfChargedHadronIso")'), objectPFNeutralIso=cms.string( '{object}.userIsolation("PfNeutralHadronIso")'), objectPFPhotonIso=cms.string('{object}.userIsolation("PfGammaIso")'), objectEffectiveArea2012Data=cms.string( '{object}.userFloat("ea_comb_Data2012_iso04_kt6PFJ")'), objectEffectiveArea2011Data=cms.string( '{object}.userFloat("ea_comb_Data2011_iso04_kt6PFJ")'), objectEffectiveAreaFall11MC=cms.string( '{object}.userFloat("ea_comb_Fall11MC_iso04_kt6PFJ")'), objectRelIso=cms.string("({object}.dr03TkSumPt()" "+max({object}.dr03EcalRecHitSumEt()-1.0,0.0)" "+{object}.dr03HcalTowerSumEt())/{object}.pt()"), objectChargeIdTight='{object}.isGsfCtfScPixChargeConsistent', objectChargeIdMed='{object}.isGsfScPixChargeConsistent', objectChargeIdLoose='{object}.isGsfCtfChargeConsistent', # shower shape / ID variables objectHadronicOverEM='{object}.hcalOverEcal', objectHadronicDepth1OverEm='{object}.hcalDepth1OverEcal', objectHadronicDepth2OverEm='{object}.hcalDepth2OverEcal', objectSigmaIEtaIEta='{object}.sigmaIetaIeta', objectE1x5='{object}.scE1x5', objectE2x5Max='{object}.scE2x5Max', objectE5x5='{object}.scE5x5', objectGenMotherPdgId= '? (getDaughterGenParticleMotherSmart({object_idx}).isAvailable && getDaughterGenParticleMotherSmart({object_idx}).isNonnull) ? getDaughterGenParticleMotherSmart({object_idx}).pdgId() : -999', objectComesFromHiggs='comesFromHiggs({object_idx})', )
''' Ntuple branch template sets for topological variables (MT, etc) Each string is transformed into an expression on a FinalStateEvent object. Author: Evan K. Friis ''' from FinalStateAnalysis.Utilities.cfgtools import PSet mtToMET = PSet( # Raw means no MET corrections objectMtToMET='mtMET({object_idx}, "raw")', objectToMETDPhi='deltaPhi({object}.phi, met().phi())', ) # Variables based on pairs of objects pairs = PSet( object1_object2_SVfitMass= 'SVfit({object1_idx},{object2_idx})', # SVfit mass ([email protected]) object1_object2_Mass='subcand({object1_idx}, {object2_idx}).get.mass', object1_object2_Pt='subcand({object1_idx}, {object2_idx}).get.pt', object1_object2_DR='dR({object1_idx}, {object2_idx})', object1_object2_DPhi='dPhi({object1_idx}, {object2_idx})', object1_object2_SS='likeSigned({object1_idx}, {object2_idx})', object1_object2_PZeta='pZeta({object1_idx}, {object2_idx})', object1_object2_PZetaVis='pZetaVis({object1_idx}, {object2_idx})', )
Ntuple branch template sets for tau objects. Each string is transformed into an expression on a FinalStateEvent object. {object} should be replaced by an expression which evaluates to a pat::Muon i.e. daughter(1) or somesuch. Author: Evan K. Friis ''' from FinalStateAnalysis.Utilities.cfgtools import PSet info = PSet( objectGenDecayMode='{object}.userInt("genDecayMode")', objectLeadTrackPt='{object}.userFloat("ps_ldTrkPt")', objectDecayMode='{object}.decayMode', objectTNPId='{object}.userInt("ps_sel_nom")', ) # ID and isolation id = PSet( #Against Electron #STD objectAntiElectronLoose='{object}.tauID("againstElectronLoose")', objectAntiElectronMedium='{object}.tauID("againstElectronMedium")', objectAntiElectronTight='{object}.tauID("againstElectronTight")', objectAntiElectronMVA5VLoose='{object}.tauID("againstElectronVLooseMVA5")', objectAntiElectronMVA5Loose='{object}.tauID("againstElectronLooseMVA5")', objectAntiElectronMVA5Medium='{object}.tauID("againstElectronMediumMVA5")', objectAntiElectronMVA5Tight='{object}.tauID("againstElectronTightMVA5")', objectAntiElectronMVA5VTight='{object}.tauID("againstElectronVTightMVA5")',
''' Ntuple branch template sets for generic candidate objects. Author: Evan K. Friis ''' from FinalStateAnalysis.Utilities.cfgtools import PSet kinematics = PSet( objectPt = '{object}.pt', objectEta = '{object}.eta', objectAbsEta = 'abs({object}.eta)', objectPhi = '{object}.phi', objectCharge = '{object}.charge', objectMass = '{object}.mass', objectRank ='{object}.userFloat("rankByPt")' ) vertex_info = PSet( objectDZ = '{object}.userFloat("dz")', objectVZ = '{object}.vz', objectIP3DS = '{object}.userFloat("ip3DS")', ) # The info about the associated pat::Jet base_jet = PSet( objectJetPt = '{object}.userFloat("jetPt")', objectJetQGMVAID = '? {object}.userCand("patJet").isNonnull ? ' '{object}.userCand("patJet").userFloat("QuarkGluonMVAID") : -5',
mtToMET = PSet( # Raw means no MET corrections objectMtToMET='mtMET({object_idx}, "raw")', #PF Type1 MET (and systematics) objectMtToPFMET= 'mtMET({object_idx}, "", "pfmet", "" , 1)', #1, apply phi correction objectMtToPfMet_Ty1='mtMET({object_idx}, "", "pfmet", "type1", 1)', objectMtToPfMet_mes='mtMET({object_idx}, "", "pfmet", "mes+" , 1)', objectMtToPfMet_tes='mtMET({object_idx}, "", "pfmet", "tes+" , 1)', objectMtToPfMet_jes='mtMET({object_idx}, "", "pfmet", "jes+" , 1)', objectMtToPfMet_ues='mtMET({object_idx}, "", "pfmet", "ues+" , 1)', objectMtToPfMet_Ty1_ues_plus= 'mtMET({object_idx}, "", "pfmet", "type1", "ues+", 1)', objectMtToPfMet_Ty1_ues_minus= 'mtMET({object_idx}, "", "pfmet", "type1", "ues-", 1)', objectMtToPfMet_mes_plus='mtMET({object_idx}, "", "pfmet", "mes+" , 1)', objectMtToPfMet_tes_plus='mtMET({object_idx}, "", "pfmet", "tes+" , 1)', objectMtToPfMet_jes_plus='mtMET({object_idx}, "", "pfmet", "jes+" , 1)', objectMtToPfMet_ues_plus='mtMET({object_idx}, "", "pfmet", "ues+" , 1)', objectMtToPfMet_mes_minus='mtMET({object_idx}, "", "pfmet", "mes-" , 1)', objectMtToPfMet_tes_minus='mtMET({object_idx}, "", "pfmet", "tes-" , 1)', objectMtToPfMet_jes_minus='mtMET({object_idx}, "", "pfmet", "jes-" , 1)', objectMtToPfMet_ues_minus='mtMET({object_idx}, "", "pfmet", "ues-" , 1)', #MVA MET objectMtToMVAMET='mtMET({object_idx}, "", "mvamet", "", 0)', objectToMETDPhi='deltaPhi({object}.phi, met().phi())', )
def make_ntuple(*legs, **kwargs): ''' Build an ntuple for a set of input legs. You can passes extra branches by passing a dict of branch:strings using the keyword argument: branches You can specify that no disambiguation can be applied (i.e. a dimuon candidate will appear twice in the mu-mu ntuple, in both orders) by setting 'noclean' to True in kwargs. ''' # Make sure we only use allowed leg types allowed = set(['m', 'e', 't', 'g']) assert(all(x in allowed for x in legs)) # Make object labels object_labels = [] format_labels = { } # Count how many objects of each type we put in counts = { 't' : 0, 'm' : 0, 'e' : 0, 'g' : 0 } ntuple_config = _common_template.clone() # If we only have two legs, we are interested in VBF selections. if len(legs) == 2: ntuple_config = PSet( ntuple_config, templates.topology.vbf ) # Optionally apply extra branches in kwargs if 'branches' in kwargs: for branch, value in kwargs['branches'].iteritems(): setattr(ntuple_config, branch, cms.string(value)) for i, leg in enumerate(legs): counts[leg] += 1 # Check if we need to append an index (i.e. we have same flavor objects) label = leg if legs.count(leg) > 1: label = leg + str(counts[leg]) format_labels[label] = 'daughter(%i)' % i format_labels[label+ '_idx'] = '%i' % i object_labels.append(label) # Get a PSet describing the branches for this leg leg_branches = _leg_templates[leg].replace(object=label) # Add to the total config ntuple_config = PSet( ntuple_config, leg_branches ) #pdb.set_trace() # Now we need to add all the information about the pairs for leg_a, leg_b in itertools.combinations(object_labels, 2): ntuple_config = PSet( ntuple_config, templates.topology.pairs.replace(object1=leg_a, object2=leg_b), templates.topology.zboson.replace(object1=leg_a, object2=leg_b), ) # Now build our analyzer EDFilter skeleton output = cms.EDFilter( "PATFinalStateAnalysisFilter", weights = cms.vstring(), src = cms.InputTag("finalState" + "".join( _producer_translation[x] for x in legs)), evtSrc = cms.InputTag("patFinalStateEventProducer"), skimCounter = cms.InputTag("eventCount", "", "TUPLE"), analysis = cms.PSet( selections = cms.VPSet(), final = cms.PSet( sort = cms.string('daughter(0).pt'), # Doesn't really matter take = cms.uint32(50), plot = cms.PSet( histos = cms.VPSet(), # Don't make any final plots ntuple = ntuple_config.clone(), ) ), ) ) # Apply the basic selection to each leg for i, leg in enumerate(legs): output.analysis.selections.append( cms.PSet( name = cms.string('Leg%iPt' % i), cut = cms.string('daughter(%i).pt>%s' % ( i, _pt_cuts[legs[i]]), ) ) ) output.analysis.selections.append( cms.PSet( name = cms.string('Leg%iEta' % i), cut = cms.string('abs(daughter(%i).eta) < %s' % ( i, _eta_cuts[legs[i]])) ), ) # Apply "uniqueness requirements" to reduce final processing/storage. # This make sure there is only one ntuple entry per-final state. The # combinatorics due to different orderings are removed. # Algorithm: # if there are 2 of any given type, order them by pt # if there are 3 # first put best Z in initial position # then order first two by pt # if there are 4 # first put best Z in initial position # then order first two by pt # then order third and fourth by pt make_unique = True if 'noclean' in kwargs: make_unique = False if make_unique: for type, count in counts.iteritems(): if count == 2: leg1_idx = format_labels['%s1_idx' % type] leg2_idx = format_labels['%s2_idx' % type] output.analysis.selections.append(cms.PSet( name = cms.string('%s_UniqueByPt' % type), cut = cms.string('orderedInPt(%s, %s)' % (leg1_idx, leg2_idx)) )) if count == 3: leg1_idx_label = format_labels['%s1_idx' % type] leg2_idx_label = format_labels['%s2_idx' % type] leg3_idx_label = format_labels['%s3_idx' % type] # Require first two leptons make the best Z output.analysis.selections.append(cms.PSet( name = cms.string('Z12_Better_Z13'), cut = cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg1_idx_label, leg3_idx_label) ) )) output.analysis.selections.append(cms.PSet( name = cms.string('Z12_Better_Z23'), cut = cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg2_idx_label, leg3_idx_label) ) )) # Require first two leptons are ordered in PT output.analysis.selections.append(cms.PSet( name = cms.string('%s_UniqueByPt' % type), cut = cms.string('orderedInPt(%s, %s)' % (leg1_idx_label, leg2_idx_label)) )) if count == 4: leg1_idx_label = format_labels['%s1_idx' % type] leg2_idx_label = format_labels['%s2_idx' % type] leg3_idx_label = format_labels['%s3_idx' % type] leg4_idx_label = format_labels['%s4_idx' % type] # Require first two leptons make the best Z output.analysis.selections.append(cms.PSet( name = cms.string('Z12_Better_Z13'), cut = cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg1_idx_label, leg3_idx_label) ) )) output.analysis.selections.append(cms.PSet( name = cms.string('Z12_Better_Z23'), cut = cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg2_idx_label, leg3_idx_label) ) )) output.analysis.selections.append(cms.PSet( name = cms.string('Z12_Better_Z14'), cut = cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg1_idx_label, leg4_idx_label) ) )) output.analysis.selections.append(cms.PSet( name = cms.string('Z12_Better_Z24'), cut = cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg2_idx_label, leg4_idx_label) ) )) output.analysis.selections.append(cms.PSet( name = cms.string('Z12_Better_Z34'), cut = cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg3_idx_label, leg4_idx_label) ) )) # Require first two leptons are ordered in PT output.analysis.selections.append(cms.PSet( name = cms.string('%s_UniqueByPt12' % type), cut = cms.string('orderedInPt(%s, %s)' % (leg1_idx_label, leg2_idx_label)) )) # Require last two leptons are ordered in PT output.analysis.selections.append(cms.PSet( name = cms.string('%s_UniqueByPt34' % type), cut = cms.string('orderedInPt(%s, %s)' % (leg3_idx_label, leg4_idx_label)) )) # Now apply our formatting operations format(output, **format_labels) return output
id = PSet( objectVBTFID='{object}.userInt("VBTF")', objectWWID='{object}.userInt("WWID")', objectPFIDTight='{object}.userInt("tightID")', #objectPFIDLoose = cms.string('{object}.isGlobalMuon && {object}.isTrackerMuon && {object}.pfCandidateRef.isNonnull'), # for since with Belgian ZH objectIsPFMuon='{object}.pfCandidateRef.isNonnull', objectIDHZG2011='{object}.userInt("HZG2011")', objectIDHZG2012='{object}.userInt("HZG2012")', # For charged, we use ALL charged particles objectEffectiveArea2012='{object}.userFloat("ea_comb_iso04_kt6PFJCNth05")', objectEffectiveArea2011='{object}.userFloat("ea_comb_iso04_kt6PFJCth05")', objectRhoHZG2012='{object}.userFloat("hzgRho2012")', objectRhoHZG2011='{object}.userFloat("hzgRho2011")', objectPFChargedIso=cms.string( '{object}.userIsolation("PfChargedHadronIso")'), objectPFNeutralIso=cms.string( '{object}.userIsolation("PfNeutralHadronIso")'), objectPFPhotonIso=cms.string('{object}.userIsolation("PfGammaIso")'), objectPFPUChargedIso=cms.string( '{object}.userIsolation("PfPUChargedHadronIso")'), objectRelPFIsoDBHtt=cms.string("({object}.userIso(0)" "+max({object}.photonIso()" "+{object}.neutralHadronIso()" "-0.5*{object}.puChargedHadronIso,0.0))" "/{object}.pt()"), objectRelPFIsoDBDefault=cms.string("({object}.chargedHadronIso()" "+max({object}.photonIso()" "+{object}.neutralHadronIso()" "-0.5*{object}.puChargedHadronIso,0.0))" "/{object}.pt()"), objectRelPFIsoRho=cms.string( '({object}.chargedHadronIso()' '+max(0.0,{object}.neutralHadronIso()' '+{object}.photonIso()' '-{object}.userFloat("zzRho2012")*{object}.userFloat("ea_comb_iso04_kt6PFJCNth05")))' '/{object}.pt()'), objectRelPFIsoRhoFSR=cms.string( '({object}.chargedHadronIso()' '+max(0.0,{object}.neutralHadronIso()' '+{object}.photonIso() - userFloat("leg{object_idx}fsrIsoCorr")' '-{object}.userFloat("zzRho2012")*{object}.userFloat("ea_comb_iso04_kt6PFJCNth05")))' '/{object}.pt()'), ## objectRelPFIsoDBZhLike = cms.string( ## "({object}.chargedHadronIso()" ## "+max({object}.photonIso()" ## "+{object}.neutralHadronIso()" ## "-0.5*{object}.puChargedHadronIso,0.0))" ## "/{object}.pt()" ## ), objectIsGlobal='{object}.isGlobalMuon', objectIsTracker='{object}.isTrackerMuon', objectTypeCode=cms.vstring('{object}.type', 'I'), objectGenMotherPdgId= '? (getDaughterGenParticleMotherSmart({object_idx}, 13, 1).isAvailable && getDaughterGenParticleMotherSmart({object_idx}, 13, 1).isNonnull) ? getDaughterGenParticleMotherSmart({object_idx}, 13, 1).pdgId() : -999', objectComesFromHiggs='comesFromHiggs({object_idx}, 13, 1)', objectGenPdgId= '? (getDaughterGenParticle({object_idx}, 13, 0).isAvailable && getDaughterGenParticle({object_idx}, 13, 0).isNonnull) ? getDaughterGenParticle({object_idx}, 13, 0).pdgId() : -999', objectGenCharge= '? (getDaughterGenParticle({object_idx}, 13, 0).isAvailable && getDaughterGenParticle({object_idx}, 13, 0).isNonnull) ? getDaughterGenParticle({object_idx}, 13, 0).charge() : -999', objectGenEnergy= '? (getDaughterGenParticle({object_idx}, 13, 0).isAvailable && getDaughterGenParticle({object_idx}, 13, 0).isNonnull) ? getDaughterGenParticle({object_idx}, 13, 0).energy() : -999', objectGenEta= '? (getDaughterGenParticle({object_idx}, 13, 0).isAvailable && getDaughterGenParticle({object_idx}, 13, 0).isNonnull) ? getDaughterGenParticle({object_idx}, 13, 0).eta() : -999', objectGenPhi= '? (getDaughterGenParticle({object_idx}, 13, 0).isAvailable && getDaughterGenParticle({object_idx}, 13, 0).isNonnull) ? getDaughterGenParticle({object_idx}, 13, 0).phi() : -999', )
from FinalStateAnalysis.Utilities.cfgtools import PSet # Vetos on extra stuff in the event vetos = PSet( muVetoPt5='vetoMuons(0.4, "pt > 5 & abs(eta) < 2.4").size()', muGlbIsoVetoPt10= 'vetoMuons(0.4, "isGlobalMuon & isTrackerMuon & pt > 10 & abs(eta) < 2.4 & (userIso(0) + max(photonIso + neutralHadronIso - 0.5*puChargedHadronIso, 0))/pt < 0.4").size()', tauVetoPt20= 'vetoTaus(0.4, "pt > 20 & abs(eta) < 2.5 & tauID(\'decayModeFinding\') & tauID(\'byLooseIsolationMVA\')").size()', tauHpsVetoPt20= 'vetoTaus(0.4, "pt > 20 & abs(eta) < 2.5 & tauID(\'decayModeFinding\') & tauID(\'againstElectronLoose\') & tauID(\'againstMuonLoose\') & tauID(\'byMediumCombinedIsolationDeltaBetaCorr\')").size()', # Electrons embedding currently broken eVetoMVAIso= 'vetoElectrons(0.4, "pt > 10 & abs(eta) < 2.5 & userInt(\'mvaidwp\') > 0.5 & (userIso(0) + max(userIso(1) + neutralHadronIso - 0.5*userIso(2), 0))/pt < 0.3").size()', eVetoCicTightIso= 'vetoElectrons(0.4, "pt > 10 & abs(eta) < 2.5 & test_bit(electronID(\'cicTight\'), 0) > 0.5 & (userIso(0) + max(userIso(1) + neutralHadronIso - 0.5*userIso(2), 0))/pt < 0.3").size()', bjetVeto= 'vetoJets(0.4, "pt > 20 & abs(eta) < 2.4 & userInt(\'fullIdLoose\') & bDiscriminator(\'\') > 3.3").size()', bjetCSVVeto= 'vetoJets(0.4, "pt > 20 & abs(eta) < 2.4 & userInt(\'fullIdLoose\') & bDiscriminator(\'combinedSecondaryVertexBJetTags\') > 0.679").size()', bjetCSVVeto30= 'vetoJets(0.4, "pt > 30 & abs(eta) < 2.4 & userInt(\'fullIdLoose\') & bDiscriminator(\'combinedSecondaryVertexBJetTags\') > 0.679").size()', jetVeto20= 'vetoJets(0.4, "pt > 20 & abs(eta) < 5.0 & userInt(\'fullIdLoose\')").size()', jetVeto30= 'vetoJets(0.4, "pt > 30 & abs(eta) < 5.0 & userInt(\'fullIdLoose\')").size()', jetVeto40= 'vetoJets(0.4, "pt > 40 & abs(eta) < 5.0 & userInt(\'fullIdLoose\')").size()', ) overlaps = PSet( objectMuOverlap='overlapMuons({object_idx}, 0.4, "pt > 5").size()',
Ntuple branch template sets for tau objects. Each string is transformed into an expression on a FinalStateEvent object. {object} should be replaced by an expression which evaluates to a pat::Muon i.e. daughter(1) or somesuch. Author: Evan K. Friis ''' from FinalStateAnalysis.Utilities.cfgtools import PSet info = PSet( objectGenDecayMode = '{object}.userInt("genDecayMode")', objectLeadTrackPt = '{object}.userFloat("ps_ldTrkPt")', objectDecayMode = '{object}.decayMode', objectTNPId = '{object}.userInt("ps_sel_nom")', ) # ID and isolation id = PSet( objectDecayFinding = '{object}.tauID("decayModeFinding")', objectLooseIso = '{object}.tauID("byLooseCombinedIsolationDeltaBetaCorr")', objectMediumIso = '{object}.tauID("byMediumCombinedIsolationDeltaBetaCorr")', objectTightIso = '{object}.tauID("byTightCombinedIsolationDeltaBetaCorr")', objectLooseMVAIso = '{object}.tauID("byLooseIsolationMVA")', objectMediumMVAIso = '{object}.tauID("byMediumIsolationMVA")', objectTightMVAIso = '{object}.tauID("byTightIsolationMVA")', objectAntiElectronLoose = '{object}.tauID("againstElectronLoose")', objectAntiElectronMedium = '{object}.tauID("againstElectronMedium")', objectAntiElectronTight = '{object}.tauID("againstElectronTight")',
''' Ntuple branch template sets for trigger selections Each string is transformed into an expression on a FinalStateEvent object. Author: Evan K. Friis ''' from FinalStateAnalysis.Utilities.cfgtools import PSet _trig_template = PSet( namePass = '******', nameGroup = 'evt.hltGroup("paths")', namePrescale = 'evt.hltPrescale("paths")', ) singlemu = _trig_template.replace( name='singleMu', paths=r'HLT_Mu15_v\\d+, HLT_Mu24_v\\d+, HLT_Mu30_v\\d+') isomu = _trig_template.replace(name='isoMu', paths=r'HLT_IsoMu17_v\\d+, HLT_IsoMu20_v\\d+, ' r'HLT_IsoMu24_v\\d+, HLT_IsoMu24_eta2p1_v\\d+, ' r'HLT_IsoMu30_v\\d+, HLT_IsoMu30_eta2p1_v\\d+') doublemu = PSet( _trig_template.replace( name='doubleMu', paths=r'HLT_DoubleMu7_v\\d+,HLT_Mu13_Mu8_v\\d+,HLT_Mu17_Mu8_v\\d+'), _trig_template.replace(
from FinalStateAnalysis.Utilities.cfgtools import PSet btagging = PSet( #Btagging objectSSVHEBtag= '{object}.bDiscriminator("simpleSecondaryVertexHighEffBJetTags")', objectSSVHPBtag= '{object}.bDiscriminator("simpleSecondaryVertexHighPurBJetTags")', objectCSVBtag='{object}.bDiscriminator("combinedSecondaryVertexBJetTags")', #Custom Btagging, based on SV objectSVMassBtag='{object}.userFloat("mass_SSV")', objectSVChargeBtag='{object}.userFloat("chargeSSV")', objectSVNtracksBtag='{object}.userFloat("nTracksSSV")', objectNSVsBtag='{object}.userFloat("nTracksSSV")', objectSVFlightDistanceBtag='{object}.userFloat("flightDistance")', objectSVErrFlightDistanceBtag='{object}.userFloat("errorFlightDistance")', objectSVMassDPMBtag='{object}.userFloat("massD_SSV")', objectSVMassD0Btag='{object}.userFloat("massD0_SSV")', #Custom Btagging, based on Muons-In-Jets objectMuonInJetPtBtag='{object}.userFloat("MuonInJetPt")', objectMuonInJetPtRelBtag='{object}.userFloat("MuonInJetPtRel")', #Flavour objectJetFlavour='{object}.partonFlavour()', ) pujets = PSet( objectIDTight='{object}.userFloat("idTight")',
Ntuple branch template sets for tau objects. Each string is transformed into an expression on a FinalStateEvent object. {object} should be replaced by an expression which evaluates to a pat::Muon i.e. daughter(1) or somesuch. Author: Evan K. Friis ''' from FinalStateAnalysis.Utilities.cfgtools import PSet info = PSet( objectGenDecayMode='{object}.userInt("genDecayMode")', objectLeadTrackPt='{object}.userFloat("ps_ldTrkPt")', objectDecayMode='{object}.decayMode', objectTNPId='{object}.userInt("ps_sel_nom")', ) # ID and isolation id = PSet( #Against Electron #STD objectAntiElectronLoose='{object}.tauID("againstElectronLoose")', objectAntiElectronMedium='{object}.tauID("againstElectronMedium")', objectAntiElectronTight='{object}.tauID("againstElectronTight")', #MVA objectAntiElectronMVA='{object}.tauID("againstElectronMVA")', #MVA2 objectAntiElectronMVA2Vloose='{object}.tauID("againstElectronVLooseMVA2")',
id = PSet( objectWWID='{object}.userFloat("WWID")', objectMITID='{object}.userFloat("MITID")', objectMVANonTrig='{object}.electronID("mvaNonTrigV0")', objectMVATrig='{object}.electronID("mvaTrigV0")', objectMVATrigIDISO= '? {object}.isElectronIDAvailable("mvaTrigIDISOV0") ?{object}.electronID("mvaTrigIDISOV0") : -1', objectMVATrigIDISOPUSUB= '? {object}.isElectronIDAvailable("mvaTrigIDISOPUSUBV0") ?{object}.electronID("mvaTrigIDISOPUSUBV0") : -1', objectMVAIDH2TauWP='{object}.userInt("mvaidwp")', objectCiCTight='{object}.electronID("cicTight")', objectCBID_VETO='{object}.userInt("CBID_VETO")', objectCBID_LOOSE='{object}.userInt("CBID_LOOSE")', objectCBID_MEDIUM='{object}.userInt("CBID_MEDIUM")', objectCBID_TIGHT='{object}.userInt("CBID_TIGHT")', #new Summer13 MVA ID objectMVATrigNoIP='{object}.userFloat("mvaTrigNoIP")', # Use cms.string so we get the parentheses formatting bonus objectRelPFIsoDB=cms.string("({object}.userIso(0)" "+max({object}.userIso(1)" "+{object}.neutralHadronIso()" "-0.5*{object}.userIso(2),0.0))" "/{object}.pt()"), objectRelPFIsoRho=cms.string( '({object}.chargedHadronIso()' '+max(0.0,{object}.neutralHadronIso()' '+{object}.photonIso()' '-{object}.userFloat("zzRho2012")*{object}.userFloat("ea_comb_Data2012_iso04_kt6PFJ")))' '/{object}.pt()'), objectRelPFIsoRhoFSR=cms.string( '({object}.chargedHadronIso()' '+max(0.0,{object}.neutralHadronIso()' '+{object}.photonIso() - userFloat("leg{object_idx}fsrIsoCorr")' '-{object}.userFloat("zzRho2012")*{object}.userFloat("ea_comb_Data2012_iso04_kt6PFJ")))' '/{object}.pt()'), objectPFChargedIso=cms.string( '{object}.userIsolation("PfChargedHadronIso")'), objectPFNeutralIso=cms.string( '{object}.userIsolation("PfNeutralHadronIso")'), objectPFPhotonIso=cms.string('{object}.userIsolation("PfGammaIso")'), #ZH Synch iso variables ## objectRelPFIsoDBZhLike = cms.string( ## "({object}.chargedHadronIso()" ## "+max({object}.photonIso()" ## "+{object}.neutralHadronIso()" ## "-0.5*{object}.userIso(2),0.0))" ## "/{object}.pt()" ## ), objectEffectiveArea2012Data=cms.string( '{object}.userFloat("ea_comb_Data2012_iso04_kt6PFJ")'), objectEffectiveArea2011Data=cms.string( '{object}.userFloat("ea_comb_Data2011_iso04_kt6PFJ")'), objectEffectiveAreaFall11MC=cms.string( '{object}.userFloat("ea_comb_Fall11MC_iso04_kt6PFJ")'), objectRhoHZG2011=cms.string('{object}.userFloat("hzgRho2011")'), objectRhoHZG2012=cms.string('{object}.userFloat("hzgRho2012")'), objectRelIso=cms.string("({object}.dr03TkSumPt()" "+max({object}.dr03EcalRecHitSumEt()-1.0,0.0)" "+{object}.dr03HcalTowerSumEt())/{object}.pt()"), objectTrkIsoDR03=cms.string("{object}.dr03TkSumPt()"), objectEcalIsoDR03=cms.string("{object}.dr03EcalRecHitSumEt()"), objectHcalIsoDR03=cms.string("{object}.dr03HcalTowerSumEt()"), objectChargeIdTight='{object}.isGsfCtfScPixChargeConsistent', objectChargeIdMed='{object}.isGsfScPixChargeConsistent', objectChargeIdLoose='{object}.isGsfCtfChargeConsistent', # raw energy error objectEnergyError='{object}.corrections().combinedP4Error', #Experimental charge id from Silvia ## objectGsfCharge = '{object}.gsfTrack().charge()', ## objectTrkCharge = '{object}.track().charge()', ## objectScPixCharge = '{object}.scPixCharge()', # shower shape / ID variables objectHadronicOverEM='{object}.hcalOverEcal', objectHadronicDepth1OverEm='{object}.hcalDepth1OverEcal', objectHadronicDepth2OverEm='{object}.hcalDepth2OverEcal', objectSigmaIEtaIEta='{object}.sigmaIetaIeta', objectdeltaEtaSuperClusterTrackAtVtx= '{object}.deltaEtaSuperClusterTrackAtVtx', objectdeltaPhiSuperClusterTrackAtVtx= '{object}.deltaPhiSuperClusterTrackAtVtx', objectfBrem='{object}.fbrem', objecteSuperClusterOverP='{object}.eSuperClusterOverP', objectecalEnergy='{object}.ecalEnergy', objecttrackMomentumAtVtxP='{object}.trackMomentumAtVtx.r', objectHasMatchedConversion=cms.vstring( '{object}.userInt("HasMatchedConversion")', 'I'), objectE1x5='{object}.scE1x5', objectE2x5Max='{object}.scE2x5Max', objectE5x5='{object}.scE5x5', objectNearMuonVeto= 'overlapMuons({object_idx},0.05,"isGlobalMuon() & abs(eta()) < 2.4").size()', objectGenMotherPdgId= '? (getDaughterGenParticleMotherSmart({object_idx}, 11, 0).isAvailable && getDaughterGenParticleMotherSmart({object_idx}, 11, 0).isNonnull) ? getDaughterGenParticleMotherSmart({object_idx}, 11, 0).pdgId() : -999', objectComesFromHiggs='comesFromHiggs({object_idx}, 11, 1)', objectGenPdgId= '? (getDaughterGenParticle({object_idx}, 11, 0).isAvailable && getDaughterGenParticle({object_idx}, 11, 0).isNonnull) ? getDaughterGenParticle({object_idx}, 11, 0).pdgId() : -999', objectGenCharge= '? (getDaughterGenParticle({object_idx}, 11, 0).isAvailable && getDaughterGenParticle({object_idx}, 11, 0).isNonnull) ? getDaughterGenParticle({object_idx}, 11, 0).charge() : -999', objectGenEnergy= '? (getDaughterGenParticle({object_idx}, 11, 0).isAvailable && getDaughterGenParticle({object_idx}, 11, 0).isNonnull) ? getDaughterGenParticle({object_idx}, 11, 0).energy() : -999', objectGenEta= '? (getDaughterGenParticle({object_idx}, 11, 0).isAvailable && getDaughterGenParticle({object_idx}, 11, 0).isNonnull) ? getDaughterGenParticle({object_idx}, 11, 0).eta() : -999', objectGenPhi= '? (getDaughterGenParticle({object_idx}, 11, 0).isAvailable && getDaughterGenParticle({object_idx}, 11, 0).isNonnull) ? getDaughterGenParticle({object_idx}, 11, 0).phi() : -999', )
vetos = PSet( #MUON VETOS muVetoPt5='vetoMuons(0.4, "pt > 5 & abs(eta) < 2.4").size()', muGlbIsoVetoPt10= 'vetoMuons(0.4, "isGlobalMuon & isTrackerMuon & pt > 10 & abs(eta) < 2.4 & (userIso(0) + max(photonIso + neutralHadronIso - 0.5*puChargedHadronIso, 0))/pt < 0.4").size()', muVetoZH= 'vetoMuons(0.4, "isGlobalMuon & isTrackerMuon & pfCandidateRef.isNonnull & pt > 10 & abs(eta) < 2.4 & (userIso(0) + max(photonIso + neutralHadronIso - 0.5*puChargedHadronIso, 0))/pt < 0.3").size()', muVetoPt5IsoIdVtx= 'vetoMuons(0.4, "pt > 5 & abs(eta) < 2.4 & userInt(\'tightID\') > 0.5 & ((userIso(0) + max(photonIso()+neutralHadronIso()-0.5*puChargedHadronIso,0.0))/pt()) < 0.15 & userFloat(\'dz\') < 0.2").size()', muVetoPt15IsoIdVtx= 'vetoMuons(0.4, "pt > 15 & abs(eta) < 2.4 & userInt(\'tightID\') > 0.5 & ((userIso(0) + max(photonIso()+neutralHadronIso()-0.5*puChargedHadronIso,0.0))/pt()) < 0.15 & userFloat(\'dz\') < 0.2").size()', #TAU VETOS tauVetoPt20= 'vetoTaus(0.4, "pt > 20 & abs(eta) < 2.5 & tauID(\'decayModeFinding\') & tauID(\'byLooseIsolationMVA\')").size()', tauHpsVetoPt20= 'vetoTaus(0.3, "pt > 20 & abs(eta) < 2.3 & tauID(\'decayModeFinding\') & tauID(\'againstElectronLoose\') & tauID(\'againstMuonLoose\') & tauID(\'byMediumCombinedIsolationDeltaBetaCorr\')").size()', tauVetoZH= 'vetoTaus(0.1, "pt > 15 & abs(eta) < 2.3 & tauID(\'decayModeFinding\') & userFloat(\'dz\') < 0.1").size()', tauVetoPt20LooseMVAVtx= 'vetoTaus(0.4, "pt > 20 & abs(eta) < 2.5 & tauID(\'decayModeFinding\') & tauID(\'byLooseIsolationMVA\') & userFloat(\'dz\') < 0.2").size()', tauVetoPt20LooseMVA2Vtx= 'vetoTaus(0.4, "pt > 20 & abs(eta) < 2.5 & tauID(\'decayModeFinding\') & tauID(\'byLooseIsolationMVA2\') & userFloat(\'dz\') < 0.2").size()', tauVetoPt20Loose3HitsVtx= 'vetoTaus(0.4, "pt > 20 & abs(eta) < 2.5 & tauID(\'decayModeFinding\') & tauID(\'byLooseCombinedIsolationDeltaBetaCorr3Hits\') & userFloat(\'dz\') < 0.2").size()', tauVetoPt20VLooseHPSVtx= 'vetoTaus(0.4, "pt > 20 & abs(eta) < 2.5 & tauID(\'decayModeFinding\') & tauID(\'byVLooseCombinedIsolationDeltaBetaCorr\') & userFloat(\'dz\') < 0.2").size()', tauVetoPt20TightMVALTVtx= 'vetoTaus(0.4, "pt > 20 & abs(eta) < 2.5 & tauID(\'decayModeFinding\') & tauID(\'byTightIsolationMVA3oldDMwLT\') & userFloat(\'dz\') < 0.2").size()', tauVetoPt20TightMVAVtx= 'vetoTaus(0.4, "pt > 20 & abs(eta) < 2.5 & tauID(\'decayModeFinding\') & tauID(\'byTightIsolationMVA3oldDMwoLT\') & userFloat(\'dz\') < 0.2").size()', #NEW DMs tauVetoPt20Loose3HitsNewDMVtx= 'vetoTaus(0.4, "pt > 20 & abs(eta) < 2.5 & tauID(\'decayModeFindingNewDMs\') & tauID(\'byLooseCombinedIsolationDeltaBetaCorr3Hits\') & userFloat(\'dz\') < 0.2").size()', tauVetoPt20VLooseHPSNewDMVtx= 'vetoTaus(0.4, "pt > 20 & abs(eta) < 2.5 & tauID(\'decayModeFindingNewDMs\') & tauID(\'byVLooseCombinedIsolationDeltaBetaCorr\') & userFloat(\'dz\') < 0.2").size()', tauVetoPt20TightMVALTNewDMVtx= 'vetoTaus(0.4, "pt > 20 & abs(eta) < 2.5 & tauID(\'decayModeFinding\') & tauID(\'byTightIsolationMVA3newDMwLT\') & userFloat(\'dz\') < 0.2").size()', tauVetoPt20TightMVANewDMVtx= 'vetoTaus(0.4, "pt > 20 & abs(eta) < 2.5 & tauID(\'decayModeFinding\') & tauID(\'byTightIsolationMVA3newDMwoLT\') & userFloat(\'dz\') < 0.2").size()', #ELECTRON VETOS eVetoMVAIsoVtx= 'vetoElectrons(0.4, "pt > 10 & abs(eta) < 2.5 & userInt(\'mvaidwp\') > 0.5 & ((userIso(0) + max(userIso(1) + neutralHadronIso - 0.5*userIso(2), 0))/pt) < 0.3 & userFloat(\'dz\') < 0.2").size()', eVetoMVAIso= 'vetoElectrons(0.4, "pt > 10 & abs(eta) < 2.5 & userInt(\'mvaidwp\') > 0.5 & (userIso(0) + max(userIso(1) + neutralHadronIso - 0.5*userIso(2), 0))/pt < 0.3").size()', eVetoZH= 'vetoElectrons(0.1, "pt > 10 & abs(eta) < 2.5 & (userIso(0) + max(userIso(1) + neutralHadronIso - 0.5*userIso(2), 0))/pt < 0.3 & ( ( abs(eta) < 0.8 & electronID(\'mvaNonTrigV0\') > 0.5 ) || ( abs(eta) > 0.8 & abs(eta) < 1.479 & electronID(\'mvaNonTrigV0\') > 0.12 ) || ( abs(eta) > 1.479 & electronID(\'mvaNonTrigV0\') > 0.6 ))").size()', eVetoZH_smallDR= 'vetoElectrons(0.0001, "pt > 10 & abs(eta) < 2.5 & (userIso(0) + max(userIso(1) + neutralHadronIso - 0.5*userIso(2), 0))/pt < 0.3 & ( ( abs(eta) < 0.8 & electronID(\'mvaNonTrigV0\') > 0.5 ) || ( abs(eta) > 0.8 & abs(eta) < 1.479 & electronID(\'mvaNonTrigV0\') > 0.12 ) || ( abs(eta) > 1.479 & electronID(\'mvaNonTrigV0\') > 0.6 ))").size()', eVetoCicTightIso= 'vetoElectrons(0.4, "pt > 10 & abs(eta) < 2.5 & test_bit(electronID(\'cicTight\'), 0) > 0.5 & (userIso(0) + max(userIso(1) + neutralHadronIso - 0.5*userIso(2), 0))/pt < 0.3").size()', #B-JET Vetos bjetVeto= 'vetoJets(0.4, "pt > 20 & abs(eta) < 2.4 & userInt(\'fullIdLoose\') & bDiscriminator(\'\') > 3.3").size()', bjetCSVVeto= 'vetoJets(0.4, "pt > 20 & abs(eta) < 2.4 & userInt(\'fullIdLoose\') & bDiscriminator(\'combinedSecondaryVertexBJetTags\') > 0.679").size()', bjetCSVVetoZHLike= 'vetoJets(0.4, "pt > 20 & abs(eta) < 2.4 & userInt(\'fullIdLoose\') & bDiscriminator(\'combinedSecondaryVertexBJetTags\') > 0.898").size()', bjetCSVVetoZHLikeNoJetId= 'vetoJets(0.4, "pt > 20 & abs(eta) < 2.4 & bDiscriminator(\'combinedSecondaryVertexBJetTags\') > 0.898").size()', bjetCSVVetoZHLikeNoJetId_2= 'vetoJets(0.4, "pt > 20 & abs(eta) < 2.4 & bDiscriminator(\'combinedSecondaryVertexBJetTags\') > 0.679").size()', bjetCSVVeto30= 'vetoJets(0.4, "pt > 30 & abs(eta) < 2.4 & userInt(\'fullIdLoose\') & bDiscriminator(\'combinedSecondaryVertexBJetTags\') > 0.679").size()', #JET VETOS jetVeto20= 'vetoJets(0.4, "pt > 20 & abs(eta) < 5.0 & userInt(\'fullIdLoose\')").size()', jetVeto20_DR05= 'vetoJets(0.5, "pt > 20 & abs(eta) < 5.0 & userInt(\'fullIdLoose\')").size()', jetVeto30= 'vetoJets(0.4, "pt > 30 & abs(eta) < 5.0 & userInt(\'fullIdLoose\')").size()', jetVeto30_DR05= 'vetoJets(0.5, "pt > 30 & abs(eta) < 5.0 & userInt(\'fullIdLoose\')").size()', jetVeto40= 'vetoJets(0.4, "pt > 40 & abs(eta) < 5.0 & userInt(\'fullIdLoose\')").size()', jetVeto40_DR05= 'vetoJets(0.5, "pt > 40 & abs(eta) < 5.0 & userInt(\'fullIdLoose\')").size()', #leadingJetPt = '? (vetoJets(0.4, "abs(eta) < 5.0 & userInt(\'fullIdLoose\')").size() > 0) ? vetoJets(0.4, "abs(eta) < 5.0 & userInt(\'fullIdLoose\')").at(0).pt() : -1.', )
Ntuple branch template sets for event level quantities Each string is transformed into an expression on a FinalStateEvent object. Author: Evan K. Friis ''' import FWCore.ParameterSet.Config as cms from FinalStateAnalysis.Utilities.cfgtools import PSet # Vetos on extra stuff in the event num = PSet( evt=cms.vstring('evt.evtId.event', 'I'), # use int branch lumi=cms.vstring('evt.evtId.luminosityBlock', 'I'), # use int branch run=cms.vstring('evt.evtId.run', 'I'), # use int branch isdata=cms.vstring('evt.isRealData', 'I'), ) pileup = PSet( rho='evt.rho', nvtx='evt.recoVertices.size', # Number of true PU events nTruePU='? evt.puInfo.size > 0 ? evt.puInfo[1].getTrueNumInteractions : -1', ) met = PSet( metEt='evt.met.et', metPhi='evt.met.phi', metSignificance='evt.metSignificance', )
Ntuple branch template sets for event level quantities Each string is transformed into an expression on a FinalStateEvent object. Author: Evan K. Friis ''' import FWCore.ParameterSet.Config as cms from FinalStateAnalysis.Utilities.cfgtools import PSet # Vetos on extra stuff in the event num = PSet( evt=cms.vstring('evt.evtId.event', 'I'), # use int branch lumi=cms.vstring('evt.evtId.luminosityBlock', 'I'), # use int branch run=cms.vstring('evt.evtId.run', 'I'), # use int branch isdata=cms.vstring('evt.isRealData', 'I'), ) pileup = PSet( rho='evt.rho', nvtx='evt.recoVertices.size', # Number of true PU events nTruePU='? evt.puInfo.size > 0 ? evt.puInfo[1].getTrueNumInteractions :-1', ) pv_info = PSet( pvX='? evt.pv.isNonnull() ? evt.pv.x : -999', pvY='? evt.pv.isNonnull() ? evt.pv.y : -999', pvZ='? evt.pv.isNonnull() ? evt.pv.z : -999', pvDX='? evt.pv.isNonnull() ? evt.pv.xError : -999',
def make_ntuple(*legs, **kwargs): ''' Build an ntuple for a set of input legs. You can passes extra branches by passing a dict of branch:strings using the keyword argument: branches You can specify that no disambiguation can be applied (i.e. a dimuon candidate will appear twice in the mu-mu ntuple, in both orders) by setting 'noclean' to True in kwargs. ''' # Make sure we only use allowed leg types allowed = set(['m', 'e', 't', 'g', 'j']) assert (all(x in allowed for x in legs)) # Make object labels object_labels = [] format_labels = {} # Count how many objects of each type we put in counts = { 't': 0, 'm': 0, 'e': 0, 'g': 0, 'j': 0, } ntuple_config = _common_template.clone() # If we have two legs or photons, we are interested in VBF selections. if len(legs) == 2 or 'g' in legs: ntuple_config = PSet(ntuple_config, templates.topology.vbf) # Optionally apply extra branches in kwargs if 'branches' in kwargs: for branch, value in kwargs['branches'].iteritems(): setattr(ntuple_config, branch, cms.string(value)) # Check if we want to use special versions of the FSA producers # via a suffix on the producer name. producer_suffix = kwargs.get('suffix', '') for i, leg in enumerate(legs): counts[leg] += 1 # Check if we need to append an index (we have same flavor objects) label = leg if legs.count(leg) > 1: label = leg + str(counts[leg]) format_labels[label] = 'daughter(%i)' % i format_labels[label + '_idx'] = '%i' % i object_labels.append(label) # Get a PSet describing the branches for this leg leg_branches = _leg_templates[leg].replace(object=label) # Add to the total config ntuple_config = PSet(ntuple_config, leg_branches) #pdb.set_trace() # Now we need to add all the information about the pairs for leg_a, leg_b in itertools.combinations(object_labels, 2): ntuple_config = PSet( ntuple_config, templates.topology.pairs.replace(object1=leg_a, object2=leg_b), templates.topology.zboson.replace(object1=leg_a, object2=leg_b), ) # Check if we want to enable SVfit # Only do SVfit in states with 2 or 4 leptons do_svfit = kwargs.get("svFit", False) if not len(legs) % 2 == 0: do_svfit = False leg_a_type = leg_a[0] leg_b_type = leg_b[0] leg_a_index = legs.index(leg_a_type) \ if counts[leg_a_type] == 1 else legs.index(leg_a_type) + int(leg_a[1]) - 1 leg_b_index = legs.index(leg_b_type) \ if counts[leg_b_type] == 1 else legs.index(leg_b_type) + int(leg_b[1]) - 1 # Never do SVfit on 'non-paired' leptons (eg legs 0 & 2), or legs 1&3 # legs either adjacent or both ends (0 and 3) if leg_a_index % 2 != 0 or abs(leg_a_index - leg_b_index) % 2 != 1: do_svfit = False # Only do SVfit on mu + tau, e + tau, e + mu, & tau + tau combinations if leg_a_type == leg_b_type and leg_a_type in ('m', 'e'): do_svfit = False # Always ignore photons if 'g' in legs: do_svfit = False if do_svfit: print "SV fitting legs %s and %s in final state %s" % ( leg_a, leg_b, ''.join(legs)) ntuple_config = PSet( ntuple_config, templates.topology.svfit.replace(object1=leg_a, object2=leg_b)) # Are we running on the ZZ-specific collections? zz_mode = kwargs.get('zz_mode', False) analyzerSrc = "finalState" + "".join(_producer_translation[x] for x in legs) + producer_suffix if zz_mode: analyzerSrc += "Hzz" ntuple_config = PSet(ntuple_config, templates.topology.zzfsr) # Now build our analyzer EDFilter skeleton output = cms.EDFilter( "PATFinalStateAnalysisFilter", weights=cms.vstring(), # input final state collection. src=cms.InputTag(analyzerSrc), evtSrc=cms.InputTag("patFinalStateEventProducer"), # counter of events before any selections skimCounter=cms.InputTag("eventCount", "", "TUPLE"), analysis=cms.PSet( selections=cms.VPSet(), EventView=cms.bool(False), final=cms.PSet( sort=cms.string('daughter(0).pt'), # Doesn't really matter take=cms.uint32(50), plot=cms.PSet( histos=cms.VPSet(), # Don't make any final plots # ntuple has all generated branches in it. ntuple=ntuple_config.clone(), )), )) # Apply the basic selection to each leg for i, leg in enumerate(legs): output.analysis.selections.append( cms.PSet(name=cms.string('Leg%iPt' % i), cut=cms.string( 'daughter(%i).pt>%s' % (i, _pt_cuts[legs[i]]), ))) output.analysis.selections.append( cms.PSet(name=cms.string('Leg%iEta' % i), cut=cms.string('abs(daughter(%i).eta) < %s' % (i, _eta_cuts[legs[i]]))), ) # Apply "uniqueness requirements" to reduce final processing/storage. # This make sure there is only one ntuple entry per-final state. The # combinatorics due to different orderings are removed. # Algorithm: # if there are 2 of any given type, order them by pt # if there are 3 # first put best Z in initial position # then order first two by pt # if there are 4 # first put best Z in initial position # then order first two by pt # then order third and fourth by pt noclean = kwargs.get('noclean', False) # ZZ-producer does not require this cleaning step make_unique = not noclean and not zz_mode if make_unique: for type, count in counts.iteritems(): if count == 2: leg1_idx = format_labels['%s1_idx' % type] leg2_idx = format_labels['%s2_idx' % type] output.analysis.selections.append( cms.PSet(name=cms.string('%s_UniqueByPt' % type), cut=cms.string('orderedInPt(%s, %s)' % (leg1_idx, leg2_idx)))) if count == 3: leg1_idx_label = format_labels['%s1_idx' % type] leg2_idx_label = format_labels['%s2_idx' % type] leg3_idx_label = format_labels['%s3_idx' % type] # Require first two leptons make the best Z output.analysis.selections.append( cms.PSet( name=cms.string('Z12_Better_Z13'), cut=cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg1_idx_label, leg3_idx_label)))) output.analysis.selections.append( cms.PSet( name=cms.string('Z12_Better_Z23'), cut=cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg2_idx_label, leg3_idx_label)))) # Require first two leptons are ordered in PT output.analysis.selections.append( cms.PSet(name=cms.string('%s_UniqueByPt' % type), cut=cms.string('orderedInPt(%s, %s)' % (leg1_idx_label, leg2_idx_label)))) if count == 4: leg1_idx_label = format_labels['%s1_idx' % type] leg2_idx_label = format_labels['%s2_idx' % type] leg3_idx_label = format_labels['%s3_idx' % type] leg4_idx_label = format_labels['%s4_idx' % type] # Require first two leptons make the best Z output.analysis.selections.append( cms.PSet( name=cms.string('Z12_Better_Z13'), cut=cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg1_idx_label, leg3_idx_label)))) output.analysis.selections.append( cms.PSet( name=cms.string('Z12_Better_Z23'), cut=cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg2_idx_label, leg3_idx_label)))) output.analysis.selections.append( cms.PSet( name=cms.string('Z12_Better_Z14'), cut=cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg1_idx_label, leg4_idx_label)))) output.analysis.selections.append( cms.PSet( name=cms.string('Z12_Better_Z24'), cut=cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg2_idx_label, leg4_idx_label)))) output.analysis.selections.append( cms.PSet( name=cms.string('Z12_Better_Z34'), cut=cms.string( 'zCompatibility(%s, %s) < zCompatibility(%s, %s)' % (leg1_idx_label, leg2_idx_label, leg3_idx_label, leg4_idx_label)))) # Require first two leptons are ordered in PT output.analysis.selections.append( cms.PSet(name=cms.string('%s_UniqueByPt12' % type), cut=cms.string('orderedInPt(%s, %s)' % (leg1_idx_label, leg2_idx_label)))) # Require last two leptons are ordered in PT output.analysis.selections.append( cms.PSet(name=cms.string('%s_UniqueByPt34' % type), cut=cms.string('orderedInPt(%s, %s)' % (leg3_idx_label, leg4_idx_label)))) # Now apply our formatting operations format(output, **format_labels) # return LHEFilter*output return output
''' Ntuple branch template sets for trigger selections Each string is transformed into an expression on a FinalStateEvent object. Author: Evan K. Friis ''' from FinalStateAnalysis.Utilities.cfgtools import PSet _trig_template = PSet( namePass = '******', nameGroup = 'evt.hltGroup("paths")', namePrescale = 'evt.hltPrescale("paths")', ) singlemu = _trig_template.replace( name='singleMu', paths=r'HLT_Mu15_v\\d+, HLT_Mu24_v\\d+, HLT_Mu30_v\\d+') isomu = _trig_template.replace(name='isoMu', paths=r'HLT_IsoMu17_v\\d+, HLT_IsoMu20_v\\d+, ' r'HLT_IsoMu24_v\\d+, HLT_IsoMu24_eta2p1_v\\d+') doublemu = PSet( _trig_template.replace( name='doubleMu', paths=r'HLT_DoubleMu7_v\\d+,HLT_Mu13_Mu8_v\\d+,HLT_Mu17_Mu8_v\\d+'), _trig_template.replace( name='doubleMuTrk',