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 void simulation(Int_t nEvents = 1000)
3 {
4  // Load basic libraries;
5  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
6 
7  // Create simulation run manager; use GEANT3 for tracking excercises here;
8  EicRunSim *fRun = new EicRunSim("TGeant3");
9  fRun->SetOutputFile("simulation.root");
10 
11  // Well, do not need secondaries in this simulation;
12  fRun->SuppressSecondaries();
13 
14  // "VTX" & "TPC" names here (case-insensitive) should match the respective names
15  // in vtx-builder.C and tpc-builder.C scripts used to create the detectors;
16  // qMergeStepsInOneHit as a last parameter means that if particle makes more than one
17  // step in silicon, they will be merged together and yield only one hit;
18  fRun->AddModule(new EicDetector("VTX", "./vtx.root", qDUMMY, qMergeStepsInOneHit));
19  // qOneStepOneHit as a last parameter means that hits will be produced for each
20  // GEANT step; gas medium has max.step of 1cm in media.geo, which makes sense for
21  // a *simplistic* TPC example (remember, we are only interested to obtain reasonable
22  // track fits from some combination of hits);
23  fRun->AddModule(new EicDetector("TPC", "./tpc.root", qDUMMY, qOneStepOneHit));
24 
25  // Create and set up (Box) Event Generator;
26  {
27  int PDG = 211; // pion
28  double momentum = 10.0, theta = 75.0; // 10 GeV/c @ 75 degrees
29 
30  EicBoxGenerator *boxGen = new EicBoxGenerator(PDG);
31  boxGen->SetMomentum(momentum);
32  boxGen->SetTheta(theta);
33 
34  fRun->AddGenerator(boxGen);
35  }
36 
37  // Hook up 3T constant field aligned with Z axis;
38  fRun->AddField(new PndSolenoidMap("SolenoidMap1", "R"));
39 
40  // Initialize and run the simulation; exit at the end;
41  fRun->Run(nEvents);
42 } // simulation()