Go to the U of M home page
School of Physics & Astronomy
School of Physics and Astronomy Wiki

User Tools


computing:contrib:root:localdoc

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
computing:contrib:root:localdoc [2009/02/19 11:13] straitcomputing:contrib:root:localdoc [2009/06/01 15:47] (current) – more strait
Line 71: Line 71:
   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);
Line 83: Line 85:
     Loop(awesomedata);     Loop(awesomedata);
   }   }
 +
 +The class "yourdataobject" needs only contain the data and not any functions.
  
 === Use Good Names === === Use Good Names ===
Line 131: Line 135:
   // If you declared with '*' and 'new'   // If you declared with '*' and 'new'
   void IWantRandomNumbers(TRandom3 * laserfocus)   void IWantRandomNumbers(TRandom3 * laserfocus)
 +  
   // If you simply declared the object:   // If you simply declared the object:
-  // This copies the object so the sequence of random numbers will not be advanced in the calling function+  // This copies the objectthe sequence of random 
 +  // numbers will not be advanced in the calling function
   void IWantRandomNumbers(TRandom3 laserfocus)   void IWantRandomNumbers(TRandom3 laserfocus)
-  // This uses the object itself and so the sequence of random numbers **will** be advanced in the calling function+   
 +  // This uses the object itselfthe sequence of random 
 +  // numbers *will* be advanced in the calling function
   void IWantRandomNumbers(TRandom3 & laserfocus)   void IWantRandomNumbers(TRandom3 & laserfocus)
  
Line 194: Line 201:
 <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 ======
computing/contrib/root/localdoc.1235063610.txt.gz · Last modified: 2009/02/19 11:13 by strait