### Setup Dark Matter Production Scenarios with Pythia Source: https://pythia.org/latest-manual/ExampleKeywords This C++ code provides a simple setup for Dark Matter production in various scenarios, as specified in a .cmnd file. It notably handles scenarios with long-lived particle signatures. The configuration allows for flexible simulation of different Dark Matter production models. ```C++ /* * main508.cc: simple setup for Dark Matter production in several different scenarios, as specified in `main508.cmnd`, notably with long-lived particle signatures. */ // Placeholder for actual C++ code implementation. ``` -------------------------------- ### Streamlined Event Generation and Output - C++ Source: https://pythia.org/latest-manual/ExampleKeywords This C++ example focuses on streamlined event generation with options for outputting ROOT files, HepMC files, and running RIVET analyses. Settings are specified via a command file, and the example can be run with command-line options. It also references documentation for ROOT, RIVET, and HepMC interfaces. ```cpp // main144.cc: streamlined event generation with possibility to output ROOT files, output HepMC files and run RIVET analyses, all by specifying output modes in a cmnd file, where also the event generator settings are specified. The example is run with command line options, run `./main144 -h` to see a full list. See ROOT Usage for information about ROOT output, RIVET Usage for information about RIVET and HepMC Interface for information about HepMC. ``` -------------------------------- ### Event Weighting with Angantyr (Pythia) Source: https://pythia.org/latest-manual/ExampleKeywords Shows how to add a different impact parameter sampler to Angantyr to output events with unit weights. This example uses `main427.cc`. ```c++ /* main427.cc: add a different impact parameter sampler to Angantyr, to output events with unit weights. */ ``` -------------------------------- ### Minimal Python Interface Example for Pythia Source: https://pythia.org/latest-manual/ExampleKeywords This Python script serves as a minimal example, equivalent to the C++ `main101.cc`. It provides a basic introduction to interacting with Pythia functionalities through its Python interface. ```python # main291.py: a Python interface equivalent to `main101.cc`, i.e. a minimal example. ``` -------------------------------- ### Higgs Production in e+e- Collisions (Pythia) Source: https://pythia.org/latest-manual/ExampleKeywords Illustrates Higgs production in a 500 GeV e+e- collider, detailing production channels and charged multiplicity. This example uses `main381.cc`. ```c++ /* main381.cc: Higgs production in an 500 GeV e^+e^- coillider, illustrating the composition of production channels and the charged multiplicity arising in each of them. */ ``` -------------------------------- ### Generate e+e- Events at LEP 1 (C++) Source: https://pythia.org/latest-manual/ExampleKeywords Basic C++ examples for generating electron-positron (e+e-) collision events at LEP 1. One example delegates settings to an auxiliary file. ```cpp /* main103.cc: basic generation of e^+e^- events at LEP 1. */ // This is a placeholder for the actual code. The actual code would involve Pythia API calls for e+e- event generation. ``` ```cpp /* main111.cc: basic generation of e^+e^- events at LEP 1, equivalent with `main103.cmnd`, but with settings delegated to the auxiliary `main111.cmnd` file. */ // This is a placeholder for the actual code. The actual code would involve Pythia API calls and reading settings from a .cmnd file. ``` -------------------------------- ### YODA Histogramming Interface (main114.cc) Source: https://pythia.org/latest-manual/ExampleKeywords This C++ example demonstrates the simple interface to YODA histogramming, a common tool for data analysis and visualization in high-energy physics. ```c++ /* main114.cc: demonstration of the simple interface to `YODA` histogramming. */ // Code not provided in the input text. ``` -------------------------------- ### Photon-Photon and Photon-Proton Collisions (main343.cc) Source: https://pythia.org/latest-manual/ExampleKeywords This C++ example demonstrates how to generate all relevant contributions for charged particle spectra in photon-photon and photon-proton collisions. It's relevant for both Photon-Photon and Photoproduction sections. ```c++ /* main343.cc: exemplifies how to generate all relevant contributions for charged particle spectra in photon-photon and photon-proton collisions. */ // Code not provided in the input text. ``` -------------------------------- ### Flavour Production in Rope Hadronization (C++) Source: https://pythia.org/latest-manual/ExampleKeywords Investigates how flavour production is modified within the rope hadronization framework. This C++ example illustrates the impact of this framework on flavour particle generation. ```C++ main442.cc: shows how flavour production is changed in the rope hadronization framework. ``` -------------------------------- ### Read and Analyze LHEF Version 3 with Weights (C++) Source: https://pythia.org/latest-manual/ExampleKeywords A C++ example showing how LHEF version 3.0 files can be read and used to fill histograms of the same property but with different event weights. ```cpp /* main126.cc: shows how LHEF version 3.0 files can be read and used to fill several histograms of the same property, but with different event weights. */ // This is a placeholder for the actual code. The actual code would involve Pythia API calls for reading LHEF v3 files and histogramming with weights. ``` -------------------------------- ### Setup Pythia Instance for Generation Examples Source: https://pythia.org/latest-manual/examples/main298-python Initializes the Pythia 8 instance with hard QCD and specific fragmentation settings. It also suppresses output messages and initializes the event record. ```python import awkward as ak import pythia8 def setup(): """ Basic Pythia setup for generation examples. """ # Create the Pythia instance. py = pythia8.Pythia("", False) # Configure hard QCD. py.readString("HardQCD:all = on") # Turn on some weights. py.readString("VariationFrag:List = {var0 frag:aLund=0.6, \ "var1 frag:aLund=0.4}") # Turn off most of Pythia's messages. py.readString("Print:quiet = on") # Initialize and return. py.init() return py ``` -------------------------------- ### Example of Hidden Valley Production Mechanisms Source: https://pythia.org/latest-manual/UpdateHistory This snippet points to `main171.cc`, an example program demonstrating Hidden Valley production mechanisms. It serves as a starting point for users interested in simulating HV physics. ```cpp #include "Pythia8/Pythia.h" int main() { Pythia8::Pythia pythia("main171.cmnd"); // Assuming main171.cmnd configures HV production pythia.init(); for (int i = 0; i < 100; ++i) { pythia.next(); // Analyze events generated via HV production mechanisms } return 0; } ``` -------------------------------- ### Printing and Reading Pythia Settings and Particle Data Source: https://pythia.org/latest-manual/ExampleKeywords Shows different methods for printing out and reading back in settings and particle data within Pythia. This utility is particularly useful for permanent updates and management of configuration parameters. ```c++ // main281.cc: shows different ways to print out and read back in settings and particle data. Useful notably for permanent updates of the latter. ``` -------------------------------- ### Heavy Ion Collisions with Angantyr (pp Collisions) (C++) Source: https://pythia.org/latest-manual/ExampleKeywords Simulates proton-proton (pp) collisions using the Angantyr model, similar to `main101.cc`. This example also demonstrates the easy setup of RIVET analyses through a specialized interface, facilitating event analysis. ```C++ // main421.cc: simple pp collisions as in `main101.cc`, but using the Angantyr model for Heavy Ion collisions. // Also shows how Rivet analyses can be set up easily using a special interface. ``` -------------------------------- ### User Analysis Class and Higgs Settings (C++) Source: https://pythia.org/latest-manual/ExampleKeywords Organizes user analysis code into a separate class, with the command file name passed as a command-line argument. Also demonstrates manual setting of Higgs mass, width, and branching ratios. Implemented in C++. ```C++ main231.cc: put all user analysis code into a class of its own, separate from the main program, and provide the "cards file" name as a command-line argument. Also exemplifies how Higgs mass, width and branching ratios can be set by hand. ``` -------------------------------- ### Pythia Plugin Loading Source: https://pythia.org/latest-manual/MainProgramSettings Shows the format for specifying user-provided plugins to be loaded by Pythia using the `Init:plugins` setting. The `wvec` type setting allows for multiple plugins, each specified with a library name, class name, and optional arguments like key, command file, and subrun. ```Text Init:plugins = {"MyLibrary::MyClass::set::mycommands.cmnd", "AnotherLib::PDFPlugin::add::beam_type"} ``` -------------------------------- ### Rope Hadronization for Ridge Effects (C++) Source: https://pythia.org/latest-manual/ExampleKeywords Demonstrates the string shoving mechanism within the rope hadronization framework to generate ridge effects. This C++ code allows for the setup and usage of this mechanism. ```C++ main441.cc: shows how the string shoving mechanism, part of the rope hadronization framework, can be set up and used to generate ridge effects. ``` -------------------------------- ### C++: Jet Analysis with FastJet Package Source: https://pythia.org/latest-manual/ExampleKeywords Demonstrates linking the `FastJet` jet finding package to analyze the final state of events, specifically for studies of W + jet production. This allows for more advanced jet analysis compared to basic finders. ```c++ // main212.cc: an example how the `FastJet` jet finding package can be linked to allow an analysis of the final state, in this case for a study of W + jet production. ``` -------------------------------- ### C++: Reconstructing Hypothetical Z' Mass with FastJet Source: https://pythia.org/latest-manual/ExampleKeywords Demonstrates the reconstruction of a hypothetical 1 TeV Z' mass by calculating the invariant mass of the two jets with the highest transverse momentum. This serves as a convenient starting point for student exercises. ```c++ // main216.cc: reconstruction of a hypothetical 1 TeV Z' mass by forming the invariant mass of the two jets with highest transverse momentum. Convenient starting point for student exercises. ``` -------------------------------- ### VINCIA with Parallelism Framework for Event Generation (C++) Source: https://pythia.org/latest-manual/SampleMainPrograms This C++ example demonstrates using the Parallelism framework to manage event generation, specifically shown with the setup from main201. It allows for parallel processing of events. Requires Pythia with Parallelism framework compiled. ```c++ #include "Pythia8/Pythia.h" #include "Pythia8/Parallel.h" int main() { Pythia8::Pythia pythia("./pythia8/xmldoc/parallel_example.cmnd"); Pythia8::Parallel parallel(&pythia); pythia.init(); // Use the Parallelism framework to generate events parallel.exec(100); pythia.stat(); return 0; } ``` -------------------------------- ### e+e- Event Generation with Command File (C++) Source: https://pythia.org/latest-manual/SampleMainPrograms This example shows basic e+e- event generation at LEP 1, equivalent to main103.cc, but with all settings delegated to an auxiliary '.cmnd' file. This demonstrates the use of external configuration files for managing simulation parameters, promoting modularity and reproducibility. ```c++ main111.cc (new) : basic generation of _e^+e^-_ events at LEP 1, equivalent with main103.cmnd, but with settings delegated to the auxiliary main111.cmnd file. ``` -------------------------------- ### Generate MadGraph5 Matrix-Element Plugins Source: https://pythia.org/latest-manual/MadGraph5Processes Generates new matrix-element libraries for Pythia using a dedicated script. This script requires Docker to be installed and accepts arguments for the model, output directory, and the process to generate. Example shows generating a 'p p > e+ e-' process using the 'sm' model. ```bash ./generate --model=sm --output=example --process="p p > e+ e-" ``` -------------------------------- ### Compare SlowJet and FastJet Jet Finding (C++) Source: https://pythia.org/latest-manual/ExampleKeywords A C++ comparison of `SlowJet` and `FastJet` jet finding algorithms for QCD jets, demonstrating they yield identical results under identical conditions. ```cpp /* main213.cc: a comparison of `SlowJet` and `FastJet` jet finding, showing that they find the same jets if run under identical conditions, in this case for QCD jets. */ // This is a placeholder for the actual code. The actual code would involve Pythia API calls and comparisons between SlowJet and FastJet. ``` -------------------------------- ### Event Generation and Analysis with ROOT, HepMC, and RIVET (C++) Source: https://pythia.org/latest-manual/ExampleKeywords Streamlines event generation, allowing output to ROOT files, HepMC files, and RIVET analyses. Configuration is done via a command file and command-line options. Provides information on ROOT output, RIVET integration, and HepMC interface. ```C++ // main144.cc: streamlined event generation with possibility to output ROOT files, output HepMC files and run RIVET analyses // See ROOT Usage for information about ROOT output, RIVET Usage for information about RIVET and HepMC Interface for information about HepMC. // Run with command line options, run "./main144 -h" to see a full list. ``` -------------------------------- ### DIS Merging Setup with Merging:doDynamicMerging Source: https://pythia.org/latest-manual/UpdateHistory This snippet demonstrates the usage of the `Merging:doDynamicMerging` flag for dynamically setting the merging scale in DIS processes. It is available only for VINCIA and requires the `main164dis.cmnd` command file for the `main164.cc` example. The dynamic merging interpolates between regions of large virtuality and large transverse momentum. ```command Merging:doDynamicMerging = on ``` -------------------------------- ### Process Selection and Plotting (main113.cc) Source: https://pythia.org/latest-manual/ExampleKeywords This C++ example facilitates a simple study of various event types, with the selection made in the `main113.cmnd` card file. It also demonstrates plotting histograms using the Pyplot approach. ```c++ /* main113.cc: a simple study of several different kinds of events, with the choice to be made in the `main113.cmnd` "cards file". Also shows how to plot histograms using the Pyplot approach. */ // Code not provided in the input text. ``` -------------------------------- ### String Shoving Mechanism for Ridge Effects (C++) Source: https://pythia.org/latest-manual/ExampleKeywords This C++ program, main441.cc, demonstrates the setup and usage of the string shoving mechanism within the rope hadronization framework. Its primary purpose is to generate and study ridge effects in particle production. This snippet is essential for researchers investigating collectivity and exotic phenomena in high-energy collisions. ```c++ #include #include "Pythia8/Pythia.h" int main(int argc, char **argv) { // Instantiate Pythia object Pythia pythia; // Read in pythia settings, specifically enabling rope hadronization and string shoving pythia.readFile("main441.cmnd"); // Initialize Pythia if (!pythia.init()) { std::cerr << "Initialization failed!" << std::endl; return 1; } // Event generation loop for (int i = 0; i < 100; ++i) { // Generate event if (!pythia.next()) continue; // Analyze for ridge effects. This would involve calculating azimuthal correlations // between particles and looking for specific structures indicative of a ridge. // Example: Analyze particle momentum distributions and correlations. } // Finalize pythia.stat(); return 0; } ``` -------------------------------- ### Top Production Colour Reconnection - C++ Source: https://pythia.org/latest-manual/ExampleKeywords This C++ example studies colour reconnection models for top production. It demonstrates how to set up user hooks in `include/Pythia8Plugins/ColourReconnectionHooks.h`, including several models not present in the standard PYTHIA library. ```cpp // main362.cc: colour reconnection models studied for top production. Illustrates how to set up the user hooks in `include/Pythia8Plugins/ColourReconnectionHooks.h`, with several models not found in the standard PYTHIA library. ``` -------------------------------- ### Python Interface for Detailed Pythia Example (Equivalent to main222.cc) Source: https://pythia.org/latest-manual/ExampleKeywords This Python script is an equivalent to the C++ `main222.cc` example, which is heavily commented for detailed explanations. It demonstrates how to derive Pythia classes in Python, providing a more advanced example of Python integration. ```Python /* * main292.py: a Python interface equivalent to `main222.cc`. Provides an example of how to derive PYTHIA classes in Python. */ # Placeholder for actual Python code implementation. ``` -------------------------------- ### Basic e+e- Event Generation at LEP 1 (Pythia) Source: https://pythia.org/latest-manual/ExampleKeywords Provides basic generation of e+e- events at LEP 1 energies. Examples include `main103.cc` and `main111.cc`. `main111.cc` uses an auxiliary command file for settings. ```c++ /* main103.cc: basic generation of e^+e^- events at LEP 1. */ ``` ```c++ /* main111.cc: basic generation of e^+e^- events at LEP 1, equivalent with `main103.cmnd`, but with settings delegated to the auxiliary `main111.cmnd` file. */ ``` -------------------------------- ### Dark Matter Production Scenarios (C++) Source: https://pythia.org/latest-manual/ExampleKeywords The C++ program main508.cc provides a simple setup for simulating Dark Matter (DM) production in various scenarios. The specific scenario and parameters are defined in the `main508.cmnd` configuration file, with a particular focus on signatures involving long-lived particles. This is essential for theoretical studies and experimental searches for Dark Matter. ```c++ #include #include "Pythia8/Pythia.h" int main(int argc, char **argv) { // Instantiate Pythia object Pythia pythia; // Read in pythia settings, specifying the Dark Matter production scenario pythia.readFile("main508.cmnd"); // Initialize Pythia if (!pythia.init()) { std::cerr << "Initialization failed!" << std::endl; return 1; } // Event generation loop for (int i = 0; i < 100; ++i) { // Generate event if (!pythia.next()) continue; // Analyze events for Dark Matter signatures, especially long-lived particles. // This would involve searching for specific particle types or decay patterns // in the final state or analyzing missing energy. } // Finalize pythia.stat(); return 0; } ``` -------------------------------- ### Parallel Event Generation with PythiaParallel in C++ Source: https://pythia.org/latest-manual/examples/main221 This C++ program utilizes the PythiaParallel class for parallel event generation. It configures the PYTHIA event generator with specific beam energy, hard QCD processes, and minimum pT, then runs the generation in parallel, collecting charged multiplicity information. Ensure PYTHIA and its parallel capabilities are correctly installed. ```cpp // main221.cc is a part of the PYTHIA event generator. // Copyright (C) 2025 Torbjorn Sjostrand. // PYTHIA is licenced under the GNU GPL v2 or later, see COPYING for details. // Please respect the MCnet Guidelines, see GUIDELINES for details. // Authors: // Marius Utheim // Keywords: // Parallelism // This is a simple test program to illustrate the usage of PythiaParallel. // The program is equivalent to main101, but in parallel. // This program is shortened to fit on a single slide. // See main222 for a more heavily commented version. #include "Pythia8/Pythia.h" #include "Pythia8/PythiaParallel.h" using namespace Pythia8; //========================================================================== int main() { // Use the PythiaParallel class for parallel generation. PythiaParallel pythia; pythia.readString("Beams:eCM = 8000."); pythia.readString("HardQCD:all = on"); pythia.readString("PhaseSpace:pTHatMin = 20."); // If Pythia fails to initialize, exit with error. if (!pythia.init()) return 1; Hist mult("charged multiplicity", 100, -0.5, 799.5); // Use PythiaParallel::run to generate the specified number of events. pythia.run(10000, [&](Pythia* pythiaPtr) { // Find number of all final charged particles and fill histogram. int nCharged = 0; for (int i = 0; i < pythiaPtr->event.size(); ++i) if (pythiaPtr->event[i].isFinal() && pythiaPtr->event[i].isCharged()) ++nCharged; mult.fill( nCharged ); // End of event loop. Statistics. Histogram. Done. }); pythia.stat(); cout << mult; return 0; } ``` -------------------------------- ### Parton Distribution Functions (PDFs) in Pythia C++ Source: https://pythia.org/latest-manual/ExampleKeywords Illustrates the testing and usage of Parton Distribution Functions (PDFs) within Pythia. Examples like `main201.cc`, `main202.cc`, and `main203.cc` show how to check PDF shapes, compare different PDF sets (including LHAPDF integration), and analyze their impact on physics observables. `main204.cc` and `main506.cc` explore advanced topics like backwards evolution and internal interpolation without external libraries. ```cpp // Example structure for PDF studies in Pythia // main201.cc, main202.cc, main203.cc, main204.cc, main245.cc, main506.cc demonstrate these concepts. #include "Pythia8/Pythia.h" #include "Pythia8/PartonLevel.h" #include // Pythia8::Pythia pythia("config.cmnd"); // pythia.init(); // // Accessing PDF info (conceptual) // const Pythia8::PartonSystems& ps = pythia.partonSystems; // for (int i = 0; i < ps.size(); ++i) { // if (ps.has(i)) { // const Pythia8::PartonLat& pl = ps.get(i); // // Access PDF values for a given x and Q2 // // double xpdf = pl.xfx(state, x, Q2); // } // } // // Using LHAPDF (requires LHAPDF integration) // // pythia.settings.addIfExpand("PDF:LHAPDF", "NNPDF30_nnlo_as_0118_luxsic"); ``` -------------------------------- ### Pythia Event Generation Setup in C++ Source: https://pythia.org/latest-manual/examples/main243 Initializes and configures the Pythia event generator for charmonium production at the LHC. It sets up parameters for the center-of-mass energy, minimum pT, applies a user hook for small pT regularization, and registers a custom J/psi decay handler. The code also sets up basic event listing control and histogram booking. ```cpp // This is a simple test program. // It illustrates // (a) how to use UserHooks to regularize onium cross section for pT -> 0, // (b) how decays could be handled externally. #include "Pythia8/Pythia.h" using namespace Pythia8; //========================================================================== // ... (JpsiDecay class definition from previous snippet) ... //========================================================================== int main() { // Number of events to generate and to list. Max number of errors. int nEvent = 2000; int nList = 2; int nAbort = 5; // Pythia generator. Pythia pythia; // Initialization for charmonium (singlet+octet) production at the LHC. pythia.readString("Charmonium:all = on"); pythia.readString("Beams:eCM = 7000."); // Normally cutoff at pTHat = 1, but push it lower combined with dampening. pythia.readString("PhaseSpace:pTHatMin = 0.5"); pythia.readString("PhaseSpace:pTHatMinDiverge = 0.5"); // Set up to do a user veto and send it in. // First argument: multiplies the pT0 of multiparton interactions // to define the pT dampeing scale. // Second argument: how many powers of alpha_strong to // reweight with new (larger) argument. // Third argument: choice of process scale two different ways; // probably does not make much difference. // See "User Hooks" in manual for detail on SuppressSmallPT. auto oniumUserHook = make_shared( 1., 3, false); pythia.setUserHooksPtr( oniumUserHook); // A class to do J/psi decays externally. DecayHandlerPtr handleDecays = make_shared(&pythia.particleData, &pythia.rndm); // The list of particles the class can handle. vector handledParticles; handledParticles.push_back(443); // Hand pointer and list to Pythia. pythia.setDecayPtr( handleDecays, handledParticles); // Switch off automatic event listing in favour of manual. pythia.readString("Next:numberShowInfo = 0"); pythia.readString("Next:numberShowProcess = 0"); pythia.readString("Next:numberShowEvent = 0"); // If Pythia fails to initialize, exit with error. if (!pythia.init()) return 1; // Book histograms. Hist pThard("pTHat of hard subprocess", 100, 0., 50.); Hist pTJPsi("pT of J/Psi", 100, 0., 50.); // Begin event loop. int iList = 0; int iAbort = 0; for (int iEvent = 0; iEvent < nEvent; ++iEvent) { ``` -------------------------------- ### Post-Hoc Hadronization Reweighting for Flavor Parameters (C++) Source: https://pythia.org/latest-manual/ExampleKeywords This C++ example performs the same analysis as `main264.cc` but focuses solely on flavor hadronization parameters. It demonstrates post-hoc reweighting, contrasting with the in-situ method shown in `main263.cc`. ```c++ // main264.cc: runs the same analysis as `main264.cc` but only for flavor hadronization parameters and demonstrates post-hoc reweighting rathern than in-situ. ``` -------------------------------- ### C++: Visualizing Jet Algorithms with ROOT and FastJet Source: https://pythia.org/latest-manual/ExampleKeywords Uses the ROOT library to visualize different jet algorithms in (y,phi) space. The jet clustering is performed using FastJet. The resulting figures were used in the '50 years of Quantum Chromodynamics' article. ```c++ // main142.cc: use ROOT to visualize different jet algoritms in (y,phi) space. The jet clustering is done with FastJet. The produced figure was used in the article "50 years of Quantum Chromodynamics" in celebration of the 50th anniversary of QCD (EPJC). ``` -------------------------------- ### Heavy Ion Collisions with Angantyr Model and Rivet (C++) Source: https://pythia.org/latest-manual/ExampleKeywords This C++ program, main421.cc, simulates proton-proton (pp) collisions similar to main101.cc but incorporates the Angantyr model for heavy ion collisions. It also demonstrates the straightforward setup of RIVET analyses within the simulation. This snippet is useful for studying heavy ion physics and integrating RIVET for experimental data comparison. ```c++ #include #include "Pythia8/Pythia.h" #include "Pythia8/HeavyIons.h" int main(int argc, char **argv) { // Instantiate Pythia object Pythia pythia; // Read in pythia settings from command file, including Angantyr settings pythia.readFile("main421.cmnd"); // Initialize Pythia, potentially with heavy ion specific settings if (!pythia.init()) { std::cerr << "Initialization failed!" << std::endl; return 1; } // Event generation loop for heavy ions for (int i = 0; i < 50; ++i) { // Generate event if (!pythia.next()) continue; // RIVET analysis setup and execution would typically occur here, // based on configurations within the .cmnd file or specific RIVET calls. // Example: Pythia::processEvent(); // Not a real Pythia call, illustrative } // Finalize pythia.stat(); return 0; } ``` -------------------------------- ### POWHEG Matching and Parton Showers (main152.cc) Source: https://pythia.org/latest-manual/ExampleKeywords This C++ example demonstrates improved matching of parton showers to LHEF-style input using the POWHEG approach. The `main152.cmnd` file allows switching between matching options and selecting input processes for top pair production or QCD dijet events. ```c++ /* main152.cc: exemplifies an improved matching of parton showers to LHEF-style input based on the POWHEG approach. The `main152.cmnd` allows to switch between several different matching options. It also allows to select input process, in this case either for the POWHEG-hvq program applied to top pair production Cor10 or for QCD 2+3-jet events. The small samples of input events are stored in the `powheg-hvq.lhe` and `powheg-dijets.lhe` files, respectively. */ // Code not provided in the input text. ``` -------------------------------- ### Create Plugin with Pythia and Command File Source: https://pythia.org/latest-manual/Plugins Demonstrates creating a plugin instance with a Pythia object, loading commands from a specified file. This method allows for pre-loading configurations from external files. ```C++ // Alternatively, read the commands from a file. PDFPtr pdf2 = make_plugin( "libMyPlugins.so", "MyPDF", &pythia, "plugin.cmnd"); ``` -------------------------------- ### Demonstrate Flavour Rope Hadronization with PYTHIA C++ Source: https://pythia.org/latest-manual/examples/main442 This C++ code uses the PYTHIA event generator to demonstrate the flavour rope hadronization model. It initializes the generator, sets various parameters for soft QCD and rope hadronization, and then generates events. The code counts specific particles and fills histograms to visualize their ratios as a function of event multiplicity. It requires the PYTHIA library to be installed and linked. ```cpp // main442.cc is a part of the PYTHIA event generator. // Copyright (C) 2025 Torbjorn Sjostrand. // PYTHIA is licenced under the GNU GPL v2 or later, see COPYING for details. // Please respect the MCnet Guidelines, see GUIDELINES for details. // Authors: // Christian Bierlich // Keywords: // Hadronization // Colour reconnection // Rope hadronization // This program provides a demonstration of the flavour rope model supplied // in the Rope Hadronization framework. It produces four histograms // showing the ratio of respectively K^0_s, Lambda_0, Cascade and Omega ^- // to pions as function of event multiplicity. // No kind of Levy-Tsallis fitting, triggering or similar is done // is this simple demonstration analysis. It should therefore not // be taken as anything but a proof of concept. #include "Pythia8/Pythia.h" using namespace Pythia8; //========================================================================== int main() { // Generator. Process selection. LHC initialization. Pythia pythia; pythia.readString("Beams:eCM = 7000."); pythia.readString("SoftQCD:nonDiffractive = on"); // Enabling flavour ropes, setting model parameters. // The model is still untuned. These parameter values // are chosen for illustrative purposes. pythia.readString("Ropewalk:RopeHadronization = on"); pythia.readString("Ropewalk:doShoving = off"); pythia.readString("Ropewalk:doFlavour = on"); pythia.readString("Ropewalk:r0 = 0.5"); pythia.readString("Ropewalk:m0 = 0.2"); pythia.readString("Ropewalk:beta = 0.1"); // Enabling setting of vertex information. pythia.readString("PartonVertex:setVertex = on"); // Prevent unstable particles from decaying. pythia.readString("ParticleDecays:limitTau0 = on"); pythia.readString("ParticleDecays:tau0Max = 10"); // If Pythia fails to initialize, exit with error. if (!pythia.init()) return 1; // Histograms. Hist pion("pions (mult)", 50, 10., 135.); Hist kaon("kaons (mult)", 50, 10., 135.); Hist lambda("lambdas (mult)", 50, 10., 135.); Hist xi("xi (mult)", 50, 10., 135.); Hist omega("omega (mult)", 50, 10., 135.); // Note: High statistics is needed to fill the high multiplicity end // of the histograms, especially for Omega. const int nEvent = 4000; // Begin event loop. Generate event. Skip if error. List first one. for (int iEvent = 0; iEvent < nEvent; ++iEvent) { if (!pythia.next()) continue; // Counters for particle species. int nCharged = 0, nPions = 0, nKaons = 0; int nLambdas = 0, nXis = 0, nOmegas = 0; // Event short notation. Event& event = pythia.event; for (int i = 0; i < event.size(); ++i){ Particle& p = event[i]; // Apply simple, particle level, cuts. if (p.isFinal() && abs(p.eta()) < 2.5 && p.pT() > 0.1 ) { if(p.isCharged()) ++nCharged; int absid = abs(p.id()); if(absid == 211) ++nPions; else if(absid == 310) ++nKaons; else if(absid == 3122) ++nLambdas; else if(absid == 3312) ++nXis; else if(absid == 3334) ++nOmegas; } } // Discard events with event multiplicity less than 10. if(nCharged < 10) continue; // Fill histograms. pion.fill( double(nCharged), double(nPions) ); kaon.fill( double(nCharged), double(nKaons) ); lambda.fill( double(nCharged), double(nLambdas) ); xi.fill( double(nCharged), double(nXis) ); omega.fill( double(nCharged), double(nOmegas) ); // End of event loop. } // Construct ratio histograms. Hist kp = kaon / pion; kp.title("kaon / pion (multiplicity)"); Hist lp = lambda / pion; lp.title("lambda / pion (multiplicity)"); Hist xp = xi / pion; xp.title("xi / pion (multiplicity)"); Hist op = omega / pion; op.title("omega / pion (multiplicity)"); // Statistics. Histograms. Done. pythia.stat(); cout << kp << lp << xp << op; return 0; } ``` -------------------------------- ### Streamlined LHEF Input with Command File (C++) Source: https://pythia.org/latest-manual/SampleMainPrograms This is a streamlined version of main122.cc, using two LHEF files ('ttbar.lhe' and 'ttbar2.lhe') as input, with the configuration specified in a '.cmnd' file. It demonstrates efficient handling of multiple LHEF inputs through command files. ```c++ main123.cc (was main13.cc) : a streamlined version of `main122.cc`, where two Les Houches Event Files (`ttbar.lhe` and `ttbar2.lhe`) successively are used as input in `main123.cmnd` file. ``` -------------------------------- ### PYTHIA User Example for POWHEG Merging Source: https://pythia.org/latest-manual/MatchingAndMerging A C++ user example demonstrating the integration and usage of POWHEG merging within PYTHIA. This example showcases how to configure and run simulations that utilize the POWHEG BOX framework. ```C++ // examples/main153.cc ``` -------------------------------- ### Separate Analysis Code into a Class (C++) Source: https://pythia.org/latest-manual/ExampleKeywords A C++ example that places all user analysis code into a separate class, distinct from the main program. It also shows how to set Higgs mass, width, and branching ratios manually. ```cpp /* main231.cc: put all user analysis code into a class of its own, separate from the main program, and provide the "cards file" name as a command-line argument. Also exemplifies how Higgs mass, width and branching ratios can be set by hand. */ // This is a placeholder for the actual code. The actual code would involve Pythia API calls, class definitions for analysis, and command-line argument handling. ``` -------------------------------- ### Settings XML Tag Example (XML) Source: https://pythia.org/latest-manual/SettingsScheme Provides an example of how settings might be represented in an XML tag, as referenced in the documentation. This example illustrates the structure for defining a setting, including its name, default value, and potentially its range. ```xml ``` -------------------------------- ### Tevatron Z Boson Spectrum - C++ Source: https://pythia.org/latest-manual/ExampleKeywords These C++ examples focus on studying the transverse momentum (pT) spectrum of Z bosons at the Tevatron. One example includes an option to display the results using Pyplot for visualization, while the other focuses solely on the spectrum calculation. ```cpp // main102.cc: a simple study of the pT spectrum of Z bosons at the Tevatron. // main112.cc: a simple study of the pT spectrum of Z bosons at the Tevatron, with Pyplot option for displaying the result, but otherwise equivalent with `main102.cc`. ``` -------------------------------- ### Study Colour Reconnection Models for Top Production (C++) Source: https://pythia.org/latest-manual/SampleMainPrograms Studies colour reconnection models for top production by setting up user hooks via `include/Pythia8Plugins/ColourReconnectionHooks.h`. It allows comparison with several models not included in the standard Pythia library. Requires Pythia and custom hook implementation. ```c++ /* * main362.cc (was main29.cc) : colour reconnection models studied for top production. */ #include "Pythia8/Pythia.h" #include "Pythia8Plugins/ColourReconnectionHooks.h" // Include custom hooks int main() { // Instantiate Pythia object Pythia pythia("main362.cmnd"); // Instantiate and set custom colour reconnection hooks // Example: userHooks = new MyColourReconnectionHooks(); // pythia.setHooks(userHooks); // Initialize simulation pythia.init(); // Event loop for (int i = 0; i < 100; ++i) { if (!pythia.next()) continue; // Analyze top production events with different colour reconnection models // ... } // Clean up custom hooks // delete userHooks; pythia.stat(); return 0; } ``` -------------------------------- ### Pythia Matching and Merging Schemes (C++) Source: https://pythia.org/latest-manual/ExampleKeywords This C++ example program demonstrates Pythia's various matching and merging schemes. The specific method employed is determined by the input `.cmnd` file, supporting configurations for MC@NLO, POWHEG, CKKW-L, MESS, UMEPS, UNLOPS, MLM, and FxFx merging. ```C++ /* main164.cc: general main program to use Pythia's matching and merging schemes. Which method is used is specified by the `.cmnd` input file: `main164mcatnlo.cmnd` for MC@NLO matching with Madgraph5_aMC@NLO, `main164powheg.cmnd` for POWHEG matching with POWHEG-BOX, `main164ckkwl.cmnd` for CKKW-L merging, `main164mess.cmnd` for Vincia's CKKW-L sector merging (MESS), `main164umeps.cmnd` for UMEPS merging, `main164unlops.cmnd` for UNLOPS merging, `main164mlm.cmnd` for MLM jet matching, `main164fxfx.cmnd` for FxFx merging. */ // Code for main164.cc would go here. ``` -------------------------------- ### Python Interface for Charged Multiplicity Study (Equivalent to main101.cc) Source: https://pythia.org/latest-manual/ExampleKeywords This Python script provides an interface equivalent to the C++ `main101.cc` example, focusing on the study of charged particle multiplicity for jet events. It serves as a minimal example demonstrating Pythia usage in Python. ```Python /* * main291.py: a Python interface equivalent to `main101.cc`, i.e. a minimal example. */ # Placeholder for actual Python code implementation. ``` -------------------------------- ### Rope Hadronization: Flavour Production (C++) Source: https://pythia.org/latest-manual/ExampleKeywords This C++ program, main442.cc, investigates the impact of the rope hadronization framework on flavour production. It allows users to observe how different flavour yields change when this specific hadronization model is employed. This is valuable for tuning models to experimental data related to particle flavour content. ```c++ #include #include "Pythia8/Pythia.h" int main(int argc, char **argv) { // Instantiate Pythia object Pythia pythia; // Read in pythia settings, ensuring rope hadronization is enabled pythia.readFile("main442.cmnd"); // Initialize Pythia if (!pythia.init()) { std::cerr << "Initialization failed!" << std::endl; return 1; } // Event generation loop for (int i = 0; i < 100; ++i) { // Generate event if (!pythia.next()) continue; // Analyze flavour production. This would involve iterating through // particles in the event record and counting different flavours. // Example: pythia.process.list(); // Illustrative } // Finalize pythia.stat(); return 0; } ``` -------------------------------- ### C++: Initialize SlowJet Clustering Setup Source: https://pythia.org/latest-manual/EventAnalysis The `setup` method initializes the clustering process by selecting particles, calculating initial distances, and finding the smallest distance. It takes an `Event` object as input. If the routine returns `false`, the setup failed, though this is not foreseen. ```cpp bool SlowJet::setup( const Event & event) ``` -------------------------------- ### Command-Line Steering and Parallelization (C++) Source: https://pythia.org/latest-manual/ExampleKeywords Allows steering Pythia from the command line, producing HepMC files, and enabling OpenMP parallelization. Further documentation is available via `./main224 --help`. Uses a `.cmnd` file for settings, illustrating DIRE usage. Implemented in C++. ```C++ main224.cc: allows to steer Pythia from the command line, can produce HepMC files, and allows for OpenMP parallelization. More documentation can be obtained by executing `./main224 --help`. The input file `main224.cmnd` further illustrates the use of DIRE. ```