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 // Suitable for mass production (see condor.sh and script.sh scripts);
4 //
5 
6 // May want to hook up the calorimeters later (very slow though);
7 //#define _WITH_CALORIMETERS_
8 
9 void simulation(unsigned seed = 0x12345678, int id = 0, int nEvents = 2000)
10 {
11  int nOffset = id * nEvents;
12  printf("My ID: %4d -> offset %6d\n", id, nOffset);
13 
14  // Load basic libraries;
15  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
16 
17  TString SimEngine = "TGeant3";
18 
19  // Create simulation run manager; use GEANT3 for tracking excercises here;
20  EicRunSim *fRun = new EicRunSim(SimEngine);
21  fRun->SetOutputFile("simulation.root");
22  fRun->SetSeed(seed);
23 
24  // Beam pipe;
25  fRun->AddModule(new EicDummyDetector("BEAMPIPE", "BEAMPIPE/beampipe.root"));
26 
27  // Silicon detectors;
28  fRun->AddModule(new EicMaps("VST", "MAPS/vst-v01.0-ss.root", qVST));
29  fRun->AddModule(new EicMaps("FST", "MAPS/fst-v01.0-ss.root", qFST));
30  fRun->AddModule(new EicMaps("BST", "MAPS/bst-v01.0-ss.root", qBST));
31 
32  // GEM disks;
33  fRun->AddModule(new EicGem ("FGT", "GEM/fgt-v01.0.root", qFGT));
34  fRun->AddModule(new EicGem ("BGT", "GEM/bgt-v01.0.root", qBGT));
35 
36  // TPC;
37  fRun->AddModule(new EicTpc ( "TPC/tpc-v01.0-ns.root"));
38 
39 #ifdef _WITH_CALORIMETERS_
40  //fRun->AddModule(new EicCalorimeter("BEMC", "ECAL/bemc-v01.0-ns.root", qBEMC));
41  fRun->AddModule(new EicCalorimeter("CEMC", "ECAL/cemc-v00.0-ss.root", qFEMC));
42  fRun->AddModule(new EicCalorimeter("FEMC", "ECAL/femc-v00.0-ss.root", qFEMC));
43 
44  fRun->AddModule(new EicCalorimeter("FHAC", "HCAL/fhac-v00.0-fs.root", qFHAC));
45  fRun->AddModule(new EicCalorimeter("BHAC", "HCAL/bhac-v00.0-fs.root", qBHAC));
46 #endif
47 
48  // Create and set up physics Event Generator; in a mass production mode can be
49  // a huge file which will be split between different nodes;
50  {
51  // Input ASCII file name (PYTHIA 20x250 GeV, Q^2>0.8 cut applied;
52  TString evFile = "../pythia.ep.20x250.5Mevents.1.RadCor=0.Q2-0.8..100k-lines.txt";
53 
54  // An interface to eic-smear (which is able to import PYTHIA, DJANGOH, ... files);
55  EicEventGenerator* evtGen = new EicEventGenerator(evFile.Data());
56  // Select primary electrons only; ignore all the rest;
57  evtGen->SelectPdgCode(11);
58  evtGen->SelectLeadingParticle();
59 
60  evtGen->SkipFewEvents(nOffset);
61  evtGen->RestrictEventChunkSize(nEvents);
62 
63  fRun->AddGenerator(evtGen);
64  }
65 
66  // Create and set up Apr'2016 solenoid field;
67  fRun->AddField(new PndSolenoidMap("SolenoidMap8", "R"));
68 
69  // Initialize and run the simulation; exit at the end;
70  fRun->Init();
71  if (SimEngine.EqualTo("TGeant4"))
72  // Assume, that want a (more or less) fair calorimeter simulation in this case;
73  ((TGeant4*)gMC)->ProcessGeantCommand("/mcPhysics/rangeCuts 0.01 mm");
74  fRun->Run(nEvents);
75 } // simulation()