Robert_Matching_2013July

advertisement
Matching in Analysis Tools
Robert Fischer, RWTH Aachen
([email protected])
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)
2
Robert Fischer
Credits
Thank you for the slides:
Norraphat, Roger, and Yvonne
3
Robert Fischer
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
4
Robert Fischer
genParticles Candidates
Status
Meaning
1
Existing entry not decayed or fragmented, represents
the final state as given by the generator (NOT stable
particle in nature).
2
Decayed or fragmented entry (i.e. decayed particle or
parton produced in shower.)
3
Identifes the "hard part" of the interaction, i.e. the
partons that are used in the matrix element calculation,
including immediate decays of resonances.
Exercise
How to access
genParticles
Collection?
Exercise (Task0).
Know your generator:
= Know what you are working with including conditions and limits.
= Know what your generator produces for you.
5
Robert Fischer
Exercise - Task 0
mkdir exerciseMatching
cd exerciseMatching
cmsrel CMSSW_5_3_11
mypatmatching_Task0_cfg.py
src/MyPatMatchingTask0.cc
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
## You can see how to access genParticles collection @ src/MyPatMatchingTask0.cc
6
Robert Fischer
Physics Object Matching
What is "matching"? ......(https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuidePATMCMatching)
Matching means the association of objects from different collections
based 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.
7
Robert Fischer
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:
8 You can start from
Robert Fischer
Physics Object Matching
Five template arguments
9
C1
The collection to be matched
e.g. reconstructed objects
C2
The target collection
e.g. generated particles
S
A preselector for the match
e.g. a selection on PDG id or status
D
The class determining a match
between two objects
e.g. maxDeltaR, maxDeltaPt
Q
The ranking of matches
e.g. ranking by relative deltaPt or deltaR
Robert Fischer
Physics Object Matching
Preselection for MC matches
checkCharge
bool: use / ignore electrical charge
mcPdgId
vint32: MC particle codes
mcStatus
vint32: MC status codes
MCMatchSelector
S
DummyMatchSelector
no preselection
deltaR match
MatchByDR
maxDeltaR
D
cut on deltaR
match by deltaR and relative deltaPt
MatchByDRDPt
maxDeltaR
cut on deltaR
maxDPtRel
cut on fabs(pt2-pt1)/pt2
LessByMatchDistance<D,C1,C2>
ranking by distance (e.g., deltaR)
MatchLessByDPt
ranking by relative deltaPt
Q
10
Robert Fischer
Physics Object Matching
What does PAT use by default?
Preselection for MC matches
checkCharge
bool: use / ignore electrical charge
mcPdgId
vint32: MC particle codes
mcStatus
vint32: MC status codes
S MCMatchSelector
match by deltaR and relative deltaPt
D MatchByDRDPt
Q LessByMatchDistance<D,C1,C2>
11
maxDeltaR
cut on deltaR
maxDPtRel
cut on fabs(pt2-pt1)/pt2
ranking by distance (e.g., deltaR)
Robert Fischer
Physics Object Matching
Some defined concrete matching modules
12
/CMSSW/PhysicsTools/HepMCCandAlgos/plugins/MCTruthMatchers.cc
GenJetMatcher
// 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;
MCMatcherByPt
// 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;
MCMatcher
// 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;
Robert Fischer
Physics Object Matching
Do we need somethings more?
src
InputTag for C1
matched
InputTag for C2
resolveAmbiguities
bool to enable / disable the resolution of ambiguities. If false each
object in C1 is associated to the best match in C2, but several objects in
C1 can point to the same object in C2.
C1
C2
RECO RECO RECO RECO
MC
MC
MC
MC
resolveAmbiguities == False
13
Robert Fischer
Physics Object Matching
Do we need somethings more?
src
InputTag for C1
matched
InputTag for C2
resolveByMatchQuality
bool to choose the type of ambiguity resolution. If true multiple
associations of the same object in C2 are resolved by choosing the best
match, otherwise the match with the lowest index in C1 is chosen.
(Work only when resolveAmbiguities == True)
C1 RECO RECO RECO RECO
resolveAmbiguities == True
resolveByMatchQuality
False: Match input in order
C2
14
MC
MC
MC
MC
True: Pick lowest order first
Robert Fischer
Physics Object Matching
Electron, Muon, and Photon matching
Exercise
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),
)
match the MC objects
to the PAT objects
Embedding of matching information
How to make
matching using
non-default?
You will find in the
exercise (Task1).
makePatMuons = cms.Sequence(
# reco pre-production
# pat specifics
muonMatch *
# object production
patMuons
)
# mc matching
addGenMatch
= cms.bool(True),
embedGenMatch = cms.bool(True),
genParticleMatch = cms.InputTag("muonMatch"),
PhysicsTools/PatAlgos/python/producersLayer1/
15 PhysicsTools/PatAlgos/python/mcMatchLayer0/
add the matching
MC objects to
the PAT objects
Robert Fischer
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
embedGenPartonMatch
genPartonMatch
addGenJetMatch
embedGenJetMatch
genJetMatch
addPartonJetMatch
16 partonJetSource
=
=
=
=
=
=
=
=
makePatJets = cms.Sequence(
makePatJets
cms.Sequence(
# reco= pre-production
# reco pre-production
patJetCorrections *
patJetCorrections *
patJetCharge
patJetCharge
* *
patspecifics
specifics
##pat
patJetPartonMatch
*
patJetPartonMatch
*
patJetGenJetMatch
*
patJetGenJetMatch
*
patJetFlavourId *
patJetFlavourId *
# object production
# object production
patJets
)patJets
)
cms.bool(True),
cms.bool(True),
cms.InputTag("patJetPartonMatch"),
cms.bool(True),
cms.bool(True),
cms.InputTag("patJetGenJetMatch"),
cms.bool(False),
cms.InputTag("NOT_IMPLEMENTED"),
Robert Fischer
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
const ;
genParticleById(int pdgId, int status, uint8_t autoCharge=0)
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"
17
More information in doxygen pages:
http://cmssdt.cern.ch/SDT/doxygen/CMSSW_5_3_6/doc/html/d4/d55/classpat_1_1PATObje
Robert Fischer
How to access MC matching information
If status == 0, only the pdgId will be checked.
If pdgId == 0, only the status will be checked.
//
reco::GenParticleRef
genParticleById(int pdgId, int status,
uint8_t autoCharge=0) const ;
More information can be found in
http://cmssdt.cern.ch/SDT/doxygen/CMSSW_5_3_6/doc/html/d4/d55/classpat_1_1PATObje
ct.html
Exercise
How to use it?
What is autoCharge?
You will find in the
exercise (Task1).
18
Robert Fischer
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 jetint
partonFlavour() 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"
19
Robert Fischer
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.muMatch1 + process.muMatch3)## Add input(s) with MC match informationprocess.patMuons.genParticleMatch =
cms.VInputTag( cms.InputTag("muMatch1"), cms.InputTag("muMatch3"))
process.muonMatch,
## In src/MyPatMatchingTask1.cc, We also give an example how to access genParticles information using genParticle(id)
mypatmatching_Task1_cfg.py
src/MyPatMatchingTask1.cc
20
Robert Fischer
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
21
Robert Fischer
inFlight Decay
'MSTJ(22)=2
! Decay those unstable particles',
'PARJ(71)=10 .! for which ctau 10 mm',
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
22
Robert Fischer
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"
23
Robert Fischer
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"))
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),
)
Robert Fischer
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.
Exercise
Exercise (Task2).
mypatmatching_Task2_cfg.py
src/MyPatMatchingTask2.cc
25
Robert Fischer
Reminder
# mc matching
addGenMatch
= cms.bool(True),
embedGenMatch = cms.bool(True),
genParticleMatch = cms.InputTag("muonMatch"),
# mc matching
addGenPartonMatch
embedGenPartonMatch
genPartonMatch
addGenJetMatch
embedGenJetMatch
genJetMatch
addPartonJetMatch
partonJetSource
=
=
=
=
=
=
=
=
cms.bool(True),
cms.bool(True),
cms.InputTag("patJetPartonMatch"),
cms.bool(True),
cms.bool(True),
cms.InputTag("patJetGenJetMatch"),
cms.bool(False),
cms.InputTag("NOT_IMPLEMENTED"),
Don’t forget to keep GenJet/genParticles if you don’t embed into PAT.
26
$ 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"
Robert Fischer
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).
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.
I don’t have my MC couple T_T,
Hope I can find my match
trigger.
27
G
J
M
RECO,
Who are you
looking for?
JT
E
Robert Fischer
Download
Related flashcards
Create Flashcards