RTelescope_sim_test.C
1 |
//#include "FairBoxGenerator.h"
|
---|---|
2 |
//#include "FairIonGenerator.h"
|
3 |
|
4 |
using std::cout;
|
5 |
using std::endl;
|
6 |
|
7 |
void RTelescope_sim_test(Int_t nEvents = 10){ |
8 |
//---------------------Files-----------------------------------------------
|
9 |
TString outFile= "sim.root";
|
10 |
TString parFile= "par.root";
|
11 |
// ------------------------------------------------------------------------
|
12 |
|
13 |
// ----- Timer --------------------------------------------------------
|
14 |
TStopwatch timer; |
15 |
timer.Start(); |
16 |
// ------------------------------------------------------------------------
|
17 |
|
18 |
// ----- Create simulation run ----------------------------------------
|
19 |
FairRunSim* run = new FairRunSim();
|
20 |
/** Select transport engine
|
21 |
* TGeant3
|
22 |
* TGeant4
|
23 |
**/
|
24 |
run->SetName("TGeant4"); // Transport engine |
25 |
run->SetOutputFile(outFile.Data()); // Output file
|
26 |
// ------------------------------------------------------------------------
|
27 |
|
28 |
// ----- Runtime database ---------------------------------------------
|
29 |
FairRuntimeDb* rtdb = run->GetRuntimeDb(); |
30 |
// ------------------------------------------------------------------------
|
31 |
|
32 |
// ----- Create media -------------------------------------------------
|
33 |
run->SetMaterials("media.geo"); // Materials |
34 |
// ------------------------------------------------------------------------
|
35 |
|
36 |
// ----- Create detectors ----------------------------------------------
|
37 |
FairModule* cave= new ERCave("CAVE"); |
38 |
cave->SetGeometryFileName("cave.geo");
|
39 |
run->AddModule(cave); |
40 |
|
41 |
// ER NeuRad definition
|
42 |
/* Select verbosity level
|
43 |
* 1 - only standard logs
|
44 |
* 2 - Print points after each event
|
45 |
* 3 - - GEANT Step information
|
46 |
*/
|
47 |
Int_t verbose = 1;
|
48 |
ERRTelescope* RTelescope= new ERRTelescope("ERRTelescope", kTRUE,verbose); |
49 |
RTelescope->SetGeometryFileName("RTelescope.v3.geo.root");
|
50 |
run->AddModule(RTelescope); |
51 |
// ------------------------------------------------------------------------
|
52 |
|
53 |
// ----- Create PrimaryGenerator --------------------------------------
|
54 |
FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
|
55 |
|
56 |
//proton
|
57 |
Int_t pdgId = 2212; // proton beam |
58 |
Double32_t theta1 = 0; // polar angle distribution |
59 |
Double32_t theta2 = 0;
|
60 |
Double32_t kin_energy = 0.01; //GeV |
61 |
Double_t mass = TDatabasePDG::Instance()->GetParticle(pdgId)->Mass(); |
62 |
Double32_t momentum = TMath::Sqrt(kin_energy*kin_energy + 2.*kin_energy*mass); //GeV |
63 |
FairBoxGenerator* boxGen = new FairBoxGenerator(pdgId, 1); |
64 |
boxGen->SetThetaRange(theta1, theta2); |
65 |
boxGen->SetPRange(momentum, momentum); |
66 |
boxGen->SetPhiRange(0, 360); |
67 |
boxGen->SetBoxXYZ(2.,0.,2.,0.,-2.); |
68 |
|
69 |
//proton 2
|
70 |
// Int_t pdgId = 2212; // proton beam
|
71 |
// Double32_t theta1 = 0; // polar angle distribution
|
72 |
// Double32_t theta2 = 0;
|
73 |
Double32_t kin_energy_p2 = 0.01; //GeV |
74 |
Double_t mass_p2 = TDatabasePDG::Instance()->GetParticle(pdgId)->Mass(); |
75 |
Double32_t momentum_p2 = TMath::Sqrt(kin_energy_p2*kin_energy_p2 + 2.*kin_energy_p2*mass_p2); //GeV |
76 |
FairBoxGenerator* boxGen_p2 = new FairBoxGenerator(pdgId, 1); |
77 |
boxGen_p2->SetThetaRange(theta1, theta2); |
78 |
boxGen_p2->SetPRange(momentum, momentum); |
79 |
boxGen_p2->SetPhiRange(0, 360); |
80 |
boxGen_p2->SetBoxXYZ(1.,-3.8,1.,-3.8,-2.); |
81 |
|
82 |
//alpha
|
83 |
Int_t A = 4;
|
84 |
Int_t Z = 2;
|
85 |
Int_t Q = 2;
|
86 |
Double32_t theta1A = 0; // polar angle distribution |
87 |
Double32_t theta2A = 0;
|
88 |
Double32_t kin_energy_alpha = 0.07; //GeV |
89 |
Double_t massA = 3.727; |
90 |
Double32_t momentumAlpha = TMath::Sqrt(kin_energy_alpha*kin_energy_alpha + 2.*kin_energy_alpha*massA); //GeV |
91 |
Double_t xA = 1.;
|
92 |
Double_t yA = 3.;
|
93 |
Double_t zA = -2.;
|
94 |
FairIonGenerator *ionGen = new FairIonGenerator(Z, A, Q, 1, 0., 0., momentumAlpha, xA, yA, zA); |
95 |
|
96 |
primGen->AddGenerator(boxGen); |
97 |
// primGen->AddGenerator(boxGen_p2);
|
98 |
primGen->AddGenerator(ionGen); |
99 |
run->SetGenerator(primGen); |
100 |
// ------------------------------------------------------------------------
|
101 |
|
102 |
//-------Set visualisation flag to true------------------------------------
|
103 |
run->SetStoreTraj(kTRUE); |
104 |
|
105 |
//-------Set LOG verbosity -----------------------------------------------
|
106 |
FairLogger::GetLogger()->SetLogVerbosityLevel("LOW");
|
107 |
|
108 |
// ----- Initialize simulation run ------------------------------------
|
109 |
run->Init(); |
110 |
Int_t nSteps = -15000;
|
111 |
//gMC->SetMaxNStep(nSteps);
|
112 |
|
113 |
// ----- Runtime database ---------------------------------------------
|
114 |
Bool_t kParameterMerged = kTRUE; |
115 |
FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged);
|
116 |
parOut->open(parFile.Data()); |
117 |
rtdb->setOutput(parOut); |
118 |
rtdb->saveOutput(); |
119 |
rtdb->print(); |
120 |
// ---------------------------------------------------------
|
121 |
|
122 |
// ----- Run simulation ------------------------------------------------
|
123 |
run->Run(nEvents); |
124 |
|
125 |
// ----- Finish -------------------------------------------------------
|
126 |
//neuRad->WriteHistos();
|
127 |
timer.Stop(); |
128 |
Double_t rtime = timer.RealTime(); |
129 |
Double_t ctime = timer.CpuTime(); |
130 |
cout << endl << endl; |
131 |
cout << "Macro finished succesfully." << endl;
|
132 |
cout << "Output file is sim.root" << endl;
|
133 |
cout << "Parameter file is par.root" << endl;
|
134 |
cout << "Real time " << rtime << " s, CPU time " << ctime |
135 |
<< "s" << endl << endl;
|
136 |
} |