Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-09-27 07:03:40

0001 /////////////////////////////////////////////////////////////////////////// 
0002 // 
0003 // Copyright 2010 
0004 // 
0005 // This file is part of starlight. 
0006 // 
0007 // starlight is free software: you can redistribute it and/or modify 
0008 // it under the terms of the GNU General Public License as published by 
0009 // the Free Software Foundation, either version 3 of the License, or 
0010 // (at your option) any later version. 
0011 // 
0012 // starlight is distributed in the hope that it will be useful, 
0013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
0014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
0015 // GNU General Public License for more details. 
0016 // 
0017 // You should have received a copy of the GNU General Public License 
0018 // along with starlight. If not, see <http://www.gnu.org/licenses/>. 
0019 // 
0020 /////////////////////////////////////////////////////////////////////////// 
0021 // 
0022 // File and Version Information: 
0023 // $Rev:: 276 $: revision of last commit // $Author:: jnystra#$: author of last commit 
0024 // $Date:: 2016-09-13 19:54:42 +0100 #$: date of last commit // 
0025 // Description: 
0026 // 
0027 // 
0028 // 
0029 ///////////////////////////////////////////////////////////////////////////
0030 
0031 
0032 #include <iostream>
0033 #include <fstream>
0034 
0035 #include "reportingUtils.h"
0036 #include "starlightconstants.h"
0037 #include "inputParameters.h"
0038 #include "inputParser.h"
0039 #include "starlightconfig.h"
0040 #include <cmath>
0041 #include <cstring>
0042 #include "randomgenerator.h"
0043 
0044 using namespace std;
0045 using namespace starlightConstants;
0046 
0047 parameterlist parameterbase::_parameters;
0048 
0049 #define REQUIRED true
0050 #define NOT_REQUIRED false
0051 
0052 //______________________________________________________________________________
0053 inputParameters::inputParameters()
0054         : _baseFileName          ("baseFileName","slight"),
0055       _targetBeamZ                ("TARGET_BEAM_Z",0),
0056       _targetBeamA                ("TARGET_BEAM_A",0),
0057       _electronBeamLorentzGamma     ("ELECTRON_BEAM_GAMMA",0),
0058       _targetBeamLorentzGamma     ("TARGET_BEAM_GAMMA",0),
0059       _maxW                  ("W_MAX",0),
0060       _minW                  ("W_MIN",0),
0061       _maxW_GP               ("W_GP_MAX", 0,NOT_REQUIRED), 
0062       _minW_GP               ("W_GP_MIN", 0,NOT_REQUIRED), 
0063       _nmbWBins              ("W_N_BINS",0),
0064       _maxRapidity           ("RAP_MAX",9,NOT_REQUIRED),
0065       _nmbRapidityBins       ("RAP_N_BINS",100,NOT_REQUIRED),
0066       _nmbEnergyBins         ("EGA_N_BINS",0),
0067       _ptCutEnabled          ("CUT_PT",false, NOT_REQUIRED),
0068       _ptCutMin              ("PT_MIN",0, NOT_REQUIRED),
0069       _ptCutMax              ("PT_MAX",0, NOT_REQUIRED),
0070       _etaCutEnabled         ("CUT_ETA",false, NOT_REQUIRED),
0071       _etaCutMin             ("ETA_MIN",0, NOT_REQUIRED),
0072       _etaCutMax             ("ETA_MAX",0, NOT_REQUIRED),
0073       _productionMode        ("PROD_MODE",0),
0074       _nmbEventsTot          ("N_EVENTS",0),
0075       _prodParticleId        ("PROD_PID",0),
0076       _randomSeed            ("RND_SEED",0),
0077       _beamBreakupMode       ("BREAKUP_MODE",0),
0078       _interferenceEnabled   ("INTERFERENCE",false,NOT_REQUIRED),
0079       _interferenceStrength  ("IF_STRENGTH",0,NOT_REQUIRED),
0080       _maxPtInterference     ("INT_PT_MAX",0,NOT_REQUIRED),
0081       _nmbPtBinsInterference ("INT_PT_N_BINS",0),
0082       _ptBinWidthInterference("INT_PT_WIDTH",0),
0083       _protonEnergy          ("PROTON_ENERGY",0, NOT_REQUIRED),
0084       _electronEnergy        ("ELECTRON_ENERGY",0, NOT_REQUIRED),
0085       _minGammaEnergy    ("MIN_GAMMA_ENERGY",6.0, NOT_REQUIRED),
0086       _maxGammaEnergy    ("MAX_GAMMA_ENERGY",600000.0, NOT_REQUIRED),
0087       _minGammaQ2            ("MIN_GAMMA_Q2",0,NOT_REQUIRED),
0088       _maxGammaQ2            ("MAX_GAMMA_Q2",0,NOT_REQUIRED),
0089       _nmbGammaQ2Bins       ("INT_GAMMA_Q2_BINS",400,NOT_REQUIRED),
0090       _pythiaParams          ("PYTHIA_PARAMS","", NOT_REQUIRED),
0091       _outputFormat           ("OUTPUT_FORMAT",0, NOT_REQUIRED),
0092       _backwardsProduction    ("BACKWARDS_PRODUCTION",false, NOT_REQUIRED),
0093 
0094       _xsecCalcMethod    ("XSEC_METHOD",0, NOT_REQUIRED),
0095           _axionMass             ("AXION_MASS",50, NOT_REQUIRED),  // AXION HACK
0096           _bslopeDefinition      ("BSLOPE_DEFINITION",0, NOT_REQUIRED),
0097       _bslopeValue           ("BSLOPE_VALUE",4.0,NOT_REQUIRED),
0098       _impulseVM             ("SELECT_IMPULSE_VM",0,NOT_REQUIRED),
0099       _quantumGlauber        ("QUANTUM_GLAUBER",0,NOT_REQUIRED)
0100 {
0101   // All parameters must be initialised in initialisation list! 
0102   // If not: error: 'parameter<T, validate>::parameter() [with T = unsigned int, bool validate = true]' is private
0103   // or similar
0104     
0105         _ip.addParameter(_baseFileName);
0106 
0107     _ip.addParameter(_targetBeamZ);
0108     _ip.addParameter(_targetBeamA);
0109 
0110     _ip.addParameter(_targetBeamLorentzGamma);
0111     _ip.addParameter(_electronBeamLorentzGamma);
0112     
0113     _ip.addParameter(_maxW);
0114     _ip.addParameter(_minW);
0115 
0116     _ip.addParameter(_maxW_GP);
0117     _ip.addParameter(_minW_GP);
0118 
0119     _ip.addParameter(_nmbWBins);
0120 
0121     _ip.addParameter(_maxRapidity);
0122     _ip.addParameter(_nmbRapidityBins);
0123     //
0124     _ip.addParameter(_nmbEnergyBins);
0125 
0126     _ip.addParameter(_ptCutEnabled);
0127     _ip.addParameter(_ptCutMin);
0128     _ip.addParameter(_ptCutMax);
0129     
0130     _ip.addParameter(_etaCutEnabled);
0131     _ip.addParameter(_etaCutMax);
0132     _ip.addParameter(_etaCutMin);
0133     
0134     _ip.addParameter(_productionMode);
0135     _ip.addParameter(_nmbEventsTot);
0136     _ip.addParameter(_prodParticleId);
0137     _ip.addParameter(_randomSeed);
0138     _ip.addParameter(_beamBreakupMode);
0139     _ip.addParameter(_interferenceEnabled);
0140     _ip.addParameter(_interferenceStrength);
0141     _ip.addParameter(_maxPtInterference);
0142     _ip.addParameter(_nmbPtBinsInterference);
0143     _ip.addParameter(_minGammaEnergy);
0144     _ip.addParameter(_maxGammaEnergy);
0145     _ip.addParameter(_minGammaQ2);
0146     _ip.addParameter(_maxGammaQ2);
0147     _ip.addParameter(_nmbGammaQ2Bins);
0148     _ip.addParameter(_pythiaParams);
0149     _ip.addParameter(_outputFormat);
0150     _ip.addParameter(_backwardsProduction);
0151     _ip.addParameter(_xsecCalcMethod);
0152         _ip.addParameter(_axionMass);     // AXION HACK
0153         _ip.addParameter(_bslopeDefinition); 
0154         _ip.addParameter(_bslopeValue); 
0155     _ip.addParameter(_impulseVM);
0156     _ip.addParameter(_quantumGlauber);
0157 }
0158 
0159 
0160 //______________________________________________________________________________
0161 inputParameters::~inputParameters()
0162 { }
0163 
0164 
0165 //______________________________________________________________________________
0166 bool
0167 inputParameters::configureFromFile(const std::string &_configFileName)
0168 {
0169 
0170     int nParameters = _ip.parseFile(_configFileName);
0171     
0172     if(nParameters == -1) 
0173     {
0174         printWarn << "could not open file '" << _configFileName << "'" << endl;
0175       return false;
0176     }
0177     
0178     
0179     if(_ip.validateParameters(cerr))
0180         printInfo << "successfully read input parameters from '" << _configFileName << "'" << endl;
0181     else {
0182         printWarn << "problems reading input parameters from '" << _configFileName << "'" << endl
0183                   << *this;
0184         return false;
0185     }
0186     return true;
0187 }
0188  bool inputParameters::init()
0189  {
0190     
0191     // Calculate beam gamma in CMS frame
0192     double rap1 = acosh(electronBeamLorentzGamma());
0193     double rap2 = -acosh(targetBeamLorentzGamma());
0194 
0195     double _electronEnergy_lab = (electronBeamLorentzGamma())*(starlightConstants::mel);
0196     double _ionEnergy_lab = targetBeamLorentzGamma()*(targetBeamA())*protonMass;
0197     double _ionPz_lab = -1.0*sqrt(_ionEnergy_lab*_ionEnergy_lab - (targetBeamA()*targetBeamA())*protonMass*protonMass);
0198     double _electronPz_lab = 1.0*sqrt(_electronEnergy_lab*_electronEnergy_lab - starlightConstants::mel*(starlightConstants::mel));
0199     double _totalEnergy_lab = 1.0*_electronEnergy_lab + _ionEnergy_lab;
0200     double _totalPz_lab = _ionPz_lab + _electronPz_lab;
0201     _rap_CM = (1.0/2.0)*log((_totalEnergy_lab + _totalPz_lab)/(_totalEnergy_lab - _totalPz_lab));
0202     double _totalEnergy_COM;
0203     _totalEnergy_COM = sqrt((_totalEnergy_lab) * (_totalEnergy_lab) - (_totalPz_lab) * (_totalPz_lab)); //This is Lorentz invariant.
0204 
0205     _beamLorentzGamma = cosh(_rap_CM-rap2);
0206     _targetLorentzGamma = cosh(rap1-rap2);
0207 
0208     if( targetBeamA() == 1) //proton case 0.87 fm = 4.4 GeV^{-1}
0209       _targetR = 4.4;
0210     else
0211       _targetR = 6.1 * pow(targetBeamA(), 1./3.);
0212       //_targetR = 4.4/2.;
0213 
0214     _fixedQ2Range = false;
0215     std::cout << "Rapidity electron beam: " << rap1 << ", rapidity target beam: " << rap2 << ", rapidity CMS system: " << _rap_CM << ", beam gamma in CMS: " << _beamLorentzGamma<< std::endl;
0216     std::cout << "Rapidity beam 1 in beam 2 frame: " << rap1-rap2 << ", beam 1 gamma in beam 2 frame: " << _targetLorentzGamma<< std::endl;
0217     _ptBinWidthInterference = maxPtInterference() / nmbPtBinsInterference();
0218     _protonEnergy           = _beamLorentzGamma * protonMass;
0219     // Electron energy in the target frame of reference
0220     _electronEnergy         = _targetLorentzGamma * starlightConstants::mel;
0221 
0222     if( (targetBeamZ()==1) && (targetBeamA()==3) ){
0223         printWarn << "tritium is not currently supported" << endl;
0224         return false;}
0225     // check that rho production uses wide resonance option
0226     if(_prodParticleId.value()==113 && _productionMode.value()==2){
0227         printWarn << endl<< "For rho meson production, you should choose the wide resonance option (production mode = 3)" << endl;
0228         return false;}
0229 
0230     // define interaction type
0231     switch (productionMode()) {
0232     case 1:
0233         _interactionType = PHOTONPHOTON;
0234         break;
0235     case 2:
0236         _interactionType = PHOTONPOMERONNARROW;
0237         break;
0238     case 3:
0239         _interactionType = PHOTONPOMERONWIDE;
0240         break;
0241         case 4:
0242                 _interactionType = PHOTONPOMERONINCOHERENT;
0243                 break;
0244     case 5:
0245         _interactionType = PHOTONUCLEARSINGLE;
0246         break;
0247     case 6:
0248         _interactionType = PHOTONUCLEARDOUBLE;
0249         break;
0250     case 7:
0251         _interactionType = PHOTONUCLEARSINGLEPA;
0252         break;
0253     case 8:
0254         _interactionType = PHOTONUCLEARSINGLEPAPY;
0255         break;
0256 //  case 9:
0257 //      _interactionType = PHOTONPHOTONKNIEHL;
0258 //      break;
0259 //         case 10:
0260 //                 _interactionType = PHOTONPHOTONKNIEHLMODIFIED;
0261 //                 break;
0262     case 12:
0263         _interactionType = E_PHOTONPOMERONNARROW;
0264         break;
0265     case 13:
0266         _interactionType = E_PHOTONPOMERONWIDE;
0267         break;
0268       
0269     default:
0270         printWarn << "unknown production mode '" << _productionMode << "'" << endl;
0271         return false;
0272     }
0273     if( (_productionMode.value() ==4) && (_interferenceEnabled.value())) {
0274         printWarn << " cannot enable interference for incoherent production " << endl;
0275         return false;
0276     }
0277   
0278     double mass        = 0;
0279     double width       = 0;
0280     double defaultMinW = 0;  // default for _minW, unless it is defined later [GeV/c^2]
0281     double defaultMaxW = 0;  // default for _maxW, unless it is defined later [GeV/c^2]
0282     switch (prodParticleId()) {
0283 
0284 //  case 24:  // W+W- pair
0285 //      _particleType = W;
0286 //      _decayType    = WW;
0287 //      defaultMinW   = 2 * muonMass;
0288 //      break;
0289     case 115:  // a_2(1320)
0290         _particleType = A2;
0291         _decayType    = SINGLEMESON;
0292         mass          = starlightConstants::a2Mass;
0293         width         = starlightConstants::a2Width;
0294                 defaultMinW   = mass - 5*width; // JES 6.17.2015 to avoid problems with default of 0
0295                 defaultMaxW   = mass + 5*width; // JES 6.17.2015 to avoid problems with no default
0296                 _inputBranchingRatio = 1.0; 
0297         break;
0298     case 221:  // eta
0299         _particleType = ETA;
0300         _decayType    = SINGLEMESON;
0301         mass          = starlightConstants::etaMass;
0302         width         = starlightConstants::etaWidth;
0303                 defaultMinW   = mass - 5*width; // JES 6.17.2015 to avoid problems with default of 0
0304                 defaultMaxW   = mass + 5*width; // JES 6.17.2015 to avoid problems with no default
0305                 _inputBranchingRatio = 1.0; 
0306         break;
0307     case 225:  // f_2(1270)
0308         _particleType = F2;
0309         _decayType    = SINGLEMESON;
0310         mass          = starlightConstants::f2Mass;
0311         width         = starlightConstants::f2Width;
0312                 defaultMinW   = mass - 5*width; // JES 6.17.2015 to avoid problems with default of 0
0313                 defaultMaxW         = mass + 5*width; // JES 6.17.2015 to avoid problems with no default
0314                 _inputBranchingRatio = starlightConstants::f2BrPiPi; 
0315         break;
0316     case 331:  // eta'(958)
0317         _particleType = ETAPRIME;
0318         _decayType    = SINGLEMESON;
0319         mass          = starlightConstants::etaPrimeMass;
0320         width         = starlightConstants::etaPrimeWidth;
0321                 defaultMinW   = mass - 5*width; // JES 6.17.2015 to avoid problems with default of 0
0322                 defaultMaxW         = mass + 5*width; // JES 6.17.2015 to avoid problems with no default
0323                 _inputBranchingRatio = 1.0; 
0324         break;
0325     case 335:  // f_2'(1525)
0326         _particleType = F2PRIME;
0327         _decayType    = SINGLEMESON;
0328         mass          = starlightConstants::f2PrimeMass;
0329         width         = starlightConstants::f2PrimeWidth;
0330                 defaultMinW   = mass - 5*width; // JES 6.17.2015 to avoid problems with default of 0
0331                 defaultMaxW         = mass + 5*width; // JES 6.17.2015 to avoid problems with no default
0332                 _inputBranchingRatio = starlightConstants::f2PrimeBrKK; 
0333         break;
0334     case 441:  // eta_c(1s)
0335         _particleType = ETAC;
0336         _decayType    = SINGLEMESON;
0337         mass          = starlightConstants::etaCMass;
0338         width         = starlightConstants::etaCWidth;
0339                 defaultMinW   = mass - 5*width; // JES 6.17.2015 to avoid problems with default of 0
0340                 defaultMaxW         = mass + 5*width; // JES 6.17.2015 to avoid problems with no default
0341                 _inputBranchingRatio = 1.0; 
0342         break;
0343     case 9010221:  // f_0(980), was orginally called 10221? updated to standard number
0344         _particleType = F0;
0345         _decayType    = SINGLEMESON;
0346         mass          = starlightConstants::f0Mass;
0347         width         = starlightConstants::f0Width;
0348                 defaultMinW   = mass - 5*width; // JES 6.17.2015 to avoid problems with default of 0
0349                 defaultMaxW         = mass + 5*width; // JES 6.17.2015 to avoid problems with no default
0350                _inputBranchingRatio = starlightConstants::f0BrPiPi; 
0351         break;
0352     case 33:  // Z"/Z0  This is the rho^0 rho^0 final state SRK
0353         _particleType = ZOVERZ03;
0354         _decayType    = SINGLEMESON;
0355                 defaultMinW   = 4*pionChargedMass;
0356                 defaultMaxW         = 1.6; // JES 6.17.2015 to avoid problems with no default
0357                 _inputBranchingRatio = 1.0; 
0358         break;
0359         case 88:  // axion// AXION HACK, till break statement
0360                 _particleType = AXION;
0361                 _decayType    = SINGLEMESON;
0362                 mass          = _axionMass.value();
0363                 width         = 1/(64*starlightConstants::pi)*mass*mass*mass/(1000*1000);//Fix Lambda=1000 GeV, rescaling is trivial.
0364                 defaultMinW   = mass - 5*width; // JES 6.17.2015 to avoid problems with default of 0
0365                 defaultMaxW         = mass + 5*width; // JES 6.17.2015 to avoid problems with no default
0366                 break;    // AXION HACK, end
0367 //  case 25: // Higgs
0368 //      _particleType = HIGGS;
0369 //      _decayType    = SINGLEMESON;
0370 //      break;
0371     case 113:  // rho(770)
0372         _particleType = RHO;
0373         _decayType    = WIDEVMDEFAULT;
0374         mass          = starlightConstants::rho0Mass;
0375         width         = starlightConstants::rho0Width;
0376         defaultMinW   = 2 * pionChargedMass;
0377         defaultMaxW         = mass + 5 * width;
0378         _inputBranchingRatio = starlightConstants::rho0BrPiPi; 
0379         break;
0380     case 913:  // rho(770) with direct pi+pi- decay, interference given by ZEUS data
0381         _particleType = RHOZEUS;
0382         _decayType    = WIDEVMDEFAULT;
0383         mass          = starlightConstants::rho0Mass;
0384         width         = starlightConstants::rho0Width;
0385         defaultMinW   = 2 * pionChargedMass;
0386         defaultMaxW         = mass + 5 * width;  // use the same 1.5GeV max mass as ZEUS
0387         _inputBranchingRatio = starlightConstants::rho0BrPiPi; 
0388         break;
0389         //  case 999:  // pi+pi-pi+pi- phase space decay
0390         //      _particleType = FOURPRONG;
0391         //      _decayType    = WIDEVMDEFAULT;
0392         //      mass          = starlightConstants::rho0PrimeMass;
0393         //      width         = starlightConstants::rho0PrimeWidth;     
0394         //      defaultMinW   = 4 * pionChargedMass;
0395         //                defaultMaxW     = sqrt(beam1LorentzGamma()*beam2LorentzGamma())*2*(starlightConstants::hbarc)/(1.2*pow(float(beam1A()),1./6.)*pow(float(beam2A()),1./6.)); // JES 6.17.2015 to avoid problems with no default
0396         //      _inputBranchingRatio = 1.0; 
0397         //      break;
0398     case 223:  // omega(782)
0399         _particleType = OMEGA;
0400         _decayType    = NARROWVMDEFAULT;  
0401         mass          = starlightConstants::OmegaMass;
0402         width         = starlightConstants::OmegaWidth;
0403         defaultMinW   = mass - 5 * width;
0404         defaultMaxW         = mass + 5 * width;
0405         _inputBranchingRatio = starlightConstants::OmegaBrPiPi; 
0406         break;
0407     case 223022:  // omega(782) -> pi0 + gamma
0408         _particleType = OMEGA_pi0gamma;
0409         _decayType    = NARROWVMDEFAULT;  
0410         mass          = starlightConstants::OmegaMass;
0411         width         = starlightConstants::OmegaWidth;
0412         defaultMinW   = mass - 5 * width;
0413         defaultMaxW         = mass + 5 * width;
0414         _inputBranchingRatio = starlightConstants::OmegaBrPi0Gamma; 
0415         break;
0416     case 333:  // phi(1020)
0417         _particleType = PHI;
0418         _decayType    = NARROWVMDEFAULT;
0419         mass          = starlightConstants::PhiMass;
0420         width         = starlightConstants::PhiWidth;
0421         defaultMinW   = 2 * kaonChargedMass;
0422         defaultMaxW         = mass + 5 * width;
0423         _inputBranchingRatio = starlightConstants::PhiBrKK; 
0424         break;
0425     case 443:  // J/psi
0426         _particleType = JPSI;
0427         _decayType    = NARROWVMDEFAULT;
0428         mass          = starlightConstants::JpsiMass;
0429         width         = starlightConstants::JpsiWidth;
0430         defaultMinW   = mass - 5 * width;
0431         defaultMaxW         = mass + 5 * width;
0432         _inputBranchingRatio = (starlightConstants::JpsiBree + starlightConstants::JpsiBrmumu)/2.; 
0433         break;
0434     case 443011:  // J/psi
0435         _particleType = JPSI_ee;
0436         _decayType    = NARROWVMDEFAULT;
0437         mass          = starlightConstants::JpsiMass;
0438         width         = starlightConstants::JpsiWidth;
0439         defaultMinW   = mass - 5 * width;
0440         defaultMaxW         = mass + 5 * width;
0441         _inputBranchingRatio = starlightConstants::JpsiBree; 
0442         break;
0443     case 443013:  // J/psi
0444             cout<<"In inputParameters setting J/psi mass!"<<endl; 
0445         _particleType = JPSI_mumu;
0446         _decayType    = NARROWVMDEFAULT;
0447         mass          = starlightConstants::JpsiMass;
0448         width         = starlightConstants::JpsiWidth;
0449         defaultMinW   = mass - 5 * width;
0450         defaultMaxW         = mass + 5 * width;
0451         _inputBranchingRatio = starlightConstants::JpsiBrmumu; 
0452         break;
0453     case 444:  // psi(2S) 
0454         _particleType = JPSI2S;
0455         _decayType    = NARROWVMDEFAULT;
0456         mass          = starlightConstants::Psi2SMass;
0457         width         = starlightConstants::Psi2SWidth;
0458         defaultMinW   = mass - 5 * width;
0459         defaultMaxW         = mass + 5 * width;
0460         _inputBranchingRatio = (starlightConstants::Psi2SBree + starlightConstants::Psi2SBrmumu)/2.; 
0461         break;
0462     case 444011: // psi(2S)
0463         _particleType = JPSI2S_ee;
0464         _decayType    = NARROWVMDEFAULT;
0465         mass          = starlightConstants::Psi2SMass;
0466         width         = starlightConstants::Psi2SWidth;
0467         defaultMinW   = mass - 5 * width;
0468         defaultMaxW   = mass + 5 * width;
0469         _inputBranchingRatio = starlightConstants::Psi2SBree; 
0470         break;
0471     case 444013:  // psi(2S)
0472         _particleType = JPSI2S_mumu;
0473         _decayType    = NARROWVMDEFAULT;
0474         mass          = starlightConstants::Psi2SMass;
0475         width         = starlightConstants::Psi2SWidth;
0476         defaultMinW   = mass - 5 * width;
0477         defaultMaxW   = mass + 5 * width;
0478         _inputBranchingRatio = starlightConstants::Psi2SBrmumu; 
0479         break;
0480     case 553:  // Upsilon(1S) 
0481         _particleType = UPSILON;
0482         _decayType    = NARROWVMDEFAULT;
0483         mass          = starlightConstants::Upsilon1SMass;
0484         width         = starlightConstants::Upsilon1SWidth;
0485         defaultMinW   = mass - 5 * width;
0486         defaultMaxW   = mass + 5 * width;
0487         _inputBranchingRatio = (starlightConstants::Upsilon1SBree + starlightConstants::Upsilon1SBrmumu)/2.; 
0488         break;
0489     case 553011:  // Upsilon
0490         _particleType = UPSILON_ee;
0491         _decayType    = NARROWVMDEFAULT;
0492         mass          = starlightConstants::Upsilon1SMass;
0493         width         = starlightConstants::Upsilon1SWidth;
0494         defaultMinW   = mass - 5 * width;
0495         defaultMaxW   = mass + 5 * width;
0496         _inputBranchingRatio = starlightConstants::Upsilon1SBree; 
0497         break;
0498     case 553013:  // Upsilon
0499         _particleType = UPSILON_mumu;
0500         _decayType    = NARROWVMDEFAULT;
0501         mass          = starlightConstants::Upsilon1SMass;
0502         width         = starlightConstants::Upsilon1SWidth;
0503         defaultMinW   = mass - 5 * width;
0504         defaultMaxW   = mass + 5 * width;
0505         _inputBranchingRatio = starlightConstants::Upsilon1SBrmumu; 
0506         break;
0507     case 554:  // Upsilon(2S)
0508         _particleType = UPSILON2S;
0509         _decayType    = NARROWVMDEFAULT;
0510         mass          = starlightConstants::Upsilon2SMass;
0511         width         = starlightConstants::Upsilon2SWidth;
0512         defaultMinW   = mass - 5 * width;
0513         defaultMaxW   = mass + 5 * width;
0514         _inputBranchingRatio = (starlightConstants::Upsilon2SBree + starlightConstants::Upsilon2SBrmumu)/2.; 
0515         break;
0516     case 554011:  // Upsilon(2S)
0517         _particleType = UPSILON2S_ee;
0518         _decayType    = NARROWVMDEFAULT;
0519         mass          = starlightConstants::Upsilon2SMass;
0520         width         = starlightConstants::Upsilon2SWidth;
0521         defaultMinW   = mass - 5 * width;
0522         defaultMaxW   = mass + 5 * width;
0523         _inputBranchingRatio = starlightConstants::Upsilon2SBree; 
0524         break;
0525     case 554013:  // Upsilon(2S)
0526         _particleType = UPSILON2S_mumu;
0527         _decayType    = NARROWVMDEFAULT;
0528         mass          = starlightConstants::Upsilon2SMass;
0529         width         = starlightConstants::Upsilon2SWidth;
0530         defaultMinW   = mass - 5 * width;
0531         defaultMaxW   = mass + 5 * width;
0532         _inputBranchingRatio = starlightConstants::Upsilon2SBrmumu; 
0533         break;
0534     case 555:  // Upsilon(3S)
0535         _particleType = UPSILON3S;
0536         _decayType    = NARROWVMDEFAULT;
0537         mass          = starlightConstants::Upsilon3SMass;
0538         width         = starlightConstants::Upsilon3SWidth;
0539         defaultMinW   = mass - 5 * width;
0540         defaultMaxW   = mass + 5 * width;
0541         _inputBranchingRatio = (starlightConstants::Upsilon3SBree + starlightConstants::Upsilon3SBrmumu)/2.; 
0542         break;
0543     case 555011:  // Upsilon(3S)
0544         _particleType = UPSILON3S_ee;
0545         _decayType    = NARROWVMDEFAULT;
0546         mass          = starlightConstants::Upsilon3SMass;
0547         width         = starlightConstants::Upsilon3SWidth;
0548         defaultMinW   = mass - 5 * width;
0549         defaultMaxW   = mass + 5 * width;
0550         _inputBranchingRatio = starlightConstants::Upsilon3SBree; 
0551         break;
0552     case 555013:  // Upsilon(3S)
0553         _particleType = UPSILON3S_mumu;
0554         _decayType    = NARROWVMDEFAULT;
0555         mass          = starlightConstants::Upsilon3SMass;
0556         width         = starlightConstants::Upsilon3SWidth;
0557         defaultMinW   = mass - 5 * width;
0558         defaultMaxW   = mass + 5 * width;
0559         _inputBranchingRatio = starlightConstants::Upsilon3SBrmumu; 
0560         break;
0561     default:
0562         printWarn << "unknown particle ID " << _prodParticleId << endl;
0563         return false;
0564     }  // _prodParticleId
0565 
0566     if (_minW.value() == -1)
0567         _minW = defaultMinW;
0568     if (_maxW.value() == -1)
0569         _maxW = defaultMaxW;
0570     if ( _maxW.value() <= _minW.value() ) {
0571         printWarn << "maxW must be greater than minW" << endl;
0572         return false;
0573     }
0574 
0575     if (_minW_GP.value() == -1)
0576         _minW_GP = 0;
0577     if (_maxW_GP.value() == -1)
0578         _maxW_GP = 1e7;
0579     if ( _maxW_GP.value() <= _minW_GP.value() ) {
0580         printWarn << "maxW_GA must be greater than minW_GP" << endl;
0581         printWarn <<"The value of minW_GP is " << _minW_GP << endl;
0582         printWarn <<"The value of maxW_GP is " << _maxW_GP << endl;
0583         return false;
0584     }
0585     if(_minW_GP.value() > _totalEnergy_COM) { 
0586     /* If the minimum COM energy of gamma and nucleon is set by user 
0587     to be greater than the total energy supply by electron and target, code will terminate. */
0588     printWarn << "ERROR: The current input minimum CoM energy (_minW_GP) is: "<< _minW_GP 
0589     << " which is larger than the total center-of-mass energy of the electron-ion system: " 
0590     <<_totalEnergy_COM << endl;
0591     cout<<"Exiting now..." << endl;
0592     return false;
0593     }
0594 
0595     // Sanity check on Q2 range in case it is specified by user
0596     if( _minGammaQ2.value() != 0 || _maxGammaQ2.value() != 0){
0597       if( _minGammaQ2.value() <0 || _maxGammaQ2.value() <=_minGammaQ2.value() )
0598         printWarn << "Input values for min and max Q2 are inconsistent: "<<_minGammaQ2.value()<<","<<_maxGammaQ2.value()
0599               <<". Continuing with default "<<endl;
0600       else
0601         _fixedQ2Range = true;
0602     }
0603     //Photon energy limits in C.M.S frame, used for some basic safety chekcs
0604     _cmsMinPhotonEnergy  = 0.5*(((mass+protonMass)*(mass+protonMass)-
0605                      protonMass*protonMass)/(_protonEnergy.value()+sqrt(_protonEnergy.value()*_protonEnergy.value()-protonMass*protonMass)));
0606     _cmsMaxPhotonEnergy        = 0.5*mass*exp(9);
0607     // Photon limits in target frame: this is where the photon flux is well described
0608     _targetMaxPhotonEnergy        = (_targetLorentzGamma - 10. ) *starlightConstants::mel;
0609     _targetMinPhotonEnergy = mass;
0610     printInfo << "using the following " << *this;
0611     
0612     return true;
0613 }
0614 
0615 
0616 //______________________________________________________________________________
0617 ostream&
0618 inputParameters::print(ostream& out) const
0619 {
0620     out << "starlight parameters:" << endl
0621         << "    base file name  ...................... '"  << _baseFileName.value() << "'" << endl
0622         << "    target beam atomic number .............. " << _targetBeamZ.value() << endl
0623         << "    target beam atomic mass number ......... " << _targetBeamA.value() << endl
0624         << "    Lorentz gamma of beams in CM frame ..... " << _beamLorentzGamma << endl
0625         << "    mass W of produced hadronic system ..... " << _minW.value() << " < W < " << _maxW.value() << " GeV/c^2" << endl
0626         << "    # of W bins ............................ " << _nmbWBins.value() << endl
0627         << "    maximum absolute value for rapidity .... " << _maxRapidity.value() << endl
0628         << "    # of rapidity bins ..................... " << _nmbRapidityBins.value() << endl
0629             << "    # of Egamma bins ....................... " << _nmbEnergyBins.value() << endl
0630         << "    cut in pT............................... " << yesNo(_ptCutEnabled.value()) << endl;
0631     if (_ptCutEnabled.value()) {
0632     out << "        minumum pT.......................... " << _ptCutMin.value() << " GeV/c" << endl
0633         << "        maximum pT.......................... " << _ptCutMax.value() << " GeV/c" << endl;}
0634     out << "    cut in eta.............................. " << yesNo(_etaCutEnabled.value()) << endl;
0635     if (_etaCutEnabled.value()) {
0636     out << "        minumum eta......................... " << _etaCutMin.value() << endl
0637         << "        maximum eta......................... " << _etaCutMax.value() << endl;}
0638         out << "    production mode ........................ " << _productionMode.value() << endl
0639         << "    number of events to generate ........... " << _nmbEventsTot.value() << endl
0640         << "    PDG ID of produced particle ............ " << _prodParticleId.value() << endl
0641         << "    seed for random generator .............. " << _randomSeed.value() << endl
0642         << "    breakup mode for beam particles ........ " << _beamBreakupMode.value() << endl
0643         << "    interference enabled ................... " << yesNo(_interferenceEnabled.value()) << endl;
0644     if (_interferenceEnabled.value()) {
0645     out << "    interference strength .................. " << _interferenceStrength.value() << endl
0646         << "    maximum p_T for interference calc. ..... " << _maxPtInterference.value() << " GeV/c" << endl
0647         << "    # of p_T bins for interference calc. ... " << _nmbPtBinsInterference.value() << endl;}
0648     if (_productionMode.value()!=1) {
0649         if (_productionMode.value()==4) {
0650           out  << "    coherent scattering off nucleus ........ no" << endl;}
0651         else {
0652           out  << "    coherent scattering off nucleus ........ yes" << endl;
0653         }
0654     }
0655     if (_fixedQ2Range == true ){
0656       out << "    fixed photon Q2 range .................. " << _minGammaQ2.value() << " < Q2 < "
0657       <<_maxGammaQ2.value() << " GeV/c^2 "<<endl;
0658     }
0659     out<< " Q2_BINS"       <<nmbGammaQ2Bins        () <<endl;
0660     out     <<"    Quantum Glauber parameter...............  "<<_quantumGlauber.value()<<endl;
0661     out     <<"    Impulse VM parameter....................  "<<_impulseVM.value()<<endl;
0662     return out;
0663 }
0664 
0665 
0666 //______________________________________________________________________________
0667 ostream&
0668 inputParameters::write(ostream& out) const
0669 {
0670   
0671         out << "baseFileName"  << baseFileName         () <<endl
0672         << "TARGET_BEAM_Z" << targetBeamZ          () <<endl
0673         << "TARGET_BEAM_A" << targetBeamA          () <<endl
0674         << "BEAM_GAMMA"    << beamLorentzGamma     () <<endl
0675         << "W_MAX"         << maxW                 () <<endl
0676         << "W_MIN"         << minW                 () <<endl
0677         << "W_GP_MAX"      << maxW_GP              () <<endl
0678         << "W_GP_MIN"      << minW_GP              () <<endl
0679         << "W_N_BINS"      << nmbWBins             () <<endl
0680         << "RAP_MAX"       << maxRapidity          () <<endl
0681         << "RAP_N_BINS"    << nmbRapidityBins      () <<endl
0682         << "CUT_PT"        << ptCutEnabled         () <<endl
0683         << "PT_MIN"        << ptCutMin             () <<endl
0684         << "PT_MAX"        << ptCutMax             () <<endl
0685         << "CUT_ETA"       << etaCutEnabled        () <<endl
0686         << "ETA_MIN"       << etaCutMin            () <<endl
0687         << "ETA_MAX"       << etaCutMax            () <<endl
0688         << "PROD_MODE"     << productionMode       () <<endl
0689         << "N_EVENTS"      << nmbEvents            () <<endl
0690         << "PROD_PID"      << prodParticleId       () <<endl
0691         << "RND_SEED"      << randomSeed           () <<endl
0692         << "BREAKUP_MODE"  << beamBreakupMode      () <<endl
0693         << "INTERFERENCE"  << interferenceEnabled  () <<endl
0694         << "IF_STRENGTH"   << interferenceStrength () <<endl
0695         << "INT_PT_MAX"    << maxPtInterference    () <<endl
0696         << "INT_PT_N_BINS" << nmbPtBinsInterference() <<endl;
0697     out<< "USING FIXED RANGE"<<_fixedQ2Range<<endl;
0698     if( _fixedQ2Range == true ){
0699       out << "Q2_MIN"      << minGammaQ2           () <<endl
0700           << "Q2_MAX"      << maxGammaQ2           () <<endl;
0701     }
0702     out<< " Q2_BINS"       <<nmbGammaQ2Bins        () <<endl;
0703     return out;
0704 }
0705 
0706 std::string
0707 inputParameters::parameterValueKey() const 
0708 {
0709   return parameterbase::_parameters.validationKey();
0710 }