Dear ROOT experts,
I have trouble with TTree,
Can experts look at this , please?
I created two branches
tree->Branch("north","TEvent",&north);
tree->Branch("south","TEvent",&south);
( same class but different branch names )
( TEvent class has a single valuable named "val" )
When I tried to Scan them , I did like this,
tree->Scan("north.val")
tree->Scan("south.val")
but the "north." "south." didn't work.
these commands always return "north.val" value.
with tree->SetBranchAddress and tree->GetEntry,
I can get correct values.
only Draw and Scan functions failed to distinguish
these valuables which has exactly the same name but
different branch names.
Best Regards,
Kazuya
------------------------------
I'm using ROOT Version 3.05/07 8 August 2003
The following are the source files.
TEvent.h
TEvent.C
TEventLinkDef.h
Makefile
test.C
rootlogon.C
------------------------------- SCREEN SHOT
root [0] .x test.C
root [1] tree->Scan("north.val")
************************
* Row * north.val *
************************
* 0 * 1 *
* 1 * 1 *
* 2 * 1 *
************************
(Int_t)3
root [2] tree->Scan("south.val")
************************
* Row * south.val *
************************
* 0 * 1 *
* 1 * 1 *
* 2 * 1 *
************************
(Int_t)3
----------------------------------- END OF SCREEN SHOT
-----TEvent.h-----
#ifndef __TEVENT_H
#define __TEVENT_H
#ifndef __CINT__
#include "TObject.h"
#endif
class TObject;
class TEvent : public TObject
{
int val;
public:
TEvent(){}
~TEvent(){}
void SetVal(int _val) { val = _val; }
int GetVal(){return val;}
ClassDef( TEvent , 1 )
};
#endif
---- TEvent.C ----
#include "TEvent.h"
ClassImp( TEvent )
----- test.C ----
TTree *tree;
TEvent *south;
TEvent *north;
void test()
{
TEvent t;
north = new TEvent();
south = new TEvent();
tree = new TTree("testtree","testtree");
tree->Branch("north","TEvent",&north,3200,99);
tree->Branch("south","TEvent",&south,3200,99);
north->SetVal(1);
south->SetVal(0);
tree->Fill();
tree->Fill();
tree->Fill();
}
------ rootlogon.C ----
{
gSystem->Load("libTEvent.so");
}
---- TEventLinkDef.h ---
#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class TEvent;
#endif
--- Makefile ---
ROOTCFLAGS := $(shell root-config --cflags)
ROOTLIBS := $(shell root-config --libs)
ROOTGLIBS := $(shell root-config --glibs)
CXXFLAGS = $(ROOTCFLAGS)
LD = g++
PACKAGE = TEvent
ROOTLIBS = $(shell root-config --libs)
LDFLAGS = -O
SOFLAGS = -shared
HDRFILES = TEvent.h
ADDITIONAL_SOURCES = TEventDict.C
SO = lib$(PACKAGE).so
$(SO) : $(PACKAGE).C $(ADDITIONAL_SOURCES) $(HDRFILES)
$(CXX) $(CXXFLAGS) -g -o $@ -shared $< $(ADDITIONAL_SOURCES) $(LDFLAGS)
.PHONY: clean
TEventDict.C: TEvent.h TEventLinkDef.h
@echo "Generating ROOT Dictionnary ..."
rootcint -f $@ -c $(CINTINCS) $^
clean:
rm -f $(SO) *Dict*
---------------------------
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:17 MET