ATLAS Offline Software
Loading...
Searching...
No Matches
Flow.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4/* Author: Andrii Verbytskyi andrii.verbytskyi@mpp.mpg.de */
5
6#ifndef ATLASHEPMC_FLOW_H
7#define ATLASHEPMC_FLOW_H
8#include <type_traits>
9#include "HepMC3/Attribute.h"
10#include "HepMC3/GenParticle.h"
12namespace HepMC {
13typedef std::shared_ptr<HepMC3::VectorIntAttribute> Flow;
14template <class T, std::enable_if_t<std::is_same<T, HepMC3::GenParticlePtr>::value || std::is_same<T, HepMC3::ConstGenParticlePtr>::value, bool > = true>
15inline int flow(const T& p, int i) {
16 std::shared_ptr<HepMC3::IntAttribute> f = p->template attribute<HepMC3::IntAttribute>("flow" + std::to_string(i)); if (f) return f->value();
17 std::shared_ptr<HepMC3::VectorIntAttribute> vf = p->template attribute<HepMC3::VectorIntAttribute>(HepMCStr::flow); if (vf) if (0 < i && i < (int)(vf->value().size())) return vf->value().at(i);
18 return 0;
19}
20template <class T, std::enable_if_t<std::is_same<T, HepMC3::GenParticlePtr>::value || std::is_same<T, HepMC3::ConstGenParticlePtr>::value, bool > = true>
21inline Flow flow(const T& p) {
22 std::shared_ptr<HepMC3::VectorIntAttribute> vf = p->template attribute<HepMC3::VectorIntAttribute>(HepMCStr::flow);
23 if (vf) return vf;
24
25 std::vector<int> fl;
26 for (int i = 1; i <= 10; i++) {
27 std::shared_ptr<HepMC3::IntAttribute> f = p->template attribute<HepMC3::IntAttribute>("flow" + std::to_string(i)); if (f) fl.push_back(i); else break;
28 }
29 return std::make_shared<HepMC3::VectorIntAttribute>(fl);
30}
31template<class T> void set_flow(T& a, Flow fl) {
32 if (fl) a->add_attribute(HepMCStr::flow, std::make_shared<HepMC3::VectorIntAttribute>(*fl));
33}
34}
35#endif
static Double_t a
int flow(const T &p, int i)
Definition Flow.h:15
void set_flow(T &a, Flow fl)
Definition Flow.h:31
std::shared_ptr< HepMC3::VectorIntAttribute > Flow
Definition Flow.h:13