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

Protections for jets and MET for PFEGamma and customize function to switch on PFEG in ParticleFlow REDUX #1242

Merged
merged 26 commits into from Nov 1, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a4fa11b
working on eleMva calculation
lgray Oct 15, 2013
6baa842
Old eleMva resurrected, working on protections / bitmasks
lgray Oct 16, 2013
2ca8c63
add back old dataformat
lgray Oct 16, 2013
d4958ba
get old electron mva output in PFEG mostly inline with PFElectronAlgo
lgray Oct 17, 2013
acdc1cc
fill electron veto bits
lgray Oct 18, 2013
fb76076
change to new model for extra information, now stores ElementsInBlock…
lgray Oct 18, 2013
4490120
fix crash in PFEGammaAlgo when no brems present
lgray Oct 20, 2013
3643a76
include function to switch on PFEG and off gsfElectrons,etc
lgray Oct 21, 2013
05e1420
fix crash in BremTangents
lgray Oct 22, 2013
a8e9582
working on PFEGCandidate checker
lgray Oct 23, 2013
6d14ca8
some simply analyzers and batch scripts
lgray Oct 24, 2013
26f69cc
protections part 1
dbenedet Oct 24, 2013
28b6b5d
protections part 2
dbenedet Oct 24, 2013
d54fcb6
protections part 3
dbenedet Oct 24, 2013
8cc7aa7
fix bad merge conflict resolution
lgray Oct 25, 2013
3e441e5
Protections against spurious PFclusters using residual minimization
lgray Oct 27, 2013
d33dae5
customization to turn on EGammaGED
lgray Oct 29, 2013
4d208bb
customize script for PFEG + GED switch, and associated patches for so…
lgray Oct 29, 2013
fe08e11
fixes to make the matrix really run (remove a few things in harvestin…
lgray Oct 29, 2013
830d067
add even more cluster protections
lgray Oct 30, 2013
2a484e6
provide a better interface for the protections
lgray Oct 30, 2013
cfbbf33
move combination.hpp and update PFEG
lgray Oct 30, 2013
2b2f7ae
customize fixes
lgray Oct 30, 2013
31ea1d3
remote commit conflict garbage
lgray Oct 30, 2013
f774cae
pass autoptrs up by reference, avoid accidentally resetting lists
lgray Oct 31, 2013
7e6bbf3
remove interesting det id collectors for old-pf collections when turn…
lgray Oct 31, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions DataFormats/CaloRecHit/src/classes.h
Expand Up @@ -15,6 +15,9 @@ namespace {
edm::Wrapper<edm::ValueMap<reco::CaloCluster> > wvmv11;
std::vector<reco::CaloClusterPtr> v12;
// reco::CaloClusterCollection v1; // ambiguity with std::vector<reco::CaloCluster> v11
edm::Wrapper<std::vector<std::pair<unsigned long,edm::Ptr<reco::CaloCluster> > > > wveepsassocold;
std::vector<std::pair<unsigned long,edm::Ptr<reco::CaloCluster> > > veepsassocold;
std::pair<unsigned long, edm::Ptr<reco::CaloCluster> > eepsassocold;
std::pair<DetId,float> hitAndFraction;
std::vector<std::pair<DetId,float> > hitsAndFractions;
edm::Ptr<reco::CaloCluster> p1;
Expand Down
4 changes: 3 additions & 1 deletion DataFormats/CaloRecHit/src/classes_def.xml
Expand Up @@ -6,7 +6,9 @@
<version ClassVersion="10" checksum="3936140"/>
<version ClassVersion="11" checksum="2938838489"/>
</class>

<class name="edm::Wrapper<std::vector<std::pair<unsigned long,edm::Ptr<reco::CaloCluster> > > >"/>
<class name="std::vector<std::pair<unsigned long,edm::Ptr<reco::CaloCluster> > >"/>
<class name="std::pair<unsigned long, edm::Ptr<reco::CaloCluster> >"/>
<class name="edm::RefToBase<CaloRecHit>"/>
<class name="edm::Ptr<reco::CaloCluster>"/>
<class name="edm::PtrVector<reco::CaloCluster>"/>
Expand Down
Expand Up @@ -6,6 +6,10 @@
#include "DataFormats/Math/interface/LorentzVector.h"
#include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
#include "DataFormats/EgammaCandidates/interface/ConversionFwd.h"
#include "DataFormats/ParticleFlowReco/interface/PFBlock.h"
#include "DataFormats/ParticleFlowReco/interface/PFBlockFwd.h"
#include "DataFormats/ParticleFlowReco/interface/PFBlockElementTrack.h"
#include "DataFormats/ParticleFlowReco/interface/PFBlockElementCluster.h"

#include <iosfwd>

Expand All @@ -15,6 +19,9 @@ namespace reco {
* extra information on the photon/electron particle candidate from particle flow
*
*/
typedef std::pair<reco::PFBlockRef, unsigned> ElementInBlock;
typedef std::vector< ElementInBlock > ElementsInBlocks;

class PFCandidateEGammaExtra {
public:
enum StatusFlag {
Expand Down Expand Up @@ -47,6 +54,21 @@ namespace reco {
MVA_LAST
};

enum ElectronVetoes {
kFailsMVA,
kKFTracksOnGSFCluster, // any number of additional tracks on GSF cluster
kFailsTrackAndHCALIso, // > 3 kfs on Gsf-cluster, bad h/e
kKillAdditionalKFs, // tracks with hcal linkbut good gsf etot/p_in
kItIsAPion, // bad H/P_in, H/H+E, and E_tot/P_in
kCrazyEoverP, // screwey track linking / weird GSFs
kTooLargeAngle, // angle between GSF and RSC centroid too large
kN_EVETOS
};

enum PhotonVetoes {
kFailsTrackIso, // the photon fails tracker isolation
kN_PHOVETOS
};

public:
/// constructor
Expand All @@ -62,11 +84,22 @@ namespace reco {
/// set kf track reference
void setKfTrackRef(const reco::TrackRef & ref);

/// set gsf electron cluster ref
void setGsfElectronClusterRef(const reco::PFBlockRef& blk,
const reco::PFBlockElementCluster& ref) {
eleGsfCluster_ = ElementInBlock(blk,ref.index());
}

/// return a reference to the corresponding GSF track
reco::GsfTrackRef gsfTrackRef() const { return gsfTrackRef_; }

/// return a reference to the corresponding KF track
reco::TrackRef kfTrackRef() const { return kfTrackRef_; }
reco::TrackRef kfTrackRef() const { return kfTrackRef_; }

/// return a reference to the electron cluster ref
const ElementInBlock& gsfElectronClusterRef() const {
return eleGsfCluster_;
}

/// return a reference to the corresponding supercluster
reco::SuperClusterRef superClusterRef() const {return scRef_ ; }
Expand Down Expand Up @@ -143,6 +176,16 @@ namespace reco {
float hadEnergy() const {return hadEnergy_;}
float sigmaEtaEta() const {return sigmaEtaEta_;}

/// track counting for electrons and photons
void addExtraNonConvTrack(const reco::PFBlockRef& blk,
const reco::PFBlockElementTrack& tkref) {
if( !tkref.trackType(reco::PFBlockElement::T_FROM_GAMMACONV) ) {
assoNonConvExtraTracks_.push_back(std::make_pair(blk,tkref.index()));
}
}
const ElementsInBlocks& extraNonConvTracks() const {
return assoNonConvExtraTracks_;
}

private:
void setVariable(MvaVariable type,float var);
Expand All @@ -152,6 +195,8 @@ namespace reco {
reco::GsfTrackRef gsfTrackRef_;
/// Ref to the KF track
reco::TrackRef kfTrackRef_;
/// Ref to the electron gsf cluster;
ElementInBlock eleGsfCluster_;

/// Ref to (refined) supercluster
reco::SuperClusterRef scRef_;
Expand All @@ -161,14 +206,18 @@ namespace reco {

/// vector of TrackRef from Single Leg conversions
std::vector<reco::TrackRef> assoSingleLegRefTrack_;

// information for track matching
ElementsInBlocks assoNonConvExtraTracks_;

/// vector of Mvas from Single Leg conversions
std::vector<float> assoSingleLegMva_;

/// vector of ConversionRef from PF
reco::ConversionRefVector assoConversionsRef_;

/// energy of individual clusters (corrected). The first cluster is the seed
/// energy of individual clusters (corrected).
/// The first cluster is the seed
std::vector<float> clusterEnergies_;

/// mva variables - transient !
Expand Down
2 changes: 1 addition & 1 deletion HLTriggerOffline/Top/interface/TopValidation.h
Expand Up @@ -102,7 +102,7 @@ class TopValidation : public edm::EDAnalyzer {

bool outputMEsInRootFile;


edm::InputTag offlineElectrons;

edm::ParameterSet parameters;

Expand Down
3 changes: 2 additions & 1 deletion HLTriggerOffline/Top/python/topvalidation_cfi.py
Expand Up @@ -11,6 +11,7 @@

OutputFileName = cms.string(''),
# DQMFolder = cms.untracked.string("HLT/Top")
FolderName = cms.string("HLT/Top/")
FolderName = cms.string("HLT/Top/"),
offlineElectrons = cms.InputTag('gsfElectrons')

)
6 changes: 4 additions & 2 deletions HLTriggerOffline/Top/src/TopValidation.cc
Expand Up @@ -35,7 +35,9 @@ TopValidation::TopValidation(const edm::ParameterSet& iConfig)
// triggerTag_ = iConfig.getUntrackedParameter<string>("DQMFolder","HLT/Top");
outputFileName = iConfig.getParameter<std::string>("OutputFileName");
outputMEsInRootFile = iConfig.getParameter<bool>("OutputMEsInRootFile");
FolderName_ = iConfig.getParameter<std::string>("FolderName");
FolderName_ = iConfig.getParameter<std::string>("FolderName");
offlineElectrons =
iConfig.getParameter<edm::InputTag>("offlineElectrons");

topFolder << FolderName_ ;

Expand Down Expand Up @@ -82,7 +84,7 @@ TopValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
// electron collection
Handle<reco::GsfElectronCollection> electronsH;
// iEvent.getByLabel("pixelMatchGsfElectrons",electronsH);
iEvent.getByLabel("gsfElectrons",electronsH);
iEvent.getByLabel(offlineElectrons,electronsH);

// Trigger
Handle<TriggerResults> trh;
Expand Down
4 changes: 2 additions & 2 deletions PhysicsTools/PatAlgos/python/tools/helpers.py
Expand Up @@ -163,8 +163,8 @@ def standardizeInputTagFmt(inputTag):

def enter(self,visitee):
label = ''
try: label = visitee.label_()
except AttributeError: label = '<Module not in a Process>'
#try: label = visitee.label_()
#except AttributeError: label = '<Module not in a Process>'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sanity check should not simply be switched off.

self.doIt(visitee, label)
def leave(self,visitee):
pass
Expand Down
Expand Up @@ -98,7 +98,7 @@ class PFECALSuperClusterAlgo {

std::auto_ptr<reco::SuperClusterCollection>&
getEBOutputSCCollection() { return superClustersEB_; }
std::auto_ptr<reco::SuperClusterCollection>
std::auto_ptr<reco::SuperClusterCollection>&
getEEOutputSCCollection() { return superClustersEE_; }

void loadAndSortPFClusters(const edm::View<reco::PFCluster>& ecalclusters,
Expand Down
2 changes: 1 addition & 1 deletion RecoEcal/EgammaClusterAlgos/src/PFECALSuperClusterAlgo.cc
Expand Up @@ -348,7 +348,7 @@ buildSuperCluster(CalibClusterPtr& seed,
posZ += energyweight * cluspos.Z();

energyweighttot += energyweight;
corrSCEnergy += clus->energy();
corrSCEnergy += clus->energy();
corrPS1Energy += ePS1;
corrPS2Energy += ePS2;
}
Expand Down
197 changes: 197 additions & 0 deletions RecoEgamma/Configuration/python/customizePFforEGammaGED.py
@@ -0,0 +1,197 @@
import FWCore.ParameterSet.Config as cms
import FWCore.ParameterSet.Utilities as psu
from PhysicsTools.PatAlgos.tools.helpers import massSearchReplaceAnyInputTag as _replaceTags

def customizePFforEGammaGED(process):
for path in process.paths:
sequences = getattr(process,path)
#for seq in path:
_replaceTags(sequences,
cms.InputTag('gsfElectrons'),
cms.InputTag('gedGsfElectrons'))
_replaceTags(sequences,
cms.InputTag('gsfElectronCores'),
cms.InputTag('gedGsfElectronCores'))

# all the rest:
if hasattr(process,'DigiToRaw'):
process=_customize_DigiToRaw(process)
if hasattr(process,'RawToDigi'):
process=_customize_RawToDigi(process)
if hasattr(process,'reconstruction'):
process=_customize_Reco(process)
if hasattr(process,'reconstructionWithFamos'):
process=_customize_FastSim(process)
if hasattr(process,'digitisation_step'):
process=_customize_Digi(process)
if hasattr(process,'HLTSchedule'):
process=_customize_HLT(process)
if hasattr(process,'L1simulation_step'):
process=_customize_L1Emulator(process)
if hasattr(process,'dqmoffline_step'):
process=_customize_DQM(process)
if hasattr(process,'dqmHarvesting'):
process=_customize_harvesting(process)
if hasattr(process,'validation_step'):
process=_customize_Validation(process)


return process

def _configurePFForGEDEGamma(process):
process.particleFlowTmp.useEGammaFilters = cms.bool(True)
process.particleFlowTmp.usePFPhotons = cms.bool(False)
process.particleFlowTmp.usePFElectrons = cms.bool(False)
process.particleFlow.GsfElectrons = cms.InputTag('gedGsfElectrons')
process.particleFlow.Photons = cms.InputTag('gedPhotons')
return process



def _customize_DQM(process):
return process


def _customize_Validation(process):
_replaceTags(process.validation_step,
cms.InputTag('gsfElectrons'),
cms.InputTag('gedGsfElectrons'))
_replaceTags(process.validation_step,
cms.InputTag('gsfElectronCores'),
cms.InputTag('gedGsfElectronCores'))
#don't ask... just don't ask
if hasattr(process,'HLTSusyExoValFastSim'):
process.HLTSusyExoValFastSim.PlotMakerRecoInput.electrons = \
cms.string('gedGsfElectrons')
for pset in process.HLTSusyExoValFastSim.reco_parametersets:
pset.electrons = cms.string('gedGsfElectrons')
if hasattr(process,'HLTSusyExoVal'):
process.HLTSusyExoVal.PlotMakerRecoInput.electrons = \
cms.string('gedGsfElectrons')
for pset in process.HLTSusyExoVal.reco_parametersets:
pset.electrons = cms.string('gedGsfElectrons')
if hasattr(process,'hltHiggsValidator'):
process.hltHiggsValidator.H2tau.recElecLabel = \
cms.string('gedGsfElectrons')
process.hltHiggsValidator.HZZ.recElecLabel = \
cms.string('gedGsfElectrons')
process.hltHiggsValidator.HWW.recElecLabel = \
cms.string('gedGsfElectrons')
if hasattr(process,'oldpfPhotonValidation'):
process.photonValidationSequence.remove(process.oldpfPhotonValidation)
return process


def _customize_Digi(process):
return process


def _customize_L1Emulator(process):
return process


def _customize_RawToDigi(process):
return process


def _customize_DigiToRaw(process):
return process


def _customize_HLT(process):
return process

def _customize_FastSim(process):
process=_configurePFForGEDEGamma(process)
process.famosParticleFlowSequence.remove(process.pfElectronTranslatorSequence)
process.famosParticleFlowSequence.remove(process.pfPhotonTranslatorSequence)
process.egammaHighLevelRecoPostPF.remove(process.gsfElectronMergingSequence)
process.reducedEcalRecHitsEB.interestingDetIdCollections = cms.VInputTag(
# ecal
cms.InputTag("interestingEcalDetIdEB"),
cms.InputTag("interestingEcalDetIdEBU"),
# egamma
cms.InputTag("interestingEleIsoDetIdEB"),
cms.InputTag("interestingGamIsoDetIdEB"),
# tau
#cms.InputTag("caloRecoTauProducer"),
#pf
#cms.InputTag("pfElectronInterestingEcalDetIdEB"),
#cms.InputTag("pfPhotonInterestingEcalDetIdEB"),
# muons
cms.InputTag("muonEcalDetIds"),
# high pt tracks
cms.InputTag("interestingTrackEcalDetIds")
)
process.reducedEcalRecHitsEE.interestingDetIdCollections = cms.VInputTag(
# ecal
cms.InputTag("interestingEcalDetIdEE"),
# egamma
cms.InputTag("interestingEleIsoDetIdEE"),
cms.InputTag("interestingGamIsoDetIdEE"),
# tau
#cms.InputTag("caloRecoTauProducer"),
#pf
#cms.InputTag("pfElectronInterestingEcalDetIdEE"),
#cms.InputTag("pfPhotonInterestingEcalDetIdEE"),
# muons
cms.InputTag("muonEcalDetIds"),
# high pt tracks
cms.InputTag("interestingTrackEcalDetIds")
)

if hasattr(process,'ecalDrivenElectronSeeds'):
process.ecalDrivenElectronSeeds.barrelSuperClusters = cms.InputTag('particleFlowSuperClusterECAL:particleFlowSuperClusterECALBarrel')
process.ecalDrivenElectronSeeds.endcapSuperClusters = cms.InputTag('particleFlowSuperClusterECAL:particleFlowSuperClusterECALEndcapWithPreshower')
return process


def _customize_Reco(process):
process=_configurePFForGEDEGamma(process)
process.particleFlowReco.remove(process.pfElectronTranslatorSequence)
process.particleFlowReco.remove(process.pfPhotonTranslatorSequence)
process.egammaHighLevelRecoPostPF.remove(process.gsfElectronMergingSequence)
process.reducedEcalRecHitsEB.interestingDetIdCollections = cms.VInputTag(
# ecal
cms.InputTag("interestingEcalDetIdEB"),
cms.InputTag("interestingEcalDetIdEBU"),
# egamma
cms.InputTag("interestingEleIsoDetIdEB"),
cms.InputTag("interestingGamIsoDetIdEB"),
# tau
#cms.InputTag("caloRecoTauProducer"),
#pf
#cms.InputTag("pfElectronInterestingEcalDetIdEB"),
#cms.InputTag("pfPhotonInterestingEcalDetIdEB"),
# muons
cms.InputTag("muonEcalDetIds"),
# high pt tracks
cms.InputTag("interestingTrackEcalDetIds")
)
process.reducedEcalRecHitsEE.interestingDetIdCollections = cms.VInputTag(
# ecal
cms.InputTag("interestingEcalDetIdEE"),
# egamma
cms.InputTag("interestingEleIsoDetIdEE"),
cms.InputTag("interestingGamIsoDetIdEE"),
# tau
#cms.InputTag("caloRecoTauProducer"),
#pf
#cms.InputTag("pfElectronInterestingEcalDetIdEE"),
#cms.InputTag("pfPhotonInterestingEcalDetIdEE"),
# muons
cms.InputTag("muonEcalDetIds"),
# high pt tracks
cms.InputTag("interestingTrackEcalDetIds")
)

if hasattr(process,'ecalDrivenElectronSeeds'):
process.ecalDrivenElectronSeeds.barrelSuperClusters = cms.InputTag('particleFlowSuperClusterECAL:particleFlowSuperClusterECALBarrel')
process.ecalDrivenElectronSeeds.endcapSuperClusters = cms.InputTag('particleFlowSuperClusterECAL:particleFlowSuperClusterECALEndcapWithPreshower')
return process


def _customize_harvesting(process):
if hasattr(process,'oldpfPhotonPostprocessing'):
process.photonPostProcessor.remove(process.oldpfPhotonPostprocessing)
return process