ATLAS Offline Software
UserResonanceFactory.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef GENERATOR_PYTHIA8_USER_RESONANCE_FACTORY_H
6 #define GENERATOR_PYTHIA8_USER_RESONANCE_FACTORY_H
7 
8 #include "Pythia8/ResonanceWidths.h"
9 #include "Pythia8/Pythia.h"
10 
11 #include <string>
12 #include <memory>
13 
15 
16  using Pythia8::ResonanceWidths;
17 
19 
20  public:
21 
27  static std::shared_ptr<ResonanceWidths> create(const std::string &name, int pdgid);
28 
29  private:
30 
32 
33  class ICreator{
34  public:
35  virtual std::shared_ptr<ResonanceWidths> create(int idResIn)const = 0;
36  virtual ~ICreator(){};
37  };
38 
39  public:
40 
41  template <class T>
42  class Creator: public ICreator{
43 
44  public:
45  Creator(const std::string &name) :
46  m_name(name){
48  }
49 
51  if(s_creators()[m_name] == this){
52  s_creators().erase(m_name);
53  }
54  }
55 
56  std::shared_ptr<ResonanceWidths> create(int idResIn)const{
57  return std::make_shared<T>(idResIn);
58  }
59 
60  private:
61 
62  std::string m_name;
63  };
64 
65  private:
66 
67  static std::map<std::string, const ICreator*> &s_creators();
68 
69  };
70 }
71 
72 #endif
Pythia8_UserResonance::UserResonanceFactory
Definition: UserResonanceFactory.h:18
Pythia8_UserResonance::UserResonanceFactory::create
static std::shared_ptr< ResonanceWidths > create(const std::string &name, int pdgid)
Call this with the name of the ResonanceWidth and PDG ID to which it will be applied e....
Definition: UserResonanceFactory.cxx:13
Pythia8_UserResonance::UserResonanceFactory::UserResonanceFactory
UserResonanceFactory()
Definition: UserResonanceFactory.h:31
Pythia8_UserResonance::UserResonanceFactory::Creator::~Creator
~Creator()
Definition: UserResonanceFactory.h:50
Pythia8_UserResonance::UserResonanceFactory::ICreator::create
virtual std::shared_ptr< ResonanceWidths > create(int idResIn) const =0
Pythia8_UserResonance
Definition: UserResonanceFactory.h:14
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
Pythia8_UserResonance::UserResonanceFactory::ICreator::~ICreator
virtual ~ICreator()
Definition: UserResonanceFactory.h:36
Pythia8_UserResonance::UserResonanceFactory::Creator
Definition: UserResonanceFactory.h:42
Pythia8_UserResonance::UserResonanceFactory::s_creators
static std::map< std::string, const ICreator * > & s_creators()
static function to instantiate map of string name Vs. creator object on first use
Definition: UserResonanceFactory.cxx:24
Pythia8_UserResonance::UserResonanceFactory::Creator::create
std::shared_ptr< ResonanceWidths > create(int idResIn) const
Definition: UserResonanceFactory.h:56
Pythia8_UserResonance::UserResonanceFactory::ICreator
Definition: UserResonanceFactory.h:33
Pythia8_UserResonance::UserResonanceFactory::Creator::Creator
Creator(const std::string &name)
Definition: UserResonanceFactory.h:45
Pythia8_UserResonance::UserResonanceFactory::Creator::m_name
std::string m_name
Definition: UserResonanceFactory.h:62