Re: Canvas is not shown.

Jayoung Wu (jayoung@glue.umd.edu)
Tue, 3 Mar 1998 13:17:39 -0500 (EST)


On Tue, 3 Mar 1998, Radovan Chytracek wrote:

> On Tue, 3 Mar 1998, Jayoung Wu wrote:
>
> >
> > Hi,
> > I tried to draw 1d histogram on canvas but canvas is not shown.
> > Is there something I missed in the following codes?
> >
> > These are part of my codes:
> > =======================================================
> > printf("Do you want to see tracking plot?(y/n)\n");
> > scanf("%s",&ans);
> > if (ans=='y') {
> What about:
>
> int ans;
> printf("Do you want to see tracking plot?(y/n): ");
> ans = getchar();
> ...
>
> Good Luck
>
> Radovan
>
>
>

It does not work either.
=============================================================
printf("Do you want to see tracking plot?(y/n)\n");
scanf("%s",&ans);
if (ans=='y') {
=============================================================
The above codes are fine. It seems that I miss something related to ROOT
in the following part:
// Create histogram
TH1F *layer1 = new TH1F("layer1","layer#1 profile",20,-25.,25.);

// Fill histogram
for(i=0; i<20; i++) layer1->Fill(2.5*(j-9)-1.25,yed[1][j]);

// Create a new canvas
TCanvas *c1 = new TCanvas("c1","Tracking of Incident Particle",
200,10,700,500);

c1->SetFillColor(42);
c1->GetFrame()->SetFillColor(21);
c1->GetFrame()->SetBorderSize(6);
c1->GetFrame()->SetBorderMode(-1);
layer1->Draw("cp");
c1->Modified();
c1->Update();

Of course I inclued such header files at the beginning:
#include "TROOT.h"
#include "TFile.h"
#include "TTree.h"
#include "TBranch.h"
#include "TObject.h"
#include "TH1.h"
#include "TCanvas.h"

---
Thanks,
Jayoung Wu