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