organizing directories in a root file

From: chris garcia (garcia.91@osu.edu)
Date: Mon Apr 26 1999 - 21:00:39 MEST


	i cannot seem to get my root files arranged the way i would like them to
be.  i have written a macro, which just writes some generic objects to a
file, and places them in certain directories.

	TFile *f = new TFile("dir.root", "RECREATE", "cdf root io file");
	f->cd();
	char *dirname[] = {"event1","event2","event3","event4","event5",
		"event6","event7","event8","event9","event10"};
	for (int i = 1; i <= 10; i++)
	{
		cevent2 *ch1 = new cevent2;
		ch1->met = i*100;
		f->mkdir(dirname[i-1]);
		f->cd(dirname[i-1]);
		ch1->Write("event");
		f->cd("/");
	}

this works out fine.  there is one "cevent2" object inside each directory.
however, if i try this outside the root enviroment, i get a vastly
different (and boggling result):  no objects are written, but the
directories exist, and now the "event1" directory has one subdirectory:
"event2"; "event2" has one subdirectory "event3"; etc.  the only thing i
have changed is now it is in a main function of a c++ program.  is there
some manipulative functions i am not using right, or is there a better way
to move around in file in non-interactive mode??
	
	#include <windows.h>
	#include "TFile.h"
	#include "cevent2_cint.h"
	int WINAPI WinMain(HANDLE hInstance, HANDLE hPrevInstance, 
				LPSTR lpCmdLine, int nCmdShow)
	{
		extern void InitGui();
		VoidFuncPtr_t initfuncs[] = { InitGui, 0 };
		TROOT fileio("fileio","Test of cdf i/o" ,initfuncs);		
		TFile *f = new TFile("dir.root", "RECREATE", "cdf root io file");
		f->cd();
		char *dirname[] = {"event1","event2","event3","event4","event5",
			"event6","event7","event8","event9","event10"};
		for (int i = 1; i <= 10; i++)
		{
			cevent2 *ch1 = new cevent2;
			ch1->met = (float)i*100;
			f->mkdir(dirname[i-1]);
			f->cd(dirname[i-1]);
			ch1->Write("event");
			f->cd("/");
		}
		return 1;
	}

i would *really* like to be able to write files that look like:

	(top)	|
		|-event1 |
			|-(assorted objects associated w/ event1)
		|
		|-event2 |
			|-(assorted objects associated w/ event2)
		|
		:
		:
		|-eventn |
			|-(assorted objects associated w/ eventn)

any help is, as always, GREATLY appreciated.  thanks!!
						chris

"i miss the comfort in being sad." k. cobain
"god... it's stocked!" j. kral
"the dumber people think you are, the more suprised they'll be when you kill 
	them." unknown
"if a tree falls in a forest, and noone is around, and it hits a mime, does
	anyone care?" g. larson
"'get your breakfast with the works'... but if we look closer, we see that it 
	also says 'the works is a beating so intense, you'll pray for death'" c.
o'brien
"you can never, ever, ask me to stop drinking." n. cage
"now, a pork chop is your friend." c. rock
"i'm not sick, but i'm not well" h. danger
"stop looking at me, swan!!" a. sandler
"great move...  should i have done that??...  i'm going to have to start
again." 7th guest
"warrior needs food badly" gaunlet
"where is it??" d. nukem
"my friend's got a girlfriend, and he hates that bitch, he tells me everyday.
	he says 'man i really gotta lose my chic, in the worst kind of way'..."
offspring
"i can see clearly now, the rain is gone.  i can see all obstacles in my
way..." j. nash
"since age twelve i've felt like i'm someone else, cause i hung my original
self from
	the top bunk with a belt... 99% of my life i was lied to..." eminem



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:32 MET