File indexing completed on 2024-09-27 07:03:37
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 int bslopeDefinition () const { return _bslopeDefinition.value(); }
0233 double bslopeValue () const { return _bslopeValue.value(); }
0234 int impulseVM () const { return _impulseVM.value(); }
0235 int quantumGlauber () const { return _quantumGlauber.value(); }
0236 starlightConstants::particleTypeEnum prodParticleType () const { return _particleType; }
0237 starlightConstants::decayTypeEnum prodParticleDecayType() const { return _decayType; }
0238 starlightConstants::interactionTypeEnum interactionType () const { return _interactionType; }
0239 double protonEnergy () const { return _protonEnergy.value(); }
0240 double electronEnergy () const { return _electronEnergy.value(); }
0241 double inputBranchingRatio () const { return _inputBranchingRatio; }
0242 double targetRadius () const { return _targetR; }
0243
0244 void setBaseFileName (std::string v ) { _baseFileName = v; }
0245 void setTargetBeamZ (unsigned int v) { _targetBeamZ = v; }
0246 void setTargetBeamA (unsigned int v) { _targetBeamA = v; }
0247 void setTargetLorentzGamma (double v) { _targetLorentzGamma = v; }
0248 void setBeamLorentzGamma (double v) { _beamLorentzGamma = v; }
0249 void setElectronBeamLorentzGamma (double v) { _electronBeamLorentzGamma = v; }
0250 void setRapCM (double v) { _rap_CM = v; }
0251
0252 void setMaxW (double v) { _maxW = v; }
0253 void setMinW (double v) { _minW = v; }
0254 void setmaxW_GP (double v) { _maxW_GP = v; }
0255 void setminW_GP (double v) { _minW_GP = v; }
0256 void setNmbWBins (unsigned int v) { _nmbWBins = v; }
0257 void setMaxRapidity (double v) { _maxRapidity = v; }
0258 void setNmbRapidityBins (unsigned int v) { _nmbRapidityBins = v; }
0259 void setNmbEgaBins (unsigned int v) { _nmbEnergyBins = v; }
0260 void setPtCutEnabled (bool v) { _ptCutEnabled = v; }
0261 void setPtCutMin (double v) { _ptCutMin = v; }
0262 void setPtCutMax (double v) { _ptCutMax = v; }
0263 void setEtaCutEnabled (bool v) { _etaCutEnabled = v; }
0264 void setEtaCutMin (double v) { _etaCutMin = v; }
0265 void setEtaCutMax (double v) { _etaCutMax = v; }
0266 void setProductionMode (int v) { _productionMode = v; }
0267 void setNmbEvents (unsigned int v) { _nmbEventsTot = v; }
0268 void setProdParticleId (int v) { _prodParticleId = v; }
0269 void setRandomSeed (int v) { _randomSeed = v; }
0270 void setBeamBreakupMode (int v) { _beamBreakupMode = v; }
0271 void setInterferenceEnabled (bool v) { _interferenceEnabled = v; }
0272 void setInterferenceStrength (double v) { _interferenceStrength = v; }
0273 void setMaxPtInterference (double v) { _maxPtInterference = v; }
0274 void setNmbPtBinsInterference (int v) { _nmbPtBinsInterference = v; }
0275 void setPtBinWidthInterference(double v) { _ptBinWidthInterference = v; }
0276 void setMinGammaEnergy (double v) { _minGammaEnergy = v; }
0277 void setMaxGammaEnergy (double v) { _maxGammaEnergy = v; }
0278 void setMinGammaQ2 (double v) { _minGammaQ2 = v; }
0279 void setMaxGammaQ2 (double v) { _maxGammaQ2 = v; }
0280 void setPythiaParams (std::string v) { _pythiaParams = v; }
0281 void setOutputFormat (int v) { _outputFormat = v; }
0282 void setBackwardsProduction (bool v) { _backwardsProduction = v; }
0283 void setXsecCalcMethod (int v) { _xsecCalcMethod = v; }
0284 void setAxionMass (double v) { _axionMass = v; }
0285 void setbslopeDefinition (int v) { _bslopeDefinition = v; }
0286 void setbslopeValue (double v) { _bslopeValue = v; }
0287 void setimpulseVM (int v) { _impulseVM = v; }
0288 void setquantumGlauber (int v) { _quantumGlauber = v; }
0289
0290 void setProdParticleType (starlightConstants::particleTypeEnum v) { _particleType = v; }
0291 void setProdParticleDecayType (starlightConstants::decayTypeEnum v) { _decayType = v; }
0292 void setInteractionType (starlightConstants::interactionTypeEnum v) { _interactionType = v; }
0293
0294 void setProtonEnergy (double v) { _protonEnergy = v; }
0295 void setElectronEnergy (double v) { _electronEnergy = v; }
0296 template<typename T>
0297 inline bool setParameter(std::string expression);
0298
0299 std::ostream& print(std::ostream& out) const;
0300 std::ostream& write(std::ostream& out) const;
0301
0302 std::string parameterValueKey() const;
0303
0304
0305 private:
0306
0307
0308
0309 #define VALIDITY_CHECK true
0310 #define NO_VALIDITY_CHECK false
0311
0312 std::string _configFileName;
0313
0314
0315 parameter<std::string,NO_VALIDITY_CHECK> _baseFileName;
0316 parameter<int,VALIDITY_CHECK> _targetBeamZ;
0317 parameter<unsigned int,VALIDITY_CHECK> _targetBeamA;
0318 parameter<double, VALIDITY_CHECK> _electronBeamLorentzGamma;
0319 parameter<double, VALIDITY_CHECK> _targetBeamLorentzGamma;
0320 parameter<double, VALIDITY_CHECK> _maxW;
0321 parameter<double, VALIDITY_CHECK> _minW;
0322 parameter<double, VALIDITY_CHECK> _maxW_GP;
0323 parameter<double, VALIDITY_CHECK> _minW_GP;
0324 parameter<unsigned int, VALIDITY_CHECK> _nmbWBins;
0325 parameter<double, VALIDITY_CHECK> _maxRapidity;
0326 parameter<unsigned int, VALIDITY_CHECK> _nmbRapidityBins;
0327 parameter<unsigned int, VALIDITY_CHECK> _nmbEnergyBins;
0328 parameter<bool, VALIDITY_CHECK> _ptCutEnabled;
0329 parameter<double, VALIDITY_CHECK> _ptCutMin;
0330 parameter<double, VALIDITY_CHECK> _ptCutMax;
0331 parameter<bool, VALIDITY_CHECK> _etaCutEnabled;
0332 parameter<double, VALIDITY_CHECK> _etaCutMin;
0333 parameter<double, VALIDITY_CHECK> _etaCutMax;
0334 parameter<unsigned int, VALIDITY_CHECK> _productionMode;
0335
0336
0337
0338
0339 parameter<unsigned int, VALIDITY_CHECK> _nmbEventsTot;
0340 parameter<unsigned int, VALIDITY_CHECK> _prodParticleId;
0341 parameter<unsigned int, VALIDITY_CHECK> _randomSeed;
0342
0343
0344
0345
0346 parameter<unsigned int, VALIDITY_CHECK> _beamBreakupMode;
0347
0348
0349
0350
0351
0352
0353 parameter<bool, VALIDITY_CHECK> _interferenceEnabled;
0354 parameter<double, VALIDITY_CHECK> _interferenceStrength;
0355 parameter<double, VALIDITY_CHECK> _maxPtInterference;
0356 parameter<unsigned int, VALIDITY_CHECK> _nmbPtBinsInterference;
0357 parameter<double, VALIDITY_CHECK> _ptBinWidthInterference;
0358 parameter<double, VALIDITY_CHECK> _protonEnergy;
0359 parameter<double, VALIDITY_CHECK> _electronEnergy;
0360 parameter<double, VALIDITY_CHECK> _minGammaEnergy;
0361 parameter<double, VALIDITY_CHECK> _maxGammaEnergy;
0362 parameter<double, VALIDITY_CHECK> _minGammaQ2;
0363 parameter<double, VALIDITY_CHECK> _maxGammaQ2;
0364 parameter<unsigned int, VALIDITY_CHECK> _nmbGammaQ2Bins;
0365 parameter<std::string,NO_VALIDITY_CHECK> _pythiaParams;
0366
0367
0368
0369 parameter<int, NO_VALIDITY_CHECK> _outputFormat;
0370 parameter<bool, NO_VALIDITY_CHECK> _backwardsProduction;
0371 parameter<unsigned int, VALIDITY_CHECK> _xsecCalcMethod;
0372 parameter<double, VALIDITY_CHECK> _axionMass;
0373 parameter<unsigned int, VALIDITY_CHECK> _bslopeDefinition;
0374 parameter<double, VALIDITY_CHECK> _bslopeValue;
0375 parameter<unsigned int, VALIDITY_CHECK> _impulseVM;
0376 parameter<unsigned int, VALIDITY_CHECK> _quantumGlauber;
0377
0378 starlightConstants::particleTypeEnum _particleType;
0379 starlightConstants::decayTypeEnum _decayType;
0380 starlightConstants::interactionTypeEnum _interactionType;
0381
0382 double _targetLorentzGamma;
0383 double _beamLorentzGamma;
0384 double _rap_CM;
0385 double _targetR;
0386 double _cmsMaxPhotonEnergy;
0387 double _cmsMinPhotonEnergy;
0388 double _targetMaxPhotonEnergy;
0389 double _targetMinPhotonEnergy;
0390 double _inputBranchingRatio;
0391 bool _fixedQ2Range;
0392 inputParser _ip;
0393
0394 };
0395
0396
0397 template<typename T>
0398 inline
0399 bool inputParameters::setParameter(std::string expression)
0400 {
0401
0402 return _ip.parseString(expression);
0403
0404
0405 }
0406
0407 inline
0408 std::ostream&
0409 operator <<(std::ostream& out,
0410 const inputParameters& par)
0411 {
0412 return par.print(out);
0413 }
0414
0415
0416 #endif