ATLAS Offline Software
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"
11 namespace HepMC {
12 typedef std::shared_ptr<HepMC3::VectorIntAttribute> Flow;
13 inline 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 }
18 inline 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 }
23 inline 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 }
33 inline 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 }
43 template<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"
50 namespace HepMC {
51 template <class T> int flow(const T& a,int i) {return a->flow(i);}
52 template <class T> Flow flow(const T& a) {return a->flow();}
53 }
54 #endif
55 #endif
Flow.h
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
HepMC::GenParticlePtr
GenParticle * GenParticlePtr
Definition: GenParticle.h:37
HepMC::flow
int flow(const T &a, int i)
Definition: Flow.h:51
lumiFormat.i
int i
Definition: lumiFormat.py:92
HepMC::ConstGenParticlePtr
const GenParticle * ConstGenParticlePtr
Definition: GenParticle.h:38
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
a
TList * a
Definition: liststreamerinfos.cxx:10
HepMC
Definition: Barcode.h:14