Page MenuHomeHEPForge

No OneTemporary

diff --git a/t/test_parameters.cc b/t/test_parameters.cc
index 518a89e..2261167 100644
--- a/t/test_parameters.cc
+++ b/t/test_parameters.cc
@@ -1,71 +1,71 @@
#include <iostream>
#include <stdexcept>
#include "HEJ/Parameters.hh"
#define ASSERT(x) if(!(x)) { \
throw std::logic_error("Assertion '" #x "' failed."); \
}
namespace {
bool same_description(
HEJ::EventParameters const & par1, HEJ::EventParameters const & par2
){
if( par1.mur!=par2.mur || par1.muf!=par2.muf ) return false;
auto const & des1 = par1.description;
auto const & des2 = par2.description;
if(bool(des1) != bool(des2)) return false; // only one set
if(!des1) return true; // both not set
return (des1->mur_factor == des2->mur_factor)
&& (des1->muf_factor == des2->muf_factor)
&& (des1->scale_name == des2->scale_name);
}
void same_description(
HEJ::Parameters<HEJ::EventParameters> const & par1,
HEJ::Parameters<HEJ::EventParameters> const & par2
){
ASSERT(same_description(par1.central, par2.central));
ASSERT(par1.variations.size() == par2.variations.size());
for(size_t i=0; i<par1.variations.size(); ++i)
ASSERT( same_description(par1.variations[i], par2.variations[i]) );
}
}
int main() {
HEJ::Parameters<HEJ::EventParameters> ev_param;
ev_param.central = HEJ::EventParameters{ 1,1,1.1,
std::make_shared<HEJ::ParameterDescription>("a", 1.,1.) };
ev_param.variations.emplace_back(
HEJ::EventParameters{ 2,2,2.2,
- std::make_shared<HEJ::ParameterDescription>("a", 2.,2.)
+ std::make_shared<HEJ::ParameterDescription>("b", 2.,2.)
});
ev_param.variations.emplace_back(
HEJ::EventParameters{ 3,3,3.3,
- std::make_shared<HEJ::ParameterDescription>("b", 3.,3.)
+ std::make_shared<HEJ::ParameterDescription>("c", 3.,3.)
});
HEJ::Weights weights;
weights.central = 4.4;
weights.variations.push_back(5.5);
weights.variations.push_back(6.6);
HEJ::Parameters<HEJ::EventParameters> mult_param;
mult_param = ev_param*weights;
same_description(ev_param, mult_param);
ASSERT(mult_param.central.weight == ev_param.central.weight*weights.central);
for(size_t i=0; i<weights.variations.size(); ++i)
ASSERT(mult_param.variations[i].weight
== ev_param.variations[i].weight*weights.variations[i]);
HEJ::Parameters<HEJ::EventParameters> div_param;
div_param = ev_param/weights;
same_description(ev_param, div_param);
ASSERT(div_param.central.weight == ev_param.central.weight/weights.central);
for(size_t i=0; i<weights.variations.size(); ++i)
ASSERT(div_param.variations[i].weight
== ev_param.variations[i].weight/weights.variations[i]);
return EXIT_SUCCESS;
}

File Metadata

Mime Type
text/x-diff
Expires
Tue, Nov 19, 9:19 PM (1 d, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3806233
Default Alt Text
(2 KB)

Event Timeline