
void  BX ( Double_t &K){
 return pamfield->GetBX((float *)K)
}

void Field(){
  TString PL = gSystem->Getenv("PAM_LIB");
  gSystem->Load(PL+"/libyoda.so");
  gSystem->Load(PL+"/libDarthVader.so");
  gSystem->Load(PL+"/libPamLevel2.so");
  TString Calib=gSystem->Getenv("PAM_CALIB");
  TrkLevel2* pamfield = new TrkLevel2();
  pamfield->LoadField(Calib+"/trk-param/field_param-0/");
  //Double_t K[3]=(.0,.0,-30.);
  // pamfield->GetBX((float *)x);
  //  pamfield->GetBY((float *)x);
  //  pamfield->GetBZ((float *)x);
  const Int_t n = 200;
  Double_t x[n];
  Double_t Bx[n];
   Double_t By[n];
  Double_t Bz[n];
  Double_t K[3]=(.0,.0,.0);
  for (Int_t i=0; i<n; i++){
    x[i]=-100+i;
   
    
    //  K[0]=x[i];
    Bx[i]=pamfield->GetBX((float *)K);
    By[i]=pamfield->GetBY((float *)K);
    Bz[i]=pamfield->GetBZ((float *)K);
    //  delete K;
  }
   TGraph *bx = new TGraph(n,x,Bx);
     TGraph *by = new TGraph(n,x,By);
   TGraph *bz = new TGraph(n,x,Bz);
   TMultiGraph *mg = new TMultiGraph();
   mg->Add(bx);
   mg->Add(by);
   mg->Add(bz);
   TCanvas *c = new TCanvas("Mag","Magnetic Field",200,10,600,400);
   mg->Draw("AC");
}
