KaliVeda
Toolkit for HIC analysis
KVPROOFSelector Class Referenceabstract

Detailed Description

General purpose class for running parallel tasks with PROOF.

This class has been automatically generated on Fri Apr 1 10:33:24 2011 by ROOT version 5.29/01 from TTree events/events found on file: events.root

Generate a class derived from this one using static method

KVPROOFSelector::Make("MySelector");

then you can use PROOF in order to run tasks in parallel:

TProof::Open(""); // open PROOFLite session gProof->Process("MySelector.cpp+", [ncycles], "[options]");

This will execute MySelector::Process(Long64_t) ncycles times.

USING TREES & HISTOGRAMS TO SAVE DATA

  • declare any histograms with method AddHisto(TH1*) e.g. in InitAnalysis: void MySelector::InitAnalysis() { AddHisto( new TH2F("toto", "tata", 100, 0, 0, 500, 0, 0) ); } Histograms can also be declared 'on the fly' in Analysis() method in the same way;
  • for TTrees, first call CreateTreeFile("...") with name of file for TTree(s) (by default, histograms and TTrees are written in different files - but see below), then declare all trees using method AddTree(TTree*) e.g. in InitAnalysis: void MySelector::InitAnalysis() { CreateTreeFile("MyTrees.root"); TTree* aTree = new TTree("t1", "Some Tree"); aTree->Branch(...) etc. AddTree(aTree); }
  • if you want (not obligatory), you can use methods FillHisto(...) and FillTree(...) in your Analysis() method;
  • to save histograms to file in EndAnalysis(), call method SaveHistos(const Char_t* filename) in EndAnalysis()
  • the file declared with CreateTreeFile will be automatically written to disk at the end of the analysis.

HISTOS & TREES IN SAME FILE If you want all results of your analysis to be written in a single file containing both histos and trees, put the following in the list of options: CombinedOutputFile=myResults.root or call method SetCombinedOutputFile("myResults.root") in your InitAnalysis(); do not call SaveHistos() in EndAnalysis(), and make sure you call CreateTreeFile() without giving a name (the resulting intermediate file will have a default name allowing it to be found at the end of the analysis)

Definition at line 79 of file KVPROOFSelector.h.

#include <KVPROOFSelector.h>

Inheritance diagram for KVPROOFSelector:

Public Member Functions

 KVPROOFSelector (TTree *=0)
 
virtual ~KVPROOFSelector ()
 
void AddHisto (TH1 *histo)
 
void AddTree (TTree *tree)
 
virtual Bool_t Analysis ()=0
 
void Begin (TTree *tree) override
 
Bool_t CreateTreeFile (const Char_t *filename="")
 
virtual void EndAnalysis ()=0
 
void FillHisto (const Char_t *sname, Double_t one, Double_t two=1, Double_t three=1, Double_t four=1)
 
void FillTree (const Char_t *sname="")
 
Long64_t GetCycleNumber () const
 
TH1 * GetHisto (const Char_t *name) const
 
KVHashList * GetHistoList () const
 return the list of created trees More...
 
virtual TString GetOpt (const Char_t *option) const
 
TTree * GetTree (const Char_t *name) const
 return the tree named tree_name More...
 
KVHashList * GetTreeList () const
 return the list of created trees More...
 
virtual void InitAnalysis ()=0
 
virtual Bool_t IsOptGiven (const Char_t *option)
 Returns kTRUE if the option 'opt' has been set. More...
 
virtual void ParseOptions ()
 
Bool_t Process (Long64_t entry) override
 
virtual void SaveHistos (const Char_t *filename="", Option_t *option="recreate", Bool_t onlyfilled=kFALSE)
 
void SetCombinedOutputFile (const TString &filename)
 
void SetEventsReadInterval (Long64_t N)
 
virtual void SetOpt (const Char_t *option, const Char_t *value)
 Set a value for an option. More...
 
void SlaveBegin (TTree *tree) override
 
void SlaveTerminate () override
 
void Terminate () override
 
virtual void UnsetOpt (const Char_t *opt)
 Removes the option 'opt' from the internal lists, as if it had never been set. More...
 
Int_t Version () const override
 

Static Public Member Functions

static void Make (const Char_t *classname)
 Generate a new class derived from this one with given name. More...
 

Public Attributes

TProofOutputFile * mergeFile
 for merging with PROOF More...
 
TString tree_file_name
 
TFile * writeFile
 

Constructor & Destructor Documentation

◆ KVPROOFSelector()

KVPROOFSelector::KVPROOFSelector ( TTree *  = 0)
inline

Definition at line 109 of file KVPROOFSelector.h.

◆ ~KVPROOFSelector()

virtual KVPROOFSelector::~KVPROOFSelector ( )
inlinevirtual

Definition at line 115 of file KVPROOFSelector.h.

Member Function Documentation

◆ AddHisto()

void KVPROOFSelector::AddHisto ( TH1 *  histo)

Declare a histogram to be used in analysis. This method must be called when using PROOF.

Definition at line 298 of file KVPROOFSelector.cpp.

◆ AddTree()

void KVPROOFSelector::AddTree ( TTree *  tree)

Declare a TTree to be used in analysis. This method must be called when using PROOF.

Definition at line 316 of file KVPROOFSelector.cpp.

◆ Analysis()

virtual Bool_t KVPROOFSelector::Analysis ( )
pure virtual

◆ Begin()

void KVPROOFSelector::Begin ( TTree *  tree)
override

Need to parse options here for use in Terminate Also, on PROOF, any KVDataAnalyser instance has to be passed to the workers via the TSelector input list.

Definition at line 22 of file KVPROOFSelector.cpp.

◆ CreateTreeFile()

Bool_t KVPROOFSelector::CreateTreeFile ( const Char_t *  filename = "")

For PROOF: This method must be called before creating any user TTree in InitAnalysis(). If no filename is given, default name="TreeFileFrom[name of selector class].root"

Definition at line 101 of file KVPROOFSelector.cpp.

◆ EndAnalysis()

virtual void KVPROOFSelector::EndAnalysis ( )
pure virtual

◆ FillHisto()

void KVPROOFSelector::FillHisto ( const Char_t *  histo_name,
Double_t  one,
Double_t  two = 1,
Double_t  three = 1,
Double_t  four = 1 
)

Find in the list, if there is an histogram named "sname" If not print an error message If yes redirect to the right method according to its closest mother class to fill it

Definition at line 335 of file KVPROOFSelector.cpp.

◆ FillTree()

void KVPROOFSelector::FillTree ( const Char_t *  tree_name = "")

Filltree method, the tree named tree_name has to be declared with AddTTree(TTree*) method

if no sname="", all trees in the list is filled

Definition at line 529 of file KVPROOFSelector.cpp.

◆ GetCycleNumber()

Long64_t KVPROOFSelector::GetCycleNumber ( ) const
inline

Returns the argument 'entry' passed to Process(Long64_t entry)

Definition at line 173 of file KVPROOFSelector.h.

◆ GetHisto()

TH1 * KVPROOFSelector::GetHisto ( const Char_t *  name) const

Definition at line 284 of file KVPROOFSelector.cpp.

◆ GetHistoList()

KVHashList * KVPROOFSelector::GetHistoList ( ) const

return the list of created trees

Definition at line 271 of file KVPROOFSelector.cpp.

◆ GetOpt()

TString KVPROOFSelector::GetOpt ( const Char_t *  opt) const
virtual

Returns the value of the option Only use after checking existence of option with IsOptGiven(const Char_t* opt)

Definition at line 583 of file KVPROOFSelector.cpp.

◆ GetTree()

TTree * KVPROOFSelector::GetTree ( const Char_t *  name) const

return the tree named tree_name

Definition at line 512 of file KVPROOFSelector.cpp.

◆ GetTreeList()

KVHashList * KVPROOFSelector::GetTreeList ( ) const

return the list of created trees

Definition at line 499 of file KVPROOFSelector.cpp.

◆ InitAnalysis()

virtual void KVPROOFSelector::InitAnalysis ( )
pure virtual

◆ IsOptGiven()

Bool_t KVPROOFSelector::IsOptGiven ( const Char_t *  option)
virtual

Returns kTRUE if the option 'opt' has been set.

Definition at line 569 of file KVPROOFSelector.cpp.

◆ Make()

void KVPROOFSelector::Make ( const Char_t *  classname)
static

Generate a new class derived from this one with given name.

Definition at line 644 of file KVPROOFSelector.cpp.

◆ ParseOptions()

void KVPROOFSelector::ParseOptions ( )
virtual

Analyse comma-separated list of options given to TTree::Process and store all "option=value" pairs in fOptionList. Options can then be accessed using IsOptGiven(), GetOptString(), etc. This method is called by SlaveBegin

Definition at line 612 of file KVPROOFSelector.cpp.

◆ Process()

Bool_t KVPROOFSelector::Process ( Long64_t  entry)
override

Processing will abort cleanly if static flag fCleanAbort has been set by some external controlling process.

Use fStatus to set the return value of TTree::Process().

The return value is currently not used.

Definition at line 141 of file KVPROOFSelector.cpp.

◆ SaveHistos()

void KVPROOFSelector::SaveHistos ( const Char_t *  filename = "",
Option_t *  option = "recreate",
Bool_t  onlyfilled = kFALSE 
)
virtual

Write in file all histograms declared with AddHisto(TH1*) This method works with PROOF.

If no filename is specified, set default name : HistoFileFrom[KVEvenSelector::GetName()].root

If a filename is specified, search in gROOT->GetListOfFiles() if this file has been already opened

  • if yes write in it
  • if not, create it with the corresponding option, write in it and close it just after

onlyfilled flag allow to write all (onlyfilled=kFALSE, default) or only histograms (onlyfilled=kTRUE) those have been filled

Definition at line 439 of file KVPROOFSelector.cpp.

◆ SetCombinedOutputFile()

void KVPROOFSelector::SetCombinedOutputFile ( const TString &  filename)
inline

Call in InitAnalysis() to set the name of the single output file containing all histograms and TTrees produced by analysis. This is equivalent to running the analysis with option CombinedOutputFile=[filename] but setting this option in InitAnalysis() will not work. Note that if this method is not called/the option is not given, histograms and TTrees will be written in separate files.

Definition at line 162 of file KVPROOFSelector.h.

◆ SetEventsReadInterval()

void KVPROOFSelector::SetEventsReadInterval ( Long64_t  N)
inline

Definition at line 124 of file KVPROOFSelector.h.

◆ SetOpt()

void KVPROOFSelector::SetOpt ( const Char_t *  option,
const Char_t *  value 
)
virtual

Set a value for an option.

Definition at line 556 of file KVPROOFSelector.cpp.

◆ SlaveBegin()

void KVPROOFSelector::SlaveBegin ( TTree *  tree)
override

The SlaveBegin() function is called after the Begin() function. When running with PROOF SlaveBegin() is called on each slave server. The tree argument is deprecated (on PROOF 0 is passed).

ParseOptions : Manage options passed as arguments

Called user method InitAnalysis where users can create trees or histos using the appropiate methods : CreateTrees and CreateMethods

Test the presence or not of such histo or tree to manage it properly

Definition at line 60 of file KVPROOFSelector.cpp.

◆ SlaveTerminate()

void KVPROOFSelector::SlaveTerminate ( )
override

The SlaveTerminate() function is called after all entries or objects have been processed. When running with PROOF SlaveTerminate() is called on each slave server. if tree have been defined in the CreateTrees method manage the merge of them in ProofLite session

Definition at line 177 of file KVPROOFSelector.cpp.

◆ Terminate()

void KVPROOFSelector::Terminate ( )
override

The Terminate() function is the last function to be called during a query. It always runs on the client, it can be used to present the results graphically or save the results to file.

This method call the user defined EndAnalysis where user can do what she wants

Definition at line 223 of file KVPROOFSelector.cpp.

◆ UnsetOpt()

void KVPROOFSelector::UnsetOpt ( const Char_t *  opt)
virtual

Removes the option 'opt' from the internal lists, as if it had never been set.

Definition at line 597 of file KVPROOFSelector.cpp.

◆ Version()

Int_t KVPROOFSelector::Version ( ) const
inlineoverride

Definition at line 128 of file KVPROOFSelector.h.

Member Data Documentation

◆ mergeFile

TProofOutputFile* KVPROOFSelector::mergeFile

for merging with PROOF

Definition at line 103 of file KVPROOFSelector.h.

◆ tree_file_name

TString KVPROOFSelector::tree_file_name

Definition at line 104 of file KVPROOFSelector.h.

◆ writeFile

TFile* KVPROOFSelector::writeFile

Definition at line 102 of file KVPROOFSelector.h.