Skip to content

Commit

Permalink
Revert "[muon] reco to trigger object matching"
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiocos authored Jun 28, 2018
1 parent 099029d commit bcca149
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 160 deletions.
1 change: 0 additions & 1 deletion Configuration/Applications/python/ConfigBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1649,7 +1649,6 @@ def prepare_PAT(self, sequence = "miniAOD"):
self._options.customise_commands = self._options.customise_commands + " \n"
self._options.customise_commands = self._options.customise_commands + "process.patTrigger.processName = \""+self._options.hltProcess+"\"\n"
self._options.customise_commands = self._options.customise_commands + "process.slimmedPatTrigger.triggerResults= cms.InputTag( 'TriggerResults::"+self._options.hltProcess+"' )\n"
self._options.customise_commands = self._options.customise_commands + "process.patMuons.triggerResults= cms.InputTag( 'TriggerResults::"+self._options.hltProcess+"' )\n"

# self.renameHLTprocessInSequence(sequence)

Expand Down
1 change: 0 additions & 1 deletion Configuration/Skimming/python/PDWG_BPHSkim_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
userIsolation = cms.PSet(), # no extra isolation beyond what's in reco::Muon itself
isoDeposits = cms.PSet(), # no heavy isodeposits
addGenMatch = False, # no mc
addTriggerMatching = cms.bool(False)
)

oniaSelectedMuons = cms.EDFilter('PATMuonSelector',
Expand Down
13 changes: 1 addition & 12 deletions DataFormats/PatCandidates/interface/Muon.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,18 +311,6 @@ namespace pat {
void setSimPt(float pt){ simPt_ = pt;}
void setSimEta(float eta){ simEta_ = eta;}
void setSimPhi(float phi){ simPhi_ = phi;}

/// Trigger information
const pat::TriggerObjectStandAlone* l1Object(const size_t idx=0) const {
return triggerObjectMatchByType(trigger::TriggerL1Mu,idx);
}
const pat::TriggerObjectStandAlone* hltObject(const size_t idx=0) const {
return triggerObjectMatchByType(trigger::TriggerMuon,idx);
}
bool triggered( const char * pathName ){
return triggerObjectMatchByPath(pathName,true,true)!=nullptr;
}

protected:

// ---- for content embedding ----
Expand Down Expand Up @@ -412,6 +400,7 @@ namespace pat {
float simPt_;
float simEta_;
float simPhi_;

};


Expand Down
115 changes: 0 additions & 115 deletions PhysicsTools/PatAlgos/plugins/PATMuonProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@
#include "JetMETCorrections/JetCorrector/interface/JetCorrector.h"

#include "PhysicsTools/PatAlgos/interface/SoftMuonMvaEstimator.h"
#include "DataFormats/PatCandidates/interface/TriggerObjectStandAlone.h"
#include "DataFormats/Math/interface/deltaR.h"
#include "DataFormats/Math/interface/deltaPhi.h"

#include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
#include "Geometry/CommonDetUnit/interface/GeomDet.h"

#include <vector>
#include <memory>
Expand Down Expand Up @@ -185,13 +179,6 @@ PATMuonProducer::PATMuonProducer(const edm::ParameterSet & iConfig, PATMuonHeavy
// MC info
simInfo_ = consumes<edm::ValueMap<reco::MuonSimInfo> >(iConfig.getParameter<edm::InputTag>("muonSimInfo"));

addTriggerMatching_ = iConfig.getParameter<bool>("addTriggerMatching");
if ( addTriggerMatching_ ){
triggerObjects_ = consumes<std::vector<pat::TriggerObjectStandAlone>>(iConfig.getParameter<edm::InputTag>("triggerObjects"));
triggerResults_ = consumes<edm::TriggerResults>(iConfig.getParameter<edm::InputTag>("triggerResults"));
}
hltCollectionFilters_ = iConfig.getParameter<std::vector<std::string>>("hltCollectionFilters");

// produces vector of muons
produces<std::vector<Muon> >();
}
Expand All @@ -201,91 +188,8 @@ PATMuonProducer::~PATMuonProducer()
{
}

std::unique_ptr<GlobalPoint> PATMuonProducer::getMuonDirection(const reco::MuonChamberMatch& chamberMatch,
const edm::ESHandle<GlobalTrackingGeometry>& geometry,
const DetId& chamberId)
{
const GeomDet* chamberGeometry = geometry->idToDet( chamberId );
if (chamberGeometry){
LocalPoint localPosition(chamberMatch.x, chamberMatch.y, 0);
return std::unique_ptr<GlobalPoint>(new GlobalPoint(chamberGeometry->toGlobal(localPosition)));
}
return std::unique_ptr<GlobalPoint>();

}


void PATMuonProducer::fillL1TriggerInfo(pat::Muon& aMuon,
edm::Handle<std::vector<pat::TriggerObjectStandAlone> >& triggerObjects,
const edm::TriggerNames & names,
const edm::ESHandle<GlobalTrackingGeometry>& geometry)
{
// L1 trigger object parameters are defined at MB2/ME2. Use the muon
// chamber matching information to get the local direction of the
// muon trajectory and convert it to a global direction to match the
// trigger objects

std::unique_ptr<GlobalPoint> muonPosition;
// loop over chambers
for ( const auto& chamberMatch: aMuon.matches() ) {
if ( chamberMatch.id.subdetId() == MuonSubdetId::DT) {
DTChamberId detId(chamberMatch.id.rawId());
if (abs(detId.station())!=2) continue;
muonPosition = std::move(getMuonDirection(chamberMatch, geometry, detId));
break;
}
if ( chamberMatch.id.subdetId() == MuonSubdetId::CSC) {
CSCDetId detId(chamberMatch.id.rawId());
if (abs(detId.station())!=2) continue;
muonPosition = std::move(getMuonDirection(chamberMatch, geometry, detId));
break;
}
}
if (not muonPosition) return;
for (const auto& triggerObject: *triggerObjects){
if (triggerObject.hasTriggerObjectType(trigger::TriggerL1Mu)){
if (deltaR(triggerObject.p4(),*muonPosition)>0.1) continue;
pat::TriggerObjectStandAlone obj(triggerObject);
obj.unpackPathNames(names);
aMuon.addTriggerObjectMatch(obj);
}
}
}

void PATMuonProducer::fillHltTriggerInfo(pat::Muon& muon,
edm::Handle<std::vector<pat::TriggerObjectStandAlone> >& triggerObjects,
const edm::TriggerNames & names,
const std::vector<std::string>& collection_filter_names)
{
// WARNING: in a case of close-by muons the dR matching may select both muons.
// It's better to select the best match for a given collection.
for (const auto& triggerObject: *triggerObjects){
if (triggerObject.hasTriggerObjectType(trigger::TriggerMuon)){
bool keepIt = false;
for (const auto& name: collection_filter_names){
if (triggerObject.hasCollection(name)){
keepIt = true;
break;
}
}
if (not keepIt) continue;
if ( deltaR(triggerObject.p4(),muon)>0.1 ) continue;
pat::TriggerObjectStandAlone obj(triggerObject);
obj.unpackPathNames(names);
muon.addTriggerObjectMatch(obj);
}
}
}


void PATMuonProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup)
{
// get the tracking Geometry
edm::ESHandle<GlobalTrackingGeometry> geometry;
iSetup.get<GlobalTrackingGeometryRecord>().get(geometry);
if ( ! geometry.isValid() )
throw cms::Exception("FatalError") << "Unable to find GlobalTrackingGeometryRecord in event!\n";

// switch off embedding (in unschedules mode)
if (iEvent.isRealData()){
addGenMatch_ = false;
Expand Down Expand Up @@ -619,24 +523,7 @@ void PATMuonProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetu
if (computeMuonMVA_) iEvent.getByToken(rho_,rho);
const reco::Vertex* pv(nullptr);
if (primaryVertexIsValid) pv = &primaryVertex;

edm::Handle<std::vector<pat::TriggerObjectStandAlone> > triggerObjects;
edm::Handle< edm::TriggerResults > triggerResults;
bool triggerObjectsAvailable = false;
bool triggerResultsAvailable = false;
if (addTriggerMatching_){
triggerObjectsAvailable = iEvent.getByToken(triggerObjects_, triggerObjects);
triggerResultsAvailable = iEvent.getByToken(triggerResults_, triggerResults);
}

for(auto& muon: *patMuons){
// trigger info
if (addTriggerMatching_ and triggerObjectsAvailable and triggerResultsAvailable){
const edm::TriggerNames & triggerNames(iEvent.triggerNames( *triggerResults ));
fillL1TriggerInfo(muon,triggerObjects,triggerNames,geometry);
fillHltTriggerInfo(muon,triggerObjects,triggerNames,hltCollectionFilters_);
}

if (recomputeBasicSelectors_){
muon.setSelectors(0);
bool isRun2016BCDEF = (272728 <= iEvent.run() && iEvent.run() <= 278808);
Expand Down Expand Up @@ -855,8 +742,6 @@ void PATMuonProducer::fillDescriptions(edm::ConfigurationDescriptions & descript
iDesc.add<edm::InputTag>("pfCandsForMiniIso", edm::InputTag("packedPFCandidates"))->setComment("collection to use to compute mini-iso");
iDesc.add<std::vector<double> >("miniIsoParams", std::vector<double>())->setComment("mini-iso parameters to use for muons");

iDesc.add<bool>("addTriggerMatching", false)->setComment("add L1 and HLT matching to offline muon");

pat::helper::KinResolutionsLoader::fillDescription(iDesc);

// IsoDeposit configurables
Expand Down
21 changes: 1 addition & 20 deletions PhysicsTools/PatAlgos/plugins/PATMuonProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
#include "PhysicsTools/PatAlgos/interface/MuonMvaEstimator.h"
#include "PhysicsTools/PatAlgos/interface/SoftMuonMvaEstimator.h"
#include "DataFormats/PatCandidates/interface/TriggerObjectStandAlone.h"
#include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
#include "DataFormats/Common/interface/TriggerResults.h"

namespace pat {

Expand Down Expand Up @@ -112,17 +109,7 @@ namespace pat {
bool beamspotIsValid );
double relMiniIsoPUCorrected( const pat::Muon& aMuon,
double rho);
std::unique_ptr<GlobalPoint> getMuonDirection(const reco::MuonChamberMatch& chamberMatch,
const edm::ESHandle<GlobalTrackingGeometry>& geometry,
const DetId& chamberId);
void fillL1TriggerInfo(pat::Muon& muon,
edm::Handle<std::vector<pat::TriggerObjectStandAlone> >& triggerObjects,
const edm::TriggerNames & names,
const edm::ESHandle<GlobalTrackingGeometry>& geometry);
void fillHltTriggerInfo(pat::Muon& muon,
edm::Handle<std::vector<pat::TriggerObjectStandAlone> >& triggerObjects,
const edm::TriggerNames & names,
const std::vector<std::string>& collection_names);

private:
/// input source
edm::EDGetTokenT<edm::View<reco::Muon> > muonToken_;
Expand Down Expand Up @@ -227,12 +214,6 @@ namespace pat {

/// MC info
edm::EDGetTokenT<edm::ValueMap<reco::MuonSimInfo> > simInfo_;

/// Trigger
bool addTriggerMatching_;
edm::EDGetTokenT<std::vector<pat::TriggerObjectStandAlone>> triggerObjects_;
edm::EDGetTokenT<edm::TriggerResults> triggerResults_;
std::vector<std::string> hltCollectionFilters_;
};

}
Expand Down
10 changes: 3 additions & 7 deletions PhysicsTools/PatAlgos/python/producersLayer1/muonProducer_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,8 @@
softMvaTrainingFile = cms.string("RecoMuon/MuonIdentification/data/TMVA-muonid-bmm4-B-25.weights.xml"),

# MC Info
muonSimInfo = cms.InputTag("muonSimClassifier"),

# Trigger Info
addTriggerMatching = cms.bool(True),
triggerObjects = cms.InputTag("slimmedPatTrigger"),
triggerResults = cms.InputTag("TriggerResults","","HLT"),
hltCollectionFilters = cms.vstring('*')
muonSimInfo = cms.InputTag("muonSimClassifier")

)


Expand All @@ -146,5 +141,6 @@






3 changes: 0 additions & 3 deletions PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,6 @@ def miniAOD_customizeCommon(process):
phase2_hgcal.toModify(task, func=lambda t: t.add(process.slimmedEgammaFromMultiClTask))



def miniAOD_customizeMC(process):
task = getPatAlgosToolsTask(process)
#GenJetFlavourInfos
Expand Down Expand Up @@ -530,6 +529,4 @@ def miniAOD_customizeAllMCFastSim(process):
process = miniAOD_customizeMETFiltersFastSim(process)
from PhysicsTools.PatAlgos.slimming.isolatedTracks_cfi import miniAOD_customizeIsolatedTracksFastSim
process = miniAOD_customizeIsolatedTracksFastSim(process)
process.patMuons.addTriggerMatching = False

return process
1 change: 0 additions & 1 deletion PhysicsTools/PatAlgos/test/IntegrationTest_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
patAlgosToolsTask.add(process.patCandidatesTask)
# Temporary customize to the unit tests that fail due to old input samples
process.patTaus.skipMissingTauID = True
process.patMuons.addTriggerMatching = False

process.load("PhysicsTools.PatAlgos.selectionLayer1.selectedPatCandidates_cff")
patAlgosToolsTask.add(process.selectedPatCandidatesTask)
Expand Down

0 comments on commit bcca149

Please sign in to comment.