Patrick Marks | 1 Jun 2004 15:03
Picon

[ROOT] tfile->Write() kills other class members

Hello,

I'm working on a Visual c++ data acquistion program and am storing my
data to a root file.  An object, which does not inherit from a root
object manages the data taking, and contains pointers to a TTree,
TFile, the DAQ control structures, and a 'sync' struct written to by
another thread that controls the data taking.  THe control thread
inherits from TGMainFrame.  Everything works, data is written to my
root file. The problem is that when I call tfile->Close() or
tfile->Write() from the DAQ object it clobbers the other members of
the class.  Below is a brief outline of my code. Any ideas why writing
or closing the TFile interferes with my object -- the object ownership
rules don't seem to suggest that the objects will be owned by the
file, though i can't tell for sure.  Thanks for any help!

Patrick Marks

class MyGUI : TGMainFrame {

  MyDAQ *daq;
  struct sync *control;

}

void MyGUI::DoDAQ() {

  daq = new MyDAQ();
  control->status = START;
  // Some code to start MyDAQ::Run in a new thread

(Continue reading)

Ric Blacksten | 1 Jun 2004 16:11

[ROOT] Broader ROOT Applications?


ROOT Users,

In perusing the ROOT website and the Example Applications http://root.cern.ch/root/ExApplications.html), I only seem to see science applications.  On the one hand this is not surprising, since ROOT was developed for the physics research community.  But on the ohter hand it is surprising since it appears that ROOT is a very general and powerful toolkit for data analysis.

Although a physicist at the bachelor's level, I confess to having strayed from that path into a career in Operations Research and Applied Mathematics (with occassional forays into part time high school physics teaching).  So I'd be interested in applications of ROOT in fields such as sociology, manufacturing, business, defense, or engineering, particularly in the analysis of data from stochastic (event-sequenced) simulations.  If you have any leads to such applications I'd be most interested.

Cheers,
Ric Blacksten
Thomas Bretz | 1 Jun 2004 16:32
Picon

[ROOT] How to get x- and y-range of displayed histogram

Dear all,

I display a histogram, eg
TH1F h("", "", 10, 0, 1);
h.Fill(0.5);
h.Draw();

The displayed range in x I get calling:
h.GetXaxis()->GetXmin();
h.GetXaxis()->GetXmax();

Doing the  same for the y-axis fails. How do I get this range? (The aim 
is to draw a line from through the histogram)

Thanks in advance,
Thomas.

Rene Brun | 1 Jun 2004 17:21
Picon
Picon

Re: [ROOT] tfile->Write() kills other class members

Hi Patrick,

tfile->Write() should not touch your members in MyDAQ, UNLESS you write
files greater than 2GB. If this is the case, have a look at the IMPORTANT NOTE
 at:
http://root.cern.ch/root/htmldoc/TTree.html#TTree:ChangeFile

Rene Brun

Patrick Marks wrote:
> 
> Hello,
> 
> I'm working on a Visual c++ data acquistion program and am storing my
> data to a root file.  An object, which does not inherit from a root
> object manages the data taking, and contains pointers to a TTree,
> TFile, the DAQ control structures, and a 'sync' struct written to by
> another thread that controls the data taking.  THe control thread
> inherits from TGMainFrame.  Everything works, data is written to my
> root file. The problem is that when I call tfile->Close() or
> tfile->Write() from the DAQ object it clobbers the other members of
> the class.  Below is a brief outline of my code. Any ideas why writing
> or closing the TFile interferes with my object -- the object ownership
> rules don't seem to suggest that the objects will be owned by the
> file, though i can't tell for sure.  Thanks for any help!
> 
> Patrick Marks
> 
> class MyGUI : TGMainFrame {
> 
>   MyDAQ *daq;
>   struct sync *control;
> 
> }
> 
> void MyGUI::DoDAQ() {
> 
>   daq = new MyDAQ();
>   control->status = START;
>   // Some code to start MyDAQ::Run in a new thread
> 
> }
> 
> clas MyDAQ {
> 
>   TFile *tfile;
>   TTree *ttree;
>   MyEvent *ev;   // Inherits from TObject
>   struct sync *contol;
>  // Some DAQ related members...
> }
> 
> void MyDAQ::Run() {
> 
> Init();
> 
> while(CheckControl()){     // look at *control
>   GetData();  // Fills ev
>   ttree->Fill();
> }
> 
> tfile->Write();  // the sync & tfile member pointers are  changed to
> invalid ptrs by this line.
>                     // same thing happens if i call tfile->Close() instead
> 
> tfile->Close()                        // now this segfaults
> sync->status = STOPPED;   // or this does (whichever comes first)
> 
> }

Olivier Couet | 1 Jun 2004 17:57
Picon
Picon

Re: [ROOT] How to get x- and y-range of displayed histogram


Hi Thomas,

 I guess it is: 

 h.GetMaximum();
 h.GetMinimum();

 Cheers,      Olivier

On Tue, 1 Jun 2004, Thomas Bretz wrote:

> Dear all,
> 
> I display a histogram, eg
> TH1F h("", "", 10, 0, 1);
> h.Fill(0.5);
> h.Draw();
> 
> The displayed range in x I get calling:
> h.GetXaxis()->GetXmin();
> h.GetXaxis()->GetXmax();
> 
> Doing the  same for the y-axis fails. How do I get this range? (The aim 
> is to draw a line from through the histogram)
> 
> Thanks in advance,
> Thomas.
> 
> 

--

-- 
Org:    CERN - European Laboratory for Particle Physics.
Mail:   1211 Geneve 23 - Switzerland                     Mailbox: J25910      
E-Mail: Olivier.Couet <at> cern.ch                            Phone:   +41 22 7676522
WWW:    http://cern.ch/Olivier.Couet/                    Fax:     +41 22 7677155

Rene Brun | 1 Jun 2004 18:11
Picon
Picon

Re: [ROOT] How to get x- and y-range of displayed histogram

Thomas,

My guess is that you want to know the current frame coordinates.
Here is an example

Rene Brun

{
   TCanvas c1;
   TH1F h("", "", 10, 0, 1);
   h.Fill(0.5);
   h.Draw();
   c1.Update();
   //draw a line from the bottom right of the pad to the top left
   TLine line(c1.GetUxmax(),c1.GetUymin(),c1.GetUxmin(),c1.GetUymax());
   line.Draw();
}

Thomas Bretz wrote:
> 
> Dear all,
> 
> I display a histogram, eg
> TH1F h("", "", 10, 0, 1);
> h.Fill(0.5);
> h.Draw();
> 
> The displayed range in x I get calling:
> h.GetXaxis()->GetXmin();
> h.GetXaxis()->GetXmax();
> 
> Doing the  same for the y-axis fails. How do I get this range? (The aim
> is to draw a line from through the histogram)
> 
> Thanks in advance,
> Thomas.

mwxchetb | 1 Jun 2004 18:46

[ROOT] Inkjet, Laser & Copier Cartridges ~ Save up to 89%


Save up to 89% on Inkjet, Laser & Copier Supplies
Quality Products, with 100% Satisfaction Guarantee
Easy, Fast, Affordable Shipping Worldwide
Plenty of Payment Options to Meet YOUR Needs!

>> SPECIAL: FREE Shipping to US & Canada on Orders over $50 <<

Visit us on the web at http://www.excuria.net

 
>> Income Opportunity with No Startup Cost, Ask Us How <<

Visit us on the web at http://www.excuria.net/DealerInfo/

 
If you wish to contact us please visit our web site.

For instruction on how to be permanently remove from this
distribution system go to http://www.excuria.net/Remove/

Philippe Canal | 1 Jun 2004 19:16
Favicon

RE: [ROOT] tfile->Write() kills other class members

Hi,

> tfile->Write();  // the sync & tfile member pointers are  changed to

This should not have any effect on the validity of the pointer tfile.

However 'ttree->Fill()' might have an effect (See TTree::ChangeFile).
If you data set is large you may have to do

while(CheckControl()){     // look at *control
  GetData();  // Fills ev
  ttree->Fill();
}
tfile = ttree->GetFile();

Cheers,
Philippe.

-----Original Message-----
From: owner-roottalk <at> pcroot.cern.ch
[mailto:owner-roottalk <at> pcroot.cern.ch]On Behalf Of Patrick Marks
Sent: Tuesday, June 01, 2004 8:03 AM
To: roottalk <at> pcroot.cern.ch
Subject: [ROOT] tfile->Write() kills other class members

Hello,

I'm working on a Visual c++ data acquistion program and am storing my
data to a root file.  An object, which does not inherit from a root
object manages the data taking, and contains pointers to a TTree,
TFile, the DAQ control structures, and a 'sync' struct written to by
another thread that controls the data taking.  THe control thread
inherits from TGMainFrame.  Everything works, data is written to my
root file. The problem is that when I call tfile->Close() or
tfile->Write() from the DAQ object it clobbers the other members of
the class.  Below is a brief outline of my code. Any ideas why writing
or closing the TFile interferes with my object -- the object ownership
rules don't seem to suggest that the objects will be owned by the
file, though i can't tell for sure.  Thanks for any help!

Patrick Marks

class MyGUI : TGMainFrame {

  MyDAQ *daq;
  struct sync *control;

}

void MyGUI::DoDAQ() {

  daq = new MyDAQ();
  control->status = START;
  // Some code to start MyDAQ::Run in a new thread

}

clas MyDAQ {

  TFile *tfile;
  TTree *ttree;
  MyEvent *ev;   // Inherits from TObject
  struct sync *contol;
 // Some DAQ related members...
}

void MyDAQ::Run() {

Init();

while(CheckControl()){     // look at *control
  GetData();  // Fills ev
  ttree->Fill();
}

tfile->Write();  // the sync & tfile member pointers are  changed to
invalid ptrs by this line.
                    // same thing happens if i call tfile->Close() instead 

tfile->Close()                        // now this segfaults
sync->status = STOPPED;   // or this does (whichever comes first)

}

Valeri Fine | 1 Jun 2004 21:39
Favicon

[ROOT] ROOT version from the CVS HEAD


Hello ROOT team,
Is there any convention to define whether the ROOT source code coming 
from ROOT CVS HEAD?

At the moment the ROOT version is provided by "RVersion.h". 
However that doesn't help just one wants to play with ROTO from CVS as
well.

Some dedicated CPP macro would have allowed distinguishing the ROOT from
the CVS HEAD at the compile time.

  Something like

RVersion.h:
  #define ROOT_SOURCE_HEAD

The problem is the ROOT interfaces (see TCanvasImp class for example)
from CVS HEAD and from ROOT 4.00.04 are not compatible and this leads to
the compilation error.

To avoid this I need to be able to add into my code

  #if defined(ROOT_SOURCE_HEAD) ||  (ROOT_VERSION_CODE >
ROOT_VERSION(4,00,4))
      virtual UInt_t GetWindowGeometry(){ return 0;}
  #else
      virtual void GetWindowGeometry(){}
  #endif

I would appreciate any other solution to distinguish the source of the
interface pragmatically without the "manual editing"

  Thank you,

Valeri Fine                          
Brookaven National Laboratiory
P.O.Box 5000
Upton, NY 11973-5000
-----
Phone: +1 631 344 7806
Fax:   +1 631 344 4206
E-mail: fine <at> bnl.gov 


Gmane