Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F8724288
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
View Options
diff --git a/include/HEJ/CrossSectionAccumulator.hh b/include/HEJ/CrossSectionAccumulator.hh
index 4d5b91e..9be4d9f 100644
--- a/include/HEJ/CrossSectionAccumulator.hh
+++ b/include/HEJ/CrossSectionAccumulator.hh
@@ -1,68 +1,69 @@
#pragma once
#include <map>
#include <ostream>
+#include <iomanip>
#include <string>
#include "HEJ/Event.hh"
#include "HEJ/event_types.hh"
namespace HEJ {
template<typename T>
struct XSWithError {
T value = T{};
T error = T{};
};
/**
* @brief Sum of Cross Section for different subproccess
*/
class CrossSectionAccumulator {
public:
void fill(HEJ::Event const & ev) {
const double wt = ev.central().weight;
auto & entry = xs_[ev.type()];
entry.value += wt;
entry.error += wt*wt;
total_.value += wt;
total_.error += wt*wt;
}
auto begin() const {
return std::begin(xs_);
}
auto end() const {
return std::end(xs_);
}
//! total Cross Section and error
XSWithError<double> total() const {
return total_;
}
private:
std::map<HEJ::event_type::EventType, XSWithError<double>> xs_;
XSWithError<double> total_;
};
std::ostream& operator<<(std::ostream& os, const CrossSectionAccumulator& xs){
- std::streamsize ss = std::cout.precision();
+ const std::streamsize orig_prec = os.precision();
os << std::scientific << std::setprecision(10)
<< " " << std::left << std::setw(20)
<< "Cross section: " << xs.total().value
<< " +- " << std::sqrt(xs.total().error) << " (pb)\n";
for(auto const & xs_type: xs) {
os
<< " " << std::left << std::setw(20)
<< (HEJ::event_type::names[xs_type.first] + std::string(": "))
<< xs_type.second.value << " +- "
<< std::sqrt(xs_type.second.error) << " (pb)\n";
}
os << std::defaultfloat;
- std::cout.precision(ss);
+ os.precision(orig_prec);
return os;
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Jan 20, 10:59 PM (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4242761
Default Alt Text
(1 KB)
Attached To
rHEJ HEJ
Event Timeline
Log In to Comment