Page MenuHomeHEPForge

No OneTemporary

diff --git a/FixedOrderGen/src/main.cc b/FixedOrderGen/src/main.cc
index a996b7c..75fdd7e 100644
--- a/FixedOrderGen/src/main.cc
+++ b/FixedOrderGen/src/main.cc
@@ -1,180 +1,193 @@
/**
* 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 "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/PDF.hh"
//#include "RHEJ/EventReweighter.hh"
#include "RHEJ/stream.hh"
#include "RHEJ/MatrixElement.hh"
#include "RHEJ/LesHouchesWriter.hh"
#include "PhaseSpacePoint.hh"
namespace{
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) {
std::cout << " __ ___ __ ______ __ __ \n";
std::cout << " / / / (_)___ _/ /_ / ____/___ ___ _________ ___ __ / /__ / /______ \n";
std::cout << " / /_/ / / __ `/ __ \\ / __/ / __ \\/ _ \\/ ___/ __ `/ / / / __ / / _ \\/ __/ ___/ \n";
std::cout << " / __ / / /_/ / / / / / /___/ / / / __/ / / /_/ / /_/ / / /_/ / __/ /_(__ ) \n";
std::cout << " /_/ /_/_/\\__, /_/ /_/ /_____/_/ /_/\\___/_/ \\__, /\\__, / \\____/\\___/\\__/____/ \n";
std::cout << " ____///__/ __ ____ ///__//____/ ______ __ \n";
std::cout << " / ____(_) _____ ____/ / / __ \\_________/ /__ _____ / ____/__ ____ ___ _________ _/ /_____ _____\n";
std::cout << " / /_ / / |/_/ _ \\/ __ / / / / / ___/ __ / _ \\/ ___/ / / __/ _ \\/ __ \\/ _ \\/ ___/ __ `/ __/ __ \\/ ___/\n";
std::cout << " / __/ / /> </ __/ /_/ / / /_/ / / / /_/ / __/ / / /_/ / __/ / / / __/ / / /_/ / /_/ /_/ / / \n";
std::cout << " /_/ /_/_/|_|\\___/\\__,_/ \\____/_/ \\__,_/\\___/_/ \\____/\\___/_/ /_/\\___/_/ \\__,_/\\__/\\____/_/ \n";
-
+ fastjet::ClusterSequence::print_banner();
using clock = std::chrono::system_clock;
if (argn < 2) {
std::cerr << "\n# Usage:\n.FOgen config_file\n";
return EXIT_FAILURE;
}
const auto start_time = clock::now();
// read configuration
const auto config = load_config(argv[1]);
std::unique_ptr<RHEJ::Analysis> analysis = get_analysis(
config.analysis_parameters
);
assert(analysis != nullptr);
RHEJ::PDF pdf{
config.pdf_id,
config.beam.particles[0], config.beam.particles[1]
};
// Generate a matrix element:
RHEJ::MatrixElement ME{
[&pdf](double mu){ return pdf.Halphas(mu); },
config.jets.def, config.jets.min_pt,
false,
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);
// 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;
}
- std::cout.flush();
// Generate phase space point
HEJFOG::PhaseSpacePoint psp{
config.process,
config.jets.def,config.jets.min_pt, config.jets.max_y,
pdf
};
hmstatus->Fill(psp.status());
if (psp.status()!=0) continue;
RHEJ::Event ev = config.scale_gen(
RHEJ::Event{
to_UnclusteredEvent(std::move(psp)),
config.jets.def, config.jets.min_pt
}
);
const double shat = RHEJ::shat(ev);
const double xa = (ev.incoming()[0].E()-ev.incoming()[0].pz())/(2.*config.beam.energy);
const double xb = (ev.incoming()[1].E()+ev.incoming()[1].pz())/(2.*config.beam.energy);
// evaluate matrix element on this point
ev.central().weight *= ME.tree(
ev.central().mur, ev.incoming(), ev.outgoing(), false
)/(shat*shat);
ev.central().weight *= pdf.pdfpt(0,xa,ev.central().muf, ev.incoming()[0].type);
ev.central().weight *= pdf.pdfpt(0,xb,ev.central().muf, ev.incoming()[1].type);
ev.central().weight *= invGeV2_to_pb;
ev.central().weight /= config.trials;
for(auto & var: ev.variations()){
var.weight *= ME.tree(
var.mur, ev.incoming(), ev.outgoing(), false
)/(shat*shat);
var.weight *= pdf.pdfpt(0,xa,var.muf, ev.incoming()[0].type);
var.weight *= pdf.pdfpt(0,xb,var.muf, ev.incoming()[1].type);
var.weight *= invGeV2_to_pb;
var.weight /= config.trials;
}
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();
return 0;
}

File Metadata

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

Event Timeline