ATLAS Offline Software
Loading...
Searching...
No Matches
UserHooksFactory.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_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){
60 UserHooksFactory::s_creators()[name] = this;
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 * UserHooksPtrType
virtual UserHooks * create() const =0
static std::map< std::string, std::string > & userWords()
static std::map< std::string, T > & userSettings()
static UserHooks * create(const std::string &hookName)
static std::map< std::string, double > & userParams()
static std::map< std::string, int > & userModes()
static std::map< std::string, const ICreator * > & s_creators()
static function to instantiate map of string name Vs. creator object on first use
Some common functions for determining pTs and navigating event records for the PoWHEG + Pythia user h...