]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STARLIGHT/starlight/src/.svn/text-base/readinluminosity.cpp.svn-base
STARLIGHT code and interface
[u/mrichter/AliRoot.git] / STARLIGHT / starlight / src / .svn / text-base / readinluminosity.cpp.svn-base
CommitLineData
da32329d
AM
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//
20///////////////////////////////////////////////////////////////////////////
21//
22// File and Version Information:
23// $Rev:: $: revision of last commit
24// $Author:: $: author of last commit
25// $Date:: $: date of last commit
26//
27// Description:
28// Added 18->19 for reading in the luminosity table
29// Incoherent factor added to table --Joey
30//
31//
32//
33///////////////////////////////////////////////////////////////////////////
34
35
36#include <iostream>
37#include <fstream>
38
39#include "readinluminosity.h"
40#include "starlightconstants.h"
41#include "inputParameters.h"
42
43
44using namespace std;
45
46
47//______________________________________________________________________________
48readLuminosity::readLuminosity()//:inputread(input)
49: _Warray(0), _Yarray(0), _Farray(0)
50{
51 //storing inputparameters into protected variables for the object to use them
52 _ReadInputNPT=inputParametersInstance.nmbPtBinsInterference();
53 _ReadInputnumy=inputParametersInstance.nmbRapidityBins();
54 _ReadInputnumw=inputParametersInstance.nmbWBins();
55 _ReadInputgg_or_gP=inputParametersInstance.productionMode();
56 _ReadInputinterferencemode=inputParametersInstance.interferenceEnabled();
57
58}
59
60
61//______________________________________________________________________________
62readLuminosity::~readLuminosity()
63{
64 if(_Warray) delete [] _Warray;
65 if(_Yarray) delete [] _Yarray;
66 if(_Farray) delete [] _Farray;
67}
68
69
70//______________________________________________________________________________
71void readLuminosity::read()
72{
73
74 if(!_Warray) _Warray = new double[_ReadInputnumw];
75 if(!_Yarray) _Yarray = new double[_ReadInputnumy];
76 if(!_Farray)
77 {
78 _Farray = new double*[_ReadInputnumw];
79 for(int i = 0; i < _ReadInputnumw; i++)
80 {
81 _Farray[i] = new double[_ReadInputnumy];
82 }
83 }
84 double dummy[19]; //14//18
85// double (*finterm)[starlightLimits::MAXWBINS]=new double[starlightLimits::MAXWBINS][starlightLimits::MAXYBINS];
86
87 //decreased from 1000*1000; too big! causes fault!
88 double fpart =0.;
89 double fptsum=0.;
90 ifstream wylumfile;
91
92 _f_max=0.0;
93
94 wylumfile.open("slight.txt");
95 for(int i=0;i < 19;i++){ // was 14; this is to account for sergei's additional parameters ie d-Au//was19
96 wylumfile >> dummy[i];
97 }
98 for(int i=0;i<_ReadInputnumw;i++){
99 wylumfile >> _Warray[i];
100 }
101 for(int i=0;i<_ReadInputnumy;i++){
102 wylumfile >> _Yarray[i];
103 }
104 for(int i=0;i<_ReadInputnumw;i++){
105 for(int j=0;j<_ReadInputnumy;j++){
106 wylumfile >> _Farray[i][j];
107 if( _Farray[i][j] > _f_max ) _f_max=_Farray[i][j];
108 }
109 }
110 //Normalize farray (JN 010402)
111 for(int i=0;i<_ReadInputnumw;i++){
112 for(int j=0;j<_ReadInputnumy;j++){
113 _Farray[i][j]=_Farray[i][j]/_f_max;
114 }
115 }
116
117 if (_ReadInputgg_or_gP != 1 && _ReadInputinterferencemode != 0) {
118 // only numy/2 y bins here, from 0 (not -ymax) to ymax
119 double **finterm = new double*[starlightLimits::MAXWBINS];
120 for (int i = 0; i < starlightLimits::MAXWBINS; i++) finterm[i] = new double[starlightLimits::MAXYBINS];
121 for (int i=0;i<_ReadInputnumy/2;i++) {
122 //fmax=0;
123 //we want to convert _fptarray to an integral array where fpt(i,j) is near 0, and fpt(j,NPT) ~1. This will facilitate a simple table loookup
124 fptsum=0.;
125 for (int j=0;j<_ReadInputNPT;j++) {
126 wylumfile >> fpart;
127 finterm[i][j] = fpart;
128 _fptarray[i][j]=0.;
129 fptsum=fptsum+fpart;
130 }
131 //convert array to integral
132 _fptarray[i][0]=finterm[i][0]/fptsum;
133 for (int j=1;j<_ReadInputNPT;j++) {
134 for (int k=0;k<=j;k++) {
135 _fptarray[i][j]=_fptarray[i][j]+finterm[i][k];
136 }
137 _fptarray[i][j]=_fptarray[i][j]/fptsum;
138 }
139 }
140 delete [] finterm;
141
142 }
143 wylumfile >> _bwnormsave;
144 wylumfile.close();
145 //8delete[] finterm;
146 return;
147}