exp1803_sim_BeamDetEloss.C
1 |
void exp1803_sim_BeamDetEloss(Int_t nEvents = 100) { |
---|---|
2 |
// --------------- Telescope T1 -------------------------------------------
|
3 |
Double_t T1Dl = 0.5; // [cm] |
4 |
Double_t T1PosZ = 10.; // [cm] |
5 |
Double_t T1D1Thick = 0.002; // [cm] |
6 |
Double_t T1D2Thick = 0.1; // [cm] |
7 |
Double_t T1Side = 6.2; // [cm] this parameter should coincide with SD1 side length from /db/QTelescope/QTelescopeParts.xml |
8 |
Double_t T1Aperture = 3.1; // [cm] |
9 |
// --------------- Telescope D1 -------------------------------------------
|
10 |
Double_t D1PosZ = 20.; // [cm] |
11 |
Double_t D1Thick = 0.03; // [cm] |
12 |
// --------------- BeamDet ------------------------------------------------
|
13 |
// Double_t BeamDetLToF = 1500.; // [cm]
|
14 |
Double_t BeamDetLToF = 150.; // [cm] |
15 |
Double_t BeamDetPosZToF = -50; // [cm] |
16 |
Double_t BeamDetLMWPC = 32.; // [cm] |
17 |
Double_t BeamDetPosZMWPC = -8; // [cm] |
18 |
// --------------- Beam start position ------------------------------------
|
19 |
Double_t beamStartPosition = -1600; // [cm] |
20 |
// --------------- Target -------------------------------------------------
|
21 |
Double_t targetH2Thickness = 0.4; // [cm] this parameter should coincide with target H2 thickness in /macro/geo/create_GadastEXP1803_geo.C |
22 |
//---------------------Files-----------------------------------------------
|
23 |
TString outFile= "sim.root";
|
24 |
TString parFile= "par.root";
|
25 |
TString workDirPath = gSystem->Getenv("VMCWORKDIR");
|
26 |
TString paramFileQTelescope = workDirPath |
27 |
+ "/db/QTelescope/QTelescopeParts.xml";
|
28 |
TString paramFileBeamDet = workDirPath |
29 |
+ "/db/BeamDet/BeamDetParts.xml";
|
30 |
TString targetGeoFileName = workDirPath + "/geometry/target.h2.geo.root";
|
31 |
TString gadastGeoFileName = workDirPath + "/geometry/partOfGadast.v1.geo.root";
|
32 |
TString ndGeoFileName = workDirPath + "/geometry/ND.geo.root";
|
33 |
TString magnetGeoFileName = workDirPath + "/geometry/magnet.geo.root";
|
34 |
// ------------------------------------------------------------------------
|
35 |
|
36 |
// ----- Timer --------------------------------------------------------
|
37 |
TStopwatch timer; |
38 |
timer.Start(); |
39 |
// ------------------------------------------------------------------------
|
40 |
|
41 |
// ----- Create simulation run ----------------------------------------
|
42 |
ERRunSim* run = new ERRunSim();
|
43 |
/** Select transport engine
|
44 |
* TGeant3
|
45 |
* TGeant4
|
46 |
**/
|
47 |
run->SetName("TGeant4"); // Transport engine |
48 |
run->SetOutputFile(outFile.Data()); // Output file
|
49 |
// ------------------------------------------------------------------------
|
50 |
|
51 |
// ----- Runtime database ---------------------------------------------
|
52 |
FairRuntimeDb* rtdb = run->GetRuntimeDb(); |
53 |
|
54 |
// ----- Create media -------------------------------------------------
|
55 |
run->SetMaterials("media.geo"); // Materials |
56 |
|
57 |
// ----- Create detectors ----------------------------------------------
|
58 |
FairModule* cave= new ERCave("CAVE"); |
59 |
cave->SetGeometryFileName("cave.geo");
|
60 |
run->AddModule(cave); |
61 |
|
62 |
// ----- Create target -------------------------------------------------
|
63 |
FairModule* target = new ERTarget("targetH2", kTRUE, 1); |
64 |
target->SetGeometryFileName(targetGeoFileName); |
65 |
run->AddModule(target); |
66 |
|
67 |
ERBeamDetSetup* setupBeamDet = ERBeamDetSetup::Instance(); |
68 |
setupBeamDet->SetXmlParametersFile(paramFileBeamDet); |
69 |
|
70 |
// ----- BeamDet parameters ----------------------------------------------
|
71 |
setupBeamDet->AddToF("ToF1", BeamDetPosZToF - BeamDetLToF); // |
72 |
setupBeamDet->AddToF("ToF1", BeamDetPosZToF); // BeamDet parts should be added in ascending order |
73 |
setupBeamDet->AddMWPC("MWPC1", BeamDetPosZMWPC - BeamDetLMWPC); // of Z-coordinate of part. |
74 |
setupBeamDet->AddMWPC("MWPC1", BeamDetPosZMWPC); // |
75 |
// //setupBeamDet->SetSensitiveTarget();
|
76 |
|
77 |
// ------BeamDet ----------------------------------------------------------
|
78 |
ERBeamDet* beamdet= new ERBeamDet("ERBeamDet", kTRUE,1); |
79 |
run->AddModule(beamdet); |
80 |
// ----- Create PrimaryGenerator --------------------------------------
|
81 |
|
82 |
FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
|
83 |
|
84 |
Double_t kinE_MevPerNucleon = 40.; |
85 |
// Int_t Z = 1, A = 3, Q = 1;
|
86 |
// TString ionName = "3H";
|
87 |
Int_t Z = 2, A = 6, Q = 2; |
88 |
TString ionName = "6He";
|
89 |
ERIonMixGenerator* generator = new ERIonMixGenerator(ionName, Z, A, Q, 1); |
90 |
Double32_t kin_energy = kinE_MevPerNucleon * 1e-3 * A; //GeV |
91 |
generator->SetKinE(kin_energy); |
92 |
generator->SetPSigmaOverP(0);
|
93 |
Double32_t sigmaTheta = 0.004*TMath::RadToDeg(); |
94 |
generator->SetThetaSigma(0, 0); |
95 |
// generator->SetThetaRange(0., 5.);
|
96 |
// generator->SetPhiRange(0, 360);
|
97 |
generator->SetBoxXYZ(0, 0, 0, 0, beamStartPosition); |
98 |
// generator->SpreadingOnTarget();
|
99 |
|
100 |
primGen->AddGenerator(generator); |
101 |
run->SetGenerator(primGen); |
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 |
// ----- Run simulation ------------------------------------------------
|
122 |
run->Run(nEvents); |
123 |
|
124 |
// ----- Finish -------------------------------------------------------
|
125 |
timer.Stop(); |
126 |
Double_t rtime = timer.RealTime(); |
127 |
Double_t ctime = timer.CpuTime(); |
128 |
std::cout << std::endl << std::endl; |
129 |
std::cout << "Macro finished succesfully." << std::endl;
|
130 |
std::cout << "Output file is sim.root" << std::endl;
|
131 |
std::cout << "Parameter file is par.root" << std::endl;
|
132 |
std::cout << "Real time " << rtime << " s, CPU time " << ctime |
133 |
<< "s" << std::endl << std::endl;
|
134 |
} |