Both sides previous revisionPrevious revisionNext revision | Previous revision |
computing:contrib:root:localdoc [2009/02/19 11:16] – strait | computing:contrib:root:localdoc [2009/06/01 15:47] (current) – more strait |
---|
void Loop(TTree * awesomedata) | void Loop(TTree * awesomedata) |
{ | { |
| yourdataobject * onedatum = 0; |
| awesomedata->SetBranchAddress("yourdataobject", &onedatum); |
for(int i = 0; i < awesomedata->GetEntries(); i++){ | for(int i = 0; i < awesomedata->GetEntries(); i++){ |
awesomedata->GetEntry(i); | awesomedata->GetEntry(i); |
Loop(awesomedata); | Loop(awesomedata); |
} | } |
| |
| The class "yourdataobject" needs only contain the data and not any functions. |
| |
=== Use Good Names === | === Use Good Names === |
<code>printrandomnumber 17 datafile.root</code> | <code>printrandomnumber 17 datafile.root</code> |
| |
This has two big advantages. First, you do not need to type all of those quotation marks and parentheses. Second, your compiled program can run on machines that don't have ROOT installed. Third, your code is less likely to stop working when the ROOT version changes. Fourth, it probably runs faster because it doesn't have all the overhead of running root itself. Fifth, your code looks much more like the ordinary C++ that most programmers are familiar with. Ok, more than two. | This has two big advantages. First, you do not need to type all of those quotation marks and parentheses. Second, your compiled program can run on machines that don't have ROOT installed. Third, your code is less likely to stop working when the ROOT version changes. Fourth, it probably runs faster because it doesn't have all the overhead of running root itself. Fifth, your code looks much more like the ordinary C++ that most programmers are familiar with. Sixth, the compile error messages from g++ are **much** more helpful than those from the ROOT compiler. Ok, more than two. |
| |
====== Making Attractive Plots ====== | ====== Making Attractive Plots ====== |