-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add tool to get lumi json for lumi calc #9
Comments
Also add the following code (but note the need to add boost as a dependency), #include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
class LumiFilter
{
private:
boost::property_tree::ptree ptree;
public:
LumiFilter(std::string filename = "/cms/xaastorage/PicoTrees/JSON_FILES/Cert_271036-284044_13TeV_ReReco_07Aug2017_Collisions16_JSON.txt");
~LumiFilter();
float Eval(float run, float lumi);
};
LumiFilter::LumiFilter(std::string filename = "/cms/xaastorage/PicoTrees/JSON_FILES/Cert_271036-284044_13TeV_ReReco_07Aug2017_Collisions16_JSON.txt") {
boost::property_tree::read_json(filename, ptree);
}
LumiFilter::~LumiFilter() {
}
float LumiFilter::Eval(float run, float lumi) {
for ( const auto& runEntry : ptree ) {
if (std::stoul(runEntry.first) == (unsigned int)run) {
for ( const auto& lrEntry : runEntry.second ) {
const auto lrNd = lrEntry.second;
unsigned int lumStart = std::stoul(lrNd.begin()->second.data());
unsigned int lumEnd = std::stoul((++lrNd.begin())->second.data());
unsigned int L = (unsigned int) lumi;
if ((L < lumEnd) && (L > lumStart)) {
return 1.;
}
}
}
}
return 0.;
} |
Adapted version of copied script ( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Port printLumiJson.py
The text was updated successfully, but these errors were encountered: