EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
simulation.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file simulation.C
1 
2 //
3 // Tracker simulation script;
4 //
5 
6 void simulation(Int_t nEvents = 1000)
7 {
8  // Load basic libraries;
9  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
10 
11  // Create the simulation run manager; use GEANT4 transport; may want to use
12  // "TGeant3" for comparison;
13  EicRunSim *fRun = new EicRunSim("TGeant4");
14  // Define the output file with the simulated tracks and GEANT hits;
15  fRun->SetOutputFile("simulation.root");
16 
17  // Well, do not need secondaries in this simulation;
18  fRun->SuppressSecondaries();
19 
20  // "FWDST" name here (case-insensitive) should match the respective name
21  // in the tracker.C script used to create the detector; one can actually
22  // create more than one tracking detector this way, and as long as their names differ
23  // (and physical locations do not overlap), all the simulation/digitization/reconstruction
24  // scheme will work (including Kalman filter track fitting); qMergeStepsInOneHit as a
25  // last parameter means that if particle makes more than one step in silicon, they will
26  // be merged together and yield only one hit; be aware that the simulation.root output
27  // file will contain 1) a full description of the actual geometry, 2) reference to a
28  // magnetic field map, therefore bookkeeping of the detector configuration is done
29  // "automatically" and no other manual input in either digitization.C or reconstruction.C
30  // scripts is required;
31  fRun->AddModule(new EicDetector("FWDST", "./fwdst.root", qDUMMY, qMergeStepsInOneHit));
32 
33  // Create and set up (Box) Event Generator;
34  {
35  int PDG = 211; // pi-
36  double pmin = 9.0, pmax = 11.0, theta = 5.0; // [9..11] GeV/c @ 5 degrees polar angle
37 
38  EicBoxGenerator* boxGen = new EicBoxGenerator(PDG);
39  // Define momentum range and theta; the rest is default: 2pi range in phi,
40  // primary vertex location (0,0,0) with no smearing;
41  boxGen->SetMomentumRange(pmin, pmax);
42  boxGen->SetTheta(theta);
43 
44  fRun->AddGenerator(boxGen);
45  }
46 
47  // Create and set up Elmer-based Apr'2016 solenoid magnetic field (binary
48  // file "input/SolenoidMap8.root");
49  fRun->AddField(new PndSolenoidMap("SolenoidMap8", "R"));
50 
51  // Initialize and run the simulation; exit at the end;
52  fRun->Run(nEvents);
53 } // simulation()