Example Using PROOF Lite

Here is a simple example on how to setup PROOF Lite to run the query on a Tree. We can start from the same example used during the Tree session, Exercise 7, which was using a Selector class to analyse the Tree. We will run the same Selector on the same Tree, but using PROOF Lite.

It is maybe better to re-create the Tree with much more entries. Here is the macro creating the Tree:

#include "TRandom.h"
#include "TFile.h"
#include "TTree.h"

void exampleTTree(const char * filename= "tree.root", int  n = 10000000) {

   TTree data("tree","Example TTree");
   double x, y, z, t;

// fill it with random data                                                                                                                                
   for (int i = 0; i<n; ++i) {
      x = gRandom->Uniform(-10,10);
      y = gRandom->Gaus(0,5);
      z = gRandom->Exp(10);
      t = gRandom->Landau(0,2);

// write in a file                                                                                                                                         
   TFile f(filename,"RECREATE");


Run the macro two times, for example do:

root [0] .x exampleTTree.C("tree_1.root",10000000);
root [0] .x exampleTTree.C("tree_2.root",10000000);

Afterwards, create and edit the Selector code and as in Exercise 7 to add the creation (booking), filling and analysing of the histogram. For PROOF you need also to add the histograms in the output list, in order to be merged at the end and returned for the user. To do that you add, after booking the histogram in MySelector::SlaveBegin:

myHistogram = new TH1D(.

Here is the complete Selector code which run for this example by making 4 histograms with the variables:

MySelector.h MySelector.C

And to run PROOF you can use then this simple macro, which makes a TChain and process it using Proof

void runProof(Bool_t on = kTRUE) {

   TChain * chain = new TChain("tree");
   if (on) {

   TStopwatch w; w.Start();

Topic attachments
I Attachment History Action Size Date Who Comment
C source code filec MySelector.C r1 manage 3.5 K 2013-03-04 - 18:30 LorenzoMoneta Selector file to be used to run the example
Header fileh MySelector.h r1 manage 3.0 K 2013-03-04 - 18:30 LorenzoMoneta Selector file to be used to run the example
Edit | Attach | Watch | Print version | History: r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r1 - 2013-03-04 - LorenzoMoneta
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback