RE: [ROOT] Problem writing data to TTrees in several TFiles

From: Philippe Canal (pcanal@fnal.gov)
Date: Tue Jun 10 2003 - 23:31:54 MEST


Hi John

The compilation problem can be solved by replacing
	#ifndef (__CINT__)
	#include <iostream>
	...
	#endif
by
	#if !defined(__CINT__) || defined(__MAKECINT__)
	#include <iostream>
	...
	#endif

After this change I could not reproduce your other problem (but then again
the tree in the example is empty).

My best guess is that the new tree (in your switch section) is not properly
recreated (i.e. one or more of the objects being read are
not re-connected to the new file).

Note that in the latest release, what you are trying to accomplish
is basically implemented by TTree::ChangeFile (see
http://root.cern.ch/root/html/TTree.html#TTree:ChangeFile )

Cheers,
Philippe.

-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Frankland John
Sent: Saturday, June 07, 2003 8:29 AM
To: pcanal@popserver1.fnal.gov
Subject: [ROOT] Problem writing data to TTrees in several TFiles


// Tried on: RedHat 7.3 (gcc2.96) and 8.0 (gcc3.2) with ROOT v.3.03/09 and
// 3.05/05 compiled from CVS image on 5th June 2003

Hello ROOTers

Attached is a simplified version of a script which we have been trying
to use
in order to read some simulated events, filter them through our detection
setup, and write the results in TTrees which we keep in TFiles on disk.
I have removed all reference to our own classes so that the example can
be tested anywhere - also demonstrating that the problem doesn't come from
our code !! ;-)

In order to limit the size of the ROOT files, we stop every 100000 events to
write the current tree to disk and close the current file, then open a
new file
with a new tree before continuing.

Compilation with ACLiC gives the following error:

root [0] .L Example.C+
Info in <TUnixSystem::ACLiC>: creating shared library
/home/john/lib//home/john/Desktop/Analysis/ROOT/escano/./Example_C.so
/home/john/lib/home/john/Desktop/Analysis/ROOT/escano/filejSOCOc.cxx: In
   function `int G__filejSOCOc__8_25(G__value*, const char*, G__param*,
int)':
/home/john/lib/home/john/Desktop/Analysis/ROOT/escano/filejSOCOc.cxx:92:
cannot
   convert `int**' to `TTree**' for argument `2' to `TFile*
OpenROOTFile(int,
   TTree**)'
g++:
/home/john/lib//home/john/Desktop/Analysis/ROOT/escano/./filejSOCOc.o:
No such file or directory
Error in <ACLiC>: Compilation failed!

Is this normal ?

Carrying on regardless, we added the "main()" that you can see commented
at the end of the file, compiled with g++:
g++ `root-config --cflags --libs` Example.C -o Example.exe
(no errors) and ran the resulting executable. It produced the following
output:

-rw-r--r--    1 john     users         29M Jun  6 20:02 xesn50run1_1.root
-rw-r--r--    1 john     users         76K Jun  6 21:28 xesn50run1_2.root
-rw-r--r--    1 john     users        126K Jun  6 22:53 xesn50run1_3.root
-rw-r--r--    1 john     users         66K Jun  7 00:17 xesn50run1_4.root
-rw-r--r--    1 john     users         71K Jun  7 01:41 xesn50run1_5.root
-rw-r--r--    1 john     users         74K Jun  7 03:04 xesn50run1_6.root
-rw-r--r--    1 john     users         83K Jun  7 04:27 xesn50run1_7.root
-rw-r--r--    1 john     users         70K Jun  7 05:49 xesn50run1_8.root
-rw-r--r--    1 john     users         66K Jun  7 07:29 xesn50run1_9.root
-rw-r--r--    1 john     users         64K Jun  7 08:53 xesn50run1_10.root

As you can see, although each file took about the same time to produce
(1h30),
only the first one contains any events, while the other files contain
empty trees.
In a small scale test we performed beforehand (read 100 events, changing
file
every 10 events) all the files/trees contained events. Can anybody see why
this should be ?

Thanks a lot for any advice.

--
John D. Frankland
Beam Coordinator
GANIL
B.P. 55027
14076 CAEN Cedex 05

tel: +33 (0)231454628
fax: +33 (0)231454665



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET