evtgen is hosted by Hepforge, IPPP Durham
EvtGen  2.0.0
Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons.
EvtExternalGenFactory.cpp
Go to the documentation of this file.
1 
2 /***********************************************************************
3 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors *
4 * *
5 * This file is part of EvtGen. *
6 * *
7 * EvtGen is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * EvtGen is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with EvtGen. If not, see <https://www.gnu.org/licenses/>. *
19 ***********************************************************************/
20 
22 
23 #include "EvtGenBase/EvtPatches.hh"
24 #include "EvtGenBase/EvtReport.hh"
25 
26 #ifdef EVTGEN_PYTHIA
28 #endif
29 
30 #ifdef EVTGEN_PHOTOS
32 #endif
33 
34 #ifdef EVTGEN_TAUOLA
36 #endif
37 
38 #include <iostream>
39 using std::endl;
40 
42 {
43  _extGenMap.clear();
44 }
45 
47 {
48  ExtGenMap::iterator iter;
49  for ( iter = _extGenMap.begin(); iter != _extGenMap.end(); ++iter ) {
50  EvtAbsExternalGen* theGenerator = iter->second;
51  delete theGenerator;
52  }
53 
54  _extGenMap.clear();
55 }
56 
58 {
59  static EvtExternalGenFactory* theFactory = 0;
60 
61  if ( theFactory == 0 ) {
62  theFactory = new EvtExternalGenFactory();
63  }
64 
65  return theFactory;
66 }
67 
69  bool convertPhysCodes,
70  bool useEvtGenRandom )
71 {
72  // Only define the generator if we have the external ifdef variable set
73 #ifdef EVTGEN_PYTHIA
74 
76 
77  EvtGenReport( EVTGEN_INFO, "EvtGen" )
78  << "Defining EvtPythiaEngine: data tables defined in " << xmlDir << endl;
79  if ( convertPhysCodes == true ) {
80  EvtGenReport( EVTGEN_INFO, "EvtGen" )
81  << "Pythia 6 codes in decay files will be converted to Pythia 8 codes"
82  << endl;
83  } else {
84  EvtGenReport( EVTGEN_INFO, "EvtGen" )
85  << "Pythia 8 codes need to be used in decay files" << endl;
86  }
87 
88  if ( useEvtGenRandom == true ) {
89  EvtGenReport( EVTGEN_INFO, "EvtGen" )
90  << "Using EvtGen random engine for Pythia 8 as well" << endl;
91  }
92 
93  EvtAbsExternalGen* pythiaGenerator =
94  new EvtPythiaEngine( xmlDir, convertPhysCodes, useEvtGenRandom );
95  _extGenMap[genId] = pythiaGenerator;
96 
97 #endif
98 }
99 
100 void EvtExternalGenFactory::definePhotosGenerator( std::string photonType,
101  bool useEvtGenRandom )
102 {
103 #ifdef EVTGEN_PHOTOS
104 
106 
107  EvtGenReport( EVTGEN_INFO, "EvtGen" )
108  << "Defining EvtPhotosEngine using photonType = " << photonType << endl;
109 
110  EvtAbsExternalGen* photosGenerator = new EvtPhotosEngine( photonType,
111  useEvtGenRandom );
112  _extGenMap[genId] = photosGenerator;
113 
114 #endif
115 }
116 
118 {
119 #ifdef EVTGEN_TAUOLA
120 
122 
123  EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "Defining EvtTauolaEngine." << endl;
124 
125  EvtAbsExternalGen* tauolaGenerator = new EvtTauolaEngine( useEvtGenRandom );
126  _extGenMap[genId] = tauolaGenerator;
127 
128 #endif
129 }
130 
132 {
133  EvtAbsExternalGen* theGenerator( 0 );
134 
135  ExtGenMap::iterator iter;
136 
137  if ( ( iter = _extGenMap.find( genId ) ) != _extGenMap.end() ) {
138  // Retrieve the external generator engine
139  theGenerator = iter->second;
140 
141  } else {
142  EvtGenReport( EVTGEN_INFO, "EvtGen" )
143  << "EvtAbsExternalGen::getGenerator: could not find generator for genId = "
144  << genId << endl;
145  }
146 
147  return theGenerator;
148 }
149 
151 {
152  ExtGenMap::iterator iter;
153  for ( iter = _extGenMap.begin(); iter != _extGenMap.end(); ++iter ) {
154  EvtAbsExternalGen* theGenerator = iter->second;
155  if ( theGenerator != 0 ) {
156  theGenerator->initialise();
157  }
158  }
159 }
static EvtExternalGenFactory * getInstance()
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
std::ostream & EvtGenReport(EvtGenSeverity severity, const char *facility=0)
Definition: EvtReport.cpp:33
EvtAbsExternalGen * getGenerator(int genId=0)
void definePythiaGenerator(std::string xmlDir, bool convertPhysCodes, bool useEvtGenRandom=true)
virtual void initialise()=0
void defineTauolaGenerator(bool useEvtGenRandom=true)
void definePhotosGenerator(std::string photonType="gamma", bool useEvtGenRandom=true)