146 lines
4.2 KiB
C++
146 lines
4.2 KiB
C++
#include <TApplication.h>
|
|
#include <TCanvas.h>
|
|
#include <TROOT.h>
|
|
|
|
#include "Garfield/AvalancheMC.hh"
|
|
#include "Garfield/ComponentAnalyticField.hh"
|
|
#include "Garfield/DriftLineRKF.hh"
|
|
#include "Garfield/MediumMagboltz.hh"
|
|
#include "Garfield/Sensor.hh"
|
|
#include "Garfield/TrackSrim.hh"
|
|
#include "Garfield/ViewCell.hh"
|
|
#include "Garfield/ViewDrift.hh"
|
|
#include "Garfield/ViewField.hh"
|
|
#include "Garfield/ViewMedium.hh"
|
|
#include "Garfield/ViewSignal.hh"
|
|
|
|
#include <fstream>
|
|
#include <iostream>
|
|
|
|
using namespace Garfield;
|
|
|
|
int main(int argc, char* argv[]) {
|
|
TApplication app("app", &argc, argv);
|
|
|
|
MediumMagboltz gas;
|
|
gas.LoadGasFile("helium3_100atm_3000K.gas");
|
|
gas.LoadIonMobility("IonMobility_He+_He.txt");
|
|
|
|
gas.SetComposition("helium-3");
|
|
gas.SetPressure(10.0 * 760.);
|
|
gas.SetTemperature(300);
|
|
gas.SetFieldGrid(1e5, 1.35e5, 3, true);
|
|
gas.EnableThermalMotion();
|
|
gas.GenerateGasTable(10);
|
|
// gas.WriteGasFile("helium3_100atm_3000K.gas");
|
|
|
|
TCanvas* cM = new TCanvas("cM", "", 600, 600);
|
|
ViewMedium mediumView;
|
|
mediumView.SetMedium(&gas);
|
|
mediumView.SetCanvas(cM);
|
|
mediumView.PlotElectronVelocity('e');
|
|
// mediumView.PlotIonVelocity();
|
|
// mediumView.PlotHoleVelocity('e', true);
|
|
app.Run(kTRUE);
|
|
return 0;
|
|
|
|
ComponentAnalyticField cmp;
|
|
cmp.SetMedium(&gas);
|
|
|
|
const double rWire = 5e-3;
|
|
const double rTube = 2.54 / 2;
|
|
const double vWire = 1900.;
|
|
const double vTube = 0.;
|
|
cmp.AddWire(0., 0., 2 * rWire, vWire, "s", 30.);
|
|
cmp.AddTube(rTube, vTube, 0, "t");
|
|
cmp.AddReadout("s");
|
|
|
|
ViewField fieldView;
|
|
fieldView.SetComponent(&cmp);
|
|
fieldView.SetPlane(0, 0, 1, 0, 0, 0);
|
|
fieldView.SetArea(-0.5, -0.5, 0.5, 0.5);
|
|
fieldView.SetVoltageRange(0., 1000.);
|
|
fieldView.PlotContour("e");
|
|
// fieldView.PlotProfile(rWire, 0, 0, rTube, 0, 0, "e");
|
|
app.Run(kTRUE);
|
|
return 0;
|
|
|
|
const double tStep = 0.5;
|
|
Sensor sensor;
|
|
sensor.AddComponent(&cmp);
|
|
sensor.AddElectrode(&cmp, "s");
|
|
sensor.SetTimeWindow(-tStep / 2, tStep, 4000);
|
|
sensor.ClearSignal();
|
|
|
|
TrackSrim track;
|
|
track.SetSensor(&sensor);
|
|
track.ReadFile("proton_in_he3(gas).txt");
|
|
track.SetKineticEnergy(0.65e6);
|
|
|
|
// track.PlotEnergyLoss();
|
|
// track.PlotRange();
|
|
// track.PlotStraggling();
|
|
// track.Print();
|
|
|
|
AvalancheMC mc;
|
|
mc.SetSensor(&sensor);
|
|
mc.EnableSignalCalculation();
|
|
|
|
DriftLineRKF drift;
|
|
drift.SetSensor(&sensor);
|
|
drift.SetMaximumStepSize(5.e-4);
|
|
drift.EnableIonTail();
|
|
drift.EnableSignalCalculation();
|
|
|
|
TCanvas* cD = new TCanvas("cD", "", 600, 600);
|
|
ViewCell cellView;
|
|
ViewDrift driftView;
|
|
cellView.SetCanvas(cD);
|
|
cellView.SetComponent(&cmp);
|
|
driftView.SetCanvas(cD);
|
|
mc.EnablePlotting(&driftView);
|
|
track.EnablePlotting(&driftView);
|
|
|
|
int nc = 0, ne = 0;
|
|
double eDepSum = 0;
|
|
|
|
const double rTrack = 0.3;
|
|
track.NewTrack(rTrack, rTrack, 0, 0, -1, 1, 0);
|
|
for (const auto& cluster : track.GetClusters()) {
|
|
nc += 1;
|
|
ne += cluster.n;
|
|
eDepSum += cluster.energy;
|
|
|
|
mc.SetElectronSignalScalingFactor(cluster.n);
|
|
mc.AvalancheElectron(cluster.x, cluster.y, cluster.z, cluster.t);
|
|
mc.DriftIon(cluster.x, cluster.y, cluster.z, cluster.t);
|
|
|
|
int status;
|
|
const unsigned int np = mc.GetNumberOfElectronEndpoints();
|
|
double xe1, ye1, ze1, te1, xe2, ye2, ze2, te2;
|
|
for (unsigned int i = 0; i < np; ++i) {
|
|
mc.GetElectronEndpoint(i, xe1, ye1, ze1, te1, xe2, ye2, ze2, te2, status);
|
|
mc.DriftIon(xe1, ye1, ze1, te1);
|
|
}
|
|
|
|
// drift.SetIonSignalScalingFactor(cluster.n);
|
|
// drift.DriftIon(cluster.x, cluster.y, cluster.z, cluster.t);
|
|
// drift.SetElectronSignalScalingFactor(cluster.n);
|
|
// drift.DriftElectron(cluster.x, cluster.y, cluster.z, cluster.t);
|
|
}
|
|
|
|
printf("Cluster = %d, Total Count = %d, Energy Deposit = %.3f, W = %.3f\n", nc, ne, eDepSum, eDepSum / ne);
|
|
|
|
cD->Clear();
|
|
cellView.Plot2d();
|
|
driftView.Plot(true, false);
|
|
|
|
ViewSignal signalView;
|
|
sensor.IntegrateSignals();
|
|
signalView.SetSensor(&sensor);
|
|
signalView.PlotSignal("s", "tei");
|
|
|
|
app.Run(kTRUE);
|
|
return 0;
|
|
}
|