Usage of a Tree using the JetEvent class.
The JetEvent class has several collections (TClonesArray) and other collections (TRefArray) referencing objects in the TClonesArrays. The JetEvent class is in $ROOTSYS/tutorials/tree/JetEvent.h,cxx to execute the script, do
#ifdef JETS_SECOND_RUN
void write(
Int_t nev=100) {
TFile f(
"JetEvent.root",
"recreate");
TTree *T =
new TTree(
"T",
"Event example with Jets");
T->Branch(
"event",
"JetEvent",&
event,8000,2);
for (
Int_t ev=0;ev<nev;ev++) {
event->Build();
T->Fill();
}
T->Print();
T->Write();
}
void read() {
T->SetBranchAddress(
"event", &
event);
if (ev) continue;
cout << " Event: "<< ev
<< " Jets: " << event->GetNjet()
<< " Tracks: " << event->GetNtrack()
<< " Hits A: " << event->GetNhitA()
<< " Hits B: " << event->GetNhitB() << endl;
}
}
void pileup(
Int_t nev=200) {
for (loop=0;loop<LOOPMAX;loop++) events[loop] = 0;
if (ev%10 == 0) printf("building pileup: %lld\n",ev);
for (loop=0;loop<LOOPMAX;loop++) {
T->SetBranchAddress(
"event", &events[loop]);
}
}
}
write(nev);
read();
pileup(npileup);
}
#else
gROOT->ProcessLine(
".L " + tutdir +
"/tree/JetEvent.cxx+");
gROOT->ProcessLine(
"#define JETS_SECOND_RUN yes");
gROOT->ProcessLine(
"#include \"" __FILE__
"\"");
gROOT->ProcessLine(
"jets(100,200,true)");
}
#endif
R__EXTERN TRandom * gRandom
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
A TTree represents a columnar dataset.
- Author
- Rene Brun
Definition in file jets.C.