Re: ROOT question

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Wed, 22 Aug 2007 16:48:34 +0200


Use a TPolyLine3D and not a histogram. See code below

Rene Brun

void graph() {
  TCanvas *TPCView = new TCanvas("TPCView", "TPC View", 10, 10, 800, 800);   FILE * graph;
  graph = fopen("graph.dat", "r");
  char line[16];
  Float_t x, y, z;
  Int_t k;
  TView *view = TView::CreateView(1,0,0);   view->SetRange(-32.,32.,-26.,26.,-30., 30.);

  TPolyLine3D *pline = new TPolyLine3D(22);   for (k=0; k<22; k++)
   {

      fscanf(graph, "%f %f %f", &x, &y, &z);
      cout << x << "," << y << "," << z << endl;
      pline->SetPoint(k,x,y,z);

    }  

  pline->Draw();
}

Matthew E. Hogan wrote:
> Hi!
> I'm trying to graph a (presumably) helical data set, but so far
> all I'm getting it points, and not a connected curve.
>
> My code is:
>
> #include " TH3D.h"
> #include "TCanvas.h"
> #include <cstdlib>
> #include <stdio.h>
>
> gROOT->Reset();
>
> void graph() {
> TPCView = new TCanvas("TPCView", "TPC View", 10, 10, 800, 800);
> fHistExN023D = new TH3F("HistExN023D", "HistExN023D",
> 40.,-32.,32.,40.,-26.,26.,60.,-30., 30.);
> FILE * graph;
> graph = fopen("graph.dat", "r");
> char line[16];
> Float_t x, y, z;
> Int_t k;
>
> for (k=0; k<22; k++)
> {
> fscanf(graph, "%f %f %f", &x, &y, &z);
> cout << x << "," << y << "," << z << endl;
> fHistExN023D->Fill(x, y/10., z/10.);
> }
>
> fHistExN023D->Draw("C A L P ARR");
> }
>
> Is there something I'm doing wrong? Draw("C A L P ARR") looks just
> like Draw().
>
> Thanks!!!!!!!!
>
> -Matthew E. Hogan
>
> Graduate Research Assistant, Ohio University Department of Physics and
> Astronomy
> 251B Clippinger Research Laboratories
> Ohio University
> Athens, OH 45701-2979 USA
> [+1] (740) 593-0991
> http://www.phy.ohiou.edu/~hogan/ <http://www.phy.ohiou.edu/%7Ehogan/>
Received on Wed Aug 22 2007 - 16:48:40 CEST

This archive was generated by hypermail 2.2.0 : Fri Aug 24 2007 - 17:50:03 CEST