EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gammaeluminosity.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file gammaeluminosity.cpp
1 
2 //
3 // Copyright 2010
4 //
5 // This file is part of starlight.
6 //
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.
11 //
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.
16 //
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/>.
19 //
21 //
22 // File and Version Information:
23 // $Rev:: 264 $: revision of last commit
24 // $Author:: jseger $: author of last commit
25 // $Date:: 2016-06-06 21:05:12 +0100 #$: date of last commit
26 //
27 // Description:
28 //
29 //
30 //
32 
33 
34 #include <iostream>
35 #include <fstream>
36 #include <cmath>
37 
38 #include "inputParameters.h"
39 #include "beambeamsystem.h"
40 #include "beam.h"
41 #include "starlightconstants.h"
42 #include "nucleus.h"
43 #include "bessel.h"
44 #include "gammaeluminosity.h"
45 
46 
47 using namespace std;
48 using namespace starlightConstants;
49 
50 
51 //______________________________________________________________________________
53  : photonNucleusCrossSection(inputParametersInstance, bbsystem)
54  ,_protonEnergy(inputParametersInstance.protonEnergy())
55  ,_electronEnergy(inputParametersInstance.electronEnergy())
56  ,_beamLorentzGamma(inputParametersInstance.beamLorentzGamma())
57  ,_baseFileName(inputParametersInstance.baseFileName())
58  ,_maxW(inputParametersInstance.maxW())
59  ,_minW(inputParametersInstance.minW())
60  ,_nmbWBins(inputParametersInstance.nmbWBins())
61  ,_maxRapidity(inputParametersInstance.maxRapidity())
62  ,_nmbRapidityBins(inputParametersInstance.nmbRapidityBins())
63  ,_nEBins(inputParametersInstance.nmbEnergyBins())
64  ,_minGammaQ2(inputParametersInstance.minGammaQ2())
65  ,_maxGammaQ2(inputParametersInstance.maxGammaQ2())
66  ,_nmbGammaQ2Bins(inputParametersInstance.nmbGammaQ2Bins())
67  ,_cmsMaxPhotonEnergy(inputParametersInstance.cmsMaxPhotonEnergy())
68  ,_cmsMinPhotonEnergy(inputParametersInstance.cmsMinPhotonEnergy())
69  ,_targetMaxPhotonEnergy(inputParametersInstance.targetMaxPhotonEnergy())
70  ,_targetMinPhotonEnergy(inputParametersInstance.targetMinPhotonEnergy())
71  ,_productionMode(inputParametersInstance.productionMode())
72  ,_beamBreakupMode(inputParametersInstance.beamBreakupMode())
73 {
74  cout <<"Creating Luminosity Tables."<<endl;
76  cout <<"Luminosity Tables created."<<endl;
77 }
78 
79 
80 //______________________________________________________________________________
82 { }
83 
84 
85 //______________________________________________________________________________
87 {
88  double W,dW, dY;
89  double Egamma,Y;
90  //
91  double testint;
92  //
93  double g_E;
94  double csgA;
95  double C;
96  int beam;
97  //
98  //int nQ2steps =100;
99 
100  std::string wyFileName;
101  wyFileName = _baseFileName +".txt";
102 
103  ofstream wylumfile;
104  wylumfile.precision(15);
105 
106  std::string EQ2FileName;
107  EQ2FileName = "e_"+_baseFileName +".txt";
108 
109  ofstream EQ2lumfile;
110  EQ2lumfile.precision(15);
111 
112  double bwnorm;
113 
114  dW = (_wMax-_wMin)/_nWbins;
115  dY = (_yMax-(-1.0)*_yMax)/_nYbins;
116 
117  // Look-up table storing double and single photon flux differentials
118  EQ2lumfile.open(EQ2FileName.c_str());
119  EQ2lumfile << _nmbGammaQ2Bins <<endl;
120  // Look-up table storing photo-nuclear cross section
121  // Write the values of W used in the calculation to slight.txt.
122  wylumfile.open(wyFileName.c_str());
123  wylumfile << getbbs().electronBeam().Z() <<endl;
124  wylumfile << getbbs().electronBeam().A() <<endl;
125  wylumfile << getbbs().targetBeam().Z() <<endl;
126  wylumfile << getbbs().targetBeam().A() <<endl;
127  wylumfile << _beamLorentzGamma <<endl;
128  wylumfile << _maxW <<endl;
129  wylumfile << _minW <<endl;
130  wylumfile << _nmbWBins <<endl;
131  wylumfile << _maxRapidity <<endl;
132  wylumfile << _nmbRapidityBins <<endl;
133  wylumfile << _productionMode <<endl;
134  wylumfile << _beamBreakupMode <<endl;
135  wylumfile << starlightConstants::deuteronSlopePar <<endl;
136 
137  // Normalize the Breit-Wigner Distribution and write values of W to slight.txt
138  testint=0.0;
139  // Grabbing default value for C in the breit-wigner calculation
140  C=getDefaultC();
141  for(unsigned int i = 0; i <= _nWbins - 1; ++i) {
142  W = _wMin + double(i)*dW + 0.5*dW;
143  testint = testint + breitWigner(W,C)*dW;
144  wylumfile << W << endl;
145  }
146  bwnorm = 1./testint;
147 
148  // Write the values of Y used in the calculation to slight.txt.
149  for(unsigned int i = 0; i <= _nYbins - 1; ++i) {
150  Y = -1.0*_yMax + double(i)*dY + 0.5*dY;
151  wylumfile << Y << endl;
152  }
153 
154  int A_1 = getbbs().electronBeam().A();
155  int A_2 = getbbs().targetBeam().A();
156  if( A_2 == 0 && A_1 != 0 ){
157  beam = 1;
158  } else if( A_1 ==0 && A_2 != 0){
159  beam = 2;
160  } else{
161  beam = 2;
162  }
163  // Exponential steps for both tables: Target frame for photon generation and CMS frame for final state generation
164  double dE_target = std::log(_targetMaxPhotonEnergy/_targetMinPhotonEnergy)/_nEBins;
165  // - - - - Calculations in Target frame
166  for(unsigned int i = 0; i < _nWbins; ++i) {
167 
168  W = _wMin + double(i)*dW + 0.5*dW;
169  wylumfile << breitWigner(W,bwnorm) <<endl;
170  }
171  for(int j = 0; j < _nEBins ; ++j) {
172  // Used for calculation of g(Egamma) which must be done in the ion (target) rest frame
173  Egamma = std::exp( std::log(_targetMinPhotonEnergy)+j*dE_target);
174  g_E = 0;
175  // Photon energy limits are determnined in target frame - multiply by Egamma to speed up event generation
176  std::pair< double, double >* this_energy = Q2arraylimits(Egamma);
177  double Q2min = this_energy->first;
178  double Q2max = this_energy->second;
179  if( Q2min > Q2max)
180  continue;
181  //Accounts for the phase space factor
182  g_E = Egamma*integrated_Q2_dep(Egamma, Q2min, Q2max);
183  EQ2lumfile << g_E<<endl;
184  // Write out Q2 range used for generation
185  EQ2lumfile << Q2min << endl;
186  EQ2lumfile << Q2max << endl;
187  for( unsigned int iQ2 =0 ;iQ2<_nmbGammaQ2Bins; ++iQ2){
188  double Q2 = std::exp( std::log(Q2min)+iQ2*std::log(Q2max/Q2min)/_nmbGammaQ2Bins );
189  EQ2lumfile<< g(Egamma,Q2) <<endl;
190  csgA=getcsgA(Egamma,Q2,beam);
191  wylumfile << csgA << endl;
192  }
193  }
194 
195  EQ2lumfile.close();
196 
197  wylumfile << bwnorm << endl;
198  wylumfile.close();
199 
200 }
202 {
203  ostringstream tag1, tag2;
204  tag1<<ii;
205  tag2<<jj;
206  string to_ret = tag1.str()+","+tag2.str();
207  return to_ret;
208 }
209