Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Commit

Permalink
Implement access to raw MET
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-popov committed Jun 20, 2016
1 parent 793ce4c commit 179de32
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 10 deletions.
18 changes: 12 additions & 6 deletions include/mensura/PECReader/PECJetMETReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ class PECJetMETReader: public JetMETReader
*/
virtual double GetJetRadius() const override;

/// Requests reading of raw MET
void ReadRawMET(bool enable = true);

/// Specifies name of the plugin that provides generator-level jets
void SetGenJetReader(std::string const name = "GenJetMET");

Expand Down Expand Up @@ -134,26 +137,29 @@ class PECJetMETReader: public JetMETReader
/**
* \brief An auxiliary pointer to jet buffer
*
* Need by ROOT to read the object from a tree.
* Needed by ROOT to read the object from a tree.
*/
decltype(bfJets) *bfJetPointer;

/// Buffer to read the branch with METs
std::vector<pec::Candidate> bfMETs;
/// Buffers to read the branches with METs
std::vector<pec::Candidate> bfMETs, bfUncorrMETs;

/**
* \brief An auxiliary pointer to MET buffer
* \brief Auxiliary pointers to MET buffers
*
* Need by ROOT to read the object from a tree.
* Needed by ROOT to read the object from a tree.
*/
decltype(bfMETs) *bfMETPointer;
decltype(bfMETs) *bfMETPointer, *bfUncorrMETPointer;

/// Minimal allowed transverse momentum
double minPt;

/// Maximal allowed absolute value of pseudorapidity
double maxAbsEta;

/// Specifies whether raw MET should be read
bool readRawMET;

/**
* \brief Name of the plugin that produces leptons
*
Expand Down
6 changes: 6 additions & 0 deletions include/mensura/core/JetMETReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,16 @@ class JetMETReader: public ReaderPlugin
/// Returns corrected MET in the current event
MET const &GetMET() const;

/// Returns raw MET in the current event
MET const &GetRawMET() const;

protected:
/// Collection of (corrected) jets in the current event
std::vector<Jet> jets;

/// Corrected MET in the current event
MET met;

/// Raw MET in the current event
MET rawMET;
};
26 changes: 22 additions & 4 deletions modules/PECReader/src/PECJetMETReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ PECJetMETReader::PECJetMETReader(std::string name /*= "JetMET"*/):
inputDataPluginName("InputData"), inputDataPlugin(nullptr),
systServiceName("Systematics"),
treeName("pecJetMET/JetMET"),
bfJetPointer(&bfJets), bfMETPointer(&bfMETs),
bfJetPointer(&bfJets), bfMETPointer(&bfMETs), bfUncorrMETPointer(&bfUncorrMETs),
minPt(0.), maxAbsEta(std::numeric_limits<double>::infinity()),
readRawMET(false),
leptonPluginName("Leptons"), leptonPlugin(nullptr),
genJetPluginName(""), genJetPlugin(nullptr),
systType(SystType::None), systDirection(0)
Expand All @@ -32,8 +33,9 @@ PECJetMETReader::PECJetMETReader(PECJetMETReader const &src) noexcept:
inputDataPluginName(src.inputDataPluginName), inputDataPlugin(src.inputDataPlugin),
systServiceName(src.systServiceName),
treeName(src.treeName),
bfJetPointer(&bfJets), bfMETPointer(&bfMETs),
bfJetPointer(&bfJets), bfMETPointer(&bfMETs), bfUncorrMETPointer(&bfUncorrMETs),
minPt(src.minPt), maxAbsEta(src.maxAbsEta),
readRawMET(src.readRawMET),
leptonPluginName(src.leptonPluginName), leptonPlugin(src.leptonPlugin),
leptonDR2(src.leptonDR2),
genJetPluginName(src.genJetPluginName), genJetPlugin(src.genJetPlugin),
Expand Down Expand Up @@ -97,13 +99,15 @@ void PECJetMETReader::BeginRun(Dataset const &)

tree->SetBranchStatus("jets.bTagCMVA", false);
tree->SetBranchStatus("jets.secVertexMass", false);
// tree->SetBranchStatus("jets.area", false);
tree->SetBranchStatus("jets.charge", false);
tree->SetBranchStatus("jets.pullAngle", false);

tree->SetBranchAddress("jets", &bfJetPointer);
tree->SetBranchAddress("METs", &bfMETPointer);

if (readRawMET)
tree->SetBranchAddress("uncorrMETs", &bfUncorrMETPointer);

ROOTLock::Unlock();
}

Expand Down Expand Up @@ -134,6 +138,12 @@ double PECJetMETReader::GetJetRadius() const
}


void PECJetMETReader::ReadRawMET(bool enable /*= true*/)
{
readRawMET = enable;
}


void PECJetMETReader::SetGenJetReader(std::string const name /*= "GenJetMET"*/)
{
genJetPluginName = name;
Expand Down Expand Up @@ -335,9 +345,17 @@ bool PECJetMETReader::ProcessEvent()
met.SetPtEtaPhiM(correctedMET.Pt(), 0., correctedMET.Phi(), 0.);


// Copy raw MET if requested
if (readRawMET)
{
pec::Candidate const &pecRawMET = bfUncorrMETs.at(0);
rawMET.SetPtEtaPhiM(pecRawMET.Pt(), 0., pecRawMET.Phi(), 0.);
}


#ifdef DEBUG
std::cout << "PECJetMETReader[\"" << GetName() << "\"]: MET in the current event:\n";
std::cout << " Raw MET (pt, phi): " << bfMETs.at(1).Pt() << ", " << bfMETs.at(1).Phi() << '\n';
std::cout << " Raw MET (pt, phi): " << rawMET.Pt() << ", " << rawMET.Phi() << '\n';
std::cout << " Corrected MET (pt, phi): " << bfMETs.at(0).Pt() << ", "
<< bfMETs.at(0).Phi() << std::endl;
#endif
Expand Down
6 changes: 6 additions & 0 deletions modules/core/src/JetMETReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ MET const &JetMETReader::GetMET() const
{
return met;
}


MET const &JetMETReader::GetRawMET() const
{
return rawMET;
}

0 comments on commit 179de32

Please sign in to comment.