Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter tracks extrapolated to the muon system #41323

Merged
merged 8 commits into from
Jun 13, 2023
4 changes: 4 additions & 0 deletions RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,10 @@ void MuonIdProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptio
descTrkAsoPar.add<edm::InputTag>("ME0SegmentCollectionLabel", edm::InputTag("me0Segments"));
descTrkAsoPar.add<bool>("useGEM", false);
descTrkAsoPar.add<bool>("useME0", false);
descTrkAsoPar.add<bool>("preselectMuonTracks", false);
descTrkAsoPar.add<edm::InputTag>("RPCHitCollectionLabel", edm::InputTag("rpcRecHits"));
descTrkAsoPar.add<edm::InputTag>("GEMHitCollectionLabel", edm::InputTag("gemRecHits"));
descTrkAsoPar.add<edm::InputTag>("ME0HitCollectionLabel", edm::InputTag("me0RecHits"));
descTrkAsoPar.setAllowAnything();
desc.add<edm::ParameterSetDescription>("TrackAssociatorParameters", descTrkAsoPar);

Expand Down
3 changes: 3 additions & 0 deletions RecoMuon/MuonIdentification/python/muons1stStep_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
from RecoMuon.MuonIdentification.MuonShowerDigiFiller_cfi import *
from RecoMuon.MuonIdentification.TrackerKinkFinder_cfi import *
from TrackingTools.TrackAssociator.default_cfi import *

TrackAssociatorParameterBlock.TrackAssociatorParameters.preselectMuonTracks = True

muons1stStep = cms.EDProducer("MuonIdProducer",
# MuonCaloCompatibility
MuonCaloCompatibilityBlock,
Expand Down
1 change: 1 addition & 0 deletions TrackingTools/TrackAssociator/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<use name="DataFormats/DTRecHit"/>
<use name="DataFormats/CSCRecHit"/>
<use name="DataFormats/GEMRecHit"/>
<use name="DataFormats/RPCRecHit"/>
<use name="DataFormats/EcalDetId"/>
<use name="DataFormats/GeometrySurface"/>
<use name="DataFormats/GeometryVector"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
#include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
#include "DataFormats/GEMRecHit/interface/GEMSegmentCollection.h"
#include "DataFormats/GEMRecHit/interface/ME0SegmentCollection.h"
#include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h"
#include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h"
#include "DataFormats/GEMRecHit/interface/ME0RecHitCollection.h"

class DetIdAssociator;
class DetIdAssociatorRecord;
Expand Down Expand Up @@ -90,6 +93,7 @@ class TrackAssociatorParameters {
bool truthMatch;
bool useGEM;
bool useME0;
bool preselectMuonTracks;

/// Labels of the detector EDProducts
edm::InputTag theEBRecHitCollectionLabel;
Expand All @@ -101,6 +105,9 @@ class TrackAssociatorParameters {
edm::InputTag theCSCSegmentCollectionLabel;
edm::InputTag theGEMSegmentCollectionLabel;
edm::InputTag theME0SegmentCollectionLabel;
edm::InputTag theRPCHitCollectionLabel;
edm::InputTag theGEMHitCollectionLabel;
edm::InputTag theME0HitCollectionLabel;

// Specify if we want to widen the search pass of the crossed
// calorimeter elements taking into account uncertainty
Expand All @@ -119,6 +126,9 @@ class TrackAssociatorParameters {
edm::EDGetTokenT<CSCSegmentCollection> cscSegmentsToken;
edm::EDGetTokenT<GEMSegmentCollection> gemSegmentsToken;
edm::EDGetTokenT<ME0SegmentCollection> me0SegmentsToken;
edm::EDGetTokenT<RPCRecHitCollection> rpcHitsToken;
edm::EDGetTokenT<GEMRecHitCollection> gemHitsToken;
edm::EDGetTokenT<ME0RecHitCollection> me0HitsToken;
edm::EDGetTokenT<edm::SimTrackContainer> simTracksToken;
edm::EDGetTokenT<edm::SimVertexContainer> simVerticesToken;
edm::EDGetTokenT<edm::PCaloHitContainer> simEcalHitsEBToken;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ class TrackDetectorAssociator {
bool addTAMuonSegmentMatch(TAMuonChamberMatch&, const RecSegment*, const AssociatorParameters&) dso_internal;

void getTAMuonChamberMatches(std::vector<TAMuonChamberMatch>& matches,
const AssociatorParameters& parameters) dso_internal;
const AssociatorParameters& parameters,
std::set<DetId> occupancy) dso_internal;

void init(const edm::EventSetup&, const AssociatorParameters&) dso_internal;

Expand Down
8 changes: 8 additions & 0 deletions TrackingTools/TrackAssociator/python/default_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@
EERecHitCollectionLabel = cms.InputTag("ecalRecHit","EcalRecHitsEE"),
dRHcalPreselection = cms.double(0.2),
useMuon = cms.bool(True),
preselectMuonTracks = cms.bool(False),
useCalo = cms.bool(False),
EBRecHitCollectionLabel = cms.InputTag("ecalRecHit","EcalRecHitsEB"),
dRMuonPreselection = cms.double(0.2),
usePreshower = cms.bool(False),
dRPreshowerPreselection = cms.double(0.2),
truthMatch = cms.bool(False),
HBHERecHitCollectionLabel = cms.InputTag("hbhereco"),
RPCHitCollectionLabel = cms.InputTag("rpcRecHits"),
GEMHitCollectionLabel = cms.InputTag("gemRecHits"),
ME0HitCollectionLabel = cms.InputTag("me0RecHits"),
useHcal = cms.bool(True)
)
)
Expand Down Expand Up @@ -69,9 +73,13 @@
usePreshower = cms.bool(False),
dRHcalPreselection = cms.double(0.2),
useMuon = cms.bool(True),
preselectMuonTracks = cms.bool(False),
useCalo = cms.bool(False),
EBRecHitCollectionLabel = cms.InputTag("ecalRecHit","EcalRecHitsEB"),
truthMatch = cms.bool(False),
HBHERecHitCollectionLabel = cms.InputTag("hbhereco"),
RPCHitCollectionLabel = cms.InputTag("rpcRecHits"),
GEMHitCollectionLabel = cms.InputTag("gemRecHits"),
ME0HitCollectionLabel = cms.InputTag("me0RecHits"),
useHcal = cms.bool(True)
)
15 changes: 15 additions & 0 deletions TrackingTools/TrackAssociator/src/TrackAssociatorParameters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ void TrackAssociatorParameters::loadParameters(const edm::ParameterSet& iConfig,
usePreshower = iConfig.getParameter<bool>("usePreshower");
useGEM = iConfig.getParameter<bool>("useGEM");
useME0 = iConfig.getParameter<bool>("useME0");
preselectMuonTracks = iConfig.getParameter<bool>("preselectMuonTracks");

theEBRecHitCollectionLabel = iConfig.getParameter<edm::InputTag>("EBRecHitCollectionLabel");
theEERecHitCollectionLabel = iConfig.getParameter<edm::InputTag>("EERecHitCollectionLabel");
Expand All @@ -48,6 +49,11 @@ void TrackAssociatorParameters::loadParameters(const edm::ParameterSet& iConfig,
theCSCSegmentCollectionLabel = iConfig.getParameter<edm::InputTag>("CSCSegmentCollectionLabel");
theGEMSegmentCollectionLabel = iConfig.getParameter<edm::InputTag>("GEMSegmentCollectionLabel");
theME0SegmentCollectionLabel = iConfig.getParameter<edm::InputTag>("ME0SegmentCollectionLabel");
if (preselectMuonTracks) {
theRPCHitCollectionLabel = iConfig.getParameter<edm::InputTag>("RPCHitCollectionLabel");
theGEMHitCollectionLabel = iConfig.getParameter<edm::InputTag>("GEMHitCollectionLabel");
theME0HitCollectionLabel = iConfig.getParameter<edm::InputTag>("ME0HitCollectionLabel");
}

accountForTrajectoryChangeCalo = iConfig.getParameter<bool>("accountForTrajectoryChangeCalo");
// accountForTrajectoryChangeMuon = iConfig.getParameter<bool>("accountForTrajectoryChangeMuon");
Expand All @@ -72,6 +78,11 @@ void TrackAssociatorParameters::loadParameters(const edm::ParameterSet& iConfig,
gemSegmentsToken = iC.consumes<GEMSegmentCollection>(theGEMSegmentCollectionLabel);
if (useME0)
me0SegmentsToken = iC.consumes<ME0SegmentCollection>(theME0SegmentCollectionLabel);
if (preselectMuonTracks) {
rpcHitsToken = iC.consumes<RPCRecHitCollection>(theRPCHitCollectionLabel);
gemHitsToken = iC.consumes<GEMRecHitCollection>(theGEMHitCollectionLabel);
me0HitsToken = iC.consumes<ME0RecHitCollection>(theME0HitCollectionLabel);
}
}
if (truthMatch) {
simTracksToken = iC.consumes<edm::SimTrackContainer>(edm::InputTag("g4SimHits"));
Expand Down Expand Up @@ -110,6 +121,7 @@ void TrackAssociatorParameters::fillPSetDescription(edm::ParameterSetDescription
desc.add<bool>("useME0", false);
desc.add<bool>("useMuon", true);
desc.add<bool>("usePreshower", false);
desc.add<bool>("preselectMuonTracks", false);
desc.add<double>("dREcal", 9999.0);
desc.add<double>("dREcalPreselection", 0.05);
desc.add<double>("dRHcal", 9999.0);
Expand All @@ -131,4 +143,7 @@ void TrackAssociatorParameters::fillPSetDescription(edm::ParameterSetDescription
desc.add<edm::InputTag>("HBHERecHitCollectionLabel", edm::InputTag("hbreco"));
desc.add<edm::InputTag>("HORecHitCollectionLabel", edm::InputTag("horeco"));
desc.add<edm::InputTag>("ME0SegmentCollectionLabel", edm::InputTag("me0Segments"));
desc.add<edm::InputTag>("RPCHitCollectionLabel", edm::InputTag("rpcRecHits"));
desc.add<edm::InputTag>("GEMHitCollectionLabel", edm::InputTag("gemRecHits"));
desc.add<edm::InputTag>("ME0HitCollectionLabel", edm::InputTag("me0RecHits"));
}
69 changes: 67 additions & 2 deletions TrackingTools/TrackAssociator/src/TrackDetectorAssociator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
#include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
#include "DataFormats/GEMRecHit/interface/GEMSegmentCollection.h"
#include "DataFormats/GEMRecHit/interface/ME0SegmentCollection.h"
#include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h"
#include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h"
#include "DataFormats/GEMRecHit/interface/ME0RecHitCollection.h"

// calorimeter and muon infos
#include "Geometry/CommonDetUnit/interface/GeomDet.h"
Expand Down Expand Up @@ -591,7 +594,8 @@ DetIdAssociator::MapRange TrackDetectorAssociator::getMapRange(const std::pair<f
}

void TrackDetectorAssociator::getTAMuonChamberMatches(std::vector<TAMuonChamberMatch>& matches,
const AssociatorParameters& parameters) {
const AssociatorParameters& parameters,
std::set<DetId> occupancy) {
// Strategy:
// Propagate through the whole detector, estimate change in eta and phi
// along the trajectory, add this to dRMuon and find DetIds around this
Expand Down Expand Up @@ -621,6 +625,18 @@ void TrackDetectorAssociator::getTAMuonChamberMatches(std::vector<TAMuonChamberM

std::set<DetId> muonIdsInRegion = muonDetIdAssociator_->getDetIdsCloseToAPoint(trajectoryPoint.position(), mapRange);
LogTrace("TrackAssociator") << "Number of chambers to check: " << muonIdsInRegion.size();

if (parameters.preselectMuonTracks) {
std::set<DetId> muonIdsInRegionOccupied;
std::set_intersection(muonIdsInRegion.begin(),
muonIdsInRegion.end(),
occupancy.begin(),
occupancy.end(),
std::inserter(muonIdsInRegionOccupied, muonIdsInRegionOccupied.begin()));
if (muonIdsInRegionOccupied.empty())
return;
}

for (std::set<DetId>::const_iterator detId = muonIdsInRegion.begin(); detId != muonIdsInRegion.end(); detId++) {
const GeomDet* geomDet = muonDetIdAssociator_->getGeomDet(*detId);
TrajectoryStateOnSurface stateOnSurface = cachedTrajectory_.propagate(&geomDet->surface());
Expand Down Expand Up @@ -723,6 +739,55 @@ void TrackDetectorAssociator::fillMuon(const edm::Event& iEvent,
if (parameters.useME0)
iEvent.getByToken(parameters.me0SegmentsToken, me0Segments);

// Get the hits from the event only if track preselection is activated
// Get the chambers segments/hits in the events
std::set<DetId> occupancy_set;
if (parameters.preselectMuonTracks) {
edm::Handle<RPCRecHitCollection> rpcRecHits;
iEvent.getByToken(parameters.rpcHitsToken, rpcRecHits);
if (!rpcRecHits.isValid())
throw cms::Exception("FatalError") << "Unable to find RPCRecHitCollection in event!\n";

edm::Handle<GEMRecHitCollection> gemRecHits;
if (parameters.useGEM)
iEvent.getByToken(parameters.gemHitsToken, gemRecHits);

edm::Handle<ME0RecHitCollection> me0RecHits;
if (parameters.useME0)
iEvent.getByToken(parameters.me0HitsToken, me0RecHits);

for (const auto& dtSegment : *dtSegments) {
occupancy_set.insert(dtSegment.geographicalId());
}
for (const auto& cscSegment : *cscSegments) {
occupancy_set.insert(cscSegment.geographicalId());
}
for (const auto& rpcRecHit : *rpcRecHits) {
occupancy_set.insert(rpcRecHit.geographicalId());
}
if (parameters.useGEM) {
for (const auto& gemSegment : *gemSegments) {
occupancy_set.insert(gemSegment.geographicalId());
}
for (const auto& gemRecHit : *gemRecHits) {
occupancy_set.insert(gemRecHit.geographicalId());
}
}
if (parameters.useME0) {
for (const auto& me0Segment : *me0Segments) {
occupancy_set.insert(me0Segment.geographicalId());
}
for (const auto& me0RecHit : *me0RecHits) {
occupancy_set.insert(me0RecHit.geographicalId());
}
}
if (occupancy_set.empty()) {
LogTrace("TrackAssociator") << "No segments or hits were found in the event: aborting track extrapolation"
<< std::endl;
return;
}
}

///// get a set of DetId's in a given direction

// check the map of available segments
Expand All @@ -736,7 +801,7 @@ void TrackDetectorAssociator::fillMuon(const edm::Event& iEvent,
// get a set of matches corresponding to muon chambers
std::vector<TAMuonChamberMatch> matchedChambers;
LogTrace("TrackAssociator") << "Trying to Get ChamberMatches" << std::endl;
getTAMuonChamberMatches(matchedChambers, parameters);
getTAMuonChamberMatches(matchedChambers, parameters, occupancy_set);
LogTrace("TrackAssociator") << "Chambers matched: " << matchedChambers.size() << "\n";

// Iterate over all chamber matches and fill segment matching
Expand Down