Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F8725470
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
View Options
diff --git a/src/Rivet_Analysis.cc b/src/Rivet_Analysis.cc
index e0bb33b..15195d9 100644
--- a/src/Rivet_Analysis.cc
+++ b/src/Rivet_Analysis.cc
@@ -1,98 +1,105 @@
#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)
{
// 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."
};
}
}
void Rivet_Analysis::init(Event const & event){
- const auto & central = event.central();
- for(size_t i = 0; i < event.variations().size(); ++i){
- 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_);
- }
+ if(!event.variations().size()){
+ 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;
+ // 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_);
+ }
+ }
}
void Rivet_Analysis::fill(Event const & event, Event const &){
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_){
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"
);
}
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
Tue, Jan 21, 1:45 AM (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4243501
Default Alt Text
(3 KB)
Attached To
rHEJ HEJ
Event Timeline
Log In to Comment