Segmentation fault when use ViewGeometry::Plot3d()

Dear experts,

I was trying to set a geometry of my simple prototype of a drift chamber, using GeometrySimple and SolidBox. Also I filled He/IC4H10 for 90/10 by MediumMagboltz. It seems all fine with doing above, but I got a segmentation fault when I add the function ViewGeometry::Plot3d(). Please give me some advise where is the problem. Thanks in advance!

void SetupGeo(TString geomFile){
  fGeo = new GeometrySimple();
  
  SolidBox *box = new SolidBox(0,0,0,10,10,fSize_box/2);
  fGeo->AddSolid(box, fGas);

  fCompE_Field = new ComponentAnalyticField();
  fCompE_Field->SetGeometry(fGeo);

  const int senseHV = fHV;
  const int fieldHV = 0;

  TFile *ifile = new TFile(geomfile);
  TTree *itree = (TTree*)ifile->Get("t");
  double x,y;
  int type;
  itree->SetBranchAddress("x",&x);
  itree->SetBranchAddress("y",&y);
  itree->SetBranchAddress("type",&type);
  for (int i = 0; i<itree->GetEntries(); i++){
    itree->GetEntry(i);
    if (type==0){ // field wire
      fCompE_Field->AddWire( x,  y, d_field, fieldHV, Form("f%d",i), 147.42);
    }
    else if (type==1){ // sense wire
      fCompE_Field->AddWire( x,  y, d_sense, senseHV, Form("s%d",i), 147.42);
      fCompE_Field->AddReadout(Form("s%d",i));
      }
    }

  fCompE_Field->SetMagneticField(0,0,0);

  //view geometry
  ViewGeometry *geoView;
  geoView->SetGeometry(fGeo);
  geoView->Plot3d();
}

I think the problem is with this line

ViewGeometry *geoView;

which should probably read

ViewGeometry *geoView = new ViewGeometry();

Alternatively, you could write

ViewGeometry geoView;
geoView.SetGeometry(fGeo);
geoView.Plot3d();

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.