Skip to content

Commit

Permalink
Merge pull request #19404 from kmcdermo/oot-photons-80XLegacy
Browse files Browse the repository at this point in the history
ootPhotons for 80X Legacy reprocessing
  • Loading branch information
cmsbuild authored Jul 3, 2017
2 parents 4cac99e + 73da687 commit d5de801
Show file tree
Hide file tree
Showing 15 changed files with 277 additions and 133 deletions.
16 changes: 12 additions & 4 deletions PhysicsTools/PatAlgos/plugins/PATPhotonProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ hConversionsToken_ = consumes<reco::ConversionCollection>(iConfig.getParameter<e
if (addPFClusterIso_)
{
ecalPFClusterIsoT_ = consumes<edm::ValueMap<float> >(iConfig.getParameter<edm::InputTag>("ecalPFClusterIsoMap"));
hcalPFClusterIsoT_ = consumes<edm::ValueMap<float> >(iConfig.getParameter<edm::InputTag>("hcalPFClusterIsoMap"));
auto hcPFC = iConfig.getParameter<edm::InputTag>("hcalPFClusterIsoMap");
if (not hcPFC.label().empty())
hcalPFClusterIsoT_ = consumes<edm::ValueMap<float> >(hcPFC);
}

// photon ID configurables
Expand Down Expand Up @@ -415,10 +417,16 @@ void PATPhotonProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSe
if (addPFClusterIso_) {
edm::Handle<edm::ValueMap<float> > ecalPFClusterIsoMapH;
iEvent.getByToken(ecalPFClusterIsoT_, ecalPFClusterIsoMapH);
edm::Handle<edm::ValueMap<float> > hcalPFClusterIsoMapH;
iEvent.getByToken(hcalPFClusterIsoT_, hcalPFClusterIsoMapH);
aPhoton.setEcalPFClusterIso((*ecalPFClusterIsoMapH)[photonRef]);
aPhoton.setHcalPFClusterIso((*hcalPFClusterIsoMapH)[photonRef]);
edm::Handle<edm::ValueMap<float> > hcalPFClusterIsoMapH;
if (not hcalPFClusterIsoT_.isUninitialized()){
iEvent.getByToken(hcalPFClusterIsoT_, hcalPFClusterIsoMapH);
aPhoton.setHcalPFClusterIso((*hcalPFClusterIsoMapH)[photonRef]);
}
else
{
aPhoton.setHcalPFClusterIso(-999.);
}
} else {
aPhoton.setEcalPFClusterIso(-999.);
aPhoton.setHcalPFClusterIso(-999.);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,16 @@
)

makePatOOTPhotons = cms.Sequence(makePatOOTPhotonsTask)

## For legacy reprocessing
from RecoEgamma.EgammaPhotonProducers.ootPhotonSequence_cff import *
from RecoEgamma.EgammaIsolationAlgos.pfClusterIsolation_cfi import ootPhotonEcalPFClusterIsolationProducer

from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
run2_miniAOD_80XLegacy.toReplaceWith(makePatOOTPhotonsTask, cms.Task(
ootPhotonTask,
ootPhotonEcalPFClusterIsolationProducer,
makePatOOTPhotonsTask.copy()
))

run2_miniAOD_80XLegacy.toModify(patOOTPhotons, hcalPFClusterIsoMap = "")
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,17 @@
particleFlowSuperClusterOOTECAL.isOOTCollection = cms.bool(True)
particleFlowSuperClusterOOTECAL.barrelRecHits = cms.InputTag("ecalRecHit","EcalRecHitsEB")
particleFlowSuperClusterOOTECAL.endcapRecHits = cms.InputTag("ecalRecHit","EcalRecHitsEE")

from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy

run2_miniAOD_80XLegacy.toModify(
particleFlowSuperClusterOOTECAL,
barrelRecHits = "reducedEcalRecHitsEB",
endcapRecHits = "reducedEcalRecHitsEE"
)
run2_miniAOD_80XLegacy.toModify(
particleFlowSuperClusterOOTECAL.regressionConfig,
ecalRecHitsEB = "reducedEcalRecHitsEB",
ecalRecHitsEE = "reducedEcalRecHitsEE"
)

29 changes: 25 additions & 4 deletions RecoEgamma/EgammaPhotonProducers/python/ootPhotonSequence_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,33 @@
from RecoParticleFlow.PFClusterProducer.particleFlowClusterOOTECALUncorrected_cff import *
from RecoParticleFlow.PFClusterProducer.particleFlowClusterOOTECAL_cff import *
from RecoEcal.EgammaClusterProducers.particleFlowSuperClusterOOTECAL_cff import *
from RecoEgamma.EgammaPhotonProducers.ootPhotons_cff import *
from RecoEgamma.EgammaPhotonProducers.ootPhotonCore_cff import *
from RecoEgamma.EgammaPhotonProducers.ootPhotons_cff import *

# sequence to make OOT photons from clusters in ECAL from full PFRecHits w/o timing cut

ootPhotonSequence = cms.Sequence(particleFlowOOTRecHitECAL*particleFlowClusterOOTECALUncorrected*particleFlowClusterOOTECAL*particleFlowSuperClusterOOTECAL*ootPhotonCore*ootPhotons)
# task+sequence to make OOT photons from clusters in ECAL from full PFRecHits w/o timing cut
ootPhotonTask = cms.Task(
particleFlowRecHitOOTECAL,
particleFlowClusterOOTECALUncorrected,
particleFlowClusterOOTECAL,
particleFlowSuperClusterOOTECAL,
ootPhotonCore,
ootPhotons
)

ootPhotonSequence = cms.Sequence(ootPhotonTask)

## For legacy reprocessing: need additional products
from RecoJets.Configuration.CaloTowersES_cfi import *
from RecoLocalCalo.EcalRecAlgos.EcalSeverityLevelESProducer_cfi import essourceEcalSev, ecalSeverityLevel
from RecoParticleFlow.PFClusterProducer.particleFlowRecHitPS_cfi import particleFlowRecHitPS
from RecoParticleFlow.PFClusterProducer.particleFlowClusterPS_cfi import particleFlowClusterPS

from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
run2_miniAOD_80XLegacy.toReplaceWith(ootPhotonTask, cms.Task(
CaloTowerConstituentsMapBuilder,
essourceEcalSev,
ecalSeverityLevel,
particleFlowRecHitPS,
particleFlowClusterPS,
ootPhotonTask.copy()
))
21 changes: 21 additions & 0 deletions RecoEgamma/EgammaPhotonProducers/python/ootPhotons_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,24 @@
valueMapPhotons = ""
)
del ootPhotons.regressionConfig

from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy

run2_miniAOD_80XLegacy.toModify(
ootPhotons,
barrelEcalHits = "reducedEcalRecHitsEB",
endcapEcalHits = "reducedEcalRecHitsEE",
preshowerHits = "reducedEcalRecHitsES",
hcalTowers = ""
)
run2_miniAOD_80XLegacy.toModify(
ootPhotons.isolationSumsCalculatorSet,
barrelEcalRecHitCollection = "reducedEcalRecHitsEB",
endcapEcalRecHitCollection = "reducedEcalRecHitsEE",
HcalRecHitCollection = ""
)
run2_miniAOD_80XLegacy.toModify(
ootPhotons.mipVariableSet,
barrelEcalRecHitCollection = "reducedEcalRecHitsEB",
endcapEcalRecHitCollection = "reducedEcalRecHitsEE",
)
7 changes: 7 additions & 0 deletions RecoEgamma/EgammaPhotonProducers/python/reducedEgamma_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,10 @@
phase2_common.toModify(reducedEgamma,
preshowerEcalHits = cms.InputTag(""),
)

from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
run2_miniAOD_80XLegacy.toModify(
reducedEgamma,
ootPhotonPFClusterIsoSources = [ "ootPhotonEcalPFClusterIsolationProducer" ],
ootPhotonPFClusterIsoOutput = [ "ootPhoEcalPFClusIso" ]
)
43 changes: 28 additions & 15 deletions RecoEgamma/EgammaPhotonProducers/src/GEDPhotonProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ GEDPhotonProducer::GEDPhotonProducer(const edm::ParameterSet& config) :
vertexProducer_ =
consumes<reco::VertexCollection>(conf_.getParameter<edm::InputTag>("primaryVertexProducer"));

hcalTowers_ =
consumes<CaloTowerCollection>(conf_.getParameter<edm::InputTag>("hcalTowers"));
auto hcTow = conf_.getParameter<edm::InputTag>("hcalTowers");
if (not hcTow.label().empty())
hcalTowers_ =
consumes<CaloTowerCollection>(hcTow);
//
photonCollection_ = conf_.getParameter<std::string>("outputPhotonCollection");
hOverEConeSize_ = conf_.getParameter<double>("hOverEConeSize");
Expand Down Expand Up @@ -335,8 +337,9 @@ void GEDPhotonProducer::produce(edm::Event& theEvent, const edm::EventSetup& the

// get Hcal towers collection
Handle<CaloTowerCollection> hcalTowersHandle;
theEvent.getByToken(hcalTowers_, hcalTowersHandle);

if (not hcalTowers_.isUninitialized()){
theEvent.getByToken(hcalTowers_, hcalTowersHandle);
}

// get the geometry from the event setup:
theEventSetup.get<CaloGeometryRecord>().get(theCaloGeom_);
Expand Down Expand Up @@ -503,17 +506,27 @@ void GEDPhotonProducer::fillPhotonCollection(edm::Event& evt,
ptFast(parentSCRef->energy(),parentSCRef->position(),math::XYZPoint(0,0,0)) <= preselCutValues[0] ) continue;
// calculate HoE

const CaloTowerCollection* hcalTowersColl = hcalTowersHandle.product();
EgammaTowerIsolation towerIso1(hOverEConeSize_,0.,0.,1,hcalTowersColl) ;
EgammaTowerIsolation towerIso2(hOverEConeSize_,0.,0.,2,hcalTowersColl) ;
double HoE1=towerIso1.getTowerESum(&(*scRef))/scRef->energy();
double HoE2=towerIso2.getTowerESum(&(*scRef))/scRef->energy();

EgammaHadTower towerIsoBehindClus(es);
towerIsoBehindClus.setTowerCollection(hcalTowersHandle.product());
std::vector<CaloTowerDetId> TowersBehindClus = towerIsoBehindClus.towersOf(*scRef);
float hcalDepth1OverEcalBc = towerIsoBehindClus.getDepth1HcalESum(TowersBehindClus)/scRef->energy();
float hcalDepth2OverEcalBc = towerIsoBehindClus.getDepth2HcalESum(TowersBehindClus)/scRef->energy();
double HoE1,HoE2;
HoE1=HoE2=0.;

std::vector<CaloTowerDetId> TowersBehindClus;
float hcalDepth1OverEcalBc,hcalDepth2OverEcalBc;
hcalDepth1OverEcalBc=hcalDepth2OverEcalBc=0.f;

if (not hcalTowers_.isUninitialized()) {
const CaloTowerCollection* hcalTowersColl = hcalTowersHandle.product();
EgammaTowerIsolation towerIso1(hOverEConeSize_,0.,0.,1,hcalTowersColl) ;
EgammaTowerIsolation towerIso2(hOverEConeSize_,0.,0.,2,hcalTowersColl) ;
HoE1=towerIso1.getTowerESum(&(*scRef))/scRef->energy();
HoE2=towerIso2.getTowerESum(&(*scRef))/scRef->energy();

EgammaHadTower towerIsoBehindClus(es);
towerIsoBehindClus.setTowerCollection(hcalTowersHandle.product());
TowersBehindClus = towerIsoBehindClus.towersOf(*scRef);
hcalDepth1OverEcalBc = towerIsoBehindClus.getDepth1HcalESum(TowersBehindClus)/scRef->energy();
hcalDepth2OverEcalBc = towerIsoBehindClus.getDepth2HcalESum(TowersBehindClus)/scRef->energy();
}

// std::cout << " GEDPhotonProducer calculation of HoE with towers in a cone " << HoE1 << " " << HoE2 << std::endl;
//std::cout << " GEDPhotonProducer calcualtion of HoE with towers behind the BCs " << hcalDepth1OverEcalBc << " " << hcalDepth2OverEcalBc << std::endl;

Expand Down
Loading

0 comments on commit d5de801

Please sign in to comment.