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/io/tree/JetEvent.h,cxx to execute the script, do
#ifdef JETS_SECOND_RUN
void write(
Int_t nev=100)
{
TFile f(
"JetEvent.root",
"recreate");
auto 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->Write();
}
void read()
{
T->SetBranchAddress("event", &event);
T->GetEntry(ev);
if (ev)
continue;
std::cout << " Event: "<< ev
<< " Jets: " << event->GetNjet()
<< " Tracks: " << event->GetNtrack()
<< " Hits A: " << event->GetNhitA()
<< " Hits B: " << event->GetNhitB() << std::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]);
T->GetEntry(rev);
}
}
}
{
write(nev);
read();
pileup(npileup);
}
#else
void tree130_jets(
Int_t nev = 100,
Int_t npileup = 200)
{
gROOT->ProcessLine(
".L " + tutdir +
"/io/tree/JetEvent.cxx+");
gROOT->ProcessLine(
"#define JETS_SECOND_RUN yes");
gROOT->ProcessLine(
"#include \"" __FILE__
"\"");
gROOT->ProcessLine(
"jets(100, 200, true)");
}
#endif
int Int_t
Signed integer 4 bytes (int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
long long Long64_t
Portable signed long integer 8 bytes.
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
A TTree represents a columnar dataset.
- Author
- Rene Brun
Definition in file tree130_jets.C.