27 namespace MD = MultiDimensional;
30 _histograms = histograms;
35 Event::~Event() noexcept {
37 _histograms =
nullptr;
38 _dictionaries =
nullptr;
43 _histogramBins.clear();
48 void Event::setEventBaseWeight(
double weight) {
49 _eventWeight = weight;
52 double Event::getEventBaseWeight()
const {
66 pm.setSettingsHandler(*
this);
67 pm.initialize(_dictionaries);
68 HashId idx = pm.inputs().getId();
72 _processes.emplace(idx, move(pm));
78 void Event::removeProcess(
HashId idx) {
79 auto it = _processes.find(idx);
80 if (it != _processes.end()) {
83 auto it2 = _eventId.find(idx);
84 if (it2 != _eventId.end()) {
99 if(_schemes.size() == 0) {
100 _schemes = _dictionaries->schemeDefs().getFFSchemeNames();
105 for (
auto& elem : _processes) {
111 void Event::setHistogramBin(
const string& label,
const IndexList indices) {
112 auto it = _histogramBins.find(label);
113 if (it != _histogramBins.end()) {
114 it->second = indices;
116 _histogramBins.insert({label, indices});
120 void Event::fillHistograms() {
122 transform(_processes.cbegin(), _processes.cend(), inserter(evtId, evtId.end()), [](
auto const& m) {
return m.first; });
123 if(evtId.size() == 0){
126 _histograms->setEventId(evtId);
127 for(
auto& histobins : _histogramBins){
128 for(
auto& scheme : _schemes){
130 if(_processes.size() > 0) {
132 for(
const auto& proc : _processes){
134 histoWeight = proc.second.results().processWeight(scheme);
144 _histograms->fillHisto(histobins.first, scheme, histobins.second, histoWeight, _eventWeight);
153 void Event::write(flatbuffers::FlatBufferBuilder* msgwriter)
const {
154 vector<flatbuffers::Offset<Serial::FBProcess>> procs;
155 procs.reserve(_processes.size());
156 for (
auto& elem : _processes) {
158 elem.second.write(msgwriter, &tmp);
159 procs.push_back(tmp);
161 vector<uint64_t> ids;
162 ids.reserve(_eventId.size());
163 copy(_eventId.begin(),_eventId.end(), back_inserter(ids));
164 auto serialid = msgwriter->CreateVector(ids);
165 Serial::FBIdSetBuilder evtid{*msgwriter};
166 evtid.add_ids(serialid);
167 auto serialevtid = evtid.Finish();
168 auto serialprocs = msgwriter->CreateVector(procs);
169 Serial::FBEventBuilder serialevent{*msgwriter};
170 serialevent.add_processes(serialprocs);
171 serialevent.add_id(serialevtid);
172 serialevent.add_weight(_eventWeight);
173 auto evtoffset = serialevent.Finish();
174 msgwriter->Finish(evtoffset);
178 if (msgreader !=
nullptr) {
180 auto procs = msgreader->processes();
184 for (
unsigned int i = 0; i < procs->size(); ++i) {
185 auto elem = procs->Get(i);
186 auto it = _processes.find(elem->ids()->id());
187 if (it != _processes.end()) {
188 result &= it->second.read(elem, merge);
196 res.first->second.setSettingsHandler(*
this);
197 res.first->second.initialize(_dictionaries);
198 res.first->second.read(elem,
false);
201 auto evtids = msgreader->id()->ids();
205 for (
unsigned int i = 0; i < evtids->size(); ++i) {
206 _eventId.insert(evtids->Get(i));
208 _eventWeight = msgreader->weight();
214 Log& Event::getLog()
const {
215 return Log::getLog(
"Hammer.Event");
218 void Event::defineSettings() {
219 setPath(
"Hammer.Event");
223 return getProcManager(process).results().processAmplitude(what);
227 return getProcManager(process).results().processAmplitudeSquared(what);
232 for(
auto& proc: _processes) {
233 auto t = cref(proc.second.results().processAmplitude(what));
234 result.insert({proc.first, t});
241 for(
auto& proc: _processes) {
242 auto t = cref(proc.second.results().processAmplitudeSquared(what));
243 result.insert({proc.first, t});
248 vector<reference_wrapper<const Tensor>> Event::getProcessFormFactors(
const string& scheme,
HashId process)
const {
249 return getProcManager(process).results().processFormFactors(scheme);
254 for(
auto& proc: _processes) {
255 result.insert({proc.first, proc.second.results().processFormFactors(scheme)});
260 const Tensor& Event::getTensorWeight(
const string& scheme,
HashId process)
const {
261 return getProcManager(process).results().processWeight(scheme);
266 for(
auto& proc: _processes) {
267 auto t = cref(proc.second.results().processWeight(scheme));
268 result.insert({proc.first, t});
273 double Event::getWeight(
const string& scheme,
HashId process)
const {
274 const Tensor& t = getProcManager(process).results().processWeight(scheme);
276 auto ext = _dictionaries->externalData().getExternalVectors(scheme, labst);
278 if(ext.rank() != 0) {
279 MSG_ERROR(
"Invalid rank at end of evaluation");
281 return ext.element().real();
286 for(
auto& proc: _processes) {
287 const Tensor& t = proc.second.results().processWeight(scheme);
289 auto ext = _dictionaries->externalData().getExternalVectors(scheme, labst);
291 if(ext.rank() != 0) {
292 MSG_ERROR(
"Invalid rank at end of evaluation");
294 result.insert({proc.first, ext.element().real()});
std::set< ProcessUID > EventUID
auto const & getOrThrow(const std::map< KeyType, ValueType > &data, KeyType key, std::exception error)
void read(const Serial::FBProcIDs *msgreader)
TensorData read(const Serial::FBTensor *msgreader)
LabelsList labels() const
get the labels of all the indices at once
Container class for values of WC and FF vectors.
Tensor indices label definitions.
Message logging routines.
Hammer histogram manager.
Hammer histogram manager class.
virtual void setSettingsHandler(SettingsHandler &sh)
set link to settings repository handler.
std::vector< IndexType > IndexList
Order-0 tensor data container.
Multidimensional tensor class with complex numbers as elements.
TensorData makeScalar(complex< double > value)
std::map< ProcessUID, T > ProcIdDict
Container class for Scheme Definitions.
Tensor & dot(const Tensor &other, const UniqueLabelsList &indices={})
contract this tensor with another and stores the result in this tensor
Out-of-range error class.
Serialization related typedefs and includes.
Global container class for amplitudes, rates, FFs, data.