Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F8725698
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
9 KB
Subscribers
None
View Options
diff --git a/FixedOrderGen/CMakeLists.txt b/FixedOrderGen/CMakeLists.txt
index 4d763ed..6375aac 100644
--- a/FixedOrderGen/CMakeLists.txt
+++ b/FixedOrderGen/CMakeLists.txt
@@ -1,63 +1,60 @@
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project("Fixed Order Generation" C CXX)
## Flags for the compiler. No warning allowed.
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
elseif (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX /EHsc")
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 11)
## Add directories and find dependences
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/../include)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../cmake/Modules/")
#find_library(rhej rhej_)
-find_package(ROOT MODULE COMPONENTS Hist Tree MathCore)
find_package(fastjet REQUIRED)
find_package(clhep REQUIRED)
find_package(lhapdf REQUIRED)
find_package(gsl REQUIRED)
find_package(Boost REQUIRED COMPONENTS iostreams)
find_package(HepMC 3)
find_package(QCDloop 2)
-include_directories(SYSTEM ${ROOT_INCLUDE_DIR})
include_directories(SYSTEM ${lhapdf_INCLUDE_PATH})
include_directories(SYSTEM ${fastjet_INCLUDE_PATH})
include_directories(SYSTEM ${clhep_INCLUDE_PATH})
include_directories(SYSTEM ${gsl_INCLUDE_PATH})
-link_directories(${ROOT_LIBRARY_DIR})
## define executable
file(GLOB FOgen_source ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc)
list(REMOVE_ITEM FOgen_source ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cc)
add_library(hejfog STATIC ${FOgen_source})
add_executable(FOgen ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cc)
## link libraries
-set(libraries ${CMAKE_DL_LIBS} ${LHAPDF_LIBRARIES} ${CLHEP_LIBRARIES} ${FASTJET_LIBRARIES} ${GSL_LIBRARIES} ${Boost_LIBRARIES} ${HepMC_LIBRARIES} ${ROOT_LIBRARIES} yaml-cpp)
+set(libraries ${CMAKE_DL_LIBS} ${LHAPDF_LIBRARIES} ${CLHEP_LIBRARIES} ${FASTJET_LIBRARIES} ${GSL_LIBRARIES} ${Boost_LIBRARIES} ${HepMC_LIBRARIES} yaml-cpp)
if(${QCDloop_FOUND})
list(APPEND libraries ${QCDloop_LIBRARIES} quadmath)
endif()
# add libraries for reversed HEJ <by hand>
list(APPEND libraries rhej)
target_link_libraries(hejfog ${libraries})
target_link_libraries(FOgen hejfog)
install(TARGETS FOgen DESTINATION bin)
enable_testing()
set(tst_dir "${CMAKE_CURRENT_SOURCE_DIR}/t")
add_executable(test_h_2j ${tst_dir}/h_2j.cc)
target_link_libraries(test_h_2j hejfog)
add_test(NAME t_h_2j COMMAND test_h_2j WORKING_DIRECTORY ${tst_dir})
add_executable(test_h_3j ${tst_dir}/h_3j.cc)
target_link_libraries(test_h_3j hejfog)
add_test(NAME t_h_3j COMMAND test_h_3j WORKING_DIRECTORY ${tst_dir})
diff --git a/FixedOrderGen/include/Status.hh b/FixedOrderGen/include/Status.hh
index ba96a2a..54fdc0b 100644
--- a/FixedOrderGen/include/Status.hh
+++ b/FixedOrderGen/include/Status.hh
@@ -1,9 +1,22 @@
#pragma once
+#include <string>
+#include <stdexcept>
+
namespace HEJFOG{
enum Status{
good,
not_enough_jets,
too_much_energy
};
+
+ inline std::string to_string(Status s){
+ switch(s){
+ case good: return "good";
+ case not_enough_jets: return "not enough jets";
+ case too_much_energy: return "too much energy";
+ default:;
+ }
+ throw std::logic_error{"unreachable"};
+ }
}
diff --git a/FixedOrderGen/src/main.cc b/FixedOrderGen/src/main.cc
index 6f20e47..a136b10 100644
--- a/FixedOrderGen/src/main.cc
+++ b/FixedOrderGen/src/main.cc
@@ -1,165 +1,167 @@
/**
* Name: main.cc
* Authors: Jeppe R. Andersen
*/
#include <fstream>
#include <algorithm>
#include <memory>
#include <chrono>
#include <iostream>
-#include <TROOT.h>
-#include <TFile.h>
-#include <TH1.h>
+#include <map>
#include "yaml-cpp/yaml.h"
#include "config.hh"
#include "LHEF/LHEF.h"
#include "RHEJ/CombinedEventWriter.hh"
#include "RHEJ/get_analysis.hh"
#include "RHEJ/utility.hh"
//#include "RHEJ/EventReweighter.hh"
#include "RHEJ/stream.hh"
#include "RHEJ/LesHouchesWriter.hh"
#include "EventGenerator.hh"
#include "PhaseSpacePoint.hh"
namespace{
constexpr auto banner =
" __ ___ __ ______ __ __ \n"
" / / / (_)___ _/ /_ / ____/___ ___ _________ ___ __ / /__ / /______ \n"
" / /_/ / / __ `/ __ \\ / __/ / __ \\/ _ \\/ ___/ __ `/ / / / __ / / _ \\/ __/ ___/ \n"
" / __ / / /_/ / / / / / /___/ / / / __/ / / /_/ / /_/ / / /_/ / __/ /_(__ ) \n"
" /_/ /_/_/\\__, /_/ /_/ /_____/_/ /_/\\___/_/ \\__, /\\__, / \\____/\\___/\\__/____/ \n"
" ____///__/ __ ____ ///__//____/ ______ __ \n"
" / ____(_) _____ ____/ / / __ \\_________/ /__ _____ / ____/__ ____ ___ _________ _/ /_____ _____\n"
" / /_ / / |/_/ _ \\/ __ / / / / / ___/ __ / _ \\/ ___/ / / __/ _ \\/ __ \\/ _ \\/ ___/ __ `/ __/ __ \\/ ___/\n"
" / __/ / /> </ __/ /_/ / / /_/ / / / /_/ / __/ / / /_/ / __/ / / / __/ / / /_/ / /_/ /_/ / / \n"
" /_/ /_/_/|_|\\___/\\__,_/ \\____/_/ \\__,_/\\___/_/ \\____/\\___/_/ /_/\\___/_/ \\__,_/\\__/\\____/_/ \n"
;
constexpr double invGeV2_to_pb = 389379292.;
}
HEJFOG::Config load_config(char const * filename){
try{
return HEJFOG::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 progress_bar(){
std::string result = "0% ";
for(int i = 10; i <= 100; i+= 10){
result += " " + std::to_string(i) + "%";
}
result += "\n|";
for(int i = 10; i <= 100; i+= 10){
result += "---------|";
}
return result + '\n';
}
int main(int argn, char** argv) {
if (argn < 2) {
std::cerr << "\n# Usage:\n.FOgen config_file\n";
return EXIT_FAILURE;
}
std::cout << banner;
fastjet::ClusterSequence::print_banner();
using clock = std::chrono::system_clock;
const auto start_time = clock::now();
// read configuration
auto config = load_config(argv[1]);
std::unique_ptr<RHEJ::Analysis> analysis = get_analysis(
config.analysis_parameters
);
assert(analysis != nullptr);
HEJFOG::EventGenerator generator{
config.process,
config.beam,
config.scale_gen,
config.jets,
config.pdf_id,
config.unordered,
config.Higgs_coupling
};
//TODO: fix Les Houches init block (HEPRUP)
LHEF::HEPRUP lhefheprup;
lhefheprup.IDBMUP=std::pair<long,long>(config.beam.particles[0], config.beam.particles[1]);
lhefheprup.EBMUP=std::make_pair(config.beam.energy, config.beam.energy);
lhefheprup.PDFGUP=std::make_pair(0,0);
lhefheprup.PDFSUP=std::make_pair(config.pdf_id,config.pdf_id);
lhefheprup.NPRUP=1;
lhefheprup.XSECUP=std::vector<double>(1.);
lhefheprup.XERRUP=std::vector<double>(1.);
lhefheprup.LPRUP=std::vector<int>{1};
RHEJ::CombinedEventWriter writer{config.output, lhefheprup};
if(config.RanLux_init){
HEJFOG::PhaseSpacePoint::reset_ranlux(*config.RanLux_init);
}
- // Book root histogram for status
- TFile hfile("GenStatus.root","RECREATE","Generator status");
- TROOT simple("FOG","Output from HEJFOG");
- TH1D *hmstatus;
- hmstatus = new TH1D("mstatus","mstatus",25,-.5,24.5);
-
+ std::map<HEJFOG::Status, int> status_counter;
// Perform N trial generations
int iprint = 0;
std::cout << '\n' << progress_bar();
for (int trials = 0; trials< config.trials;trials++){
if (trials==iprint) {
std::cout << ".";
std::cout.flush();
iprint+=(int) config.trials/100;
}
auto ev = generator.gen_event();
- hmstatus->Fill(generator.status());
+ ++status_counter[generator.status()];
if(generator.status() != HEJFOG::good) continue;
ev.central().weight /= config.trials;
ev.central().weight *= invGeV2_to_pb;
for(auto & var: ev.variations()){
var.weight /= config.trials;
var.weight *= invGeV2_to_pb;
}
if(analysis->pass_cuts(ev)){
analysis->fill(ev);
writer.write(ev);
}
} // main event loop
std::cout << std::endl;
std::chrono::duration<double> run_time = (clock::now() - start_time);
std::cout << "\nTask Runtime: " << run_time.count() << " seconds.\n";
- hfile.Write();
- hfile.Close();
+ for(auto && entry: status_counter){
+ const double fraction = (double) entry.second/config.trials;
+ const int percent = std::round(100*fraction);
+ std::cout << "status "
+ << std::left << std::setw(16) << (to_string(entry.first) + ":")
+ << " [";
+ for(int i = 0; i < percent/2; ++i) std::cout << '#';
+ for(int i = percent/2; i < 50; ++i) std::cout << ' ';
+ std::cout << "] " << percent << "%\n";
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Tue, Jan 21, 2:18 AM (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4243649
Default Alt Text
(9 KB)
Attached To
rHEJ HEJ
Event Timeline
Log In to Comment