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

Add tool to get lumi json for lumi calc #9

Closed
lcorcodilos opened this issue Oct 7, 2020 · 2 comments · Fixed by #19
Closed

Add tool to get lumi json for lumi calc #9

lcorcodilos opened this issue Oct 7, 2020 · 2 comments · Fixed by #19

Comments

@lcorcodilos
Copy link
Owner

lcorcodilos commented Oct 7, 2020

Port printLumiJson.py

@lcorcodilos
Copy link
Owner Author

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.;
}

@lcorcodilos
Copy link
Owner Author

Adapted version of copied script (LumiFilter) included in #19. Still need to port printLumiJson.py

@lcorcodilos lcorcodilos linked a pull request Nov 14, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant