diff --git a/plugins/NearbyMuonsInfo.cc b/plugins/NearbyMuonsInfo.cc index 1d8b13130ce..224ac52e9d8 100644 --- a/plugins/NearbyMuonsInfo.cc +++ b/plugins/NearbyMuonsInfo.cc @@ -105,6 +105,7 @@ NearbyMuonsInfo::produce(edm::Event & iEvent, const edm::EventSetup & iSetup) { //// Start DCA Calculation ////// reco::TrackRef tk = mu1->get(); reco::TrackRef tk2nd = mu2->get(); + if (tk.isNull() || tk2nd.isNull()) continue ; reco::TransientTrack transMu1(*tk, &(*theMF) ); reco::TransientTrack transMu2(*tk2nd, &(*theMF) ); TrajectoryStateClosestToPoint mu1TS = transMu1.impactPointTSCP(); diff --git a/python/common_modules_cff.py b/python/common_modules_cff.py index 4c3b22edfba..6be56533d66 100644 --- a/python/common_modules_cff.py +++ b/python/common_modules_cff.py @@ -4,6 +4,10 @@ from JetMETCorrections.Configuration.JetCorrectors_cff import ak4PFCHSL1FastL2L3CorrectorChain, ak4PFCHSL1FastL2L3Corrector from JetMETCorrections.Configuration.JetCorrectors_cff import ak4PFCHSL3AbsoluteCorrector, ak4PFCHSL2RelativeCorrector, ak4PFCHSL1FastjetCorrector +tagProbeStaSeparation = tagProbeSeparation.clone( + src = cms.InputTag("tpPairsSta"), + ) + ######################################################################################### ## Object counting modules ## ######################################################################################### @@ -49,7 +53,7 @@ ) tkTracksNoBestJPsi = tkTracksNoJPsi.clone(onlyBestMatch = True) -## Filter out the J/Psi's, to compute fake matching rate +## Filter out the Z's, to compute fake matching rate tkTracksNoZ = cms.EDProducer("CandidateResonanceInefficiencyCreator", src = cms.InputTag("tkTracks"), tags = cms.InputTag("tagMuons"), @@ -179,10 +183,14 @@ ) probeMultiplicity = cms.EDProducer("ProbeMulteplicityProducer", - pairs = cms.InputTag("tpPairs"), + pairs = cms.InputTag("tpPairs"), #pairCut = cms.string(""), # count only probes whose pairs satisfy this cut #probeCut = cms.string(""), # count only probes satisfying this cut ) +probeStaMultiplicity = probeMultiplicity.clone( + pairs = cms.InputTag("tpPairsSta"), +) +# probeMultiplicityTMGM = cms.EDProducer("ProbeMulteplicityProducer", pairs = cms.InputTag("tpPairs"), #pairCut = cms.string(""), # count only probes whose pairs satisfy this cut @@ -238,3 +246,25 @@ cut = cms.string("abs(pdgId) == 13 && pt > 3 && abs(eta) < 2.4 && status == 1 && isPromptFinalState") ) +goodGenMuonsFromJpsi = cms.EDFilter("GenParticleSelector", + src = cms.InputTag("genParticles"), + cut = cms.string("abs(pdgId) == 13 && abs(eta) < 2.4 && numberOfMothers == 1 && motherRef.pdgId == 443") +) + +softIDToGenMatch = cms.EDProducer("MatcherUsingTracksWithTagAssoc", + src = cms.InputTag("probeGen"), + matched = cms.InputTag("probeMuons"), + tags = cms.InputTag("tagMuons"), # needed just to ask for #Deltaz < tagDeltaZ + tagDeltaZ = cms.double(1.0), + algorithm = cms.string("byDirectComparison"), + srcTrack = cms.string("none"), srcState = cms.string("atVertex"), + matchedTrack = cms.string("tracker"), matchedState = cms.string("atVertex"), + maxDeltaR = cms.double(1.), # large range in DR (we can tighten it later) + maxDeltaEta = cms.double(1.), # small in eta, which is more precise + maxDeltaLocalPos = cms.double(100), + maxDeltaPtRel = cms.double(5), # |pt(src) - pt(matched)|/pt(matched) + sortBy = cms.string("deltaR"), + requireSameCharge = cms.bool(True), + softID = cms.bool(True), + objectSelection = cms.string("") +) diff --git a/python/common_variables_cff.py b/python/common_variables_cff.py index 3c7acc096b5..d05a2c71327 100644 --- a/python/common_variables_cff.py +++ b/python/common_variables_cff.py @@ -17,29 +17,17 @@ chargedHadIso03 = cms.string("pfIsolationR03().sumChargedHadronPt"), puIso03 = cms.string("pfIsolationR03().sumPUPt"), neutralHadIso03 = cms.string("pfIsolationR03().sumNeutralHadronEt"), -# neutralHadIso03HT = cms.string("pfIsolationR03().sumNeutralHadronEtHighThreshold"), photonIso03 = cms.string("pfIsolationR03().sumPhotonEt"), -# photonIso03HT = cms.string("pfIsolationR03().sumPhotonEtHighThreshold"), chargedParticleIso03 = cms.string("pfIsolationR03().sumChargedParticlePt"), combRelIsoPF03 = cms.string("(pfIsolationR03().sumChargedHadronPt + pfIsolationR03().sumNeutralHadronEt + pfIsolationR03().sumPhotonEt)/pt"), combRelIsoPF03dBeta = cms.string("(pfIsolationR03().sumChargedHadronPt + max(pfIsolationR03().sumNeutralHadronEt + pfIsolationR03().sumPhotonEt - pfIsolationR03().sumPUPt/2,0.0))/pt"), -# combRelIsoPF03HT = cms.string("(pfIsolationR03().sumChargedHadronPt + pfIsolationR03().sumNeutralHadronEtHighThreshold + pfIsolationR03().sumPhotonEtHighThreshold)/pt"), - chargedHadIso04 = cms.string("pfIsolationR04().sumChargedHadronPt"), puIso04 = cms.string("pfIsolationR04().sumPUPt"), neutralHadIso04 = cms.string("pfIsolationR04().sumNeutralHadronEt"), -# neutralHadIso04HT = cms.string("pfIsolationR04().sumNeutralHadronEtHighThreshold"), photonIso04 = cms.string("pfIsolationR04().sumPhotonEt"), -# photonIso04HT = cms.string("pfIsolationR04().sumPhotonEtHighThreshold"), chargedParticleIso04 = cms.string("pfIsolationR04().sumChargedParticlePt"), combRelIsoPF04 = cms.string("(pfIsolationR04().sumChargedHadronPt + pfIsolationR04().sumNeutralHadronEt + pfIsolationR04().sumPhotonEt)/pt"), combRelIsoPF04dBeta = cms.string("(pfIsolationR04().sumChargedHadronPt + max(pfIsolationR04().sumNeutralHadronEt + pfIsolationR04().sumPhotonEt - pfIsolationR04().sumPUPt/2,0.0))/pt"), -# combRelIsoPF04HT = cms.string("(pfIsolationR04().sumChargedHadronPt + pfIsolationR04().sumNeutralHadronEtHighThreshold + pfIsolationR04().sumPhotonEtHighThreshold)/pt"), - -# neutralHadIso = cms.string("neutralHadronIso"), -# chargedHadIso = cms.string("chargedHadronIso"), -# photonIso = cms.string("photonIso"), -# combRelIsoP = cms.string("(neutralHadronIso + chargedHadronIso + photonIso)/pt"), ) MuonIDVariables = cms.PSet( @@ -67,11 +55,8 @@ tkTrackerLay = cms.string("? track.isNull ? 0 : track.hitPattern.trackerLayersWithMeasurement"), tkValidPixelHits = cms.string("? track.isNull ? 0 : track.hitPattern.numberOfValidPixelHits"), tkPixelLay = cms.string("? track.isNull ? 0 : track.hitPattern.pixelLayersWithMeasurement"), - # tkExpHitIn = cms.string("? track.isNull ? 0 : track.trackerExpectedHitsInner().numberOfLostHits"), - # tkExpHitOut = cms.string("? track.isNull ? 0 : track.trackerExpectedHitsOuter().numberOfLostHits"), tkExpHitIn = cms.string("? track.isNull ? 0 : track.hitPattern.numberOfLostHits('MISSING_INNER_HITS')"), #reco::HitPattern:: tkExpHitOut = cms.string("? track.isNull ? 0 : track.hitPattern.numberOfLostHits('MISSING_OUTER_HITS')"), #reco::HitPattern:: - # tkHitFract = cms.string("? track.isNull ? 0 : track.hitPattern.numberOfValidHits/(track.hitPattern.numberOfValidHits+track.hitPattern.numberOfLostHits+track.trackerExpectedHitsInner().numberOfLostHits+track.trackerExpectedHitsOuter().numberOfLostHits)"), tkHitFract = cms.string("? track.isNull ? 0 : track.hitPattern.numberOfValidHits/(track.hitPattern.numberOfValidHits+track.hitPattern.numberOfLostHits('TRACK_HITS')+track.hitPattern.numberOfLostHits('MISSING_INNER_HITS')+ track.hitPattern.numberOfLostHits('MISSING_OUTER_HITS') )"), tkChi2 = cms.string("? track.isNull ? -1 : track.normalizedChi2"), tkPtError = cms.string("? track.isNull ? -1 : track.ptError"), @@ -161,41 +146,6 @@ ) HighPtTriggerFlags = cms.PSet( - # legacy - #Mu9 = cms.string("!triggerObjectMatchesByPath('HLT_Mu9').empty()"), - #DoubleMu3 = cms.string("!triggerObjectMatchesByPath('HLT_DoubleMu3_v*').empty()"), - # current or new up to 3E33 menu - #Mu15 = cms.string("!triggerObjectMatchesByPath('HLT_Mu15_v*',1,0).empty()"), - #Mu20 = cms.string("!triggerObjectMatchesByPath('HLT_Mu20_v*',1,0).empty()"), - #Mu24 = cms.string("!triggerObjectMatchesByPath('HLT_Mu24_v*',1,0).empty()"), - #Mu24_eta2p1 = cms.string("!triggerObjectMatchesByPath('HLT_Mu24_eta2p1_v*',1,0).empty()"), - #Mu30 = cms.string("!triggerObjectMatchesByPath('HLT_Mu30_v*',1,0).empty()"), - #Mu30_eta2p1 = cms.string("!triggerObjectMatchesByPath('HLT_Mu30_eta2p1_v*',1,0).empty()"), - #Mu40 = cms.string("!triggerObjectMatchesByPath('HLT_Mu40_v*',1,0).empty()"), - #Mu40_eta2p1 = cms.string("!triggerObjectMatchesByPath('HLT_Mu40_eta2p1_v*',1,0).empty()"), - #IsoMu15 = cms.string("!triggerObjectMatchesByPath('HLT_IsoMu15_v*',1,0).empty()"), - #IsoMu15_eta2p1 = cms.string("!triggerObjectMatchesByPath('HLT_IsoMu15_eta2p1_v*',1,0).empty()"), - #IsoMu17 = cms.string("!triggerObjectMatchesByPath('HLT_IsoMu17_v*',1,0).empty()"), - #IsoMu24 = cms.string("!triggerObjectMatchesByPath('HLT_IsoMu24_v*',1,0).empty()"), - #IsoMu24_eta2p1 = cms.string("!triggerObjectMatchesByPath('HLT_IsoMu24_eta2p1_v*',1,0).empty()"), - #IsoMu30 = cms.string("!triggerObjectMatchesByPath('HLT_IsoMu30_v*',1,0).empty()"), - #IsoMu30_eta2p1 = cms.string("!triggerObjectMatchesByPath('HLT_IsoMu30_eta2p1_v*',1,0).empty()"), - #Mu15orMu17orMu20orMu24orMu30orMu40 = cms.string("!triggerObjectMatchesByPath('HLT_Mu15_v*',1,0).empty() || !triggerObjectMatchesByPath('HLT_IsoMu17_v*',1,0).empty() || !triggerObjectMatchesByPath('HLT_Mu20_v*',1,0).empty() || !triggerObjectMatchesByPath('HLT_IsoMu20_v*',1,0).empty() || !triggerObjectMatchesByPath('HLT_Mu24_v*',1,0).empty() || !triggerObjectMatchesByPath('HLT_Mu24_eta2p1_v*',1,0).empty() || !triggerObjectMatchesByPath('HLT_IsoMu24_eta2p1_v*',1,0).empty() || !triggerObjectMatchesByPath('HLT_IsoMu24_v*',1,0).empty() || !triggerObjectMatchesByPath('HLT_IsoMu30_eta2p1_v*',1,0).empty() || !triggerObjectMatchesByPath('HLT_IsoMu30_eta2p1_v*',1,0).empty() || !triggerObjectMatchesByPath('HLT_Mu30_v*',1,0).empty() || !triggerObjectMatchesByPath('HLT_Mu30_eta2p1_v*',1,0).empty() || !triggerObjectMatchesByPath('HLT_Mu40_v*',1,0).empty() || !triggerObjectMatchesByPath('HLT_Mu40_eta2p1_v*',1,0).empty()"), - #DoubleMu5 = cms.string("!triggerObjectMatchesByPath('HLT_DoubleMu5_v*',1,0).empty()"), - #DoubleMu7 = cms.string("!triggerObjectMatchesByPath('HLT_DoubleMu7_v*',1,0).empty()"), - #DoubleMu13Mu8_Mu13 = cms.string("!triggerObjectMatchesByPath('HLT_Mu13_Mu8_v*',1,0).empty()"), - #DoubleMu13Mu8_Mu8 = cms.string("!triggerObjectMatchesByFilter('hltDiMuonL3PreFiltered8').empty() || !triggerObjectMatchesByFilter('hltDiMuonL3p5PreFiltered8').empty()"), - - ## Heavily prescaled but still useful - #Mu17 = cms.string("!triggerObjectMatchesByPath('HLT_Mu17_v*',1,0).empty()"), - #Mu8 = cms.string("!triggerObjectMatchesByPath('HLT_Mu8_v*',1,0).empty()"), - - # 2011 version - # DoubleMu17Mu8_Mu17 = cms.string("!triggerObjectMatchesByPath('HLT_Mu17_Mu8_v*',1,0).empty()"), - # DoubleMu17Mu8_Mu8 = cms.string("!triggerObjectMatchesByFilter('hltDiMuonL3PreFiltered8').empty() || !triggerObjectMatchesByFilter('hltDiMuonL3p5PreFiltered8').empty()"), - # DoubleMu17TkMu8_TkMu8 = cms.string("!triggerObjectMatchesByPath('HLT_Mu17_TkMu8_v*',1,0).empty()"), - # DoubleMu17TkMu8_Mu17 = cms.string("!triggerObjectMatchesByFilter('hltL3Mu17FromDiMuonFiltered17').empty()") - # 2015 version Mu17 = cms.string("!triggerObjectMatchesByPath('HLT_Mu17_v*',1,0).empty()"), Mu17_IsoTrkVVL = cms.string("!triggerObjectMatchesByPath('HLT_Mu17_TrkIsoVVL_v*',1,0).empty()"), @@ -209,7 +159,11 @@ IsoMu27 = cms.string("!triggerObjectMatchesByPath('HLT_IsoMu27_v*',1,0).empty()"), IsoMu17_eta2p1 = cms.string("!triggerObjectMatchesByPath('HLT_IsoMu17_eta2p1_v*',1,0).empty()"), IsoMu20_eta2p1 = cms.string("!triggerObjectMatchesByPath('HLT_IsoMu20_eta2p1_v*',1,0).empty()"), + Mu40 = cms.string("!triggerObjectMatchesByPath('HLT_Mu40_v*',1,0).empty()"), + Mu40_eta2p1 = cms.string("!triggerObjectMatchesByPath('HLT_Mu40_eta2p1_v*',1,0).empty()"), + IsoMu24 = cms.string("!triggerObjectMatchesByPath('HLT_IsoMu24_v*',1,0).empty()"), IsoMu24_eta2p1 = cms.string("!triggerObjectMatchesByPath('HLT_IsoMu24_eta2p1_v*',1,0).empty()"), + IsoMu30 = cms.string("!triggerObjectMatchesByPath('HLT_IsoMu30_v*',1,0).empty()"), OldIsoTkMu18 = cms.string("!triggerObjectMatchesByPath('HLT_OldIsoTkMu18_v*',1,0).empty()"), IsoTkMu18 = cms.string("!triggerObjectMatchesByPath('HLT_IsoTkMu18_v*',1,0).empty()"), IsoTkMu20 = cms.string("!triggerObjectMatchesByPath('HLT_IsoTkMu20_v*',1,0).empty()"), @@ -217,6 +171,9 @@ IsoTkMu27 = cms.string("!triggerObjectMatchesByPath('HLT_IsoTkMu27_v*',1,0).empty()"), IsoTkMu20_eta2p1 = cms.string("!triggerObjectMatchesByPath('HLT_IsoTkMu20_eta2p1_v*',1,0).empty()"), IsoTkMu24_eta2p1 = cms.string("!triggerObjectMatchesByPath('HLT_IsoTkMu24_eta2p1_v*',1,0).empty()"), + + ## Heavily prescaled but still useful + Mu8 = cms.string("!triggerObjectMatchesByPath('HLT_Mu8_v*',1,0).empty()"), # To take care of the presence or not of the dz filter, we are requiring three flags for each of the main un-prescaled DoubleMuon Triggers # Mu17 leg, Mu8 leg, and (Mu17 leg && fired path) @@ -224,7 +181,7 @@ #DoubleMu17Mu8_Mu17 = cms.string("!triggerObjectMatchesByPath('HLT_Mu17_Mu8_v*',1,0).empty() && (!triggerObjectMatchesByFilter('hltL3fL1DoubleMu10MuOpenL1f0L2f10L3Filtered17').empty() || !triggerObjectMatchesByFilter('hltL3fL1DoubleMu10MuOpenOR3p5L1f0L2f10L3Filtered17').empty())"), ##DoubleMu17Mu8_Mu8 = cms.string("!triggerObjectMatchesByPath('HLT_Mu17_Mu8_v*',1,0).empty() && (!triggerObjectMatchesByFilter('hltL3pfL1DoubleMu10MuOpenL1f0L2pf0L3PreFiltered8').empty() || !triggerObjectMatchesByFilter('hltL3pfL1DoubleMu10MuOpenOR3p5L1f0L2pf0L3PreFiltered8').empty())"), #DoubleMu17Mu8_Mu17leg = cms.string("!triggerObjectMatchesByFilter('hltL3fL1DoubleMu10MuOpenL1f0L2f10L3Filtered17').empty() || !triggerObjectMatchesByFilter('hltL3fL1DoubleMu10MuOpenOR3p5L1f0L2f10L3Filtered17').empty()"), - #DoubleMu17Mu8_Mu8leg = cms.string("!triggerObjectMatchesByFilter('hltL3pfL1DoubleMu10MuOpenL1f0L2pf0L3PreFiltered8').empty() || !triggerObjectMatchesByFilter('hltL3pfL1DoubleMu10MuOpenOR3p5L1f0L2pf0L3PreFiltered8').empty()"), + #DoubleMu17Mu8_Mu8leg = cms.string("!triggerObjectMatchesByFilter('hltL3pfL1DoubleMu10MuOpenL1f0L2pf0L3PreFiltered8').empty() || !triggerObjectMatchesByFilter('hltL3pfL1DoubleMu10MuOpenOR3p5L1f0L2pf0L3PreFiltered8').empty()"), #DoubleMu17TkMu8_Mu17 = cms.string("!triggerObjectMatchesByPath('HLT_Mu17_TkMu8_v*',1,0).empty() && (!triggerObjectMatchesByFilter('hltL3fL1sMu10MuOpenL1f0L2f10L3Filtered17').empty() || !triggerObjectMatchesByFilter('hltL3fL1sMu10MuOpenOR3p5L1f0L2f10L3Filtered17').empty())"), @@ -294,80 +251,138 @@ L3fL1sMu16f0TkFiltered20QL3pfhcalIsoRhoFilteredHB0p21HE0p22 = cms.string("!triggerObjectMatchesByFilter('hltL3fL1sMu16f0TkFiltered20QL3pfhcalIsoRhoFilteredHB0p21HE0p22').empty()||!triggerObjectMatchesByFilter('hltL3fL1sMu16f0TkFiltered20QL3pfhcalIsoRhoFiltered0p23').empty()"), L3fL1sMu16L1f0Tkf20QL3trkIsoFiltered0p09 = cms.string("!triggerObjectMatchesByFilter('hltL3fL1sMu16L1f0Tkf20QL3trkIsoFiltered0p09').empty()"), -) + ) LowPtTriggerFlagsPhysics = cms.PSet( - #DoubleMu0_Quarkonium = cms.string("!triggerObjectMatchesByPath('HLT_DoubleMu0',1,0).empty() || "+ - # "!triggerObjectMatchesByPath('HLT_DoubleMu0_Quarkonium',1,0).empty() || "+ - # "!triggerObjectMatchesByPath('HLT_DoubleMu0_Quarkonium_v1',1,0).empty()"), - #DoubleMu3_Jpsi_A = cms.string("!triggerObjectMatchesByFilter('hltDiMuonL3PreFiltered3Jpsi').empty()"), - #DoubleMu3_Jpsi_B = cms.string("!triggerObjectMatchesByFilter('hltDoubleMu3JpsiL3Filtered').empty()"), - #DoubleMu3_Jpsi = cms.string("!triggerObjectMatchesByPath('HLT_DoubleMu3_Jpsi_v*',1,0).empty()"), -) + ########## Onia triggers filters ########## + Dimuon16_L1L2 = cms.string( "!triggerObjectMatchesByCollection('hltL2MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL2MuonCandidates').at(0).hasFilterLabel('hltL2fL1sL1DoubleMu10MuOpenL1f0L2PreFiltered0')" + ), + Dimuon10_L1L2 = cms.string( "!triggerObjectMatchesByCollection('hltL2MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL2MuonCandidates').at(0).hasFilterLabel('hltL2fL1sL1DoubleMu0er16NoOSL1f0L2PreFiltered0')" + ), + ########## L3 Mu ########## + Mu_L3 = cms.string( "!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()" + ), + ########## Vertexing filters ########## + Dimuon6_Jpsi_NoVertexing = cms.string( "!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltDimuon6JpsiL3Filtered')"), + Dimuon0er16_Jpsi_NoVertexing = cms.string("!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltDimuon0JpsiOSL3Filtered')"), + Dimuon0er16_Jpsi_NoOS_NoVertexing = cms.string("!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltDimuon0JpsiNoOSL3Filtered')"), + ########## Final filters ########## + Dimuon16_Jpsi = cms.string("!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltDisplacedmumuFilterDimuon16Jpsi')"), + Dimuon20_Jpsi = cms.string("!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltDisplacedmumuFilterDimuon20Jpsi')"), + Dimuon10_Jpsi_Barrel = cms.string("!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltDisplacedmumuFilterDimuon10JpsiBarrel')"), + Dimuon13_PsiPrime = cms.string("!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltDisplacedmumuFilterDimuon13PsiPrime')"), + Dimuon8_PsiPrime_Barrel = cms.string("!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltDisplacedmumuFilterDimuon8PsiPrimeBarrel')"), + Dimuon13_Upsilon = cms.string("!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltDisplacedmumuFilterDimuon13Upsilon')"), + Dimuon8_Upsilon_Barrel = cms.string("!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltDisplacedmumuFilterDimuon8UpsilonBarrel')"), + Dimuon0_Phi_Barrel = cms.string("!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltDisplacedmumuFilterDimuon0PhiBarrel')"), + ) LowPtTriggerFlagsEfficienciesTag = cms.PSet( - ## Mu + Track - ## 2012 - Mu5_Track2_Jpsi_MU = cms.string("!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty() && "+ - " triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltMu5Track2JpsiTrackMassFiltered')"), - Mu5_Track3p5_Jpsi_MU = cms.string("!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty() && "+ - " triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltMu5Track3p5JpsiTrackMassFiltered')"), - Mu7_Track7_Jpsi_MU = cms.string("!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty() && "+ - " triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltMu7Track7JpsiTrackMassFiltered')"), - - ## 2015 - Mu7p5_Track2_Jpsi_MU = cms.string("!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty() && "+ - " triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltMu7p5Track2JpsiTrackMassFiltered')"), - Mu7p5_Track3p5_Jpsi_MU = cms.string("!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty() && "+ - " triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltMu7p5Track3p5JpsiTrackMassFiltered')"), - Mu7p5_Track7_Jpsi_MU = cms.string("!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty() && "+ - " triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltMu7p5Track7JpsiTrackMassFiltered')"), - - ## Mu + L2Mu - ## 2012 - Mu5_L2Mu0_MU = cms.string("!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty() && "+ - " triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltMu5L2Mu0L3Filtered5')"), - Mu5_L2Mu2_Jpsi_MU = cms.string("!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty() && "+ - " triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltMu5L2Mu2JpsiTrackMassFiltered')"), - Mu5_L2Mu3_Jpsi_MU = cms.string("!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty() && "+ - " triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltMu5L2Mu3JpsiTrackMassFiltered')"), - ## 2015 - Mu7p5_L2Mu2_Jpsi_MU = cms.string("!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty() && "+ - " triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltMu7p5L2Mu2JpsiTrackMassFiltered')"), -) + ########## Mu ########## + Mu7p5_MU = cms.string("!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltL3fLMu7p5TrackL3Filtered7p5')" + ), + ########## Mu + Track ########## + Mu7p5_Track2_Jpsi_MU = cms.string( "!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltL3fLMu7p5TrackL3Filtered7p5')" + + " && triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltMu7p5Track2JpsiTrackMassFiltered')" + ), + Mu7p5_Track3p5_Jpsi_MU = cms.string("!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltL3fLMu7p5TrackL3Filtered7p5')" + + " && triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltMu7p5Track3p5JpsiTrackMassFiltered')" + ), + Mu7p5_Track7_Jpsi_MU = cms.string( "!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltL3fLMu7p5TrackL3Filtered7p5')" + + " && triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltMu7p5Track7JpsiTrackMassFiltered')" + ), + ########## Mu + L2Mu ########## + Mu7p5_L2Mu2_Jpsi_MU = cms.string( "!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltL3fMu7p5L2Mu2L3Filtered7p5')" + + " && triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltMu7p5L2Mu2JpsiTrackMassFiltered')" + ), + ########## Mu + TkMu ########## + Mu25TkMu0Onia_L3_MU = cms.string( "!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltL3fL1sMu16orMu20erorMu25L1f0L2f0L3Filtered25')" + ), + Mu16TkMu0Onia_L3_MU = cms.string( "!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltL3fL1sMu16orMu20erorMu16L1f0L2f0L3Filtered16')" + ), + ) LowPtTriggerFlagsEfficienciesProbe = cms.PSet( - - ## Mu + Track - ## 2012 - Mu5_Track2_Jpsi_TK = cms.string("!triggerObjectMatchesByCollection('hltMuTrackJpsiEffCtfTrackCands').empty() && "+ - " triggerObjectMatchesByCollection('hltMuTrackJpsiEffCtfTrackCands').at(0).hasFilterLabel('hltMu5Track2JpsiTrackMassFiltered')"), - Mu5_Track3p5_Jpsi_TK = cms.string("!triggerObjectMatchesByCollection('hltMuTrackJpsiEffCtfTrackCands').empty() && "+ - " triggerObjectMatchesByCollection('hltMuTrackJpsiEffCtfTrackCands').at(0).hasFilterLabel('hltMu5Track3p5JpsiTrackMassFiltered')"), - Mu7_Track7_Jpsi_TK = cms.string("!triggerObjectMatchesByCollection('hltMuTrackJpsiCtfTrackCands').empty() && "+ - " triggerObjectMatchesByCollection('hltMuTrackJpsiCtfTrackCands').at(0).hasFilterLabel('hltMu7Track7JpsiTrackMassFiltered')"), - - ## 2015 - Mu7p5_Track2_Jpsi_TK = cms.string("!triggerObjectMatchesByCollection('hltTracksIter').empty() && " + - " triggerObjectMatchesByCollection('hltTracksIter').at(0).hasFilterLabel('hltMu7p5Track2JpsiTrackMassFiltered')"), - Mu7p5_Track3p5_Jpsi_TK = cms.string("!triggerObjectMatchesByCollection('hltTracksIter').empty() && " + - " triggerObjectMatchesByCollection('hltTracksIter').at(0).hasFilterLabel('hltMu7p5Track3p5JpsiTrackMassFiltered')"), - Mu7p5_Track7_Jpsi_TK = cms.string("!triggerObjectMatchesByCollection('hltTracksIter').empty() && " + - " triggerObjectMatchesByCollection('hltTracksIter').at(0).hasFilterLabel('hltMu7p5Track7JpsiTrackMassFiltered')"), - - ## Mu + L2Mu - ## 2012 - Mu5_L2Mu0_L2 = cms.string("!triggerObjectMatchesByCollection('hltL2MuonCandidates').empty() && "+ - " triggerObjectMatchesByCollection('hltL2MuonCandidates').at(0).hasFilterLabel('hltDiMuonL2PreFiltered0')"), - Mu5_L2Mu2_Jpsi_L2 = cms.string("!triggerObjectMatchesByCollection('hltL2MuonCandidates').empty() && "+ - " triggerObjectMatchesByCollection('hltL2MuonCandidates').at(0).hasFilterLabel('hltMu5L2Mu2JpsiTrackMassFiltered')"), - Mu5_L2Mu3_Jpsi_L2 = cms.string("!triggerObjectMatchesByCollection('hltL2MuonCandidates').empty() && "+ - " triggerObjectMatchesByCollection('hltL2MuonCandidates').at(0).hasFilterLabel('hltMu5L2Mu3JpsiTrackMassFiltered')"), - ## 2012 - Mu7p5_L2Mu2_Jpsi_L2 = cms.string("!triggerObjectMatchesByCollection('hltL2MuonCandidates').empty() && " + - " triggerObjectMatchesByCollection('hltL2MuonCandidates').at(0).hasFilterLabel('hltMu7p5L2Mu2JpsiTrackMassFiltered')"), - -) + ########## Mu + Track ########## + #Mu7p5_Track2_Jpsi_TK = cms.string("!triggerObjectMatchesByCollection('hltMuTrackJpsiEffCtfTrackCands').empty() && "+ + # " triggerObjectMatchesByCollection('hltMuTrackJpsiEffCtfTrackCands').at(0).hasFilterLabel('hltMu7p5Track2JpsiTrackMassFiltered')"), + #Mu7p5_Track3p5_Jpsi_TK = cms.string("!triggerObjectMatchesByCollection('hltMuTrackJpsiEffCtfTrackCands').empty() && "+ + # " triggerObjectMatchesByCollection('hltMuTrackJpsiEffCtfTrackCands').at(0).hasFilterLabel('hltMu7p5Track3p5JpsiTrackMassFiltered')"), + #Mu7p5_Track7_Jpsi_TK = cms.string("!triggerObjectMatchesByCollection('hltMuTrackJpsiEffCtfTrackCands').empty() && "+ + # " triggerObjectMatchesByCollection('hltMuTrackJpsiEffCtfTrackCands').at(0).hasFilterLabel('hltMu7p5Track7JpsiTrackMassFiltered')"), + ########## Mu + Track ########## + Mu7p5_Track2_Jpsi_TK = cms.string( "!triggerObjectMatchesByCollection('hltTracksIter').empty()" + + " && triggerObjectMatchesByCollection('hltTracksIter').at(0).hasFilterLabel('hltMu7p5Track2JpsiTrackMassFiltered')" + ), + Mu7p5_Track3p5_Jpsi_TK = cms.string("!triggerObjectMatchesByCollection('hltTracksIter').empty()" + + " && triggerObjectMatchesByCollection('hltTracksIter').at(0).hasFilterLabel('hltMu7p5Track3p5JpsiTrackMassFiltered')" + ), + Mu7p5_Track7_Jpsi_TK = cms.string( "!triggerObjectMatchesByCollection('hltTracksIter').empty()" + + " && triggerObjectMatchesByCollection('hltTracksIter').at(0).hasFilterLabel('hltMu7p5Track7JpsiTrackMassFiltered')" + ), + ########## Mu + L2Mu ########## + Mu7p5_L2Mu2_L2 = cms.string( "!triggerObjectMatchesByCollection('hltL2MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL2MuonCandidates').at(0).hasFilterLabel('hltL2fDoubleMu2L2PreFiltered2')" + ), + Mu7p5_L2Mu2_Jpsi_L2 = cms.string( "!triggerObjectMatchesByCollection('hltL2MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL2MuonCandidates').at(0).hasFilterLabel('hltL2fDoubleMu2L2PreFiltered2')" + + " && triggerObjectMatchesByCollection('hltL2MuonCandidates').at(0).hasFilterLabel('hltMu7p5L2Mu2JpsiTrackMassFiltered')" + ), + ########## Mu + TkMu ########## + Mu25TkMu0Onia_L2 = cms.string( "!triggerObjectMatchesByCollection('hltL2MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL2MuonCandidates').at(0).hasFilterLabel('hltL2fL1sMu16orMu20erorMu25L1f0L2Filtered0')" + ), + Mu25TkMu0Onia_L3 = cms.string( "!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltL3fL1sMu16orMu20erorMu25L1f0L2f0L3Filtered25')" + ), + Mu25TkMu0Onia_TM = cms.string( "!triggerObjectMatchesByCollection('hltGlbTrkMuonCands').empty()" + #+ " && triggerObjectMatchesByCollection('hltMuTkMuTrackerMuonCandsOnia').at(0).hasFilterLabel('hltDiMuonGlb25Trk0DzFiltered0p2')" + ), + Mu16TkMu0Onia_L2 = cms.string( "!triggerObjectMatchesByCollection('hltL2MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL2MuonCandidates').at(0).hasFilterLabel('hltL2fL1sMu16orMu20erorMu16L1f0L2Filtered0')" + ), + Mu16TkMu0Onia_L3 = cms.string( "!triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL3MuonCandidates').at(0).hasFilterLabel('hltL3fL1sMu16orMu20erorMu16L1f0L2f0L3Filtered16')" + ), + ) LowPtTriggerFlagsEfficiencies = cms.PSet(LowPtTriggerFlagsEfficienciesTag,LowPtTriggerFlagsEfficienciesProbe) + +LowPtTriggerFlagsEfficienciesProbe_L2 = cms.PSet( + ########## Mu + Track ########## + Mu7p5_Track2_Jpsi_TK = cms.string("!triggerObjectMatchesByCollection('hltL2MuonCandidates').empty()" + #+ " && triggerObjectMatchesByCollection('hltL2MuonCandidates').at(0).hasFilterLabel('hltMu7p5Track2JpsiTrackMassFiltered')" + ), + Mu7p5_Track3p5_Jpsi_TK = cms.string("!triggerObjectMatchesByCollection('hltL2MuonCandidates').empty()" + #+ " && triggerObjectMatchesByCollection('hltL2MuonCandidates').at(0).hasFilterLabel('hltMu7p5Track3p5JpsiTrackMassFiltered')" + ), + Mu7p5_Track7_Jpsi_TK = cms.string("!triggerObjectMatchesByCollection('hltL2MuonCandidates').empty()" + #+ " && triggerObjectMatchesByCollection('hltL2MuonCandidates').at(0).hasFilterLabel('hltMu7p5Track7JpsiTrackMassFiltered')" + ), + ########## Mu + L2Mu ########## + Mu7p5_L2Mu2_Jpsi_L2 = cms.string("!triggerObjectMatchesByCollection('hltL2MuonCandidates').empty()" + + " && triggerObjectMatchesByCollection('hltL2MuonCandidates').at(0).hasFilterLabel('hltMu7p5L2Mu2JpsiTrackMassFiltered')" + ), + + ) diff --git a/test/jpsi/createPtRootFiles.C b/test/jpsi/createPtRootFiles.C new file mode 100755 index 00000000000..b18d6dec578 --- /dev/null +++ b/test/jpsi/createPtRootFiles.C @@ -0,0 +1,1001 @@ +//////////////////////////////// +// +//written by Ilse Kraetschmer +//last updated on 19th August 2013 +// +//////////////////////////////// +//change for combination of tracks + +// C/C++ +#include +#include +#include +#include +#include +#include +#include +// Root +#include "TFile.h" +#include "TROOT.h" +#include "TStyle.h" +#include "TH2.h" +#include "TDirectory.h" +#include "TCanvas.h" +#include "TPad.h" +#include "TGraph.h" +#include "TIterator.h" +#include "TObject.h" +#include "TKey.h" +#include "TText.h" +#include "TPaveText.h" +#include "TString.h" +#include "TLatex.h" +#include "TGraphAsymmErrors.h" +#include "TMath.h" + + +// Return opened root file (or 0 on fail) +TFile* open(std::string filename) { + TFile* file = new TFile(filename.c_str()); + if ((!file)||(file->IsZombie())) { + std::cerr <<"File "<(indir->Get(subdir.c_str())); + if (!outdir) { + std::cerr <<"\nDirectory "<SetStyle("Plain"); + gStyle->SetTitleBorderSize(0); + gStyle->SetTitleOffset(1.25,"X") ; + gStyle->SetTitleOffset(1.2,"Y") ; + + // code set up so that MC file is split in different files for abseta bins + //const std::string effName[] = {"Loose2012", "Soft2012", "newSoft2012", "Tight2012", "Dimuon10_L1L2"}; + //TString effName[] = {"Loose2012", "Soft2012", "newSoft2012", "Tight2012", "Dimuon10_L1L2", "Dimuon16_L1L2", "L3_wrt_Dimuon10_L1L2", "L3_wrt_Dimuon16_L1L2", "Dimuon16_Jpsi_wrt_Dimuon6_Jpsi_NoVertexing", "Dimuon10_Jpsi_Barrel_wrt_Dimuon0er16_Jpsi_NoVertexing"}; + const TString effName[] = {"Loose2015", "Medium2015", "Tight2012_zIPCut", "Soft2012", "Dimuon10_L1L2", "Dimuon16_L1L2", "L3_wrt_Dimuon10_L1L2", "L3_wrt_Dimuon16_L1L2", "Dimuon16_Jpsi_wrt_Dimuon6_Jpsi_NoVertexing", "Dimuon10_Jpsi_Barrel_wrt_Dimuon0er16_Jpsi_NoVertexing"}; + const int nEff = sizeof(effName)/sizeof(effName[0]); + vector triggers = {"_Mu7p5_Track2_Jpsi"} ; + vector noTrig = {""} ; + // + vector< pair> > eff_triggers ; + for (uint iEff=0; iEff bins1, bins2; + vector< TString > bins2name; + for (int iEff=3; iEff<=3; ++iEff) { + //for (int iEff=4; iEff<=7; ++iEff) { + //for (int iEff=8; iEff<=9; ++iEff) { + //for (int iEff=0; iEff<=3; ++iEff) { + //for (int iEff=3; iEff<=7; ++iEff) { + cout <<"\nWorking on efficiency \"" < > trackName(nEffSample) ; + for (Int_t iEffSample = 0; iEffSample < nEffSample; iEffSample++) { + if (effName[iEff].Contains("Dimuon6_Jpsi_NoVertexing")) { + //const std::string trackName[nEffSample][1] = { {"Dimuon6_Jpsi_NoVertexing"},{"Dimuon6_Jpsi_NoVertexing"} }; + trackName[iEffSample].push_back("Dimuon6_Jpsi_NoVertexing"); + } else if (effName[iEff].Contains("Dimuon0er16_Jpsi_NoVertexing")) { + //const std::string trackName[nEffSample][1] = { {"Dimuon0er16_Jpsi_NoVertexing"},{"Dimuon0er16_Jpsi_NoVertexing"} }; + trackName[iEffSample].push_back("Dimuon0er16_Jpsi_NoVertexing"); + } else + //if (effName[iEff].Contains("Soft2012")) { + //const std::string trackName[nEffSample][] = {{"Mu5_Track2", "Mu7_Track7"},{"Mu5_Track2", "Mu7_Track7"}}; + //const std::string trackName[nEffSample][] = {{"Mu7p5_Track2", "Mu7p5_Track7"},{"Mu7p5_Track2", "Mu7p5_Track7"}}; + //const std::string trackName[nEffSample][] = {{"Mu8"}}; + //const std::string trackName[nEffSample][] = }{"Mu7p5_Track7"}}; + //const std::string trackName[nEffSample][1] = {{"Mu7p5_Track2"},{"Mu8"}}; + //const std::string trackName[nEffSample][1] = {{"Mu7p5_Track2"},{"Mu7p5_Track2"}}; + trackName[iEffSample].push_back("Mu7p5_Track2"); + } + + //const int nTrack = sizeof(trackName[0])/sizeof(trackName[0][0]); + const int nTrack = trackName[0].size(); + cout <<"\nnTrack = " < 9 GeV - former 7 GeV + Float_t triggerTreshold = 999. ; + if ( trackName[0][nTrack-1] == "Mu7_Track7") + triggerTreshold = 7. ; + + + TString binnedVars = "_pt_abseta" ; + binnedVars = "_pt_abseta2p4" ; + //binnedVars = "_plateau" ; + //binnedVars = "_ptTurnOn" ; + binnedVars = "_pt_abseta_notSeparated" ; + binnedVars = "_pt_abseta" ; binnedVars = "_pt_abseta_seagull" ; //binnedVars = "_pt_abseta_cowboy" ; + binnedVars.Append("_separated") ; + //binnedVars = "_ptPlateau_eta" ; + //binnedVars = "_vtx" ; + if (effName[iEff].Contains("Vertexing")) + binnedVars.ReplaceAll("abseta","absrapidity"); + + TString var1name, var2name; + bins1.clear(); + bins2.clear(); bins2name.clear(); // fill always together! + Int_t abseta = 0; + if (!binnedVars.Contains("lateau") && !binnedVars.Contains("ptTurnOn") && !binnedVars.Contains("vtx")) { + //Declare bins according to efficiency and binnedVars + // pt_abseta + //double bins1[] = {2.0, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 4.5, 5.0, 6.0, 8.0, 10.0, 20.0}; TString var1name = "pT" ; + //double bins1[] = {2.0, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 4.5, 5.0, 6.0, 8.0, 10.0, 15.0, 20.0, 30.0, 40.0}; TString var1name = "pT" ; + //double bins1[] = {2.0, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 4.5, 5.0, 6.0, 8.0, 10.0, 15.0, 20.0}; TString var1name = "pT" ; + //double bins1[] = {2.0, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 4.5, 5.0, 5.5, 6.0, 7.0, 9.0, 11.0, 14.0, 17.0, 20.0}; TString var1name = "pT" ; + //double bins1[] = {10, 20, 25, 30, 35, 40, 50, 60, 90, 140, 300, 500}; TString var1name = "pT" ; + //double bins1[] = {2.0, 2.5, 3.0, 3.5, 4.0, 4.75, 5.5, 7.5, 10.0, 20.0, 40.0}; TString var1name = "pT" ; + if (!effName[iEff].Contains("Vertexing")) { + bins1.push_back(2.0); bins1.push_back(2.5); bins1.push_back(3.0); bins1.push_back(3.5); bins1.push_back(4.0); bins1.push_back(4.75); bins1.push_back(5.5); bins1.push_back(7.5); bins1.push_back(10.0); bins1.push_back(15.0); bins1.push_back(20.0); bins1.push_back(40.0); + } + else { + if (!effName[iEff].Contains("Dimuon16")) + bins1.push_back(10.0); + bins1.push_back(16.0); bins1.push_back(20.0); bins1.push_back(40.0); + } var1name = "pT" ; + + //std::string bins2name[] = {"0to2p4"}; + //TString bins2name[] = {"0to2p5"}; double bins2[] = {0, 2.5}; TString var2name = "abseta" ; // does not matter since we always look at only one abseta bin // ? + //TString bins2name[] = {"0to0p9","0p9to1p2","1p2to2p1","2p1to2p4"}; double bins2[] = {0., 0.9, 1.2, 2.1, 2.4}; + bins2.push_back(0.); + if ( binnedVars.Contains("pt_abseta2p4") ) { + bins2.push_back(2.4); bins2name.push_back("0to2p4"); + } else { + bins2.push_back(0.9); bins2.push_back(1.2); bins2.push_back(1.6); + bins2name.push_back("0to0p9"); bins2name.push_back("0p9to1p2"); bins2name.push_back("1p2to1p6"); + if (!effName[iEff].Contains("Dimuon10")) { + bins2.push_back(2.1); bins2.push_back(2.4); + //bins2name.push_back("1p2to2p1"); + bins2name.push_back("1p6to2p1"); bins2name.push_back("2p1to2p4"); + } + } + var2name = "abseta" ; + if (effName[iEff].Contains("Vertexing")) + var2name.ReplaceAll("abseta","absrapidity"); + abseta = bins2.size() -1; + } + else if (binnedVars.Contains("lateau")) { + bins2.push_back(8.); bins2.push_back(500.); + bins2name.push_back("8to500"); + var2name = "pT" ; + // + //double bins1[] = {0., 0.9, 1.2, 2.1, 2.4}; TString bins1name[] = {"0to0p9","0p9to1p2","1p2to2p1","2p1to2p4"}; + bins1.push_back(-2.4); bins1.push_back(-2.1); bins1.push_back(-1.6); bins1.push_back(-1.2); bins1.push_back(-0.9); bins1.push_back(-0.3); bins1.push_back(-0.2); bins1.push_back(0.2); bins1.push_back(0.3); bins1.push_back(0.9); bins1.push_back(1.2); bins1.push_back(1.6); bins1.push_back(2.1); bins1.push_back(2.4); + var1name = "eta" ; + abseta = bins1.size() -1; + } + // turn-on + //double bins2[] = {3, 5}; TString bins2name[] = {"3to5"}; TString var2name = "pT" ; + else if (binnedVars.Contains("vtx")) { + bins2.push_back(8.); bins2.push_back(500.); + bins2name.push_back("8to500"); + var2name = "pT" ; + // + //for (Int_t i=0; i<=30; i+=2) + for (Int_t i=0; i<=30; i+=3) + bins1.push_back(i+0.5); + var1name = "# PV" ; + abseta = bins1.size() -1; + } + + const int nBins1 = bins1.size() -1; + const int nBins2 = bins2.size() -1; + Bool_t logX = kFALSE; + //if ( var1name.Contains("pT") ) logX = kTRUE; + + //input files + //std::stringstream datafile, mcfile; + TString inputfile[nEffSample] ; + std::string path = "/afs/cern.ch/work/l/lecriste/TnP/recipe_740/CMSSW_7_4_0/src/MuonAnalysis/TagAndProbe/test/jpsi/fitTreeAnalyzer" ; + //datafile <<"/scratch/ikratsch/TnP2012/MuonPOG/official6March2014/changedMass/multiplicity/TnP_MuonID_data_all_" < plot(nBins2) ; + vector< TString > titleX(nBins2), titleY(nBins2) ; + // Jump to next directory + for (int iTrack = 0; iTrack < nTrack; iTrack++) { + + std::stringstream directory; + if ( !binnedVars.Contains("lateau") ) { + if ( trackName[iEffSample][iTrack] != "Mu8" ) { + if ( !inputfile[iEffSample].Contains("Vertexing") ) { + //directory < 1 && nBins2 > 1) + for (Int_t i=0; i<2; ++i) { + TString name2D = x_y[i]; + if (effName[iEff].EqualTo("Loose2015") || effName[iEff].EqualTo("Medium2015") || effName[iEff].EqualTo("Tight2012_zIPCut")) + name2D.Append("_PLOT__pair_drM1_0p5to10_and_pair_probeMultiplicity_0p5to1p5"); + else if (effName[iEff].Contains("Soft2012")) + name2D.Append("_PLOT__pair_drM1_0p5to10_and_pair_probeMultiplicity_0p5to1p5_and_"+ trackName[iEffSample][iTrack] +"_Jpsi_TK_pass_and_tag_"+ trackName[iEffSample][iTrack] +"_Jpsi_MU_pass"); + else if ( effName[iEff].EqualTo("Dimuon10_L1L2") ) + name2D.Append("_PLOT__dB_-0p3to0p3_and_dzPV_-20to20_and_pair_drM1_0p5to10_and_pair_probeMultiplicity_0p5to1p5_and_tag_abseta_0to1p6_and_"+ trackName[iEffSample][iTrack] +"_Jpsi_TK_pass_and_TMOST_pass_and_Track_HP_pass_and_tag_"+ trackName[iEffSample][iTrack] +"_Jpsi_MU_pass"); + else if ( effName[iEff].EqualTo("Dimuon16_L1L2") ) { + //name2D.Append("_PLOT__dB_-0p3to0p3_and_dzPV_-20to20_and_pair_drM1_0p5to10_and_pair_probeMultiplicity_0p5to1p5_and_tag_pt_10to1000_and_"+ trackName[iEffSample][iTrack] +"_Jpsi_TK_pass_and_TMOST_pass_and_Track_HP_pass_and_tag_"+ trackName[iEffSample][iTrack] +"_Jpsi_MU_pass"); + name2D.Append("_PLOT__dB_-0p3to0p3_and_dzPV_-20to20_and_pair_drM1_0p5to10_and_pair_probeMultiplicity_0p5to1p5_and_tag_pt_11to1000_and_"+ trackName[iEffSample][iTrack] +"_Jpsi_TK_pass_and_TMOST_pass_and_Track_HP_pass_and_tag_"+ trackName[iEffSample][iTrack] +"_Jpsi_MU_pass"); + } else if ( effName[iEff].EqualTo("L3_wrt_Dimuon10_L1L2") ) + name2D.Append("_PLOT__dB_-0p3to0p3_and_dzPV_-20to20_and_pair_drM1_0p5to10_and_pair_probeMultiplicity_0p5to1p5_and_Dimuon10_L1L2_pass_and_TMOST_pass_and_Track_HP_pass_and_tag_Mu7p5_L2Mu2_Jpsi_MU_pass"); + else if ( effName[iEff].EqualTo("L3_wrt_Dimuon16_L1L2") ) { + //name2D.Append("_PLOT__dB_-0p3to0p3_and_dzPV_-20to20_and_pair_drM1_0p5to10_and_pair_probeMultiplicity_0p5to1p5_and_tag_pt_10to1000_and_Dimuon16_L1L2_pass_and_TMOST_pass_and_Track_HP_pass_and_tag_Mu7p5_L2Mu2_Jpsi_MU_pass"); + name2D.Append("_PLOT__dB_-0p3to0p3_and_dzPV_-20to20_and_pair_drM1_0p5to10_and_pair_probeMultiplicity_0p5to1p5_and_tag_pt_11to1000_and_Dimuon16_L1L2_pass_and_TMOST_pass_and_Track_HP_pass_and_tag_Mu7p5_L2Mu2_Jpsi_MU_pass"); + } else if ( effName[iEff].Contains("NoVertexing") ) + name2D.Append("_PLOT__pair_probeMultiplicity_0p5to1p5_and_"+ trackName[iEffSample][iTrack] +"_pass_and_tag_"+ trackName[iEffSample][iTrack] +"_pass"); + + if ( binnedVars.Contains("notSeparated") ) + name2D.ReplaceAll("pair_drM1_0p5to10_and_","") ; + + TCanvas* c2D = dynamic_cast (dir_fit_eff->Get( name2D )); + if (!c2D) cout <<"No " <GetName() <<"\" dir in " < (c2D->FindObject( c2D->GetName() )); + if (!myTH2[i]) cout <<"No " <GetName() <<" in TCanvas " <SetTitle( c2D->GetName() ); + myTH2[i]->SetName( TString(effSampleName[iEffSample]+"__"+x_y[i]) ); } + } + } + + // 1D + for(int iBins2 = 0; iBins2 < nBins2; iBins2++) { + + cout <<"\n" < 2 ) { + if ( trackName[iEffSample][iTrack] != "Mu8" ) { + if (eff_triggers[iEff].first.Contains("L3")) + inter <<"pt_PLOT__abseta_" < (dir_fit_eff->Get( plot[iBins2].c_str() )); + if (!c) { + cout <<"No \"" < (c->FindObject("hxy_fit_eff")) ; + titleX[iBins2] = tGraph->GetXaxis()->GetTitle() ; + titleY[iBins2] = tGraph->GetYaxis()->GetTitle() ; + //check if there are values in PLOT + int N = tGraph->GetN(); + if (N == 0) { + cout <<"No values in " < N) { + cout <<"nBins1+1 (= " < #points in the TGraph (=" <GetPoint(iPoint, x, y); + double err_high = tGraph->GetErrorYhigh(iPoint), err_low = tGraph->GetErrorYlow(iPoint); + double var_high = tGraph->GetErrorXhigh(iPoint), var_low = tGraph->GetErrorXlow(iPoint); + //if(err_high > 0.05) {err_high = err_low; cout <<"changed high error" < 0.05) {err_low = err_high; cout <<"changed low error" < 0.05) {err_high = err_low; cout <<"changed MC high error" < 1) err_high = 1 - y; + + //store values + for (int s = 0; s < nBins1; s++) { + cout <<"\nx_" <SetName(name); + graph->SetTitle(plot[iBins2].c_str()); + int points = 0; + + for(int iBins1 = 0; iBins1 < nBins1; iBins1++) { + // fill TGraphsAsymmErrors + // fill with Mu5_Track2 for pt < 9 GeV - former 7 GeV + //if (!isZero(values[iEffSample][0][iBins1][iBins2].eff)) { + if ( !binnedVars.Contains("lateau") && !binnedVars.Contains("ptTurnOn") && !binnedVars.Contains("vtx") ) { + if ( bins1[iBins1] < triggerTreshold && !isZero(values[iEffSample][0][iBins1][iBins2].eff)) { + + //if ((abseta == 0 && bins1[iBins1] >= 3.5) || (abseta == 1 && bins1[iBins1] >= 2.5) || (abseta == 2 && bins1[iBins1] >= 2.0)) { + if ((abseta == 0 && bins1[iBins1] >= 3.5) || (abseta == 1 && bins1[iBins1] >= 2.5) || (abseta >= 2 && bins1[iBins1] >= 2.0)) { + // only tight + //if((abseta == 0 && bins1[iBins1] >= 3.5) || (abseta == 1 && bins1[iBins1] >= 3.0) || (abseta == 2 && bins1[iBins1] >= 2.0)){ + graph->SetPoint(points, values[iEffSample][0][iBins1][iBins2].var, values[iEffSample][0][iBins1][iBins2].eff); + graph->SetPointError(points, + values[iEffSample][0][iBins1][iBins2].var_low, values[iEffSample][0][iBins1][iBins2].var_high, + values[iEffSample][0][iBins1][iBins2].eff_low, values[iEffSample][0][iBins1][iBins2].eff_high); + cout <GetXaxis()->SetTitle( titleX[iBins2] ) ; + graph->GetYaxis()->SetTitle( titleY[iBins2] ) ; + output->cd(); + graph->Write(); + + } // iBins2 + for (Int_t i=0; i<2; ++i) + if (myTH2[i]) + myTH2[i]->Write(); + } // iEffSample + //output->Close() ; + + TPaveText *lumi = new TPaveText(.6, .902, .9, .95, "NDC"); + lumi->SetTextSize(0.04); lumi->SetFillColor(0); lumi->SetLineColor(0); lumi->SetBorderSize(1); + if (!mode[1].Contains("25ns")) + lumi->AddText("BX = 50 ns, L = 47 pb^{-1}"); + else + lumi->AddText("BX = 25 ns, L = 2.26 fb^{-1}"); + + TString prefix = "../" ; + prefix = "/afs/cern.ch/work/l/lecriste/www/TnP/" ; + Bool_t web = kFALSE; + if ( prefix.EqualTo("/afs/cern.ch/work/l/lecriste/www/TnP/") ) + web = kTRUE; + TString uploadFile = "index.php" ; + + + TFile *data_yield_file = TFile::Open("../TnP_yield_Charmonium_PromptReco_50ns_first47ipb.root") ; + if (mode[1].Contains("25ns")) + data_yield_file = 0; // use the 25ns yields file when available + + // + // ratio: DATA/MC + if ( nEffSample > 1 ) { + + TGraphAsymmErrors *overlay[nEffSample] ; + TCanvas *overlayC = new TCanvas("overlayC","overlay Canvas",800,800) ; + TPad* overlayPad = new TPad("overlayPad", "overlay Pad", .005, .25, .995, .995); + TPad* ratioPad = new TPad("ratioPad", "ratio Pad", .005, .005, .995, .995-.75); + overlayPad->Draw(); ratioPad->Draw(); + + Int_t dataIdx = 1, noDataIdx = 0; + for (int iEffSample = 0; iEffSample < nEffSample; iEffSample++) + if ( effSampleName[iEffSample] == "DATA" ) { + dataIdx = iEffSample ; + noDataIdx = nEffSample-1-dataIdx ; + } + + //TString dir = prefix+"plots/mc/tpTree/"+eff_triggers[iEff].first+"/" ; + TString dir = prefix+"plots/mc/50ns/tpTree/"+eff_triggers[iEff].first+"/" ; + if (mode[1].Contains("25ns")) + dir.ReplaceAll("50ns","25ns") ; + if ( inputfile[0].Contains("30M") || inputfile[1].Contains("30M")) + dir.ReplaceAll("/tpTree","/30M/tpTree") ; + if ( effName[iEff].Contains("Vertexing") ) + dir.ReplaceAll("tpTree","tpTreeOnePair") ; + dir.ReplaceAll("/_","/") ; + + gSystem->mkdir(dir, true); + if ( web ) + gSystem->CopyFile(prefix+uploadFile, dir+uploadFile, true); + + dir.Append( binnedVars+"/" ); dir.ReplaceAll("/_","/") ; + gSystem->mkdir(dir, true); + if ( web ) + gSystem->CopyFile(prefix+uploadFile, dir+uploadFile, true); + + dir.Append( eff_triggers[iEff].second[0]+"/" ); dir.ReplaceAll("/_","/") ; + gSystem->mkdir(dir, true); + if ( web ) + gSystem->CopyFile(prefix+uploadFile, dir+uploadFile, true); + + dir.Append( "overlay/" ); // first + gSystem->mkdir(dir, true); + if ( web ) + gSystem->CopyFile(prefix+uploadFile, dir+uploadFile, true); + + if ( dir.Contains("overlay") ) { // second + dir.ReplaceAll("overlay/", "ratio/"); + gSystem->mkdir(dir, true); + if ( web ) + gSystem->CopyFile(prefix+uploadFile, dir+uploadFile, true); + } + + dir.Append( effSampleName[nEffSample-1]+"/" ); + gSystem->mkdir(dir, true); + if ( web ) + gSystem->CopyFile(prefix+uploadFile, dir+uploadFile, true); + + if ( dir.Contains("ratio") ) { // third + dir.ReplaceAll("ratio/", "overlay/"); + gSystem->mkdir(dir, true); + if ( web ) + gSystem->CopyFile(prefix+uploadFile, dir+uploadFile, true); + } + + + for (int iBins2 = 0; iBins2 < nBins2; iBins2++) { + // overlay + cout <<"\nGoing to overlay:" <cd(); + overlay[0] = (TGraphAsymmErrors*)output->Get(effSampleName[0]+"__"+var2name+"_"+bins2name[iBins2]) ; + overlay[nEffSample-1] = (TGraphAsymmErrors*)output->Get(effSampleName[1]+"__"+var2name+"_"+bins2name[iBins2]) ; + if ( overlay[0] ) { + overlayPad->cd(); + overlay[0]->Draw("AP") ; + overlay[0]->SetMaximum( 1.1 ) ; + if (!effName[iEff].EqualTo("Loose2015") && !effName[iEff].EqualTo("Soft2012") && !effName[iEff].EqualTo("Medium2015") && !effName[iEff].EqualTo("Tight2012_zIPCut")) + overlay[0]->SetMinimum( 0. ) ; + else + if (!binnedVars.Contains("vtx") && !binnedVars.Contains("ptPlateau")) { + overlay[0]->SetMinimum( 0.79 ) ; // from Gael's plots: https://indico.cern.ch/event/461572/contribution/0/attachments/1186546/1720473/muonTnP1280.pdf + if (binnedVars.Contains("pt_abseta")) overlay[0]->SetMinimum( 0. ) ; + } else { + overlay[0]->SetMinimum( 0.49 ) ; // from Ilse's plots: https://indico.cern.ch/event/316122/contribution/3/attachments/607097/835440/muonEfficiencies2012_Jpsi_14April2014.pdf + overlay[0]->SetMaximum( 1.3 ) ; // from Ilse's plots: https://indico.cern.ch/event/316122/contribution/3/attachments/607097/835440/muonEfficiencies2012_Jpsi_14April2014.pdf + } + } else cout <<"\nNo " <Draw("Psame") ; + } else cout <<"\nNo " <SetTitle( effSampleName[i]+"__"+var2name+"_"+bins2name[iBins2] ); + overlay[i]->SetMarkerColor(sampleMarker[i][0]) ; overlay[i]->SetLineColor(sampleMarker[i][0]) ; overlay[i]->SetFillColor(0) ; + overlay[i]->SetMarkerStyle(sampleMarker[i][1]) ; overlay[i]->SetLineStyle(sampleMarker[i][1]) ; + if ( logX ) + overlay[i]->GetXaxis()->SetMoreLogLabels(); + overlay[i]->GetXaxis()->SetRangeUser(bins1[0],bins1[nBins1]); + if (binnedVars.Contains("ptPlateau_eta")) + overlay[i]->GetXaxis()->SetRangeUser(-2.1,2.1); + } + + + // Ratio + TGraph *data_yield = 0 ; + if (data_yield_file) { + data_yield = (TGraph*)data_yield_file->Get("pT_yields_Mu7p5_Track2__abseta"+bins2name[iBins2]) ; + if (data_yield == 0) + cout <<"No \"" <<"pT_yields_Mu7p5_Track2__abseta"+bins2name[iBins2] <<"\" TGraph found in file \"" <GetName() <<"\"" <SetTitle("Ratio "+effSampleName[dataIdx]+"/"+effSampleName[noDataIdx]+" for |#eta(#mu)| from"+bins2name[iBins2]+";muon p_{T} [GeV];"+effSampleName[dataIdx]+"/"+effSampleName[noDataIdx]); + else + ratio->SetTitle("Ratio "+effSampleName[dataIdx]+"/"+effSampleName[noDataIdx]+" for |y(#mu#mu)| from"+bins2name[iBins2]+";dimuon p_{T} [GeV];"+effSampleName[dataIdx]+"/"+effSampleName[noDataIdx]); + else if ( var1name.Contains("eta") ) + ratio->SetTitle("Ratio "+effSampleName[dataIdx]+"/"+effSampleName[noDataIdx]+" for |p_{T}(#mu)| from"+bins2name[iBins2]+";muon #eta;"+effSampleName[dataIdx]+"/"+effSampleName[noDataIdx]); + else if (binnedVars.Contains("vtx")) + ratio->SetTitle("Ratio "+effSampleName[dataIdx]+"/"+effSampleName[noDataIdx]+" for |p_{T}(#mu)| from"+bins2name[iBins2]+";"+var1name+";"+effSampleName[dataIdx]+"/"+effSampleName[noDataIdx]); + TCanvas* ratioC = 0; TCanvas* ratioFitC = 0 ; + // + TGraphAsymmErrors *diff = new TGraphAsymmErrors(); + if ( logX ) + diff->SetTitle("Difference "+effSampleName[dataIdx]+" - "+effSampleName[noDataIdx]+" for |#eta(#mu)| from"+bins2name[iBins2]+";muon p_{T} [GeV];"+effSampleName[dataIdx]+" - "+effSampleName[noDataIdx]); + else if ( var1name.Contains("eta") ) + diff->SetTitle("Difference "+effSampleName[dataIdx]+" - "+effSampleName[noDataIdx]+" for |p_{T}(#mu)| from"+bins2name[iBins2]+";muon #eta;"+effSampleName[dataIdx]+" - "+effSampleName[noDataIdx]); + else if (binnedVars.Contains("vtx")) + diff->SetTitle("Difference "+effSampleName[dataIdx]+" - "+effSampleName[noDataIdx]+" for |p_{T}(#mu)| from"+bins2name[iBins2]+";"+var1name+";"+effSampleName[dataIdx]+" - "+effSampleName[noDataIdx]); + TCanvas* diffC = 0 ; + + int pointsRatio = 0, pointsDiff = 0; + vector > eff_ratio(nBins1), eff_diff(nBins1) ; + eff_ratio.resize(nBins1) ; eff_diff.resize(nBins1) ; + for (int iBins1 = 0; iBins1 < nBins1; iBins1++) { + // compute ratio and diff + eff_ratio[iBins1].resize(4,0) ; eff_diff[iBins1].resize(4,1) ; + + if ( binnedVars.Contains("lateau") || binnedVars.Contains("ptTurnOn") || binnedVars.Contains("vtx") ) { + // RATIO + eff_ratio[iBins1][1] = values[dataIdx][0][iBins1][iBins2].eff / values[noDataIdx][0][iBins1][iBins2].eff; + eff_ratio[iBins1][2] = eff_ratio[iBins1][1] * + TMath::Sqrt(TMath::Power(values[dataIdx][0][iBins1][iBins2].eff_low/values[dataIdx][0][iBins1][iBins2].eff,2) + + TMath::Power(values[noDataIdx][0][iBins1][iBins2].eff_low/values[noDataIdx][0][iBins1][iBins2].eff,2)); + eff_ratio[iBins1][3] = eff_ratio[iBins1][1] * + TMath::Sqrt(TMath::Power(values[dataIdx][0][iBins1][iBins2].eff_high/values[dataIdx][0][iBins1][iBins2].eff,2) + + TMath::Power(values[noDataIdx][0][iBins1][iBins2].eff_high/values[noDataIdx][0][iBins1][iBins2].eff,2)); + // DIFF + eff_diff[iBins1][1] = values[dataIdx][0][iBins1][iBins2].eff - values[noDataIdx][0][iBins1][iBins2].eff; + eff_diff[iBins1][2] = + TMath::Sqrt(TMath::Power(values[dataIdx][0][iBins1][iBins2].eff_low,2) + + TMath::Power(values[noDataIdx][0][iBins1][iBins2].eff_low,2)); + eff_diff[iBins1][3] = + TMath::Sqrt(TMath::Power(values[dataIdx][0][iBins1][iBins2].eff_high,2) + + TMath::Power(values[noDataIdx][0][iBins1][iBins2].eff_high,2)); + // MEAN + eff_ratio[iBins1][0] = (values[dataIdx][0][iBins1][iBins2].var + values[noDataIdx][0][iBins1][iBins2].var)/2; + eff_diff[iBins1][0] = (values[dataIdx][0][iBins1][iBins2].var + values[noDataIdx][0][iBins1][iBins2].var)/2; + } + else if (bins1[iBins1] < triggerTreshold && !isZero(values[noDataIdx][0][iBins1][iBins2].eff)) { // 7 GeV + //if ((abseta == 0 && bins1[iBins1] >= 3.5) || (abseta == 1 && bins1[iBins1] >= 2.5) || (abseta == 2 && bins1[iBins1] >= 2.0)) { + if ((abseta == 0 && bins1[iBins1] >= 3.5) || (abseta == 1 && bins1[iBins1] >= 2.5) || (abseta >= 2 && bins1[iBins1] >= 2.0)) { + // only tight + //if((abseta == 0 && bins1[iBins1] >= 3.5) || (abseta == 1 && bins1[iBins1] >= 3.0) || (abseta == 2 && bins1[iBins1] >= 2.0)) { + // RATIO + eff_ratio[iBins1][1] = values[dataIdx][0][iBins1][iBins2].eff / values[noDataIdx][0][iBins1][iBins2].eff; + eff_ratio[iBins1][2] = eff_ratio[iBins1][1] * + TMath::Sqrt(TMath::Power(values[dataIdx][0][iBins1][iBins2].eff_low/values[dataIdx][0][iBins1][iBins2].eff,2) + + TMath::Power(values[noDataIdx][0][iBins1][iBins2].eff_low/values[noDataIdx][0][iBins1][iBins2].eff,2)); + eff_ratio[iBins1][3] = eff_ratio[iBins1][1] * + TMath::Sqrt(TMath::Power(values[dataIdx][0][iBins1][iBins2].eff_high/values[dataIdx][0][iBins1][iBins2].eff,2) + + TMath::Power(values[noDataIdx][0][iBins1][iBins2].eff_high/values[noDataIdx][0][iBins1][iBins2].eff,2)); + // DIFF + eff_diff[iBins1][1] = values[dataIdx][0][iBins1][iBins2].eff - values[noDataIdx][0][iBins1][iBins2].eff; + eff_diff[iBins1][2] = + TMath::Sqrt(TMath::Power(values[dataIdx][0][iBins1][iBins2].eff_low,2) + + TMath::Power(values[noDataIdx][0][iBins1][iBins2].eff_low,2)); + eff_diff[iBins1][3] = + TMath::Sqrt(TMath::Power(values[dataIdx][0][iBins1][iBins2].eff_high,2) + + TMath::Power(values[noDataIdx][0][iBins1][iBins2].eff_high,2)); + // MEAN + eff_ratio[iBins1][0] = (values[dataIdx][0][iBins1][iBins2].var + values[noDataIdx][0][iBins1][iBins2].var)/2; + eff_diff[iBins1][0] = (values[dataIdx][0][iBins1][iBins2].var + values[noDataIdx][0][iBins1][iBins2].var)/2; + // + // } + } + } + else if (bins1[iBins1] >= triggerTreshold && !isZero(values[noDataIdx][1][iBins1][iBins2].eff)) { // 7 GeV + // RATIO + eff_ratio[iBins1][1] = values[dataIdx][1][iBins1][iBins2].eff / values[noDataIdx][1][iBins1][iBins2].eff; + eff_ratio[iBins1][2] = eff_ratio[iBins1][1] * + TMath::Sqrt(TMath::Power(values[dataIdx][1][iBins1][iBins2].eff_low/values[dataIdx][1][iBins1][iBins2].eff,2) + + TMath::Power(values[noDataIdx][1][iBins1][iBins2].eff_low/values[noDataIdx][1][iBins1][iBins2].eff,2)); + eff_ratio[iBins1][3] = eff_ratio[iBins1][1] * + TMath::Sqrt(TMath::Power(values[dataIdx][1][iBins1][iBins2].eff_high/values[dataIdx][1][iBins1][iBins2].eff,2) + + TMath::Power(values[noDataIdx][1][iBins1][iBins2].eff_high/values[noDataIdx][1][iBins1][iBins2].eff,2)); + // DIFF + eff_diff[iBins1][1] = values[dataIdx][1][iBins1][iBins2].eff - values[noDataIdx][1][iBins1][iBins2].eff; + eff_diff[iBins1][2] = + TMath::Sqrt(TMath::Power(values[dataIdx][1][iBins1][iBins2].eff_low,2) + + TMath::Power(values[noDataIdx][1][iBins1][iBins2].eff_low,2)); + eff_diff[iBins1][3] = + TMath::Sqrt(TMath::Power(values[dataIdx][1][iBins1][iBins2].eff_high,2) + + TMath::Power(values[noDataIdx][1][iBins1][iBins2].eff_high,2)); + // MEAN + eff_ratio[iBins1][0] = (values[dataIdx][1][iBins1][iBins2].var + values[noDataIdx][1][iBins1][iBins2].var)/2; + eff_diff[iBins1][0] = (values[dataIdx][1][iBins1][iBins2].var + values[noDataIdx][1][iBins1][iBins2].var)/2; + } + + + double x_high = 0, x_low = 0; + for (int i = 0; i < nBins1; i++) { + if ((bins1[i] <= eff_ratio[iBins1][0]) && (bins1[i+1] >= eff_ratio[iBins1][0])){ + //cout <<"found bin: " <SetPoint(pointsRatio, eff_ratio[iBins1][0], eff_ratio[iBins1][1]); + ratio->SetPointError(pointsRatio, TMath::Abs(x_low), TMath::Abs(x_high), eff_ratio[iBins1][2], eff_ratio[iBins1][3]); + pointsRatio++; + + //cout < nBins1 ? nBins1 : row_bins*(iRow+1)); iBins1++) + cout < nBins1 ? nBins1 : row_bins*(iRow+1)); iBins1++) + cout < nBins1 ? nBins1 : row_bins*(iRow+1)); iBins1++) + cout <SetName( ratioName ) ; diff->SetName( diffName ) ; + output->cd(); + ratio->Write(); diff->Write(); + + Int_t nx = 1, ny = 1 ; + if (data_yield) ny = 2 ; + ratioC = new TCanvas(ratioName,ratioName,nx*800,ny*600) ; ratioC->Divide(nx,ny); + ratioC->cd(1) ; + ratio->SetMarkerStyle(8); diff->SetMarkerStyle(8); + ratio->Draw("ALP") ; + lumi->Draw(); + if (effSampleName[nEffSample-1] != "MC_Mu8") { + ratio->SetMinimum( 0.5 ) ; //0.6 + ratio->SetMaximum( 1.5 ) ; //1.1 + } else { + ratio->SetMinimum( 0.85 ) ; + ratio->SetMaximum( 1.15 ) ; + } + if ( logX ) + ratio->GetXaxis()->SetMoreLogLabels(); + ratio->GetXaxis()->SetRangeUser(bins1[0],bins1[nBins1]); + gPad->SetGrid() ; + // + if (!effName[iEff].Contains("Vertexing")) { + if ( logX ) + gPad->SetLogx() ; + if (data_yield) { + ratioC->cd(2) ; + data_yield->Draw("ALP") ; + data_yield->GetXaxis()->SetRangeUser(bins1[0],bins1[nBins1]); + if ( logX ) + gPad->SetLogx() ; + gPad->SetGrid() ; + } + } + //ratioC->SaveAs( TString::Format("../plots/ratio/27oct/"+eff_triggers[iEff].first+"/%s.png", ratioName.Data()) ) ; + // + // DIFF + diffC = new TCanvas(diffName,diffName,nx*800,ny*600) ; diffC->Divide(nx,ny); + diffC->cd(1) ; + diff->Draw("ALP") ; + lumi->Draw(); + diff->SetMinimum( ratio->GetMinimum() - 1 ) ; + diff->SetMaximum( ratio->GetMaximum() - 1 ) ; + if ( logX ) + diff->GetXaxis()->SetMoreLogLabels(); + diff->GetXaxis()->SetRangeUser(bins1[0],bins1[nBins1]); + gPad->SetGrid() ; + if (!effName[iEff].Contains("Vertexing")) { + if ( logX ) + gPad->SetLogx() ; + if (data_yield) { + diffC->cd(2) ; + data_yield->Draw("ALP") ; + data_yield->GetXaxis()->SetRangeUser(bins1[0],bins1[nBins1]); + if ( logX ) + gPad->SetLogx() ; + gPad->SetGrid() ; + } + } + //diffC->SaveAs( TString::Format("../plots/ratio/27oct/"+eff_triggers[iEff].first+"/%s.png", diffName.Data()) ) ; + + dir.ReplaceAll("overlay/", "ratio/"); + ratioC->SaveAs( dir+ratioName+".png") ; + diffC->SaveAs( dir+diffName+".png") ; + + + // fit + gSystem->mkdir(dir+"fit/", true); + if ( web ) + gSystem->CopyFile(prefix+uploadFile, dir+"fit/"+uploadFile, true); + + ratioFitC = new TCanvas(ratioName.Append("_fit"),ratioName,800,600) ; + lumi->Draw(); + ratio->Fit("pol0","0"); + TF1 *myfunc = ratio->GetFunction("pol0"); + ratio->Draw("AP") ; + if (myfunc) { + ratio->GetFunction("pol0")->SetLineColor(kRed); myfunc->Draw("same"); + } else cout <<"No TF1 function with name \"pol0\" found!" <SetOptFit(111); + TPaveStats *st = (TPaveStats*)ratio->GetListOfFunctions()->FindObject("stats"); + if (st) { + st->SetX1NDC(0.5); st->SetX2NDC(0.9); + st->SetY1NDC(0.7); st->SetY2NDC(0.9); } + if ( logX ) + gPad->SetLogx() ; + gPad->SetGrid() ; + ratioFitC->SaveAs( dir+"fit/"+ratioName+".png") ; + + + dir.ReplaceAll("ratio/", "overlay/"); + // PAS style overlay + ratioPad->cd(); + // from Gael's plots: https://indico.cern.ch/event/461572/contribution/0/attachments/1186546/1720473/muonTnP1280.pdf + ratioPad->SetTopMargin(0.); ratio->SetTitle(""); + ratioPad->SetBottomMargin(0.2); + ratio->GetYaxis()->SetTitleSize(0.12); ratio->GetYaxis()->SetTitleOffset(0.4); + ratio->GetXaxis()->SetTitleSize(0.12); ratio->GetXaxis()->SetTitleOffset(0.75); + ratio->GetXaxis()->SetLabelSize(0.1); + ratio->SetMinimum( 1 -0.15 ) ; + ratio->SetMaximum( 1 +0.16 ) ; // in order to make the label not truncated + if ( logX ) + ratioPad->SetLogx(); + ratioPad->SetGrid() ; + gStyle->SetOptFit(0); + ratio->Draw("APZ") ; + if (binnedVars.Contains("ptPlateau_eta")) + ratio->GetXaxis()->SetRangeUser(-2.1,2.1); + TPaveStats *stNo = (TPaveStats*)ratio->GetListOfFunctions()->FindObject("stats"); + if (stNo) stNo->Delete(); + gPad->Modified(); + overlayPad->cd(); + overlayPad->SetBottomMargin(0.005); + gPad->BuildLegend(.5, .12, .88, .32) ; + lumi->Draw(); + if ( logX ) + overlayPad->SetLogx(); + overlayPad->SetGrid() ; + + overlayC->SaveAs( dir+bins2name[iBins2]+".png") ; + + } //iBins2 + + } // nEffSample > 1 + + } // for (int iEff=6; iEff<=7; ++iEff) + +} //void + diff --git a/test/jpsi/fitMuonID_2015.py b/test/jpsi/fitMuonID_2015.py new file mode 100644 index 00000000000..1c41dbd0517 --- /dev/null +++ b/test/jpsi/fitMuonID_2015.py @@ -0,0 +1,687 @@ +import FWCore.ParameterSet.Config as cms + +### USAGE: +### cmsRun fitMuonID.py +### scenarios: +### - data_all (default) +### - signal_mc + +import sys +args = sys.argv[1:] +if (sys.argv[0] == "cmsRun"): args = sys.argv[2:] +scenario = "data_all" +if len(args) > 0: scenario = args[0] +print "Will run scenario ", scenario + +process = cms.Process("TagProbe") + +process.load('Configuration.StandardSequences.Services_cff') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True) ) +process.MessageLogger.cerr.FwkReport.reportEvery = 1000 + +process.source = cms.Source("EmptySource") + +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1) ) + +print "About to define TagProbeFitTreeAnalyzer" + +Template = cms.EDAnalyzer("TagProbeFitTreeAnalyzer", + WeightVariable = cms.string("weight"), + NumCPU = cms.uint32(1), + SaveWorkspace = cms.bool(False), + + Variables = cms.PSet( + mass = cms.vstring("Tag-muon Mass", "2.9", "3.3", "GeV/c^{2}"), #2.8-3.35 + p = cms.vstring("muon p", "0", "1000", "GeV/c"), + pt = cms.vstring("muon p_{T}", "0", "1000", "GeV/c"), + eta = cms.vstring("muon #eta", "-2.5", "2.5", ""), + abseta = cms.vstring("muon |#eta|", "0", "2.5", ""), + tag_pt = cms.vstring("Tag p_{T}", "0", "1000", "GeV/c"), + tag_abseta = cms.vstring("Tag |#eta|", "0", "2.5", ""), + tag_nVertices = cms.vstring("Number of vertices", "0", "999", ""), + tag_nVerticesDA = cms.vstring("Number of vertices", "0", "999", ""), + # + pair_pt = cms.vstring("dimuon p_{T}", "0", "1000", "GeV/c"), + pair_absrapidity = cms.vstring("dimuon |y|", "0", "2.5", ""), + pair_dphiVtxTimesQ = cms.vstring("q1 * (#phi1-#phi2)", "-6", "6", ""), + pair_drM1 = cms.vstring("#Delta R(Station 1)", "-99999", "999999", "rad"), + pair_distM1 = cms.vstring("dist(Station 1)", "-99999", "999999", "cm"), + pair_dz = cms.vstring("dz","-5","5",""), + pair_probeMultiplicity = cms.vstring("multiplicity","0","99",""), + dB = cms.vstring("dB", "-1000", "1000", ""), + dzPV = cms.vstring("dzPV", "-1000", "1000", ""), + dxyBS = cms.vstring("dxyBS", "-1000", "1000", ""), + tkValidHits = cms.vstring("track.numberOfValidHits", "-1", "999", ""), + tkTrackerLay = cms.vstring("track.hitPattern.trackerLayersWithMeasurement", "-1", "999", ""), + tkValidPixelHits = cms.vstring("track.hitPattern.numberOfValidPixelHits", "-1", "999", ""), + tkPixelLay = cms.vstring("track.hitPattern.pixelLayersWithMeasurement", "-1", "999", ""), + tkChi2 = cms.vstring("track.normalizedChi2", "-1", "999", ""), + numberOfMatchedStations = cms.vstring("numberOfMatchedStations", "-1", "99", ""), + glbChi2 = cms.vstring("global.normalizedChi2", "-9999", "9999", ""), + glbValidMuHits = cms.vstring("globalTrack.numberOfValidMuonHits", "-1", "9999", ""), + caloComp = cms.vstring("caloCompatibility","-1","5",""), + # Added for mediumVar + validFraction = cms.vstring("innerTrack.validFraction","-9999","9999",""), + chi2LPosition = cms.vstring("combinedQuality.chi2LocalPosition","-9999","9999",""), + tkKink = cms.vstring("combinedQuality.trkKink","-9999","9999",""), + segmComp = cms.vstring("segmentCompatibility","-1","5",""), + # tracking efficiency + tk_deltaR = cms.vstring("Match #Delta R", "0", "1000", ""), + tk_deltaEta = cms.vstring("Match #Delta #eta", "0", "1000", ""), + tk_deltaR_NoJPsi = cms.vstring("Unmatch #Delta R", "0", "1000", ""), + tk_deltaEta_NoJPsi = cms.vstring("Unmatch #Delta #eta", "0", "1000", ""), + tk_deltaR_NoBestJPsi = cms.vstring("Unmatch #Delta R", "0", "1000", ""), + tk_deltaEta_NoBestJPsi = cms.vstring("Unmatch #Delta #eta", "0", "1000", ""), + # + weight = cms.vstring("weight","0","10","") # There is no problem by defining more variables and categories than are present in the TTree as long as they are not used in the Efficiency calculations. + ), + + Categories = cms.PSet( + TM = cms.vstring("Tracker muon", "dummy[pass=1,fail=0]"), + TMA = cms.vstring("Tracker muon", "dummy[pass=1,fail=0]"), + Glb = cms.vstring("Global", "dummy[pass=1,fail=0]"), + Loose = cms.vstring("Loose", "dummy[pass=1,fail=0]"), + VBTF = cms.vstring("VBTFLike", "dummy[pass=1,fail=0]"), + TMOST = cms.vstring("TMOneStationTight", "dummy[pass=1,fail=0]"), + PF = cms.vstring("PF", "dummy[pass=1,fail=0]"), + Track_HP = cms.vstring("Track_HP", "dummy[pass=1,fail=0]"), + Tight2012 = cms.vstring("Tight Id. Muon", "dummy[pass=1,fail=0]"), + Medium = cms.vstring("Medium Id. Muon", "dummy[pass=1,fail=0]"), + # 2012 triggers + #Mu5_Track2_Jpsi_TK = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + #Mu7_Track7_Jpsi_TK = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + #tag_Mu5_Track2_Jpsi_MU = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + #tag_Mu7_Track7_Jpsi_MU = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + # 2015 triggers + tag_Mu7p5_MU = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + Mu7p5_Track2_Jpsi_TK = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + tag_Mu7p5_Track2_Jpsi_MU = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + Mu7p5_Track3p5_Jpsi_TK = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + tag_Mu7p5_Track3p5_Jpsi_MU = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + Mu7p5_Track7_Jpsi_TK = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + tag_Mu7p5_Track7_Jpsi_MU = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + # + Mu7p5_L2Mu2_Jpsi_L2 = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + tag_Mu7p5_L2Mu2_Jpsi_MU = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + Mu7p5_L2Mu2_L2 = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + # Onia triggers + Dimuon16_L1L2 = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + Dimuon10_L1L2 = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + # + Mu_L3 = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + # + # vertexing efficiency + Dimuon6_Jpsi_NoVertexing = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + tag_Dimuon6_Jpsi_NoVertexing = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + Dimuon0er16_Jpsi_NoVertexing = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + tag_Dimuon0er16_Jpsi_NoVertexing = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + Dimuon16_Jpsi = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + Dimuon10_Jpsi_Barrel = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + # + mcTrue = cms.vstring("MC true", "dummy[true=1,false=0]"), + # test + DoubleMu17TkMu8_TkMu8leg = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + tag_DoubleMu17TkMu8_TkMu8leg = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + Mu8 = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + tag_Mu8 = cms.vstring("ProbeTrigger_Track0", "dummy[pass=1,fail=0]"), + ), + + Expressions = cms.PSet( + LooseVar = cms.vstring("LooseVar", "PF==1 && (Glb==1 || TM==1) ", "PF", "Glb", "TM"), + Loose2015Var = cms.vstring("Loose2015Var", "PF==1", "PF"), + oldSoftVar = cms.vstring("oldSoftVar", "TMOST ==1 && tkTrackerLay > 5 && tkPixelLay > 1 && tkChi2 < 1.8 && abs(dzPV) < 30 && abs(dB) < 3", "TMOST","tkTrackerLay", "tkPixelLay", "tkChi2", "dzPV", "dB"), + # without chi2 cut + #oldSoftVar = cms.vstring("oldSoftVar", "TMOST ==1 && tkTrackerLay > 5 && tkPixelLay > 1 && abs(dzPV) < 30 && abs(dB) < 3", "TMOST","tkTrackerLay", "tkPixelLay", "dzPV", "dB"), + #changed cuts + #oldSoftVar = cms.vstring("oldSoftVar", "TMOST ==1", "TMOST"), + #oldSoftVar = cms.vstring("oldSoftVar", "TMOST ==1 && abs(dzPV) < 20", "TMOST", "dzPV"), + #oldSoftVar = cms.vstring("oldSoftVar", "TMOST ==1 && abs(dzPV) < 20 && abs(dB) < 0.3", "TMOST", "dzPV", "dB"), + #oldSoftVar = cms.vstring("oldSoftVar", "TMOST ==1 && abs(dzPV) < 20 && abs(dB) < 0.3 && tkPixelLay > 0", "TMOST", "dzPV", "dB", "tkPixelLay"), + #oldSoftVar = cms.vstring("oldSoftVar", "TMOST ==1 && abs(dzPV) < 20 && abs(dB) < 0.3 && tkPixelLay > 0 && tkTrackerLay > 5", "TMOST", "dzPV", "dB", "tkPixelLay", "tkTrackerLay"), + #MediumVar = cms.vstring("MediumVar", "Loose==1 && validFraction > 0.8 && ((Glb==1 && glbChi2 < 3 && chi2LPosition < 12 && tkKink < 20 && segmComp > 0.303) || segmComp> 0.451)", "Loose", "validFraction", "Glb", "glbChi2", "chi2LPosition", "tkKink", "segmComp"), # already defined in the tree + MediumVar = cms.vstring("MediumVar", "Medium==1", "Medium"), + TightVar = cms.vstring("TightVar", "PF==1 && Glb==1 && tkChi2 < 10 && glbValidMuHits > 0 && numberOfMatchedStations > 1 && abs(dB) < 0.2 && abs(dzPV) < 0.5 && tkValidPixelHits > 0 && tkTrackerLay > 5", "PF", "Glb", "tkChi2", "glbValidMuHits", "numberOfMatchedStations", "dB", "dzPV", "tkValidPixelHits", "tkTrackerLay" ), + Tight2012_zIPCutVar = cms.vstring("Tight2012_zIPCut", "Tight2012 == 1 && abs(dzPV) < 0.5", "Tight2012", "dzPV"), + # new SoftMuon ID 2012 + SoftVar = cms.vstring("SoftVar", "TMOST == 1 && tkTrackerLay > 5 && tkPixelLay > 0 && abs(dzPV) < 20 && abs(dB) < 0.3 && Track_HP == 1", "TMOST","tkTrackerLay", "tkPixelLay", "dzPV", "dB", "Track_HP"), + ), + + Cuts = cms.PSet( + Loose2012 = cms.vstring("Loose", "LooseVar", "0.5"), + Loose2015 = cms.vstring("Loose2015", "Loose2015Var", "0.5"), + Medium2015 = cms.vstring("Medium2015", "MediumVar", "0.5"), + Tight2012 = cms.vstring("Tight", "TightVar", "0.5"), + Tight2012_zIPCut = cms.vstring("Tight2012_zIPCut", "Tight2012_zIPCutVar", "0.5"), + oldSoft2012 = cms.vstring("oldSoft", "oldSoftVar", "0.5"), + Soft2012 = cms.vstring("Soft", "SoftVar", "0.5"), + ), + + PDFs = cms.PSet( + signalPlusBkg = cms.vstring( + "CBShape::signal(mass, mean[3.1,3.0,3.2], sigma[0.05,0.02,0.06], alpha[3., 0.5, 5.], n[1, 0.1, 100.])", + #"Chebychev::backgroundPass(mass, {cPass[0,-0.5,0.5], cPass2[0,-0.5,0.5]})", + #"Chebychev::backgroundFail(mass, {cFail[0,-0.5,0.5], cFail2[0,-0.5,0.5]})", + #"Gaussian::signal(mass, mean[3.1,3.0,3.2], sigma[0.05,0.02,0.1])", + "Exponential::backgroundPass(mass, lp[0,-5,5])", + "Exponential::backgroundFail(mass, lf[0,-5,5])", + "efficiency[0.9,0,1]", + "signalFractionInPassing[0.9]" + ) + ), + + binnedFit = cms.bool(True), + binsForFit = cms.uint32(40), + + Efficiencies = cms.PSet(), # will be filled later +) + +print "TagProbeFitTreeAnalyzer defined!" + +# pick muons that bend apart from each other +SEPARATED = cms.PSet(pair_drM1 = cms.vdouble(0.5,10), + pair_probeMultiplicity = cms.vdouble(0.5,1.5), + #pair_dz = cms.vdouble(-0.1,0.1), + #caloComp = cms.vdouble(0.5,5), + ) +SEPARATED_allPairs = cms.PSet(pair_drM1 = cms.vdouble(0.5,10), + #pair_dz = cms.vdouble(-0.1,0.1), + #caloComp = cms.vdouble(0.5,5), + ) +NOTSEPARATED = cms.PSet(#pair_drM1 = cms.vdouble(0.5,10), + pair_probeMultiplicity = cms.vdouble(0.5,1.5), + #pair_dz = cms.vdouble(-0.1,0.1), + #caloComp = cms.vdouble(0.5,5), + ) +NOTSEPARATED_allPairs = cms.PSet(#pair_drM1 = cms.vdouble(0.5,10), + #pair_probeMultiplicity = cms.vdouble(0.5,1.5), + #pair_dz = cms.vdouble(-0.1,0.1), + #caloComp = cms.vdouble(0.5,5), + ) +# pair_distM1 = cms.vdouble(200,1000)) +#SEPARATED = cms.PSet(pair_dphiVtxTimesQ = cms.vdouble(-3.14,0), #seagulls +# pair_drM1 = cms.vdouble(0.5,10), +# pair_distM1 = cms.vdouble(200,1000)) +#SEPARATED = cms.PSet(pair_dphiVtxTimesQ = cms.vdouble(0,3.14),) #cowboys +# pair_drM1 = cms.vdouble(0.5,10), +# pair_distM1 = cms.vdouble(200,1000)) +# +# defined by Leo +SEAGULL = cms.PSet(pair_dphiVtxTimesQ = cms.vdouble(-3.14,0), #seagull (~= pair_drM1>0.5) + ) +COWBOY = cms.PSet(pair_dphiVtxTimesQ = cms.vdouble(0,3.14), #cowboy (~= pair_drM1<0.5) + ) + +pT_binning_2012 = cms.vdouble(2.0, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 4.5, 5.0, 6.0, 8.0, 10.0, 15.0, 20.0) # 2012 +pT_binning_2015 = cms.vdouble(2.0, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 4.5, 5.0, 6.0, 8.0, 10.0, 15.0, 20.0, 30.0, 40.0) +pT_binning_47ipb = cms.vdouble(2.0, 2.5, 3.0, 3.5, 4.0, 4.75, 5.5, 7.5, 10.0, 20.0, 40.0) +pT_binning_25ns = cms.vdouble(2.0, 2.5, 3.0, 3.5, 4.0, 4.75, 5.5, 7.5, 10.0, 15.0, 20.0, 40.0) + +abseta_binning_47ipb = cms.vdouble(0.0,0.9,1.2,2.1,2.4) +abseta_binning_25ns = cms.vdouble(0.0,0.9,1.2,1.6,2.1,2.4) + +PT_ETA_BINS = cms.PSet( SEPARATED, + #pt = pT_binning_2012, + #pt = pT_binning_2015, + pt = pT_binning_47ipb, + eta = cms.vdouble(-2.4,-2.1,-1.2,-0.9,0.0,0.9,1.2,2.1,2.4) + ) + +PT_ABSETA_BINS = cms.PSet( SEPARATED, + #pt = pT_binning_2012, + #pt = pT_binning_2015, + pt = pT_binning_47ipb, + #abseta = cms.vdouble(0.0,0.9,1.2,2.1) # 2012 + abseta = abseta_binning_47ipb + ) + +PT_ABSETA_BINS = cms.PSet( SEPARATED, + #pt = pT_binning_2012, + #pt = pT_binning_2015, + pt = pT_binning_47ipb, + #abseta = cms.vdouble(0.0,0.9,1.2,2.1) # 2012 + abseta = abseta_binning_47ipb + ) + +PT_ABSETA_BINS_allPairs = cms.PSet( SEPARATED_allPairs, + #pt = pT_binning_2012, + #pt = pT_binning_2015, + #pt = pT_binning_47ipb, + pt = pT_binning_25ns, + #abseta = cms.vdouble(0.0,0.9,1.2,2.1) # 2012 + #abseta = abseta_binning_47ipb, + abseta = abseta_binning_25ns + ) + +PT_ABSETA_BINS_notSeparated = cms.PSet( NOTSEPARATED, + #pt = pT_binning_2012, + #pt = pT_binning_2015, + pt = pT_binning_47ipb, + #abseta = cms.vdouble(0.0,0.9,1.2,2.1) # 2012 + abseta = abseta_binning_47ipb + ) + +PT_BINS_notSeparated = cms.PSet( NOTSEPARATED, + #pt = pT_binning_2012, + #pt = pT_binning_2015, + pt = pT_binning_47ipb, + #abseta = cms.vdouble(0.0,0.9,1.2,2.1) # 2012 + abseta = cms.vdouble(0.0,2.4) + ) + +PT_BINS_ABSETA2p4 = cms.PSet( SEPARATED, + #pt = pT_binning_2012, + #pt = pT_binning_2015, + pt = pT_binning_47ipb, + #abseta = cms.vdouble(0.0,0.9,1.2,2.1) # 2012 + abseta = cms.vdouble(0.0,2.4) + ) + +PT_ABSY_BINS_notSeparated_pair = cms.PSet( NOTSEPARATED, + #pt = pT_binning_2012, + #pt = pT_binning_2015, + #pair_pt = cms.vdouble(10.0, 16.0, 20.0, 40.0), + pair_pt = cms.vdouble(10.0, 13.0, 16.0, 18.0, 20.0, 30.0, 40.0), + #abseta = cms.vdouble(0.0,0.9,1.2,2.1) # 2012 + pair_absrapidity = abseta_binning_47ipb + ) + +PT_ABSETA_BINS_notSeparated_allPairs = cms.PSet( NOTSEPARATED_allPairs, + #pt = pT_binning_2012, + #pt = pT_binning_2015, + pt = pT_binning_47ipb, + #abseta = cms.vdouble(0.0,0.9,1.2,2.1) # 2012 + abseta = abseta_binning_47ipb + ) + +PT_ABSETA_BINS_SEAGULL = cms.PSet( SEAGULL, + #pt = pT_binning_2012, + #pt = pT_binning_2015, + pt = pT_binning_47ipb, + #abseta = cms.vdouble(0.0,0.9,1.2,2.1) # 2012 + abseta = abseta_binning_47ipb + ) + +PT_ABSETA_BINS_SEAGULL_separated = cms.PSet( SEAGULL, + SEPARATED_allPairs, + #pt = pT_binning_2012, + #pt = pT_binning_2015, + #pt = pT_binning_47ipb, + pt = pT_binning_25ns, + #abseta = cms.vdouble(0.0,0.9,1.2,2.1) # 2012 + #abseta = abseta_binning_47ipb + abseta = abseta_binning_25ns + ) + +PT_ABSETA_BINS_COWBOY = cms.PSet( COWBOY, + #pt = pT_binning_2012, + #pt = pT_binning_2015, + pt = pT_binning_47ipb, + #abseta = cms.vdouble(0.0,0.9,1.2,2.1) # 2012 + abseta = abseta_binning_47ipb + ) + +PT_ABSETA_BINS_COWBOY_separated = cms.PSet( COWBOY, + SEPARATED_allPairs, + #pt = pT_binning_2012, + #pt = pT_binning_2015, + #pt = pT_binning_47ipb, + pt = pT_binning_25ns, + #abseta = cms.vdouble(0.0,0.9,1.2,2.1) # 2012 + #abseta = abseta_binning_47ipb + anseta = abseta_binning_25ns + ) + +PT_BINS = cms.PSet( SEPARATED, + #pt = pT_binning_2012 + #pt = pT_binning_2015, + pt = pT_binning_47ipb + ) # check abseta var limits + +VTX_BINS = cms.PSet( SEPARATED, + abseta = cms.vdouble(0.0, 2.1), + pt = cms.vdouble(8.0, 20.0), + tag_nVertices = cms.vdouble(0.5,2.5,4.5,6.5,8.5,10.5,12.5,14.5,16.5,18.5,20.5,22.5,24.5,26.5,28.5,30.5) + #tag_nVerticesDA = cms.vdouble(0.5,2.5,4.5,6.5,8.5,10.5,12.5,14.5,16.5,18.5,20.5,22.5,24.5,26.5,28.5,30.5) + ) + +VTX_BINS_noSoft = cms.PSet( SEPARATED, + abseta = cms.vdouble(0.0, 2.4), + pt = cms.vdouble(8.0, 500.0), + tag_nVertices = cms.vdouble(0.5,3.5,6.5,9.5,12.5,15.5,18.5,21.5,24.5,27.5,30.5), + ) + +ETA_BINS = cms.PSet( SEPARATED, + pt = cms.vdouble(8.0, 20.0), + eta = cms.vdouble(-2.1,-1.6,-1.2,-0.9,-0.6,-0.3,-0.2,0.2,0.3,0.6,0.9,1.2,1.6,2.1,), + ) + +PLATEAU_ABSETA = cms.PSet(SEPARATED, + abseta = cms.vdouble(0.0, 0.9, 1.2, 2.1, 2.4), + pt = cms.vdouble(8.0, 20.0), + ) + +PLATEAU_ETA = cms.PSet( SEPARATED, + eta = cms.vdouble(-2.4, -2.1, -1.6, -1.2, -0.9, -0.3, -0.2, 0.2, 0.3, 0.9, 1.2, 1.6, 2.1, 2.4), + pt = cms.vdouble(8.0, 500.0), + ) + +PT_ABSETA_WIDE = cms.PSet(SEPARATED, + abseta = cms.vdouble(0.0, 1.2, 2.4), + pt = cms.vdouble(5.0, 7.0, 20.0), + ) + +TURNON_ABSETA = cms.PSet( SEPARATED, + abseta = cms.vdouble(0.0, 0.9, 1.2, 2.1, 2.4), + pt = cms.vdouble(3.0, 5.0), + ) + +# Prefix should be "./" only +PREFIX="/afs/cern.ch/work/l/lecriste/TnP/Ilse/CMSSW_5_3_22/test/" +process.TnP_MuonID = Template.clone( + #InputFileNames = cms.vstring( + # PREFIX+'tnpJPsi_Run2012A.root', + # PREFIX+'tnpJPsi_Run2012B.root', + # PREFIX+'tnpJPsi_Run2012C.root', + # PREFIX+'tnpJPsi_Run2012D.root', + #), + ##InputFileNames = cms.vstring('/afs/cern.ch/user/m/msharma/public/tnpJPsi_Data.root'), # 400k events, no JSON + ##InputFileNames = cms.vstring('/afs/cern.ch/user/m/msharma/public/tnpJPsi_DataJuly232015.root'), # 800k events, no JSON + ##InputFileNames = cms.vstring('/afs/cern.ch/user/m/msharma/public/tnpJPsi_Data_246908-251883_JSON_MuonPhys_v2.root'), + ##InputFileNames = cms.vstring('/afs/cern.ch/work/l/lecriste/TnP/recipe_740/CMSSW_7_4_0/src/MuonAnalysis/TagAndProbe/test/jpsi/tnpJPsi_Charmonium_PromptReco_50ns_first47pb.root'), + ##InputFileNames = cms.vstring('/afs/cern.ch/work/l/lecriste/TnP/recipe_740/CMSSW_7_4_0/src/MuonAnalysis/TagAndProbe/test/jpsi/tnpJPsi_Charmonium_PromptReco_50ns_first47ipb_OniaTriggersFlags.root'), + #InputFileNames = cms.vstring('/afs/cern.ch/work/l/lecriste/TnP/recipe_740/CMSSW_7_4_0/src/MuonAnalysis/TagAndProbe/test/jpsi/tnpJPsi_Charmonium_PromptReco_50ns_first47ipb_vertexingTriggersFlags.root'), + ##InputFileNames = cms.vstring('/afs/cern.ch/work/l/lecriste/TnP/recipe_740/CMSSW_7_4_0/src/MuonAnalysis/TagAndProbe/test/jpsi/tnpJPsi_Charmonium_PromptReco_50ns.root'), + #InputFileNames = cms.vstring('/afs/cern.ch/work/l/lecriste/TnP/recipe_740/CMSSW_7_4_0/src/MuonAnalysis/TagAndProbe/test/jpsi/tnpJPsi_Data25ns.root'), + InputFileNames = cms.vstring('/afs/cern.ch/work/l/lecriste/TnP/recipe_740/CMSSW_7_4_0/src/MuonAnalysis/TagAndProbe/test/jpsi/tnpJPsi_Data25ns_golden.root'), + #InputFileNames = cms.vstring('/afs/cern.ch/work/l/lecriste/TnP/recipe_740/CMSSW_7_4_0/src/MuonAnalysis/TagAndProbe/test/jpsi/tnpJPsi_Data25ns_golden_Mu8.root'), # Mu8 test + # + InputTreeName = cms.string("fitter_tree"), + InputDirectoryName = cms.string("tpTree"), + #InputDirectoryName = cms.string("tpTreeSta"), + OutputFileName = cms.string("TnP_MuonID_%s.root" %scenario), + Efficiencies = cms.PSet(), +) + +IDS = ["Soft2012"] +#IDS = ["oldSoft2012"] +#IDS = ["Loose2012"] +#IDS = ["Loose2012", "Soft2012", "newSoft2012"] +#IDS = [ "Glb", "TMOST", "VBTF", "PF" ] +# Carlo request: +#IDS = ["Loose2015", "Soft2012", "Medium2015", "Tight2012_zIPCut"] + +#TRIGS = [ (2,'Mu7p5_L2Mu2_Jpsi'), (2,'Mu7p5_Track2_Jpsi'), (3.5,'Mu7p5_Track3p5_Jpsi'), (7,'Mu7p5_Track7_Jpsi') ] +#TRIGS = [ (2,'Mu7p5_Track2_Jpsi'), (7,'Mu7p5_Track7_Jpsi') ] +TRIGS = [ (2,'Mu7p5_Track2_Jpsi') ] +#TRIGS = [ (2,'Mu8') ] # Mu8 test +#TRIGS = [ (7,'Mu7p5_Track7_Jpsi') ] +#TRIGS = [ (0,'Mu8'), (0,'Mu17') ] +#TRIGS = [ (0,'DoubleMu17TkMu8_TkMu8leg') ] + +UnbinnedVars = cms.vstring("mass") +if "mc" in scenario: + UnbinnedVars = cms.vstring("mass","weight") + process.TnP_MuonID.InputFileNames = ['../tnpJPsi_officialBPHMC25ns_withAllTagVars_withNVtxWeightsFromGolden.root'] + #process.TnP_MuonID.InputFileNames = ['../tnpJPsi_officialBPHMC25ns_withNVtxWeightsFromGolden.root'] + #process.TnP_MuonID.InputFileNames = ['../tnpJPsi_officialBPHMC25ns_withNVtxWeightsFromMuonPhys.root'] + #process.TnP_MuonID.InputFileNames = ['../tnpJPsi_officialBPHMC25ns.root'] + #process.TnP_MuonID.InputFileNames = ['../tnpJPsi_officialBPHMC25ns.root'] + #process.TnP_MuonID.InputFileNames = ['../tnpJPsi_officialBPHMC_withAllTagVars.root'] + #process.TnP_MuonID.InputFileNames = ['../tnpJPsi_officialBPHMC_vertexingTriggersFlags.root'] + #process.TnP_MuonID.InputFileNames = ['../tnpJPsi_officialBPHMC_OniaTriggersFlags.root'] + #process.TnP_MuonID.InputFileNames = ['../tnpJPsi_officialBPHMC.root'] + #process.TnP_MuonID.InputFileNames = ['../tnpJPsi_officialBPHMC_30M.root'] + #process.TnP_MuonID.InputFileNames = ['../tnpJPsi_officialBPHMC_Mu8.root'] # Mu8 test + #process.TnP_MuonID.InputFileNames = ['../tnpJPsi_MC_total.root'] + #process.TnP_MuonID.InputFileNames = ['root://cmsxrootd.fnal.gov///store/user/lecriste/TnP/JpsiToMuMu_OniaMuonFilter_TuneCUEP8M1_13TeV-pythia8/crab_TnP_MC_request/150710_153845/0000/tnpJPsi_MC_1.root'] + #process.TnP_MuonID.InputFileNames = ['../tnpJPsi_MC_Monika.root'] + #process.TnP_MuonID.InputFileNames = ['../tnpJPsi_MC_benchmark_10k.root'] + #process.TnP_MuonID.InputFileNames = ['../tnpJPsi_MC_Mu8.root'] + #process.TnP_MuonID.InputFileNames = ['../tnpJPsi_MC_noFilter.root'] + #process.TnP_MuonID.InputFileNames = ['../tnpJPsi_MC.root'] + #process.TnP_MuonID.InputFileNames = ['../tnpJPsi_MC_oldMatching.root'] + #process.TnP_MuonID.InputFileNames = ['../tnpJPsi_MC_oldTriggers.root'] + +if "25ns" in process.TnP_MuonID.InputFileNames[0]: + mode = "25ns_" +else: mode = "" + +#ALLBINS = [("plateau_abseta",PLATEAU_ABSETA)] +#ALLBINS = [("pt_eta",PT_ETA_BINS)] +#ALLBINS = [("pt_abseta",PT_ABSETA_BINS)] +#ALLBINS = [("pt_abseta_seagull",PT_ABSETA_BINS_SEAGULL), ("pt_abseta_cowboy",PT_ABSETA_BINS_COWBOY)] +#ALLBINS = [("pt_abseta_allPairs",PT_ABSETA_BINS_allPairs)] +#ALLBINS = [("pt_abseta_notSeparated",PT_ABSETA_BINS_notSeparated)] +#ALLBINS = [("pt_abseta_notSeparated",PT_ABSETA_BINS_notSeparated), ("pt_abseta_seagull",PT_ABSETA_BINS_SEAGULL), ("pt_abseta_cowboy",PT_ABSETA_BINS_COWBOY)] +ALLBINS = [("pt_abseta_separated",PT_ABSETA_BINS_allPairs), ("pt_abseta_seagull_separated",PT_ABSETA_BINS_SEAGULL_separated), ("pt_abseta_cowboy_separated",PT_ABSETA_BINS_COWBOY_separated)] +#ALLBINS = [("pt_eta2p4_notSeparated",PT_BINS_notSeparated)] +#ALLBINS = [("pt_abseta2p4",PT_BINS_ABSETA2p4)] +#ALLBINS = [("pt_abseta_notSeparated",PT_ABSETA_BINS_notSeparated),("pt_eta2p4_notSeparated",PT_BINS_notSeparated)] +#ALLBINS = [("pt_abseta_notSeparated_allPairs",PT_ABSETA_BINS_notSeparated_allPairs)] +#ALLBINS = [("ptTurnOn_abseta",TURNON_ABSETA)] +#ALLBINS = [("pt_abseta",PT_ABSETA_BINS), ("plateau_abseta",PLATEAU_ABSETA)] +#ALLBINS = [("vtx",VTX_BINS)] +#ALLBINS = [("vtx",VTX_BINS_noSoft)] +#ALLBINS = [("plateau_abseta",PLATEAU_ABSETA), ("vtx",VTX_BINS), ("eta",ETA_BINS)] +#ALLBINS = [("pt_abseta",PT_ABSETA_BINS), ("vtx",VTX_BINS), ("eta",ETA_BINS)] +#ALLBINS = [("pt_abseta",PT_ABSETA_BINS), ("vtx",VTX_BINS), ("plateau",PLATEAU_ABSETA)] +#ALLBINS += [("pt_abseta_wide",PT_ABSETA_WIDE)] +#ALLBINS = [("ptPlateau_eta",PLATEAU_ETA)] + +triggerEff = True +#triggerEff = False +print "Going to define TagProbeFitTreeAnalyzer for " + ', '.join(IDS) + " efficiency (trigger efficiency is " + str(triggerEff) + ")\nusing as input file: " + process.TnP_MuonID.InputFileNames[0] + +for ID in IDS: + #if len(args) > 1 and args[1] in IDS and ID != args[1]: continue + if len(args) > 1 and ID != args[1]: continue + for X,B in ALLBINS: + if len(args) > 2 and X not in args[2:]: continue + module = process.TnP_MuonID.clone(OutputFileName = cms.string( + "TnP_MuonID__%s_%s_%s_%s.root" %(scenario, mode, ID, X))) + if "Mu8" in process.TnP_MuonID.InputFileNames[0]: + #module.OutputFileName = module.OutputFileName.replace(".root","_Mu8.root") + module.OutputFileName = cms.string( + "TnP_MuonID__%s_%s_%s_%s_Mu8.root" %(scenario, mode, ID, X)) + #DEN = B.clone() + #setattr(module.Efficiencies, ID+"_"+X, cms.PSet( + # EfficiencyCategoryAndState = cms.vstring(ID,"above"), # ?? + # UnbinnedVariables = UnbinnedVars, + # BinnedVariables = DEN, + # BinToPDFmap = cms.vstring("signalPlusBkg") + # ) + # ) + # + for PTMIN, TRIG in TRIGS: + TRIGLABEL="" + #if "pt_" in X: + if "pt" in X or "vtx" in X: + TRIGLABEL="_"+TRIG + else: + #if TRIG != "Mu7p5_Track2_Jpsi": continue # use only one trigger except for turn-on ("turn-on" = ""pt_" in X") + if TRIG != "Mu7p5_Track7_Jpsi" and TRIG != "Mu8": continue # use only one trigger except for turn-on ("turn-on" = ""pt_" in X") + DEN = B.clone() + if hasattr(DEN, "pt"): + DEN.pt = cms.vdouble(*[i for i in B.pt if i >= PTMIN]) + if len(DEN.pt) == 0: raise RuntimeError, "Make sure PTMIN is less than at least one B.pt element!" + if len(DEN.pt) == 1: DEN.pt = cms.vdouble(PTMIN, DEN.pt[0]) + DEN_forSoftID = DEN.clone() + if TRIG != "Mu8": + setattr(DEN_forSoftID, "tag_%s_MU" %TRIG, cms.vstring("pass")) + setattr(DEN_forSoftID, "%s_TK" %TRIG, cms.vstring("pass")) + else: + setattr(DEN_forSoftID, "tag_%s" % TRIG, cms.vstring("pass")) + #setattr(DEN_forSoftID, "%s" % TRIG, cms.vstring("pass")) + #setattr(DEN_forSoftID, "TM", cms.vstring("pass")) + #if "calomu" in scenario: DEN_forSoftID.Calo = cms.vstring("pass") + setattr(module.Efficiencies, ID+"_"+X+TRIGLABEL, cms.PSet( + EfficiencyCategoryAndState = cms.vstring(ID,"above"), # ?? + UnbinnedVariables = UnbinnedVars, + BinnedVariables = DEN_forSoftID, + BinToPDFmap = cms.vstring("signalPlusBkg") + )) + # L1L2 w.r.t. SoftMuon ID + if triggerEff: + # for L2 + DEN_withSoftID = DEN_forSoftID.clone( # check variables bounds if input file changes + TMOST = cms.vstring("pass"), tkTrackerLay = cms.vint32(6,18), tkPixelLay = cms.vint32(1,5), dzPV = cms.vdouble(-20,20), dB = cms.vdouble(-0.3,0.3), Track_HP = cms.vstring("pass"), + ) + # for L3 + DEN_SoftID = DEN.clone( # check variables bounds if input file changes + TMOST = cms.vstring("pass"), tkTrackerLay = cms.vint32(6,18), tkPixelLay = cms.vint32(1,5), dzPV = cms.vdouble(-20,20), dB = cms.vdouble(-0.3,0.3), Track_HP = cms.vstring("pass"), + ) + setattr(DEN_SoftID, "tag_Mu7p5_L2Mu2_Jpsi_MU", cms.vstring("pass")) + # + #tag_pt_min = 10.0 # for full-coverage trigger + tag_pt_min = 11.0 # for full-coverage trigger + absetaMax = 1.6 + for L1L2, DEN_L1L2, DEN_L3 in [("Dimuon16_L1L2",DEN_withSoftID.clone(tag_pt = cms.vdouble(tag_pt_min, 1000.0)),DEN_SoftID.clone(tag_pt = cms.vdouble(tag_pt_min, 1000.0))), + ("Dimuon10_L1L2",DEN_withSoftID.clone(tag_abseta = cms.vdouble(0.0, absetaMax)),DEN_SoftID.clone(tag_abseta = cms.vdouble(0.0, absetaMax)))]: + if "Dimuon10" in L1L2: + if hasattr(DEN_L1L2, "abseta"): + DEN_L1L2.abseta = cms.vdouble(*[i for i in DEN.abseta if i < absetaMax]) + DEN_L1L2.abseta.append(absetaMax) + if hasattr(DEN_L3, "abseta"): + DEN_L3.abseta = DEN_L1L2.abseta + setattr(module.Efficiencies, L1L2+"_"+X+TRIGLABEL, cms.PSet( + EfficiencyCategoryAndState = cms.vstring(L1L2,"pass"), + UnbinnedVariables = UnbinnedVars, + BinnedVariables = DEN_L1L2, + BinToPDFmap = cms.vstring("signalPlusBkg"), + )) + # L3 w.r.t. L1L2 + setattr(DEN_L3, L1L2, cms.vstring("pass")) + setattr(module.Efficiencies, "L3_wrt_"+L1L2+"_"+X, cms.PSet( + EfficiencyCategoryAndState = cms.vstring("Mu_L3","pass"), + UnbinnedVariables = UnbinnedVars, + BinnedVariables = DEN_L3, + BinToPDFmap = cms.vstring("signalPlusBkg"), + )) + #if "plateau" in X: module.SaveWorkspace = True + ## mc efficiency, if scenario is mc + #if "mc" in scenario: + # setattr(module.Efficiencies, ID+"_"+X+TRIGLABEL+"_mcTrue", cms.PSet( + # EfficiencyCategoryAndState = cms.vstring(ID,"above"), # ?? "pass" + # UnbinnedVariables = UnbinnedVars, + # BinnedVariables = DEN.clone(mcTrue = cms.vstring("true")) + # )) + # comment the following two lines to not run this efficiency + setattr(process, "TnP_MuonID__"+ID+"_"+X, module) + setattr(process, "run_"+ID+"_"+X, cms.Path(module)) + + + +########## Tracking efficiency ########## +#ALLBINS = [("pt_abseta_notSeparated_allPairs",PT_ABSETA_BINS_notSeparated_allPairs)] +TRIGS = [ (2,'Mu7p5_L2Mu2_Jpsi') ] +matches = [(1.0,0.4), (0.7,0.3), (0.5,0.2), (0.3,0.15), (0.1,0.1)] +#effs = ["", "_NoJPsi", "_NoBestJPsi"] +effs = [""] + +process.TnP_Tracking = Template.clone( + #InputFileNames = cms.vstring('/afs/cern.ch/work/l/lecriste/TnP/recipe_740/CMSSW_7_4_0/src/MuonAnalysis/TagAndProbe/test/jpsi/tnpJPsi_Charmonium_PromptReco_50ns_first47ipb_correctL2.root'), + InputFileNames = process.TnP_MuonID.InputFileNames, + InputDirectoryName = cms.string("tpTreeSta"), + InputTreeName = cms.string("fitter_tree"), + OutputFileName = cms.string("TnP_Tracking_%s.root" % scenario), + Efficiencies = cms.PSet(), + #Cuts = cms.PSet(), +) +if "mc" in scenario: + process.TnP_Tracking.InputFileNames = process.TnP_MuonID.InputFileNames + +#sampleToPdfMap = { "":"gaussPlusCubic", "NoJPsi":"gaussPlusFloatCubic", "NoBestJPsi":"gaussPlusFloatCubic"} +sampleToPdfMap = { "":"signalPlusBkg", "NoJPsi":"gaussPlusFloatCubic", "NoBestJPsi":"gaussPlusFloatCubic"} + +for X,B in ALLBINS: + if len(args) > 2 and X not in args[2:]: continue + module = process.TnP_Tracking.clone(OutputFileName = cms.string("TnP_Tracking__%s_%s_%s.root" % (scenario, mode, X))) + # + for PTMIN, TRIG in TRIGS: + TRIGLABEL="" + #if "pt_" in X: + if "pt" in X or "vtx" in X: + TRIGLABEL="_"+TRIG + else: + #if TRIG != "Mu7p5_Track2_Jpsi": continue # use only one trigger except for turn-on ("turn-on" = ""pt_" in X") + if TRIG != "Mu7p5_Track7_Jpsi" and TRIG != "Mu8": continue # use only one trigger except for turn-on ("turn-on" = ""pt_" in X") + DEN = B.clone() + if hasattr(DEN, "pt"): + DEN.pt = cms.vdouble(*[i for i in B.pt if i >= PTMIN]) + if len(DEN.pt) == 0: raise RuntimeError, "Make sure PTMIN is less than at least one B.pt element!" + if len(DEN.pt) == 1: DEN.pt = cms.vdouble(PTMIN, DEN.pt[0]) + setattr(DEN, "tag_%s_MU" %TRIG, cms.vstring("pass")) + setattr(DEN, "%s_L2" %TRIG, cms.vstring("pass")) + # + for (DR, DETA) in matches: + label = "DR%.1f_DEta%.1f" % (DR, DETA) + #if len(args) > 1 and args[1] != label: + # print "Skipping "+label + # continue + for eff in effs: + label = label.replace(".","p") + eff + # + setattr(module.Cuts, "#DeltaR_cut", cms.vstring("tk_deltaR"+eff, "tk_deltaR"+eff, str(DR))) + setattr(module.Cuts, "#Delta#eta_cut", cms.vstring("tk_deltaEta"+eff, "tk_deltaEta"+eff, str(DETA))) + setattr(module.Efficiencies, "eff_"+label, cms.PSet( + EfficiencyCategoryAndState = cms.vstring("#DeltaR_cut","below", "#Delta#eta_cut","below"), + UnbinnedVariables = UnbinnedVars, + BinToPDFmap = cms.vstring(sampleToPdfMap[eff.replace("_","")]), + BinnedVariables = DEN, + )) + #setattr(process, "TnP_Tracking__"+X, module) + #setattr(process, "p_TnP_Tracking_"+X, cms.Path(module)) + + +########## Vertexing efficiency ########## +if triggerEff: + ALLBINS = [("pt_absrapidity_notSeparated",PT_ABSY_BINS_notSeparated_pair)] + TRIGS = [ (16,'Dimuon6_Jpsi_NoVertexing','Dimuon16_Jpsi'), (10,'Dimuon0er16_Jpsi_NoVertexing','Dimuon10_Jpsi_Barrel') ] + + process.TnP_Vertexing = Template.clone( + #InputFileNames = cms.vstring('/afs/cern.ch/work/l/lecriste/TnP/recipe_740/CMSSW_7_4_0/src/MuonAnalysis/TagAndProbe/test/jpsi/tnpJPsi_Charmonium_PromptReco_50ns_first47ipb_correctL2.root'), + InputFileNames = process.TnP_MuonID.InputFileNames, + InputDirectoryName = cms.string("tpTreeOnePair"), + InputTreeName = cms.string("fitter_tree"), + OutputFileName = cms.string("TnP_Vertexing_%s.root" % scenario), + Efficiencies = cms.PSet(), + ) + if "mc" in scenario: + process.TnP_Vertexing.InputFileNames = process.TnP_MuonID.InputFileNames + + for X,B in ALLBINS: + if len(args) > 2 and X not in args[2:]: continue + module = process.TnP_Vertexing.clone(OutputFileName = cms.string("TnP_Vertexing__%s_%s_%s.root" % (scenario, mode, X))) + # + for PTMIN, TRIG_noVtx, TRIG in TRIGS: + TRIGLABEL="_"+TRIG + # + DEN = B.clone() + if hasattr(DEN, "pair_pt"): + DEN.pair_pt = cms.vdouble(*[i for i in B.pair_pt if i >= PTMIN]) + if len(DEN.pair_pt) == 0: raise RuntimeError, "Make sure PTMIN is less than at least one B.pt element!" + if len(DEN.pair_pt) == 1: DEN.pair_pt = cms.vdouble(PTMIN, DEN.pair_pt[0]) + setattr(DEN, "tag_%s" %TRIG_noVtx, cms.vstring("pass")) + setattr(DEN, "%s" %TRIG_noVtx, cms.vstring("pass")) + # + if "er16" in TRIG_noVtx: + absyMax = 1.6 + if hasattr(DEN, "pair_absrapidity"): + DEN.pair_absrapidity = cms.vdouble(*[i for i in B.pair_absrapidity if i < absyMax]) + DEN.pair_absrapidity.append(absyMax) + #DEN = DEN.clone(abseta = cms.vdouble(0.0, absyMax)) + #DEN = DEN.clone(tag_abseta = cms.vdouble(0.0, absyMax)) + # + setattr(module.Efficiencies, TRIG+"_wrt_"+TRIG_noVtx, cms.PSet( + EfficiencyCategoryAndState = cms.vstring(TRIG,"pass"), + UnbinnedVariables = UnbinnedVars, + BinToPDFmap = cms.vstring("signalPlusBkg"), + BinnedVariables = DEN, + )) + # comment the following two lines to not run this efficiency + #setattr(process, "TnP_Vertexing__"+X, module) + #setattr(process, "p_TnP_vertexing_"+X, cms.Path(module)) + + +print "End of configuration file" diff --git a/test/jpsi/plotCanvases.cxx b/test/jpsi/plotCanvases.cxx new file mode 100644 index 00000000000..554c6e7ff52 --- /dev/null +++ b/test/jpsi/plotCanvases.cxx @@ -0,0 +1,378 @@ +// Macro to loop on the directories and subdirectories in a file and plot all canvases +// Usage: +// root -l +// .L plotCanvases.cxx +// plotCanvases("scenrario") where scenario = mc/data +// + +#include "TROOT.h" +#include "TStyle.h" +#include "TFile.h" +#include "TTree.h" +#include "TCanvas.h" +#include "TLegend.h" +#include "TString.h" +#include "TH1.h" +#include "TH2.h" +#include "TGraphAsymmErrors.h" +#include "TGraph.h" +#include "TMultiGraph.h" +#include "TList.h" +#include "TKey.h" +#include "TDirectory.h" +#include + + + +void plotCanvases(TString scenario) { + /* + gROOT->SetStyle("Plain"); + gStyle->SetTitleFillColor(0); + gStyle->SetPalette(1); + gStyle->SetOptStat(0); + // + gStyle->SetTitleSize(0.01,"t"); // not working + gStyle->SetTitleBorderSize(0); + gStyle->SetTitleOffset(1.25,"X") ; + gStyle->SetTitleOffset(1.2,"Y") ; + */ + gStyle->SetPaintTextFormat(".3f"); + TString fileName = "TnP_Muon_ID_Simple.root" ; + + TString binnedVariables = ""; + TString scenarioFile = "" ; + if ( scenario.Contains("mc") ) { + scenario = "mc/" ; scenarioFile = "signal_mc" ; + fileName = "TnP_MuonID_signal_mc_newSoft2012_pt_abseta.root" ; binnedVariables = "pt_abseta"; + fileName = "TnP_MuonID_signal_mc_Soft2012_pt_abseta_noFilter.root" ; binnedVariables = "pt_abseta"; + fileName = "TnP_MuonID_signal_mc_Soft2012_pt_abseta_benchmark10k.root" ; binnedVariables = "pt_abseta"; + fileName = "TnP_MuonID_signal_mc_Soft2012_pt_abseta_fullMC.root" ; binnedVariables = "pt_abseta"; + fileName = "TnP_MuonID_signal_mc_Soft2012_pt_abseta_etaIntegrated.root" ; binnedVariables = "pt_abseta"; + //fileName = "TnP_MuonID_signal_mc_newSoft2012_noTMOST_pt_abseta0p9to1p2.root" ; + fileName = "TnP_MuonID__signal_mc__newSoft2012_pt_abseta0p9to1p2.root" ; binnedVariables = "pt_abseta"; + fileName = "TnP_MuonID__signal_mc__Soft2012_pt_abseta_Mu8.root" ; binnedVariables = "pt_abseta"; + fileName = "TnP_MuonID__signal_mc__Soft2012_pt_abseta.root" ; binnedVariables = "pt_abseta"; + fileName = "TnP_MuonID__signal_mc__Soft2012_ptTurnOn_abseta_30M.root" ; binnedVariables = "ptTurnOn_abseta"; + fileName = "TnP_MuonID__signal_mc__Soft2012_ptTurnOn_abseta_Mu8.root" ; binnedVariables = "ptTurnOn_abseta"; + fileName = "TnP_MuonID__signal_mc__Soft2012_vtx_30M.root" ; binnedVariables = "vtx"; + fileName = "TnP_MuonID__signal_mc__Soft2012_pt_abseta_30M.root" ; binnedVariables = "pt_abseta"; + fileName = "TnP_MuonID__signal_mc__Soft2012_pt_abseta.root" ; binnedVariables = "pt_abseta"; + //fileName = "TnP_MuonID__signal_mc__Soft2012_pt_abseta_allPairs_30M.root" ; + //fileName = "TnP_MuonID__signal_mc__Soft2012_pt_eta_30M.root" ; + //fileName = "TnP_MuonID__signal_mc__Soft2012_pt_abseta_notSeparated_30M.root" ; binnedVariables = "pt_abseta_notSeparated"; + fileName = "TnP_MuonID__signal_mc__Soft2012_pt_abseta.root" ; binnedVariables = "pt_abseta"; + fileName = "TnP_Vertexing__signal_mc__pt_abseta.root" ; binnedVariables = "pt_abseta"; + fileName = "TnP_MuonID__signal_mc__Soft2012_pt_abseta_seagull.root" ; binnedVariables = "pt_abseta_seagull"; + //fileName = "TnP_MuonID__signal_mc__Soft2012_pt_abseta_cowboy.root" ; binnedVariables = "pt_abseta_cowboy"; + fileName = "TnP_MuonID__signal_mc__Soft2012_pt_abseta_notSeparated.root" ; binnedVariables = "pt_abseta_notSeparated"; + // 25ns + //fileName = "TnP_MuonID__signal_mc_25ns__Soft2012_pt_abseta_notSeparated.root" ; binnedVariables = "pt_abseta_notSeparated"; + fileName = "TnP_Vertexing__signal_mc_25ns__pt_absrapidity_notSeparated.root" ; binnedVariables = "pt_absrapidity_notSeparated"; + // + //fileName = "TnP_MuonID__signal_mc_25ns__Loose2015_pt_abseta_notSeparated.root" ; binnedVariables = "pt_abseta_notSeparated"; + //fileName = "TnP_MuonID__signal_mc_25ns__Medium2015_pt_abseta_notSeparated.root" ; binnedVariables = "pt_abseta_notSeparated"; + //fileName = "TnP_MuonID__signal_mc_25ns__Tight2012_zIPCut_pt_abseta_notSeparated.root" ; binnedVariables = "pt_abseta_notSeparated"; + // + //fileName = "TnP_MuonID__signal_mc_25ns__Loose2015_pt_abseta.root" ; binnedVariables = "pt_abseta"; + //fileName = "TnP_MuonID__signal_mc_25ns__Medium2015_pt_abseta.root" ; binnedVariables = "pt_abseta"; + //fileName = "TnP_MuonID__signal_mc_25ns__Tight2012_zIPCut_pt_abseta.root" ; binnedVariables = "pt_abseta"; + // + //fileName = "TnP_MuonID__signal_mc_25ns__Loose2015_pt_abseta2p4.root" ; binnedVariables = "pt_abseta2p4"; + //fileName = "TnP_MuonID__signal_mc_25ns__Medium2015_pt_abseta2p4.root" ; binnedVariables = "pt_abseta2p4"; + //fileName = "TnP_MuonID__signal_mc_25ns__Tight2012_zIPCut_pt_abseta2p4.root" ; binnedVariables = "pt_abseta2p4"; + // + //fileName = "TnP_MuonID__signal_mc_25ns__Loose2015_ptPlateau_eta.root" ; binnedVariables = "ptPlateau_eta"; + //fileName = "TnP_MuonID__signal_mc_25ns__Medium2015_ptPlateau_eta.root" ; binnedVariables = "ptPlateau_eta"; + //fileName = "TnP_MuonID__signal_mc_25ns__Tight2012_zIPCut_ptPlateau_eta.root" ; binnedVariables = "ptPlateau_eta"; + // + //fileName = "TnP_MuonID__signal_mc_25ns__Loose2015_vtx.root" ; binnedVariables = "vtx"; + //fileName = "TnP_MuonID__signal_mc_25ns__Medium2015_vtx.root" ; binnedVariables = "vtx"; + //fileName = "TnP_MuonID__signal_mc_25ns__Tight2012_zIPCut_vtx.root" ; binnedVariables = "vtx"; + } + else if ( scenario.Contains("data") ) { + scenario = "data/" ; scenarioFile = "data" ; + fileName = "TnP_MuonID_data_all_Soft2012_pt_abseta.root" ; binnedVariables = "pt_abseta"; + fileName = "TnP_MuonID__data_246908-255031_JSON_MuonPhys_v2__Soft2012_pt_abseta.root" ; binnedVariables = "pt_abseta"; + fileName = "TnP_MuonID__data_246908-251883_JSON_MuonPhys_v2__Soft2012_vtx.root" ; binnedVariables = "vtx"; + fileName = "TnP_MuonID__data_246908-251883_JSON_MuonPhys_v2__Soft2012_pt_abseta.root" ; binnedVariables = "pt_abseta"; + fileName = "TnP_Vertexing__data_246908-251883_JSON_MuonPhys_v2__pt_abseta.root" ; binnedVariables = "pt_abseta"; + //fileName = "TnP_MuonID__data_246908-251883_JSON_MuonPhys_v2__Soft2012_pt_abseta_allPairs.root" ; binnedVariables = "pt_abseta_allPairs"; + //fileName = "TnP_MuonID__data_246908-251883_JSON_MuonPhys_v2__Soft2012_pt_eta.root" ; binnedVariables = "pt_eta"; + //fileName = "TnP_MuonID__data_246908-251883_JSON_MuonPhys_v2__Soft2012_pt_abseta_notSeparated.root" ; binnedVariables = "pt_abseta_notSeparated"; + //fileName = "TnP_MuonID__data_246908-251883_JSON_MuonPhys_v2__Soft2012_pt_abseta_seagull.root" ; binnedVariables = "pt_abseta_seagull"; + //fileName = "TnP_MuonID__data_246908-251883_JSON_MuonPhys_v2__Soft2012_pt_abseta_cowboy.root" ; binnedVariables = "pt_abseta_cowboy"; + fileName = "TnP_MuonID__data_all__Soft2012_pt_abseta_notSeparated.root" ; binnedVariables = "pt_abseta_notSeparated"; + // 25ns + // Soft2012 + fileName = "TnP_MuonID__data_25ns__Soft2012_pt_abseta.root" ; binnedVariables = "pt_abseta"; + //fileName = "TnP_MuonID__data_25ns__Soft2012_pt_abseta2p4.root" ; binnedVariables = "pt_abseta2p4"; + //fileName = "TnP_MuonID__data_25ns__Soft2012_ptPlateau_eta.root" ; binnedVariables = "ptPlateau_eta"; + //fileName = "TnP_MuonID__data_25ns__Soft2012_vtx.root" ; binnedVariables = "vtx"; + //fileName = "TnP_MuonID__data_all_25ns__Soft2012_pt_abseta_Mu8.root" ; binnedVariables = "pt_abseta"; + // + //fileName = "TnP_MuonID__data_all_25ns__Loose2015_pt_abseta_notSeparated.root" ; binnedVariables = "pt_abseta_notSeparated"; + //fileName = "TnP_MuonID__data_all_25ns__Medium2015_pt_abseta_notSeparated.root" ; binnedVariables = "pt_abseta_notSeparated"; + //fileName = "TnP_MuonID__data_all_25ns__Tight2012_zIPCut_pt_abseta_notSeparated.root" ; binnedVariables = "pt_abseta_notSeparated"; + // + //fileName = "TnP_MuonID__data_25ns__Loose2015_pt_abseta.root" ; binnedVariables = "pt_abseta"; + //fileName = "TnP_MuonID__data_25ns__Medium2015_pt_abseta.root" ; binnedVariables = "pt_abseta"; + //fileName = "TnP_MuonID__data_25ns__Tight2012_zIPCut_pt_abseta.root" ; binnedVariables = "pt_abseta"; + // + //fileName = "TnP_MuonID__data_25ns__Loose2015_pt_abseta2p4.root" ; binnedVariables = "pt_abseta2p4"; + //fileName = "TnP_MuonID__data_25ns__Medium2015_pt_abseta2p4.root" ; binnedVariables = "pt_abseta2p4"; + //fileName = "TnP_MuonID__data_25ns__Tight2012_zIPCut_pt_abseta2p4.root" ; binnedVariables = "pt_abseta2p4"; + // + //fileName = "TnP_MuonID__data_25ns__Loose2015_ptPlateau_eta.root" ; binnedVariables = "ptPlateau_eta"; + //fileName = "TnP_MuonID__data_25ns__Medium2015_ptPlateau_eta.root" ; binnedVariables = "ptPlateau_eta"; + //fileName = "TnP_MuonID__data_25ns__Tight2012_zIPCut_ptPlateau_eta.root" ; binnedVariables = "ptPlateau_eta"; + // + //fileName = "TnP_MuonID__data_25ns__Loose2015_vtx.root" ; binnedVariables = "vtx"; + //fileName = "TnP_MuonID__data_25ns__Medium2015_vtx.root" ; binnedVariables = "vtx"; + //fileName = "TnP_MuonID__data_25ns__Tight2012_zIPCut_vtx.root" ; binnedVariables = "vtx"; + // Mu8 + //fileName = "TnP_MuonID__data_all_25ns__Loose2015_pt_abseta_Mu8.root" ; binnedVariables = "pt_abseta"; + //fileName = "TnP_MuonID__data_all_25ns__Medium2015_pt_abseta_Mu8.root" ; binnedVariables = "pt_abseta"; + //fileName = "TnP_MuonID__data_all_25ns__Tight2012_zIPCut_pt_abseta_Mu8.root" ; binnedVariables = "pt_abseta"; + } + else { + cout <<"Argument not valid!\nRun with \"plotCanvases(\"mc\") or plotCanvases(\"data\")" < tree = {"tpTree"} ; + //vector tree = {"tpTree", "tpTreeSta"} ; + if (fileName.Contains("Vertexing")) + tree = {"tpTreeOnePair"} ; + + //vector ids = {"newSoft2012"} ; + vector ids = {"Soft2012"/*,"Dimuon10_L1L2","Dimuon16_L1L2","L3_wrt_Dimuon10_L1L2","L3_wrt_Dimuon16_L1L2","Dimuon16_Jpsi_wrt_Dimuon6_Jpsi_NoVertexing","Dimuon10_Jpsi_Barrel_wrt_Dimuon0er16_Jpsi_NoVertexing"*/} ; + //vector ids = {"newSoft2012_noTMOST"} ; + //vector ids = {"Loose2015", "Soft2012", "Medium2015", "Tight2012_zIPCut"} ; + + //vector triggers = {"Mu7p5_L2Mu2_Jpsi", "Mu7p5_Track2_Jpsi", "Mu7p5_Track3p5_Jpsi", "Mu7p5_Track7_Jpsi"} ; + ////vector triggers = {"Mu7p5_Track2_Jpsi"} ; + vector triggers = {"_Mu7p5_Track2_Jpsi"} ; + //vector triggers = {"Mu7p5_Track2_Jpsi", "Mu7p5_Track7_Jpsi"} ; + //vector triggers = {"Mu5_Track2"} ; + if ( fileName.Contains("Mu8") ) + triggers = {"_Mu8"} ; + //"L1_DoubleMu0_Eta1p6_WdEta18" + vector trigL3 = {""} ; + vector triggersNoVtx = {"_Dimuon6_Jpsi_NoVertexing"} ; + vector triggersNoVtx_barrel = {"_Dimuon0er16_Jpsi_NoVertexing"} ; + vector trigNoSoft = {""} ; + + vector< pair> > ids_triggers ; + + for (uint iId=0; iId notToPlot = {"distributions_canvas"} ; + + // See the directory names from the files + //const vector folders = { + vector folders = { + //"Tight2012_pt_eta_fine", + //"Tight2012_pt", + //"Tight2012_pt_eta_fine", + //"Tight2012_nVtx", + //"Tight2012_nJets30", + //"Tight2012_eta_truth", + //"Tight2012_pt", + //"Tight2012_pt_truth", + //"Tight2012_pt_eta", + //"Tight2012_pt_eta_truth" + }; + /* + if ( fileName.Contains("pt_abseta_notSeparated") ) + folders.push_back("pt_abseta_notSeparated") ; + else if ( fileName.Contains("pt_abseta_allPairs") ) + folders.push_back("pt_abseta_allPairs") ; + else if ( fileName.Contains("pt_abseta") ) + folders.push_back("pt_abseta") ; + + if ( fileName.Contains("ptTurnOn_abseta") ) + folders.push_back("ptTurnOn_abseta") ; + if ( fileName.Contains("vtx") ) + folders.push_back("vtx") ; + else if ( fileName.Contains("pt_eta") ) + folders.push_back("pt_eta") ; + */ + folders.push_back( binnedVariables ) ; + + TString prefix = "./" ; + prefix = "/afs/cern.ch/work/l/lecriste/www/TnP/" ; // https://lecriste.web.cern.ch/lecriste/TnP + + TString uploadFile = "index.php" ; + TString dirPlace = prefix+"plots/" ; + if ( prefix.EqualTo("/afs/cern.ch/work/l/lecriste/www/TnP/") ) + gSystem->CopyFile(prefix+uploadFile, dirPlace+uploadFile, true); + + // scenario dir + //dirPlace = prefix+"plots/"+scenario ; + dirPlace.Append( scenario ); + gSystem->mkdir(dirPlace, true); + if ( prefix.EqualTo("/afs/cern.ch/work/l/lecriste/www/TnP/") ) + gSystem->CopyFile(prefix+uploadFile, dirPlace+uploadFile, true); + + TString test = "" ; // remember to put a slash '/' at the end if it's not "" + //test = "mc2012/" ; + //test = "noProbeFilter/" ; + //test = "etaIntegrated/" ; + if ( fileName.Contains("246908-251883_JSON_MuonPhys_v2") || fileName.Contains("data") ) { + test = "246908-251883_JSON_MuonPhys_v2/" ; + //test = "246908-255031_JSON_MuonPhys_v2/" ; + if ( mode.Contains("25ns") ) { + //test = "246908-260627_JSON_MuonPhys/" ; + test = "246908-260627_JSON_Golden_v2/" ; + } + } + if ( fileName.Contains("30M") ) test = "30M/" ; + //if ( fileName.Contains("Mu8") ) test = "Mu8/" ; + + dirPlace.Append( test ); + gSystem->mkdir(dirPlace, true); + if ( prefix.EqualTo("/afs/cern.ch/work/l/lecriste/www/TnP/") ) + gSystem->CopyFile(prefix+uploadFile, dirPlace+uploadFile, true); + TString testFile = "_" ; + //testFile = "_246908-251883_JSON_MuonPhys_v2_" ; + // + //fileName = "TnP_MuonID__"+scenarioFile+testFile+"_"+ids[0]+"_"+folders[0]+".root" ; + TFile *f1 = 0 ; + if ( (f1 = TFile::Open( fileName.Data() )) ) + cout <<"Successfully opened file " <mkdir(dirPlace, true); + if ( prefix.EqualTo("/afs/cern.ch/work/l/lecriste/www/TnP/") ) + gSystem->CopyFile(prefix+uploadFile, dirPlace+uploadFile, true); + + //loop on ids + //for (uint iId=0; iIdmkdir(dirPlace, true); + if ( prefix.EqualTo("/afs/cern.ch/work/l/lecriste/www/TnP/") ) + gSystem->CopyFile(prefix+uploadFile, dirPlace+uploadFile, true); + + //loop on directory names + for (uint kk=0; kkmkdir(dirPlace, true); + if ( prefix.EqualTo("/afs/cern.ch/work/l/lecriste/www/TnP/") ) + gSystem->CopyFile(prefix+uploadFile, dirPlace+uploadFile, true); + + //loop on triggers + //for (uint iTrig=0; iTrigmkdir(dirPlace, true); + if ( prefix.EqualTo("/afs/cern.ch/work/l/lecriste/www/TnP/") ) + gSystem->CopyFile(prefix+uploadFile, dirPlace+uploadFile, true); + + + //TString dirName = tree[iTree]+"/"+ids[iId]+"_"+folders[kk]+"_"+triggers[iTrig] ; + TString dirName = tree[iTree]+"/"+ids[iId]+"_"+folders[kk]+trig ; + if (ids[iId].Contains("Vertexing")) + dirName = tree[iTree]+"/"+ids[iId] ; + TDirectory *direc = f1->GetDirectory( dirName.Data() ); + if (direc == 0) { + cout <<"\nNo TDirectory called \"" <GetName() <GetListOfKeys() ); + TKey *key; + + //loop on subDirectories + while ( (key = (TKey*)next()) ) { + TClass *cl = gROOT->GetClass( key->GetClassName() ); + if ( !cl->InheritsFrom("TDirectoryFile") ) continue; + TString name = key->GetTitle() ; + //cout <GetTitle() <GetDirectory( dirName+"/"+name ); + if (direc2 == 0) { + cout <<"\nNo TDirectory called \"" <GetListOfKeys() ); + TKey *key2; + + //loop on Canvases + while( (key2 = (TKey*)next2()) ) { + TClass *cl2 = gROOT->GetClass( key2->GetClassName() ); + if ( !cl2->InheritsFrom("TCanvas") ) continue; + //cout <GetName() <GetName() ; + for (uint i=0; iGetName() != notToPlot[i].Data() ) { + if ( !notToPlot[i].EqualTo( name2 ) ) { + TCanvas *c1 = (TCanvas*) key2->ReadObj() ; + //TCanvas *c1 = dynamic_cast( key2->ReadObj() ) ; + //c1->Update() ; + c1->SetGrid() ; + c1->Draw() ; //c1->UseCurrentStyle() ; + + if ( name2.Contains("eta_pt") || name2.Contains("absrapidity_pair_pt_PLOT")) + gPad->SetLogy() ; + else if ( name2.Contains("pt_eta") || name2.Contains("pt_abseta") || name2.Contains("pt_PLOT") || name2.Contains("pt_pair_absrapidity_PLOT")) + gPad->SetLogx() ; + + + gSystem->mkdir(dirPlace, true); + + if ( !trig.Contains("Mu8") ) { + name.ReplaceAll(trig+"_TK_pass_","").ReplaceAll("_tag"+trig+"_MU_pass_","") ; + name2.ReplaceAll("_and"+trig+"_TK_pass","").ReplaceAll("_and_tag"+trig+"_MU_pass","") ; + } else { + name.ReplaceAll(trig+"_pass_","").ReplaceAll("_tag"+trig+"_pass_","") ; + name2.ReplaceAll("_and"+trig+"_pass","").ReplaceAll("_and_tag"+trig+"_pass","") ; + } + c1->SaveAs(dirPlace+name+"_"+name2+".png"); + + //c1->SaveAs("plots/"+folders[kk]+"_"+key->GetTitle()+"_"+key2->GetName()+".eps"); + //c1->SaveAs("plots/"+folders[kk]+"_"+key->GetTitle()+".eps"); + //c1->SaveAs("plots/"+folders[kk]+"_"+key->GetTitle()+"_"+key2->GetName()+".pdf"); + + } + + }//end of loop on notToPlot canvases + + }//end of loop on canvases + + }//end of loop on subdirectories + + }//end of loop on directories + + }//end of loop on triggers + + }//end of loop on ids + + }//end of loop on trees + +} + diff --git a/test/jpsi/softID_vars.C b/test/jpsi/softID_vars.C new file mode 100644 index 00000000000..62bf34fa612 --- /dev/null +++ b/test/jpsi/softID_vars.C @@ -0,0 +1,215 @@ +{ + //gStyle->SetTitleSize(0.5,"t"); // put the title inside the histogram! + //gStyle->SetTitleSize(0.5); // not working + //TGaxis::SetMoreLogLabels() ; + + TString scenario[4] ; + scenario[0] = "data2015" ; + scenario[1] = "mc2015" ; + scenario[2] = "mc2015_Mu8" ; + scenario[3] = "mc2012" ; + const Int_t nScenarios = sizeof(scenario)/sizeof(scenario[0]); + + TFile *file[nScenarios] = {0} ; + file[0] = TFile::Open("/afs/cern.ch/user/m/msharma/public/tnpJPsi_Data_246908-251883_JSON_MuonPhys_v2.root") ; + file[1] = TFile::Open("/afs/cern.ch/work/l/lecriste/TnP/recipe_740/CMSSW_7_4_0/src/MuonAnalysis/TagAndProbe/test/jpsi/tnpJPsi_MC_total.root") ; + file[2] = TFile::Open("/afs/cern.ch/work/l/lecriste/TnP/recipe_740/CMSSW_7_4_0/src/MuonAnalysis/TagAndProbe/test/jpsi/crab/tnpJPsi_officialBPHMC.root") ; + file[3] = TFile::Open("/afs/cern.ch/work/l/lecriste/TnP/Ilse/CMSSW_5_3_22/test/tnpJPsi_MC53X.root") ; + + TString path[nScenarios] ; + path[0] = "Mu7p5_Track2" ; //{"Mu7p5_Track2","Mu7p5_Track3p5","Mu7p5_Track7"} ; + path[1] = "Mu7p5_Track2" ; //{"Mu7p5_Track2","Mu7p5_Track3p5","Mu7p5_Track7"} ; + path[2] = "Mu8" ; + path[3] = "Mu5_Track2" ; //{"Mu5_Track2","Mu5_Track7"} ; + + TString baseSelection = "pair_drM1>0.5 && pair_probeMultiplicity==1" ; + baseSelection.Append( " && pt>6 && pt<11" ) ; // for plateau study + // + TString selection[nScenarios] ; + + TString prefix = "./" ; + prefix = "/afs/cern.ch/work/l/lecriste/www/TnP/" ; + TString uploadFile = "index.php" ; + + TString dir[nScenarios] ; + dir[0] = prefix+"plots/data/246908-251883_JSON_MuonPhys_v2/tpTree/Soft2012/pt_abseta/"+path[0]+"_Jpsi/"+"ID_vars/maxPtCut/" ; + dir[1] = prefix+"plots/mc/tpTree/Soft2012/pt_abseta/"+path[1]+"_Jpsi/"+"ID_vars/maxPtCut/" ; + dir[2] = prefix+"plots/mc/"+path[2]+"/tpTree/Soft2012/pt_abseta/"+path[2]+"/"+"ID_vars/maxPtCut/" ; + dir[3] = prefix+"plots/mc/mc2012/tpTree/newSoft2012/pt_abseta/"+path[3]+"/"+"ID_vars/maxPtCut/" ; + + TString var[] = {"l2pt"}; + //TString var[] = {"l2pt","pt","eta","tkTrackerLay","tkPixelLay","dzPV","dB","Track_HP","TMOST","TM","TMA","TMOSL","numberOfMatchedStations","numberOfMatches","segmentCompatibility","tkChi2"}; + TString binsVar[] = {"(100,0,50)"} ; + //TString binsVar[] = {"(100,0,50)","(100,0,50)","(96,-2.4,2.4)","(19,-0.5,18.5)","(6,-0.5,5.5)","(90,-45,45)","(160,0,2)","(2,-0.5,1.5)","(2,-0.5,1.5)","(2,-0.5,1.5)","(2,-0.5,1.5)","(2,-0.5,1.5)","(7,-1.5,5.5)","(10,-1.5,8.5)","(100,0,1)","(90,0,30)"} ; + const Int_t nVars = sizeof(var)/sizeof(var[0]); + + TH1F *hVar_sel[nScenarios][nVars] ; + + Float_t etaBin[] = {0.0, 0.9, 1.2, 2.1, 2.4} ; + Int_t nBinsEta = sizeof(etaBin)/sizeof(etaBin[0]); + vector etaBinLabel (nBinsEta-1,"etaBinLabel not set!"); + + for (Int_t iEtaBin = 0; iEtaBin < nBinsEta-1; ++iEtaBin) { + TString label = TString::Format("%.3gto%.3g",etaBin[iEtaBin],etaBin[iEtaBin+1]) ; + label.ReplaceAll(".","p") ; + //ptBinLabel.push_back( label ) ; + etaBinLabel[iEtaBin] = label ; + } + + vector< vector< vector > > etaBinHist (nScenarios); + etaBinHist.resize(nScenarios) ; + + for (Int_t iScenario = 0; iScenario < nScenarios; ++iScenario) { + etaBinHist[iScenario].resize( nVars ) ; + + TTree *fitter_tree = (TTree*)file[iScenario]->Get("tpTree/fitter_tree"); + if (iScenario != 2) + selection[iScenario] = baseSelection+" && "+"tag_"+path[iScenario]+"_Jpsi_MU && "+path[iScenario]+"_Jpsi_TK" ; + else + selection[iScenario] = baseSelection+" && "+"tag_"+path[iScenario] ; + + gSystem->mkdir(dir[iScenario], false); + if ( prefix.EqualTo("/afs/cern.ch/work/l/lecriste/www/TnP/") ) + gSystem->CopyFile(prefix+uploadFile, dir[iScenario]+uploadFile, true); + + for (Int_t iVar = 0; iVar < nVars; ++iVar) { + TString hName = var[iVar]+"_"+scenario[iScenario] ; + fitter_tree->Draw(var[iVar]+">>"+hName+binsVar[iVar], selection[iScenario]) ; + hVar_sel[iScenario][iVar] = (TH1F*)gDirectory->Get( hName ); + hVar_sel[iScenario][iVar]->Draw() ; hVar_sel[iScenario][iVar]->Draw("text45 same") ; + hVar_sel[iScenario][iVar]->SetMinimum( 0.1 ) ; + if ( var[iVar].EqualTo("tkTrackerLay") ) + gPad->SetLogy(0) ; + else + gPad->SetLogy(1) ; + + hVar_sel[iScenario][iVar]->SetLineColor( iScenario+1 ) ; + gPad->SaveAs(dir[iScenario]+(hVar_sel[iScenario][iVar]->GetName())+"_etaIntegrated.png") ; + + + // eta bins + for (Int_t iEtaBin = 0; iEtaBin < nBinsEta-1; ++iEtaBin) { + etaBinHist[iScenario][iVar].resize(nBinsEta-1) ; + + TString hName_eta = hName ; + hName_eta.Append( "__eta_"+etaBinLabel[iEtaBin] ) ; + TString cut = TString::Format("fabs(eta) > %.3g && fabs(eta) < %.3g",etaBin[iEtaBin],etaBin[iEtaBin+1]) ; + fitter_tree->Draw(var[iVar]+">>"+hName_eta+binsVar[iVar], selection[iScenario]+" && "+cut) ; + etaBinHist[iScenario][iVar][iEtaBin] = (TH1F*)gDirectory->Get( hName_eta ) ; + etaBinHist[iScenario][iVar][iEtaBin]->Draw() ; etaBinHist[iScenario][iVar][iEtaBin]->Draw("text45 same") ; + etaBinHist[iScenario][iVar][iEtaBin]->SetMinimum( 0.1 ) ; + if ( var[iVar].EqualTo("tkTrackerLay") ) + gPad->SetLogy(0) ; + else + gPad->SetLogy(1) ; + + etaBinHist[iScenario][iVar][iEtaBin]->SetLineColor( iScenario+1 ) ; + gPad->SaveAs(dir[iScenario]+(etaBinHist[iScenario][iVar][iEtaBin]->GetName())+".png") ; + } + + } + + } + + + // overlay + + Bool_t isNormalized = kFALSE ; + + for (Int_t iScenario = 0; iScenario < nScenarios; ++iScenario) { + if (iScenario == 1) { + isNormalized = kTRUE ; // normalized in iScenario = 0 loop + continue ; + } + for (Int_t iVar = 0; iVar < nVars; ++iVar) { + for (Int_t iEtaBin = 0; iEtaBin < nBinsEta-1; ++iEtaBin) { + + TString dirVS = dir[1]+"VS_"+scenario[iScenario]+"/" ; + gSystem->mkdir(dirVS, false); + if ( prefix.EqualTo("/afs/cern.ch/work/l/lecriste/www/TnP/") ) + gSystem->CopyFile(prefix+uploadFile, dirVS+uploadFile, true); + + if ( etaBinHist[1][iVar][iEtaBin]->GetEntries() && !isNormalized ) + etaBinHist[1][iVar][iEtaBin]->Scale( 1. / etaBinHist[1][iVar][iEtaBin]->GetEntries() ) ; + if ( etaBinHist[iScenario][iVar][iEtaBin]->GetEntries() ) + etaBinHist[iScenario][iVar][iEtaBin]->Scale( 1. / etaBinHist[iScenario][iVar][iEtaBin]->GetEntries() ) ; + + if (etaBinHist[1][iVar][iEtaBin]->GetMaximum() > etaBinHist[iScenario][iVar][iEtaBin]->GetMaximum()) { + etaBinHist[1][iVar][iEtaBin]->Draw() ; + etaBinHist[iScenario][iVar][iEtaBin]->Draw("same") ; + } else { + etaBinHist[iScenario][iVar][iEtaBin]->Draw() ; + etaBinHist[1][iVar][iEtaBin]->Draw("same") ; + } + // + if ( var[iVar].EqualTo("tkTrackerLay") ) + gPad->SetLogy(0) ; + else + gPad->SetLogy(1) ; + + gPad->SaveAs(dirVS+(etaBinHist[1][iVar][iEtaBin]->GetName())+".png") ; + + } + } + } + + /* + Float_t ptBin[] = {2.0, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 4.5, 5.0, 6.0, 8.0, 10.0, 15.0, 20.0, 30.0, 40.0} ; + Int_t nBinsPt = sizeof(ptBin)/sizeof(ptBin[0]); + + vector ptBinLabel (nBinsPt-1,"ptBinLabel not set!"); + vector ptBinCenter (nBinsPt-1,-1); + vector ptBinEvts_sel (nBinsPt-1,-1); + + Int_t nPath = sizeof(path)/sizeof(path[0]); + //vector< vector > ptBinEvts_path (nPath, (nBinsPt-1,-1) ); + vector< vector > ptBinEvts_path (nPath); + //for (Int_t iPath = 0; iPath < nPath; ++iPath) + //ptBinEvts_path[iPath](nBinsPt-1,-1) ; + + ptBinEvts_path.resize(nPath); + + for (Int_t iPtBin = 0; iPtBin < nBinsPt-1; ++iPtBin) { + TString label = TString::Format("%.3gto%.3g",ptBin[iPtBin],ptBin[iPtBin+1]) ; + label.ReplaceAll(".","p") ; + //ptBinLabel.push_back( label ) ; + ptBinLabel[iPtBin] = label ; + + //ptBinCenter.push_back( (ptBin[iPtBin+1]+ptBin[iPtBin])/2 ) ; + ptBinCenter[iPtBin] = (ptBin[iPtBin]+ptBin[iPtBin+1])/2 ; + + hName = "hMass_sel_pt" ; hName.Append( label ) ; + TString cut = TString::Format("pt > %.3g && pt < %.3g",ptBin[iPtBin],ptBin[iPtBin+1]) ; + fitter_tree->Draw("mass>>"+hName, baseSelection+" && "+cut) ; + TH1F *hMass_sel_ptBin = (TH1F*)gDirectory->Get( hName ); + //ptBinEvts_sel.push_back( hMass_sel_ptBin->GetEntries() ) ; + ptBinEvts_sel[iPtBin] = hMass_sel_ptBin->GetEntries() ; + //hMass_sel_ptBin->SaveAs(dir+hName+".png") ; + + for (Int_t iPath = 0; iPath < nPath; ++iPath) { + hName.Append( "_"+path[iPath] ) ; + TString cutPath = "tag_"+path[iPath]+"_Jpsi_MU && "+path[iPath]+"_Jpsi_TK" ; + fitter_tree->Draw("mass>>"+hName, baseSelection+" && "+cut+" && "+cutPath) ; + TH1F *hMass_sel_ptBin_path = (TH1F*)gDirectory->Get( hName ); + //ptBinEvts_path[iPath][iPtBin] = hMass_sel_ptBin_path->GetEntries() ; + ptBinEvts_path[iPath].push_back( hMass_sel_ptBin_path->GetEntries() ) ; + } + } + + TGraph* pT_yields = new TGraph( nBinsPt-1, &ptBinCenter[0], &ptBinEvts_sel[0]); + pT_yields->SetNameTitle("pT_yields","selection yields;muon p_{T} [GeV]") ; + pT_yields->Draw("AL*"); + gPad->SetGrid() ; + gPad->SaveAs(dir+pT_yields->GetName()+".png") ; + + vector< TGraph* > pT_yields_path (nPath,0); + for (Int_t iPath = 0; iPath < nPath; ++iPath) { + pT_yields_path[iPath] = new TGraph( nBinsPt-1, &ptBinCenter[0], &ptBinEvts_path[iPath][0]); + pT_yields_path[iPath]->SetNameTitle("pT_yields_"+path[iPath],path[iPath]+" yields;muon p_{T} [GeV]") ; + pT_yields_path[iPath]->Draw("AL*"); + gPad->SetGrid() ; + gPad->SaveAs(dir+pT_yields_path[iPath]->GetName()+".png") ; + } + */ + +} diff --git a/test/jpsi/tp_from_aod_simple_Data.py b/test/jpsi/tp_from_aod_simple_Data.py index 7d6c904b4dc..0826b86dee4 100644 --- a/test/jpsi/tp_from_aod_simple_Data.py +++ b/test/jpsi/tp_from_aod_simple_Data.py @@ -5,20 +5,19 @@ process.load('Configuration.StandardSequences.Services_cff') process.load('FWCore.MessageService.MessageLogger_cfi') process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True) ) -process.MessageLogger.cerr.FwkReport.reportEvery = 1000 +process.MessageLogger.cerr.FwkReport.reportEvery = 100 process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring(), ) -process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) ) +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1000000) ) # 3' for 1k vents on Run2015C, 2.5MB in 20' for 10k events, 90MB in 26h for 1M events on Run2015C + process.load('Configuration.StandardSequences.GeometryRecoDB_cff') process.load('Configuration.StandardSequences.MagneticField_cff') -process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') process.load("Configuration.StandardSequences.Reconstruction_cff") -# process.Tracer = cms.Service('Tracer') - import os if "CMSSW_5_3_" in os.environ['CMSSW_VERSION']: process.GlobalTag.globaltag = cms.string('GR_R_53_V7::All') @@ -46,19 +45,154 @@ elif "CMSSW_7_4_" in os.environ['CMSSW_VERSION']: process.GlobalTag.globaltag = cms.string('GR_P_V56::All') process.source.fileNames = [ - '/store/data/Run2015B/Charmonium/AOD/PromptReco-v1/000/251/164/00000/56BA3AC3-A226-E511-98BB-02163E0133B5.root', - '/store/data/Run2015B/Charmonium/AOD/PromptReco-v1/000/251/167/00000/FED37D13-A826-E511-8641-02163E01386E.root', - '/store/data/Run2015B/Charmonium/AOD/PromptReco-v1/000/251/168/00000/1602316B-CF26-E511-BCBA-02163E011BF3.root', - '/store/data/Run2015B/Charmonium/AOD/PromptReco-v1/000/251/168/00000/86456DCF-D026-E511-A8E2-02163E011D37.root', - '/store/data/Run2015B/Charmonium/AOD/PromptReco-v1/000/251/162/00000/E855BF93-4227-E511-8207-02163E011976.root', - '/store/data/Run2015B/Charmonium/AOD/PromptReco-v1/000/251/244/00000/4ADDEB99-6727-E511-BEF2-02163E011955.root', - '/store/data/Run2015B/Charmonium/AOD/PromptReco-v1/000/251/244/00000/C6DB3E01-8327-E511-B696-02163E0139CF.root', - '/store/data/Run2015B/Charmonium/AOD/PromptReco-v1/000/251/244/00000/FC4B5FE2-8A27-E511-A0DD-02163E014729.root', - '/store/data/Run2015B/Charmonium/AOD/PromptReco-v1/000/251/251/00000/7097B2BC-8E27-E511-80E1-02163E0138B3.root', - '/store/data/Run2015B/Charmonium/AOD/PromptReco-v1/000/251/252/00000/0067F5A4-9A27-E511-B904-02163E01267F.root', - '/store/data/Run2015B/Charmonium/AOD/PromptReco-v1/000/251/252/00000/642ACBD2-A127-E511-A59E-02163E0123F1.root', - '/store/data/Run2015B/Charmonium/AOD/PromptReco-v1/000/251/252/00000/F24C3492-9627-E511-AEC5-02163E011C7F.root' - ] + # 50 ns + #'/store/data/Run2015B/Charmonium/AOD/PromptReco-v1/000/251/164/00000/56BA3AC3-A226-E511-98BB-02163E0133B5.root', + #'/store/data/Run2015B/Charmonium/AOD/PromptReco-v1/000/251/167/00000/FED37D13-A826-E511-8641-02163E01386E.root', + #'/store/data/Run2015B/Charmonium/AOD/PromptReco-v1/000/251/168/00000/1602316B-CF26-E511-BCBA-02163E011BF3.root', + #'/store/data/Run2015B/Charmonium/AOD/PromptReco-v1/000/251/168/00000/86456DCF-D026-E511-A8E2-02163E011D37.root', + #'/store/data/Run2015B/Charmonium/AOD/PromptReco-v1/000/251/162/00000/E855BF93-4227-E511-8207-02163E011976.root', + #'/store/data/Run2015B/Charmonium/AOD/PromptReco-v1/000/251/244/00000/4ADDEB99-6727-E511-BEF2-02163E011955.root', + #'/store/data/Run2015B/Charmonium/AOD/PromptReco-v1/000/251/244/00000/C6DB3E01-8327-E511-B696-02163E0139CF.root', + #'/store/data/Run2015B/Charmonium/AOD/PromptReco-v1/000/251/244/00000/FC4B5FE2-8A27-E511-A0DD-02163E014729.root', + #'/store/data/Run2015B/Charmonium/AOD/PromptReco-v1/000/251/251/00000/7097B2BC-8E27-E511-80E1-02163E0138B3.root', + #'/store/data/Run2015B/Charmonium/AOD/PromptReco-v1/000/251/252/00000/0067F5A4-9A27-E511-B904-02163E01267F.root', + #'/store/data/Run2015B/Charmonium/AOD/PromptReco-v1/000/251/252/00000/642ACBD2-A127-E511-A59E-02163E0123F1.root', + #'/store/data/Run2015B/Charmonium/AOD/PromptReco-v1/000/251/252/00000/F24C3492-9627-E511-AEC5-02163E011C7F.root' + # 25 ns + # redirector: root://eoscms.cern.ch/ ; global redirector: root://cms-xrd-global.cern.ch/ ; european redirector: root://xrootd-cms.infn.it// ; US redirector: root://cmsxrootd.fnal.gov/ + #'/store/data/Run2015D/Charmonium/AOD/PromptReco-v3/000/257/822/00000/00B0174E-0869-E511-82B8-02163E01469D.root', + #'/store/data/Run2015D/Charmonium/AOD/PromptReco-v3/000/256/629/00000/3475D421-065F-E511-9389-02163E011D45.root', + # dataset C + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/253/888/00000/5668060A-0941-E511-A433-02163E014523.root', # 0 events + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/253/890/00000/D0DD2762-0941-E511-8D68-02163E014481.root', # 0 events + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/253/944/00000/CC59B3BC-3C41-E511-850A-02163E014405.root', # 0 events + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/253/952/00000/AAB10CDC-4241-E511-B200-02163E0140E9.root', # 0 events + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/253/954/00000/08A34D9A-4441-E511-B733-02163E014331.root', # 0 events + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/094/00000/00D975CA-2C46-E511-8D41-02163E014229.root', # 0 events + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/096/00000/60E94939-5C45-E511-A45F-02163E014555.root', # 0 events + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/212/00000/C4B4E9F1-BA45-E511-A0C9-02163E0140F8.root', # 0 events + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/219/00000/8229ACBC-C345-E511-8D7D-02163E0140F8.root', # 0 events + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/226/00000/42D98650-4545-E511-A6B3-02163E014128.root', # 0 events + # + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/227/00000/2AAF5B25-9C45-E511-88E0-02163E014636.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/229/00000/9CD00F16-EB45-E511-9414-02163E013565.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/231/00000/462E71A3-6345-E511-AC60-02163E0133C0.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/232/00000/C6507137-8245-E511-85AB-02163E014510.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/251/00000/9238F0DC-3546-E511-8F87-02163E012460.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/279/00000/FEB2DE57-A545-E511-A5E4-02163E01298B.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/280/00000/3ADD7E2F-A445-E511-B561-02163E01478E.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/282/00000/B04DCE4A-A845-E511-BC98-02163E011DF7.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/283/00000/8A0E2867-DD45-E511-99C6-02163E0141E8.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/284/00000/822D271E-3E45-E511-BFFF-02163E0138DE.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/285/00000/723CC112-1946-E511-8A21-02163E013860.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/289/00000/E095B7BE-FA45-E511-8EC0-02163E014258.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/290/00000/68741B2F-F745-E511-9F6A-02163E0137FC.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/292/00000/FECD67F6-CB45-E511-B661-02163E01391B.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/293/00000/B270069F-2346-E511-B7AF-02163E011A21.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/294/00000/868D358C-5D45-E511-8458-02163E01457C.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/306/00000/9687B35B-EC45-E511-B603-02163E0135DD.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/307/00000/82442455-3E45-E511-A5F4-02163E014683.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/308/00000/C2DF0ABD-3C45-E511-BDE9-02163E01374E.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/309/00000/641EAFAF-BF45-E511-A1E1-02163E011A21.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/313/00000/64FCC821-CE45-E511-8DF4-02163E0144A6.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/314/00000/A61220F6-0846-E511-AFE9-02163E01299C.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/315/00000/12663589-2346-E511-AD2A-02163E01250A.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/317/00000/BC1B83AC-E945-E511-8B9D-02163E0129E7.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/318/00000/E83C84D9-BE45-E511-A660-02163E011D96.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/319/00000/5C66B233-3E46-E511-8E9B-02163E013831.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/332/00000/5C445947-0F46-E511-A775-02163E0145AD.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/340/00000/20DA6081-AB45-E511-AA37-02163E013932.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/341/00000/5402E77D-9A45-E511-B04D-02163E011DB6.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/342/00000/F0943C6E-9445-E511-9D11-02163E014588.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/349/00000/369C82FE-1046-E511-9DBE-02163E01338E.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/362/00000/681F3297-4046-E511-B82B-02163E0121D5.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/367/00000/7C532C87-4046-E511-9E59-02163E0138DE.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/368/00000/C2C12F5C-4546-E511-99F1-02163E014300.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/380/00000/BED1BE0F-5B46-E511-9E51-02163E012460.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/416/00000/96F61819-8746-E511-8C62-02163E01455F.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/437/00000/B6D554FD-8A46-E511-91A2-02163E013591.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/450/00000/C47E9931-9246-E511-A9C5-02163E0144AE.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/451/00000/0018573A-9246-E511-9AF3-02163E0133EC.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/453/00000/4CC7FB60-9446-E511-9EF8-02163E012155.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/454/00000/32237FFA-9446-E511-9A1B-02163E013816.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/456/00000/C8FB008B-9646-E511-89E4-02163E01469B.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/457/00000/A4308B49-9746-E511-B008-02163E01340A.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/458/00000/4E0B3629-9C46-E511-B994-02163E013723.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/459/00000/76B13945-D646-E511-8B7E-02163E0138DE.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/500/00000/6405BBD0-D246-E511-BF19-02163E014541.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/511/00000/32B3994D-D846-E511-864D-02163E013497.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/512/00000/6A0C6AD0-2547-E511-8B9B-02163E0136DB.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/513/00000/385AE0BE-D746-E511-A62D-02163E01479A.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/530/00000/6E12F204-0F47-E511-8082-02163E011851.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/532/00000/2C26AB3A-1C47-E511-8E62-02163E01470C.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/602/00000/CA93D054-A347-E511-9102-02163E0143CC.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/607/00000/FE6A5737-BB47-E511-B71D-02163E013958.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/608/00000/707AABC2-BD48-E511-86F4-02163E01267F.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/712/00000/92855E71-CF48-E511-8EB0-02163E012BA2.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/768/00000/3EA12D26-1049-E511-81E5-02163E014642.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/769/00000/8CBD7CF5-1849-E511-8D66-02163E0133CA.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/780/00000/E61D74A1-2949-E511-B5A9-02163E0121D5.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/785/00000/70BA055C-3E49-E511-9F83-02163E014717.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/790/00000/1E96E0E6-DA49-E511-A085-02163E011DBA.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/790/00000/20E9A637-B549-E511-AA58-02163E011A50.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/790/00000/309EBFAE-D349-E511-B366-02163E014125.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/790/00000/602E9016-C249-E511-84EB-02163E01559C.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/790/00000/64476921-CB49-E511-A948-02163E0129EE.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/790/00000/6C0A4392-D849-E511-B13B-02163E01266D.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/790/00000/94E81D99-D249-E511-94C1-02163E012647.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/790/00000/A497C6D2-B849-E511-8077-02163E01339E.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/790/00000/A6B9BCFF-D049-E511-A1CC-02163E013765.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/790/00000/A8401D68-D449-E511-89D8-02163E014360.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/790/00000/B0CF8495-D549-E511-8D10-02163E0143C8.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/790/00000/BE46CBA7-CF49-E511-9D19-02163E014200.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/790/00000/D83D6F9F-E149-E511-AE1C-02163E011E88.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/824/00000/1ED25134-354A-E511-AEB7-02163E013441.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/128F6535-324B-E511-AACD-02163E011D21.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/16D16F3F-324B-E511-B5CE-02163E011DFD.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/1A095A2D-324B-E511-B23D-02163E013558.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/3897AC4B-334B-E511-BF13-02163E01456D.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/3A524439-324B-E511-A28C-02163E011F5D.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/408EB52B-324B-E511-A245-02163E011B6A.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/540E9233-324B-E511-BBA5-02163E01248D.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/5463DD38-324B-E511-B45B-02163E011AC9.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/5EA0C43C-324B-E511-AD87-02163E0143D3.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/60B9232C-324B-E511-B49F-02163E0121C9.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/6AAF522F-324B-E511-AC33-02163E01357D.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/70611F32-324B-E511-9B94-02163E0120FF.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/72A10CF3-324B-E511-903C-02163E0140DC.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/760AA435-324B-E511-A9CE-02163E01186D.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/7691622C-324B-E511-9B31-02163E011DCA.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/76B1EB78-324B-E511-9E37-02163E012303.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/9E0A042B-324B-E511-9199-02163E01380A.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/AA5B162F-324B-E511-B0DC-02163E0135B0.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/B07F5732-324B-E511-8AC4-02163E0154D3.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/B677EC3F-324B-E511-B82B-02163E01282E.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/B803CF2D-384B-E511-BC3D-02163E01389C.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/BA8D8F32-324B-E511-B9FB-02163E0135D4.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/BC01484A-324B-E511-9BC0-02163E011F24.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/C0E4A730-324B-E511-90E3-02163E01343E.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/C8B37FB9-404B-E511-93C9-02163E014761.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/CC6CB539-324B-E511-9697-02163E011A41.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/D49FC93A-324B-E511-BD5A-02163E01364B.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/E0AC833A-324B-E511-9EEC-02163E014761.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/E6FB6332-324B-E511-AAC6-02163E0145BB.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/E8FDA438-324B-E511-ABFA-02163E01466E.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/EAF0A12D-324B-E511-8361-02163E0137E3.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/833/00000/F21A5D2C-324B-E511-8E32-02163E014796.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/852/00000/E46424F0-974B-E511-B5E2-02163E01213D.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/879/00000/20B268F2-9F4B-E511-A359-02163E0143AA.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/879/00000/F8E352F9-9F4B-E511-88EB-02163E015541.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/905/00000/18F65DA6-BA4B-E511-A2DB-02163E01279E.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/905/00000/1CD21CAD-BA4B-E511-A566-02163E0143A2.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/905/00000/204135A9-BA4B-E511-82FE-02163E011E91.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/905/00000/26E685A3-BA4B-E511-8A82-02163E012ABA.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/906/00000/1CBD178C-CD4B-E511-B61D-02163E014291.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/907/00000/C4A55346-E24B-E511-80E3-02163E013463.root', + #'/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/913/00000/00716CF9-EB4B-E511-BEA7-02163E0136EE.root', + '/store/data/Run2015C/Charmonium/AOD/PromptReco-v1/000/254/914/00000/FCED70C1-EC4B-E511-9676-02163E0142B5.root' + # DoubleMuon for Mu8 test + #'root://cms-xrd-global.cern.ch//store/data/Run2015C_25ns/DoubleMuon/AOD/05Oct2015-v1/50000/001DCCA1-0574-E511-9088-0025905B85D0.root' + ] else: raise RuntimeError, "Unknown CMSSW version %s" % os.environ['CMSSW_VERSION'] @@ -75,16 +209,26 @@ numtrack = cms.untracked.uint32(10), thresh = cms.untracked.double(0.25) ) +process.fastFilter = cms.Sequence(process.goodVertexFilter + process.noScraping) process.load("HLTrigger.HLTfilters.triggerResultsFilter_cfi") process.triggerResultsFilter.triggerConditions = cms.vstring( 'HLT_Mu*_L2Mu*' ) process.triggerResultsFilter.l1tResults = '' process.triggerResultsFilter.throw = True process.triggerResultsFilter.hltResults = cms.InputTag( "TriggerResults", "", "HLT" ) -process.HLTMu = process.triggerResultsFilter.clone(triggerConditions = [ 'HLT_Mu*_L2Mu*' ]) -process.HLTBoth = process.triggerResultsFilter.clone(triggerConditions = [ 'HLT_Mu*_L2Mu*', 'HLT_Mu*_Track*_Jpsi*' ]) - -process.fastFilter = cms.Sequence(process.goodVertexFilter + process.noScraping) +#process.HLTMu = process.triggerResultsFilter.clone(triggerConditions = ['HLT_Mu*_L2Mu*']) +#process.HLTBoth = process.triggerResultsFilter.clone(triggerConditions = ['HLT_Mu*_L2Mu*', 'HLT_Mu*_Track*_Jpsi*']) +process.HLTMu = process.triggerResultsFilter.clone(triggerConditions = [ 'HLT_Mu*_L2Mu*', 'HLT_Mu*' ]) # for Mu8 test +process.HLTBoth = process.triggerResultsFilter.clone(triggerConditions = [ 'HLT_Mu*_L2Mu*', 'HLT_Mu*_Track*_Jpsi*', 'HLT_Mu*' ]) # for Mu8 test +#process.HLTBoth_withDimuon = process.triggerResultsFilter.clone(triggerConditions = [ 'HLT_Mu*_L2Mu*', 'HLT_Mu*_Track*_Jpsi*', 'HLT_Mu*', 'HLT_Dimuon*' ]) +process.HLTBoth_withDimuon = process.triggerResultsFilter.clone(triggerConditions = [ 'HLT_Mu*_L2Mu*', 'HLT_Mu*_Track*_Jpsi*', 'HLT_Mu*', 'HLT_Dimuon*', 'HLT_Mu*_TkMu*' ]) # asked by Ilse + +## __ __ +## | \/ |_ _ ___ _ __ ___ +## | |\/| | | | |/ _ \| '_ \/ __| +## | | | | |_| | (_) | | | \__ \ +## |_| |_|\__,_|\___/|_| |_|___/ +## ## ==== Merge CaloMuons and Tracks into the collection of reco::Muons ==== from RecoMuon.MuonIdentification.calomuons_cfi import calomuons; process.mergedMuons = cms.EDProducer("CaloMuonMerger", @@ -103,25 +247,29 @@ ## ==== Trigger matching process.load("MuonAnalysis.MuonAssociators.patMuonsWithTrigger_cff") ## with some customization +#process.muonMatchHLTL2.maxDeltaR = 0.3 # Zoltan tuning - it was 0.5 # present in Zmumu +#process.muonMatchHLTL3.maxDeltaR = 0.1 # present in Zmumu from MuonAnalysis.MuonAssociators.patMuonsWithTrigger_cff import * changeRecoMuonInput(process, "mergedMuons") #useExtendedL1Match(process) #addHLTL1Passthrough(process) - from MuonAnalysis.TagAndProbe.common_variables_cff import * process.load("MuonAnalysis.TagAndProbe.common_modules_cff") process.tagMuons = cms.EDFilter("PATMuonSelector", src = cms.InputTag("patMuonsWithTrigger"), - cut = cms.string("(isGlobalMuon || numberOfMatchedStations > 1) && pt > 5 && !triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()"), + cut = cms.string("(isGlobalMuon || numberOfMatchedStations > 1) && pt > 7.5 && !triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()"), ) process.oneTag = cms.EDFilter("CandViewCountFilter", src = cms.InputTag("tagMuons"), minNumber = cms.uint32(1)) process.probeMuons = cms.EDFilter("PATMuonSelector", src = cms.InputTag("patMuonsWithTrigger"), - cut = cms.string("track.isNonnull && (!triggerObjectMatchesByCollection('hltMuTrackJpsiEffCtfTrackCands').empty() || !triggerObjectMatchesByCollection('hltMuTrackJpsiCtfTrackCands').empty() || !triggerObjectMatchesByCollection('hltL2MuonCandidates').empty())"), + #cut = cms.string("track.isNonnull && (!triggerObjectMatchesByCollection('hltMuTrackJpsiEffCtfTrackCands').empty() || !triggerObjectMatchesByCollection('hltMuTrackJpsiCtfTrackCands').empty() || !triggerObjectMatchesByCollection('hltL2MuonCandidates').empty())"), + #cut = cms.string("track.isNonnull && !triggerObjectMatchesByCollection('hltTracksIter').empty()"), + cut = cms.string("") # for Mu8 test + #cut = cms.string("track.isNonnull && !triggerObjectMatchesByCollection('hltL2MuonCandidates').empty()"), ) process.tpPairs = cms.EDProducer("CandViewShallowCloneCombiner", @@ -155,14 +303,12 @@ Acc_JPsi = cms.string("(abs(eta) <= 1.3 && pt > 3.3) || (1.3 < abs(eta) <= 2.2 && p > 2.9) || (2.2 < abs(eta) <= 2.4 && pt > 0.8)"), ), tagVariables = cms.PSet( - pt = cms.string('pt'), - eta = cms.string('eta'), - phi = cms.string('phi'), + KinematicVariables, nVertices = cms.InputTag("nverticesModule"), l1rate = cms.InputTag("l1rate"), bx = cms.InputTag("l1rate","bx"), ), - tagFlags = cms.PSet( + tagFlags = cms.PSet( HighPtTriggerFlags, HighPtTriggerFlagsDebug, LowPtTriggerFlagsPhysics, @@ -184,35 +330,77 @@ pairFlags = cms.PSet(), isMC = cms.bool(False), addRunLumiInfo = cms.bool(True), + allProbes = cms.InputTag("probeMuons"), # was missing ) process.load("MuonAnalysis.TagAndProbe.muon.tag_probe_muon_extraIso_cfi") process.tnpSimpleSequence = cms.Sequence( - process.tagMuons + - process.oneTag + - process.probeMuons + - process.tpPairs + - process.onePair + - process.muonDxyPVdzmin + - process.nverticesModule + - process.tagProbeSeparation + - process.computeCorrectedIso + - process.probeMultiplicity + - process.splitTrackTagger + - process.l1rate + + process.tagMuons * + process.oneTag * + process.probeMuons * + process.tpPairs * + process.onePair * + process.muonDxyPVdzmin * + process.nverticesModule * + process.tagProbeSeparation * + process.computeCorrectedIso * + process.probeMultiplicity * + process.splitTrackTagger * + process.l1rate * process.tpTree ) process.tagAndProbe = cms.Path( - process.fastFilter + - process.HLTBoth + + process.fastFilter * + process.HLTBoth * process.mergedMuons * process.patMuonsWithTriggerSequence * process.tnpSimpleSequence ) +# OnePair tree for vertexing filter efficiency +process.tpTreeOnePair = process.tpTree.clone( + arbitration = "OnePair", + # a few L1,L2,L3 variables in Ilse's file + pairVariables = cms.PSet( + process.tpTree.pairVariables, + rapidity = cms.string("rapidity"), + absrapidity = cms.string("abs(rapidity)"), + #prescaled = cms.InputTag("tagProbeSeparation", "prescaled"), + #VtxProb = cms.InputTag("tagProbeSeparation", "VtxProb"), + #VtxCosPA = cms.InputTag("tagProbeSeparation", "VtxCosPA"), + #VtxLxy = cms.InputTag("tagProbeSeparation", "VtxLxy"), + #VtxLxySig = cms.InputTag("tagProbeSeparation", "VtxLxySig"), + #VtxL3d = cms.InputTag("tagProbeSeparation", "VtxL3d"), + DCA = cms.InputTag("tagProbeSeparation", "DCA"), + ), +) + +process.tnpSimpleSequenceOnePair = cms.Sequence( + process.tagMuons * + process.probeMuons * + process.tpPairs * + process.muonDxyPVdzmin * + process.nverticesModule * + process.tagProbeSeparation * + process.computeCorrectedIso * + process.probeMultiplicity * + process.splitTrackTagger * + process.l1rate * + process.tpTreeOnePair +) + +process.tagAndProbeOnePair = cms.Path( + process.fastFilter * + process.HLTBoth_withDimuon * + process.mergedMuons * + process.patMuonsWithTriggerSequence * + process.tnpSimpleSequenceOnePair +) + + ## _____ _ _ ## |_ _| __ __ _ ___| | _(_)_ __ __ _ ## | || '__/ _` |/ __| |/ / | '_ \ / _` | @@ -237,17 +425,23 @@ src = cms.InputTag("patMuonsWithTriggerSta"), cut = cms.string("outerTrack.isNonnull && !triggerObjectMatchesByCollection('hltL2MuonCandidates').empty()"), ) - process.tpPairsSta = process.tpPairs.clone(decay = "tagMuons@+ probeMuonsSta@-", cut = "2 < mass < 5") process.onePairSta = cms.EDFilter("CandViewCountFilter", src = cms.InputTag("tpPairsSta"), minNumber = cms.uint32(1)) +process.staToTkMatch.maxDeltaR = 0.3 +process.staToTkMatch.maxDeltaPtRel = 2. +process.staToTkMatchNoJPsi.maxDeltaR = 0.3 +process.staToTkMatchNoJPsi.maxDeltaPtRel = 2. + process.load("MuonAnalysis.TagAndProbe.tracking_reco_info_cff") process.tpTreeSta = process.tpTree.clone( tagProbePairs = "tpPairsSta", + #arbitration = "OneProbe", # present in Zmumu variables = cms.PSet( KinematicVariables, + #StaOnlyVariables, # present in Zmumu ## track matching variables tk_deltaR = cms.InputTag("staToTkMatch","deltaR"), tk_deltaEta = cms.InputTag("staToTkMatch","deltaEta"), @@ -257,38 +451,62 @@ tk_deltaEta_NoBestJPsi = cms.InputTag("staToTkMatchNoBestJPsi","deltaEta"), ), flags = cms.PSet( + #Mu5_L2Mu3_Jpsi_L2 = LowPtTriggerFlagsEfficienciesProbe.Mu5_L2Mu3_Jpsi_L2, + LowPtTriggerFlagsPhysics, + LowPtTriggerFlagsEfficienciesProbe, outerValidHits = cms.string("outerTrack.numberOfValidHits > 0"), - Mu5_L2Mu3_Jpsi_L2 = LowPtTriggerFlagsEfficienciesProbe.Mu5_L2Mu3_Jpsi_L2, TM = cms.string("isTrackerMuon"), Glb = cms.string("isGlobalMuon"), + Tk = cms.string("track.isNonnull"), + #StaTkSameCharge = cms.string("outerTrack.isNonnull && innerTrack.isNonnull && (outerTrack.charge == innerTrack.charge)"), # present in Zmumu ), tagVariables = cms.PSet( - pt = cms.string("pt"), - eta = cms.string("eta"), - phi = cms.string("phi"), + KinematicVariables, nVertices = cms.InputTag("nverticesModule"), - combRelIso = cms.string("(isolationR03.emEt + isolationR03.hadEt + isolationR03.sumPt)/pt"), - chargedHadIso04 = cms.string("pfIsolationR04().sumChargedHadronPt"), - neutralHadIso04 = cms.string("pfIsolationR04().sumNeutralHadronEt"), - photonIso04 = cms.string("pfIsolationR04().sumPhotonEt"), - combRelIsoPF04dBeta = IsolationVariables.combRelIsoPF04dBeta, + #combRelIso = cms.string("(isolationR03.emEt + isolationR03.hadEt + isolationR03.sumPt)/pt"), + #chargedHadIso04 = cms.string("pfIsolationR04().sumChargedHadronPt"), + #neutralHadIso04 = cms.string("pfIsolationR04().sumNeutralHadronEt"), + #photonIso04 = cms.string("pfIsolationR04().sumPhotonEt"), + #combRelIsoPF04dBeta = IsolationVariables.combRelIsoPF04dBeta, + #l1rate = cms.InputTag("l1rate"), # uncommented in "add bx information to data tree #18" + #bx = cms.InputTag("l1rate","bx"), ), tagFlags = cms.PSet( - Mu5_L2Mu3_Jpsi_MU = LowPtTriggerFlagsEfficienciesTag.Mu5_L2Mu3_Jpsi_MU, + #Mu5_L2Mu3_Jpsi_MU = LowPtTriggerFlagsEfficienciesTag.Mu5_L2Mu3_Jpsi_MU, + LowPtTriggerFlagsEfficienciesTag, ), - pairVariables = cms.PSet(), + pairVariables = cms.PSet( + dz = cms.string("daughter(0).vz - daughter(1).vz"), + pt = cms.string("pt"), + # + dphiVtxTimesQ = cms.InputTag("tagProbeStaSeparation", "dphiVtxTimesQ"), + drM1 = cms.InputTag("tagProbeStaSeparation", "drM1"), + dphiM1 = cms.InputTag("tagProbeStaSeparation", "dphiM1"), + distM1 = cms.InputTag("tagProbeStaSeparation", "distM1"), + drM2 = cms.InputTag("tagProbeStaSeparation", "drM2"), + dphiM2 = cms.InputTag("tagProbeStaSeparation", "dphiM2"), + distM2 = cms.InputTag("tagProbeStaSeparation", "distM2"), + drVtx = cms.InputTag("tagProbeStaSeparation", "drVtx"), + probeMultiplicity = cms.InputTag("probeStaMultiplicity"), + # + rapidity = cms.string("rapidity"), + deltaR = cms.string("deltaR(daughter(0).eta, daughter(0).phi, daughter(1).eta, daughter(1).phi)"), + ), pairFlags = cms.PSet(), + allProbes = "probeMuonsSta", # was missing w.r.t. MC ) process.tnpSimpleSequenceSta = cms.Sequence( - process.tagMuons + - process.oneTag + - process.probeMuonsSta + - process.tpPairsSta + - process.onePairSta + - process.nverticesModule + - process.staToTkMatchSequenceJPsi + - process.l1rate + + process.tagMuons * + process.oneTag * + process.probeMuonsSta * + process.tpPairsSta * + process.onePairSta * + process.nverticesModule * + process.tagProbeStaSeparation * + process.probeStaMultiplicity * + process.staToTkMatchSequenceJPsi * + process.l1rate * process.tpTreeSta ) @@ -302,7 +520,7 @@ process.tpTreeSta.tagVariables.nLogErrPix = cms.InputTag("tkLogErrors","pixelSteps") process.tpTreeSta.tagVariables.nLogErrAny = cms.InputTag("tkLogErrors","anyStep") -if True: # turn on for tracking efficiency from RECO/AOD + earlyGeneralTracks +if False: # turn on for tracking efficiency from RECO/AOD + earlyGeneralTracks process.tracksNoMuonSeeded = cms.EDFilter("TrackSelector", src = cms.InputTag("generalTracks"), cut = cms.string(" || ".join("isAlgoInMask('%s')" % a for a in [ @@ -331,15 +549,14 @@ process.tpTreeSta.variables.tk0_deltaEta_NoBestJPsi = cms.InputTag("staToTkMatchNoBestJPsi0","deltaEta") process.tagAndProbeSta = cms.Path( - process.fastFilter + - process.HLTMu + - process.muonsSta + - process.patMuonsWithTriggerSequenceSta + + process.fastFilter * + process.HLTMu * + process.muonsSta * + process.patMuonsWithTriggerSequenceSta * process.tnpSimpleSequenceSta ) - if False: # turn on for tracking efficiency using L1 seeds process.probeL1 = cms.EDFilter("CandViewSelector", src = cms.InputTag("l1extraParticles"), @@ -381,6 +598,12 @@ eta = cms.string("eta"), phi = cms.string("phi"), nVertices = cms.InputTag("nverticesModule"), + #ERICA:to check if for the JPsi is valid + #combRelIso = cms.string("(isolationR03.emEt + isolationR03.hadEt + isolationR03.sumPt)/pt"), + #chargedHadIso04 = cms.string("pfIsolationR04().sumChargedHadronPt"), + #neutralHadIso04 = cms.string("pfIsolationR04().sumNeutralHadronEt"), + #photonIso04 = cms.string("pfIsolationR04().sumPhotonEt"), + #combRelIsoPF04dBeta = IsolationVariables.combRelIsoPF04dBeta, ), pairVariables = cms.PSet( #nJets30 = cms.InputTag("njets30ModuleSta"), @@ -392,23 +615,86 @@ allProbes = cms.InputTag("probeL1"), ) process.tagAndProbeTkL1 = cms.Path( - process.fastFilter + - process.probeL1 + - process.tpPairsTkL1 + - process.preTkMatchSequenceJPsi + - process.l1ToTkMatch + - process.l1ToTkMatchNoJPsi + process.l1ToTkMatchNoBestJPsi + - process.l1ToTkMatch0 + - process.l1ToTkMatchNoJPsi0 + process.l1ToTkMatchNoBestJPsi0 + + process.fastFilter * + process.probeL1 * + process.tpPairsTkL1 * + process.preTkMatchSequenceJPsi * + process.l1ToTkMatch * process.l1ToTkMatchNoJPsi * process.l1ToTkMatchNoBestJPsi * + process.l1ToTkMatch0 * process.l1ToTkMatchNoJPsi0 * process.l1ToTkMatchNoBestJPsi0 * + #process.nverticesModule * process.l1rate * # added in "add bx information to data tree #18" process.tpTreeL1 ) +## _____ _ ____ _ +## | ___|_ _| | _____ | _ \ __ _| |_ ___ ___ +## | |_ / _` | |/ / _ \ | |_) / _` | __/ _ \/ __| +## | _| (_| | < __/ | _ < (_| | || __/\__ \ +## |_| \__,_|_|\_\___| |_| \_\__,_|\__\___||___/ +## +## +#process.load("MuonAnalysis.TagAndProbe.fakerate_all_cff") +# +#process.fakeRateJetPlusProbeTree = process.tpTree.clone( +# tagProbePairs = 'jetPlusProbe', +# arbitration = 'None', +# tagVariables = process.JetPlusProbeTagVariables, +# tagFlags = cms.PSet(), +# pairVariables = cms.PSet(deltaPhi = cms.string("deltaPhi(daughter(0).phi, daughter(1).phi)")), +# pairFlags = cms.PSet(), +# isMC = False, # MC matches not in place for FR yet +#) +#process.fakeRateWPlusProbeTree = process.tpTree.clone( +# tagProbePairs = 'wPlusProbe', +# arbitration = 'None', +# tagVariables = process.WPlusProbeTagVariables, +# tagFlags = cms.PSet(), +# pairVariables = cms.PSet(), +# pairFlags = cms.PSet(SameSign = cms.string('daughter(0).daughter(0).charge == daughter(1).charge')), +# isMC = False, # MC matches not in place for FR yet +#) +#process.fakeRateZPlusProbeTree = process.tpTree.clone( +# tagProbePairs = 'zPlusProbe', +# arbitration = 'None', +# tagVariables = process.ZPlusProbeTagVariables, +# tagFlags = cms.PSet(), +# pairVariables = cms.PSet(), +# pairFlags = cms.PSet(), +# isMC = False, # MC matches not in place for FR yet +#) +# +#process.fakeRateJetPlusProbe = cms.Path( +# process.fastFilter * +# process.mergedMuons * process.patMuonsWithTriggerSequence * +# process.tagMuons * process.probeMuons * process.extraProbeVariablesSeq * +# process.jetPlusProbeSequence * +# process.fakeRateJetPlusProbeTree +#) +#process.fakeRateWPlusProbe = cms.Path( +# process.fastFilter * +# process.mergedMuons * process.patMuonsWithTriggerSequence * +# process.tagMuons * process.probeMuons * process.extraProbeVariablesSeq * +# process.wPlusProbeSequence * +# process.fakeRateWPlusProbeTree +#) +#process.fakeRateZPlusProbe = cms.Path( +# process.fastFilter * +# process.mergedMuons * process.patMuonsWithTriggerSequence * +# process.tagMuons * process.probeMuons * process.extraProbeVariablesSeq * +# process.zPlusProbeSequence * +# process.fakeRateZPlusProbeTree +#) + process.schedule = cms.Schedule( process.tagAndProbe, process.tagAndProbeSta, + process.tagAndProbeOnePair, #process.tagAndProbeTkL1 + #process.fakeRateJetPlusProbe, + #process.fakeRateWPlusProbe, + #process.fakeRateZPlusProbe, ) + process.RandomNumberGeneratorService.tkTracksNoJPsi = cms.PSet( initialSeed = cms.untracked.uint32(81) ) process.RandomNumberGeneratorService.tkTracksNoJPsi0 = cms.PSet( initialSeed = cms.untracked.uint32(81) ) process.RandomNumberGeneratorService.tkTracksNoBestJPsi = cms.PSet( initialSeed = cms.untracked.uint32(81) ) diff --git a/test/jpsi/tp_from_aod_simple_MC.py b/test/jpsi/tp_from_aod_simple_MC.py index 8c57db7cea7..6ee9391c7c9 100644 --- a/test/jpsi/tp_from_aod_simple_MC.py +++ b/test/jpsi/tp_from_aod_simple_MC.py @@ -5,20 +5,25 @@ process.load('Configuration.StandardSequences.Services_cff') process.load('FWCore.MessageService.MessageLogger_cfi') process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True) ) -process.MessageLogger.cerr.FwkReport.reportEvery = 10 +process.MessageLogger.cerr.FwkReport.reportEvery = 100 process.source = cms.Source("PoolSource", - fileNames = cms.untracked.vstring(), -) -process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(20) ) + fileNames = cms.untracked.vstring(), + skipEvents = cms.untracked.uint32( 0 ), + ) + +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32( -1 ) + # 355KB in 6' on 1k events, ?KB in 100' on 20k events for the official 25ns BPH MC + # 1.3Mb in 2h30' on 9 files, 660Kb in 70' on 50K events, 405Kb in 15' on 10K events for the official 50ns BPH MC + # 4.8Mb in 1h on 84597 (=-1) events for the MC from Muon POG + ) + process.load('Configuration.StandardSequences.GeometryRecoDB_cff') process.load('Configuration.StandardSequences.MagneticField_cff') process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_condDBv2_cff') process.load("Configuration.StandardSequences.Reconstruction_cff") -# process.Tracer = cms.Service('Tracer') - import os if "CMSSW_5_3_" in os.environ['CMSSW_VERSION']: process.GlobalTag.globaltag = cms.string('START53_V14::All') @@ -35,16 +40,55 @@ '/store/relval/CMSSW_5_2_3/RelValJpsiMM/GEN-SIM-RECO/START52_V5-v1/0043/304746CC-097A-E111-A71F-003048FFD76E.root', ] elif "CMSSW_7_4_" in os.environ['CMSSW_VERSION']: - from Configuration.AlCa.GlobalTag_condDBv2 import GlobalTag - process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '') + #process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '') + process.GlobalTag.globaltag = cms.string('MCRUN2_74_V9') process.source.fileNames = [ - 'file:data2015/RelValBoostedJPsi_7_3_0_pre1/Reference_PU35/RECO_1.root', - ] + # MC from Muon POG + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_JPsiPt7_13TeV-pythia8/AODSIM/Asympt25ns_MCRUN2_74_V9-v1/60000/183C894F-C008-E511-AFB5-0025905A606A.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_JPsiPt7_13TeV-pythia8/AODSIM/Asympt25ns_MCRUN2_74_V9-v1/60000/3615E328-D708-E511-B2F9-003048FFD752.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_JPsiPt7_13TeV-pythia8/AODSIM/Asympt25ns_MCRUN2_74_V9-v1/60000/561562A2-D708-E511-B06E-0025905B8576.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_JPsiPt7_13TeV-pythia8/AODSIM/Asympt25ns_MCRUN2_74_V9-v1/60000/6E145BC4-D708-E511-99CF-002481E94BCA.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_JPsiPt7_13TeV-pythia8/AODSIM/Asympt25ns_MCRUN2_74_V9-v1/60000/7E81F237-C808-E511-90F4-00261894383E.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_JPsiPt7_13TeV-pythia8/AODSIM/Asympt25ns_MCRUN2_74_V9-v1/60000/888136A8-D708-E511-823C-002590A2CD68.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_JPsiPt7_13TeV-pythia8/AODSIM/Asympt25ns_MCRUN2_74_V9-v1/70000/08135FA6-6E0C-E511-9A97-002618943948.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_JPsiPt7_13TeV-pythia8/AODSIM/Asympt25ns_MCRUN2_74_V9-v1/70000/283882C6-860C-E511-AB1C-0026189438C9.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_JPsiPt7_13TeV-pythia8/AODSIM/Asympt25ns_MCRUN2_74_V9-v1/70000/76BD42C8-FE08-E511-BAB9-0025905A60DE.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_JPsiPt7_13TeV-pythia8/AODSIM/Asympt25ns_MCRUN2_74_V9-v1/70000/9AA472CE-FE08-E511-BEE3-0025905B8582.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_JPsiPt7_13TeV-pythia8/AODSIM/Asympt25ns_MCRUN2_74_V9-v1/70000/C81001CF-860C-E511-A5B7-0025905A6088.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_JPsiPt7_13TeV-pythia8/AODSIM/Asympt25ns_MCRUN2_74_V9-v1/70000/F87F150E-710C-E511-9F33-0025905A60BC.root' + # + # BPH MC + # 50 ns + #'file:./BECF20C9-CE27-E511-AD2B-02163E013B74.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_OniaMuonFilter_TuneCUEP8M1_13TeV-pythia8/AODSIM/Asympt50ns_MCRUN2_74_V9A-v2/80000/EE4E7950-D726-E511-8751-001E67A404B0.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_OniaMuonFilter_TuneCUEP8M1_13TeV-pythia8/AODSIM/Asympt50ns_MCRUN2_74_V9A-v2/20000/0072AAD1-7028-E511-8448-0025905A612E.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_OniaMuonFilter_TuneCUEP8M1_13TeV-pythia8/AODSIM/Asympt50ns_MCRUN2_74_V9A-v2/20000/00C6C123-0428-E511-92F2-D4AE526A091F.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_OniaMuonFilter_TuneCUEP8M1_13TeV-pythia8/AODSIM/Asympt50ns_MCRUN2_74_V9A-v2/20000/026710B4-5F27-E511-B9D3-B8CA3A70A520.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_OniaMuonFilter_TuneCUEP8M1_13TeV-pythia8/AODSIM/Asympt50ns_MCRUN2_74_V9A-v2/20000/02D22B1C-D626-E511-8850-002590D60026.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_OniaMuonFilter_TuneCUEP8M1_13TeV-pythia8/AODSIM/Asympt50ns_MCRUN2_74_V9A-v2/20000/04C3F72A-D126-E511-B12F-00238BBD7594.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_OniaMuonFilter_TuneCUEP8M1_13TeV-pythia8/AODSIM/Asympt50ns_MCRUN2_74_V9A-v2/20000/08FCBA7F-D126-E511-99C8-0025905964A6.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_OniaMuonFilter_TuneCUEP8M1_13TeV-pythia8/AODSIM/Asympt50ns_MCRUN2_74_V9A-v2/20000/0A4AB9B0-3827-E511-8277-0025905B857C.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_OniaMuonFilter_TuneCUEP8M1_13TeV-pythia8/AODSIM/Asympt50ns_MCRUN2_74_V9A-v2/20000/0C175E3E-E627-E511-ADEB-6C3BE5B58000.root', + # 25 ns + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_OniaMuonFilter_TuneCUEP8M1_13TeV-pythia8/AODSIM/Asympt25ns_MCRUN2_74_V9-v2/20000/004604F1-3827-E511-AC59-0CC47A13D110.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_OniaMuonFilter_TuneCUEP8M1_13TeV-pythia8/AODSIM/Asympt25ns_MCRUN2_74_V9-v2/20000/00AF527B-3827-E511-A8CB-002618FDA216.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_OniaMuonFilter_TuneCUEP8M1_13TeV-pythia8/AODSIM/Asympt25ns_MCRUN2_74_V9-v2/20000/062F705F-9727-E511-84ED-0025905A60BE.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_OniaMuonFilter_TuneCUEP8M1_13TeV-pythia8/AODSIM/Asympt25ns_MCRUN2_74_V9-v2/20000/06BB1C40-4727-E511-8677-003048344A94.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_OniaMuonFilter_TuneCUEP8M1_13TeV-pythia8/AODSIM/Asympt25ns_MCRUN2_74_V9-v2/20000/087B11AE-5427-E511-AD8A-00259048A462.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_OniaMuonFilter_TuneCUEP8M1_13TeV-pythia8/AODSIM/Asympt25ns_MCRUN2_74_V9-v2/20000/08A91A07-7927-E511-B91C-0025905A48FC.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_OniaMuonFilter_TuneCUEP8M1_13TeV-pythia8/AODSIM/Asympt25ns_MCRUN2_74_V9-v2/20000/0C691B12-532D-E511-9F91-0025905B8590.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_OniaMuonFilter_TuneCUEP8M1_13TeV-pythia8/AODSIM/Asympt25ns_MCRUN2_74_V9-v2/20000/0E1A8498-6627-E511-8BDF-00238BBD75D8.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_OniaMuonFilter_TuneCUEP8M1_13TeV-pythia8/AODSIM/Asympt25ns_MCRUN2_74_V9-v2/20000/0E95776B-6627-E511-BEAC-001E67A42BA2.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_OniaMuonFilter_TuneCUEP8M1_13TeV-pythia8/AODSIM/Asympt25ns_MCRUN2_74_V9-v2/20000/0EC5741B-9C28-E511-81CD-B499BAABF064.root', + # 50 ns problem + #'dcap://dcache-cms-dcap.desy.de//pnfs/desy.de/cms/tier2/store/mc/RunIISpring15DR74/JpsiToMuMu_OniaMuonFilter_TuneCUEP8M1_13TeV-pythia8/AODSIM/Asympt50ns_MCRUN2_74_V9A-v2/80000/96B24D6D-0C27-E511-B9BB-003048FFD720.root', + #'/store/mc/RunIISpring15DR74/JpsiToMuMu_OniaMuonFilter_TuneCUEP8M1_13TeV-pythia8/AODSIM/Asympt50ns_MCRUN2_74_V9A-v2/80000/96B24D6D-0C27-E511-B9BB-003048FFD720.root', + # 25 ns problem with pair_probemultiplicity + '/store/mc/RunIISpring15DR74/JpsiToMuMu_OniaMuonFilter_TuneCUEP8M1_13TeV-pythia8/AODSIM/Asympt25ns_MCRUN2_74_V9-v2/30000/52DA6630-6527-E511-8382-0025905C42A8.root' + ] else: raise RuntimeError, "Unknown CMSSW version %s" % os.environ['CMSSW_VERSION'] -## SELECT WHAT DATASET YOU'RE RUNNING ON -#TRIGGER="SingleMu" -TRIGGER="Any" + ## ==== Fast Filters ==== process.goodVertexFilter = cms.EDFilter("VertexSelector", @@ -66,8 +110,12 @@ process.triggerResultsFilter.throw = True #process.triggerResultsFilter.hltResults = cms.InputTag( "TriggerResults", "", "REDIGI38XPU" ) process.triggerResultsFilter.hltResults = cms.InputTag( "TriggerResults", "", "HLT" ) -process.HLTMu = process.triggerResultsFilter.clone(triggerConditions = [ 'HLT_Mu*_L2Mu*' ]) -process.HLTBoth = process.triggerResultsFilter.clone(triggerConditions = [ 'HLT_Mu*_L2Mu*', 'HLT_Mu*_Track*_Jpsi*' ]) +process.HLTMu = process.triggerResultsFilter.clone(triggerConditions = ['HLT_Mu*_L2Mu*']) +process.HLTBoth = process.triggerResultsFilter.clone(triggerConditions = ['HLT_Mu*_L2Mu*', 'HLT_Mu*_Track*_Jpsi*']) +#process.HLTMu = process.triggerResultsFilter.clone(triggerConditions = ['HLT_Mu*_L2Mu*', 'HLT_Mu*']) # for Mu8 test +#process.HLTBoth = process.triggerResultsFilter.clone(triggerConditions = ['HLT_Mu*_L2Mu*', 'HLT_Mu*_Track*_Jpsi*', 'HLT_Mu*']) # for Mu8 test +#process.HLTBoth_withDimuon = process.triggerResultsFilter.clone(triggerConditions = [ 'HLT_Mu*_L2Mu*', 'HLT_Mu*_Track*_Jpsi*', 'HLT_Mu*', 'HLT_Dimuon*' ]) +process.HLTBoth_withDimuon = process.triggerResultsFilter.clone(triggerConditions = [ 'HLT_Mu*_L2Mu*', 'HLT_Mu*_Track*_Jpsi*', 'HLT_Mu*', 'HLT_Dimuon*', 'HLT_Mu*_TkMu*' ]) # asked by Ilse ## __ __ ## | \/ |_ _ ___ _ __ ___ @@ -93,6 +141,8 @@ ## ==== Trigger matching process.load("MuonAnalysis.MuonAssociators.patMuonsWithTrigger_cff") ## with some customization +#process.muonMatchHLTL2.maxDeltaR = 0.3 # Zoltan tuning - it was 0.5 # present in Zmumu +#process.muonMatchHLTL3.maxDeltaR = 0.1 # present in Zmumu from MuonAnalysis.MuonAssociators.patMuonsWithTrigger_cff import * changeRecoMuonInput(process, "mergedMuons") #useExtendedL1Match(process) #MM no idea what the sequence did, not available @@ -104,32 +154,27 @@ process.tagMuons = cms.EDFilter("PATMuonSelector", src = cms.InputTag("patMuonsWithTrigger"), - cut = cms.string("(isGlobalMuon || numberOfMatchedStations > 1) && pt > 5 && !triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()"), + cut = cms.string("(isGlobalMuon || numberOfMatchedStations > 1) && pt > 7.5 && !triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()"), ) -if TRIGGER != "SingleMu": - process.tagMuons.cut = ("pt > 6 && (isGlobalMuon || isTrackerMuon) && isPFMuon "+ - " && !triggerObjectMatchesByCollection('hltL3MuonCandidates').empty()"+ - " && pfIsolationR04().sumChargedHadronPt/pt < 0.2") - - process.oneTag = cms.EDFilter("CandViewCountFilter", src = cms.InputTag("tagMuons"), minNumber = cms.uint32(1)) process.probeMuons = cms.EDFilter("PATMuonSelector", src = cms.InputTag("patMuonsWithTrigger"), - cut = cms.string("track.isNonnull && (!triggerObjectMatchesByCollection('hltMuTrackJpsiEffCtfTrackCands').empty() || !triggerObjectMatchesByCollection('hltMuTrackJpsiCtfTrackCands').empty() || !triggerObjectMatchesByCollection('hltL2MuonCandidates').empty())"), + #cut = cms.string("track.isNonnull && (!triggerObjectMatchesByCollection('hltMuTrackJpsiEffCtfTrackCands').empty() || !triggerObjectMatchesByCollection('hltMuTrackJpsiCtfTrackCands').empty() || !triggerObjectMatchesByCollection('hltL2MuonCandidates').empty())"), # Run-I + cut = cms.string("track.isNonnull && !triggerObjectMatchesByCollection('hltTracksIter').empty()"), + #cut = cms.string("track.isNonnull") # for Mu8 test ) process.tpPairs = cms.EDProducer("CandViewShallowCloneCombiner", cut = cms.string('2.8 < mass < 3.4 && abs(daughter(0).vz - daughter(1).vz) < 1'), - decay = cms.string('tagMuons@+ probeMuons@-') ) process.onePair = cms.EDFilter("CandViewCountFilter", src = cms.InputTag("tpPairs"), minNumber = cms.uint32(1)) process.tagMuonsMCMatch = cms.EDProducer("MCMatcher", # cut on deltaR, deltaPt/Pt; pick best by deltaR src = cms.InputTag("tagMuons"), # RECO objects to match - matched = cms.InputTag("goodGenMuons"), # mc-truth particle collection + matched = cms.InputTag("goodGenMuonsFromJpsi"), # mc-truth particle collection mcPdgId = cms.vint32(13), # one or more PDG ID (13 = muon); absolute values (see below) checkCharge = cms.bool(False), # True = require RECO and MC objects to have the same charge mcStatus = cms.vint32(1), # PYTHIA status code (1 = stable, 2 = shower, 3 = hard scattering) @@ -138,10 +183,14 @@ resolveAmbiguities = cms.bool(True), # Forbid two RECO objects to match to the same GEN object resolveByMatchQuality = cms.bool(True), # False = just match input in order; True = pick lowest deltaR pair first ) -process.probeMuonsMCMatch = process.tagMuonsMCMatch.clone(src = "probeMuons") +process.probeMuonsMCMatch = process.tagMuonsMCMatch.clone(src = "probeMuons", maxDeltaR = 0.3, maxDPtRel = 1.0, resolveAmbiguities = False, resolveByMatchQuality = False) from MuonAnalysis.TagAndProbe.muon.tag_probe_muon_extraIso_cff import ExtraIsolationVariables +#process.load("MuonAnalysis.TagAndProbe.mvaIsoVariables_cff") +#from MuonAnalysis.TagAndProbe.mvaIsoVariables_cff import MVAIsoVariablesPlain, MVAIsoVariablesPlainTag +#process.load("MuonAnalysis.TagAndProbe.radialIso_cfi") + process.tpTree = cms.EDAnalyzer("TagProbeFitTreeProducer", # choice of tag and probe pairs, and arbitration tagProbePairs = cms.InputTag("tpPairs"), @@ -165,14 +214,12 @@ Acc_JPsi = cms.string("(abs(eta) <= 1.3 && pt > 3.3) || (1.3 < abs(eta) <= 2.2 && p > 2.9) || (2.2 < abs(eta) <= 2.4 && pt > 0.8)"), ), tagVariables = cms.PSet( - pt = cms.string('pt'), - eta = cms.string('eta'), - phi = cms.string('phi'), + KinematicVariables, nVertices = cms.InputTag("nverticesModule"), l1rate = cms.InputTag("l1rate"), bx = cms.InputTag("l1rate","bx"), ), - tagFlags = cms.PSet( + tagFlags = cms.PSet( HighPtTriggerFlags, HighPtTriggerFlagsDebug, LowPtTriggerFlagsPhysics, @@ -201,38 +248,82 @@ checkMotherInUnbiasEff = cms.bool(True), allProbes = cms.InputTag("probeMuons"), ) -if TRIGGER != "SingleMu": - for K,F in MuonIDFlags.parameters_().iteritems(): - setattr(process.tpTree.tagFlags, K, F) process.load("MuonAnalysis.TagAndProbe.muon.tag_probe_muon_extraIso_cfi") +#process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAny_cfi") +#process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAlong_cfi") +#process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorOpposite_cfi") +#process.load("RecoMuon.DetLayers.muonDetLayerGeometry_cfi") + process.tnpSimpleSequence = cms.Sequence( - process.goodGenMuons + - process.tagMuons * process.tagMuonsMCMatch + - process.oneTag + - process.probeMuons * process.probeMuonsMCMatch + - process.tpPairs + - process.onePair + - process.muonDxyPVdzmin + - process.nverticesModule + - process.tagProbeSeparation + - process.computeCorrectedIso + - process.probeMultiplicity + - process.splitTrackTagger + - process.l1rate + + process.goodGenMuonsFromJpsi * + process.tagMuons * process.tagMuonsMCMatch * + process.oneTag * + process.probeMuons * process.probeMuonsMCMatch * + process.tpPairs * + process.onePair * + process.muonDxyPVdzmin * + process.nverticesModule * + process.tagProbeSeparation * + process.computeCorrectedIso * + process.probeMultiplicity * + process.splitTrackTagger * + process.l1rate * process.tpTree ) process.tagAndProbe = cms.Path( - process.fastFilter + - #process.HLTBoth + + process.fastFilter * + process.HLTBoth * process.mergedMuons * process.patMuonsWithTriggerSequence * process.tnpSimpleSequence ) +# OnePair tree for vertexing filter efficiency +process.tpTreeOnePair = process.tpTree.clone( + arbitration = "OnePair", + # a few L1,L2,L3 variables in Ilse's file + pairVariables = cms.PSet( + process.tpTree.pairVariables, + rapidity = cms.string("rapidity"), + absrapidity = cms.string("abs(rapidity)"), + #prescaled = cms.InputTag("tagProbeSeparation", "prescaled"), # throw Exception Message: Principal::getByToken: Found zero products matching all criteria\n Looking for type: edm::ValueMap\n Looking for module label: tagProbeSeparation\n Looking for productInstanceName: prescaled + #VtxProb = cms.InputTag("tagProbeSeparation", "VtxProb"), + #VtxCosPA = cms.InputTag("tagProbeSeparation", "VtxCosPA"), # throw Exception Message: Principal::getByToken: Found zero products matching all criteria\n Looking for type: edm::ValueMap\n Looking for module label: tagProbeSeparation\n Looking for productInstanceName: VtxCosPA + #VtxLxy = cms.InputTag("tagProbeSeparation", "VtxLxy"), # throw Exception Message: Principal::getByToken: Found zero products matching all criteria\n Looking for type: edm::ValueMap\n Looking for module label: tagProbeSeparation\n Looking for productInstanceName: VtxLxy + #VtxLxySig = cms.InputTag("tagProbeSeparation", "VtxLxySig"), + #VtxL3d = cms.InputTag("tagProbeSeparation", "VtxL3d"), # throw Exception Message: Principal::getByToken: Found zero products matching all criteria\n Looking for type: edm::ValueMap\n Looking for module label: tagProbeSeparation\n Looking for productInstanceName: VtxL3d + DCA = cms.InputTag("tagProbeSeparation", "DCA"), + ), +) + +process.tnpSimpleSequenceOnePair = cms.Sequence( + process.goodGenMuonsFromJpsi * + process.tagMuons * process.tagMuonsMCMatch * + process.probeMuons * process.probeMuonsMCMatch * + process.tpPairs * + process.muonDxyPVdzmin * + process.nverticesModule * + process.tagProbeSeparation * + process.computeCorrectedIso * + process.probeMultiplicity * + process.splitTrackTagger * + process.l1rate * + process.tpTreeOnePair +) + +process.tagAndProbeOnePair = cms.Path( + process.fastFilter * + process.HLTBoth_withDimuon * + process.mergedMuons * + process.patMuonsWithTriggerSequence * + process.tnpSimpleSequenceOnePair +) + + ## _____ _ _ ## |_ _| __ __ _ ___| | _(_)_ __ __ _ ## | || '__/ _` |/ __| |/ / | '_ \ / _` | @@ -255,18 +346,26 @@ ## Define probes and T&P pairs process.probeMuonsSta = cms.EDFilter("PATMuonSelector", src = cms.InputTag("patMuonsWithTriggerSta"), - cut = cms.string("outerTrack.isNonnull && !triggerObjectMatchesByCollection('hltL2MuonCandidates').empty()"), + cut = cms.string("outerTrack.isNonnull && !triggerObjectMatchesByCollection('hltL2MuonCandidates').empty()"), ) process.probeMuonsMCMatchSta = process.tagMuonsMCMatch.clone(src = "probeMuonsSta") - process.tpPairsSta = process.tpPairs.clone(decay = "tagMuons@+ probeMuonsSta@-", cut = "2 < mass < 5") process.onePairSta = cms.EDFilter("CandViewCountFilter", src = cms.InputTag("tpPairsSta"), minNumber = cms.uint32(1)) +process.staToTkMatch.maxDeltaR = 0.3 +process.staToTkMatch.maxDeltaPtRel = 2. +process.staToTkMatchNoJPsi.maxDeltaR = 0.3 +process.staToTkMatchNoJPsi.maxDeltaPtRel = 2. + +#process.load("MuonAnalysis.TagAndProbe.tracking_reco_info_cff") + process.tpTreeSta = process.tpTree.clone( tagProbePairs = "tpPairsSta", + #arbitration = "OneProbe", # present in Zmumu variables = cms.PSet( KinematicVariables, + #StaOnlyVariables, # present in Zmumu ## track matching variables tk_deltaR = cms.InputTag("staToTkMatch","deltaR"), tk_deltaEta = cms.InputTag("staToTkMatch","deltaEta"), @@ -276,56 +375,86 @@ tk_deltaEta_NoBestJPsi = cms.InputTag("staToTkMatchNoBestJPsi","deltaEta"), ), flags = cms.PSet( + #Mu5_L2Mu3_Jpsi_L2 = LowPtTriggerFlagsEfficienciesProbe.Mu5_L2Mu3_Jpsi_L2, + LowPtTriggerFlagsEfficienciesProbe, outerValidHits = cms.string("outerTrack.numberOfValidHits > 0"), - Mu5_L2Mu3_Jpsi_L2 = LowPtTriggerFlagsEfficienciesProbe.Mu5_L2Mu3_Jpsi_L2, TM = cms.string("isTrackerMuon"), Glb = cms.string("isGlobalMuon"), + Tk = cms.string("track.isNonnull"), + #StaTkSameCharge = cms.string("outerTrack.isNonnull && innerTrack.isNonnull && (outerTrack.charge == innerTrack.charge)"), # present in Zmumu ), tagVariables = cms.PSet( - pt = cms.string("pt"), - eta = cms.string("eta"), - phi = cms.string("phi"), + KinematicVariables, nVertices = cms.InputTag("nverticesModule"), - combRelIso = cms.string("(isolationR03.emEt + isolationR03.hadEt + isolationR03.sumPt)/pt"), - chargedHadIso04 = cms.string("pfIsolationR04().sumChargedHadronPt"), - neutralHadIso04 = cms.string("pfIsolationR04().sumNeutralHadronEt"), - photonIso04 = cms.string("pfIsolationR04().sumPhotonEt"), - combRelIsoPF04dBeta = IsolationVariables.combRelIsoPF04dBeta, + #combRelIso = cms.string("(isolationR03.emEt + isolationR03.hadEt + isolationR03.sumPt)/pt"), + #chargedHadIso04 = cms.string("pfIsolationR04().sumChargedHadronPt"), + #neutralHadIso04 = cms.string("pfIsolationR04().sumNeutralHadronEt"), + #photonIso04 = cms.string("pfIsolationR04().sumPhotonEt"), + #combRelIsoPF04dBeta = IsolationVariables.combRelIsoPF04dBeta, ), tagFlags = cms.PSet( - Mu5_L2Mu3_Jpsi_MU = LowPtTriggerFlagsEfficienciesTag.Mu5_L2Mu3_Jpsi_MU, - ), - pairVariables = cms.PSet(), + #Mu5_L2Mu3_Jpsi_MU = LowPtTriggerFlagsEfficienciesTag.Mu5_L2Mu3_Jpsi_MU, + LowPtTriggerFlagsEfficienciesTag, + ), + pairVariables = cms.PSet( + pt = cms.string("pt"), + # + dphiVtxTimesQ = cms.InputTag("tagProbeStaSeparation", "dphiVtxTimesQ"), + drM1 = cms.InputTag("tagProbeStaSeparation", "drM1"), + dphiM1 = cms.InputTag("tagProbeStaSeparation", "dphiM1"), + distM1 = cms.InputTag("tagProbeStaSeparation", "distM1"), + drM2 = cms.InputTag("tagProbeStaSeparation", "drM2"), + dphiM2 = cms.InputTag("tagProbeStaSeparation", "dphiM2"), + distM2 = cms.InputTag("tagProbeStaSeparation", "distM2"), + drVtx = cms.InputTag("tagProbeStaSeparation", "drVtx"), + dz = cms.string("daughter(0).vz - daughter(1).vz"), + probeMultiplicity = cms.InputTag("probeStaMultiplicity"), + # + rapidity = cms.string("rapidity"), + deltaR = cms.string("deltaR(daughter(0).eta, daughter(0).phi, daughter(1).eta, daughter(1).phi)"), + ), pairFlags = cms.PSet(), allProbes = "probeMuonsSta", probeMatches = "probeMuonsMCMatchSta", ) process.tnpSimpleSequenceSta = cms.Sequence( - process.tagMuons * process.tagMuonsMCMatch + - process.oneTag + - process.probeMuonsSta * process.probeMuonsMCMatchSta + - process.tpPairsSta + - process.onePairSta + - process.nverticesModule + - process.staToTkMatchSequenceJPsi + - process.l1rate + + process.tagMuons * process.tagMuonsMCMatch * + process.oneTag * + process.probeMuonsSta * process.probeMuonsMCMatchSta * + process.tpPairsSta * + process.onePairSta * + process.nverticesModule * + process.tagProbeStaSeparation * + process.probeStaMultiplicity * + process.staToTkMatchSequenceJPsi * + process.l1rate * process.tpTreeSta ) process.RandomNumberGeneratorService.tkTracksNoJPsi = cms.PSet( initialSeed = cms.untracked.uint32(81) ) process.RandomNumberGeneratorService.tkTracksNoBestJPsi = cms.PSet( initialSeed = cms.untracked.uint32(81) ) -if True: # turn on for tracking efficiency from RECO/AOD + earlyGeneralTracks - process.pCutTracks0 = process.pCutTracks.clone(src = 'earlyGeneralTracks') +if True: # turn on for tracking efficiency from RECO/AOD + earlyGeneralTracks + process.tracksNoMuonSeeded = cms.EDFilter("TrackSelector", + src = cms.InputTag("generalTracks"), + #cut = cms.string(" || ".join("isAlgoInMask('%s')" % a for a in [ + #'initialStep', 'lowPtTripletStep', 'pixelPairStep', 'detachedTripletStep', + #'mixedTripletStep', 'pixelLessStep', 'tobTecStep', 'jetCoreRegionalStep'] ) ) # not working + cut = cms.string("") + ) + process.pCutTracks0 = process.pCutTracks.clone(src = 'tracksNoMuonSeeded') + #process.pCutTracks0 = process.pCutTracks.clone(src = 'earlyGeneralTracks') # not working + #process.pCutTracks0 = process.pCutTracks.clone() # an alternative to 'tracksNoMuonSeeded' process.tkTracks0 = process.tkTracks.clone(src = 'pCutTracks0') process.tkTracksNoJPsi0 = process.tkTracksNoJPsi.clone(src = 'tkTracks0') process.tkTracksNoBestJPsi0 = process.tkTracksNoBestJPsi.clone(src = 'tkTracks0') process.RandomNumberGeneratorService.tkTracksNoJPsi0 = cms.PSet( initialSeed = cms.untracked.uint32(81) ) process.RandomNumberGeneratorService.tkTracksNoBestJPsi0 = cms.PSet( initialSeed = cms.untracked.uint32(81) ) - process.preTkMatchSequenceJPsi.replace( + process.preTkMatchSequenceJPsi.replace( process.tkTracksNoJPsi, process.tkTracksNoJPsi + - process.pCutTracks0 + process.tkTracks0 + process.tkTracksNoJPsi0 +process.tkTracksNoBestJPsi0 + process.tracksNoMuonSeeded + process.pCutTracks0 + process.tkTracks0 + process.tkTracksNoJPsi0 + process.tkTracksNoBestJPsi0 + #process.pCutTracks0 + process.tkTracks0 + process.tkTracksNoJPsi0 + process.tkTracksNoBestJPsi0 ) process.staToTkMatch0 = process.staToTkMatch.clone(matched = 'tkTracks0') process.staToTkMatchNoJPsi0 = process.staToTkMatchNoJPsi.clone(matched = 'tkTracksNoJPsi0') @@ -341,18 +470,21 @@ process.tpTreeSta.variables.tk0_deltaEta_NoBestJPsi = cms.InputTag("staToTkMatchNoBestJPsi0","deltaEta") process.tagAndProbeSta = cms.Path( - process.fastFilter + -# process.HLTMu + - process.muonsSta + - process.patMuonsWithTriggerSequenceSta + + process.fastFilter * + process.HLTMu * + process.muonsSta * + process.patMuonsWithTriggerSequenceSta * process.tnpSimpleSequenceSta ) + if True: # turn on for tracking efficiency using gen particles as probe process.probeGen = cms.EDFilter("GenParticleSelector", - src = cms.InputTag("genParticles"), - cut = cms.string("abs(pdgId) == 13 && pt > 2 && abs(eta) < 2.4 && numberOfMothers == 1 && motherRef.pdgId == 443"), - ) + #src = cms.InputTag("genParticles"), + #cut = cms.string("abs(pdgId) == 13 && pt > 2 && abs(eta) < 2.4 && numberOfMothers == 1 && motherRef.pdgId == 443"), + src = cms.InputTag("goodGenMuonsFromJpsi"), + cut = cms.string(""), + ) process.tpPairsTkGen = process.tpPairs.clone(decay = "tagMuons@+ probeGen@-", cut = '2 < mass < 5') process.genToTkMatch = process.staToTkMatch.clone(src = "probeGen", srcTrack="none") process.genToTkMatchNoJPsi = process.staToTkMatchNoJPsi.clone(src = "probeGen", srcTrack="none") @@ -360,16 +492,24 @@ process.genToTkMatch0 = process.staToTkMatch0.clone(src = "probeGen", srcTrack="none") process.genToTkMatchNoJPsi0 = process.staToTkMatchNoJPsi0.clone(src = "probeGen", srcTrack="none") process.genToTkMatchNoBestJPsi0 = process.staToTkMatchNoBestJPsi0.clone(src = "probeGen", srcTrack="none") + # + process.genToProbeMuonsMatch = process.softIDToGenMatch.clone(objectSelection = cms.string("")) + BMuQual_noTMOST = "track.hitPattern.trackerLayersWithMeasurement > 5 && track.hitPattern.pixelLayersWithMeasurement > 0 " + " && abs(dB) < 0.3 && abs(track.dz) < 20.0 " + " && track.quality('highPurity') " + process.genToSoftIDNoTMOSTMatch = process.softIDToGenMatch.clone(objectSelection = cms.string(BMuQual_noTMOST)) + BMuQual = BMuQual_noTMOST + " && muonID('TMOneStationTight')" + process.genToSoftIDMatch = process.softIDToGenMatch.clone(objectSelection = cms.string(BMuQual)) + # process.probeMuonsMCMatchGen = process.tagMuonsMCMatch.clone(src = "probeGen") + # process.tpTreeGen = process.tpTreeSta.clone( tagProbePairs = "tpPairsTkGen", arbitration = "OneProbe", variables = cms.PSet( - KinematicVariables, + KinematicVariables, ## track matching variables tk_deltaR = cms.InputTag("genToTkMatch","deltaR"), tk_deltaEta = cms.InputTag("genToTkMatch","deltaEta"), - tk_deltaR_NoJPsi = cms.InputTag("genToTkMatchNoJPsi","deltaR"), + tk_deltaR_NoJPsi = cms.InputTag("genToTkMatchNoJPsi","deltaR"), tk_deltaEta_NoJPsi = cms.InputTag("genToTkMatchNoJPsi","deltaEta"), tk_deltaR_NoBestJPsi = cms.InputTag("genToTkMatchNoBestJPsi","deltaR"), tk_deltaEta_NoBestJPsi = cms.InputTag("genToTkMatchNoBestJPsi","deltaEta"), @@ -380,41 +520,51 @@ tk0_deltaEta_NoJPsi = cms.InputTag("genToTkMatchNoJPsi0","deltaEta"), tk0_deltaR_NoBestJPsi = cms.InputTag("genToTkMatchNoBestJPsi0","deltaR"), tk0_deltaEta_NoBestJPsi = cms.InputTag("genToTkMatchNoBestJPsi0","deltaEta"), - ), + ## softID matching variables + mu_deltaR = cms.InputTag("genToProbeMuonsMatch","deltaR"), + mu_deltaEta = cms.InputTag("genToProbeMuonsMatch","deltaEta"), + muSoftIDNoTMOST_deltaR = cms.InputTag("genToSoftIDNoTMOSTMatch","deltaR"), + muSoftIDNoTMOST_deltaEta = cms.InputTag("genToSoftIDNoTMOSTMatch","deltaEta"), + muSoftID_deltaR = cms.InputTag("genToSoftIDMatch","deltaR"), + muSoftID_deltaEta = cms.InputTag("genToSoftIDMatch","deltaEta"), + ), flags = cms.PSet( - ), + ), tagVariables = cms.PSet( pt = cms.string("pt"), eta = cms.string("eta"), phi = cms.string("phi"), nVertices = cms.InputTag("nverticesModule"), - combRelIso = cms.string("(isolationR03.emEt + isolationR03.hadEt + isolationR03.sumPt)/pt"), - chargedHadIso04 = cms.string("pfIsolationR04().sumChargedHadronPt"), - neutralHadIso04 = cms.string("pfIsolationR04().sumNeutralHadronEt"), - photonIso04 = cms.string("pfIsolationR04().sumPhotonEt"), - combRelIsoPF04dBeta = IsolationVariables.combRelIsoPF04dBeta, - ), + ), pairVariables = cms.PSet( #nJets30 = cms.InputTag("njets30ModuleSta"), dz = cms.string("daughter(0).vz - daughter(1).vz"), - pt = cms.string("pt"), + pt = cms.string("pt"), rapidity = cms.string("rapidity"), - deltaR = cms.string("deltaR(daughter(0).eta, daughter(0).phi, daughter(1).eta, daughter(1).phi)"), - ), + deltaR = cms.string("deltaR(daughter(0).eta, daughter(0).phi, daughter(1).eta, daughter(1).phi)"), + ), pairFlags = cms.PSet(), allProbes = cms.InputTag("probeGen"), probeMatches = cms.InputTag("probeMuonsMCMatchGen"), - ) - process.tagAndProbeTkGen = cms.Path( - process.fastFilter + - process.probeGen + - process.tpPairsTkGen + - process.preTkMatchSequenceJPsi + - process.genToTkMatch + process.genToTkMatchNoJPsi + process.genToTkMatchNoBestJPsi + - process.genToTkMatch0 + process.genToTkMatchNoJPsi0 + process.genToTkMatchNoBestJPsi0 + - process.probeMuonsMCMatchGen + + ) + + process.tagAndProbeTkGen = cms.Path( + process.goodGenMuonsFromJpsi * # added by me + process.fastFilter * + process.mergedMuons * process.patMuonsWithTriggerSequence * process.tagMuons * process.tagMuonsMCMatch * # added by me + process.probeMuons * # added by me for softIDToGenMatch + process.probeGen * + process.tpPairsTkGen * + process.nverticesModule * + process.preTkMatchSequenceJPsi * + process.genToTkMatch * process.genToTkMatchNoJPsi * process.genToTkMatchNoBestJPsi * + process.genToTkMatch0 * process.genToTkMatchNoJPsi0 * process.genToTkMatchNoBestJPsi0 * + process.genToProbeMuonsMatch * process.genToSoftIDNoTMOSTMatch * process.genToSoftIDMatch * + process.probeMuonsMCMatchGen * + process.nverticesModule * # added by gpetruc: https://github.com/cms-analysis/MuonAnalysis-TagAndProbe/pull/21/files#diff-0 process.tpTreeGen - ) + ) + if True: # turn on for tracking efficiency using L1 seeds process.probeL1 = cms.EDFilter("CandViewSelector", @@ -458,6 +608,12 @@ eta = cms.string("eta"), phi = cms.string("phi"), nVertices = cms.InputTag("nverticesModule"), + #ERICA:to check if for the JPsi is valid + #combRelIso = cms.string("(isolationR03.emEt + isolationR03.hadEt + isolationR03.sumPt)/pt"), + #chargedHadIso04 = cms.string("pfIsolationR04().sumChargedHadronPt"), + #neutralHadIso04 = cms.string("pfIsolationR04().sumNeutralHadronEt"), + #photonIso04 = cms.string("pfIsolationR04().sumPhotonEt"), + #combRelIsoPF04dBeta = IsolationVariables.combRelIsoPF04dBeta, ), pairVariables = cms.PSet( #nJets30 = cms.InputTag("njets30ModuleSta"), @@ -470,15 +626,16 @@ probeMatches = cms.InputTag("probeMuonsMCMatchL1"), ) process.tagAndProbeTkL1 = cms.Path( - process.fastFilter + - process.probeL1 + - process.tpPairsTkL1 + - process.preTkMatchSequenceJPsi + - process.l1ToTkMatch + - process.l1ToTkMatchNoJPsi + process.l1ToTkMatchNoBestJPsi + - process.l1ToTkMatch0 + - process.l1ToTkMatchNoJPsi0 + process.l1ToTkMatchNoBestJPsi0 + - process.probeMuonsMCMatchL1 + + process.fastFilter * + process.probeL1 * + process.tpPairsTkL1 * + process.preTkMatchSequenceJPsi * + process.l1ToTkMatch * + process.l1ToTkMatchNoJPsi * process.l1ToTkMatchNoBestJPsi * + process.l1ToTkMatch0 * + process.l1ToTkMatchNoJPsi0 * process.l1ToTkMatchNoBestJPsi0 * + process.probeMuonsMCMatchL1 * + process.nverticesModule * # added by gpetruc: https://github.com/cms-analysis/MuonAnalysis-TagAndProbe/pull/21/files#diff-0 process.tpTreeL1 ) @@ -488,7 +645,7 @@ ## | _| (_| | < __/ | _ < (_| | || __/\__ \ ## |_| \__,_|_|\_\___| |_| \_\__,_|\__\___||___/ ## -## +## #process.load("MuonAnalysis.TagAndProbe.fakerate_all_cff") # #process.fakeRateJetPlusProbeTree = process.tpTree.clone( @@ -520,38 +677,43 @@ #) # #process.fakeRateJetPlusProbe = cms.Path( -# process.fastFilter + -# process.mergedMuons * process.patMuonsWithTriggerSequence + -# process.tagMuons + process.probeMuons + process.extraProbeVariablesSeq + -# process.jetPlusProbeSequence + +# process.fastFilter * +# process.mergedMuons * process.patMuonsWithTriggerSequence * +# process.tagMuons * process.probeMuons * process.extraProbeVariablesSeq * +# process.jetPlusProbeSequence * # process.fakeRateJetPlusProbeTree #) #process.fakeRateWPlusProbe = cms.Path( -# process.fastFilter + -# process.mergedMuons * process.patMuonsWithTriggerSequence + -# process.tagMuons + process.probeMuons + process.extraProbeVariablesSeq + -# process.wPlusProbeSequence + +# process.fastFilter * +# process.mergedMuons * process.patMuonsWithTriggerSequence * +# process.tagMuons * process.probeMuons * process.extraProbeVariablesSeq * +# process.wPlusProbeSequence * # process.fakeRateWPlusProbeTree #) #process.fakeRateZPlusProbe = cms.Path( -# process.fastFilter + -# process.mergedMuons * process.patMuonsWithTriggerSequence + -# process.tagMuons + process.probeMuons + process.extraProbeVariablesSeq + -# process.zPlusProbeSequence + +# process.fastFilter * +# process.mergedMuons * process.patMuonsWithTriggerSequence * +# process.tagMuons * process.probeMuons * process.extraProbeVariablesSeq * +# process.zPlusProbeSequence * # process.fakeRateZPlusProbeTree #) process.schedule = cms.Schedule( - process.tagAndProbe, - process.tagAndProbeSta, - process.tagAndProbeTkGen, - process.tagAndProbeTkL1, - #process.fakeRateJetPlusProbe, - #process.fakeRateWPlusProbe, - #process.fakeRateZPlusProbe, -) + process.tagAndProbe, + process.tagAndProbeSta, + process.tagAndProbeOnePair, + process.tagAndProbeTkGen, + #process.tagAndProbeTkL1, + #process.fakeRateJetPlusProbe, + #process.fakeRateWPlusProbe, + #process.fakeRateZPlusProbe, + ) + -process.TFileService = cms.Service("TFileService", fileName = cms.string("tnpJPsi_MC_prova.root")) +process.TFileService = cms.Service("TFileService", + #fileName = cms.string("tnpJPsi_MC.root") + fileName = cms.string("tnpJPsi_officialBPHMC.root") + ) # use this if you want to compute also 'unbiased' efficiencies, # - you have to remove all filters diff --git a/test/jpsi/yields.C b/test/jpsi/yields.C new file mode 100644 index 00000000000..438f86a85e2 --- /dev/null +++ b/test/jpsi/yields.C @@ -0,0 +1,114 @@ +{ + TFile *outputFile = new TFile("./TnP_yield_Charmonium_PromptReco_50ns_first47ipb.root","RECREATE") ; + //TFile *inputFile = TFile::Open("/afs/cern.ch/user/m/msharma/public/tnpJPsi_Data_246908-251883_JSON_MuonPhys_v2.root") ; + TFile *inputFile = TFile::Open("/afs/cern.ch/work/l/lecriste/TnP/recipe_740/CMSSW_7_4_0/src/MuonAnalysis/TagAndProbe/test/jpsi/tnpJPsi_Charmonium_PromptReco_50ns_first47ipb.root") ; + // + //TFile *outputFile = new TFile("./TnP_yield_Charmonium_PromptReco_50ns.root","RECREATE") ; + //TFile *inputFile = TFile::Open("/afs/cern.ch/work/l/lecriste/TnP/recipe_740/CMSSW_7_4_0/src/MuonAnalysis/TagAndProbe/test/jpsi/tnpJPsi_Charmonium_PromptReco_50ns.root") ; + + if (!inputFile) return ; + TTree *fitter_tree = (TTree*)inputFile->Get("tpTree/fitter_tree"); + + TString selection = "pair_drM1>0.5 && pair_probeMultiplicity==1" ; + + TString prefix = "./" ; + prefix = "/afs/cern.ch/work/l/lecriste/www/TnP/" ; + TString uploadFile = "index.php" ; + + + TString dir = prefix+"plots/data/246908-251883_JSON_MuonPhys_v2/tpTree/Soft2012/pt_abseta/yields/" ; + //TString dir = prefix+"plots/data/246908-255031_JSON_MuonPhys_v2/tpTree/Soft2012/pt_abseta/yields/" ; + + gSystem->mkdir(dir, false); + if ( prefix.EqualTo("/afs/cern.ch/work/l/lecriste/www/TnP/") ) + gSystem->CopyFile(prefix+uploadFile, dir+uploadFile, true); + + TString hName = "hMass_total" ; + fitter_tree->Draw("mass>>"+hName) ; + TH1F *hMass = (TH1F*)gDirectory->Get( hName ); + Int_t total_tree_events = hMass->GetEntries() ; + cout <<"hMass->GetEntries() = " <SaveAs(dir+hName+".png") ; + + hName = "hMass_sel" ; + fitter_tree->Draw("mass>>"+hName, selection) ; + TH1F *hMass_sel = (TH1F*)gDirectory->Get( hName ); + Int_t eventsSel = hMass_sel->GetEntries() ; + cout <<"hMass_sel->GetEntries() = " <SaveAs(dir+hName+".png") ; + + Float_t absetaBin[] = {0.0, 0.9, 1.2, 2.1, 2.4}; + Float_t ptBin[] = {2.0, 2.5, 3.0, 3.5, 4.0, 4.75, 5.5, 7.5, 10.0, 20.0, 40.0} ; + //Float_t ptBin[] = {2.0, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 4.5, 5.0, 6.0, 8.0, 10.0, 15.0, 20.0, 30.0, 40.0} ; + + Int_t nBinsAbseta = sizeof(absetaBin)/sizeof(absetaBin[0]); + Int_t nBinsPt = sizeof(ptBin)/sizeof(ptBin[0]); + + vector ptBinLabel (nBinsPt-1,"ptBinLabel not set!"); + vector ptBinCenter (nBinsPt-1,-1); + vector ptBinEvts_sel (nBinsPt-1,-1); + + //TString path[] = {"Mu7p5_Track2","Mu7p5_Track3p5","Mu7p5_Track7"} ; + TString path[] = {"Mu7p5_Track2","Mu7p5_Track7"} ; + Int_t nPath = sizeof(path)/sizeof(path[0]); + vector< vector > ptBinEvts_path (nPath); + + ptBinEvts_path.resize(nPath); + + for (Int_t iAbsetaBin = 0; iAbsetaBin < nBinsAbseta-1; ++iAbsetaBin) { + TString labelAbseta = TString::Format("%.2gto%.2g",absetaBin[iAbsetaBin],absetaBin[iAbsetaBin+1]) ; + labelAbseta.ReplaceAll(".","p") ; + + for (Int_t iPtBin = 0; iPtBin < nBinsPt-1; ++iPtBin) { + TString labelPt = TString::Format("%.3gto%.3g",ptBin[iPtBin],ptBin[iPtBin+1]) ; + labelPt.ReplaceAll(".","p") ; + ptBinLabel[iPtBin] = labelPt ; + + ptBinCenter[iPtBin] = (ptBin[iPtBin]+ptBin[iPtBin+1])/2 ; + + hName = "hMass_sel_pt" ; hName.Append( labelPt ) ; + hName.Append( "__abseta" ) ; hName.Append( labelAbseta ) ; + TString cutPt = TString::Format("pt > %.3g && pt < %.3g",ptBin[iPtBin],ptBin[iPtBin+1]) ; + TString cutAbseta = TString::Format("abseta > %.2g && abseta < %.2g",absetaBin[iAbsetaBin],absetaBin[iAbsetaBin+1]) ; + fitter_tree->Draw("mass>>"+hName, selection+" && "+cutPt+" && "+cutAbseta) ; + TH1F *hMass_sel_ptBin_absetaBin = (TH1F*)gDirectory->Get( hName ); + ptBinEvts_sel[iPtBin] = hMass_sel_ptBin_absetaBin->GetEntries() ; + //hMass_sel_ptBin->SaveAs(dir+hName+".png") ; + + for (Int_t iPath = 0; iPath < nPath; ++iPath) { + hName.Append( "_"+path[iPath] ) ; + TString cutPath = "tag_"+path[iPath]+"_Jpsi_MU && "+path[iPath]+"_Jpsi_TK" ; + fitter_tree->Draw("mass>>"+hName, selection+" && "+cutPt+" && "+cutAbseta+" && "+cutPath) ; + TH1F *hMass_sel_ptBin_absetaBin_path = (TH1F*)gDirectory->Get( hName ); + //ptBinEvts_path[iPath].push_back( hMass_sel_ptBin_absetaBin_path->GetEntries() ) ; + ptBinEvts_path[iPath].resize(nBinsPt-1); + ptBinEvts_path[iPath][iPtBin] = hMass_sel_ptBin_absetaBin_path->GetEntries() ; + } + } + + outputFile->cd() ; + + TGraph* pT_yields = new TGraph( nBinsPt-1, &ptBinCenter[0], &ptBinEvts_sel[0]); + pT_yields->SetNameTitle("pT_yields__abseta"+labelAbseta,"selection yields for |#eta| from"+labelAbseta+";muon p_{T} [GeV]") ; + pT_yields->Draw("AL*"); + pT_yields->GetXaxis()->SetMoreLogLabels(); + gPad->SetLogx() ; + gPad->SetGrid() ; + gPad->SaveAs(dir+pT_yields->GetName()+".png") ; + pT_yields->Write() ; + + vector< TGraph* > pT_yields_path (nPath,0); + for (Int_t iPath = 0; iPath < nPath; ++iPath) { + pT_yields_path[iPath] = new TGraph( nBinsPt-1, &ptBinCenter[0], &ptBinEvts_path[iPath][0]); + pT_yields_path[iPath]->SetNameTitle("pT_yields_"+path[iPath]+"__abseta"+labelAbseta,path[iPath]+" yields for |#eta| from"+labelAbseta+";muon p_{T} [GeV]") ; + pT_yields_path[iPath]->Draw("AL*"); + pT_yields_path[iPath]->GetXaxis()->SetMoreLogLabels(); + gPad->SetLogx() ; + gPad->SetGrid() ; + gPad->SaveAs(dir+pT_yields_path[iPath]->GetName()+".png") ; + pT_yields_path[iPath]->Write() ; + } + + } + +}