Dear experts
I am a freshman in garfieldpp.Some questions occured when I was using DriftRKF to calculate the driftline.I searched the question in the forum,although there are some similar situations,the ways to solve this error are unsuitable for me.Pic of error and my code is presented below:
#include <cstdlib>
#include <iostream>
#include <TROOT.h>
#include <TApplication.h>
#include "TCanvas.h"
#include "Garfield/MediumMagboltz.hh"
#include "Garfield/ComponentAnalyticField.hh"
#include "Garfield/Sensor.hh"
#include "Garfield/TrackHeed.hh"
#include "Garfield/DriftLineRKF.hh"
#include "Garfield/ViewField.hh"
#include "Garfield/ViewCell.hh"
#include "Garfield/ViewDrift.hh"
#include "Garfield/FundamentalConstants.hh"
#include "Garfield/Random.hh"
#include "Garfield/ViewMedium.hh"
#include "Garfield/ComponentFieldMap.hh"
using namespace Garfield;
int main(int argc, char* argv[])
{
//visualization
TApplication app("app",&argc,argv);
//Switch between cathod_gap(true) or sense_gap(false)
//bool flag = true;
//set distance of cathod wires sense wires gate wires[cm]
constexpr double gap_cathod = 0.2;
constexpr double gap_sense = 0.8;
//set wire diameters[cm]
constexpr double cathod_dia = 0.01; //cathod
constexpr double gate_dia = 0.01; //gate
constexpr double sense_dia = 0.0025; //sense
//Voltages Setting[V]
constexpr double vs = 1200.; //sense
constexpr double vg = -300.; //gate
//set gas
MediumMagboltz gas;
gas.SetComposition("ar",80,"co2",20);
gas.SetTemperature(293.15);
gas.SetPressure(637.55);
gas.WriteGasFile("ar_80_co2_20.gas");
gas.LoadGasFile("ar_80_co2_20.gas");
auto installdir = std::getenv("GARFIELD_INSTALL");
//read the ion mobility table from file
if(!installdir)
{std::cerr << "GARFIELD_INSTALL variable not set.\n";
return 1;
}
const std::string path = installdir;
gas.LoadIonMobility(path + "/share/Garfield/Data/IonMobility_Ar+_Ar.txt");
//set the electricfield
ComponentAnalyticField cmp;
cmp.SetMedium(&gas);
//add cathod wires
constexpr double xc = 0.;
constexpr double yc = 0.;
for(int i = 0;i <= 26;i++)
{
cmp.AddWire(xc+i*gap_cathod,yc,cathod_dia,vg,"cathod",70.,120.,8.62,1);
cmp.AddWire(xc+i*gap_cathod,yc+0.8,cathod_dia,vg,"cathod",70.,120.,8.62,1);
cmp.AddWire(xc+i*gap_cathod,yc+1.6,cathod_dia,vg,"cathod",70.,120.,8.62,1);
}
for(int j = 0;j <= 6;j++)
{
//add gate wires
cmp.AddWire(xc+j*gap_sense,yc+0.4,gate_dia,vg,"gate",70.,120.,8.62,1);
cmp.AddWire(xc+0.4+j*gap_sense,yc+1.2,gate_dia,vg,"gate",70.,120.,8.62,1);
//add Sense wires
cmp.AddWire(xc+0.4+j*gap_sense,yc+0.4,sense_dia,vs,"sense",70.,55.,19.35,1);
cmp.AddWire(xc+j*gap_sense,yc+1.2,sense_dia,vs,"sense",70.,55.,19.35,1);
}
//add the plane
cmp.AddPlaneY(-0.4,0.,"pad_window");
cmp.AddPlaneY(2.,0.,"pad_window");
//plot the cell
TCanvas *c1 = new TCanvas("c1","c1",600,600);
ViewCell cellView;
cellView.SetComponent(&cmp);
cellView.SetArea(-0.5,-1.5,5.5,3.1);
cellView.SetCanvas(c1);
cellView.Plot2d();
c1 -> Update();
//make a sensor
Sensor sensor;
sensor.AddComponent(&cmp);
sensor.AddElectrode(&cmp,"s");
sensor.SetArea(0.,0.,0.,5.2,1.6,2.);
//plot iopotential contours
ViewField fieldView;
TCanvas *c2 = new TCanvas("c2","c2",600,600);
fieldView.SetComponent(&cmp);
fieldView.SetArea(0.,0.,4.,1.6);
fieldView.SetVoltageRange(-300.,1200.);
fieldView.SetCanvas(c2);
// fieldView.PlotContour();
fieldView.Plot("e","colz");
c2 -> Update();
//set the driftline and tracks
TrackHeed track;
track.SetSensor(&sensor);
track.SetParticle("electron");
track.SetEnergy(1.e9);
DriftLineRKF drift;
drift.SetSensor(&sensor);
//plot driftline
ViewDrift driftView;
drift.EnablePlotting(&driftView);
track.EnablePlotting(&driftView);
driftView.SetCanvas(c1);
//simulate a track
//initialise of track
track.Initialise(&gas, true);
track.NewTrack(2.1,1.3,1.,0.,0,-1.,0.);
//retrieve the clusters
for(const auto& cluster : track.GetClusters())
{
for(const auto& electron : cluster.electrons)
{
drift.DriftElectron(electron.x,electron.y,electron.z,electron.t);
}
}
driftView.Plot(true,false);
c1 -> Update();
//viewmedium
TCanvas *c3 = new TCanvas("c3","c3",600,600);
ViewMedium mediumView;
mediumView.SetMedium(&gas);
mediumView.SetCanvas(c3);
mediumView.EnableAutoRangeX(false);
mediumView.SetRangeE(0.,1000.,false);
mediumView.PlotElectronVelocity('e');
c3 -> Update();
app.Run(true);
}