Re: [ROOT] Create my own class without compilation

From: Jayoung Wu (jayoung@glue.umd.edu)
Date: Tue Apr 03 2001 - 19:02:38 MEST


Thanks, Jacek.

I followed what RootDoc.html says but I still have the following error:
root [0]  .L Myclass.C
root [1] TFile *f = new TFile("jay.root","RECREATE");
root [2] TTree   *mytree = new TTree("MyT","Event Tree");
root [3] event = new Event();
root [4] Int_t bufsize = 256000;
root [5] Int_t split = bufsize /= 4; 
root [6] mytree->Branch("event", "Event", &event, bufsize,split);
Error in <TTree::BranchObject>: Cannot find class:Event

It seems not to recognize my class Event. Do you have any idea?

---
Thanks,
Jayoung

--------------------- Myclass.C ---------------------
class EventHeader {

private:
  Int_t              jEvtNum;
  ULong_t            jTimeSec;
  UShort_t           jTimeMsec;
  UShort_t           JEvtType;
  UShort_t           JSubType;
  UShort_t           jTrigType; 

public:
  EventHeader() : jEvtNum(0),  jTimeSec(0),  jTimeMsec(0), JEvtType(0),
JSubType(0),  jTrigType(0)  { }
  virtual ~EventHeader() {}
  void   Set(Int_t en, ULong_t ts, UShort_t tm, UShort_t et, UShort_t st,
	     UShort_t tt) { jEvtNum = en; jTimeSec = ts; jTimeMsec = tm;
	     JEvtType = et; JSubType = st; jTrigType = tt;}
  Int_t     GetEvtNum()    { return   jEvtNum; }
  ULong_t   GetTimeSec()   { return   jTimeSec;}
  UShort_t  GetTimeMsec()  { return   jTimeMsec;}
  UShort_t  GetEvtType()   { return   JEvtType;}
  UShort_t  GetSubType()   { return   JSubType;}
  UShort_t  GetTrigType()  { return   jTrigType;} 
}; 

//-------------------------------------------------------------------------
class Event {

private:
  EventHeader     jEvtHdr;

public:
  Event();
  virtual ~Event();
  void    SetHeader(Int_t en, ULong_t ts, UShort_t tm, UShort_t et,
		    UShort_t st, UShort_t tt);


}; 


Event::Event()
{

}

Event::~Event()
{

}

void Event::SetHeader(Int_t en, ULong_t ts, UShort_t tm, UShort_t et,
		    UShort_t st, UShort_t tt)
{
  jEvtHdr.Set(en,ts,tm,et,st,tt);

}

//////////////////////////////////////////////////////////////////////////
On Tue, 3 Apr 2001, Jacek M. Holeczek wrote:

> Hi,
> Please have a look at the ROOT User's Guide :
> 	http://root.cern.ch/root/RootDoc.html
> at the chapter :
> 	"CINT the C++ Interpreter" -> "A Script Containing a Class Definition"
> Hope this helps,
> Jacek.
> 
> 



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:41 MET