forked from cms-sw/cmssw
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #406 from cms-nanoAOD/port_1oct19_110X
Port recent pull requests to master
- Loading branch information
Showing
12 changed files
with
224 additions
and
61 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
Configuration/Eras/python/Modifier_run2_nanoAOD_106Xv1_cff.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
run2_nanoAOD_106Xv1 = cms.Modifier() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "PhysicsTools/NanoAOD/plugins/EventStringOutputBranches.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "FWCore/ParameterSet/interface/Registry.h" | ||
|
||
#include <iostream> | ||
|
||
void EventStringOutputBranches::updateEventStringNames(TTree &tree, const std::string &evstring) { | ||
bool found = false; | ||
for (auto &existing : m_evStringBranches) { | ||
existing.buffer = false; | ||
if (evstring == existing.name) { | ||
existing.buffer = true; | ||
found = true; | ||
} | ||
} | ||
if (!found && (!evstring.empty())) { | ||
NamedBranchPtr nb(evstring, "EventString bit"); | ||
bool backFillValue = false; | ||
nb.branch = tree.Branch(nb.name.c_str(), &backFillValue, (nb.name + "/O").c_str()); | ||
nb.branch->SetTitle(nb.title.c_str()); | ||
for (size_t i = 0; i < m_fills; i++) | ||
nb.branch->Fill(); // Back fill | ||
nb.buffer = true; | ||
m_evStringBranches.push_back(nb); | ||
for (auto &existing : m_evStringBranches) | ||
existing.branch->SetAddress(&(existing.buffer)); // m_evStringBranches might have been resized | ||
} | ||
} | ||
|
||
void EventStringOutputBranches::fill(const edm::EventForOutput &iEvent, TTree &tree) { | ||
if ((!m_update_only_at_new_lumi) || m_lastLumi != iEvent.id().luminosityBlock()) { | ||
edm::Handle<std::string> handle; | ||
iEvent.getByToken(m_token, handle); | ||
const std::string &evstring = *handle; | ||
m_lastLumi = iEvent.id().luminosityBlock(); | ||
updateEventStringNames(tree, evstring); | ||
} | ||
m_fills++; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#ifndef PhysicsTools_NanoAOD_EventStringOutputBranches_h | ||
#define PhysicsTools_NanoAOD_EventStringOutputBranches_h | ||
|
||
#include <string> | ||
#include <vector> | ||
#include <TTree.h> | ||
#include "FWCore/Framework/interface/EventForOutput.h" | ||
#include "DataFormats/Provenance/interface/BranchDescription.h" | ||
#include "FWCore/Utilities/interface/EDGetToken.h" | ||
|
||
class EventStringOutputBranches { | ||
public: | ||
EventStringOutputBranches(const edm::BranchDescription *desc, | ||
const edm::EDGetToken &token, | ||
bool update_only_at_new_lumi = false) | ||
: m_token(token), m_lastLumi(-1), m_fills(0), m_update_only_at_new_lumi(update_only_at_new_lumi) { | ||
if (desc->className() != "std::basic_string<char,std::char_traits<char> >") | ||
throw cms::Exception("Configuration", | ||
"NanoAODOutputModule/EventStringOutputBranches can only write out std::string objects"); | ||
} | ||
|
||
void updateEventStringNames(TTree &, const std::string &); | ||
void fill(const edm::EventForOutput &iEvent, TTree &tree); | ||
|
||
private: | ||
edm::EDGetToken m_token; | ||
struct NamedBranchPtr { | ||
std::string name, title; | ||
TBranch *branch; | ||
bool buffer; | ||
NamedBranchPtr(const std::string &aname, const std::string &atitle, TBranch *branchptr = nullptr) | ||
: name(aname), title(atitle), branch(branchptr), buffer(false) {} | ||
}; | ||
std::vector<NamedBranchPtr> m_evStringBranches; | ||
long m_lastLumi; | ||
unsigned long m_fills; | ||
bool m_update_only_at_new_lumi; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.