File indexing completed on 2025-07-05 08:15:47
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #ifndef INPUTPARAMETERS_H
0035 #define INPUTPARAMETERS_H
0036
0037
0038 #include "starlightconstants.h"
0039 #include "inputParser.h"
0040 #include <string>
0041 #include <ostream>
0042 #include <vector>
0043 #include <sstream>
0044
0045 class parameterbase;
0046
0047
0048 class parameterlist
0049 {
0050 public:
0051
0052 parameterlist() : _parameters(0) {}
0053
0054 void add(parameterbase* p) {
0055 _parameters.push_back(p);
0056 }
0057
0058
0059
0060 inline std::string validationKey();
0061
0062
0063 private:
0064
0065 std::vector<parameterbase*> _parameters;
0066
0067 };
0068
0069
0070 class parameterbase
0071 {
0072 public:
0073
0074
0075 parameterbase()
0076 {
0077 _parameters.add(this);
0078 }
0079 virtual std::string validationkey() = 0;
0080
0081 template<typename T>
0082 std::string toString(T v)
0083 {
0084 std::stringstream s;
0085 s << v;
0086 return s.str();
0087 }
0088 inline friend std::ostream& operator<<(std::ostream& os, const parameterbase& par);
0089
0090
0091 static parameterlist _parameters;
0092
0093
0094
0095 };
0096
0097
0098
0099
0100
0101
0102 template<typename T, bool validate>
0103 class parameter : public parameterbase
0104 {
0105 public:
0106
0107
0108 parameter(const std::string &name, T value, bool required = true) :parameterbase(),_name(name), _value(value), _validate(validate), _required(required) {}
0109
0110
0111 parameter &operator=(T v) { _value = v; return *this;}
0112 T* ptr() const {
0113 return const_cast<T*>(&_value);
0114 }
0115
0116 T value() const { return _value; }
0117
0118 std::string name() const { return _name;}
0119
0120 bool required() const { return _required; }
0121
0122 void setValue(T v) { _value = v; }
0123
0124 void setName(std::string name) { _name = name; }
0125
0126 void setRequired(bool r) { _required = r; }
0127
0128
0129 std::string validationkey()
0130 {
0131 return (_validate ? _name + ":" + toString(_value) + "-" : std::string(""));
0132 }
0133
0134 template<typename S, bool v>
0135 inline friend std::ostream& operator<<(std::ostream& os, const parameter<S,v>& par);
0136
0137
0138
0139 private:
0140 std::string _name;
0141
0142 T _value;
0143 bool _validate;
0144 bool _required;
0145
0146 parameter();
0147 };
0148
0149 template<typename S, bool v>
0150 inline std::ostream& operator<<(std::ostream& os, const parameter<S,v>& par)
0151 {
0152 os << par._value;
0153 return os;
0154 }
0155
0156 std::ostream& operator<<(std::ostream& os, const parameterbase& par)
0157 {
0158 os << par._parameters.validationKey();
0159 return os;
0160 }
0161 std::string parameterlist::validationKey()
0162 {
0163 std::stringstream s;
0164 for(unsigned int i = 0; i < _parameters.size(); ++i)
0165 {
0166 s << _parameters[i]->validationkey();
0167 }
0168 return s.str();
0169 }
0170
0171 class inputParameters {
0172
0173 public:
0174 inputParameters();
0175 ~inputParameters();
0176
0177 bool init();
0178 bool configureFromFile(const std::string &configFileName = "./config/slight.in");
0179
0180 std::string baseFileName () const { return _baseFileName.value(); }
0181
0182 int targetBeamZ () const { return _targetBeamZ.value(); }
0183 unsigned int targetBeamA () const { return _targetBeamA.value(); }
0184 double targetLorentzGamma () const { return _targetLorentzGamma; }
0185 double beamLorentzGamma () const { return _beamLorentzGamma; }
0186 double electronBeamLorentzGamma () const { return _electronBeamLorentzGamma.value(); }
0187 double targetBeamLorentzGamma () const { return _targetBeamLorentzGamma.value(); }
0188 double rap_CM () const { return _rap_CM; }
0189 double targetMaxPhotonEnergy () const { return _targetMaxPhotonEnergy; }
0190 double cmsMaxPhotonEnergy () const { return _cmsMaxPhotonEnergy; }
0191 double targetMinPhotonEnergy () const { return _targetMinPhotonEnergy; }
0192 double cmsMinPhotonEnergy () const { return _cmsMinPhotonEnergy; }
0193 double maxW () const { return _maxW.value(); }
0194 double minW () const { return _minW.value(); }
0195 double maxW_GP () const { return _maxW_GP.value(); }
0196 double minW_GP () const { return _minW_GP.value(); }
0197 unsigned int nmbWBins () const { return _nmbWBins.value(); }
0198 double maxRapidity () const { return _maxRapidity.value(); }
0199 unsigned int nmbRapidityBins () const { return _nmbRapidityBins.value(); }
0200 unsigned int nmbEnergyBins () const { return _nmbEnergyBins.value(); }
0201 bool ptCutEnabled () const { return _ptCutEnabled.value(); }
0202 double ptCutMin () const { return _ptCutMin.value(); }
0203 double ptCutMax () const { return _ptCutMax.value(); }
0204 bool etaCutEnabled () const { return _etaCutEnabled.value(); }
0205 double etaCutMin () const { return _etaCutMin.value(); }
0206 double etaCutMax () const { return _etaCutMax.value(); }
0207 int productionMode () const { return _productionMode.value(); }
0208 unsigned int nmbEvents () const { return _nmbEventsTot.value(); }
0209 int prodParticleId () const { return _prodParticleId.value(); }
0210 int randomSeed () const { return _randomSeed.value(); }
0211 int beamBreakupMode () const { return _beamBreakupMode.value(); }
0212 bool interferenceEnabled () const { return _interferenceEnabled.value(); }
0213 double interferenceStrength () const { return _interferenceStrength.value(); }
0214 double maxPtInterference () const { return _maxPtInterference.value(); }
0215 int nmbPtBinsInterference () const { return _nmbPtBinsInterference.value(); }
0216 double ptBinWidthInterference() const { return _ptBinWidthInterference.value(); }
0217 double minGammaEnergy () const { return _minGammaEnergy.value(); }
0218 double maxGammaEnergy () const { return _maxGammaEnergy.value(); }
0219 double minGammaQ2 () const { return _minGammaQ2.value(); }
0220 double maxGammaQ2 () const { return _maxGammaQ2.value(); }
0221 bool fixedQ2Range () const { return _fixedQ2Range; }
0222 unsigned int nmbGammaQ2Bins () const { return _nmbGammaQ2Bins.value(); }
0223 std::string pythiaParams () const { return _pythiaParams.value(); }
0224 bool defaultFullEventRecord() const { bool a; _outputFormat.value()==0 ? a=true : a=false; return a;}
0225 bool pythiaFullEventRecord () const { bool a; _outputFormat.value()==1 ? a=true : a=false; return a;}
0226 bool hepmc3FullEventRecord () const { bool a; _outputFormat.value()==2 ? a=true : a=false; return a;}
0227 bool lundFullEventRecord () const { bool a; _outputFormat.value()==3 ? a=true : a=false; return a;}
0228 int outputFormat () const { return _outputFormat.value(); }
0229 bool backwardsProduction () const { return _backwardsProduction.value(); }
0230 int xsecCalcMethod () const { return _xsecCalcMethod.value(); }
0231 double axionMass () const { return _axionMass.value(); }
0232 double rho0PrimeBrFourProng () const { return _rho0PrimeBrFourProng.value(); }
0233 double rho0PrimeCoupling () const { return _rho0PrimeCoupling.value(); }
0234 int bslopeDefinition () const { return _bslopeDefinition.value(); }
0235 double bslopeValue () const { return _bslopeValue.value(); }
0236 int impulseVM () const { return _impulseVM.value(); }
0237 int quantumGlauber () const { return _quantumGlauber.value(); }
0238 starlightConstants::particleTypeEnum prodParticleType () const { return _particleType; }
0239 starlightConstants::decayTypeEnum prodParticleDecayType() const { return _decayType; }
0240 starlightConstants::interactionTypeEnum interactionType () const { return _interactionType; }
0241 double protonEnergy () const { return _protonEnergy.value(); }
0242 double electronEnergy () const { return _electronEnergy.value(); }
0243 double inputBranchingRatio () const { return _inputBranchingRatio; }
0244 double targetRadius () const { return _targetR; }
0245
0246 void setBaseFileName (std::string v ) { _baseFileName = v; }
0247 void setTargetBeamZ (unsigned int v) { _targetBeamZ = v; }
0248 void setTargetBeamA (unsigned int v) { _targetBeamA = v; }
0249 void setTargetLorentzGamma (double v) { _targetLorentzGamma = v; }
0250 void setBeamLorentzGamma (double v) { _beamLorentzGamma = v; }
0251 void setElectronBeamLorentzGamma (double v) { _electronBeamLorentzGamma = v; }
0252 void setRapCM (double v) { _rap_CM = v; }
0253
0254 void setMaxW (double v) { _maxW = v; }
0255 void setMinW (double v) { _minW = v; }
0256 void setmaxW_GP (double v) { _maxW_GP = v; }
0257 void setminW_GP (double v) { _minW_GP = v; }
0258 void setNmbWBins (unsigned int v) { _nmbWBins = v; }
0259 void setMaxRapidity (double v) { _maxRapidity = v; }
0260 void setNmbRapidityBins (unsigned int v) { _nmbRapidityBins = v; }
0261 void setNmbEgaBins (unsigned int v) { _nmbEnergyBins = v; }
0262 void setPtCutEnabled (bool v) { _ptCutEnabled = v; }
0263 void setPtCutMin (double v) { _ptCutMin = v; }
0264 void setPtCutMax (double v) { _ptCutMax = v; }
0265 void setEtaCutEnabled (bool v) { _etaCutEnabled = v; }
0266 void setEtaCutMin (double v) { _etaCutMin = v; }
0267 void setEtaCutMax (double v) { _etaCutMax = v; }
0268 void setProductionMode (int v) { _productionMode = v; }
0269 void setNmbEvents (unsigned int v) { _nmbEventsTot = v; }
0270 void setProdParticleId (int v) { _prodParticleId = v; }
0271 void setRandomSeed (int v) { _randomSeed = v; }
0272 void setBeamBreakupMode (int v) { _beamBreakupMode = v; }
0273 void setInterferenceEnabled (bool v) { _interferenceEnabled = v; }
0274 void setInterferenceStrength (double v) { _interferenceStrength = v; }
0275 void setMaxPtInterference (double v) { _maxPtInterference = v; }
0276 void setNmbPtBinsInterference (int v) { _nmbPtBinsInterference = v; }
0277 void setPtBinWidthInterference(double v) { _ptBinWidthInterference = v; }
0278 void setMinGammaEnergy (double v) { _minGammaEnergy = v; }
0279 void setMaxGammaEnergy (double v) { _maxGammaEnergy = v; }
0280 void setMinGammaQ2 (double v) { _minGammaQ2 = v; }
0281 void setMaxGammaQ2 (double v) { _maxGammaQ2 = v; }
0282 void setPythiaParams (std::string v) { _pythiaParams = v; }
0283 void setOutputFormat (int v) { _outputFormat = v; }
0284 void setBackwardsProduction (bool v) { _backwardsProduction = v; }
0285 void setXsecCalcMethod (int v) { _xsecCalcMethod = v; }
0286 void setAxionMass (double v) { _axionMass = v; }
0287 void setRho0PrimeBrFourProng (double v) { _rho0PrimeBrFourProng = v; }
0288 void setRho0PrimeCoupling (double v) { _rho0PrimeCoupling = v; }
0289 void setbslopeDefinition (int v) { _bslopeDefinition = v; }
0290 void setbslopeValue (double v) { _bslopeValue = v; }
0291 void setimpulseVM (int v) { _impulseVM = v; }
0292 void setquantumGlauber (int v) { _quantumGlauber = v; }
0293
0294 void setProdParticleType (starlightConstants::particleTypeEnum v) { _particleType = v; }
0295 void setProdParticleDecayType (starlightConstants::decayTypeEnum v) { _decayType = v; }
0296 void setInteractionType (starlightConstants::interactionTypeEnum v) { _interactionType = v; }
0297
0298 void setProtonEnergy (double v) { _protonEnergy = v; }
0299 void setElectronEnergy (double v) { _electronEnergy = v; }
0300 template<typename T>
0301 inline bool setParameter(std::string expression);
0302
0303 std::ostream& print(std::ostream& out) const;
0304 std::ostream& write(std::ostream& out) const;
0305
0306 std::string parameterValueKey() const;
0307
0308
0309 private:
0310
0311
0312
0313 #define VALIDITY_CHECK true
0314 #define NO_VALIDITY_CHECK false
0315
0316 std::string _configFileName;
0317
0318
0319 parameter<std::string,NO_VALIDITY_CHECK> _baseFileName;
0320 parameter<int,VALIDITY_CHECK> _targetBeamZ;
0321 parameter<unsigned int,VALIDITY_CHECK> _targetBeamA;
0322 parameter<double, VALIDITY_CHECK> _electronBeamLorentzGamma;
0323 parameter<double, VALIDITY_CHECK> _targetBeamLorentzGamma;
0324 parameter<double, VALIDITY_CHECK> _maxW;
0325 parameter<double, VALIDITY_CHECK> _minW;
0326 parameter<double, VALIDITY_CHECK> _maxW_GP;
0327 parameter<double, VALIDITY_CHECK> _minW_GP;
0328 parameter<unsigned int, VALIDITY_CHECK> _nmbWBins;
0329 parameter<double, VALIDITY_CHECK> _maxRapidity;
0330 parameter<unsigned int, VALIDITY_CHECK> _nmbRapidityBins;
0331 parameter<unsigned int, VALIDITY_CHECK> _nmbEnergyBins;
0332 parameter<bool, VALIDITY_CHECK> _ptCutEnabled;
0333 parameter<double, VALIDITY_CHECK> _ptCutMin;
0334 parameter<double, VALIDITY_CHECK> _ptCutMax;
0335 parameter<bool, VALIDITY_CHECK> _etaCutEnabled;
0336 parameter<double, VALIDITY_CHECK> _etaCutMin;
0337 parameter<double, VALIDITY_CHECK> _etaCutMax;
0338 parameter<unsigned int, VALIDITY_CHECK> _productionMode;
0339
0340
0341
0342
0343 parameter<unsigned int, VALIDITY_CHECK> _nmbEventsTot;
0344 parameter<unsigned int, VALIDITY_CHECK> _prodParticleId;
0345 parameter<unsigned int, VALIDITY_CHECK> _randomSeed;
0346
0347
0348
0349
0350 parameter<unsigned int, VALIDITY_CHECK> _beamBreakupMode;
0351
0352
0353
0354
0355
0356
0357 parameter<bool, VALIDITY_CHECK> _interferenceEnabled;
0358 parameter<double, VALIDITY_CHECK> _interferenceStrength;
0359 parameter<double, VALIDITY_CHECK> _maxPtInterference;
0360 parameter<unsigned int, VALIDITY_CHECK> _nmbPtBinsInterference;
0361 parameter<double, VALIDITY_CHECK> _ptBinWidthInterference;
0362 parameter<double, VALIDITY_CHECK> _protonEnergy;
0363 parameter<double, VALIDITY_CHECK> _electronEnergy;
0364 parameter<double, VALIDITY_CHECK> _minGammaEnergy;
0365 parameter<double, VALIDITY_CHECK> _maxGammaEnergy;
0366 parameter<double, VALIDITY_CHECK> _minGammaQ2;
0367 parameter<double, VALIDITY_CHECK> _maxGammaQ2;
0368 parameter<unsigned int, VALIDITY_CHECK> _nmbGammaQ2Bins;
0369 parameter<std::string,NO_VALIDITY_CHECK> _pythiaParams;
0370
0371
0372
0373 parameter<int, NO_VALIDITY_CHECK> _outputFormat;
0374 parameter<bool, NO_VALIDITY_CHECK> _backwardsProduction;
0375 parameter<unsigned int, VALIDITY_CHECK> _xsecCalcMethod;
0376 parameter<double, VALIDITY_CHECK> _axionMass;
0377 parameter<double, VALIDITY_CHECK> _rho0PrimeBrFourProng;
0378 parameter<double, VALIDITY_CHECK> _rho0PrimeCoupling;
0379 parameter<unsigned int, VALIDITY_CHECK> _bslopeDefinition;
0380 parameter<double, VALIDITY_CHECK> _bslopeValue;
0381 parameter<unsigned int, VALIDITY_CHECK> _impulseVM;
0382 parameter<unsigned int, VALIDITY_CHECK> _quantumGlauber;
0383
0384 starlightConstants::particleTypeEnum _particleType;
0385 starlightConstants::decayTypeEnum _decayType;
0386 starlightConstants::interactionTypeEnum _interactionType;
0387
0388 double _targetLorentzGamma;
0389 double _beamLorentzGamma;
0390 double _rap_CM;
0391 double _targetR;
0392 double _cmsMaxPhotonEnergy;
0393 double _cmsMinPhotonEnergy;
0394 double _targetMaxPhotonEnergy;
0395 double _targetMinPhotonEnergy;
0396 double _inputBranchingRatio;
0397 bool _fixedQ2Range;
0398 inputParser _ip;
0399
0400 };
0401
0402
0403 template<typename T>
0404 inline
0405 bool inputParameters::setParameter(std::string expression)
0406 {
0407
0408 return _ip.parseString(expression);
0409
0410
0411 }
0412
0413 inline
0414 std::ostream&
0415 operator <<(std::ostream& out,
0416 const inputParameters& par)
0417 {
0418 return par.print(out);
0419 }
0420
0421
0422 #endif