Skip to content

Commit

Permalink
Merge pull request #43107 from watson-ij/ge0_goodtrackermuon
Browse files Browse the repository at this point in the history
Allow TrackerMuons with only an ME0 segment match
  • Loading branch information
cmsbuild authored Dec 14, 2023
2 parents 18fc414 + 2ba14ee commit 0c4daea
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 46 deletions.
14 changes: 10 additions & 4 deletions DataFormats/MuonReco/src/Muon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,13 @@ int Muon::numberOfMatches(ArbitrationType type) const {
continue;
}
if (type == GEMSegmentAndTrackArbitration) {
if (chamberMatch.gemMatches.empty())
continue;
matches += chamberMatch.gemMatches.size();
for (auto& segmentMatch : chamberMatch.gemMatches) {
if (segmentMatch.isMask(MuonSegmentMatch::BestInChamberByDR) &&
segmentMatch.isMask(MuonSegmentMatch::BelongsToTrackByDR)) {
matches++;
break;
}
}
continue;
}

Expand All @@ -81,13 +85,15 @@ int Muon::numberOfMatches(ArbitrationType type) const {
continue;
}

if (chamberMatch.segmentMatches.empty())
if (chamberMatch.gemMatches.empty() and chamberMatch.segmentMatches.empty())
continue;
if (type == NoArbitration) {
matches++;
continue;
}

if (chamberMatch.segmentMatches.empty())
continue;
for (auto& segmentMatch : chamberMatch.segmentMatches) {
if (type == SegmentArbitration)
if (segmentMatch.isMask(MuonSegmentMatch::BestInChamberByDR)) {
Expand Down
48 changes: 46 additions & 2 deletions RecoLocalMuon/GEMSegment/plugins/GEMSegmentBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#include "FWCore/MessageLogger/interface/MessageLogger.h"

GEMSegmentBuilder::GEMSegmentBuilder(const edm::ParameterSet& ps) : geom_(nullptr) {
// Segment building selection
enableGE0 = ps.getParameter<bool>("enableGE0");
enableGE12 = ps.getParameter<bool>("enableGE12");

// Algo name
segAlgoName = ps.getParameter<std::string>("algo_name");
ge0AlgoName = ps.getParameter<std::string>("ge0_name");
Expand All @@ -27,6 +31,46 @@ GEMSegmentBuilder::GEMSegmentBuilder(const edm::ParameterSet& ps) : geom_(nullpt
}
GEMSegmentBuilder::~GEMSegmentBuilder() {}

void GEMSegmentBuilder::fillDescription(edm::ParameterSetDescription& desc) {
desc.add<bool>("enableGE0", true);
desc.add<bool>("enableGE12", false);
desc.add<std::string>("ge0_name", "GE0SegAlgoRU");
desc.add<std::string>("algo_name", "GEMSegmentAlgorithm");

edm::ParameterSetDescription ge0AlgoConfigDesc;
ge0AlgoConfigDesc.add<bool>("allowWideSegments", true);
ge0AlgoConfigDesc.add<bool>("doCollisions", true);
ge0AlgoConfigDesc.add<double>("maxChi2Additional", 100);
ge0AlgoConfigDesc.add<double>("maxChi2Prune", 50);
ge0AlgoConfigDesc.add<double>("maxChi2GoodSeg", 50);
ge0AlgoConfigDesc.add<double>("maxPhiSeeds", 0.001096605744)->setComment("Assuming 384 strips");
ge0AlgoConfigDesc.add<double>("maxPhiAdditional", 0.001096605744)->setComment("Assuming 384 strips");
ge0AlgoConfigDesc.add<double>("maxETASeeds", 0.1)->setComment("Assuming 8 eta partitions");
ge0AlgoConfigDesc.add<double>("maxTOFDiff", 25);
ge0AlgoConfigDesc.add<bool>("requireCentralBX", true)
->setComment("require that a majority of hits come from central BX");
ge0AlgoConfigDesc.add<unsigned int>("minNumberOfHits", 4);
ge0AlgoConfigDesc.add<unsigned int>("maxNumberOfHits", 300);
ge0AlgoConfigDesc.add<unsigned int>("maxNumberOfHitsPerLayer", 100);
desc.add<edm::ParameterSetDescription>("ge0_pset", ge0AlgoConfigDesc);

edm::ParameterSetDescription recAlgoConfigDesc;
recAlgoConfigDesc.addUntracked<bool>("GEMDebug", false);
recAlgoConfigDesc.add<unsigned int>("minHitsPerSegment", 2);
recAlgoConfigDesc.add<bool>("preClustering", true)
->setComment("False => all hits in chamber are given to the fitter");
recAlgoConfigDesc.add<double>("dXclusBoxMax", 1)->setComment("Clstr Hit dPhi");
recAlgoConfigDesc.add<double>("dYclusBoxMax", 5)->setComment("Clstr Hit dEta");
recAlgoConfigDesc.add<bool>("preClusteringUseChaining", true)
->setComment("True ==> use Chaining() , False ==> use Clustering() Fnct");
recAlgoConfigDesc.add<double>("dPhiChainBoxMax", .02)->setComment("Chain Hit dPhi");
recAlgoConfigDesc.add<double>("dEtaChainBoxMax", .05)->setComment("Chain Hit dEta");
recAlgoConfigDesc.add<int>("maxRecHitsInCluster", 4)->setComment("Does 4 make sense here?");
recAlgoConfigDesc.add<bool>("clusterOnlySameBXRecHits", true)
->setComment("only working for (preClustering && preClusteringUseChaining)");
desc.add<edm::ParameterSetDescription>("algo_pset", recAlgoConfigDesc);
}

void GEMSegmentBuilder::build(const GEMRecHitCollection* recHits, GEMSegmentCollection& oc) {
edm::LogVerbatim("GEMSegmentBuilder") << "[GEMSegmentBuilder::build] Total number of rechits in this event: "
<< recHits->size();
Expand Down Expand Up @@ -93,9 +137,9 @@ void GEMSegmentBuilder::build(const GEMRecHitCollection* recHits, GEMSegmentColl

// given the superchamber select the appropriate algo... and run it
std::vector<GEMSegment> segv;
if (chamber->id().station() == 0)
if (enableGE0 and chamber->id().station() == 0)
segv = ge0Algo->run(ensemble, gemRecHits);
else
else if (enableGE12)
segv = segAlgo->run(ensemble, gemRecHits);
#ifdef EDM_ML_DEBUG // have lines below only compiled when in debug mode
LogTrace("GEMSegmentBuilder") << "[GEMSegmentBuilder::build] found " << segv.size();
Expand Down
5 changes: 5 additions & 0 deletions RecoLocalMuon/GEMSegment/plugins/GEMSegmentBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "DataFormats/GEMRecHit/interface/GEMSegmentCollection.h"
#include "Geometry/GEMGeometry/interface/GEMGeometry.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"

class GEMSegmentAlgorithmBase;

Expand All @@ -39,7 +40,11 @@ class GEMSegmentBuilder {
*/
void setGeometry(const GEMGeometry* g);

static void fillDescription(edm::ParameterSetDescription& descriptions);

private:
bool enableGE0;
bool enableGE12;
std::string segAlgoName;
std::string ge0AlgoName;
edm::ParameterSet segAlgoPSet;
Expand Down
11 changes: 11 additions & 0 deletions RecoLocalMuon/GEMSegment/plugins/GEMSegmentProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Utilities/interface/ESGetToken.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"

#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h"
Expand All @@ -30,6 +32,8 @@ class GEMSegmentProducer : public edm::stream::EDProducer<> {
/// Produce the GEMSegment collection
void produce(edm::Event&, const edm::EventSetup&) override;

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
int iev; // events through
edm::EDGetTokenT<GEMRecHitCollection> theGEMRecHitToken;
Expand All @@ -45,6 +49,13 @@ GEMSegmentProducer::GEMSegmentProducer(const edm::ParameterSet& ps) : iev(0) {
produces<GEMSegmentCollection>();
}

void GEMSegmentProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("gemRecHitLabel", edm::InputTag("gemRecHits"));
GEMSegmentBuilder::fillDescription(desc);
descriptions.add("gemSegments", desc);
}

void GEMSegmentProducer::produce(edm::Event& ev, const edm::EventSetup& setup) {
LogDebug("GEMSegmentProducer") << "start producing segments for " << ++iev << "th event with GEM data";

Expand Down
33 changes: 0 additions & 33 deletions RecoLocalMuon/GEMSegment/python/gemSegments_cfi.py

This file was deleted.

25 changes: 18 additions & 7 deletions RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,9 @@ void MuonIdProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
}

if (arbitrateTrackerMuons_) {
fillArbitrationInfo(outputMuons.get());
fillArbitrationInfo(outputMuons.get(), reco::Muon::TrackerMuon);
fillArbitrationInfo(outputMuons.get(), reco::Muon::GEMMuon);
fillArbitrationInfo(outputMuons.get(), reco::Muon::ME0Muon);
arbitrateMuons(outputMuons.get(), caloMuons.get());
}

Expand Down Expand Up @@ -798,10 +800,11 @@ void MuonIdProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
bool MuonIdProducer::isGoodTrackerMuon(const reco::Muon& muon) {
if (muon.track()->pt() < minPt_ || muon.track()->p() < minP_)
return false;
if (addExtraSoftMuons_ && muon.pt() < 5 && std::abs(muon.eta()) < 1.5 &&
muon.numberOfMatches(reco::Muon::NoArbitration) >= 1)
// NoArbitration checks for CSC/DT segments only, also use ME0 segments
int numMatches = muon.numberOfMatches(reco::Muon::NoArbitration);
if (addExtraSoftMuons_ && muon.pt() < 5 && std::abs(muon.eta()) < 1.5 && numMatches >= 1)
return true;
return (muon.numberOfMatches(reco::Muon::NoArbitration) >= minNumberOfMatches_);
return (numMatches >= minNumberOfMatches_);
}

bool MuonIdProducer::isGoodCaloMuon(const reco::CaloMuon& caloMuon) {
Expand All @@ -825,8 +828,14 @@ bool MuonIdProducer::isGoodGEMMuon(const reco::Muon& muon) {
return false;
if (muon.track()->pt() < minPt_ || muon.track()->p() < minP_)
return false;
return (muon.numberOfMatches(reco::Muon::GEMSegmentAndTrackArbitration) +
muon.numberOfMatches(reco::Muon::GEMHitAndTrackArbitration)) >= 1;
//
int numMatches = 0;
for (auto& chamberMatch : muon.matches()) {
if (chamberMatch.gemMatches.empty())
continue;
numMatches += chamberMatch.gemMatches.size();
}
return (numMatches + muon.numberOfMatches(reco::Muon::GEMHitAndTrackArbitration)) >= 1;
}

bool MuonIdProducer::isGoodME0Muon(const reco::Muon& muon) {
Expand Down Expand Up @@ -1139,7 +1148,9 @@ void MuonIdProducer::arbitrateMuons(reco::MuonCollection* muons, reco::CaloMuonC
// if a muon was exclusively TrackerMuon check if it can be a calo muon
for (reco::MuonCollection::iterator muon = muons->begin(); muon != muons->end();) {
if (muon->isTrackerMuon()) {
if (muon->numberOfMatches(arbitration) < minNumberOfMatches_) {
int numMatches =
muon->numberOfMatches(reco::Muon::GEMSegmentAndTrackArbitration) + muon->numberOfMatches(arbitration);
if (numMatches < minNumberOfMatches_) {
// TrackerMuon failed arbitration
// If not any other base type - erase the element
// (PFMuon is not a base type)
Expand Down

0 comments on commit 0c4daea

Please sign in to comment.