Difference between revisions of "ParticleSimulationEicRoot"

From EIC
Jump to navigation Jump to search
Line 3: Line 3:
  
 
== Generating Particles on the Fly ==
 
== 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.  Insert the below code snippet into a script to implement the particle generation.
+
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 and configure the simulation run manager;
+
   // Create the simulation run manager; use GEANT3 transport;
   FairRunSim *fRun = new FairRunSim();
+
   EicRunSim *fRun = new EicRunSim("TGeant3");
 
    
 
    
 
   // Create and set up (Box) Event Generator;
 
   // Create and set up (Box) Event Generator;
   FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
+
   {
  fRun->SetGenerator(primGen);
+
    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);
 +
   
 +
    fRun->AddGenerator(boxGen);
 +
  }
 
    
 
    
  FairBoxGenerator* boxGen = new FairBoxGenerator(PDG, 1);
+
   // Initialize and run the simulation; exit at the end;
  boxGen->SetPRange    ( pmin, pmin + dp);
 
  boxGen->SetPhiRange  (fimin, fimax);
 
  boxGen->SetThetaRange(thmin, thmin + dth);
 
 
 
  boxGen->SetXYZ(0., 0., 0.); // primary vertex; units are [cm];
 
  primGen->AddGenerator(boxGen);
 
 
 
   // Initialize the run;
 
  fRun->Init();
 
 
 
  // Run the simulation;
 
 
   fRun->Run(nEvents);
 
   fRun->Run(nEvents);
  
The parameters pmin, dp, fimin, fimax, thmin, dth can be changed to select the desired phase space in which particles are generated.  The particles are generated flat in this phase space.  The options in FairBoxGenerator(PDG, 1) correspond to the PDG code of the particle species to be generated and the number of those particles to be generated.
+
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 ==
 
== Importing Physics Simulations from External Sources ==

Revision as of 09:40, 29 July 2015

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);
   
   fRun->AddGenerator(boxGen);
 }
 
 // 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;
 FairRunSim *fRun = new FairRunSim();
 
 // Set the primary generator used by FairRoot;
 FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
 fRun->SetGenerator(primGen);
 
 // An interface to eic-smear (which is able to import PYTHIA, DJANGOH, ... files);
 EicEventGenerator* evtGen = new EicEventGenerator(evFile.Data());
 primGen->AddGenerator(evtGen);
 
 // Initialize the RUN
 fRun->Init();
 
 // Run the simulation;
 fRun->Run(nEvents);