]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STARLIGHT/starlight/include/inputParameters.h~
nbins added as data member + axes renamed
[u/mrichter/AliRoot.git] / STARLIGHT / starlight / include / inputParameters.h~
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:: 163 $: revision of last commit
24// $Author:: odjuvsla $: author of last commit
25// $Date:: 2013-10-06 16:18:06 +0200 #$: date of last commit
26//
27// Description:
28//
29//
30//
31///////////////////////////////////////////////////////////////////////////
32
33
34#ifndef INPUTPARAMETERS_H
35#define INPUTPARAMETERS_H
36
37
38#include "starlightconstants.h"
39#include "inputParser.h"
40#include "singleton.h"
41#include <string>
42#include <ostream>
43#include <vector>
44#include <sstream>
45
46class parameterbase;
47
48
49class parameterlist
50{
51public:
52
53 parameterlist() : _parameters(0) {}
54
55 void add(parameterbase* p) {
56 _parameters.push_back(p);
57 }
58
59 // Returns a string with a key of the current state of the parameter list
60 // only
61 inline std::string validationKey();
62
63
64private:
65
66 std::vector<parameterbase*> _parameters;
67
68};
69
70// Base class for parameters, needed to keep a list of parameters
71class parameterbase
72{
73public:
74
75 // Add this to parameter list
76 parameterbase()
77 {
78 _parameters.add(this);
79 }
80 virtual ~parameterbase() {}
81
82 virtual std::string validationkey() = 0;
83
84 template<typename T>
85 std::string toString(T v)
86 {
87 std::stringstream s;
88 s << v;
89 return s.str();
90 }
91 inline friend std::ostream& operator<<(std::ostream& os, const parameterbase& par);
92
93 // List of all parameters
94 static parameterlist _parameters;
95
96
97
98};
99// Need to init the static variable
100// parameterlist parameterbase::_parameters;
101
102
103// The actual parameter class
104// validate parameter specifies if the parameter should be a part of the validity check of the current parameters
105template<typename T, bool validate>
106class parameter : public parameterbase
107{
108public:
109
110 // Constructor
111 parameter(const std::string &name, T value, bool required = true) :parameterbase(),_name(name), _value(value), _validate(validate), _required(required) {}
112
113 virtual ~parameter() {}
114// T operator()() const {
115// return _value;
116// }
117
118 parameter &operator=(T v) { _value = v; return *this;}
119 T* ptr() const {
120 return const_cast<T*>(&_value);
121 }
122
123 T value() const { return _value; }
124
125 std::string name() const { return _name;}
126
127 bool required() const { return _required; }
128
129 void setValue(T v) { _value = v; }
130
131 void setName(std::string name) { _name = name; }
132
133 void setRequired(bool r) { _required = r; }
134
135 // Validation key for this parameter
136 std::string validationkey()
137 {
138 return (_validate ? _name + ":" + toString(_value) + "-" : std::string(""));
139 }
140
141 template<typename S, bool v>
142 inline friend std::ostream& operator<<(std::ostream& os, const parameter<S,v>& par);
143
144
145
146private:
147 std::string _name;
148
149 T _value; // Value
150 bool _validate; // true if a change in the parameter invalidates x-sec tables
151 bool _required; // true if this is required option.
152
153 parameter();
154};
155
156template<typename S, bool v>
157std::ostream& operator<<(std::ostream& os, const parameter<S,v>& par)
158{
159 os << par._value;
160 return os;
161}
162
163std::ostream& operator<<(std::ostream& os, const parameterbase& par)
164{
165 os << par._parameters.validationKey();
166 return os;
167}
168std::string parameterlist::validationKey()
169{
170 std::stringstream s;
171 for(unsigned int i = 0; i < _parameters.size(); ++i)
172 {
173 s << _parameters[i]->validationkey(); // Will print names and values of validation parameters
174 }
175 return s.str();
176}
177
178class inputParameters {
179
180private:
181 // inputParameters is now a singleton
182 friend class Singleton<inputParameters>;
183 inputParameters();
184public:
185
186 ~inputParameters();
187
188 bool init();
189 bool configureFromFile(const std::string &configFileName = "./config/slight.in");
190
191 unsigned int beam1Z () const { return _beam1Z.value(); } ///< returns atomic number of beam particle 1
192 unsigned int beam1A () const { return _beam1A.value(); } ///< returns atomic mass number of beam particle 1
193 unsigned int beam2Z () const { return _beam2Z.value(); } ///< returns atomic number of beam particle 2
194 unsigned int beam2A () const { return _beam2A.value(); } ///< returns atomic mass number of beam particle 2
195 double beamLorentzGamma () const { return _beamLorentzGamma; } ///< returns Lorentz gamma factor of both beams in beam CMS frame
196 double beam1LorentzGamma () const { return _beam1LorentzGamma.value(); } ///< returns Lorentz gamma factor of beam 1 in collider frame
197 double beam2LorentzGamma () const { return _beam2LorentzGamma.value(); } ///< returns Lorentz gamma factor of beam 2 in collider frame
198 double maxW () const { return _maxW.value(); } ///< returns maximum mass W of produced hadronic system [GeV/c^2]
199 double minW () const { return _minW.value(); } ///< returns minimum mass W of produced hadronic system [GeV/c^2]
200 unsigned int nmbWBins () const { return _nmbWBins.value(); } ///< returns number of W bins in lookup table
201 double maxRapidity () const { return _maxRapidity.value(); } ///< returns maximum absolute value of rapidity
202 unsigned int nmbRapidityBins () const { return _nmbRapidityBins.value(); } ///< returns number of rapidity bins in lookup table
203 bool ptCutEnabled () const { return _ptCutEnabled.value(); } ///< returns cut in pt
204 double ptCutMin () const { return _ptCutMin.value(); } ///< returns minimum pt
205 double ptCutMax () const { return _ptCutMax.value(); } ///< returns maximum pt
206 bool etaCutEnabled () const { return _etaCutEnabled.value(); } ///< returns cut in eta
207 double etaCutMin () const { return _etaCutMin.value(); } ///< returns minimum eta
208 double etaCutMax () const { return _etaCutMax.value(); } ///< returns maximum eta
209 int productionMode () const { return _productionMode.value(); } ///< returns production mode
210 unsigned int nmbEvents () const { return _nmbEventsTot.value(); } ///< returns total number of events to generate
211 int prodParticleId () const { return _prodParticleId.value(); } ///< returns PDG particle ID of produced particle
212 int randomSeed () const { return _randomSeed.value(); } ///< returns seed for random number generator
213 int outputFormat () const { return _outputFormat.value(); } ///< returns output format
214 int beamBreakupMode () const { return _beamBreakupMode.value(); } ///< returns breakup mode for beam particles
215 bool interferenceEnabled () const { return _interferenceEnabled.value(); } ///< returns whether interference is taken into account
216 double interferenceStrength () const { return _interferenceStrength.value(); } ///< returns percentage of interference
217 bool coherentProduction () const { return _coherentProduction.value(); } ///< returns whether production is coherent or incoherent
218 double incoherentFactor () const { return _incoherentFactor.value(); } ///< returns incoherent contribution in vector meson production
219 double deuteronSlopePar () const { return _deuteronSlopePar.value(); } ///< returns slope parameter for deuteron form factor [(GeV/c)^{-2}]
220 double maxPtInterference () const { return _maxPtInterference.value(); } ///< returns maximum p_T for interference calculation [GeV/c]
221 int nmbPtBinsInterference () const { return _nmbPtBinsInterference.value(); } ///< returns number of p_T bins for interference calculation
222 double ptBinWidthInterference() const { return _ptBinWidthInterference.value(); } ///< returns width of p_T bins for interference calculation [GeV/c]
223 double minGammaEnergy () const { return _minGammaEnergy.value(); } ///< returns minimum gamma energy in case of photo nuclear processes [GeV]
224 double maxGammaEnergy () const { return _maxGammaEnergy.value(); } ///< returns maximum gamma energy in case of photo nuclear processes [GeV]
225 std::string pythiaParams () const { return _pythiaParams.value(); } ///< returns parameters to be passed to pythia
226 bool pythiaFullEventRecord () const { return _pythiaFullEventRecord.value(); } ///< returns if the full pythia event record should be printed
227 int xsecCalcMethod () const { return _xsecCalcMethod.value(); } ///< returns the method used for the x-sec calculation
228 int nThreads () const { return _nThreads.value(); } ///< returns the number of threads in case method 1 is used for the x-sec calc
229 unsigned int nBinsQKniehl () const { return _nBinsQKniehl.value(); } ///< Number of bins in Q used for the transformation to the impact paramter space of the Kniehl function
230 unsigned int nBinsEKniehl () const { return _nBinsEKniehl.value(); } ///< Number of bins in photon energy used for the Kniehl function
231 unsigned int nBinsBKniehl () const { return _nBinsBKniehl.value(); } ///< Number of bins in impact parameter used for the Kniehl function
232 double qMaxKniehl () const { return _qMaxKniehl.value(); } ///< Max value of Q used for the Kniehl funcion
233 double eGammaMinKniehl () const { return _eGammaMinKniehl.value(); } ///< Min value of gamma energy used for the Kniehl funcion
234 double eGammaMaxKniehl () const { return _eGammaMaxKniehl.value(); } ///< Max value of gamma energy used for the Kniehl funcion
235 double bMinKniehl () const { return _bMinKniehl.value(); } ///< Min value of impact parameter used for the Kniehl funcion
236 double bMaxKniehl () const { return _bMaxKniehl.value(); } ///< Max value of impact parameter used for the Kniehl funcion
237
238 starlightConstants::particleTypeEnum prodParticleType () const { return _particleType; } ///< returns type of produced particle
239 starlightConstants::decayTypeEnum prodParticleDecayType() const { return _decayType; } ///< returns decay type of produced particle
240 starlightConstants::interactionTypeEnum interactionType () const { return _interactionType; } ///< returns interaction type
241 // double vmPhotonCoupling();
242 // double slopeParameter();
243 double protonEnergy () const { return _protonEnergy.value(); }
244
245 void setBeam1Z (unsigned int v) { _beam1Z = v; } ///< returns atomic number of beam particle 1
246 void setBeam1A (unsigned int v) { _beam1A = v; } ///< returns atomic mass number of beam particle 1
247 void setBeam2Z (unsigned int v) { _beam2Z = v; } ///< returns atomic number of beam particle 2
248 void setBeam2A (unsigned int v) { _beam2A = v; } ///< returns atomic mass number of beam particle 2
249 void setBeamLorentzGamma (double v) { _beamLorentzGamma = v; } ///< returns Lorentz gamma factor of both beams in beam CMS frame
250 void setBeam1LorentzGamma (double v) { _beam1LorentzGamma = v; } ///< returns Lorentz gamma factor of beam 1 in collider frame
251 void setBeam2LorentzGamma (double v) { _beam2LorentzGamma = v; } ///< returns Lorentz gamma factor of beam 2 in collider frame
252 void setMaxW (double v) { _maxW = v; } ///< returns maximum mass W of produced hadronic system [GeV/c^2]
253 void setMinW (double v) { _minW = v; } ///< returns minimum mass W of produced hadronic system [GeV/c^2]
254 void setNmbWBins (unsigned int v) { _nmbWBins = v; } ///< returns number of W bins in lookup table
255 void setMaxRapidity (double v) { _maxRapidity = v; } ///< returns maximum absolute value of rapidity
256 void setNmbRapidityBins (unsigned int v) { _nmbRapidityBins = v; } ///< returns number of rapidity bins in lookup table
257 void setPtCutEnabled (bool v) { _ptCutEnabled = v; } ///< returns cut in pt
258 void setPtCutMin (double v) { _ptCutMin = v; } ///< returns minimum pt
259 void setPtCutMax (double v) { _ptCutMax = v; } ///< returns maximum pt
260 void setEtaCutEnabled (bool v) { _etaCutEnabled = v; } ///< returns cut in eta
261 void setEtaCutMin (double v) { _etaCutMin = v; } ///< returns minimum eta
262 void setEtaCutMax (double v) { _etaCutMax = v; } ///< returns maximum eta
263 void setProductionMode (int v) { _productionMode = v; } ///< returns production mode
264 void setNmbEvents (unsigned int v) { _nmbEventsTot = v; } ///< returns total number of events to generate
265 void setProdParticleId (int v) { _prodParticleId = v; } ///< returns PDG particle ID of produced particle
266 void setRandomSeed (int v) { _randomSeed = v; } ///< returns seed for random number generator
267 void setOutputFormat (int v) { _outputFormat = v; } ///< returns output format
268 void setBeamBreakupMode (int v) { _beamBreakupMode = v; } ///< returns breakup mode for beam particles
269 void setInterferenceEnabled (bool v) { _interferenceEnabled = v; } ///< returns whether interference is taken into account
270 void setInterferenceStrength (double v) { _interferenceStrength = v; } ///< returns percentage of interference
271 void setCoherentProduction (bool v) { _coherentProduction = v; } ///< returns whether production is coherent or incoherent
272 void setIncoherentFactor (double v) { _incoherentFactor = v; } ///< returns incoherent contribution in vector meson production
273 void setDeuteronSlopePar (double v) { _deuteronSlopePar = v; } ///< returns slope parameter for deuteron form factor [(GeV/c)^{-2}]
274 void setMaxPtInterference (double v) { _maxPtInterference = v; } ///< returns maximum p_T for voiderference calculation [GeV/c]
275 void setNmbPtBinsInterference (int v) { _nmbPtBinsInterference = v; } ///< returns number of p_T bins for interference calculation
276 void setPtBinWidthInterference(double v) { _ptBinWidthInterference = v; } ///< returns width of p_T bins for voiderference calculation [GeV/c]
277 void setMinGammaEnergy (double v) { _minGammaEnergy = v; } ///< returns minimum gamma energy in case of photo nuclear processes [GeV]
278 void setMaxGammaEnergy (double v) { _maxGammaEnergy = v; } ///< returns maximum gamma energy in case of photo nuclear processes [GeV]
279 void setPythiaParams (std::string v) { _pythiaParams = v; } ///< returns parameters to be passed to pythia
280 void setPythiaFullEventRecord (bool v) { _pythiaFullEventRecord = v; } ///< returns if the full pythia event record should be prvoided
281 void setXsecCalcMethod (int v) { _xsecCalcMethod = v; } ///< returns the method used for the x-sec calculation
282 void setNThreads (int v) { _nThreads = v; } ///< returns the number of threads in case method 1 is used for the x-sec calc
283 void setNBinsQKniehl (unsigned int v) { _nBinsQKniehl = v; } ///< Number of bins in Q used for the transformation to the impact paramter space of the Kniehl function
284 void setNBinsEKniehl (unsigned int v) { _nBinsEKniehl = v; } ///< Number of bins in photon energy used for the Kniehl function
285 void setNBinsBKniehl (unsigned int v) { _nBinsBKniehl = v; } ///< Number of bins in impact parameter used for the Kniehl function
286 void setQMaxKniehl (double v) { _qMaxKniehl = v; } ///< Max value of Q used for the Kniehl funcion
287 void setEGammaMinKniehl (double v) { _eGammaMinKniehl = v; } ///< Min value of gamma energy used for the Kniehl funcion
288 void setEGammaMaxKniehl (double v) { _eGammaMaxKniehl = v; } ///< Max value of gamma energy used for the Kniehl funcion
289 void setBMinKniehl (double v) { _bMinKniehl = v; } ///< Min value of impact parameter used for the Kniehl funcion
290 void setBMaxKniehl (double v) { _bMaxKniehl = v; } ///< Max value of impact parameter used for the Kniehl funcion
291
292 void setProdParticleType (starlightConstants::particleTypeEnum v) { _particleType = v; } ///< returns type of produced particle
293 void setProdParticleDecayType (starlightConstants::decayTypeEnum v) { _decayType = v; } ///< returns decay type of produced particle
294 void setInteractionType (starlightConstants::interactionTypeEnum v) { _interactionType = v; } ///< returns interaction type
295
296 // double vmPhotonCoupling();
297 // double slopeParameter();
298 void setProtonEnergy (double v) { _protonEnergy = v; }
299
300// template<typename T>
301 inline bool setParameter(std::string expression);
302
303 std::ostream& print(std::ostream& out) const; ///< prints parameter summary
304 std::ostream& write(std::ostream& out) const; ///< writes parameters back to an ostream
305
306 std::string parameterValueKey() const; ///< Generates key for the current parameters
307
308
309private:
310
311
312// To indicate if the crossection table should be re-calculated if parameter changes
313#define VALIDITY_CHECK true
314#define NO_VALIDITY_CHECK false
315
316 std::string _configFileName; ///< path to configuration file (default = ./config/slight.in)
317
318 // config file parameters
319 parameter<unsigned int,VALIDITY_CHECK> _beam1Z; ///< atomic number of beam particle 1
320 parameter<unsigned int,VALIDITY_CHECK> _beam1A; ///< atomic mass number of beam particle 1
321 parameter<unsigned int,VALIDITY_CHECK> _beam2Z; ///< atomic number of beam particle 2
322 parameter<unsigned int,VALIDITY_CHECK> _beam2A; ///< atomic mass number of beam particle 2
323 parameter<double, VALIDITY_CHECK> _beam1LorentzGamma; ///< Lorentz gamma factor of beam 1 in collider frame
324 parameter<double, VALIDITY_CHECK> _beam2LorentzGamma; ///< Lorentz gamma factor of beam 2 in collider frame
325 parameter<double, VALIDITY_CHECK> _maxW; ///< maximum mass W of produced hadronic system [GeV/c^2]
326 parameter<double, VALIDITY_CHECK> _minW; ///< minimum mass W of produced hadronic system; if set to -1 default value is taken [GeV/c^2]
327 parameter<unsigned int, VALIDITY_CHECK> _nmbWBins; ///< number of W bins in lookup table
328 parameter<double, VALIDITY_CHECK> _maxRapidity; ///< maximum absolute value of rapidity
329 parameter<unsigned int, VALIDITY_CHECK> _nmbRapidityBins; ///< number of rapidity bins in lookup table
330 parameter<bool, VALIDITY_CHECK> _ptCutEnabled; ///< en/disables cut in pt
331 parameter<double, VALIDITY_CHECK> _ptCutMin; ///< minimum pt, if cut is enabled
332 parameter<double, VALIDITY_CHECK> _ptCutMax; ///< maximum pt, if cut is enabled
333 parameter<bool, VALIDITY_CHECK> _etaCutEnabled; ///< en/disables cut in eta
334 parameter<double, VALIDITY_CHECK> _etaCutMin; ///< minimum eta, if cut is enabled
335 parameter<double, VALIDITY_CHECK> _etaCutMax; ///< maximum eta, if cut is enabled
336 parameter<unsigned int, VALIDITY_CHECK> _productionMode; ///< \brief production mode
337 ///<
338 ///< 1 = photon-photon fusion,
339 ///< 2 = narrow vector meson resonance in photon-Pomeron fusion,
340 ///< 3 = Breit-Wigner vector meson resonance in photon-Pomeron fusion
341 parameter<unsigned int, VALIDITY_CHECK> _nmbEventsTot; ///< total number of events to generate
342 parameter<unsigned int, VALIDITY_CHECK> _prodParticleId; ///< PDG particle ID of produced particle
343 parameter<unsigned int, VALIDITY_CHECK> _randomSeed; ///< seed for random number generator
344 parameter<unsigned int, NO_VALIDITY_CHECK> _outputFormat; ///< \brief output format
345 ///<
346 ///< 1 = ASCII
347 ///< 2 = GSTARtext,
348 ///< 3 = PAW ntuple (not working)
349 parameter<unsigned int, VALIDITY_CHECK> _beamBreakupMode; ///< \brief breakup mode for beam particles
350 ///<
351 ///< 1 = hard sphere nuclei (b > 2R),
352 ///< 2 = both nuclei break up (XnXn),
353 ///< 3 = a single neutron from each nucleus (1n1n),
354 ///< 4 = neither nucleon breaks up (with b > 2R),
355 ///< 5 = no hadronic break up (similar to option 1, but with the actual hadronic interaction)
356 parameter<bool, VALIDITY_CHECK> _interferenceEnabled; ///< if VALIDITY_CHECK, interference is taken into account
357 parameter<double, VALIDITY_CHECK> _interferenceStrength; ///< percentage of interference: from 0 = none to 1 = full
358 parameter<bool, VALIDITY_CHECK> _coherentProduction; ///< if VALIDITY_CHECK, production is coherent, else incoherent
359 parameter<double, VALIDITY_CHECK> _incoherentFactor; ///< allows to scale the incoherent contribution in vector meson production
360 parameter<double, VALIDITY_CHECK> _deuteronSlopePar; ///< slope parameter for deuteron form factor [(GeV/c)^{-2}]
361 parameter<double, VALIDITY_CHECK> _maxPtInterference; ///< maximum p_T for interference calculation [GeV/c]
362 parameter<unsigned int, VALIDITY_CHECK> _nmbPtBinsInterference; ///< number of p_T bins for interference calculation
363 parameter<double, VALIDITY_CHECK> _ptBinWidthInterference; ///< width of p_T bins for interference calculation [GeV/c]
364 parameter<double, VALIDITY_CHECK> _protonEnergy;
365 parameter<double, VALIDITY_CHECK> _minGammaEnergy; ///< minimum gamma energy in case of photo nuclear processes [GeV]
366 parameter<double, VALIDITY_CHECK> _maxGammaEnergy; ///< maximum gamma energy in case of photo nuclear processes [GeV]
367 parameter<std::string,NO_VALIDITY_CHECK> _pythiaParams; ///< semi-colon separated parameters to pass to pythia, e.g. "mstj(1)=0;paru(13)=0.1"
368 parameter<bool, NO_VALIDITY_CHECK> _pythiaFullEventRecord; ///< if the full pythia event record should be in the outputu
369 parameter<unsigned int, VALIDITY_CHECK> _xsecCalcMethod; ///< Select x-sec calc method. (0 is standard starlight method, 1 must be used for assym. collisions (e.g. p-A), but is slow)
370 parameter<unsigned int, NO_VALIDITY_CHECK> _nThreads; ///< Number of threads used in the case of using method 1 for calculating the x-sections
371 parameter<unsigned int, VALIDITY_CHECK> _nBinsQKniehl; ///< Number of bins in Q used for the transformation to the impact paramter space of the Kniehl function
372 parameter<unsigned int, VALIDITY_CHECK> _nBinsEKniehl; ///< Number of bins in photon energy used for the Kniehl function
373 parameter<unsigned int, VALIDITY_CHECK> _nBinsBKniehl; ///< Number of bins in impact parameter used for the Kniehl function
374 parameter<double, VALIDITY_CHECK> _qMaxKniehl; ///< Max value of Q used for the Kniehl funcion
375 parameter<double, VALIDITY_CHECK> _eGammaMinKniehl; ///< Min value of gamma energy used for the Kniehl funcion
376 parameter<double, VALIDITY_CHECK> _eGammaMaxKniehl; ///< Max value of gamma energy used for the Kniehl funcion
377 parameter<double, VALIDITY_CHECK> _bMinKniehl; ///< Min value of impact parameter used for the Kniehl funcion
378 parameter<double, VALIDITY_CHECK> _bMaxKniehl; ///< Max value of impact parameter used for the Kniehl funcion
379
380
381 starlightConstants::particleTypeEnum _particleType;
382 starlightConstants::decayTypeEnum _decayType;
383 starlightConstants::interactionTypeEnum _interactionType;
384
385 double _beamLorentzGamma; ///< Lorentz gamma factor of the beams in CMS frame, not an input parameter
386
387 inputParser _ip;
388
389};
390
391#define inputParametersInstance Singleton<inputParameters>::instance()
392
393// template<typename T>
394inline
395bool inputParameters::setParameter(std::string expression)
396{
397
398 return _ip.parseString(expression);
399
400
401}
402
403inline
404std::ostream&
405operator <<(std::ostream& out,
406 const inputParameters& par)
407{
408 return par.print(out);
409}
410
411
412#endif // INPUTPARAMETERS_H