ATLAS Offline Software
Loading...
Searching...
No Matches
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
std::shared_ptr< ResonanceWidths > create(int idResIn) const
virtual std::shared_ptr< ResonanceWidths > create(int idResIn) const =0
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....
static std::map< std::string, const ICreator * > & s_creators()
static function to instantiate map of string name Vs. creator object on first use