Skip to content

Commit

Permalink
Update KJets
Browse files Browse the repository at this point in the history
Functions, called getTag and getId, can also return unchecked.
  • Loading branch information
JoramBerger committed Nov 30, 2014
1 parent ab8740d commit 0ba7640
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 35 deletions.
52 changes: 27 additions & 25 deletions DataFormats/interface/KJetMET.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,39 +40,41 @@ typedef std::vector<KBasicJet> KBasicJets;

struct KJetMetadata
{
std::vector<std::string> taggernames;
std::vector<std::string> pujetidnames;
std::vector<std::string> tagNames;
std::vector<std::string> idNames;
};

struct KJet : public KBasicJet
{
std::vector<float> taggers;
unsigned int puJetID;

float getTagger(const std::string &name, const KJetMetadata *taggermetadata) const
{
for (unsigned int i = 0; i < taggermetadata->taggernames.size(); ++i)
{
if (taggermetadata->taggernames[i] == name)
return taggers[i];
std::vector<float> tags;
unsigned int binaryIds;

float getTag(const std::string& name, const KJetMetadata *jetmetadata, bool check = true) const
{
for (unsigned int i = 0; i < jetmetadata->tagNames.size(); ++i)
{
if (jetmetadata->tagNames[i] == name)
return tags[i];
}
std::cout << "Tagger " << name << " not available!" << std::endl;
if (!check)
return -999.;
std::cout << "Tag \"" << name << "\" not available!" << std::endl;
exit(1);
}

bool getpuJetID(const std::string &name, const KJetMetadata *taggermetadata) const
{
for (unsigned int i = 0; i < taggermetadata->pujetidnames.size(); ++i)
{
if (taggermetadata->pujetidnames[i] == name)
return puJetID & (1 << i);
}
std::cout << "PUJetID " << name << " not available!" << std::endl;
}

bool getId(const std::string& name, const KJetMetadata *jetmetadata, bool check = true) const
{
for (unsigned int i = 0; i < jetmetadata->idNames.size(); ++i)
{
if (jetmetadata->idNames[i] == name)
return binaryIds & (1 << i);
}
if (!check)
return false;
std::cout << "Binary ID \"" << name << "\" not available!" << std::endl;
exit(1);
}

}
};

typedef std::vector<KJet> KJets;

struct KBasicMET : public KLV
Expand Down
8 changes: 4 additions & 4 deletions DataFormats/test/KDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ std::ostream &operator<<(std::ostream &os, const KBasicJet &jet)
std::ostream &operator<<(std::ostream &os, const KJet &jet)
{
os << static_cast<const KBasicJet>(jet) << std::endl;
os << "taggers: " << std::endl;
for (size_t i = 0; i < jet.taggers.size(); ++i)
os << jet.taggers[i] << " " << std::endl;
return os << "\tpuJetId: " << jet.puJetID << std::endl;
os << "tags: " << std::endl;
for (size_t i = 0; i < jet.tags.size(); ++i)
os << jet.tags[i] << " " << std::endl;
return os << "\tIDs: " << std::bitset<8>(jet.binaryIds) << std::endl;
}

std::ostream &operator<<(std::ostream &os, const KBasicTau &tau)
Expand Down
12 changes: 6 additions & 6 deletions Producers/interface/KJetProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class KJetProducer : public KBaseMultiLVProducer<reco::PFJetCollection, KJets>
|| (tagger[i] == "puJetIDCutbasedMedium")
|| (tagger[i] == "puJetIDCutbasedTight")
|| (tagger[i] == "puJetIDMET") )
names->pujetidnames.push_back(tagger[i]);
names->idNames.push_back(tagger[i]);
else
names->taggernames.push_back(tagger[i]);
names->tagNames.push_back(tagger[i]);
}
return KBaseMultiLVProducer<reco::PFJetCollection, KJets>::onLumi(lumiBlock, setup);
}
Expand Down Expand Up @@ -121,9 +121,9 @@ class KJetProducer : public KBaseMultiLVProducer<reco::PFJetCollection, KJets>
for (size_t i = 0; i < tagger.size(); ++i)
{
if ( (tagger[i] == "QGlikelihood") || (tagger[i] == "QGmlp"))
out.taggers.push_back(getvalue( (*tagmap_qg[tagger[i]])[jetRef] ) );
out.tags.push_back(getvalue( (*tagmap_qg[tagger[i]])[jetRef] ) );
else if ((tagger[i] == "puJetIDFullDiscriminant") || (tagger[i] == "puJetIDCutbasedDiscriminant"))
out.taggers.push_back(getsignedvalue( (*tagmap_pu[tagger[i]])[jetRef] ) );
out.tags.push_back(getsignedvalue( (*tagmap_pu[tagger[i]])[jetRef] ) );
else if (tagger[i] == "puJetIDFullLoose")
puJetID.push_back(( (*puJetIDfull_Handle)[jetRef] & (1 << 2) ) != 0);
else if (tagger[i] == "puJetIDFullMedium")
Expand All @@ -141,12 +141,12 @@ class KJetProducer : public KBaseMultiLVProducer<reco::PFJetCollection, KJets>
else
{
const reco::JetTagCollection & tags = *(tagmap_b[tagger[i]].product());
out.taggers.push_back(getvalue( tags[this->nCursor].second ) );
out.tags.push_back(getvalue( tags[this->nCursor].second ) );
}
}

for (unsigned int i = 0; i < puJetID.size(); ++i)
out.puJetID |= puJetID[i] << i;
out.binaryIds |= puJetID[i] << i;

// PF variables:
copyP4(in, out.p4);
Expand Down

0 comments on commit 0ba7640

Please sign in to comment.