Page MenuHomeHEPForge

No OneTemporary

diff --git a/cmake/Templates/Version.hh.in b/cmake/Templates/Version.hh.in
index 6843703..a1e4da2 100644
--- a/cmake/Templates/Version.hh.in
+++ b/cmake/Templates/Version.hh.in
@@ -1,46 +1,47 @@
/** \file Version.hh
* \brief The file gives the current rHEJ Version
*/
#pragma once
#include <string>
/// @brief Full name of this package.
#define RHEJ_PACKAGE_NAME "@PROJECT_NAME@"
/// @brief rHEJ version string
#define RHEJ_VERSION "@PROJECT_VERSION@"
/// @brief Full name and version of this package.
#define RHEJ_PACKAGE_STRING "@PROJECT_NAME@ @PROJECT_VERSION@"
/// @brief Major version of this package
#define RHEJ_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
/// @brief Minor version of this package
#define RHEJ_VERSION_MINOR @PROJECT_VERSION_MINOR@
/// @brief Patch version of this package
#define RHEJ_VERSION_PATCH @PROJECT_VERSION_PATCH@
/// @brief Git revision of this package
#define RHEJ_GIT_revision "@PROJECT_GIT_REVISION@"
/// @brief Git branch name of this package
#define RHEJ_GIT_branch "@PROJECT_GIT_BRANCH@"
namespace RHEJ {
struct Version {
static std::string String() { return RHEJ_VERSION; }
static std::string package_name() { return RHEJ_PACKAGE_NAME; }
static std::string package_name_full() { return RHEJ_PACKAGE_STRING; }
static int Major() { return RHEJ_VERSION_MAJOR; }
static int Minor() { return RHEJ_VERSION_MINOR; }
static int Patch() { return RHEJ_VERSION_PATCH; }
+ static std::string revision() { return RHEJ_GIT_revision; }
};
}
diff --git a/src/main.cc b/src/main.cc
index 0ace328..40a6b1c 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -1,159 +1,160 @@
/**
* Name: main.cc
* Authors: Tuomas Hapola, Andreas Maier <andreas.maier@durham.ac.uk>
*
*/
#include <fstream>
#include <algorithm>
#include <memory>
#include <chrono>
#include <iostream>
#include "yaml-cpp/yaml.h"
#include "RHEJ/CombinedEventWriter.hh"
#include "RHEJ/config.hh"
#include "RHEJ/EventReweighter.hh"
#include "RHEJ/get_analysis.hh"
#include "LHEF/LHEF.h"
#include "RHEJ/utility.hh"
#include "RHEJ/Version.hh"
#include "RHEJ/stream.hh"
#include "RHEJ/YAMLreader.hh"
int event_number(std::string const & record){
size_t start = record.rfind("Number of Events");
start = record.find_first_of("123456789", start);
if(start == std::string::npos) {
throw std::invalid_argument("no event number record found");
}
const size_t end = record.find_first_not_of("0123456789", start);
return std::stoi(record.substr(start, end - start));
}
RHEJ::Config load_config(char const * filename){
try{
return RHEJ::load_config(filename);
}
catch(std::exception const & exc){
std::cerr << "Error: " << exc.what() << '\n';
std::exit(EXIT_FAILURE);
}
}
std::unique_ptr<RHEJ::Analysis> get_analysis(
YAML::Node const & parameters
){
try{
return RHEJ::get_analysis(parameters);
}
catch(std::exception const & exc){
std::cerr << "Failed to load analysis: " << exc.what() << '\n';
std::exit(EXIT_FAILURE);
}
}
std::string time_to_string(const time_t time){
char s[1000];
struct tm * p = localtime(&time);
strftime(s, 1000, "%a %b %d %Y %H:%M:%S", p);
return s;
}
int main(int argn, char** argv) {
using clock = std::chrono::system_clock;
if (argn < 3) {
std::cerr << "\n# Usage:\n."<< argv[0] <<" config_file input_file\n\n";
return EXIT_FAILURE;
}
const auto start_time = clock::now();
{
- std::cout << "Starting " << RHEJ::Version().package_name_full() << " ("
+ std::cout << "Starting " << RHEJ::Version().package_name_full()
+ << ", revision " << RHEJ::Version().revision() << " ("
<< time_to_string(clock::to_time_t(start_time)) << ")" << std::endl;
}
// read configuration
const RHEJ::Config config = load_config(argv[1]);
RHEJ::istream in{argv[2]};
std::unique_ptr<RHEJ::Analysis> analysis = get_analysis(
config.analysis_parameters
);
assert(analysis != nullptr);
LHEF::Reader reader{in};
RHEJ::CombinedEventWriter writer{config, reader.heprup};
double global_reweight = 1.;
int max_events = std::numeric_limits<int>::max();
if(argn > 3){
max_events = std::stoi(argv[3]);
const int input_events = event_number(reader.headerBlock);
global_reweight = input_events/static_cast<double>(max_events);
std::cout << "Processing " << max_events
<< " out of " << input_events << " events\n";
}
RHEJ::EventReweighter rhej{
reader.heprup,
config
};
if(config.RanLux_init){
RHEJ::PhaseSpacePoint::reset_ranlux(*config.RanLux_init);
}
int nevent = 0;
std::array<int, RHEJ::event_type::last_type + 1>
nevent_type{0}, nfailed_type{0};
// Loop over the events in the inputfile
while(reader.readEvent()){
// reweight events so that the total cross section is conserved
reader.hepeup.setWeight(0, global_reweight * reader.hepeup.weight());
if(nevent == max_events) break;
++nevent;
if (nevent % 10000 == 0){
std::cout << "Passed " << nevent << " events ("
<< time_to_string(clock::to_time_t(clock::now())) << ")"<< std::endl;
}
// calculate rHEJ weight
RHEJ::Event FO_event{
RHEJ::UnclusteredEvent{reader.hepeup},
config.fixed_order_jets.def, config.fixed_order_jets.min_pt,
};
auto resummed_events = rhej.reweight(
FO_event,
config.trials, config.scale_gen
);
++nevent_type[FO_event.type()];
if(resummed_events.empty()) ++nfailed_type[FO_event.type()];
for(auto const & ev: resummed_events){
//TODO: move pass_cuts to after phase space point generation
if(analysis->pass_cuts(ev, FO_event)){
analysis->fill(ev, FO_event);
writer.write(ev);
}
}
} // main event loop
using namespace RHEJ::event_type;
std::cout<< "Events processed: " << nevent << '\n';
for(size_t ev_type = first_type; ev_type <= last_type; ++ev_type){
std::cout << '\t' << names[ev_type] << ": " << nevent_type[ev_type]
<< ", failed to reconstruct " << nfailed_type[ev_type]
<< '\n';
}
std::chrono::duration<double> run_time = (clock::now() - start_time);
std::cout << "Finished " << RHEJ::Version().package_name() << " at "
<< time_to_string(clock::to_time_t(clock::now()))
<< "\n=> Runtime: " << run_time.count() << " sec ("
<< nevent/run_time.count() << " Events/sec).\n";
}

File Metadata

Mime Type
text/x-diff
Expires
Tue, Jan 21, 1:47 AM (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4243545
Default Alt Text
(6 KB)

Event Timeline