RooProofDriverSelector.cxx

Go to the documentation of this file.
00001 #define RooProofDriverSelector_cxx
00002 // The class definition in RooProofDriverSelector.h has been generated automatically
00003 // by the ROOT utility TTree::MakeSelector(). This class is derived
00004 // from the ROOT class TSelector. For more information on the TSelector
00005 // framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual.
00006 
00007 // The following methods are defined in this file:
00008 //    Begin():        called every time a loop on the tree starts,
00009 //                    a convenient place to create your histograms.
00010 //    SlaveBegin():   called after Begin(), when on PROOF called only on the
00011 //                    slave servers.
00012 //    Process():      called for each event, in this function you decide what
00013 //                    to read and fill your histograms.
00014 //    SlaveTerminate: called at the end of the loop on the tree, when on PROOF
00015 //                    called only on the slave servers.
00016 //    Terminate():    called at the end of the loop on the tree,
00017 //                    a convenient place to draw/fit your histograms.
00018 //
00019 // To use this file, try the following session on your Tree T:
00020 //
00021 // Root > T->Process("RooProofDriverSelector.C")
00022 // Root > T->Process("RooProofDriverSelector.C","some options")
00023 // Root > T->Process("RooProofDriverSelector.C+")
00024 //
00025 
00026 // #include <unistd.h>
00027 #include "RooProofDriverSelector.h"
00028 #include <TH2.h>
00029 #include <TStyle.h>
00030 #include "RooDataSet.h"
00031 #include "RooWorkspace.h"
00032 #include "RooAbsPdf.h"
00033 #include "RooRealVar.h"
00034 #include "RooFitResult.h"
00035 #include "TRandom.h"
00036 #include "RooRandom.h"
00037 #include "RooAbsStudy.h"
00038 #include "TSystem.h"
00039 #include "RooStudyPackage.h"
00040 #ifndef __CINT__
00041 #include "RooGlobalFunc.h"
00042 #endif
00043  
00044 using namespace RooFit ;
00045 
00046 void RooProofDriverSelector::SlaveBegin(TTree * /*tree*/) 
00047 {  
00048   // Retrieve study pack 
00049   _pkg=0 ;
00050   if (fInput) { 
00051     TIterator* iter = fInput->MakeIterator() ;
00052     TObject* obj ;
00053     while((obj=iter->Next())) {
00054       RooStudyPackage* tmp = dynamic_cast<RooStudyPackage*>(obj) ;
00055       if (tmp) {
00056         _pkg = tmp ;
00057       }
00058      }
00059   }
00060   if (_pkg==0) {
00061     cout << "RooProofDriverSelector::SlaveBegin() no RooStudyPackage found, aborting process" << endl ;
00062     fStatus = kAbortProcess ;
00063   } else {
00064     cout << "workspace contents = " << endl ;
00065     _pkg->wspace().Print() ;
00066     
00067     // Initialize study pack
00068     seed = _pkg->initRandom() ;
00069     _pkg->initialize() ;
00070   }
00071     
00072 }
00073 
00074 Bool_t RooProofDriverSelector::Process(Long64_t entry)
00075 {
00076   cout << "RooProofDriverSelector::Process(" << entry << ")" << endl ;
00077   _pkg->runOne() ;
00078   return kTRUE;
00079 }
00080 
00081 
00082 void RooProofDriverSelector::SlaveTerminate() 
00083 {
00084   _pkg->finalize() ;
00085   _pkg->exportData(fOutput,seed) ;
00086 }
00087 
00088 
00089 
00090 void RooProofDriverSelector::Init(TTree *tree)
00091 {
00092    // Set branch addresses and branch pointers
00093    if (!tree) return;
00094    fChain = tree;
00095    fChain->SetMakeClass(1);
00096    fChain->SetBranchAddress("i", &i, &b_i);
00097 }
00098 
00099 Bool_t RooProofDriverSelector::Notify()
00100 {
00101    return kTRUE;
00102 }
00103 

Generated on Tue Jul 5 15:07:07 2011 for ROOT_528-00b_version by  doxygen 1.5.1