ATLAS Offline Software
UserHooksFactory.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef GENERATOR_PYTHIA8_USER_HOOKS_FACTORY_H
6 #define GENERATOR_PYTHIA8_USER_HOOKS_FACTORY_H
7 
8 #include "Pythia8/Pythia.h"
9 #include "Pythia8/UserHooks.h"
10 
11 #include <string>
12 #include <map>
13 
14 #define PYTHIA8_PTRWRAP(A) A
15 #define PYTHIA8_INITUSERHOOK_WRAP(A) A->initPtr(infoPtr, settingsPtr, particleDataPtr, rndmPtr, beamAPtr, beamBPtr, beamPomAPtr, beamPomBPtr, coupSMPtr, partonSystemsPtr, sigmaTotPtr)
16 #ifdef PYTHIA_VERSION_INTEGER
17  #define PYTHIA8_3SERIES
18  #if PYTHIA_VERSION_INTEGER > 8303
19  #define PYTHIA8_304SERIES
20  #endif
21  typedef std::shared_ptr<Pythia8::UserHooks> UserHooksPtrType;
22  #undef PYTHIA8_PTRWRAP
23  #define PYTHIA8_PTRWRAP(A) std::shared_ptr<Pythia8::UserHooks>(A)
24  #undef PYTHIA8_INITUSERHOOK_WRAP
25  #define PYTHIA8_INITUSERHOOK_WRAP(A) registerSubObject(*A)
26 #else
27  typedef Pythia8::UserHooks* UserHooksPtrType;
28 #endif
29 
31 
32  using Pythia8::UserHooks;
33 
34 
36 
37  public:
38 
39  static UserHooks *create(const std::string &hookName);
40 
41  private:
42 
44 
45  class ICreator{
46  public:
47  virtual UserHooks *create() const = 0;
48  virtual ~ICreator(){};
49  };
50 
51  public:
52 
53  template <class T>
54  class Creator: public ICreator{
55 
56  public:
57 
58  Creator(const std::string &name){
59  m_name = name;
61  }
62 
64  if(s_creators()[m_name] == this){
65  s_creators().erase(m_name);
66  }
67  }
68 
69  UserHooks *create()const{
70  return new T;
71  }
72 
73  private:
74 
75  std::string m_name;
76  };
77 
78  template<typename T>
79  static std::map<std::string, T> &userSettings();
80 
81  static std::map<std::string, double> &userParams();
82  static std::map<std::string, int> &userModes();
83  static std::map<std::string, std::string> &userWords();
84 
85  private:
86 
87  static std::map<std::string, const ICreator*> &s_creators();
88 
89  };
90 
91 
92 }
93 
94 
95 #endif
Pythia8_UserHooks::UserHooksFactory::userParams
static std::map< std::string, double > & userParams()
UserHooksPtrType
Pythia8::UserHooks * UserHooksPtrType
Definition: UserHooksFactory.h:27
Pythia8_UserHooks::UserHooksFactory::userWords
static std::map< std::string, std::string > & userWords()
Pythia8_UserHooks::UserHooksFactory::UserHooksFactory
UserHooksFactory()
Definition: UserHooksFactory.h:43
Pythia8_UserHooks::UserHooksFactory::Creator
Definition: UserHooksFactory.h:54
Pythia8_UserHooks
Some common functions for determining pTs and navigating event records for the PoWHEG + Pythia user h...
Definition: UserHooksFactory.h:30
Pythia8_UserHooks::UserHooksFactory::Creator::create
UserHooks * create() const
Definition: UserHooksFactory.h:69
Pythia8_UserHooks::UserHooksFactory::Creator::m_name
std::string m_name
Definition: UserHooksFactory.h:75
Pythia8_UserHooks::UserHooksFactory::Creator::~Creator
~Creator()
Definition: UserHooksFactory.h:63
Pythia8_UserHooks::UserHooksFactory::Creator::Creator
Creator(const std::string &name)
Definition: UserHooksFactory.h:58
Pythia8_UserHooks::UserHooksFactory::ICreator::~ICreator
virtual ~ICreator()
Definition: UserHooksFactory.h:48
Pythia8_UserHooks::UserHooksFactory::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: UserHooksFactory.cxx:19
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
Pythia8_UserHooks::UserHooksFactory::ICreator::create
virtual UserHooks * create() const =0
Pythia8_UserHooks::UserHooksFactory
Definition: UserHooksFactory.h:35
Pythia8_UserHooks::UserHooksFactory::userSettings
static std::map< std::string, T > & userSettings()
Pythia8_UserHooks::UserHooksFactory::create
static UserHooks * create(const std::string &hookName)
Definition: UserHooksFactory.cxx:10
Pythia8_UserHooks::UserHooksFactory::userModes
static std::map< std::string, int > & userModes()
Pythia8_UserHooks::UserHooksFactory::ICreator
Definition: UserHooksFactory.h:45