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#ifdef HEPMC3
9#include "HepMC3/Attribute.h"
10#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>("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>("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>("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>("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("flow",std::make_shared<HepMC3::VectorIntAttribute>(*fl));
45}
46
47}
48#else
49#include "HepMC/Flow.h"
50namespace HepMC {
51template <class T> int flow(const T& a,int i) {return a->flow(i);}
52template <class T> Flow flow(const T& a) {return a->flow();}
53}
54#endif
55#endif
static Double_t a
int flow(const T &a, int i)
Definition Flow.h:51