Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F8309896
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Subscribers
None
View Options
diff --git a/include/RHEJ/Rivet_Analysis.hh b/include/RHEJ/Rivet_Analysis.hh
index 86f2d5a..e0b5fee 100644
--- a/include/RHEJ/Rivet_Analysis.hh
+++ b/include/RHEJ/Rivet_Analysis.hh
@@ -1,65 +1,57 @@
/** \file Rivet_Analysis.hh
* \brief A custom analysis that calles multiple rivet analyses
*/
#include <memory>
#include <string>
#include <utility>
#include "RHEJ/Analysis.hh"
#include "RHEJ/HepMCInterface.hh"
namespace RHEJ {
class Event;
}
namespace Rivet {
- class AnalysisHandler;
+ class AnalysisHandler;
}
namespace YAML {
class Node;
}
namespace RHEJ {
/**
* @brief Rivet analysis which can be called as a normal rHEJ analysis
* @details In the input file both "analysis" (list of rivet analysis to be called)
* and "output" (prefix for the .yoda files)
*/
- class Rivet_Analysis: public RHEJ::Analysis {
- public:
+ class Rivet_Analysis: public RHEJ::Analysis {
+ public:
static std::unique_ptr<Analysis> create(YAML::Node const & config);
Rivet_Analysis(YAML::Node const & config);
void fill(RHEJ::Event const & event, RHEJ::Event const &) override;
bool pass_cuts(RHEJ::Event const &, RHEJ::Event const &) override
- {return true;} //< no additional cuts are applied
+ {return true;} //< no additional cuts are applied
void finalise() override;
private:
std::vector<std::string> analyses_names_;
const std::string output_name_;
/// struct to organise the infos per rivet run/scale setting
struct rivet_info {
std::unique_ptr<Rivet::AnalysisHandler> handler;
std::string name;
RHEJ::HepMCInterface hepmc;
};
std::vector<rivet_info> rivet_runs_;
/** @brief Calculates the scale variation from the first event for the output file
* @note Name is wrong if multiple scale functions are choosen
* @TODO is there a better way of finding the scale factor?
*/
void init(RHEJ::Event const & event);
bool first_event_;
- };
+ };
}
-
-// extern "C"
-// __attribute__((visibility("default")))
-// std::unique_ptr<RHEJ::Analysis> make_analysis(
-// YAML::Node const & config
-// ){
-// return std::make_unique<Rivet_Analysis>(config);
-// }
diff --git a/src/Rivet_Analysis.cc b/src/Rivet_Analysis.cc
index 15195d9..7ff192d 100644
--- a/src/Rivet_Analysis.cc
+++ b/src/Rivet_Analysis.cc
@@ -1,105 +1,107 @@
#include "RHEJ/Rivet_Analysis.hh"
#ifdef RHEJ_BUILD_WITH_RIVET
#include <ostream>
#include "RHEJ/Event.hh"
#include "yaml-cpp/yaml.h"
#include "Rivet/AnalysisHandler.hh"
namespace RHEJ {
std::unique_ptr<Analysis> Rivet_Analysis::create(YAML::Node const & config){
return std::unique_ptr<Analysis>{new Rivet_Analysis{config}};
}
- Rivet_Analysis::Rivet_Analysis(YAML::Node const & config):
- output_name_{config["output"].as<std::string>()},
- first_event_(true)
- {
+ Rivet_Analysis::Rivet_Analysis(YAML::Node const & config):
+ output_name_{config["output"].as<std::string>()},
+ first_event_(true)
+ {
// read in analyses
const auto & name_node = config["rivet"];
switch(name_node.Type()){
case YAML::NodeType::Scalar:
analyses_names_.push_back(name_node.as<std::string>());
break;
case YAML::NodeType::Sequence:
for(YAML::const_iterator it = name_node.begin(); it != name_node.end(); ++it){
analyses_names_.push_back(it->as<std::string>());
}
break;
default:
throw std::invalid_argument{
"No Analysis was provided to rivet. "
- "Either give an analysis or deactivate rivet."
- };
+ "Either give an analysis or deactivate rivet."
+ };
}
- }
+ }
- void Rivet_Analysis::init(Event const & event){
- if(!event.variations().size()){
- rivet_runs_.push_back({std::make_unique<Rivet::AnalysisHandler>()
- , "", HepMCInterface()});
+ void Rivet_Analysis::init(Event const & event){
+ if(event.variations().empty()){
+ rivet_runs_.push_back(
+ {std::make_unique<Rivet::AnalysisHandler>(), "", HepMCInterface()}
+ );
rivet_runs_.back().handler->addAnalyses(analyses_names_);
}
else{
const auto & central = event.central();
for(size_t i = 0; i < event.variations().size(); ++i){
- const auto & vari = event.variations(i);
- std::ostringstream name;
+ const auto & vari = event.variations(i);
+ std::ostringstream name;
// calculate name ratio of the scales and use them for the output file name
- name << ".Scale" << i << "_MuR" << vari.mur/central.mur
- << "_MuF" << vari.muf/central.muf;
- rivet_runs_.push_back({std::make_unique<Rivet::AnalysisHandler>()
- , name.str(), HepMCInterface()});
- rivet_runs_.back().handler->addAnalyses(analyses_names_);
- }
+ name << ".Scale" << i << "_MuR" << vari.mur/central.mur
+ << "_MuF" << vari.muf/central.muf;
+ rivet_runs_.push_back(
+ {std::make_unique<Rivet::AnalysisHandler>(), name.str(), HepMCInterface()}
+ );
+ rivet_runs_.back().handler->addAnalyses(analyses_names_);
+ }
}
- }
+ }
void Rivet_Analysis::fill(Event const & event, Event const &){
- if(first_event_){
- first_event_=false;
- init(event);
- }
+ if(first_event_){
+ first_event_=false;
+ init(event);
+ }
for(auto & run: rivet_runs_){
run.handler->analyze(run.hepmc(event));
}
}
- void Rivet_Analysis::finalise(){
- for(auto const & run: rivet_runs_){
+ void Rivet_Analysis::finalise(){
+ for(auto const & run: rivet_runs_){
run.handler->finalize();
run.handler->writeData(output_name_+run.name+std::string(".yoda"));
}
- }
+ }
} // namespace RHEJ
#else // no rivet => create empty analysis
namespace Rivet {
class AnalysisHandler {};
}
namespace RHEJ {
std::unique_ptr<Analysis> Rivet_Analysis::create(YAML::Node const & config){
return std::unique_ptr<Analysis>{new Rivet_Analysis{config}};
}
Rivet_Analysis::Rivet_Analysis(YAML::Node const &)
{
- throw std::invalid_argument(
- "Failed to create Rivet_Analysis: "
- "Reversed HEJ was built without rivet support"
- );
+ throw std::invalid_argument(
+ "Failed to create Rivet_Analysis: "
+ "Reversed HEJ was built without rivet support"
+ );
}
void Rivet_Analysis::init(Event const &){}
void Rivet_Analysis::fill(Event const &, Event const &){}
void Rivet_Analysis::finalise(){}
} // namespace RHEJ
#endif
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Dec 21, 4:50 PM (18 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4023523
Default Alt Text
(6 KB)
Attached To
rHEJ HEJ
Event Timeline
Log In to Comment