# Difference between revisions of "ParticleSimulationEicRoot"

## Simulating Particle in EicRoot

There are many existing example scripts for simulating particles in EicRoot. A user has some options. One can generate particles on the fly using the box generator (which will generate one species of particle flat in the specified phase space) or one can import particle simulations from other event generators such as PYTHIA, MILOU, etc. Details for each option can be found below.

## Generating Particles on the Fly

You can simulate particle on the fly send through the detector setup. This can be done using the FairRoot particle generator, which is wrapped up in the EicBoxGenerator module. Insert the below code snippet into a script to implement the particle generation.

 // Create the simulation run manager; use GEANT3 transport;
EicRunSim *fRun = new EicRunSim("TGeant3");

// Create and set up (Box) Event Generator;
{
int PDG = -211;                              // pion
double pmin = 9.0, pmax = 11.0, theta = 5.0; // [9..11] GeV/c @ 5 degrees

EicBoxGenerator* boxGen = new EicBoxGenerator(PDG);
boxGen->SetMomentumRange(pmin, pmax);
boxGen->SetTheta(theta);

}

// Initialize and run the simulation; exit at the end;
fRun->Run(nEvents);


The parameters pmin, pmax, theta can be changed to select the desired phase space in which particles are generated. The particles are generated flat in this phase space. The option in EicBoxGenerator(PDG) corresponds to the PDG code of the particle species to be generated.

## Importing Physics Simulations from External Sources

To import existing event simulations to push through the detector setup, one can use the functionality already existing in the eic-smear package. This means eicroot must be compiled with the eic-smear package (see the instructions here). Once this is done, insert the following code snippet into the simulation script:

 //Define the file containing the particle simulation
TString evFile = "event.root";

// Create the simulation run manager; use GEANT3 transport;
EicRunSim *fRun = new EicRunSim("TGeant3");

// An interface to eic-smear (which is able to import PYTHIA, DJANGOH, ... files);
EicEventGenerator* evtGen = new EicEventGenerator(evFile.Data());