KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
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
 
virtual void Begin (TTree *tree)
 
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
 
TH1GetHisto (const Char_t *name) const
 
KVHashListGetHistoList () const
 return the list of created trees
 
virtual TString GetOpt (const Char_t *option) const
 
TTreeGetTree (const Char_t *name) const
 return the tree named tree_name
 
KVHashListGetTreeList () const
 return the list of created trees
 
virtual void InitAnalysis ()=0
 
virtual Bool_t IsOptGiven (const Char_t *option)
 Returns kTRUE if the option 'opt' has been set.
 
virtual void ParseOptions ()
 
virtual Bool_t Process (Long64_t entry)
 
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.
 
virtual void SlaveBegin (TTree *tree)
 
virtual void SlaveTerminate ()
 
virtual void Terminate ()
 
virtual void UnsetOpt (const Char_t *opt)
 Removes the option 'opt' from the internal lists, as if it had never been set.
 
virtual Int_t Version () const
 
- Public Member Functions inherited from TSelector
 TSelector ()
 
 ~TSelector () override
 
virtual void Abort (const char *why, EAbort what=kAbortProcess)
 
virtual EAbort GetAbort () const
 
virtual Int_t GetEntry (Long64_t, Int_t=0)
 
virtual TListGetInputList () const
 
const char * GetOption () const override
 
virtual TListGetOutputList () const
 
virtual Long64_t GetStatus () const
 
virtual void ImportOutput (TList *output)
 
virtual void Init (TTree *)
 
TClassIsA () const override
 
Bool_t Notify () override
 
virtual Bool_t ProcessCut (Long64_t)
 
virtual void ProcessFill (Long64_t)
 
virtual void ResetAbort ()
 
virtual void SetInputList (TList *input)
 
virtual void SetObject (TObject *obj)
 
virtual void SetOption (const char *option)
 
virtual void SetStatus (Long64_t status)
 
void Streamer (TBuffer &) override
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 
- Public Member Functions inherited from TObject
 TObject ()
 
 TObject (const TObject &object)
 
virtual ~TObject ()
 
void AbstractMethod (const char *method) const
 
virtual void AppendPad (Option_t *option="")
 
virtual void Browse (TBrowser *b)
 
ULong_t CheckedHash ()
 
virtual const char * ClassName () const
 
virtual void Clear (Option_t *="")
 
virtual TObjectClone (const char *newname="") const
 
virtual Int_t Compare (const TObject *obj) const
 
virtual void Copy (TObject &object) const
 
virtual void Delete (Option_t *option="")
 
virtual Int_t DistancetoPrimitive (Int_t px, Int_t py)
 
virtual void Draw (Option_t *option="")
 
virtual void DrawClass () const
 
virtual TObjectDrawClone (Option_t *option="") const
 
virtual void Dump () const
 
virtual void Error (const char *method, const char *msgfmt,...) const
 
virtual void Execute (const char *method, const char *params, Int_t *error=nullptr)
 
virtual void Execute (TMethod *method, TObjArray *params, Int_t *error=nullptr)
 
virtual void ExecuteEvent (Int_t event, Int_t px, Int_t py)
 
virtual void Fatal (const char *method, const char *msgfmt,...) const
 
virtual TObjectFindObject (const char *name) const
 
virtual TObjectFindObject (const TObject *obj) const
 
virtual Option_tGetDrawOption () const
 
virtual const char * GetIconName () const
 
virtual const char * GetName () const
 
virtual char * GetObjectInfo (Int_t px, Int_t py) const
 
virtual const char * GetTitle () const
 
virtual UInt_t GetUniqueID () const
 
virtual Bool_t HandleTimer (TTimer *timer)
 
virtual ULong_t Hash () const
 
Bool_t HasInconsistentHash () const
 
virtual void Info (const char *method, const char *msgfmt,...) const
 
virtual Bool_t InheritsFrom (const char *classname) const
 
virtual Bool_t InheritsFrom (const TClass *cl) const
 
virtual void Inspect () const
 
void InvertBit (UInt_t f)
 
Bool_t IsDestructed () const
 
virtual Bool_t IsEqual (const TObject *obj) const
 
virtual Bool_t IsFolder () const
 
R__ALWAYS_INLINE Bool_t IsOnHeap () const
 
virtual Bool_t IsSortable () const
 
R__ALWAYS_INLINE Bool_t IsZombie () const
 
virtual void ls (Option_t *option="") const
 
void MayNotUse (const char *method) const
 
void Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const
 
void operator delete (void *ptr)
 
void operator delete (void *ptr, void *vp)
 
void operator delete[] (void *ptr)
 
void operator delete[] (void *ptr, void *vp)
 
voidoperator new (size_t sz)
 
voidoperator new (size_t sz, void *vp)
 
voidoperator new[] (size_t sz)
 
voidoperator new[] (size_t sz, void *vp)
 
TObjectoperator= (const TObject &rhs)
 
virtual void Paint (Option_t *option="")
 
virtual void Pop ()
 
virtual void Print (Option_t *option="") const
 
virtual Int_t Read (const char *name)
 
virtual void RecursiveRemove (TObject *obj)
 
void ResetBit (UInt_t f)
 
virtual void SaveAs (const char *filename="", Option_t *option="") const
 
virtual void SavePrimitive (std::ostream &out, Option_t *option="")
 
void SetBit (UInt_t f)
 
void SetBit (UInt_t f, Bool_t set)
 
virtual void SetDrawOption (Option_t *option="")
 
virtual void SetUniqueID (UInt_t uid)
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 
virtual void SysError (const char *method, const char *msgfmt,...) const
 
R__ALWAYS_INLINE Bool_t TestBit (UInt_t f) const
 
Int_t TestBits (UInt_t f) const
 
virtual void UseCurrentStyle ()
 
virtual void Warning (const char *method, const char *msgfmt,...) const
 
virtual Int_t Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
 
virtual Int_t Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const
 

Static Public Member Functions

static void Make (const Char_t *classname)
 Generate a new class derived from this one with given name.
 
- Static Public Member Functions inherited from TSelector
static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 
static TSelectorGetSelector (const char *filename)
 
static Bool_t IsStandardDraw (const char *selec)
 
- Static Public Member Functions inherited from TObject
static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 
static Longptr_t GetDtorOnly ()
 
static Bool_t GetObjectStat ()
 
static void SetDtorOnly (void *obj)
 
static void SetObjectStat (Bool_t stat)
 

Public Attributes

TProofOutputFilemergeFile
 for merging with PROOF
 
TString tree_file_name
 
TFilewriteFile
 
- Public Attributes inherited from TSelector
 kAbortFile
 
 kAbortProcess
 
 kContinue
 
- Public Attributes inherited from TObject
 kBitMask
 
 kCanDelete
 
 kCannotPick
 
 kHasUUID
 
 kInconsistent
 
 kInvalidObject
 
 kIsOnHeap
 
 kIsReferenced
 
 kMustCleanup
 
 kNoContextMenu
 
 kNotDeleted
 
 kObjInCanvas
 
 kOverwrite
 
 kSingleKey
 
 kWriteDelete
 
 kZombie
 

Private Member Functions

void FillTH1 (TH1 *h1, Double_t one, Double_t two)
 
void FillTH2 (TH2 *h2, Double_t one, Double_t two, Double_t three)
 
void FillTH3 (TH3 *h3, Double_t one, Double_t two, Double_t three, Double_t four)
 
void FillTProfile (TProfile *h1, Double_t one, Double_t two, Double_t three)
 
void FillTProfile2D (TProfile2D *h2, Double_t one, Double_t two, Double_t three, Double_t four)
 

Private Attributes

KVString fCombinedOutputFile
 optional name for single results file with trees and histos
 
Bool_t fDisableCreateTreeFile
 used with PROOF
 
Long64_t fEventsRead
 cycle number (argument 'entry' passed to Process(Long64_t))
 
Long64_t fEventsReadInterval
 interval at which to print number of events read
 
KVNameValueList fOptionList
 parsed list of options given to TTree::Process
 
KVHashListlhisto
 !
 
KVHashListltree
 !
 

Additional Inherited Members

- Public Types inherited from TSelector
enum  EAbort
 
- Public Types inherited from TObject
enum  EDeprecatedStatusBits
 
enum  EStatusBits
 
- Protected Member Functions inherited from TObject
virtual void DoError (int level, const char *location, const char *fmt, va_list va) const
 
void MakeZombie ()
 
- Protected Attributes inherited from TSelector
EAbort fAbort
 
TListfInput
 
TObjectfObject
 
TString fOption
 
TSelectorListfOutput
 
Long64_t fStatus
 
- Protected Attributes inherited from TObject
 kOnlyPrepStep
 

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)
virtual

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.

Reimplemented from TSelector.

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.

◆ FillTH1()

void KVPROOFSelector::FillTH1 ( TH1 h1,
Double_t  one,
Double_t  two 
)
private

Definition at line 368 of file KVPROOFSelector.cpp.

◆ FillTH2()

void KVPROOFSelector::FillTH2 ( TH2 h2,
Double_t  one,
Double_t  two,
Double_t  three 
)
private

Definition at line 392 of file KVPROOFSelector.cpp.

◆ FillTH3()

void KVPROOFSelector::FillTH3 ( TH3 h3,
Double_t  one,
Double_t  two,
Double_t  three,
Double_t  four 
)
private

Definition at line 415 of file KVPROOFSelector.cpp.

◆ FillTProfile()

void KVPROOFSelector::FillTProfile ( TProfile h1,
Double_t  one,
Double_t  two,
Double_t  three 
)
private

Definition at line 380 of file KVPROOFSelector.cpp.

◆ FillTProfile2D()

void KVPROOFSelector::FillTProfile2D ( TProfile2D h2,
Double_t  one,
Double_t  two,
Double_t  three,
Double_t  four 
)
private

Definition at line 404 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)
virtual

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.

Reimplemented from TSelector.

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)
virtual

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

Reimplemented from TSelector.

Definition at line 60 of file KVPROOFSelector.cpp.

◆ SlaveTerminate()

void KVPROOFSelector::SlaveTerminate ( )
virtual

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

Reimplemented from TSelector.

Definition at line 177 of file KVPROOFSelector.cpp.

◆ Terminate()

void KVPROOFSelector::Terminate ( )
virtual

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

Reimplemented from TSelector.

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()

virtual Int_t KVPROOFSelector::Version ( ) const
inlinevirtual

Reimplemented from TSelector.

Definition at line 128 of file KVPROOFSelector.h.

Member Data Documentation

◆ fCombinedOutputFile

KVString KVPROOFSelector::fCombinedOutputFile
private

optional name for single results file with trees and histos

Definition at line 88 of file KVPROOFSelector.h.

◆ fDisableCreateTreeFile

Bool_t KVPROOFSelector::fDisableCreateTreeFile
private

used with PROOF

Definition at line 93 of file KVPROOFSelector.h.

◆ fEventsRead

Long64_t KVPROOFSelector::fEventsRead
private

cycle number (argument 'entry' passed to Process(Long64_t))

Definition at line 82 of file KVPROOFSelector.h.

◆ fEventsReadInterval

Long64_t KVPROOFSelector::fEventsReadInterval
private

interval at which to print number of events read

Definition at line 83 of file KVPROOFSelector.h.

◆ fOptionList

KVNameValueList KVPROOFSelector::fOptionList
private

parsed list of options given to TTree::Process

Definition at line 91 of file KVPROOFSelector.h.

◆ lhisto

KVHashList* KVPROOFSelector::lhisto
private

!

Definition at line 85 of file KVPROOFSelector.h.

◆ ltree

KVHashList* KVPROOFSelector::ltree
private

!

Definition at line 86 of file KVPROOFSelector.h.

◆ 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.