ATLAS Offline Software
Loading...
Searching...
No Matches
Flow.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 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 "HepMC3/Attribute.h"
9#include "HepMC3/GenParticle.h"
11namespace HepMC {
12typedef std::shared_ptr<HepMC3::VectorIntAttribute> Flow;
13inline int flow(const HepMC3::GenParticlePtr& p, int i) {
14 std::shared_ptr<HepMC3::IntAttribute> f = p->attribute<HepMC3::IntAttribute>("flow" + std::to_string(i)); if (f) return f->value();
15 std::shared_ptr<HepMC3::VectorIntAttribute> vf = p->attribute<HepMC3::VectorIntAttribute>(HepMCStr::flow); if (vf) if (0 < i && i < (int)(vf->value().size())) return vf->value().at(i);
16 return 0;
17}
18inline int flow(const HepMC3::ConstGenParticlePtr& p, int i) {
19 std::shared_ptr<HepMC3::IntAttribute> f = p->attribute<HepMC3::IntAttribute>("flow" + std::to_string(i)); if (f) return f->value();
20 std::shared_ptr<HepMC3::VectorIntAttribute> vf = p->attribute<HepMC3::VectorIntAttribute>(HepMCStr::flow); if (vf) if (0 < i && i < (int)(vf->value().size())) return vf->value().at(i);
21 return 0;
22}
23inline Flow flow(const HepMC3::GenParticlePtr& p) {
24 std::shared_ptr<HepMC3::VectorIntAttribute> vf = p->attribute<HepMC3::VectorIntAttribute>(HepMCStr::flow);
25 if (vf) return vf;
26
27 std::vector<int> fl;
28 for (int i = 1; i <= 10; i++) {
29 std::shared_ptr<HepMC3::IntAttribute> f = p->attribute<HepMC3::IntAttribute>("flow" + std::to_string(i)); if (f) fl.push_back(i); else break;
30 }
31 return std::make_shared<HepMC3::VectorIntAttribute>(fl);
32}
33inline Flow flow(const HepMC3::ConstGenParticlePtr& p) {
34 std::shared_ptr<HepMC3::VectorIntAttribute> vf = p->attribute<HepMC3::VectorIntAttribute>(HepMCStr::flow);
35 if (vf) return vf;
36
37 std::vector<int> fl;
38 for (int i = 1; i <= 10; i++) {
39 std::shared_ptr<HepMC3::IntAttribute> f = p->attribute<HepMC3::IntAttribute>("flow" + std::to_string(i)); if (f) fl.push_back(i); else break;
40 }
41 return std::make_shared<HepMC3::VectorIntAttribute>(fl);
42}
43template<class T> void set_flow(T& a, Flow fl) {
44 if (fl) a->add_attribute(HepMCStr::flow, std::make_shared<HepMC3::VectorIntAttribute>(*fl));
45}
46
47}
48#endif
static Double_t a
const std::string flow
void set_flow(T &a, Flow fl)
Definition Flow.h:43
int flow(const HepMC3::GenParticlePtr &p, int i)
Definition Flow.h:13
std::shared_ptr< HepMC3::VectorIntAttribute > Flow
Definition Flow.h:12