Page MenuHomeHEPForge

CrossSectionAccumulator.cc
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

CrossSectionAccumulator.cc

/**
* \authors The HEJ collaboration (see AUTHORS for details)
* \date 2019
* \copyright GPLv2 or later
*/
#include "HEJ/CrossSectionAccumulator.hh"
#include <iomanip>
#include <string>
#include "HEJ/Event.hh"
namespace HEJ {
void CrossSectionAccumulator::fill( double const wt, double const err,
event_type::EventType const type
){
total_.value += wt;
total_.error += err;
auto & entry = xs_[type];
entry.value += wt;
entry.error += err;
}
void CrossSectionAccumulator::fill(
double const wt, event_type::EventType const type
){
fill(wt, wt*wt, type);
}
void CrossSectionAccumulator::fill(Event const & ev){
fill(ev.central().weight, ev.type());
}
void CrossSectionAccumulator::fill_correlated(
double const sum, double const sum2, event_type::EventType const type
){
fill(sum, sum*sum+sum2, type);
}
void CrossSectionAccumulator::fill_correlated(std::vector<Event> const & evts){
if(evts.empty()) return;
fill_correlated(evts.cbegin(), evts.cend());
}
std::ostream& operator<<(std::ostream& os, const CrossSectionAccumulator& xs){
const std::streamsize orig_prec = os.precision();
os << std::scientific << std::setprecision(3)
<< " " << std::left << std::setw(25)
<< "Cross section: " << xs.total().value
<< " +- " << std::sqrt(xs.total().error) << " (pb)\n";
for(auto const & xs_type: xs) {
os << " " << std::left << std::scientific <<std::setw(25)
<< (event_type::name(xs_type.first) + std::string(": "));
os << xs_type.second.value << " +- "
<< std::sqrt(xs_type.second.error) << " (pb) "
<< std::fixed << std::setprecision(3)
<< "[" <<std::setw(6) <<std::right
<< ((xs_type.second.value)/xs.total().value)*100 << "%]"
<< std::endl;
}
os << std::defaultfloat;
os.precision(orig_prec);
return os;
}
}

File Metadata

Mime Type
text/x-c
Expires
Tue, Sep 30, 5:47 AM (1 d, 10 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
6466790
Default Alt Text
CrossSectionAccumulator.cc (1 KB)

Event Timeline