Split level = 1 means no data written out...

From: Gordon Watts (Brown University) (gwatts@fnal.gov)
Date: Mon Oct 20 1997 - 01:46:17 MEST


Hi,
  I'm trying to write out a simple object to a file. When I have split
level set to 0 the object is written out just fine. When I set it to 1, all
the object's values are written out a zero.  I'm using WinNT 4.0 and root
1.03/04. The text output from the problem looks the same between the two.
Any clues? Do others generate files with a non zero split level on NT? Do
you remember if you had any trouble with it? :-)

  What follows:
	main.cpp -- Main writer program.
	MLQ_Event.h -- the event object that is being written out.
	MLQ_Event.h -- The header
	test.cpp -- A macro I use to read out the output file.

  The main program is built in C++ (msvc 5.0) and looks like the following.
When split level is 0, when you read in the first event and dump out the
event (using the Dump method) you see "10" for _temp, as you should. If you
change split level to 1, then _temp is
zero.

//==========================================================================
==
//
// main.cpp
//
//  This routine will read in a Greg ntuple and produce an output root file
that contains
// all the fits we are interested in.
//

#include "TROOT.h"
#include "TFile.h"
#include "TSystem.h"
#include "TTree.h"
#include "MLQ_Event.h"

#include <iostream.h>

int make_root_from_greg (Text_t *f_name);

main (int argc, char **argv)
{
	if (argc != 2) {
		cout << "Usage: " << argv[0] << " <ntuple-name>" << endl;
		return 1;
	}

	make_root_from_greg (argv[1]);
	return 0;
}
int make_root_from_greg (Text_t *f_name)
{
	TROOT simple ("simple", "Simple example.");
	gDebug = 1;

	//
	// Define the various varriables we need to access here
	//

	Int_t run;
	Int_t event_number;

	//
	// Open the output file, and define the event.
	//

	TFile output_file ("output.root", "RECREATE", "LQ Mass Ntuple");

	TTree *output_tree = new TTree ("T", "LQ Mass Tree (eejj)", 1024);

	MLQ_Event *event = 0;
	output_tree ->Branch ("event", "MLQ_Event", &event, 64 * 1024, 0);

	//
	// Loop over ntuple, processing
	//

	int nentries = 100;
	run = 0; event_number = 0;
	for (Int_t i=0; i<nentries;i++) {
		cout << "Run: " << run << " event: " << event_number <


< endl;
		
		//
		// Get the new event object up and going!
		//

		event = new MLQ_Event (10);

		//
		// Make sure to write it out!
		//

		output_tree -> Fill ();
		delete event;
	}

	//
	// Done!
	//
	output_file.Write();
	output_tree -> Print();
	output_file.Close();

	return 0;
}


   I also build a .dll that contains the definition of a
MLQ_Event:

//============================================================================
//
// MLQ_Event.h
//
//  A lq mass event
//

#ifndef __MLQ_Event__
#define __MLQ_Evnet__

#include "TObject.h"

class MLQ_Event : public TObject {

public:
	Int_t _temp;
public:
	MLQ_Event (void);
	MLQ_Event (int temp);
	~MLQ_Event (void);

	ClassDef(MLQ_Event,1) // Basic
event

};

#endif

//============================================================================
//
// MLQ_Event.cpp
//
//  Routines to implement the event dude.
//

#include "MLQ_Event.h"
#include "lq_jet.h"

ClassImp(MLQ_Event);

//
// MLQ_Event
//

MLQ_Event :: MLQ_Event (void)
: _temp(30)
{
}

MLQ_Event :: MLQ_Event (int temp)
: _temp(temp)
{
}

//
// ~MLQ_Event
//
//  Get rid of everything
//
MLQ_Event :: ~MLQ_Event (void)
{
};

  And a short macro to read out the first item in the
array.

//============================================================================
// test.cpp
{
	gSystem->Load("eejj_ntuple_objects.dll");
	TFile f("output.root");
	TBranch *b = T.GetBranch("event");

	MLQ_Event *event;
	b->SetAddress (&event);

	b->GetEvent (1);
	event->Dump();
}

  Thanks.

	Cheers,
		Gordon.



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