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  fRun->AddModule(new EicDetector("IP", "./ip-sphere.root", qDUMMY, qMergeStepsInOneHit));
21 
22  // "FWDST" name here (case-insensitive) should match the respective name
23  // in the tracker.C script used to create the detector; one can actually
24  // create more than one tracking detector this way, and as long as their names differ
25  // (and physical locations do not overlap), all the simulation/digitization/reconstruction
26  // scheme will work (including Kalman filter track fitting); qMergeStepsInOneHit as a
27  // last parameter means that if particle makes more than one step in silicon, they will
28  // be merged together and yield only one hit; be aware that the simulation.root output
29  // file will contain 1) a full description of the actual geometry, 2) reference to a
30  // magnetic field map, therefore bookkeeping of the detector configuration is done
31  // "automatically" and no other manual input in either digitization.C or reconstruction.C
32  // scripts is required;
33  fRun->AddModule(new EicDetector("FWDST", "./fwdst.root", qDUMMY, qMergeStepsInOneHit));
34 
35  // Create and set up (Box) Event Generator;
36  {
37  int PDG = 211; // pi-
38  double pmin = 9.0, pmax = 11.0, theta = 5.0; // [9..11] GeV/c @ 5 degrees polar angle
39 
40  EicBoxGenerator* boxGen = new EicBoxGenerator(PDG);
41  // Define momentum range and theta; the rest is default: 2pi range in phi,
42  // primary vertex location (0,0,0) with no smearing;
43  boxGen->SetMomentumRange(pmin, pmax);
44  boxGen->SetTheta(theta);
45 
46  fRun->AddGenerator(boxGen);
47  }
48 
49  // Create and set up Elmer-based Apr'2016 solenoid magnetic field (binary
50  // file "input/SolenoidMap8.root");
51  fRun->AddField(new PndSolenoidMap("SolenoidMap8", "R"));
52 
53  // Initialize and run the simulation; exit at the end;
54  fRun->Run(nEvents);
55 } // simulation()