1 / 27

Matching in Analysis Tools Robert Fischer, RWTH Aachen ( robert.fischer@cern.ch )

Matching in Analysis Tools Robert Fischer, RWTH Aachen ( robert.fischer@cern.ch ) PAT Tutorial, Jul 15-19, 2013. Today’s Agenda. Morning: Matching of Physics Objects Triggers in CMSSW Afternoon: Trigger information in PAT (lecture by Phat). PAT. Credits. Thank you for the slides:

Download Presentation

Matching in Analysis Tools Robert Fischer, RWTH Aachen ( robert.fischer@cern.ch )

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Matching in Analysis Tools Robert Fischer, RWTH Aachen (robert.fischer@cern.ch) PAT Tutorial, Jul 15-19, 2013

  2. Today’s Agenda Morning: Matching of Physics Objects Triggers in CMSSW Afternoon: Trigger information in PAT (lecture by Phat) PAT

  3. Credits Thank you for the slides: Norraphat, Roger, and Yvonne PAT

  4. Contents genParticles candidates Physics Object (MC) Matching - Template arguments - PAT MC matching - How to access matching information - Reminder Summary Color code: - Color: Important concept - Color: Strongly recommendation - Color: Should try - Color: Questions

  5. Exercise How to access genParticles Collection? Exercise (Task0). genParticles Candidates Know your generator: = Know what you are working with including conditions and limits. = Know what your generator produces for you.

  6. Exercise - Task 0 mkdir exerciseMatching cd exerciseMatching cmsrel CMSSW_5_3_11 cd CMSSW_5_3_11/srcaddpkg DataFormats/PatCandidates V06-05-06-03addpkg PhysicsTools/PatAlgos     V08-09-44addpkg FWCore/GuiBrowsers V00-00-67 cvs co -d UserCode/PATMCMatching UserCode/srimanob/PhysicsTools/PatMCMatching ## exercise scram b -j4 cd UserCode/PATMCMatching/test cmsRun mypatmatching_Task0_cfg.py mypatmatching_Task0_cfg.py src/MyPatMatchingTask0.cc ## You can see how to access genParticles collection @ src/MyPatMatchingTask0.cc

  7. Physics Object Matching What is "matching"? ......(https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuidePATMCMatching) Matching means the association of objects from different collectionsbased on their similarity in spatial coordinates and/or kinematics. Discrete object properties like e.g. a general type or charge can be used to restrict the possible matches additionally. Goal of the matching is to find representations of the same object in different collections.

  8. Physics Object Matching You can find framework matching in CommonTools/UtilAlgos and the matching utility in PhysicsTools/HepMCCandAlgos. Physics object matching can be configured using 5 template arguments: You can start fromhttps://twiki.cern.ch/twiki/bin/view/CMSPublic/WorkBookMCTruthMatch.

  9. Physics Object Matching Five template arguments

  10. Physics Object Matching

  11. Physics Object Matching What does PAT use by default?

  12. // Match by deltaR and deltaPt, ranking by deltaR (default) typedef reco::PhysObjectMatcher< reco::CandidateView, reco::GenParticleCollection, reco::MCMatchSelector<reco::CandidateView::value_type, reco::GenParticleCollection::value_type>, reco::MatchByDRDPt<reco::CandidateView::value_type, reco::GenParticleCollection::value_type> > MCMatcher; // Alternative: match by deltaR and deltaPt, ranking by deltaPt typedef reco::PhysObjectMatcher< reco::CandidateView, reco::GenParticleCollection, reco::MCMatchSelector<reco::CandidateView::value_type, reco::GenParticleCollection::value_type>, reco::MatchByDRDPt<reco::CandidateView::value_type, reco::GenParticleCollection::value_type>, reco::MatchLessByDPt<reco::CandidateView, reco::GenParticleCollection> > MCMatcherByPt; // JET Match by deltaR, ranking by deltaR (default) typedef reco::PhysObjectMatcher< reco::CandidateView, reco::GenJetCollection, reco::MCMatchSelector<reco::CandidateView::value_type, reco::GenJetCollection::value_type>, reco::MatchByDR<reco::CandidateView::value_type, reco::CandidateView::value_type> > GenJetMatcher; Physics Object Matching Some defined concrete matching modules MCMatcher MCMatcherByPt GenJetMatcher /CMSSW/PhysicsTools/HepMCCandAlgos/plugins/MCTruthMatchers.cc

  13. C1 RECO RECO RECO RECO MC MC MC MC C2 resolveAmbiguities == False Physics Object Matching Do we need somethings more?

  14. resolveAmbiguities == True RECO RECO RECO RECO MC MC MC MC resolveByMatchQuality False: Match input in order True: Pick lowest order first Physics Object Matching Do we need somethings more? C1 C2

  15. Exercise How to make matching using non-default? You will find in the exercise (Task1). Physics Object Matching Electron, Muon, and Photon matching Example configuration for muons: muonMatch = cms.EDProducer("MCMatcher", src = cms.InputTag("muons"), matched = cms.InputTag("genParticles"), mcPdgId = cms.vint32(13), checkCharge = cms.bool(True), mcStatus = cms.vint32(1), maxDeltaR = cms.double(0.5), maxDPtRel = cms.double(0.5), resolveAmbiguities = cms.bool(True), resolveByMatchQuality = cms.bool(False), ) makePatMuons = cms.Sequence( # reco pre-production # pat specifics muonMatch * # object production patMuons ) match the MC objects to the PAT objects Embedding of matching information # mc matching addGenMatch = cms.bool(True), embedGenMatch = cms.bool(True), genParticleMatch = cms.InputTag("muonMatch"), add the matching MC objects to the PAT objects PhysicsTools/PatAlgos/python/producersLayer1/PhysicsTools/PatAlgos/python/mcMatchLayer0/

  16. makePatJets = cms.Sequence( # reco pre-production patJetCorrections * patJetCharge * # pat specifics patJetPartonMatch * patJetGenJetMatch * patJetFlavourId * # object production patJets ) makePatJets = cms.Sequence( # reco pre-production patJetCorrections * patJetCharge * # pat specifics patJetPartonMatch * patJetGenJetMatch * patJetFlavourId * # object production patJets ) Physics Object Matching Jet, and Tau matching patJetPartonMatch = cms.EDProducer("MCMatcher", src = cms.InputTag("ak5CaloJets"), matched = cms.InputTag("genParticles"), mcPdgId = cms.vint32(1, 2, 3, 4, 5, 21), mcStatus = cms.vint32(3), checkCharge = cms.bool(False), maxDeltaR = cms.double(0.4), maxDPtRel = cms.double(3.0), resolveAmbiguities = cms.bool(True), resolveByMatchQuality = cms.bool(False), ) patJetGenJetMatch = cms.EDProducer("GenJetMatcher", src = cms.InputTag("ak5CaloJets"), matched = cms.InputTag("ak5GenJets"), mcPdgId = cms.vint32(), mcStatus = cms.vint32(), checkCharge = cms.bool(False), maxDeltaR = cms.double(0.4), maxDPtRel = cms.double(3.0), resolveAmbiguities = cms.bool(True), resolveByMatchQuality = cms.bool(False), ) # mc matching addGenPartonMatch = cms.bool(True), embedGenPartonMatch = cms.bool(True), genPartonMatch = cms.InputTag("patJetPartonMatch"), addGenJetMatch = cms.bool(True), embedGenJetMatch = cms.bool(True), genJetMatch = cms.InputTag("patJetGenJetMatch"), addPartonJetMatch = cms.bool(False), partonJetSource = cms.InputTag("NOT_IMPLEMENTED"),

  17. How to access MC matching information DataFormats/PatCandidates/interface/PATObject.h // const reco::GenParticle * genParticle(size_t idx=0)const { reco::GenParticleRef ref = genParticleRef(idx); return ref.isNonnull() ? ref.get() : 0;} // reco::GenParticleRef genParticleRef(size_t idx=0)const { if (idx >= genParticlesSize()) return reco::GenParticleRef(); return genParticleEmbedded_.empty() ? genParticleRef_[idx] : reco::GenParticleRef(&genParticleEmbedded_, idx);} // reco::GenParticleRef genParticleById(int pdgId, int status, uint8_t autoCharge=0)const ; DataFormats/PatCandidates/interface/Photon.h /// return the match to the generated photonconst reco::Candidate * genPhoton() const { return genParticle(); } //See in "DataFormats/HepMCCandidate/interface/GenParticle.h" //See in "DataFormats/Candidate/interface/LeafCandidate.h" More information in doxygen pages: http://cmssdt.cern.ch/SDT/doxygen/CMSSW_5_3_6/doc/html/d4/d55/classpat_1_1PATObject.html

  18. Exercise How to use it? What is autoCharge? You will find in the exercise (Task1). // reco::GenParticleRef genParticleById(int pdgId, int status, uint8_t autoCharge=0)const ; How to access MC matching information If status == 0, only the pdgId will be checked. If pdgId == 0, only the status will be checked. More information can be found in http://cmssdt.cern.ch/SDT/doxygen/CMSSW_5_3_6/doc/html/d4/d55/classpat_1_1PATObject.html

  19. How to access MC matching information DataFormats/PatCandidates/interface/Jet.h /// return the matched generated partonconst reco::GenParticle * genParton() const { return genParticle(); } /// return the matched generated jetconst reco::GenJet * genJet() const; /// return the flavour of the parton underlying the jetintpartonFlavour() const; DataFormats/PatCandidates/interface/Tau.h /// return matched GenJet, built from the visible particles of a generated tauconst reco::GenJet * genJet() const; //See in "DataFormats/JetReco/interface/GenJetCollection.h"

  20. Exercise - Task 1 ## Prepare several clones of match associations for status 1 and 3## stable muons process.muMatch1 = process.muonMatch.clone(mcStatus = [1]) ## hard scattering muons process.muMatch3 = process.muonMatch.clone(mcStatus = [3]) ## Add the new matches to the default sequenceprocess.patDefaultSequence.replace( process.muonMatch, process.muMatch1 + process.muMatch3)## Add input(s) with MC match informationprocess.patMuons.genParticleMatch = cms.VInputTag( cms.InputTag("muMatch1"), cms.InputTag("muMatch3")) ## In src/MyPatMatchingTask1.cc, We also give an example how to access genParticles information using genParticle(id) mypatmatching_Task1_cfg.py src/MyPatMatchingTask1.cc

  21. Exercise - Task 1 Try to: (1) Make deltaR and deltaPt histograms using genParticleById() [Remember that now we have 2 different matches (status =1 & 3)]. (2) Count Match/Not match muons. [Not match = No matching for status =1 & status =3]. (3) Let change matching parameters, i.e. checkCharge, maxDeltaR,... and visualize their effects. (4) Create matching module using different ranking method (by DeltaPt instead of DeltaR) and compare deltaPt plots from both matching. mypatmatching_Task1_cfg.py src/MyPatMatchingTask1.cc

  22. With these parameter, they tell Pythia6 to decay unstable particles that can travel no farther than 10mm (1cm)from the collision point. Particles of life time greater than 10mm have a chance to interact with the detector's material prior they can decay in flight. For this reason it has been decided to keep them undecayed by the generator and then treated by the detector simulation step. Track information inFlight Decay 'MSTJ(22)=2 ! Decay those unstable particles', 'PARJ(71)=10 .! for which ctau 10 mm',

  23. inFlight Decay How to match inFlight decay particles? You need to create “genParticle-like” candidate. But How? PATGenCandsFromSimTracksProducer will take care this step for you. It will produce genParticles-like candidates from SimTracks, so they can be used for MC matching. You can see the code in PhysicsTools/PatAlgos/plugins/PATGenCandsFromSimTracksProducer.cc Note: edmDumpEventContent TTbar.root | grep g4SimHitsvector<SimTrack> "g4SimHits" "" "SIM" vector<SimVertex> "g4SimHits" "" "SIM"

  24. muonMatchInFlight = cms.EDProducer("MCMatcher", src = cms.InputTag("muons"), matched = cms.InputTag("inFlightMuons"), mcPdgId = cms.vint32(13), checkCharge = cms.bool(True), mcStatus = cms.vint32(-1), maxDeltaR = cms.double(0.5), maxDPtRel = cms.double(0.5), resolveAmbiguities = cms.bool(True), resolveByMatchQuality = cms.bool(False), ) inFlight Decay process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") process.inFlightMuons =cms.EDProducer( "PATGenCandsFromSimTracksProducer", src = cms.InputTag("g4SimHits"), ## use "famosSimHits" for FAMOS, g4SimHits for FullSIM setStatus = cms.int32(-1), particleTypes = cms.vstring("mu+"), ## picks also mu-, of course filter = cms.vstring("pt > 0.5"), makeMotherLink = cms.bool(True), writeAncestors = cms.bool(True), ## save also the intermediate GEANT ancestors of the muons genParticles = cms.InputTag("genParticles"))

  25. Exercise Exercise (Task2). Exercise - Task 2 Try to: (1) Put this configuration together with muMatch1, muMatch3. You also need to edit properly the muonMatch module to add this inFlightMuon to be a new matching source. (2) How many muons do not have a status 1 or 3 but a inFlightMuon? Compare with different input samples. mypatmatching_Task2_cfg.py src/MyPatMatchingTask2.cc

  26. Reminder # mc matching addGenMatch = cms.bool(True), embedGenMatch = cms.bool(True), genParticleMatch = cms.InputTag("muonMatch"), # mc matching addGenPartonMatch = cms.bool(True), embedGenPartonMatch = cms.bool(True), genPartonMatch = cms.InputTag("patJetPartonMatch"), addGenJetMatch = cms.bool(True), embedGenJetMatch = cms.bool(True), genJetMatch = cms.InputTag("patJetGenJetMatch"), addPartonJetMatch = cms.bool(False), partonJetSource = cms.InputTag("NOT_IMPLEMENTED"), Don’t forget to keep GenJet/genParticles if you don’t embed into PAT. $ UserCode/MyPatMatching/test: edmDumpEventContent RECOSIM.root | grep ak5GenJetsdouble "ak5GenJets" "rho" "HLT" double "ak5GenJets" "sigma" "HLT" vector<double> "ak5GenJets" "rhos" "HLT" vector<double> "ak5GenJets" "sigmas" "HLT" vector<reco::GenJet> "ak5GenJets" "" "HLT" $ UserCode/MyPatMatching/test: edmDumpEventContent RECOSIM.root | grep genParticlesvector<int> "genParticles" "" "HLT" vector<reco::GenParticle> "genParticles" "" "HLT"

  27. I’m looking for my match. He is electron from trigger path ‘HLT_Ele8_V10’, his PT is ~39.2215 GeV, and his eta is ~2.203. RECO, Who are you looking for? Trigger E I don’t have my MC couple T_T, Hope I can find my match trigger. JT M J G Summary - Analysis Tools holds powerful tools to apply any kind of matching you could think of. - PAT exploits an expanded template version which is the MCMatcher for MC matching. - For any more than trivial Matching you should consider using the PhysObjectMatcher, as it just relieves you from re-inventing. - Consequently you will find many parts of this when matching between TRIGGER and RECO objects will be discussed (Friday). 27

More Related