Logo ROOT   6.14/05
Reference Guide
RooProofDriverSelector.cxx
Go to the documentation of this file.
1 #define RooProofDriverSelector_cxx
2 // The class definition in RooProofDriverSelector.h has been generated automatically
3 // by the ROOT utility TTree::MakeSelector(). This class is derived
4 // from the ROOT class TSelector. For more information on the TSelector
5 // framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual.
6 
7 // The following methods are defined in this file:
8 // Begin(): called every time a loop on the tree starts,
9 // a convenient place to create your histograms.
10 // SlaveBegin(): called after Begin(), when on PROOF called only on the
11 // slave servers.
12 // Process(): called for each event, in this function you decide what
13 // to read and fill your histograms.
14 // SlaveTerminate: called at the end of the loop on the tree, when on PROOF
15 // called only on the slave servers.
16 // Terminate(): called at the end of the loop on the tree,
17 // a convenient place to draw/fit your histograms.
18 //
19 // To use this file, try the following session on your Tree T:
20 //
21 // Root > T->Process("RooProofDriverSelector.C")
22 // Root > T->Process("RooProofDriverSelector.C","some options")
23 // Root > T->Process("RooProofDriverSelector.C+")
24 //
25 
26 // #include <unistd.h>
27 #include "RooProofDriverSelector.h"
28 #include <TH2.h>
29 #include <TStyle.h>
30 #include "RooDataSet.h"
31 #include "RooWorkspace.h"
32 #include "RooAbsPdf.h"
33 #include "RooRealVar.h"
34 #include "RooFitResult.h"
35 #include "TRandom.h"
36 #include "RooRandom.h"
37 #include "RooAbsStudy.h"
38 #include "TSystem.h"
39 #include "RooStudyPackage.h"
40 #ifndef __CINT__
41 #include "RooGlobalFunc.h"
42 #endif
43 
44 using namespace RooFit ;
45 using namespace std ;
46 
47 void RooProofDriverSelector::SlaveBegin(TTree * /*tree*/)
48 {
49  // Retrieve study pack
50  _pkg=0 ;
51  if (fInput) {
52  TIterator* iter = fInput->MakeIterator() ;
53  TObject* obj ;
54  while((obj=iter->Next())) {
55  RooStudyPackage* tmp = dynamic_cast<RooStudyPackage*>(obj) ;
56  if (tmp) {
57  _pkg = tmp ;
58  }
59  }
60  }
61  if (_pkg==0) {
62  cout << "RooProofDriverSelector::SlaveBegin() no RooStudyPackage found, aborting process" << endl ;
63  fStatus = kAbortProcess ;
64  } else {
65  cout << "workspace contents = " << endl ;
66  _pkg->wspace().Print() ;
67 
68  // Initialize study pack
69  seed = _pkg->initRandom() ;
70  _pkg->initialize() ;
71  }
72 
73 }
74 
76 {
77  cout << "RooProofDriverSelector::Process(" << entry << ")" << endl ;
78  _pkg->runOne() ;
79  return kTRUE;
80 }
81 
82 
84 {
85  _pkg->finalize() ;
86  _pkg->exportData(fOutput,seed) ;
87 }
88 
89 
90 
92 {
93  // Set branch addresses and branch pointers
94  if (!tree) return;
95  fChain = tree;
96  fChain->SetMakeClass(1);
97  fChain->SetBranchAddress("i", &i, &b_i);
98 }
99 
101 {
102  return kTRUE;
103 }
104 
RooStudyPackage is a utility class to manage studies that consist of repeated applications of generat...
virtual Bool_t Notify()
This method must be overridden to handle object notification.
virtual Bool_t Process(Long64_t entry)
long long Long64_t
Definition: RtypesCore.h:69
virtual void SlaveBegin(TTree *tree)
bool Bool_t
Definition: RtypesCore.h:59
STL namespace.
Iterator abstract base class.
Definition: TIterator.h:30
virtual void Init(TTree *tree)
RooWorkspace & wspace()
Mother of all ROOT objects.
Definition: TObject.h:37
virtual TObject * Next()=0
Definition: tree.py:1
void Print(Option_t *opts=0) const
Print contents of the workspace.
const Bool_t kTRUE
Definition: RtypesCore.h:87