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

reduce memory used by iso deposits #17241

@@ -0,0 +1,17 @@
import FWCore.ParameterSet.Config as cms

import collections

def customiseEarlyDeleteForCandIsoDeposits(process, products):
# Find the producers

def _branchName(productType, moduleLabel, instanceLabel=""):
return "%s_%s_%s_%s" % (productType, moduleLabel, instanceLabel, process.name_())

for name, module in process.producers_().iteritems():
cppType = module._TypedParameterizable__type
if cppType == "CandIsoDepositProducer":
if module.ExtractorPSet.ComponentName in ["CandViewExtractor", "PFCandWithSuperClusterExtractor"] :
products[name].append(_branchName("recoIsoDepositedmValueMap", name))

return products
Expand Up @@ -15,7 +15,7 @@
ExtractorPSet = cms.PSet(
Diff_z = cms.double(99999.99),
ComponentName = cms.string('PFCandWithSuperClusterExtractor'),
DR_Max = cms.double(1.0),
DR_Max = cms.double(0.4),
Diff_r = cms.double(99999.99),
inputCandView = cms.InputTag("pfAllPhotonsPFBRECO"),
DR_Veto = cms.double(0),
Expand Down
Expand Up @@ -10,7 +10,7 @@
ExtractorPSet = cms.PSet(
Diff_z = cms.double(99999.99), #(0.2)
ComponentName = cms.string('CandViewExtractor'),
DR_Max = cms.double(1.0),
DR_Max = cms.double(0.4),
Diff_r = cms.double(99999.99), #(0.1)
inputCandView = cms.InputTag(""),
DR_Veto = cms.double(1e-05),
Expand Down
Expand Up @@ -15,7 +15,7 @@
ExtractorPSet = cms.PSet(
Diff_z = cms.double(99999.99),
ComponentName = cms.string('PFCandWithSuperClusterExtractor'),
DR_Max = cms.double(1.0),
DR_Max = cms.double(0.4),
Diff_r = cms.double(99999.99),
inputCandView = cms.InputTag("pfAllPhotonsPFBRECO"),
DR_Veto = cms.double(0),
Expand Down
Expand Up @@ -5,6 +5,7 @@
import FWCore.ParameterSet.Config as cms

from RecoTracker.Configuration.customiseEarlyDeleteForSeeding import customiseEarlyDeleteForSeeding
from CommonTools.ParticleFlow.Isolation.customiseEarlyDeleteForCandIsoDeposits import customiseEarlyDeleteForCandIsoDeposits

def _hasInputTagModuleLabel(process, pset, moduleLabel):
for name in pset.parameterNames_():
Expand Down Expand Up @@ -37,6 +38,8 @@ def customiseEarlyDelete(process):

products = customiseEarlyDeleteForSeeding(process, products)

products = customiseEarlyDeleteForCandIsoDeposits(process, products)

# Set process.options.canDeleteEarly
if not hasattr(process.options, "canDeleteEarly"):
process.options.canDeleteEarly = cms.untracked.vstring()
Expand Down
12 changes: 12 additions & 0 deletions RecoMuon/Configuration/python/RecoMuonCosmics_cff.py
Expand Up @@ -28,6 +28,8 @@
# need to modify track selection as well (not clear to what)
muons.TrackExtractorPSet.inputTrackCollection = 'ctfWithMaterialTracksP5LHCNavigation'
muons.CaloExtractorPSet.CenterConeOnCalIntersection = True
# set wide cone until the code is made to compute this wrt CalIntersection
muons.CaloExtractorPSet.DR_Max = 1.0

#similar to what's in pp configuration
muonsFromCosmics = muons1stStep.clone()
Expand Down Expand Up @@ -143,6 +145,8 @@
muonsWitht0Correction.TimingFillerParameters.MatchParameters.DTsegments = 'dt4DSegmentsT0Seg'
muonsWitht0Correction.TrackExtractorPSet.inputTrackCollection = 'ctfWithMaterialTracksP5'
muonsWitht0Correction.CaloExtractorPSet.CenterConeOnCalIntersection = True
# set wide cone until the code is made to compute this wrt CalIntersection
muonsWitht0Correction.CaloExtractorPSet.DR_Max = 1.0
muonsWitht0Correction.fillGlobalTrackRefits = False
#Sequences

Expand Down Expand Up @@ -193,6 +197,8 @@
muonsBeamHaloEndCapsOnly.fillGlobalTrackQuality = False
muonsBeamHaloEndCapsOnly.TrackExtractorPSet.inputTrackCollection = 'ctfWithMaterialTracksP5'
muonsBeamHaloEndCapsOnly.CaloExtractorPSet.CenterConeOnCalIntersection = True
# set wide cone until the code is made to compute this wrt CalIntersection
muonsBeamHaloEndCapsOnly.CaloExtractorPSet.DR_Max = 1.0
muonsBeamHaloEndCapsOnly.fillGlobalTrackRefits = False

# Sequences
Expand All @@ -219,6 +225,8 @@
muonsNoRPC.fillGlobalTrackQuality = False
muonsNoRPC.TrackExtractorPSet.inputTrackCollection = 'ctfWithMaterialTracksP5'
muonsNoRPC.CaloExtractorPSet.CenterConeOnCalIntersection = True
# set wide cone until the code is made to compute this wrt CalIntersection
muonsNoRPC.CaloExtractorPSet.DR_Max = 1.0
muonsNoRPC.fillGlobalTrackRefits = False

#Sequences
Expand Down Expand Up @@ -253,6 +261,8 @@
splitMuons.fillGlobalTrackQuality = False
splitMuons.TrackExtractorPSet.inputTrackCollection = 'splittedTracksP5'
splitMuons.CaloExtractorPSet.CenterConeOnCalIntersection = True
# set wide cone until the code is made to compute this wrt CalIntersection
splitMuons.CaloExtractorPSet.DR_Max = 1.0
splitMuons.fillGlobalTrackRefits = False

#Sequences
Expand All @@ -275,6 +285,8 @@
lhcSTAMuons.fillGlobalTrackQuality = False
lhcSTAMuons.TrackExtractorPSet.inputTrackCollection = 'ctfWithMaterialTracksP5LHCNavigation'
lhcSTAMuons.CaloExtractorPSet.CenterConeOnCalIntersection = True
# set wide cone until the code is made to compute this wrt CalIntersection
lhcSTAMuons.CaloExtractorPSet.DR_Max = 1.0
lhcSTAMuons.fillGlobalTrackRefits = False

# Final sequence
Expand Down
31 changes: 22 additions & 9 deletions RecoMuon/MuonIsolation/plugins/CaloExtractorByAssociator.cc
Expand Up @@ -22,15 +22,17 @@
#include "TrackingTools/TrackAssociator/interface/TrackDetectorAssociator.h"

#include "DataFormats/Math/interface/deltaR.h"
//#include "CommonTools/Utils/interface/deltaR.h"
//#include "PhysicsTools/Utilities/interface/deltaR.h"

using namespace edm;
using namespace std;
using namespace reco;
using namespace muonisolation;
using reco::isodeposit::Direction;

namespace {
constexpr double dRMax_CandDep = 1.0;//pick up candidate own deposits up to this dR if theDR_Max is smaller
}

CaloExtractorByAssociator::CaloExtractorByAssociator(const ParameterSet& par, edm::ConsumesCollector && iC) :
theUseRecHitsFlag(par.getParameter<bool>("UseRecHitsFlag")),
theDepositLabel(par.getUntrackedParameter<string>("DepositLabel")),
Expand Down Expand Up @@ -164,7 +166,7 @@ std::vector<IsoDeposit> CaloExtractorByAssociator::deposits( const Event & event
double cosTheta = 1./cosh(eHitPos.eta());
double energy = eHitCPtr->energy();
double et = energy*cosTheta;
if (deltar0 > theDR_Max
if (deltar0 > std::max(dRMax_CandDep, theDR_Max)
|| ! (et > theThreshold_E && energy > 3*noiseRecHit(eHitCPtr->detid()))) continue;

bool vetoHit = false;
Expand All @@ -184,6 +186,9 @@ std::vector<IsoDeposit> CaloExtractorByAssociator::deposits( const Event & event
}
}

//check theDR_Max only here to keep vetoHits being added to the veto energy
if (deltar0 > theDR_Max && ! vetoHit) continue;

if (vetoHit ){
depEcal.addCandEnergy(et);
} else {
Expand All @@ -200,7 +205,7 @@ std::vector<IsoDeposit> CaloExtractorByAssociator::deposits( const Event & event
double cosTheta = 1./cosh(hHitPos.eta());
double energy = hHitCPtr->energy();
double et = energy*cosTheta;
if (deltar0 > theDR_Max
if (deltar0 > std::max(dRMax_CandDep, theDR_Max)
|| ! (et > theThreshold_H && energy > 3*noiseRecHit(hHitCPtr->detid()))) continue;

bool vetoHit = false;
Expand All @@ -220,6 +225,9 @@ std::vector<IsoDeposit> CaloExtractorByAssociator::deposits( const Event & event
}
}

//check theDR_Max only here to keep vetoHits being added to the veto energy
if (deltar0 > theDR_Max && ! vetoHit) continue;

if (vetoHit ){
depHcal.addCandEnergy(et);
} else {
Expand All @@ -236,7 +244,7 @@ std::vector<IsoDeposit> CaloExtractorByAssociator::deposits( const Event & event
double cosTheta = 1./cosh(hoHitPos.eta());
double energy = hoHitCPtr->energy();
double et = energy*cosTheta;
if (deltar0 > theDR_Max
if (deltar0 > std::max(dRMax_CandDep, theDR_Max)
|| ! (et > theThreshold_HO && energy > 3*noiseRecHit(hoHitCPtr->detid()))) continue;

bool vetoHit = false;
Expand All @@ -256,6 +264,9 @@ std::vector<IsoDeposit> CaloExtractorByAssociator::deposits( const Event & event
}
}

//check theDR_Max only here to keep vetoHits being added to the veto energy
if (deltar0 > theDR_Max && ! vetoHit) continue;

if (vetoHit ){
depHOcal.addCandEnergy(et);
} else {
Expand All @@ -270,7 +281,7 @@ std::vector<IsoDeposit> CaloExtractorByAssociator::deposits( const Event & event
for (; calCI != mInfo.towers.end(); ++calCI){
const CaloTower* calCPtr = *calCI;
double deltar0 = reco::deltaR(muon,*calCPtr);
if (deltar0>theDR_Max) continue;
if (deltar0> std::max(dRMax_CandDep, theDR_Max)) continue;

//even more copy-pasting .. need to refactor
double etecal = calCPtr->emEt();
Expand Down Expand Up @@ -327,19 +338,21 @@ std::vector<IsoDeposit> CaloExtractorByAssociator::deposits( const Event & event
}
}

if (deltar0>theDR_Max && !(vetoTowerEcal || vetoTowerHcal || vetoTowerHOCal)) continue;

reco::isodeposit::Direction towerDir(calCPtr->eta(), calCPtr->phi());
//! add the Et of the tower to deposits if it's not a vetoed; put into muonEnergy otherwise
if (doEcal){
if (vetoTowerEcal) depEcal.addCandEnergy(etecal);
else depEcal.addDeposit(towerDir, etecal);
else if (deltar0<=theDR_Max) depEcal.addDeposit(towerDir, etecal);
}
if (doHcal){
if (vetoTowerHcal) depHcal.addCandEnergy(ethcal);
else depHcal.addDeposit(towerDir, ethcal);
else if (deltar0<=theDR_Max) depHcal.addDeposit(towerDir, ethcal);
}
if (doHOcal){
if (vetoTowerHOCal) depHOcal.addCandEnergy(ethocal);
else depHOcal.addDeposit(towerDir, ethocal);
else if (deltar0<=theDR_Max) depHOcal.addDeposit(towerDir, ethocal);
}
}
}
Expand Down
Expand Up @@ -13,7 +13,7 @@
Noise_EB = cms.double(0.025),
Noise_HO = cms.double(0.2),
CenterConeOnCalIntersection = cms.bool(False),
DR_Max = cms.double(1.0),
DR_Max = cms.double(0.5),
PropagatorName = cms.string('SteppingHelixPropagatorAny'),
ServiceParameters = cms.PSet(
Propagators = cms.untracked.vstring( 'SteppingHelixPropagatorAny' ),
Expand Down Expand Up @@ -44,7 +44,7 @@
Noise_EB = cms.double(0.025),
Noise_HO = cms.double(0.2),
CenterConeOnCalIntersection = cms.bool(False),
DR_Max = cms.double(1.0),
DR_Max = cms.double(0.5),
PropagatorName = cms.string('SteppingHelixPropagatorAny'),
ServiceParameters = cms.PSet(
Propagators = cms.untracked.vstring( 'SteppingHelixPropagatorAny' ),
Expand Down
Expand Up @@ -6,7 +6,7 @@
inputTrackCollection = cms.InputTag("generalTracks"),
BeamSpotLabel = cms.InputTag("offlineBeamSpot"),
ComponentName = cms.string('TrackExtractor'),
DR_Max = cms.double(1.0),
DR_Max = cms.double(0.5),
Diff_r = cms.double(0.1),
Chi2Prob_Min = cms.double(-1.0),
DR_Veto = cms.double(0.01),
Expand All @@ -21,7 +21,7 @@
inputTrackCollection = cms.InputTag("generalTracks"),
BeamSpotLabel = cms.InputTag("offlineBeamSpot"),
ComponentName = cms.string('TrackExtractor'),
DR_Max = cms.double(1.0),
DR_Max = cms.double(0.5),
Diff_r = cms.double(0.1),
Chi2Prob_Min = cms.double(-1.0),
DR_Veto = cms.double(0.01),
Expand All @@ -36,7 +36,7 @@
inputTrackCollection = cms.InputTag("ctfGSWithMaterialTracks"),
BeamSpotLabel = cms.InputTag("offlineBeamSpot"),
ComponentName = cms.string('TrackExtractor'),
DR_Max = cms.double(1.0),
DR_Max = cms.double(0.5),
Diff_r = cms.double(0.1),
Chi2Prob_Min = cms.double(-1.0),
DR_Veto = cms.double(0.01),
Expand Down
Expand Up @@ -15,7 +15,7 @@
ExtractorPSet = cms.PSet(
Diff_z = cms.double(99999.99),
ComponentName = cms.string('PFCandWithSuperClusterExtractor'),
DR_Max = cms.double(1.0),
DR_Max = cms.double(0.4),
Diff_r = cms.double(99999.99),
inputCandView = cms.InputTag("pfAllPhotons"),
DR_Veto = cms.double(0),
Expand Down
Expand Up @@ -15,7 +15,7 @@
ExtractorPSet = cms.PSet(
Diff_z = cms.double(99999.99),
ComponentName = cms.string('PFCandWithSuperClusterExtractor'),
DR_Max = cms.double(1.0),
DR_Max = cms.double(0.4),
Diff_r = cms.double(99999.99),
inputCandView = cms.InputTag("pfAllPhotons"),
DR_Veto = cms.double(0),
Expand Down