-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated MuonMCClassifier, added association of Global_or_Tracker muons
- Loading branch information
Showing
10 changed files
with
503 additions
and
106 deletions.
There are no files selected for viewing
217 changes: 157 additions & 60 deletions
217
MuonAnalysis/MuonAssociators/plugins/MuonMCClassifier.cc
Large diffs are not rendered by default.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
MuonAnalysis/MuonAssociators/python/muonClassificationByHitsTP_cfi.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
### Add MC classification by hits | ||
### Note: this cfi needs TrackingParticle collection from the Event | ||
|
||
from SimMuon.MCTruth.muonAssociatorByHitsNoSimHitsHelper_cfi import * | ||
|
||
classByHitsTM = cms.EDProducer("MuonMCClassifier", | ||
muons = cms.InputTag("muons"), | ||
muonPreselection = cms.string("muonID('TrackerMuonArbitrated')"), # definition of "duplicates" depends on the preselection | ||
trackType = cms.string("segments"), # 'inner','outer','global','segments','glb_or_trk' | ||
trackingParticles = cms.InputTag("mix","MergedTrackTruth"), # default TrackingParticle collection (should exist in the Event) | ||
associatorLabel = cms.InputTag("muonAssociatorByHitsNoSimHitsHelper"), | ||
decayRho = cms.double(200), # to classify differently decay muons included in ppMuX | ||
decayAbsZ = cms.double(400), # and decay muons that could not be in ppMuX | ||
linkToGenParticles = cms.bool(True), # produce also a collection of GenParticles for secondary muons | ||
genParticles = cms.InputTag("genParticles"), # and associations to primary and secondaries | ||
) | ||
classByHitsTMLSAT = classByHitsTM.clone( | ||
muonPreselection = cms.string("muonID('TMLastStationAngTight')") | ||
) | ||
classByHitsGlb = classByHitsTM.clone( | ||
muonPreselection = cms.string("isGlobalMuon"), | ||
trackType = "global" | ||
) | ||
classByHitsSta = classByHitsTM.clone( | ||
muonPreselection = cms.string("isStandAloneMuon"), | ||
trackType = "outer" | ||
) | ||
classByHitsGlbOrTrk = classByHitsTM.clone( | ||
muonPreselection = cms.string("isGlobalMuon || muonID('TrackerMuonArbitrated')"), | ||
trackType = "glb_or_trk" | ||
) | ||
|
||
|
||
muonClassificationByHits = cms.Sequence( | ||
muonAssociatorByHitsNoSimHitsHelper + | ||
( | ||
# classByHitsTM + | ||
# classByHitsTMLSAT + | ||
# classByHitsGlb + | ||
# classByHitsSta + | ||
classByHitsGlbOrTrk | ||
) | ||
) | ||
#def addUserData(patMuonProducer,labels=['classByHitsTM', 'classByHitsSta', 'classByHitsGlbOrTrk'], extraInfo = False): | ||
def addUserData(patMuonProducer,labels=['classByHitsGlbOrTrk'], extraInfo = False): | ||
for label in labels: | ||
patMuonProducer.userData.userInts.src.append( cms.InputTag(label) ) | ||
patMuonProducer.userData.userInts.src.append( cms.InputTag(label, "ext") ) | ||
if extraInfo: | ||
for ints in ("flav", "hitsPdgId", "G4processType", "momPdgId", "gmomPdgId", "momFlav", "gmomFlav", "hmomFlav", "tpId", "tpBx", "tpEv", "momStatus"): | ||
patMuonProducer.userData.userInts.src.append(cms.InputTag(label, ints)) | ||
for ins in ("signp", "pt", "eta", "phi", "prodRho", "prodZ", "tpAssoQuality", "momRho", "momZ"): | ||
|
||
patMuonProducer.userData.userFloats.src.append(cms.InputTag(label, ins)) | ||
|
||
def addGenParticleRef(patMuonProducer, label = 'classByHitsGlbOrTrk'): | ||
patMuonProducer.addGenMatch = True | ||
patMuonProducer.genParticleMatch = cms.VInputTag(cms.InputTag(label, "toPrimaries"), cms.InputTag(label, "toSecondaries")) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
150 changes: 150 additions & 0 deletions
150
MuonAnalysis/MuonAssociators/test/MuonMCClassifier/testClassByHitsTP_cfg.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from Configuration.StandardSequences.Eras import eras | ||
|
||
process = cms.Process('MuonClassif',eras.Phase2) | ||
|
||
process.load('Configuration.StandardSequences.Services_cff') | ||
process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') | ||
process.load('SimGeneral.MixingModule.mix_POISSON_average_cfi') | ||
|
||
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("PoolSource", | ||
fileNames = cms.untracked.vstring( | ||
'/store/relval/CMSSW_9_1_1/RelValZMM_14/GEN-SIM-RECO/PU25ns_91X_upgrade2023_realistic_v1_D17PU200-v1/10000/003FC7CB-EB3F-E711-92D1-0025905A6076.root' | ||
), | ||
secondaryFileNames = cms.untracked.vstring( | ||
) | ||
) | ||
|
||
process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1) ) | ||
|
||
process.load('Configuration.Geometry.GeometryExtended2023D17Reco_cff') | ||
process.load('Configuration.StandardSequences.MagneticField_cff') | ||
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') | ||
process.load("Configuration.StandardSequences.Reconstruction_cff") | ||
|
||
from Configuration.AlCa.GlobalTag import GlobalTag | ||
process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') | ||
|
||
## ==== PAT used to parse the muon selection | ||
process.load("MuonAnalysis.MuonAssociators.patMuonsWithTrigger_cff") | ||
from MuonAnalysis.MuonAssociators.patMuonsWithTrigger_cff import * | ||
|
||
## ==== Classification by Hits | ||
process.load("MuonAnalysis.MuonAssociators.muonClassificationByHitsTP_cfi") | ||
# | ||
from MuonAnalysis.MuonAssociators.muonClassificationByHitsTP_cfi import addUserData as addClassByHits | ||
addClassByHits(process.patMuonsWithoutTrigger, extraInfo=True) | ||
|
||
# Output definition | ||
process.MYoutput = cms.OutputModule("PoolOutputModule", | ||
eventAutoFlushCompressedSize = cms.untracked.int32(5242880), | ||
fileName = cms.untracked.string('ZMMpu25ns-UPG2023_test.root'), | ||
splitLevel = cms.untracked.int32(0) | ||
) | ||
|
||
process.MuonClassifier = cms.Path( | ||
process.muonClassificationByHits | ||
) | ||
|
||
process.MYoutput_step = cms.EndPath(process.MYoutput) | ||
|
||
process.schedule = cms.Schedule( | ||
process.MuonClassifier, | ||
process.MYoutput_step | ||
) | ||
|
||
# customisation of the process. | ||
|
||
# Automatic addition of the customisation function from SimGeneral.MixingModule.fullMixCustomize_cff | ||
from SimGeneral.MixingModule.fullMixCustomize_cff import setCrossingFrameOn | ||
|
||
#call to customisation function setCrossingFrameOn imported from SimGeneral.MixingModule.fullMixCustomize_cff | ||
process = setCrossingFrameOn(process) | ||
|
||
# End of customisation functions | ||
#do not add changes to your config after this point (unless you know what you are doing) | ||
from FWCore.ParameterSet.Utilities import convertToUnscheduled | ||
process=convertToUnscheduled(process) | ||
|
||
# customisation of the process. | ||
|
||
# Customisation from command line | ||
|
||
# Add early deletion of temporary data products to reduce peak memory need | ||
from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete | ||
process = customiseEarlyDelete(process) | ||
# End adding early deletion | ||
|
||
###### | ||
process.MessageLogger.categories = cms.untracked.vstring('MuonToTrackingParticleAssociatorEDProducer', | ||
'MuonToTrackingParticleAssociatorByHits','MuonAssociatorByHitsHelper','MuonToTrackingParticleAssociatorByHitsImpl', | ||
'TrackerMuonHitExtractor','MuonMCClassifier', | ||
'FwkJob','FwkReport','FwkSummary','Root_NoDictionary') | ||
|
||
process.MessageLogger.cerr = cms.untracked.PSet( | ||
noTimeStamps = cms.untracked.bool(True), | ||
|
||
threshold = cms.untracked.string('WARNING'), | ||
|
||
MuonToTrackingParticleAssociatorEDProducer = cms.untracked.PSet( | ||
limit = cms.untracked.int32(0) | ||
), | ||
MuonToTrackingParticleAssociatorByHits = cms.untracked.PSet( | ||
limit = cms.untracked.int32(0) | ||
), | ||
MuonToTrackingParticleAssociatorByHitsImpl = cms.untracked.PSet( | ||
limit = cms.untracked.int32(0) | ||
), | ||
MuonAssociatorByHitsHelper = cms.untracked.PSet( | ||
limit = cms.untracked.int32(0) | ||
), | ||
TrackerMuonHitExtractor = cms.untracked.PSet( | ||
limit = cms.untracked.int32(0) | ||
) | ||
) | ||
|
||
process.MessageLogger.cout = cms.untracked.PSet( | ||
noTimeStamps = cms.untracked.bool(True), | ||
threshold = cms.untracked.string('INFO'), | ||
|
||
default = cms.untracked.PSet( | ||
limit = cms.untracked.int32(0) | ||
), | ||
MuonToTrackingParticleAssociatorEDProducer = cms.untracked.PSet( | ||
limit = cms.untracked.int32(10000000) | ||
), | ||
MuonToTrackingParticleAssociatorByHits = cms.untracked.PSet( | ||
limit = cms.untracked.int32(10000000) | ||
), | ||
MuonToTrackingParticleAssociatorByHitsImpl = cms.untracked.PSet( | ||
limit = cms.untracked.int32(10000000) | ||
), | ||
MuonAssociatorByHitsHelper = cms.untracked.PSet( | ||
limit = cms.untracked.int32(10000000) | ||
), | ||
TrackerMuonHitExtractor = cms.untracked.PSet( | ||
limit = cms.untracked.int32(0) | ||
), | ||
MuonMCClassifier = cms.untracked.PSet( | ||
limit = cms.untracked.int32(10000000) | ||
), | ||
FwkReport = cms.untracked.PSet( | ||
reportEvery = cms.untracked.int32(1), | ||
limit = cms.untracked.int32(10000000) | ||
), | ||
FwkSummary = cms.untracked.PSet( | ||
reportEvery = cms.untracked.int32(1), | ||
limit = cms.untracked.int32(10000000) | ||
), | ||
FwkJob = cms.untracked.PSet( | ||
limit = cms.untracked.int32(0) | ||
), | ||
Root_NoDictionary = cms.untracked.PSet( | ||
limit = cms.untracked.int32(0) | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.