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

Fix inconsistency in soft lepton taginfos naming #11247

Merged
10 changes: 8 additions & 2 deletions DataFormats/BTauReco/interface/TemplatedSoftLeptonTagInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ namespace reco {
class SoftLeptonProperties {
public:
SoftLeptonProperties() :
sip2dsig( std::numeric_limits<float>::quiet_NaN() ),
sip3dsig( std::numeric_limits<float>::quiet_NaN() ),
sip2d( std::numeric_limits<float>::quiet_NaN() ),
sip3d( std::numeric_limits<float>::quiet_NaN() ),
ptRel( std::numeric_limits<float>::quiet_NaN() ),
Expand All @@ -26,6 +28,8 @@ class SoftLeptonProperties {
elec_mva( std::numeric_limits<float>::quiet_NaN() )
{ }

float sip2dsig; // 2D signed impact parameter significance
float sip3dsig; // 3D signed impact parameter significance
float sip2d; // 2D signed impact parameter
float sip3d; // 3D signed impact parameter
float ptRel; // transverse momentum wrt. the jet axis
Expand Down Expand Up @@ -163,8 +167,10 @@ TaggingVariableList TemplatedSoftLeptonTagInfo<REF>::taggingVariables(void) cons
const SoftLeptonProperties & data = m_leptons[i].second;
list.insert( TaggingVariable(btau::leptonQuality, data.quality(SoftLeptonProperties::Quality::leptonId, false)), true );
list.insert( TaggingVariable(btau::leptonQuality2, data.quality(SoftLeptonProperties::Quality::btagLeptonCands, false)), true );
list.insert( TaggingVariable(btau::trackSip2dSig, data.sip2d), true );
list.insert( TaggingVariable(btau::trackSip3dSig, data.sip3d), true );
list.insert( TaggingVariable(btau::trackSip2dVal, data.sip2d), true );
list.insert( TaggingVariable(btau::trackSip3dVal, data.sip3d), true );
list.insert( TaggingVariable(btau::trackSip2dSig, data.sip2dsig), true );
list.insert( TaggingVariable(btau::trackSip3dSig, data.sip3dsig), true );
list.insert( TaggingVariable(btau::trackPtRel, data.ptRel), true );
list.insert( TaggingVariable(btau::trackP0Par, data.p0Par), true );
list.insert( TaggingVariable(btau::trackEtaRel, data.etaRel), true );
Expand Down
17 changes: 15 additions & 2 deletions DataFormats/BTauReco/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,24 @@
<class name="edm::Wrapper<reco::IsolatedTauTagInfoCollection>"/>


<class name="reco::SoftLeptonProperties" ClassVersion="11">
<class name="reco::SoftLeptonProperties" ClassVersion="12">
<version ClassVersion="10" checksum="3825121604"/>
<version ClassVersion="11" checksum="3267387532"/>
<version ClassVersion="12" checksum="2193794521"/>
</class>

<ioread sourceClass = "reco::SoftLeptonProperties" version="[-11]" targetClass="reco::SoftLeptonProperties" source="float sip2d" target="sip2dsig">
<![CDATA[sip2dsig = onfile.sip2d;]]>
</ioread>
<ioread sourceClass = "reco::SoftLeptonProperties" version="[-11]" targetClass="reco::SoftLeptonProperties" source="float sip3d" target="sip3dsig">
<![CDATA[sip3dsig = onfile.sip3d;]]>
</ioread>
<ioread sourceClass = "reco::SoftLeptonProperties" version="[-11]" targetClass="reco::SoftLeptonProperties" source = "" target="sip2d">
<![CDATA[sip2d = 0;]]>
</ioread>
<ioread sourceClass = "reco::SoftLeptonProperties" version="[-11]" targetClass="reco::SoftLeptonProperties" source = "" target="sip3d">
<![CDATA[sip3d = 0;]]>
</ioread>

<class name="std::pair<edm::RefToBase<reco::Track>, reco::SoftLeptonProperties>"/>
<class name="reco::TemplatedSoftLeptonTagInfo<edm::RefToBase<reco::Track> >::LeptonMap"/>
<class name="reco::SoftLeptonTagInfo" />
Expand Down
8 changes: 6 additions & 2 deletions RecoBTag/SoftLepton/plugins/SoftLepton.cc
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,12 @@ reco::SoftLeptonTagInfo SoftLepton::tag (
reco::SoftLeptonProperties properties;

reco::TransientTrack transientTrack = m_transientTrackBuilder->build(*lepton->first);
properties.sip2d = IPTools::signedTransverseImpactParameter( transientTrack, jetAxis, primaryVertex ).second.significance();
properties.sip3d = IPTools::signedImpactParameter3D( transientTrack, jetAxis, primaryVertex ).second.significance();
Measurement1D ip2d = IPTools::signedTransverseImpactParameter( transientTrack, jetAxis, primaryVertex ).second;
Measurement1D ip3d = IPTools::signedImpactParameter3D( transientTrack, jetAxis, primaryVertex ).second;
properties.sip2dsig = ip2d.significance();
properties.sip3dsig = ip3d.significance();
properties.sip2d = ip2d.value();
properties.sip3d = ip3d.value();
properties.deltaR = deltaR;
properties.ptRel = Perp( lepton_momentum, axis );
properties.p0Par = boostedPPar( lepton_momentum, axis );
Expand Down
12 changes: 8 additions & 4 deletions RecoBTag/SoftLepton/plugins/SoftPFElectronTagInfoProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ SoftPFElectronTagInfoProducer::SoftPFElectronTagInfoProducer (const edm::Paramet
token_BeamSpot = consumes<reco::BeamSpot>(edm::InputTag("offlineBeamSpot"));
token_allConversions= consumes<reco::ConversionCollection>(edm::InputTag("allConversions"));
DeltaRElectronJet = conf.getParameter<double>("DeltaRElectronJet");
MaxSip3D = conf.getParameter<double>("MaxSip3D");
MaxSip3Dsig = conf.getParameter<double>("MaxSip3Dsig");
produces<reco::CandSoftLeptonTagInfoCollection>();
}

Expand Down Expand Up @@ -98,8 +98,12 @@ void SoftPFElectronTagInfoProducer::produce(edm::Event& iEvent, const edm::Event
math::XYZVector pel=recoelectron->p4().Vect();
math::XYZVector pjet=jetRef->p4().Vect();
reco::TransientTrack transientTrack=transientTrackBuilder->build(recoelectron->gsfTrack());
properties.sip2d = IPTools::signedTransverseImpactParameter(transientTrack, GlobalVector(jetRef->px(), jetRef->py(), jetRef->pz()), *vertex).second.significance();
properties.sip3d = IPTools::signedImpactParameter3D(transientTrack, GlobalVector(jetRef->px(), jetRef->py(), jetRef->pz()), *vertex).second.significance();
Measurement1D ip2d = IPTools::signedTransverseImpactParameter(transientTrack, GlobalVector(jetRef->px(), jetRef->py(), jetRef->pz()), *vertex).second;
Measurement1D ip3d = IPTools::signedImpactParameter3D(transientTrack, GlobalVector(jetRef->px(), jetRef->py(), jetRef->pz()), *vertex).second;
properties.sip2dsig = ip2d.significance();
properties.sip3dsig = ip3d.significance();
properties.sip2d = ip2d.value();
properties.sip3d = ip3d.value();
properties.deltaR = reco::deltaR((*jetRef), (*recoelectron));
properties.ptRel = ( (pjet-pel).Cross(pel) ).R() / pjet.R();
float mag = pel.R()*pjet.R();
Expand All @@ -109,7 +113,7 @@ void SoftPFElectronTagInfoProducer::produce(edm::Event& iEvent, const edm::Event
properties.ratioRel = recoelectron->p4().Dot(jetRef->p4()) / pjet.Mag2();
properties.p0Par = boostedPPar(recoelectron->momentum(), jetRef->momentum());
properties.elec_mva = recoelectron->mva_e_pi();
if(std::abs(properties.sip3d>MaxSip3D)) continue;
if(std::abs(properties.sip3dsig>MaxSip3Dsig)) continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

does this make sense?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch! I guess the original intention was to have std::abs(properties.sip3dsig)>MaxSip3Dsig. In practice I suspect the impact of this bug is negligible but still it should be fixed. Thanks again for catching it.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I'll add a commit to fix it. Yes, the impact should be negligible, as the cut is set by default at 200, that's why it passed unnoticed until now.

// Fill the TagInfos
tagInfo.insert(lepPtr, properties );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class SoftPFElectronTagInfoProducer : public edm::stream::EDProducer<>
edm::EDGetTokenT<edm::View<reco::GsfElectron> > token_elec;
edm::EDGetTokenT<reco::BeamSpot> token_BeamSpot;
edm::EDGetTokenT<reco::ConversionCollection> token_allConversions;
float DeltaRElectronJet,MaxSip3D;
float DeltaRElectronJet,MaxSip3Dsig;
bool goodvertex;

const reco::Vertex* vertex;
Expand Down
16 changes: 10 additions & 6 deletions RecoBTag/SoftLepton/plugins/SoftPFMuonTagInfoProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ SoftPFMuonTagInfoProducer::SoftPFMuonTagInfoProducer(const edm::ParameterSet& co
muonToken = consumes<edm::View<reco::Muon> >(conf.getParameter<edm::InputTag>("muons"));
vertexToken = consumes<reco::VertexCollection>(conf.getParameter<edm::InputTag>("primaryVertex"));
pTcut = conf.getParameter<double>("muonPt");
SIPcut = conf.getParameter<double>("muonSIP");
IPcut = conf.getParameter<double>("filterIp");
SIPsigcut = conf.getParameter<double>("muonSIPsig");
IPsigcut = conf.getParameter<double>("filterIpsig");
ratio1cut = conf.getParameter<double>("filterRatio1");
ratio2cut = conf.getParameter<double>("filterRatio2");
useFilter = conf.getParameter<bool>("filterPromptMuons");
Expand Down Expand Up @@ -118,8 +118,12 @@ void SoftPFMuonTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetu
reco::Candidate::Vector jetvect(jetRef->p4().Vect()), muonvect(muon->p4().Vect());
// Calculate variables
reco::SoftLeptonProperties properties;
properties.sip2d = IPTools::signedTransverseImpactParameter(transientTrack, GlobalVector(jetRef->px(), jetRef->py(), jetRef->pz()), *vertex).second.significance();
properties.sip3d = IPTools::signedImpactParameter3D(transientTrack, GlobalVector(jetRef->px(), jetRef->py(), jetRef->pz()), *vertex).second.significance();
Measurement1D ip2d = IPTools::signedTransverseImpactParameter(transientTrack, GlobalVector(jetRef->px(), jetRef->py(), jetRef->pz()), *vertex).second;
Measurement1D ip3d = IPTools::signedImpactParameter3D(transientTrack, GlobalVector(jetRef->px(), jetRef->py(), jetRef->pz()), *vertex).second;
properties.sip2dsig = ip2d.significance();
properties.sip3dsig = ip3d.significance();
properties.sip2d = ip2d.value();
properties.sip3d = ip3d.value();
properties.deltaR = reco::deltaR(*jetRef, *muon);
properties.ptRel = ( (jetvect-muonvect).Cross(muonvect) ).R() / jetvect.R(); // | (Pj-Pu) X Pu | / | Pj |
float mag = muonvect.R()*jetvect.R();
Expand All @@ -129,10 +133,10 @@ void SoftPFMuonTagInfoProducer::produce(edm::Event& iEvent, const edm::EventSetu
properties.ratioRel = muon->p4().Dot(jetRef->p4()) / jetvect.Mag2();
properties.p0Par = boostedPPar(muon->momentum(), jetRef->momentum());

if(std::abs(properties.sip3d)>SIPcut) continue;
if(std::abs(properties.sip3dsig)>SIPsigcut) continue;

// Filter leptons from W, Z decays
if(useFilter && ((std::abs(properties.sip3d)<IPcut && properties.ratio>ratio1cut) || properties.ratio>ratio2cut)) continue;
if(useFilter && ((std::abs(properties.sip3dsig)<IPsigcut && properties.ratio>ratio1cut) || properties.ratio>ratio2cut)) continue;

// Insert lepton properties
tagInfo.insert(lepPtr, properties);
Expand Down
2 changes: 1 addition & 1 deletion RecoBTag/SoftLepton/plugins/SoftPFMuonTagInfoProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class SoftPFMuonTagInfoProducer : public edm::stream::EDProducer<> {
edm::EDGetTokenT<edm::View<reco::Jet> > jetToken;
edm::EDGetTokenT<edm::View<reco::Muon> > muonToken;
edm::EDGetTokenT<reco::VertexCollection> vertexToken;
float pTcut, SIPcut, IPcut, ratio1cut, ratio2cut;
float pTcut, SIPsigcut, IPsigcut, ratio1cut, ratio2cut;
bool useFilter;
};

Expand Down
2 changes: 1 addition & 1 deletion RecoBTag/SoftLepton/python/softPFElectronTagInfos_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
jets = cms.InputTag("ak4PFJetsCHS"),
electrons = cms.InputTag("gedGsfElectrons"),
DeltaRElectronJet=cms.double(0.4),
MaxSip3D=cms.double(200)
MaxSip3Dsig=cms.double(200)
)
4 changes: 2 additions & 2 deletions RecoBTag/SoftLepton/python/softPFMuonTagInfos_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
muons = cms.InputTag("muons"),
primaryVertex = cms.InputTag("offlinePrimaryVertices"),
muonPt = cms.double(2.),
muonSIP = cms.double(200.),
filterIp = cms.double(4.),
muonSIPsig = cms.double(200.),
filterIpsig = cms.double(4.),
filterRatio1 = cms.double(0.4),
filterRatio2 = cms.double(0.7),
filterPromptMuons = cms.bool(False)
Expand Down
8 changes: 4 additions & 4 deletions RecoBTag/SoftLepton/src/ElectronTagger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ float ElectronTagger::discriminator(const TagInfoHelper & tagInfo) const {
random.seed(theSeed);
float rndm = dist(random);
//for negative tagger, flip 50% of the negative signs to positive value
float sip3d = (m_selector.isNegative() && rndm<0.5) ? -properties.sip3d : properties.sip3d;
float sip2d = (m_selector.isNegative() && rndm<0.5) ? -properties.sip2d : properties.sip2d;
float sip3dsig = (m_selector.isNegative() && rndm<0.5) ? -properties.sip3dsig : properties.sip3dsig;
float sip2dsig = (m_selector.isNegative() && rndm<0.5) ? -properties.sip2dsig : properties.sip2dsig;

std::map<std::string,float> inputs;
inputs["sip3d"] = sip3d;
inputs["sip2d"] = sip2d;
inputs["sip3d"] = sip3dsig;
inputs["sip2d"] = sip2dsig;
inputs["ptRel"] = properties.ptRel;
inputs["deltaR"] = properties.deltaR;
inputs["ratio"] = properties.ratio;
Expand Down
6 changes: 3 additions & 3 deletions RecoBTag/SoftLepton/src/LeptonSelector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ LeptonSelector::~LeptonSelector()

bool LeptonSelector::operator() (const reco::SoftLeptonProperties &properties, bool use3d) const
{
float sip = use3d ? properties.sip3d : properties.sip2d;
if ((isPositive() && sip <= 0.0) ||
(isNegative() && sip >= 0.0))
float sipsig = use3d ? properties.sip3dsig : properties.sip2dsig;
if ((isPositive() && sipsig <= 0.0) ||
(isNegative() && sipsig >= 0.0))
return false;

bool candSelection = (m_leptonId == reco::SoftLeptonProperties::Quality::btagLeptonCands);
Expand Down
6 changes: 3 additions & 3 deletions RecoBTag/SoftLepton/src/LeptonTaggerByIP.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ float LeptonTaggerByIP::discriminator(const TagInfoHelper & tagInfo) const {
// if there are multiple leptons, look for the one with the highest pT_rel
for (unsigned int i = 0; i < info.leptons(); i++) {
const reco::SoftLeptonProperties & properties = info.properties(i);
float sip = m_use3d ? properties.sip3d : properties.sip2d;
float sipsig = m_use3d ? properties.sip3dsig : properties.sip2dsig;
if (m_selector.isNegative())
sip = -sip;
sipsig = -sipsig;
if (m_selector(properties, m_use3d)) {
float tag = sip;
float tag = sipsig;
if (tag > bestTag)
bestTag = tag;
}
Expand Down
8 changes: 4 additions & 4 deletions RecoBTag/SoftLepton/src/MuonTagger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ float MuonTagger::discriminator(const TagInfoHelper& tagInfo) const {
if(rndm<0.5) flip=true;
}
//for negative tagger, flip 50% of the negative signs to positive value
float sip3d = flip ? -properties.sip3d : properties.sip3d;
float sip2d = flip ? -properties.sip2d : properties.sip2d;
float sip3dsig = flip ? -properties.sip3dsig : properties.sip3dsig;
float sip2dsig = flip ? -properties.sip2dsig : properties.sip2dsig;

std::map<std::string,float> inputs;
inputs["TagInfo1.sip3d"] = sip3d;
inputs["TagInfo1.sip2d"] = sip2d;
inputs["TagInfo1.sip3d"] = sip3dsig;
inputs["TagInfo1.sip2d"] = sip2dsig;
inputs["TagInfo1.ptRel"] = properties.ptRel;
inputs["TagInfo1.deltaR"] = properties.deltaR;
inputs["TagInfo1.ratio"] = properties.ratio;
Expand Down