]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TEvtGen/EvtGenExternal/EvtExternalGenFactory.cpp
Print also cluster pattern in readClusters
[u/mrichter/AliRoot.git] / TEvtGen / EvtGenExternal / EvtExternalGenFactory.cpp
1 //--------------------------------------------------------------------------
2 //
3 // Environment:
4 //      This software is part of the EvtGen package. If you use all or part
5 //      of it, please give an appropriate acknowledgement.
6 //
7 // Copyright Information: See EvtGen/COPYRIGHT
8 //      Copyright (C) 2011      University of Warwick, UK
9 //
10 // Module: EvtExternalGenFactory
11 //
12 // Description: A factory type method to create engines for external physics
13 // generators like Pythia.
14 //
15 // Modification history:
16 //
17 //    John Back       April 2011            Module created
18 //
19 //------------------------------------------------------------------------------
20 //
21
22 #include "EvtGenBase/EvtPatches.hh"
23 #include "EvtGenBase/EvtReport.hh"
24 #include "EvtGenExternal/EvtExternalGenFactory.hh"
25
26 #ifdef EVTGEN_PYTHIA
27 #include "EvtGenExternal/EvtPythiaEngine.hh"
28 #endif
29
30 #ifdef EVTGEN_PHOTOS
31 #include "EvtGenExternal/EvtPhotosEngine.hh"
32 #endif
33
34 #ifdef EVTGEN_TAUOLA
35 #include "EvtGenExternal/EvtTauolaEngine.hh"
36 #endif
37
38 #include <iostream>
39 using std::endl;
40
41 EvtExternalGenFactory::EvtExternalGenFactory() {
42
43   _extGenMap.clear();
44
45 }
46
47 EvtExternalGenFactory::~EvtExternalGenFactory() {
48
49   ExtGenMap::iterator iter;
50   for (iter = _extGenMap.begin(); iter != _extGenMap.end(); ++iter) {
51
52     EvtAbsExternalGen* theGenerator = iter->second;
53     delete theGenerator;
54
55   }
56   
57   _extGenMap.clear();
58
59 }
60
61 EvtExternalGenFactory* EvtExternalGenFactory::getInstance() {
62
63   static EvtExternalGenFactory* theFactory = 0;
64   
65   if (theFactory == 0) {
66     theFactory = new EvtExternalGenFactory();
67   }
68
69   return theFactory;
70
71 }
72
73 void EvtExternalGenFactory::definePythiaGenerator(std::string xmlDir, 
74                                                   bool convertPhysCodes,
75                                                   bool useEvtGenRandom) {
76
77   // Only define the generator if we have the external ifdef variable set
78 #ifdef EVTGEN_PYTHIA
79
80   int genId = EvtExternalGenFactory::PythiaGenId;
81
82   report(INFO,"EvtGen")<<"Defining EvtPythiaEngine: data tables defined in "
83                        <<xmlDir<<endl;
84
85   if (convertPhysCodes == true) {
86     report(INFO,"EvtGen")<<"Pythia 6 codes in decay files will be converted to Pythia 8 codes"<<endl;
87   } else {
88     report(INFO,"EvtGen")<<"Pythia 8 codes need to be used in decay files"<<endl;
89   }
90
91   if (useEvtGenRandom == true) {
92     report(INFO,"EvtGen")<<"Using EvtGen random engine for Pythia 8 as well"<<endl;
93   }
94
95   EvtAbsExternalGen* pythiaGenerator = new EvtPythiaEngine(xmlDir, convertPhysCodes, useEvtGenRandom);
96   _extGenMap[genId] = pythiaGenerator;
97
98 #endif
99
100 }
101
102 void EvtExternalGenFactory::definePhotosGenerator(std::string photonType, bool useEvtGenRandom) {
103
104 #ifdef EVTGEN_PHOTOS
105
106   int genId = EvtExternalGenFactory::PhotosGenId;
107   report(INFO,"EvtGen")<<"Defining EvtPhotosEngine using photonType = "<<photonType<<endl;
108   EvtAbsExternalGen* photosGenerator = new EvtPhotosEngine(photonType, useEvtGenRandom);
109   _extGenMap[genId] = photosGenerator;
110
111 #endif
112
113 }
114
115 void EvtExternalGenFactory::defineTauolaGenerator(bool useEvtGenRandom) {
116
117 #ifdef EVTGEN_TAUOLA
118
119   int genId = EvtExternalGenFactory::TauolaGenId;
120   report(INFO,"EvtGen")<<"Defining EvtTauolaEngine."<<endl;
121   EvtAbsExternalGen* tauolaGenerator = new EvtTauolaEngine(useEvtGenRandom);
122   _extGenMap[genId] = tauolaGenerator;
123
124 #endif
125
126 }
127
128 EvtAbsExternalGen* EvtExternalGenFactory::getGenerator(int genId) {
129
130   EvtAbsExternalGen* theGenerator(0);
131
132   ExtGenMap::iterator iter;
133
134   if ((iter = _extGenMap.find(genId)) != _extGenMap.end()) {
135
136     // Retrieve the external generator engine
137     theGenerator = iter->second;
138
139   }
140
141   return theGenerator;
142
143 }
144
145 void EvtExternalGenFactory::initialiseAllGenerators() {
146
147   ExtGenMap::iterator iter;
148   for (iter = _extGenMap.begin(); iter != _extGenMap.end(); ++iter) {
149
150     EvtAbsExternalGen* theGenerator = iter->second;
151     if (theGenerator != 0) {
152       theGenerator->initialise();
153     }
154
155   }
156   
157 }