Page MenuHomeHEPForge

No OneTemporary

diff --git a/cmake/Templates/Version.hh.in b/cmake/Templates/Version.hh.in
index 7e26936..6babcbe 100644
--- a/cmake/Templates/Version.hh.in
+++ b/cmake/Templates/Version.hh.in
@@ -1,85 +1,47 @@
/** \file Version.hh
* \brief The file gives the current HEJ Version
*/
#pragma once
#include <string>
/// @brief Full name of this package.
#define HEJ_PACKAGE_NAME "@PROJECT_NAME@"
/// @brief HEJ version string
#define HEJ_VERSION "@PROJECT_VERSION@"
/// @brief Full name and version of this package.
#define HEJ_PACKAGE_STRING "@PROJECT_NAME@ @PROJECT_VERSION@"
/// @brief Major version of this package
#define HEJ_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
/// @brief Minor version of this package
#define HEJ_VERSION_MINOR @PROJECT_VERSION_MINOR@
/// @brief Patch version of this package
#define HEJ_VERSION_PATCH @PROJECT_VERSION_PATCH@
/// @brief Git revision of this package
#define HEJ_GIT_revision "@PROJECT_GIT_REVISION@"
/// @brief Git branch name of this package
#define HEJ_GIT_branch "@PROJECT_GIT_BRANCH@"
namespace HEJ {
namespace Version {
inline std::string String() { return HEJ_VERSION; }
inline std::string package_name() { return HEJ_PACKAGE_NAME; }
inline std::string package_name_full() { return HEJ_PACKAGE_STRING; }
inline int Major() { return HEJ_VERSION_MAJOR; }
inline int Minor() { return HEJ_VERSION_MINOR; }
inline int Patch() { return HEJ_VERSION_PATCH; }
inline std::string revision() { return HEJ_GIT_revision; }
- inline std::string logo(){
- return "\n\
- .;l: \n \
- .lxxddl. \n HH HH EEEEEE JJJJJJ .kkOkxdoo' \
- \n HH HH EE JJ ;xOOOkxooodl \n HHHHHH EEEE JJ\
- ;dx00OOkdooddxl \n HH HH EE JJ JJ cddk0OOkxolddxxx\
- \n HH HH EEEEEE JJJJ ,dddxOOOkddllddxxx \n \
- .,xOOkkkkOkkxddlllodxd \n .,oxkOOOkkOOOOOxxdool\
-lood: \n .... .'lxkOOOO0O00OO00000Okxdoooood \n .:odxxddxxxd\
-odkkkOOOOOOOOO00000K0KKKK0kxkkodd \n ;cdxkkkxxxkkkxxkOOOOO00OOkO0O0KKKKKKK\
-KKKK0OO' \n ;cdxxddddddddxdxkOO0OOOOOkOO00000KKKKKXKKKKK0c \n .;oddocc:\
-;;;;coxkOOOOOOOOOOOO0000KKKKXXXXXXXXKc \n cdxxdol:;...,okOOkkkkkOkOOOO00K0\
-KKXXXXXKXXXXd \n ;dkkkddl:...:dxkkkkkkOOkkOOO000KKKXXXXKKXXXK' \n .;\
-ododoc,':loxkkkOOOOOOkkOOO00000OkkOKKXXKXl \n .clol::lollodxxkkkkkOOOkk\
-OO000x'..;KXXXKKk \n ,;cldxdllllooxkkkxdkOkxkO0KKx;.,kXKKKKKk \n \
- .;:lodolcclloddol::ldxkkOO0KK0O0KKKK000d \n .',;:loolc:::cloo' ..\
-;xkOOOO0000000KK000, \n .;;;;:clll:;,;:clodc;:;cdxkOOkOO0000000000. \n \
- ,;;;;;::clc:;;clcloddo:codkkkkkkO00K00OO0O. \n .;:::;;;;;lc::;;::;:c\
-lc;;ldxxkkxxkO00KK0OOx \n ';::::::::::ccc:;;;;;;;;,':ldxkdllcclo0KK0Od \
-\n .;:::ccc:::cclolccc;,',,,,',:odoc,.....c0K00d \n .;:::cccc:lllloodoo\
-c:,,',,,,:ldo. .lO0O0d \n ,:::::clccolollodollcc;,,,;;;:lol;'...;oxO00\
-x \n .;:::::cllllllodooolllc:::;:;:cccloolloxkOO00d \n .;:::::clollloooo\
-oollllccccclloddxxkkOOO00O0Od \n .;;:::::cloodddddddolooooolloodxxxkkOOOOOOO\
-OOO: \n .;;;;;:::clooodddxxxdodoodoodddxxkkkkOOOOOOOOOo \n ;:;;;;;;::cllodd\
-ddddddddddddxdxxkkkkkkOOkkkkkk; \n.;::;;;;;;;:cllooooodddddddoddddkkkkkkkkkk\
-xkkkk' \n ,:::;;;,,,::ccllooodododdooooooxxxkkxxxkxkkkkx \n .;:c:;,,,,:cc\
-cclllooooloolllllloddxxxddxkkkkk: \n .;::;,,,,;cclllllooooollllllloooddooo\
-dxxkkkkd \n .',,'',;:clllloddddolllolllooooc::lddxxkxxd \n ....\
-.,:clllodddddlcclcclllc,..;lodxxxkxd \n .,:lllodddddo:;:;:cc. \
- 'clodxxxxd \n 'cclloodddd;...... .;cloddddx. \n \
- ,c::cloddo. .:lodxxxkc \n '::ccloddo. \
- ,codxxkkk, \n ;cclodxxd; .codddxxxx, \n \
- .clodddddo. ,cllcloodd'\n .clodooool; \
- ,cl:lollo'\n :cllllcllo, ',,:c:,' \n \
- .cclc;llc:. \n ,::,cc, \
- "
-;
- }
};
}
diff --git a/src/bin/HEJ.cc b/src/bin/HEJ.cc
index f0c672a..6793c30 100644
--- a/src/bin/HEJ.cc
+++ b/src/bin/HEJ.cc
@@ -1,191 +1,188 @@
/**
* \authors Jeppe Andersen, Tuomas Hapola, Marian Heil, Andreas Maier, Jennifer Smillie
* \date 2019
* \copyright GPLv2 or later
*/
#include <array>
#include <chrono>
#include <iostream>
#include <limits>
#include <memory>
#include <numeric>
#include "yaml-cpp/yaml.h"
#include "LHEF/LHEF.h"
#include "fastjet/ClusterSequence.hh"
#include "HEJ/CombinedEventWriter.hh"
#include "HEJ/config.hh"
#include "HEJ/CrossSectionAccumulator.hh"
#include "HEJ/Event.hh"
#include "HEJ/EventReweighter.hh"
#include "HEJ/get_analysis.hh"
#include "HEJ/make_RNG.hh"
#include "HEJ/ProgressBar.hh"
#include "HEJ/stream.hh"
#include "HEJ/Version.hh"
#include "HEJ/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));
}
HEJ::Config load_config(char const * filename){
try{
return HEJ::load_config(filename);
}
catch(std::exception const & exc){
std::cerr << "Error: " << exc.what() << '\n';
std::exit(EXIT_FAILURE);
}
}
std::unique_ptr<HEJ::Analysis> get_analysis(
YAML::Node const & parameters
){
try{
return HEJ::get_analysis(parameters);
}
catch(std::exception const & exc){
std::cerr << "Failed to load analysis: " << exc.what() << '\n';
std::exit(EXIT_FAILURE);
}
}
// unique_ptr is a workaround:
// HEJ::optional is a better fit, but gives spurious errors with g++ 7.3.0
std::unique_ptr<HEJ::ProgressBar<double>> make_progress_bar(
std::vector<double> const & xs
) {
if(xs.empty()) return {};
const double Born_xs = std::accumulate(begin(xs), end(xs), 0.);
return std::make_unique<HEJ::ProgressBar<double>>(std::cout, Born_xs);
}
std::string time_to_string(const time_t time){
char s[30];
struct tm * p = localtime(&time);
strftime(s, 30, "%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 " << HEJ::Version::package_name_full()
<< ", revision " << HEJ::Version::revision() << " ("
<< time_to_string(clock::to_time_t(start_time)) << ")" << std::endl;
}
- std::cout << HEJ::Version::logo() << "\n" << std::endl;
-
fastjet::ClusterSequence::print_banner();
// read configuration
const HEJ::Config config = load_config(argv[1]);
HEJ::istream in{argv[2]};
std::unique_ptr<HEJ::Analysis> analysis = get_analysis(
config.analysis_parameters
);
assert(analysis != nullptr);
LHEF::Reader reader{in};
auto heprup = reader.heprup;
heprup.generators.emplace_back(LHEF::XMLTag{});
heprup.generators.back().name = HEJ::Version::package_name();
heprup.generators.back().version = HEJ::Version::String();
HEJ::CombinedEventWriter writer{config.output, std::move(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";
}
HEJ::ScaleGenerator scale_gen{
config.scales.base,
config.scales.factors,
config.scales.max_ratio
};
auto ran = HEJ::make_RNG(config.rng.name, config.rng.seed);
assert(ran != nullptr);
HEJ::EventReweighter hej{
reader.heprup,
std::move(scale_gen),
to_EventReweighterConfig(config),
*ran
};
int nevent = 0;
std::array<int, HEJ::event_type::last_type + 1>
nevent_type{0}, nfailed_type{0};
auto progress = make_progress_bar(reader.heprup.XSECUP);
HEJ::CrossSectionAccumulator xs;
// 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;
// calculate HEJ weight
HEJ::Event FO_event{
HEJ::UnclusteredEvent{reader.hepeup},
config.fixed_order_jets.def, config.fixed_order_jets.min_pt,
};
auto resummed_events = hej.reweight(FO_event, config.trials);
++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);
xs.fill(ev);
}
}
if(progress) progress->increment(FO_event.central().weight);
} // main event loop
std::cout << '\n';
analysis->finalise();
using namespace HEJ::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::cout << '\n' << xs << '\n';
std::chrono::duration<double> run_time = (clock::now() - start_time);
std::cout << "Finished " << HEJ::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, Nov 19, 8:30 PM (1 d, 5 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3804215
Default Alt Text
(10 KB)

Event Timeline