//C++ #include #include #include #include #include #include #include #include #include //root #include #include #include #include #include #include #include #include #include #include #include #include #include //local #include "../IOjuggler/ProgressBar.h" #include "../IOjuggler/IOjuggler.h" #ifndef NTUPLE_GIZMO_GIT_HASH #define NTUPLE_GIZMO_GIT_HASH " " #endif int main(int argc, char** argv){ //parse command line options const auto options = IOjuggler::parse_options(argc, argv, "c:d:i:o:t:v:h","nonoptions: any number of combinations"); const auto wd = options.get("workdir"); const auto ofn = options.get("outfilename"); const auto ifn = options.get("infilename"); const auto itn = options.get("treename"); //init MessageService for easy and nice printout MessageService msgsvc("selector_rootMT",static_cast(options.get("verbosity"))); msgsvc.debugmsg("Current ntuple-gizmo git hash: " + static_cast(NTUPLE_GIZMO_GIT_HASH)); //get input as TChain auto chain = IOjuggler::get_chain(itn,ifn,wd,msgsvc); //get config-file auto configtree = IOjuggler::get_ptree(options.get("config")); //manipulations of the config file IOjuggler::auto_replace_in_ptree(configtree); IOjuggler::auto_append_in_ptree(configtree); auto trim_vars = configtree.get_child_optional("variables"); auto tmp_msg = "Trimming input tree(s) with cut " + configtree.get("basiccuts",""); if(trim_vars) msgsvc.infomsg(tmp_msg + " and writing out " + configtree.get_child("variables").size() + " variables"); else msgsvc.infomsg(tmp_msg + " and writing out full tree"); const bool noImplicitCuts= (const bool) (configtree.get_child_optional("noImplicitCuts")); if(noImplicitCuts) msgsvc.infomsg("Implicit cuts switched off"); std::vector default_branches = {}; if(trim_vars) for(const auto& var : *trim_vars) default_branches.push_back(var.first.data()); //first, we need to know how many events there are and how many threads we use: ROOT::EnableImplicitMT(); const auto max_workers = ROOT::GetImplicitMTPoolSize(); auto n_workers = configtree.get("threads",max_workers); msgsvc.infomsg("Trying to run with " + std::to_string(n_workers) + " parallel threads"); if(n_workers > max_workers){ msgsvc.infomsg("Current machine only supports " + std::to_string(max_workers) + " parallel threads. I will be using this number"); n_workers = max_workers; } ROOT::Experimental::TDataFrame d(*chain.get(),default_branches); d.Snapshot(configtree.get("outtreename",itn).data(),ofn.data(),default_branches);//,configtree.get("outfopt","recreate").data() return 0; }