Page MenuHomeHEPForge

No OneTemporary

diff --git a/CepGen/Cards/ConfigHandler.cpp b/CepGen/Cards/ConfigHandler.cpp
index fbb7d53..dd0c494 100644
--- a/CepGen/Cards/ConfigHandler.cpp
+++ b/CepGen/Cards/ConfigHandler.cpp
@@ -1,236 +1,237 @@
#include "ConfigHandler.h"
#ifdef LIBCONFIG
namespace CepGen
{
namespace Cards
{
//----- specialization for CepGen input cards
ConfigHandler::ConfigHandler( const char* file )
{
#ifdef LIBCONFIG
libconfig::Config cfg;
try { cfg.readFile( file ); } catch ( const libconfig::ParseException& pe ) {
FatalError( Form( "Failed to parse the configuration card \"%s\".\n\tParser error: %s (at line %d)", file, pe.getError(), pe.getLine() ) );
}
try {
const libconfig::Setting& root = cfg.getRoot();
const libconfig::Setting& proc = root["process"];
//--- type of process to consider
const char* proc_name = proc["name"]; const std::string str_proc_name = proc_name;
if ( str_proc_name == "lpair" ) params_.setProcess( new Process::GamGamLL );
else if ( str_proc_name == "pptoll" ) params_.setProcess( new Process::PPtoLL );
+ else if ( str_proc_name == "pptoww" ) params_.setProcess( new Process::PPtoWW );
else FatalError( Form( "Unrecognised process: %s", proc_name ) );
//--- process mode
int int_mode; const char* mode;
if ( proc.lookupValue( "mode", int_mode ) ) {
params_.kinematics.mode = (Kinematics::ProcessMode)int_mode;
}
else if ( proc.lookupValue( "mode", mode ) ) {
const std::string str_mode = mode;
if ( str_mode == "elastic/elastic" ) params_.kinematics.mode = Kinematics::ProcessMode::ElasticElastic;
else if ( str_mode == "elastic/inelastic" ) params_.kinematics.mode = Kinematics::ProcessMode::ElasticInelastic;
else if ( str_mode == "inelastic/elastic" ) params_.kinematics.mode = Kinematics::ProcessMode::InelasticElastic;
else if ( str_mode == "inelastic/inelastic" ) params_.kinematics.mode = Kinematics::ProcessMode::InelasticInelastic;
else FatalError( Form( "Unrecognised interaction mode: %s", mode ) );
}
//--- process kinematics
if ( proc.exists( "in_kinematics" ) ) parseIncomingKinematics( proc["in_kinematics"] );
if ( proc.exists( "out_kinematics" ) ) parseOutgoingKinematics( proc["out_kinematics"] );
//--- generation parameters
if ( root.exists( "vegas" ) ) parseVegas( root["vegas"] );
if ( root.exists( "generator" ) ) parseGenerator( root["generator"] );
//--- taming functions
if ( proc.exists( "taming_functions" ) ) parseTamingFunctions( proc["taming_functions"] );
} catch ( const libconfig::SettingNotFoundException& nfe ) {
FatalError( Form( "Failed to retrieve the field \"%s\".", nfe.getPath() ) );
} catch ( const libconfig::SettingTypeException& te ) {
FatalError( Form( "Field \"%s\" has wrong type.", te.getPath() ) );
}
#else
InWarning( "libconfig++ is not present on this machine" );
#endif
}
#ifdef LIBCONFIG
void
ConfigHandler::parseIncomingKinematics( const libconfig::Setting& kin )
{
try {
if ( kin.exists( "beam1_pz" ) ) params_.kinematics.inp.first = (double)kin["beam1_pz"];
if ( kin.exists( "beam2_pz" ) ) params_.kinematics.inp.second = (double)kin["beam2_pz"];
if ( kin.exists( "structure_functions" ) ) {
const char* sf = kin["structure_functions" ]; const std::string sf_str = sf;
if ( sf_str == "electron" ) params_.kinematics.structure_functions = Electron;
else if ( sf_str == "elastic proton" ) params_.kinematics.structure_functions = ElasticProton;
else if ( sf_str == "Suri-Yennie" ) params_.kinematics.structure_functions = SuriYennie;
else if ( sf_str == "Suri-Yennie;lowQ2" ) params_.kinematics.structure_functions = SuriYennieLowQ2;
else if ( sf_str == "Szczurek-Uleshchenko" ) params_.kinematics.structure_functions = SzczurekUleshchenko;
else if ( sf_str == "Fiore;valence" ) params_.kinematics.structure_functions = FioreVal;
else if ( sf_str == "Fiore;sea" ) params_.kinematics.structure_functions = FioreSea;
else if ( sf_str == "Fiore" ) params_.kinematics.structure_functions = Fiore;
else FatalError( Form( "Invalid structure functions mode: %s", sf ) );
}
} catch ( const libconfig::SettingNotFoundException& nfe ) {
FatalError( Form( "Failed to retrieve the field \"%s\".", nfe.getPath() ) );
} catch ( const libconfig::SettingTypeException& te ) {
FatalError( Form( "Field \"%s\" has wrong type.", te.getPath() ) );
}
}
void
ConfigHandler::parseOutgoingKinematics( const libconfig::Setting& kin )
{
try {
if ( kin.exists( "pair" ) ) {
Particle::ParticleCode pair = (Particle::ParticleCode)(int)kin["pair"];
params_.kinematics.central_system = { pair, pair };
}
if ( kin.exists( "min_pt" ) ) params_.kinematics.central_cuts[Cuts::pt_single].min() = (double)kin["min_pt"];
if ( kin.exists( "max_pt" ) ) params_.kinematics.central_cuts[Cuts::pt_single].max() = (double)kin["max_pt"];
if ( kin.exists( "min_ptdiff" ) ) params_.kinematics.central_cuts[Cuts::pt_diff].min() = (double)kin["min_ptdiff"];
if ( kin.exists( "max_ptdiff" ) ) params_.kinematics.central_cuts[Cuts::pt_diff].max() = (double)kin["max_ptdiff"];
if ( kin.exists( "min_dely" ) ) params_.kinematics.central_cuts[Cuts::dely].min() = (double)kin["min_dely"];
if ( kin.exists( "max_dely" ) ) params_.kinematics.central_cuts[Cuts::dely].max() = (double)kin["max_dely"];
if ( kin.exists( "min_energy" ) ) params_.kinematics.central_cuts[Cuts::energy_single].min() = (double)kin["min_energy"];
if ( kin.exists( "max_energy" ) ) params_.kinematics.central_cuts[Cuts::energy_single].max() = (double)kin["max_energy"];
if ( kin.exists( "min_eta" ) ) params_.kinematics.central_cuts[Cuts::eta_single].min() = (double)kin["min_eta"];
if ( kin.exists( "max_eta" ) ) params_.kinematics.central_cuts[Cuts::eta_single].max() = (double)kin["max_eta"];
if ( kin.exists( "min_rapidity" ) ) params_.kinematics.central_cuts[Cuts::rapidity_single].min() = (double)kin["min_rapidity"];
if ( kin.exists( "max_rapidity" ) ) params_.kinematics.central_cuts[Cuts::rapidity_single].max() = (double)kin["max_rapidity"];
if ( kin.exists( "min_mx" ) ) params_.kinematics.remnant_cuts[Cuts::mass].min() = (double)kin["min_mx"];
if ( kin.exists( "max_mx" ) ) params_.kinematics.remnant_cuts[Cuts::mass].max() = (double)kin["max_mx"];
} catch ( const libconfig::SettingNotFoundException& nfe ) {
FatalError( Form( "Failed to retrieve the field \"%s\".", nfe.getPath() ) );
} catch ( const libconfig::SettingTypeException& te ) {
FatalError( Form( "Field \"%s\" has wrong type.", te.getPath() ) );
}
}
void
ConfigHandler::parseVegas( const libconfig::Setting& veg )
{
try {
if ( veg.exists( "num_points" ) ) params_.vegas.npoints = (int)veg["num_points"];
if ( veg.exists( "num_integration_calls" ) ) params_.vegas.ncvg = (int)veg["num_integration_calls"];
if ( veg.exists( "num_integration_iterations" ) ) params_.vegas.itvg = (int)veg["num_integration_iterations"];
} catch ( const libconfig::SettingNotFoundException& nfe ) {
FatalError( Form( "Failed to retrieve the field \"%s\".", nfe.getPath() ) );
}
}
void
ConfigHandler::parseGenerator( const libconfig::Setting& gen )
{
params_.generation.enabled = true;
try {
if ( gen.exists( "num_events" ) ) params_.generation.maxgen = (int)gen["num_events"];
if ( gen.exists( "print_every" ) ) params_.generation.gen_print_every = (int)gen["print_every"];
} catch ( const libconfig::SettingNotFoundException& nfe ) {
FatalError( Form( "Failed to retrieve the field \"%s\".", nfe.getPath() ) );
}
}
void
ConfigHandler::parseTamingFunctions( const libconfig::Setting& tf )
{
if ( !tf.isList() ) FatalError( "The taming functions definition must be wrapped within a list!" );
for ( unsigned short i = 0; i < tf.getLength(); ++i ) {
params_.taming_functions.add( tf[i]["variable"], tf[i]["expression"] );
}
}
void
ConfigHandler::writeProcess( const Parameters* params, libconfig::Setting& root )
{
libconfig::Setting& proc = root.add( "process", libconfig::Setting::TypeGroup );
proc.add( "name", libconfig::Setting::TypeString ) = params->processName();
std::ostringstream os; os << params->kinematics.mode;
proc.add( "mode", libconfig::Setting::TypeString ) = os.str();
}
void
ConfigHandler::writeIncomingKinematics( const Parameters* params, libconfig::Setting& root )
{
libconfig::Setting& kin = root.add( "in_kinematics", libconfig::Setting::TypeGroup );
kin.add( "beam1_pz", libconfig::Setting::TypeFloat ) = params->kinematics.inp.first;
kin.add( "beam2_pz", libconfig::Setting::TypeFloat ) = params->kinematics.inp.second;
std::ostringstream os; os << params->kinematics.structure_functions;
kin.add( "structure_function", libconfig::Setting::TypeString ) = os.str();
}
void
ConfigHandler::writeOutgoingKinematics( const Parameters* params, libconfig::Setting& root )
{
libconfig::Setting& kin = root.add( "out_kinematics", libconfig::Setting::TypeGroup );
kin.add( "pair", libconfig::Setting::TypeInt ) = (int)params->kinematics.central_system[0];
kin.add( "min_pt", libconfig::Setting::TypeFloat ) = params->kinematics.central_cuts.at( Cuts::pt_single ).min();
kin.add( "max_pt", libconfig::Setting::TypeFloat ) = params->kinematics.central_cuts.at( Cuts::pt_single ).max();
kin.add( "min_ptdiff", libconfig::Setting::TypeFloat ) = params->kinematics.central_cuts.at( Cuts::pt_diff ).min();
kin.add( "max_ptdiff", libconfig::Setting::TypeFloat ) = params->kinematics.central_cuts.at( Cuts::pt_diff ).max();
kin.add( "min_dely", libconfig::Setting::TypeFloat ) = params->kinematics.central_cuts.at( Cuts::dely ).min();
kin.add( "max_dely", libconfig::Setting::TypeFloat ) = params->kinematics.central_cuts.at( Cuts::dely ).max();
kin.add( "min_energy", libconfig::Setting::TypeFloat ) = params->kinematics.central_cuts.at( Cuts::energy_single ).min();
kin.add( "max_energy", libconfig::Setting::TypeFloat ) = params->kinematics.central_cuts.at( Cuts::energy_single ).max();
kin.add( "min_eta", libconfig::Setting::TypeFloat ) = params->kinematics.central_cuts.at( Cuts::eta_single ).min();
kin.add( "max_eta", libconfig::Setting::TypeFloat ) = params->kinematics.central_cuts.at( Cuts::eta_single ).max();
kin.add( "min_mx", libconfig::Setting::TypeFloat ) = params->kinematics.remnant_cuts.at( Cuts::mass ).min();
kin.add( "max_mx", libconfig::Setting::TypeFloat ) = params->kinematics.remnant_cuts.at( Cuts::mass ).max();
}
void
ConfigHandler::writeTamingFunctions( const Parameters* params, libconfig::Setting& root )
{
libconfig::Setting& tf = root.add( "taming_functions", libconfig::Setting::TypeList );
for ( std::map<std::string,TamingFunction>::const_iterator it = params->taming_functions.begin(); it != params->taming_functions.end(); ++it ) {
libconfig::Setting& fun = tf.add( libconfig::Setting::TypeGroup );
fun.add( "variable", libconfig::Setting::TypeString ) = it->first;
fun.add( "expression", libconfig::Setting::TypeString ) = it->second.expression;
}
}
void
ConfigHandler::writeVegas( const Parameters* params, libconfig::Setting& root )
{
libconfig::Setting& veg = root.add( "vegas", libconfig::Setting::TypeGroup );
veg.add( "num_points", libconfig::Setting::TypeInt ) = (int)params->vegas.npoints;
veg.add( "num_integration_calls", libconfig::Setting::TypeInt ) = (int)params->vegas.ncvg;
veg.add( "num_integration_iterations", libconfig::Setting::TypeInt ) = (int)params->vegas.itvg;
}
void
ConfigHandler::writeGenerator( const Parameters* params, libconfig::Setting& root )
{
if ( !params->generation.enabled ) return;
libconfig::Setting& gen = root.add( "generator", libconfig::Setting::TypeGroup );
gen.add( "num_events", libconfig::Setting::TypeInt ) = (int)params->generation.maxgen;
gen.add( "print_every", libconfig::Setting::TypeInt ) = (int)params->generation.gen_print_every;
}
#endif
void
ConfigHandler::store( const Parameters* params, const char* file )
{
#ifdef LIBCONFIG
libconfig::Config cfg;
libconfig::Setting& root = cfg.getRoot();
writeProcess( params, root );
writeIncomingKinematics( params, root["process"] );
writeOutgoingKinematics( params, root["process"] );
writeTamingFunctions( params, root["process"] );
writeVegas( params, root );
writeGenerator( params, root );
cfg.writeFile( file );
#endif
}
}
}
#endif
diff --git a/CepGen/Cards/Handler.h b/CepGen/Cards/Handler.h
index d49727a..d56c50e 100644
--- a/CepGen/Cards/Handler.h
+++ b/CepGen/Cards/Handler.h
@@ -1,32 +1,33 @@
#ifndef CepGen_Cards_Handler_h
#define CepGen_Cards_Handler_h
#include "CepGen/Parameters.h"
#include "CepGen/Processes/GamGamLL.h"
#include "CepGen/Processes/PPtoLL.h"
+#include "CepGen/Processes/PPtoWW.h"
namespace CepGen
{
/// Location for all steering card parsers/writers
namespace Cards
{
/// Generic steering card handler
class Handler
{
public:
/// Build a configuration from an external steering card
Handler() {}
~Handler() {}
/// Retrieve a configuration from a parsed steering cart
Parameters& parameters() { return params_; }
protected:
/// List of parameters parsed from a card handler
Parameters params_;
};
}
}
#endif
diff --git a/CepGen/Cards/LpairHandler.cpp b/CepGen/Cards/LpairHandler.cpp
index c7ddabb..3cd3f13 100644
--- a/CepGen/Cards/LpairHandler.cpp
+++ b/CepGen/Cards/LpairHandler.cpp
@@ -1,121 +1,122 @@
#include "LpairHandler.h"
namespace CepGen
{
namespace Cards
{
//----- specialization for LPAIR input cards
LpairHandler::LpairHandler( const char* file )
{
std::ifstream f( file, std::fstream::in );
if ( !f.is_open() ) {
FatalError( Form( "Failed to parse file \"%s\"", file ) );
return;
}
init( &params_ );
std::ostringstream os;
os << Form( "File '%s' succesfully opened! The following parameters are set:\n", file );
std::map<std::string, std::string> m_params;
std::string key, value;
while ( f >> key >> value ) {
if ( key[0] == '#' ) continue; // FIXME need to ensure there is no extra space before!
setParameter( key, value );
m_params.insert( std::pair<std::string,std::string>( key, value ) );
if ( getDescription( key ) != "null" ) os << ">> " << key << " = " << std::setw( 15 ) << getParameter( key ) << " (" << getDescription( key ) << ")" << std::endl;
}
f.close();
if ( proc_name_ == "lpair" ) params_.setProcess( new Process::GamGamLL() );
else if ( proc_name_ == "pptoll" ) params_.setProcess( new Process::PPtoLL() );
+ else if ( proc_name_ == "pptoww" ) params_.setProcess( new Process::PPtoWW() );
else FatalError( Form( "Unrecognised process name: %s", proc_name_.c_str() ) );
if ( m_params.count( "IEND" ) ) setValue<bool>( "IEND", ( std::stoi( m_params["IEND"] ) > 1 ) );
params_.kinematics.central_system = { pair_, pair_ };
Information( os.str() );
}
void
LpairHandler::init( Parameters* params )
{
registerParameter<std::string>( "PROC", "Process name to simulate", &proc_name_ );
registerParameter<bool>( "IEND", "Generation type", &params->generation.enabled );
registerParameter<unsigned int>( "DEBG", "Debugging verbosity", (unsigned int*)&Logger::get().level );
registerParameter<unsigned int>( "NCVG", "Number of function calls", &params->vegas.ncvg );
registerParameter<unsigned int>( "NCSG", "Number of points to probe", &params->vegas.npoints );
registerParameter<unsigned int>( "ITVG", "Number of Vegas iterations", &params->vegas.itvg );
registerParameter<unsigned int>( "MODE", "Subprocess' mode", (unsigned int*)&params->kinematics.mode );
registerParameter<unsigned int>( "PMOD", "Outgoing primary particles' mode", (unsigned int*)&params->kinematics.structure_functions );
registerParameter<unsigned int>( "EMOD", "Outgoing primary particles' mode", (unsigned int*)&params->kinematics.structure_functions );
registerParameter<unsigned int>( "PAIR", "Outgoing particles' PDG id", (unsigned int*)&pair_ );
registerParameter<unsigned int>( "NGEN", "Number of events to generate", &params->generation.maxgen );
registerParameter<double>( "INPP", "Momentum (1st primary particle)", &params->kinematics.inp.first );
registerParameter<double>( "INPE", "Momentum (2nd primary particle)", &params->kinematics.inp.second );
registerParameter<double>( "PTCT", "Minimal transverse momentum (single central outgoing particle)", &params->kinematics.central_cuts[Cuts::pt_single].min() );
registerParameter<double>( "MSCT", "Minimal central system mass", &params->kinematics.central_cuts[Cuts::mass_sum].min() );
registerParameter<double>( "ECUT", "Minimal energy (single central outgoing particle)", &params->kinematics.central_cuts[Cuts::energy_single].min() );
//registerParameter<double>( "THMN", "Minimal polar production angle for the central particles", &params->kinematics.eta_min );
//registerParameter<double>( "THMX", "Maximal polar production angle for the central particles", &params->kinematics.eta_max );
registerParameter<double>( "ETMN", "Minimal pseudo-rapidity (central outgoing particles)", &params->kinematics.central_cuts[Cuts::eta_single].min() );
registerParameter<double>( "ETMX", "Maximal pseudo-rapidity (central outgoing particles)", &params->kinematics.central_cuts[Cuts::eta_single].max() );
registerParameter<double>( "Q2MN", "Minimal Q^2 (exchanged parton)", &params->kinematics.initial_cuts[Cuts::q2].min() );
registerParameter<double>( "Q2MX", "Maximal Q^2 (exchanged parton)", &params->kinematics.initial_cuts[Cuts::q2].max() );
registerParameter<double>( "MXMN", "Minimal invariant mass of proton remnants", &params->kinematics.remnant_cuts[Cuts::mass].min() );
registerParameter<double>( "MXMX", "Maximal invariant mass of proton remnants", &params->kinematics.remnant_cuts[Cuts::mass].max() );
}
void
LpairHandler::store( const char* file )
{
std::ofstream f( file, std::fstream::out | std::fstream::trunc );
if ( !f.is_open() ) {
InError( Form( "Failed to open file \"%s\" for writing", file ) );
return;
}
for ( const auto& it : p_strings_ ) { if ( it.second.value ) f << it.first << " = " << *it.second.value << "\n"; }
for ( const auto& it : p_ints_ ) { if ( it.second.value ) f << it.first << " = " << *it.second.value << "\n"; }
for ( const auto& it : p_doubles_ ) { if ( it.second.value ) f << it.first << " = " << *it.second.value << "\n"; }
for ( const auto& it : p_bools_ ) { if ( it.second.value ) f << it.first << " = " << *it.second.value << "\n"; }
f.close();
}
void
LpairHandler::setParameter( std::string key, std::string value )
{
try { setValue<double>( key.c_str(), std::stod( value ) ); } catch ( std::invalid_argument& ) {}
try { setValue<unsigned int>( key.c_str(), std::stoi( value ) ); } catch ( std::invalid_argument& ) {}
//setValue<bool>( key.c_str(), std::stoi( value ) );
setValue<std::string>( key.c_str(), value );
}
std::string
LpairHandler::getParameter( std::string key ) const
{
double dd = getValue<double>( key.c_str() );
if ( dd != -999. ) return std::to_string( dd );
unsigned int ui = getValue<unsigned int>( key.c_str() );
if ( ui != 999 ) return std::to_string( ui );
//if ( out = getValue<bool>( key.c_str() ) );
return getValue<std::string>( key.c_str() );
}
std::string
LpairHandler::getDescription( std::string key ) const
{
if ( p_strings_.count( key ) ) return p_strings_.find( key )->second.description;
if ( p_ints_.count( key ) ) return p_ints_.find( key )->second.description;
if ( p_doubles_.count( key ) ) return p_doubles_.find( key )->second.description;
if ( p_bools_.count( key ) ) return p_bools_.find( key )->second.description;
return "null";
}
}
}

File Metadata

Mime Type
text/x-diff
Expires
Tue, Nov 19, 6:17 PM (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3805556
Default Alt Text
(20 KB)

Event Timeline