1 ///////////////////////////////////////////////////////////////////////////
5 // This file is part of starlight.
7 // starlight 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.
12 // starlight 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.
17 // You should have received a copy of the GNU General Public License
18 // along with starlight. If not, see <http://www.gnu.org/licenses/>.
20 ///////////////////////////////////////////////////////////////////////////
22 // File and Version Information:
23 // $Rev:: 164 $: revision of last commit
24 // $Author:: odjuvsla $: author of last commit
25 // $Date:: 2013-10-06 16:18:08 +0200 #$: date of last commit
31 ///////////////////////////////////////////////////////////////////////////
38 #include "starlightconfig.h"
41 #include "PythiaStarlight.h"
45 #include "starlightdpmjet.h"
49 #include "starlightpythia.h"
52 #include "reportingUtils.h"
53 #include "inputParameters.h"
54 #include "eventchannel.h"
55 #include "gammagammaleptonpair.h"
56 #include "gammagammasingle.h"
58 #include "psifamily.h"
59 #include "twophotonluminosity.h"
60 #include "gammaaluminosity.h"
61 #include "incoherentPhotonNucleusLuminosity.h"
63 #include "eventfilewriter.h"
64 #include "starlight.h"
68 using namespace starlightConstants;
71 starlight::starlight() :
76 _nmbEventsPerFile (100),
77 _nmbEventsToGenerate (10),
78 _configFileName ("slight.in"),
79 _eventDataFileName ("slight.out"),
80 _lumLookUpTableFileName("slight.txt"),
81 _isInitialised (false)
85 starlight::~starlight()
92 if(Starlight_VERSION_MAJOR == 9999)
94 cout << "##################################" << endl
95 << " Initialising Starlight version: trunk..." << endl
96 << "##################################" << endl;
100 cout << "##################################" << endl
101 << " Initialising Starlight version: " << Starlight_VERSION_MAJOR << "."
102 << Starlight_VERSION_MINOR << "." << Starlight_VERSION_MINOR_MINOR << "..." << endl
103 << "##################################" << endl;
106 _nmbEventsPerFile = inputParametersInstance.nmbEvents(); // for now we write only one file...
108 _beamSystem = new beamBeamSystem;
110 // cout << "Created beam system with beam lorentz gamma: " << _beamSystem->beamLorentzGamma() << endl;
112 // streamsize precision(15);
113 cout.setf(ios_base::fixed,ios_base::floatfield);
115 const bool lumTableIsValid = luminosityTableIsValid();
116 bool createChannel = true;
117 switch (inputParametersInstance.interactionType()) {
119 if (!lumTableIsValid) {
120 printInfo << "creating luminosity table for photon-photon channel" << endl;
121 twoPhotonLuminosity(_beamSystem->beam1(), _beamSystem->beam2());
124 case PHOTONPOMERONNARROW: // narrow and wide resonances use
125 case PHOTONPOMERONWIDE: // the same luminosity function
126 if (!lumTableIsValid) {
127 printInfo << "creating luminosity table for coherent photon-Pomeron channel" <<endl;
128 photonNucleusLuminosity lum(*_beamSystem);
131 case PHOTONPOMERONINCOHERENT: // narrow and wide resonances use
132 if (!lumTableIsValid) {
133 printInfo << "creating luminosity table for incoherent photon-Pomeron channel" << endl;
134 incoherentPhotonNucleusLuminosity lum(*_beamSystem);
138 case PHOTONUCLEARSINGLE:
139 createChannel = false;
140 _eventChannel = new starlightDpmJet(*_beamSystem);
141 std::cout << "CREATING PHOTONUCLEAR/DPMJET SINGLE" << std::endl;
142 dynamic_cast<starlightDpmJet*>(_eventChannel)->setSingleMode();
143 dynamic_cast<starlightDpmJet*>(_eventChannel)->setMinGammaEnergy(inputParametersInstance.minGammaEnergy());
144 dynamic_cast<starlightDpmJet*>(_eventChannel)->setMaxGammaEnergy(inputParametersInstance.maxGammaEnergy());
145 dynamic_cast<starlightDpmJet*>(_eventChannel)->init();
147 case PHOTONUCLEARDOUBLE:
148 createChannel = false;
149 _eventChannel = new starlightDpmJet(*_beamSystem);
150 std::cout << "CREATING PHOTONUCLEAR/DPMJET DOUBLE" << std::endl;
151 dynamic_cast<starlightDpmJet*>(_eventChannel)->setDoubleMode();
152 dynamic_cast<starlightDpmJet*>(_eventChannel)->setMinGammaEnergy(inputParametersInstance.minGammaEnergy());
153 dynamic_cast<starlightDpmJet*>(_eventChannel)->setMaxGammaEnergy(inputParametersInstance.maxGammaEnergy());
154 dynamic_cast<starlightDpmJet*>(_eventChannel)->init();
156 case PHOTONUCLEARSINGLEPA:
157 createChannel = false;
158 _eventChannel = new starlightDpmJet(*_beamSystem);
159 std::cout << "CREATING PHOTONUCLEAR/DPMJET SINGLE" << std::endl;
160 dynamic_cast<starlightDpmJet*>(_eventChannel)->setSingleMode();
161 dynamic_cast<starlightDpmJet*>(_eventChannel)->setProtonMode();
162 dynamic_cast<starlightDpmJet*>(_eventChannel)->setMinGammaEnergy(inputParametersInstance.minGammaEnergy());
163 dynamic_cast<starlightDpmJet*>(_eventChannel)->setMaxGammaEnergy(inputParametersInstance.maxGammaEnergy());
164 dynamic_cast<starlightDpmJet*>(_eventChannel)->init();
167 #ifdef ENABLE_PYTHIA6
168 case PHOTONUCLEARSINGLEPAPY:
169 createChannel = false;
170 _eventChannel = new starlightPythia(*_beamSystem);
171 std::cout << "CREATING PHOTONUCLEAR/PYTHIA SINGLE" << std::endl;
172 dynamic_cast<starlightPythia*>(_eventChannel)->setSingleMode();
173 dynamic_cast<starlightPythia*>(_eventChannel)->setMinGammaEnergy(inputParametersInstance.minGammaEnergy());
174 dynamic_cast<starlightPythia*>(_eventChannel)->setMaxGammaEnergy(inputParametersInstance.maxGammaEnergy());
175 dynamic_cast<starlightPythia*>(_eventChannel)->init(inputParametersInstance.pythiaParams(), inputParametersInstance.pythiaFullEventRecord());
180 printWarn << "unknown interaction type '" << inputParametersInstance.interactionType() << "'."
181 << " cannot initialize starlight." << endl;
188 if (!createEventChannel())
192 _isInitialised = true;
198 starlight::produceEvent()
200 if (!_isInitialised) {
201 printErr << "trying to generate event but Starlight is not initialised. aborting." << endl;
204 return _eventChannel->produceEvent();
209 starlight::luminosityTableIsValid() const
211 printInfo << "using random seed = " << inputParametersInstance.randomSeed() << endl;
213 ifstream lumLookUpTableFile(_lumLookUpTableFileName.c_str());
214 lumLookUpTableFile.precision(15);
215 if ((!lumLookUpTableFile) || (!lumLookUpTableFile.good())) {
216 // printWarn << "cannot open file '" << _lumLookUpTableFileName << "'" << endl;
220 unsigned int beam1Z, beam1A, beam2Z, beam2A;
221 double beamLorentzGamma = 0;
222 double maxW = 0, minW = 0;
223 unsigned int nmbWBins;
224 double maxRapidity = 0;
225 unsigned int nmbRapidityBins;
226 int productionMode, beamBreakupMode;
227 bool interferenceEnabled = false;
228 double interferenceStrength = 0;
229 bool coherentProduction = false;
230 double incoherentFactor = 0, deuteronSlopePar = 0, maxPtInterference = 0;
231 int nmbPtBinsInterference;
232 std::string validationKey;
233 if (!(lumLookUpTableFile
238 >> maxW >> minW >> nmbWBins
239 >> maxRapidity >> nmbRapidityBins
242 >> interferenceEnabled >> interferenceStrength
243 >> coherentProduction >> incoherentFactor
246 >> nmbPtBinsInterference))
247 // cannot read parameters from lookup table file
250 std::string validationKeyEnd;
251 while(!lumLookUpTableFile.eof())
253 lumLookUpTableFile >> validationKeyEnd;
255 lumLookUpTableFile.close();
256 return (validationKey == inputParametersInstance.parameterValueKey() && validationKeyEnd == validationKey);
262 starlight::createEventChannel()
264 switch (inputParametersInstance.prodParticleType()) {
269 _eventChannel = new Gammagammaleptonpair(*_beamSystem);
273 printWarn << "cannot construct Gammagammaleptonpair event channel." << endl;
279 case ETAPRIME: // jetset
284 // PythiaOutput = true;
285 cout<<"Pythia is enabled!"<<endl;
288 printWarn << "Starlight is not compiled against Pythia8; "
289 << "jetset event channel cannot be used." << endl;
297 // #ifdef ENABLE_PYTHIA
298 cout<<" This is f2, f2prim, zoverz03 "<<endl;
299 _eventChannel= new Gammagammasingle(*_beamSystem);
303 printWarn << "cannot construct Gammagammasingle event channel." << endl;
307 // printWarn << "Starlight is not compiled against Pythia8; "
308 // << "Gammagammasingle event channel cannot be used." << endl;
332 if (inputParametersInstance.interactionType() == PHOTONPOMERONNARROW) {
333 _eventChannel = new Gammaanarrowvm(*_beamSystem);
337 printWarn << "cannot construct Gammaanarrowvm event channel." << endl;
342 if (inputParametersInstance.interactionType() == PHOTONPOMERONWIDE) {
343 _eventChannel = new Gammaawidevm(*_beamSystem);
347 printWarn << "cannot construct Gammaawidevm event channel." << endl;
352 if (inputParametersInstance.interactionType() == PHOTONPOMERONINCOHERENT) {
353 _eventChannel = new Gammaaincoherentvm(*_beamSystem);
357 printWarn << "cannot construct Gammaanarrowvm event channel." << endl;
362 printWarn << "interaction type '" << inputParametersInstance.interactionType() << "' "
363 << "cannot be used with particle type '" << inputParametersInstance.prodParticleType() << "'. "
364 << "cannot create event channel." << endl;
369 printWarn << "unknown event channel '" << inputParametersInstance.prodParticleType() << "'."
370 << " cannot create event channel." << endl;