Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:24:15

0001 import FWCore.ParameterSet.Config as cms
0002 
0003 process = cms.Process("TagProbe")
0004 
0005 ######### EXAMPLE CFG 
0006 ###  A simplified version of the Muon T&P used for the J/Psi October Excercise in 2009
0007 ###  Requires MuonAnalysis/MuonAssociators V01-02-00 (or later, for the MatcherUsingTracks)
0008 ###           MuonAnalysis/TagAndProbe     V06-00-00 (or later, for the MatchedCandidateSelector)
0009 ###  The input file has been produced with MuonAnalysis/TagAndProbe/test/skim/skimJPsi_cfg.py
0010 
0011 process.load('FWCore.MessageService.MessageLogger_cfi')
0012 process.options   = cms.untracked.PSet( wantSummary = cms.untracked.bool(True) )
0013 process.MessageLogger.cerr.FwkReport.reportEvery = 100
0014 
0015 process.source = cms.Source("PoolSource", 
0016     fileNames = cms.untracked.vstring(
0017         'file:/afs/cern.ch/user/g/gpetrucc/scratch0/huntForRedOctober/CMSSW_3_1_3/src/JPsiMuMu_Skim.root'
0018     )
0019 )
0020 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) )    
0021 
0022 process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi")
0023 process.load("Configuration.StandardSequences.MagneticField_cff")
0024 process.load("Configuration.StandardSequences.GeometryDB_cff")
0025 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
0026 process.load("Geometry.CommonTopologies.globalTrackingGeometry_cfi")
0027 process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAny_cfi")
0028 process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAlong_cfi")
0029 process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorOpposite_cfi")
0030 process.GlobalTag.globaltag = cms.string( autoCond[ 'phase1_2022_realistic' ] )
0031 
0032 ##    ____                   _____               _      ____            _               
0033 ##   | __ )  __ _ _ __ ___  |_   _| __ __ _  ___| | __ |  _ \ _ __ ___ | |__   ___  ___ 
0034 ##   |  _ \ / _` | '__/ _ \   | || '__/ _` |/ __| |/ / | |_) | '__/ _ \| '_ \ / _ \/ __|
0035 ##   | |_) | (_| | | |  __/   | || | | (_| | (__|   <  |  __/| | | (_) | |_) |  __/\__ \
0036 ##   |____/ \__,_|_|  \___|   |_||_|  \__,_|\___|_|\_\ |_|   |_|  \___/|_.__/ \___||___/
0037 ##                                                                                      
0038 ##   
0039 TRACK_CUTS="track.numberOfValidHits >= 10 && track.normalizedChi2 < 5 && abs(track.d0) < 2 && abs(track.dz) < 30"
0040 process.betterTracks = cms.EDFilter("TrackSelector",
0041     src = cms.InputTag("goodTracks"),
0042     cut = cms.string(TRACK_CUTS.replace("track.","")),
0043 )
0044 process.tkTracks  = cms.EDProducer("ConcreteChargedCandidateProducer", 
0045     src  = cms.InputTag("betterTracks"),      
0046     particleType = cms.string("mu+"),
0047 ) 
0048 process.tkProbes = cms.EDProducer("CandViewRefSelector",
0049     src = cms.InputTag("tkTracks"),
0050     cut = cms.string("pt > 3 && abs(eta) < 2.4"),
0051 )
0052 
0053 ##    ____  _                  _    _    _                    ____            _               
0054 ##   / ___|| |_ __ _ _ __   __| |  / \  | | ___  _ __   ___  |  _ \ _ __ ___ | |__   ___  ___ 
0055 ##   \___ \| __/ _` | '_ \ / _` | / _ \ | |/ _ \| '_ \ / _ \ | |_) | '__/ _ \| '_ \ / _ \/ __|
0056 ##    ___) | || (_| | | | | (_| |/ ___ \| | (_) | | | |  __/ |  __/| | | (_) | |_) |  __/\__ \
0057 ##   |____/ \__\__,_|_| |_|\__,_/_/   \_\_|\___/|_| |_|\___| |_|   |_|  \___/|_.__/ \___||___/
0058 ##                                                                                            
0059 ##   
0060 process.staTracks = cms.EDProducer("ConcreteChargedCandidateProducer", 
0061     src  = cms.InputTag("standAloneMuons","UpdatedAtVtx"), 
0062     particleType = cms.string("mu+"),
0063 )
0064 process.staProbes = cms.EDProducer("CandViewRefSelector",
0065     src = cms.InputTag("staTracks"),
0066     cut = cms.string("pt > 3 && abs(eta) < 2.4"),
0067 )
0068 
0069 ##    __  __                     ____            _                                 _   _____               
0070 ##   |  \/  |_   _  ___  _ __   |  _ \ _ __ ___ | |__   ___  ___    __ _ _ __   __| | |_   _|_ _  __ _ ___ 
0071 ##   | |\/| | | | |/ _ \| '_ \  | |_) | '__/ _ \| '_ \ / _ \/ __|  / _` | '_ \ / _` |   | |/ _` |/ _` / __|
0072 ##   | |  | | |_| | (_) | | | | |  __/| | | (_) | |_) |  __/\__ \ | (_| | | | | (_| |   | | (_| | (_| \__ \
0073 ##   |_|  |_|\__,_|\___/|_| |_| |_|   |_|  \___/|_.__/ \___||___/  \__,_|_| |_|\__,_|   |_|\__,_|\__, |___/
0074 ##                                                                                               |___/     
0075 ##   
0076 PASS_HLT = "!triggerObjectMatchesByPath('%s').empty()" % ("HLT_Mu3",);
0077 process.tagMuons = cms.EDFilter("PATMuonRefSelector",
0078     src = cms.InputTag("patMuons"),
0079     cut = cms.string("isGlobalMuon && pt > 3 && abs(eta) < 2.4 && " + TRACK_CUTS + " && " +PASS_HLT ), 
0080 )
0081 process.glbMuons = cms.EDFilter("PATMuonRefSelector",
0082     src = cms.InputTag("patMuons"),
0083     cut = cms.string("isGlobalMuon && "+TRACK_CUTS), 
0084 )
0085 process.glbProbes = cms.EDFilter("PATMuonRefSelector",
0086     src = cms.InputTag("patMuons"), # can't use glbMuons as source, as RefSelectors can't be chained :-/
0087     cut = cms.string("isGlobalMuon && pt > 3 && abs(eta) < 2.1 && " + TRACK_CUTS), # 2.1, as we want to use it for trigger!
0088 )
0089 
0090 
0091 process.allTagsAndProbes = cms.Sequence(
0092     process.tagMuons +
0093     process.betterTracks * process.tkTracks * process.tkProbes +
0094     process.staTracks * process.staProbes +
0095     process.glbMuons * process.glbProbes 
0096 )
0097 
0098 ##    ____               _               ____            _                   __  __         ___ ____  
0099 ##   |  _ \ __ _ ___ ___(_)_ __   __ _  |  _ \ _ __ ___ | |__   ___  ___ _  |  \/  |_   _  |_ _|  _ \ 
0100 ##   | |_) / _` / __/ __| | '_ \ / _` | | |_) | '__/ _ \| '_ \ / _ \/ __(_) | |\/| | | | |  | || | | |
0101 ##   |  __/ (_| \__ \__ \ | | | | (_| | |  __/| | | (_) | |_) |  __/\__ \_  | |  | | |_| |  | || |_| |
0102 ##   |_|   \__,_|___/___/_|_| |_|\__, | |_|   |_|  \___/|_.__/ \___||___(_) |_|  |_|\__,_| |___|____/ 
0103 ##                               |___/                                                                
0104 ##   
0105 process.tkToGlbMatch = cms.EDProducer("MatcherUsingTracks",
0106     src     = cms.InputTag("tkTracks"), # all tracks are available for matching
0107     matched = cms.InputTag("glbMuons"), # to all global muons
0108     algorithm = cms.string("byDirectComparison"), # check that they
0109     srcTrack = cms.string("tracker"),             # have the same 
0110     srcState = cms.string("atVertex"),            # tracker track
0111     matchedTrack = cms.string("tracker"),         # can't check ref
0112     matchedState = cms.string("atVertex"),        # because of the
0113     maxDeltaR        = cms.double(0.01),          # embedding.
0114     maxDeltaLocalPos = cms.double(0.01),
0115     maxDeltaPtRel    = cms.double(0.01),
0116     sortBy           = cms.string("deltaR"),
0117 )
0118 process.tkPassingGlb = cms.EDProducer("MatchedCandidateSelector",
0119     src   = cms.InputTag("tkProbes"),
0120     match = cms.InputTag("tkToGlbMatch"),
0121 )
0122 ##    ____               _               ____            _                   _____               _    _             
0123 ##   |  _ \ __ _ ___ ___(_)_ __   __ _  |  _ \ _ __ ___ | |__   ___  ___ _  |_   _| __ __ _  ___| | _(_)_ __   __ _ 
0124 ##   | |_) / _` / __/ __| | '_ \ / _` | | |_) | '__/ _ \| '_ \ / _ \/ __(_)   | || '__/ _` |/ __| |/ / | '_ \ / _` |
0125 ##   |  __/ (_| \__ \__ \ | | | | (_| | |  __/| | | (_) | |_) |  __/\__ \_    | || | | (_| | (__|   <| | | | | (_| |
0126 ##   |_|   \__,_|___/___/_|_| |_|\__, | |_|   |_|  \___/|_.__/ \___||___(_)   |_||_|  \__,_|\___|_|\_\_|_| |_|\__, |
0127 ##                               |___/                                                                        |___/ 
0128 ##   
0129 process.staToTkMatch = cms.EDProducer("MatcherUsingTracks",
0130     src     = cms.InputTag("staTracks"), # all standalone muons
0131     matched = cms.InputTag("tkTracks"),  # to all tk tracks
0132     algorithm = cms.string("byDirectComparison"), # using parameters at PCA
0133     srcTrack = cms.string("tracker"),  # 'staTracks' is a 'RecoChargedCandidate', so it thinks
0134     srcState = cms.string("atVertex"), # it has a 'tracker' track, not a standalone one
0135     matchedTrack = cms.string("tracker"),
0136     matchedState = cms.string("atVertex"),
0137     maxDeltaR        = cms.double(1.),   # large range in DR
0138     maxDeltaEta      = cms.double(0.2),  # small in eta, which is more precise
0139     maxDeltaLocalPos = cms.double(100),
0140     maxDeltaPtRel    = cms.double(3),
0141     sortBy           = cms.string("deltaR"),
0142 )
0143 process.staPassingTk = cms.EDProducer("MatchedCandidateSelector",
0144     src   = cms.InputTag("staProbes"),
0145     match = cms.InputTag("staToTkMatch"),
0146 )
0147 
0148 ##    ____               _               ____            _                   _____     _                       
0149 ##   |  _ \ __ _ ___ ___(_)_ __   __ _  |  _ \ _ __ ___ | |__   ___  ___ _  |_   _| __(_) __ _  __ _  ___ _ __ 
0150 ##   | |_) / _` / __/ __| | '_ \ / _` | | |_) | '__/ _ \| '_ \ / _ \/ __(_)   | || '__| |/ _` |/ _` |/ _ \ '__|
0151 ##   |  __/ (_| \__ \__ \ | | | | (_| | |  __/| | | (_) | |_) |  __/\__ \_    | || |  | | (_| | (_| |  __/ |   
0152 ##   |_|   \__,_|___/___/_|_| |_|\__, | |_|   |_|  \___/|_.__/ \___||___(_)   |_||_|  |_|\__, |\__, |\___|_|   
0153 ##                               |___/                                                   |___/ |___/           
0154 ##  
0155  
0156 process.glbPassingHltMu3 = cms.EDFilter("PATMuonRefSelector",
0157     src = cms.InputTag("patMuons"),
0158     cut = cms.string(process.glbProbes.cut.value() + " && " + PASS_HLT),
0159 )
0160 
0161 # Instead of doing this we just use a string cut, for tests
0162 
0163 process.allPassingProbes = cms.Sequence(
0164     process.tkToGlbMatch * process.tkPassingGlb +
0165     process.staToTkMatch * process.staPassingTk +
0166     process.glbPassingHltMu3
0167 )
0168 
0169 
0170 ##    _____ ___   ____    ____       _          
0171 ##   |_   _( _ ) |  _ \  |  _ \ __ _(_)_ __ ___ 
0172 ##     | | / _ \/\ |_) | | |_) / _` | | '__/ __|
0173 ##     | || (_>  <  __/  |  __/ (_| | | |  \__ \
0174 ##     |_| \___/\/_|     |_|   \__,_|_|_|  |___/
0175 ##                                              
0176 ##   
0177 process.tpGlbTk = cms.EDProducer("CandViewShallowCloneCombiner",
0178     decay = cms.string("tagMuons@+ tkProbes@-"), # charge coniugate states are implied
0179     cut   = cms.string("2.5 < mass < 3.8"),
0180 )
0181 process.tpGlbSta = cms.EDProducer("CandViewShallowCloneCombiner",
0182     decay = cms.string("tagMuons@+ staProbes@-"), # charge coniugate states are implied
0183     cut   = cms.string("2 < mass < 5"),
0184 )
0185 process.tpGlbGlb = cms.EDProducer("CandViewShallowCloneCombiner",
0186     decay = cms.string("tagMuons@+ glbProbes@-"), # charge coniugate states are implied
0187     cut   = cms.string("2.5 < mass < 3.8"),
0188 )
0189 process.allTPPairs = cms.Sequence(process.tpGlbTk + process.tpGlbSta + process.tpGlbGlb)
0190 
0191 ##    __  __  ____   __  __       _       _               
0192 ##   |  \/  |/ ___| |  \/  | __ _| |_ ___| |__   ___  ___ 
0193 ##   | |\/| | |     | |\/| |/ _` | __/ __| '_ \ / _ \/ __|
0194 ##   | |  | | |___  | |  | | (_| | || (__| | | |  __/\__ \
0195 ##   |_|  |_|\____| |_|  |_|\__,_|\__\___|_| |_|\___||___/
0196 ##                                                        
0197 process.muMcMatch = cms.EDFilter("MCTruthDeltaRMatcherNew",
0198     pdgId = cms.vint32(13),
0199     src = cms.InputTag("patMuons"),
0200     distMin = cms.double(0.3),
0201     matched = cms.InputTag("genMuons")
0202 )
0203 process.tkMcMatch  = process.muMcMatch.clone(src = "tkTracks")
0204 process.staMcMatch = process.muMcMatch.clone(src = "staTracks", distMin = 0.6)
0205 
0206 process.allMcMatches = cms.Sequence(process.muMcMatch + process.tkMcMatch + process.staMcMatch)
0207 
0208 ##    _____           _       _ ____            _            _   _  ____ 
0209 ##   |_   _|_ _  __ _( )_ __ ( )  _ \ _ __ ___ | |__   ___  | \ | |/ ___|
0210 ##     | |/ _` |/ _` |/| '_ \|/| |_) | '__/ _ \| '_ \ / _ \ |  \| | |  _ 
0211 ##     | | (_| | (_| | | | | | |  __/| | | (_) | |_) |  __/ | |\  | |_| |
0212 ##     |_|\__,_|\__, | |_| |_| |_|   |_|  \___/|_.__/ \___| |_| \_|\____|
0213 ##              |___/                                                    
0214 ##
0215 
0216 recoCommonStuff = cms.PSet(
0217     variables = cms.PSet(
0218         eta = cms.string("eta()"),
0219         pt  = cms.string("pt()"),
0220         phi  = cms.string("phi()"),
0221         hits = cms.string("track.numberOfValidHits"), ## just to check it works even on something not in reco::Candidate
0222     )
0223 )
0224 mcTruthCommonStuff = cms.PSet(
0225     isMC = cms.bool(True),
0226     makeMCUnbiasTree = cms.bool(True),
0227     checkMotherInUnbiasEff = cms.bool(True),
0228     tagMatches = cms.InputTag("muMcMatch"),
0229     motherPdgId = cms.int32(443),
0230 )
0231 
0232 #####
0233 ## Mu from Tk
0234 process.fitGlbFromTk = cms.EDAnalyzer("TagProbeFitTreeProducer",
0235     ## pick the defaults
0236     recoCommonStuff, mcTruthCommonStuff,
0237     # choice of tag and probe pairs, and arbitration
0238     tagProbePairs = cms.InputTag("tpGlbTk"),
0239     arbitration   = cms.string("OneProbe"),
0240     # choice of what defines a 'passing' probe
0241     flags = cms.PSet(
0242         passing = cms.InputTag("tkPassingGlb"),
0243     ),
0244     ## These two MC things depend on the specific choice of probes
0245     probeMatches  = cms.InputTag("tkMcMatch"),
0246     allProbes     = cms.InputTag("tkProbes"),
0247 )
0248 
0249 #####
0250 ## Tk from Sta
0251 process.fitTkFromSta = cms.EDAnalyzer("TagProbeFitTreeProducer",
0252     ## pick the defaults
0253     recoCommonStuff, mcTruthCommonStuff,
0254     # choice of tag and probe pairs, and arbitration
0255     tagProbePairs = cms.InputTag("tpGlbSta"),
0256     arbitration   = cms.string("OneProbe"),
0257     # choice of what defines a 'passing' probe
0258     flags = cms.PSet(
0259         passing = cms.InputTag("staPassingTk"),
0260     ),
0261     ## These two MC things depend on the specific choice of probes
0262     probeMatches  = cms.InputTag("staMcMatch"),
0263     allProbes     = cms.InputTag("staProbes"),
0264 )
0265 
0266 
0267 #####
0268 ## HLT from Glb
0269 process.fitHltFromGlb = cms.EDAnalyzer("TagProbeFitTreeProducer",
0270     ## pick the defaults
0271     recoCommonStuff, mcTruthCommonStuff,
0272     # choice of tag and probe pairs, and arbitration
0273     tagProbePairs = cms.InputTag("tpGlbGlb"),
0274     arbitration   = cms.string("OneProbe"),
0275     # choice of what defines a 'passing' probe
0276     flags = cms.PSet(
0277         ## Here we use a string cut instead of a collection
0278         passing = cms.string("!triggerObjectMatchesByPath('HLT_Mu3').empty()"),
0279     ),
0280     ## These two MC things depend on the specific choice of probes
0281     probeMatches  = cms.InputTag("muMcMatch"),
0282     allProbes     = cms.InputTag("glbProbes"),
0283 )
0284 
0285 
0286 process.allTPHistos = cms.Sequence(
0287     process.allTPPairs   +
0288     process.fitGlbFromTk +
0289     process.fitTkFromSta +
0290     process.fitHltFromGlb 
0291 )
0292 
0293 ##    ____       _   _     
0294 ##   |  _ \ __ _| |_| |__  
0295 ##   | |_) / _` | __| '_ \ 
0296 ##   |  __/ (_| | |_| | | |
0297 ##   |_|   \__,_|\__|_| |_|
0298 ##                         
0299 process.tagAndProbe = cms.Path( 
0300     process.allTagsAndProbes *
0301     process.allPassingProbes *
0302     process.allMcMatches * 
0303     process.allTPHistos
0304 )
0305 
0306 process.TFileService = cms.Service("TFileService", fileName = cms.string("testTagProbeFitTreeProducer_JPsi.root"))
0307 
0308 
0309 
0310