Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 09:03:55

0001 // FlavorVariations.h is a part of the PYTHIA event generator.
0002 // Copyright (C) 2025 Stephen Mrenna, Christian Bierlich, Philip Ilten,
0003 // Torbjorn Sjostrand.
0004 // PYTHIA is licenced under the GNU GPL v2 or later, see COPYING for details.
0005 // Please respect the MCnet Guidelines, see GUIDELINES for details.
0006 
0007 #ifndef Pythia8_FlavorVariations_H
0008 #define Pythia8_FlavorVariations_H
0009 
0010 // Include Pythia headers.
0011 #include "Pythia8/Pythia.h"
0012 
0013 namespace Pythia8 {
0014 
0015 //==========================================================================
0016 
0017 // Calculate the weight for an event given a different set of flavor
0018 // parameters used in the hadronization.
0019 
0020 class FlavorVariations {
0021 
0022 public:
0023 
0024   // Constructor, given an intialized Pythia object.
0025   FlavorVariations(Settings &settings) : FlavorVariations(
0026     settings.parm("StringFlav:ProbQQtoQ"),
0027     settings.parm("StringFlav:ProbStoUD"),
0028     settings.parm("StringFlav:ProbSQtoQQ"),
0029     settings.parm("StringFlav:ProbQQ1toQQ0")) {}
0030 
0031   // Constructor, given the default base parameters.
0032   FlavorVariations(double xi, double rho, double x, double y) :
0033     pythia("", false) {
0034     pythia.settings.flag("ProcessLevel:all", false);
0035     pythia.settings.flag("Print:quiet", true);
0036     pythia.settings.flag("VariationFrag:flav", true);
0037     pythia.settings.parm("StringFlav:ProbQQtoQ", xi);
0038     pythia.settings.parm("StringFlav:ProbStoUD", rho);
0039     pythia.settings.parm("StringFlav:ProbSQtoQQ", x);
0040     pythia.settings.parm("StringFlav:ProbQQ1toQQ0", y);
0041     pythia.settings.addMVec(key, vector<int>(14, 0), false, false, 0, 0);
0042     pythia.init();
0043   }
0044 
0045   // Read and write string break counts.
0046   vector<int> read(string breaks) {
0047     pythia.settings.readString(key + " = " + breaks);
0048     return pythia.settings.mvec(key);}
0049   string write(const vector<int>& breaks) {
0050     string out = "{";
0051     for (const int& val : breaks) out += toString(val) + ",";
0052     return out.substr(0, out.length() - 1) + "}";}
0053 
0054   // Calculate the derived parameters.
0055   vector<double> parms(double xi, double rho, double x, double y) {
0056     return pythia.info.weightContainerPtr
0057       ->weightsFragmentation.flavParms(xi, rho, x, y);}
0058 
0059   // Calculate the weight.
0060   double weight(const vector<double>& parms, const vector<int>& breaks) {
0061     return pythia.info.weightContainerPtr
0062       ->weightsFragmentation.flavWeight(parms, breaks);}
0063 
0064 private:
0065 
0066   // Pythia object.
0067   Pythia pythia;
0068 
0069   // Key to serialize the string breaks.
0070   string key{"VariationFrag:breaks"};
0071 
0072 };
0073 
0074 //==========================================================================
0075 
0076 } // end namespace Pythia8
0077 
0078 #endif // end Pythia8_FlavorVariations_H