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 // Crystal calorimeter simulation script;
4 //
5 
6 void simulation(unsigned nEvents = 1000)
7 {
8  // Create simulation run manager; use GEANT4 here;
9  auto fRun = new EicRunSim("TGeant4");
10  fRun->SetOutputFile("simulation.root");
11 
12  // "CALORIMETER" name here (case-insensitive) should match the respective name
13  // in calorimeter.C script used to create the detector; one can actually
14  // create more than one calorimeter this way, and as long as their names differ
15  // (and physical locations do not overlap), all the simulation/digitization/reconstruction
16  // scheme will work (clustering scheme will be limited to a given calorimeter though);
17  auto calo = new EicCalorimeter("CALORIMETER", (char*)"./calorimeter.root", qDUMMY);
18  // Declare both crystals and alveoles as GEANT sensitive volumes if want to
19  // check energy deposit leak into alveole material; volumes which will actually
20  // participate in clustering algorithm may be selected later in digitization script;
21  calo->DeclareGeantSensitiveVolume("CaloCrystal");
22  //calo->DeclareGeantSensitiveVolume("CaloCellAlveole");
23  fRun->AddModule(calo);
24 
25  // Create and set up (Box) Event Generator;
26  {
27  int PDG = 11; // electron
28  double momentum = 1.0, theta = 1.0; // 1 GeV/c @ 1 degree
29 
30  auto boxGen = new EicBoxGenerator(PDG);
31  boxGen->SetMomentum(momentum);
32  boxGen->SetTheta(theta);
33 
34  fRun->AddGenerator(boxGen);
35  }
36 
37  // Initialize and run the simulation; exit at the end;
38  fRun->Init();
39  // 10um shower particle range must be Ok for crystal calorimeter?;
40  ((TGeant4*)gMC)->ProcessGeantCommand("/mcPhysics/rangeCuts 0.01 mm");
41  fRun->Run(nEvents);
42 } // simulation()