refactor: proton to mdt
This commit is contained in:
parent
a2ec7bf56c
commit
9fac823a78
|
@ -17,7 +17,7 @@
|
|||
#include <iostream>
|
||||
|
||||
#define f_PLOT 0
|
||||
#define f_PRINT 1
|
||||
#define f_PRINT 2
|
||||
|
||||
using namespace Garfield;
|
||||
|
||||
|
@ -30,11 +30,11 @@ const double tStep = 1;
|
|||
const int nbins = 10000;
|
||||
const int N = 1000;
|
||||
|
||||
bool readTransferFunction(Sensor& sensor) {
|
||||
bool readTransferFunction(Sensor& sensor, std::string filename) {
|
||||
std::ifstream infile;
|
||||
infile.open("mdt_CR_RC.txt", std::ios::in);
|
||||
infile.open(filename, std::ios::in);
|
||||
if (!infile) {
|
||||
std::cerr << "Could not read delta response function.\n";
|
||||
std::cerr << "Could not read response function.\n";
|
||||
return false;
|
||||
}
|
||||
std::vector<double> times;
|
||||
|
@ -124,8 +124,8 @@ int main(int argc, char* argv[]) {
|
|||
Sensor sensor;
|
||||
sensor.AddComponent(&cmp);
|
||||
sensor.AddElectrode(&cmp, "s");
|
||||
sensor.SetTimeWindow(-tStep / 2, tStep, nbins);
|
||||
readTransferFunction(sensor);
|
||||
sensor.SetTimeWindow(0, tStep, nbins);
|
||||
readTransferFunction(sensor, "mdt_CR_RC.txt");
|
||||
|
||||
TrackSrim proton;
|
||||
proton.SetSensor(&sensor);
|
||||
|
@ -162,8 +162,12 @@ int main(int argc, char* argv[]) {
|
|||
alpha.EnablePlotting(&driftView);
|
||||
#endif
|
||||
|
||||
double ek, px, py, dx, dy, dz;
|
||||
#if f_PRINT
|
||||
std::ofstream outfile;
|
||||
outfile.open("proton.txt", std::ios::out);
|
||||
#endif
|
||||
|
||||
double ek, rt, px, py, dx, dy, dz;
|
||||
for (int i = 0; i < N; i++) {
|
||||
#if f_PLOT
|
||||
driftView.Clear();
|
||||
|
@ -182,24 +186,28 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
// alpha.NewTrack(rTrack, rTrack, 0, 0, -1, 1, 0);
|
||||
|
||||
// sensor.IntegrateSignals();
|
||||
sensor.ConvoluteSignals();
|
||||
rt = riseTime(sensor) * 1e9;
|
||||
|
||||
#if f_PLOT
|
||||
cD->Clear();
|
||||
// cD->Clear();
|
||||
cellView.Plot2d();
|
||||
driftView.Plot(true, false);
|
||||
cD->Update();
|
||||
|
||||
// sensor.IntegrateSignals();
|
||||
sensor.ConvoluteSignals();
|
||||
signalView.SetSensor(&sensor);
|
||||
// signalView.PlotSignal("s", "tei");
|
||||
signalView.PlotSignal("s", "t");
|
||||
#endif
|
||||
|
||||
#if f_PRINT > 1
|
||||
printf("Position = (%.2f, %.2f), Ek = %.3f\n", px, py, ek);
|
||||
printf("Ek = %.3f, Rise Time = %.3f\n", ek, rt);
|
||||
printf("Position = (%.2f, %.2f), Direction = (%.2f, %.2f, %.2f)\n", px, py, dx, dy, dz);
|
||||
printf("Total Count = %d, Energy Deposit = %.3f, W = %.3f\n", ne, eDep, eDep / ne);
|
||||
#elif f_PRINT
|
||||
std::cout << eDep << " " << riseTime(sensor) * 1e9 << std::endl;
|
||||
#endif
|
||||
#if f_PRINT
|
||||
outfile << eDep << " " << rt << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
12
xmake.lua
12
xmake.lua
|
@ -34,14 +34,14 @@ target("Tube")
|
|||
add_linkdirs("/home/fox/DevKit/GPP/lib")
|
||||
add_packages("Geant4", "ROOT", "Garfield")
|
||||
set_installdir("$(projectdir)/")
|
||||
after_install(function (target)
|
||||
local installdir = target:installdir()
|
||||
os.cp("$(projectdir)/*.gas", path.join(installdir, "bin"))
|
||||
end)
|
||||
-- after_install(function (target)
|
||||
-- local installdir = target:installdir()
|
||||
-- os.cp("$(projectdir)/*.gas", path.join(installdir, "bin"))
|
||||
-- end)
|
||||
|
||||
target("Proton")
|
||||
target("MDT")
|
||||
set_kind("binary")
|
||||
add_files("proton.cpp")
|
||||
add_files("mdt.cpp")
|
||||
add_links("Garfield")
|
||||
add_linkdirs("/home/fox/DevKit/GPP/lib")
|
||||
add_packages("Geant4", "ROOT", "Garfield")
|
||||
|
|
Loading…
Reference in New Issue