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

EGM ID Update 80X #12740

Merged
merged 6 commits into from
Dec 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def miniAOD_customizeCommon(process):
setupAllVIDIdsInModule(process,idmod,setupVIDElectronSelection,None,False)

#VID Photon IDs
photon_ids = ['RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_PHYS14_PU20bx25_V2p1_cff',
photon_ids = ['RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring15_25ns_V1_cff',
'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring15_50ns_V1_cff',
'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring15_25ns_nonTrig_V2p1_cff',
'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring15_50ns_nonTrig_V2p1_cff']
Expand Down
4 changes: 2 additions & 2 deletions RecoEgamma/EgammaTools/src/EffectiveAreas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ void EffectiveAreas::checkConsistency() const {
<< "eta ranges improperly defined (disjointed) in the file "
<< filename_ << std::endl;

// The effective area should be a positive number,
// The effective area should be non-negative number,
// and should be less than the whole calorimeter area
// eta range -2.5 to 2.5, phi 0 to 2pi => Amax = 5*2*pi ~= 31.4
if( !( effectiveAreaValues_[iEta] > 0
if( !( effectiveAreaValues_[iEta] >= 0
&& effectiveAreaValues_[iEta] < 31.4 ) )
throw cms::Exception("EffectiveAreas config failure")
<< "effective area values are too large or negative in the file"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file contains Effective Area constants for
# computing pile-up corrections for the charged hadron isolation
# for a photon object.
#
# ALL CONSTANTS ARE ZEROED because it was determined that it is best
# not to correct the charged isolation for pile-up this time.
#
# |eta| min |eta| max effective area
0.0000 1.0000 0.0
1.0000 1.4790 0.0
1.4790 2.0000 0.0
2.0000 2.2000 0.0
2.2000 2.3000 0.0
2.3000 2.4000 0.0
2.4000 5.0000 0.0
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file contains Effective Area constants for
# computing pile-up corrections for the photons isolation
# computing pile-up corrections for the charged hadron isolation
# for a photon object.
#
# |eta| min |eta| max effective area
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file contains Effective Area constants for
# computing pile-up corrections for the neutral hadron isolation
# for a photon object.
#
# The effective areas are derived based on the 90% contour method.
#
# |eta| min |eta| max effective area
0.0000 1.0000 0.0599
1.0000 1.4790 0.0819
1.4790 2.0000 0.0696
2.0000 2.2000 0.0360
2.2000 2.3000 0.0360
2.3000 2.4000 0.0462
2.4000 5.0000 0.0656
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file contains Effective Area constants for
# computing pile-up corrections for the photons isolation
# computing pile-up corrections for the neutral hadron isolation
# for a photon object.
#
# |eta| min |eta| max effective area
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file contains Effective Area constants for
# computing pile-up corrections for the photons isolation
# for a photon object.
#
# The constants are based on 90% contours of isolation.
#
# |eta| min |eta| max effective area
0.0000 1.0000 0.1271
1.0000 1.4790 0.1101
1.4790 2.0000 0.0756
2.0000 2.2000 0.1175
2.2000 2.3000 0.1498
2.3000 2.4000 0.1857
2.4000 5.0000 0.2183
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
#include "PhysicsTools/SelectorUtils/interface/CutApplicatorWithEventContentBase.h"
#include "DataFormats/EgammaCandidates/interface/Photon.h"
#include "RecoEgamma/EgammaTools/interface/EffectiveAreas.h"


class PhoAnyPFIsoWithEAAndQuadScalingCut : public CutApplicatorWithEventContentBase {
public:
PhoAnyPFIsoWithEAAndQuadScalingCut(const edm::ParameterSet& c);

result_type operator()(const reco::PhotonPtr&) const override final;

void setConsumes(edm::ConsumesCollector&) override final;
void getEventContent(const edm::EventBase&) override final;

double value(const reco::CandidatePtr& cand) const override final;

CandidateType candidateType() const override final {
return PHOTON;
}

private:
// Cut values
float _C1_EB;
float _C2_EB;
float _C3_EB;
float _C1_EE;
float _C2_EE;
float _C3_EE;
// Configuration
float _barrelCutOff;
bool _useRelativeIso;
// Effective area constants
EffectiveAreas _effectiveAreas;
// The isolations computed upstream
edm::Handle<edm::ValueMap<float> > _anyPFIsoMap;
// The rho
edm::Handle< double > _rhoHandle;

constexpr static char anyPFIsoWithEA_[] = "anyPFIsoWithEA";
constexpr static char rhoString_ [] = "rho";
};

constexpr char PhoAnyPFIsoWithEAAndQuadScalingCut::anyPFIsoWithEA_[];
constexpr char PhoAnyPFIsoWithEAAndQuadScalingCut::rhoString_[];

DEFINE_EDM_PLUGIN(CutApplicatorFactory,
PhoAnyPFIsoWithEAAndQuadScalingCut,
"PhoAnyPFIsoWithEAAndQuadScalingCut");

PhoAnyPFIsoWithEAAndQuadScalingCut::PhoAnyPFIsoWithEAAndQuadScalingCut(const edm::ParameterSet& c) :
CutApplicatorWithEventContentBase(c),
_C1_EB(c.getParameter<double>("C1_EB")),
_C2_EB(c.getParameter<double>("C2_EB")),
_C3_EB(c.getParameter<double>("C3_EB")),
_C1_EE(c.getParameter<double>("C1_EE")),
_C2_EE(c.getParameter<double>("C2_EE")),
_C3_EE(c.getParameter<double>("C3_EE")),
_barrelCutOff(c.getParameter<double>("barrelCutOff")),
_useRelativeIso(c.getParameter<bool>("useRelativeIso")),
_effectiveAreas( (c.getParameter<edm::FileInPath>("effAreasConfigFile")).fullPath())
{

edm::InputTag maptag = c.getParameter<edm::InputTag>("anyPFIsoMap");
contentTags_.emplace(anyPFIsoWithEA_,maptag);

edm::InputTag rhoTag = c.getParameter<edm::InputTag>("rho");
contentTags_.emplace(rhoString_,rhoTag);

}

void PhoAnyPFIsoWithEAAndQuadScalingCut::setConsumes(edm::ConsumesCollector& cc) {
auto anyPFIsoWithEA =
cc.consumes<edm::ValueMap<float> >(contentTags_[anyPFIsoWithEA_]);
contentTokens_.emplace(anyPFIsoWithEA_,anyPFIsoWithEA);

auto rho = cc.consumes<double>(contentTags_[rhoString_]);
contentTokens_.emplace(rhoString_, rho);
}

void PhoAnyPFIsoWithEAAndQuadScalingCut::getEventContent(const edm::EventBase& ev) {
ev.getByLabel(contentTags_[anyPFIsoWithEA_],_anyPFIsoMap);
ev.getByLabel(contentTags_[rhoString_],_rhoHandle);
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be better to use getByToken() here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is necessary for the classes to operate in (py)FWLite and full CMSSW.
The consumes interface does not exist in edm::EventBase.

Copy link
Contributor

Choose a reason for hiding this comment

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

An explanatory comment to that effect would be helpful here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You cannot call consumes in FWLite and thus getbytoken cannot work. Likewise the accessor's are not available in edm::EventBase and cannot be used in this function.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Dr15Jones - can we can this behavior?

Copy link
Contributor

Choose a reason for hiding this comment

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

@davidlange6 Are you asking if we can get rid of this behavior? That is you want us to invent a new mechanism in FWLite to allow equivalent consumes behavior?

}

CutApplicatorBase::result_type
PhoAnyPFIsoWithEAAndQuadScalingCut::
operator()(const reco::PhotonPtr& cand) const{

// in case we are by-value
const std::string& inst_name = contentTags_.find(anyPFIsoWithEA_)->second.instance();
edm::Ptr<pat::Photon> pat(cand);
float anyisoval = -1.0;
if( _anyPFIsoMap.isValid() && _anyPFIsoMap->contains( cand.id() ) ) {
anyisoval = (*_anyPFIsoMap)[cand];
} else if ( _anyPFIsoMap.isValid() && _anyPFIsoMap->idSize() == 1 &&
cand.id() == edm::ProductID() ) {
// in case we have spoofed a ptr
//note this must be a 1:1 valuemap (only one product input)
anyisoval = _anyPFIsoMap->begin()[cand.key()];
} else if ( _anyPFIsoMap.isValid() ){ // throw an exception
anyisoval = (*_anyPFIsoMap)[cand];
}

// Figure out the cut value
// The value is generally pt-dependent: C1 + pt * C2
const float pt = cand->pt();

// In this version of the isolation cut we apply
// exponential pt scaling to the barrel isolation cut,
// and linear pt scaling to the endcap isolation cut.
double absEta = std::abs(cand->superCluster()->eta());
const float isolationCutValue =
( absEta < _barrelCutOff ?
_C1_EB + pt*_C2_EB + pt*pt*_C3_EB
: _C1_EE + pt*_C2_EE + pt*pt*_C3_EE );

// Retrieve the variable value for this particle
float anyPFIso = _anyPFIsoMap.isValid() ? anyisoval : pat->userFloat(inst_name);

// Apply pile-up correction
double eA = _effectiveAreas.getEffectiveArea( absEta );
double rho = *_rhoHandle;
float anyPFIsoWithEA = std::max(0.0, anyPFIso - rho * eA);

// Divide by pT if the relative isolation is requested
if( _useRelativeIso )
anyPFIsoWithEA /= pt;

// Apply the cut and return the result
return anyPFIsoWithEA < isolationCutValue;
}

double PhoAnyPFIsoWithEAAndQuadScalingCut::
value(const reco::CandidatePtr& cand) const {
reco::PhotonPtr pho(cand);

// in case we are by-value
const std::string& inst_name = contentTags_.find(anyPFIsoWithEA_)->second.instance();
edm::Ptr<pat::Photon> pat(cand);
float anyisoval = -1.0;
if( _anyPFIsoMap.isValid() && _anyPFIsoMap->contains( cand.id() ) ) {
anyisoval = (*_anyPFIsoMap)[cand];
} else if ( _anyPFIsoMap.isValid() && _anyPFIsoMap->idSize() == 1 &&
cand.id() == edm::ProductID() ) {
// in case we have spoofed a ptr
//note this must be a 1:1 valuemap (only one product input)
anyisoval = _anyPFIsoMap->begin()[cand.key()];
} else if ( _anyPFIsoMap.isValid() ){ // throw an exception
anyisoval = (*_anyPFIsoMap)[cand];
}

// Figure out the cut value
// The value is generally pt-dependent: C1 + pt * C2
const float pt = pho->pt();

// In this version of the isolation cut we apply
// exponential pt scaling to the barrel isolation cut,
// and linear pt scaling to the endcap isolation cut.
double absEta = std::abs(pho->superCluster()->eta());

// Retrieve the variable value for this particle
float anyPFIso = _anyPFIsoMap.isValid() ? anyisoval : pat->userFloat(inst_name);

// Apply pile-up correction
double eA = _effectiveAreas.getEffectiveArea( absEta );
double rho = *_rhoHandle;
float anyPFIsoWithEA = std::max(0.0, anyPFIso - rho * eA);

// Divide by pT if the relative isolation is requested
if( _useRelativeIso )
anyPFIsoWithEA /= pt;

// Apply the cut and return the result
return anyPFIsoWithEA;
}
Loading