KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVEventSelector Class Reference

Detailed Description

General purpose analysis base class for TTree containing KVEvent objects.

This is a specialised version of the ROOT TSelector class. Classes derived from this one can be used to analyse KVEvent data in TTree branches. Analyses can be performed sequentially or in parallel using the PROOFLite facility. The user needs only to implement/override the following methods in their analysis class:

void InitAnalysis() { // called once at beginning of analysis }
void InitRun() { // called once at beginning of each file/run to analyse }
bool Analysis() { // called for each event in turn }
void EndRun() { // called at the end of each file/run }
void EndAnalysis() { // called at the end of the analysis }
virtual void InitAnalysis()
virtual void EndRun()
virtual Bool_t Analysis()
virtual void EndAnalysis()
virtual void InitRun()

In most cases, it is sufficient to implement only the InitAnalysis() and Analysis() methods.

The analysis can be performed like for TSelector with a TChain or TTree my_tree:

my_tree->Process("MySelector.cpp+", "[options]");
void AddHisto(TH1 *histo)

where [options] is a list of options in the form BranchName=toto, ....

The following options MUST be given:

The following are optional options:

AuxDir: directory in which to find AuxFiles
#define N
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Abstract base class container for multi-particle events.
Definition KVEvent.h:67

When AuxFiles is used, the user can access the events in these files in her Analysis() method by doing the following:

Int_t GetFriendTreeEntry(Long64_t entry, Int_t getall=0)
KVEvent * GetFriendEvent() const

Any other options can be defined by the user and parsed in her analysis class with methods IsOptGiven() and GetOpt()

Usage

The 5 methods listed above will be called in the following order during a typical analysis:

InitAnalysis() // beginning of analysis
InitRun() // open 1st file in TChain
Analysis() // 1st event
Analysis() // 2nd event
Analysis() // 3rd event...
...
EndRun() // end of 1st file
InitRun() // open 2nd file in TChain
Analysis() // 1st event
Analysis() // etc.
...
EndRun() // end of 2nd file
...
InitRun() // Nth file in TChain...
...
EndRun() // end of Nth file

User's histograms and/or TTrees are therefore initialised in InitAnalysis(), as well as any required global variables.

Global Variables

Global variables for the analysis should be declared in InitAnalysis() using method AddGV(). These variables are calculated automatically for each event before user's Analysis() method is called.

If the user needs to define new reference frames for the data which must exist before global variables are automatically calculated in the analysis loop, she can do so by overriding the method SetAnalysisFrame(), like so:

MyAnalysis::SetAnalysisFrame()
{
static TVector3 cmvelocity(0,0,3.0);
}
KVEvent * GetEvent() const
virtual void SetFrame(const Char_t *, const KVFrameTransform &)=0

Note that the global variables are only calculated using particles which have their "OK" status set, for example because they correspond to the global particle selection criteria given to SetParticleConditions(). Any further particle selections applied to individual global variables will then select from among these "OK" particles.

If one or more global variables have event selection conditions defined (i.e. cuts on the values of the global variables) - see KVVarGlob::SetEventSelection() and KVGVList - then for each event which does not satisfy all conditions the Analysis() method will not be called.

Use with PROOF(lite)

In order to use a KVEventSelector with PROOF:

void MySelector::InitAnalysis()
{
AddHisto( new TH2F("toto", "tata", 100, 0, 0, 500, 0, 0) );
}

Histograms can also be declared 'on the fly' in the Analysis() method in the same way;

void MySelector::InitAnalysis()
{
CreateTreeFile("MyTrees.root");
TTree* aTree = new TTree("t1", "Some Tree");
aTree->Branch(...) etc.
}
Bool_t CreateTreeFile(const Char_t *filename="")
void AddTree(TTree *tree)

Histograms & TTrees in the same output file

If you want all results of your analysis to be written in a single file containing both histos and trees, call method SetJobOutputFileName() with the required filename in your InitAnalysis() method;

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

Generating & saving profiles, divided histograms, etc.

If, at the end of processing, you want to generate a histogram from one or more histograms filled in your analysis, for example generate a TProfile from a 2D histogram, or store the result of dividing one histogram by the other, you need to do the following:

  • do the processing in the EndRun() method, not in EndAnalysis() - by the time EndAnalysis() is called it is too late, the output file has been closed and written to disk
  • add the resulting histogram to the output list like so:
MyEventSelector::EndRun()
{
TProfile* my_profile = ((TH2*)GetHisto("my_histo_2D"))->ProfileX("name_of_my_profile");
}
TH1 * GetHisto(const Char_t *name) const
virtual TList * GetOutputList() const
void Add(TObject *obj) override
Examples
ExampleFilteredSimDataAnalysis.cpp, and ExampleSimDataAnalysis.cpp.

Definition at line 191 of file KVEventSelector.h.

#include <KVEventSelector.h>

Inheritance diagram for KVEventSelector:

Public Member Functions

 KVEventSelector (TTree *=0)
 
KVVarGlobAddGV (const Char_t *class_name, const Char_t *name)
 
void AddGV (KVVarGlob *vg)
 
KVGVListAddGVList (const KVString &list_name, const KVParticleCondition &selection=KVParticleCondition())
 
template<typename HistoType , typename... Args>
HistoType * AddHisto (Args &&... args)
 
void AddHisto (TH1 *histo)
 
TTreeAddTree (const TString &name, const TString &title="")
 
void AddTree (TTree *tree)
 
virtual Bool_t Analysis ()
 
virtual void Begin (TTree *tree)
 
Bool_t CreateTreeFile (const Char_t *filename="")
 
virtual void EndAnalysis ()
 
virtual void EndRun ()
 
void FillHisto (const Char_t *sname, const Char_t *label, Double_t weight=1)
 
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 *tree_name="")
 
const Char_tGetBranchName () const
 
virtual Int_t GetEntry (Long64_t entry, Int_t getall=0)
 
KVEventGetEvent () const
 
Int_t GetEventNumber () const
 
KVEventGetFriendEvent () const
 
Int_t GetFriendTreeEntry (Long64_t entry, Int_t getall=0)
 
KVVarGlobGetGV (const Char_t *name) const
 
KVGVListGetGVList (const KVString &list_name="default")
 
const KVGVListGetGVList (const KVString &list_name="default") const
 
TH1GetHisto (const Char_t *name) const
 
const KVHashListGetHistoList () const
 
TString GetOpt (const Char_t *option) const
 
virtual TListGetOutputList () const
 
TTreeGetTree (const Char_t *name) const
 
const KVHashListGetTreeList () const
 GetTreeList.
 
virtual void Init (TTree *tree)
 
virtual void InitAnalysis ()
 
virtual void InitRun ()
 
Bool_t IsOptGiven (const Char_t *option)
 
virtual Bool_t Notify ()
 
virtual Bool_t Process (Long64_t entry)
 
virtual void SaveHistos (const Char_t *="", Option_t *="recreate", Bool_t=kFALSE)
 
virtual void SetAdditionalBranchAddress ()
 
void SetBranchName (const Char_t *n)
 
virtual void SetCurrentRun (KVDBRun *)
 
void SetEventsReadInterval (Long64_t N)
 
virtual void SetInputList (TList *input)
 
void SetJobOutputFileName (const TString &filename)
 
virtual void SetObject (TObject *obj)
 
void SetOpt (const Char_t *option, const Char_t *value)
 
void SetParticleConditions (const KVParticleCondition &cond)
 
void SetTriggerConditionsForRun (int run)
 
virtual void SlaveBegin (TTree *tree)
 
virtual void SlaveTerminate ()
 
virtual void Terminate ()
 
void UnsetOpt (const Char_t *opt)
 
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 TListGetInputList () const
 
const char * GetOption () const override
 
virtual Long64_t GetStatus () const
 
virtual void ImportOutput (TList *output)
 
TClassIsA () const override
 
Bool_t Notify () override
 
virtual Bool_t ProcessCut (Long64_t)
 
virtual void ProcessFill (Long64_t)
 
virtual void ResetAbort ()
 
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
 

Private Member Functions

void add_histo (TH1 *histo)
 for merging with PROOF
 
void add_tree (TTree *tree)
 
Bool_t AtEndOfRun (void)
 
virtual void CheckEndOfRun ()
 
void create_output_file ()
 
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)
 
void InitFriendTree (TTree *tree, const TString &branchname)
 
virtual void ParseOptions ()
 
void RecalculateGlobalVariables ()
 
void SetAnalysisFrame ()
 
void SetCombinedOutputFile (const TString &filename)
 
void SetEvent (KVEvent *e)
 
void SetUpAuxEventChain ()
 

Private Attributes

KVEventAuxEvent
 [optional] events in fAuxChain
 
TBranchb_Event
 List of branches.
 
KVEventEvent
 Declaration of leaf types.
 
TTreefAuxChain
 [optional] pointer to another TTree or TChain which may be used during analysis
 
KVString fBranchName
 name of branch which contains events to analyse
 
TTreefChain
 pointer to the analyzed TTree or TChain
 
KVString fCombinedOutputFile
 name for ROOT file containing histos and/or trees produced by analysis
 
Bool_t fDisableCreateTreeFile
 used with PROOF
 
Long64_t fEventsRead
 number of events read
 
Long64_t fEventsReadInterval
 interval at which to print number of events read
 
Bool_t fFirstEvent
 set to kFALSE after first event is read
 
Bool_t fGlobalVariableAbortEventAnalysis
 
KVUniqueNameList fGlobalVariables
 Lists of global variables with different selection criteria.
 
Bool_t fNotifyCalled
 avoid multiple calls to Notify/InitRun
 
KVUserAnalysisOptionList fOptionList
 parsed list of options given to TTree::Process
 
KVParticleCondition fPartCond
 (optional) conditions for selecting particles
 
Long64_t fTreeEntry
 current tree entry number
 
KVHashList lhisto
 list of histograms added with AddHisto
 
KVHashList ltree
 list of trees added with AddTree
 
TProofOutputFilemergeFile = nullptr
 output file for trees and histos
 
TFilewriteFile = nullptr
 

Additional Inherited Members

- Public Types inherited from TSelector
enum  EAbort
 
- Public Types inherited from TObject
enum  EDeprecatedStatusBits
 
enum  EStatusBits
 
- 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 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
 
- 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

◆ KVEventSelector()

KVEventSelector::KVEventSelector ( TTree = 0)
inline

Definition at line 288 of file KVEventSelector.h.

Member Function Documentation

◆ add_histo()

void KVEventSelector::add_histo ( TH1 histo)
private

for merging with PROOF

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

Definition at line 282 of file KVEventSelector.cpp.

◆ add_tree()

void KVEventSelector::add_tree ( TTree tree)
private

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

Definition at line 301 of file KVEventSelector.cpp.

◆ AddGV() [1/2]

KVVarGlob * KVEventSelector::AddGV ( const Char_t class_name,
const Char_t name 
)
inline

Create and return a pointer to a new global variable with given name and class. The variable will be added to the default global variable list (see GetGVList())

Parameters
class_nameglobal variable class to use (see list here: Global Variables )
namename of new global variable
Returns
pointer to new global variable object

Definition at line 545 of file KVEventSelector.h.

◆ AddGV() [2/2]

void KVEventSelector::AddGV ( KVVarGlob vg)
inline

Add the global variable to the default list (see GetGVList()).

Equivalent to GetGVList()->AddGV(vg)

Parameters
vgpointer to a heap-allocated KVVarGlob object

Definition at line 530 of file KVEventSelector.h.

◆ AddGVList()

KVGVList * KVEventSelector::AddGVList ( const KVString list_name,
const KVParticleCondition selection = KVParticleCondition() 
)
inline

Create a new list of global variables with given name and an optional particle selection.

Parameters
[in]list_namename of new list, can be used to retrieve list with GetGVList()
[in]selection[optional] selection criteria for particles to be used by global variables, default is no selection
Returns
pointer to new global variable list

Definition at line 473 of file KVEventSelector.h.

◆ AddHisto() [1/2]

template<typename HistoType , typename... Args>
HistoType * KVEventSelector::AddHisto ( Args &&...  args)
inline

Add a user histogram to the analysis. The name of the histogram can later be used in calls to FillHisto().

-/! th1 is a pointer to TH1F
auto th1 = AddHisto<TH1F>("h1", "A 1-D histogram", 100, -50., 50.);
-/! th2 is a pointer to TH2F
auto th2 = AddHisto<TH2F>("h2", "A 2-D histogram", 100, -50., 50., 100, -10., 10.);
auto * th2
auto * th1
TArc a
Template Parameters
HistoTypevalid ROOT histogram class name
Parameters
argsarguments required by constructor of HistoType class
Returns
address of the newly-created histogram as a pointer of type HistoType*

Definition at line 603 of file KVEventSelector.h.

◆ AddHisto() [2/2]

◆ AddTree() [1/2]

TTree * KVEventSelector::AddTree ( const TString name,
const TString title = "" 
)

Create TTree and add to list of trees to be filled during analysis. name can be used to fill individual TTree with FillTree().

Parameters
namename for TTree
titleoptional title for TTree
Returns
pointer to new TTree

Definition at line 374 of file KVEventSelector.cpp.

◆ AddTree() [2/2]

void KVEventSelector::AddTree ( TTree tree)
inline

Definition at line 610 of file KVEventSelector.h.

◆ Analysis()

virtual Bool_t KVEventSelector::Analysis ( void  )
inlinevirtual

The Analysis() method is called for each accepted event in the TTree or TChain. Events may be rejected for two reasons:

A pointer to the current event can be obtained with the GetEvent() method. The user can then iterate over the nuclei in each event using any of the methods detailed in Iterating over nuclei in the Users Guide:

for(auto& n : EventIterator(GetEvent()) )
{
FillHisto("Zdist", n.GetZ());
}
Class for iterating over nuclei in events accessed through base pointer/reference.
void FillHisto(const Char_t *sname, Double_t one, Double_t two=1, Double_t three=1, Double_t four=1)
const Int_t n

The definition of which nuclei are OK or not is carried out before this method is called (see InitRun()). This will affect iterations such as:

for(auto& n : ReconEventOKIterator(GetEvent())) { ... }
Wrapper class for iterating over "OK" nuclei in KVReconstructedEvent accessed through base pointer or...

as well as any global variables which are defined using the default global variable list (see GetGVList()).

When analysing experimental or filtered data the "cm" frame corresponding to the centre of mass of the reaction being studied is defined for each nucleus in the event before this method is called.

Reimplemented in KVDataQualityAuditSelector, and KVEventFiltering.

Examples
ExampleAnalysis_KVEventMixerN_2Body.cpp, ExampleAnalysis_KVEventMixerN_3Body.cpp, ExampleCorrelationAnalysis.cpp, ExampleE789ReconAnalysis.cpp, ExampleFilteredSimDataAnalysis.cpp, ExampleINDRAAnalysis.cpp, ExampleReconAnalysis.cpp, and ExampleSimDataAnalysis.cpp.

Definition at line 453 of file KVEventSelector.h.

◆ AtEndOfRun()

Bool_t KVEventSelector::AtEndOfRun ( void  )
inlineprivate

Check whether the end of run is reached for the current tree

Definition at line 269 of file KVEventSelector.h.

◆ Begin()

void KVEventSelector::Begin ( TTree tree)
virtual

Reimplemented from TSelector.

Definition at line 21 of file KVEventSelector.cpp.

◆ CheckEndOfRun()

void KVEventSelector::CheckEndOfRun ( )
privatevirtual

Reimplemented in KVFAZIASelector.

Definition at line 174 of file KVEventSelector.cpp.

◆ create_output_file()

void KVEventSelector::create_output_file ( )
private

Create the file for saving histos and/or trees created during analysis.

The name of the file must first be set using SetJobOutputFileName()

Definition at line 322 of file KVEventSelector.cpp.

◆ CreateTreeFile()

Bool_t KVEventSelector::CreateTreeFile ( const Char_t filename = "")

Definition at line 363 of file KVEventSelector.cpp.

◆ EndAnalysis()

◆ EndRun()

◆ FillHisto() [1/2]

void KVEventSelector::FillHisto ( const Char_t sname,
const Char_t label,
Double_t  weight = 1 
)

Definition at line 412 of file KVEventSelector.cpp.

◆ FillHisto() [2/2]

void KVEventSelector::FillHisto ( const Char_t sname,
Double_t  one,
Double_t  two = 1,
Double_t  three = 1,
Double_t  four = 1 
)

Definition at line 386 of file KVEventSelector.cpp.

◆ FillTH1()

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

Definition at line 428 of file KVEventSelector.cpp.

◆ FillTH2()

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

Definition at line 452 of file KVEventSelector.cpp.

◆ FillTH3()

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

Definition at line 475 of file KVEventSelector.cpp.

◆ FillTProfile()

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

Definition at line 440 of file KVEventSelector.cpp.

◆ FillTProfile2D()

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

Definition at line 464 of file KVEventSelector.cpp.

◆ FillTree()

void KVEventSelector::FillTree ( const Char_t tree_name = "")

Call TTree::Fill() for TTree with given name, or for all trees associated with analysis if no name given.

Parameters
tree_name[optional] name of individual TTree to fill

Definition at line 524 of file KVEventSelector.cpp.

◆ GetBranchName()

const Char_t * KVEventSelector::GetBranchName ( ) const
inline

Definition at line 338 of file KVEventSelector.h.

◆ GetEntry()

virtual Int_t KVEventSelector::GetEntry ( Long64_t  entry,
Int_t  getall = 0 
)
inlinevirtual

Reimplemented from TSelector.

Reimplemented in KVFAZIASelector.

Definition at line 307 of file KVEventSelector.h.

◆ GetEvent()

KVEvent * KVEventSelector::GetEvent ( ) const
inline

Access current event when called from Analysis() method

Returns
pointer to current event

Definition at line 349 of file KVEventSelector.h.

◆ GetEventNumber()

Int_t KVEventSelector::GetEventNumber ( ) const
inline
Returns
number of current event

Definition at line 356 of file KVEventSelector.h.

◆ GetFriendEvent()

KVEvent * KVEventSelector::GetFriendEvent ( ) const
inline

Definition at line 315 of file KVEventSelector.h.

◆ GetFriendTreeEntry()

Int_t KVEventSelector::GetFriendTreeEntry ( Long64_t  entry,
Int_t  getall = 0 
)
inline

Definition at line 311 of file KVEventSelector.h.

◆ GetGV()

KVVarGlob * KVEventSelector::GetGV ( const Char_t name) const
inline

Access global variable in the default list of global variables for the analysis (see GetGVList())

This is equivalent to GetGVList()->GetGV( name ).

Parameters
namename of global variable to retrieve
Returns
pointer to variable if found

Definition at line 558 of file KVEventSelector.h.

◆ GetGVList() [1/2]

KVGVList * KVEventSelector::GetGVList ( const KVString list_name = "default")
inline
Parameters
list_namename of global variable list (default value: "default")
Returns
pointer to the named list of global variables

If no name is given i.e. the list_name = "default" and no such global variable lists has been defined, this will automatically create the "default" list, for which the default particle selection is to only include 'OK' particles (this is for backwards compatibility with existing analysis classes and will change in future to default selection = no selection)

If the list_name = "__internal__" and no such list exists, a list is created with no defined selection and added to the beginning of the list of global variable lists. This is used internally to implement e.g. event selection depending on various trigger criteria etc

For all other cases, global variable lists which were created with AddGVList() can be retrieved with this method

Definition at line 499 of file KVEventSelector.h.

◆ GetGVList() [2/2]

const KVGVList * KVEventSelector::GetGVList ( const KVString list_name = "default") const
inline
Parameters
list_namename of global variable list to access
Returns
read-only pointer to global variable list with given name

Definition at line 519 of file KVEventSelector.h.

◆ GetHisto()

TH1 * KVEventSelector::GetHisto ( const Char_t name) const
inline
Parameters
namename of histogram
Returns
pointer to histogram with given name added with AddHisto()

Definition at line 658 of file KVEventSelector.h.

◆ GetHistoList()

const KVHashList * KVEventSelector::GetHistoList ( ) const
inline
Returns
pointer to the list of all histograms added with AddHisto()

Definition at line 640 of file KVEventSelector.h.

◆ GetOpt()

TString KVEventSelector::GetOpt ( const Char_t option) const
inline

Definition at line 687 of file KVEventSelector.h.

◆ GetOutputList()

virtual TList * KVEventSelector::GetOutputList ( ) const
inlinevirtual

Reimplemented from TSelector.

Definition at line 327 of file KVEventSelector.h.

◆ GetTree()

TTree * KVEventSelector::GetTree ( const Char_t name) const
inline
Parameters
namename of TTree
Returns
pointer to TTree with given name added with AddTree()

Definition at line 667 of file KVEventSelector.h.

◆ GetTreeList()

const KVHashList * KVEventSelector::GetTreeList ( ) const
inline

GetTreeList.

Returns
pointer to the list of trees added with AddTree()

Definition at line 649 of file KVEventSelector.h.

◆ Init()

void KVEventSelector::Init ( TTree tree)
virtual

Reimplemented from TSelector.

Reimplemented in KVFAZIASelector, KVINDRAEventSelector, and KVReconEventSelector.

Definition at line 579 of file KVEventSelector.cpp.

◆ InitAnalysis()

virtual void KVEventSelector::InitAnalysis ( )
inlinevirtual

This is the 1st method called when a new analysis is started. It is the place to define any histograms and/or TTrees to be filled during the analysis, using AddHisto() and AddTree(), plus optionally the name of the output ROOT file containing them:

AddHisto<TH1F>("h1", "Z distribution", 50, .5, 50.5);
AddHisto<TProfile>("h2", "<pT> vs. rapidity", 200, -1., 1.);
AddTree("my_tree", "Some interesting results here");
SetJobOutputFileName("MyAmazingResults.root");
void SetJobOutputFileName(const TString &filename)

Note that by using these methods as shown here

  • the histograms and TTrees will automatically be written to file at the end of the analysis
  • the analysis can function in parallel with PROOFLite without any change to the code

This is also the place to define any global variables which the user wants to use for her analysis (see Global Variables in the Users Guide). Each analysis class can use 1 or more lists of global variables, each with an associated selection of the particles of each event to be included in the calculation of each variable (see AddGVList(), GetGVList(), AddGV() and GetGV() methods).

The user can automatically add branches to be filled with a global variable list to any TTree created here like so:

auto t = AddTree("my_tree", "Some interesting results here");
GetGVList("my_variables")->MakeBranches(t);
KVGVList * GetGVList(const KVString &list_name="default")
void MakeBranches(TTree *)
Definition KVGVList.cpp:418

See KVGVList::MakeBranches() and Automatic TTree branch creation and filling.

Reimplemented in KVDataQualityAuditSelector, and KVEventFiltering.

Examples
ExampleAnalysis_KVEventMixerN_2Body.cpp, ExampleAnalysis_KVEventMixerN_3Body.cpp, ExampleCorrelationAnalysis.cpp, ExampleE789ReconAnalysis.cpp, ExampleFilteredSimDataAnalysis.cpp, ExampleINDRAAnalysis.cpp, ExampleReconAnalysis.cpp, and ExampleSimDataAnalysis.cpp.

Definition at line 397 of file KVEventSelector.h.

◆ InitFriendTree()

void KVEventSelector::InitFriendTree ( TTree tree,
const TString branchname 
)
private
Parameters
tree
branchname

Set up a "friend" TTree/TChain containing KVEvent-derived objects in branch 'branchname' N.B. this is not a "friend" in the sense of TTree::AddFriend, the main TTree and the "friend" TTree can have different numbers of entries

After calling this method at the beginning of the analysis, you can access any of the events stored in the "friend" by doing:

Definition at line 623 of file KVEventSelector.cpp.

◆ InitRun()

virtual void KVEventSelector::InitRun ( void  )
inlinevirtual

This method is called every time a new file in the TChain is opened (for experimental data, each file represents a new 'run')

When analysing experimental or filtered data, this is the first time in the analysis where

This is the last place where the user can modify the definition of 'OK' particles (used by the default global variable list: see GetGVList()) when analysing experimental or filtered data:

Note
When a particle has been declared 'not OK', there is no way to reverse this using e.g. SetParticleConditions() which only applies to particles which are 'OK'.

Reimplemented in KVDataQualityAuditSelector_E789, KVDataQualityAuditSelector_E818, KVDataQualityAuditSelector, and KVEventFiltering.

Examples
ExampleAnalysis_KVEventMixerN_2Body.cpp, ExampleAnalysis_KVEventMixerN_3Body.cpp, ExampleCorrelationAnalysis.cpp, ExampleE789ReconAnalysis.cpp, ExampleFilteredSimDataAnalysis.cpp, ExampleINDRAAnalysis.cpp, ExampleReconAnalysis.cpp, and ExampleSimDataAnalysis.cpp.

Definition at line 418 of file KVEventSelector.h.

◆ IsOptGiven()

Bool_t KVEventSelector::IsOptGiven ( const Char_t option)
inline

Definition at line 683 of file KVEventSelector.h.

◆ Notify()

Bool_t KVEventSelector::Notify ( )
virtual

Reimplemented from TObject.

Reimplemented in KVFAZIASelector.

Definition at line 652 of file KVEventSelector.cpp.

◆ ParseOptions()

void KVEventSelector::ParseOptions ( )
privatevirtual

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.

EventsReadInterval=N: print "+++ 12345 events processed +++" every N events
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data

Reimplemented in KVFAZIASelector.

Definition at line 555 of file KVEventSelector.cpp.

◆ Process()

Bool_t KVEventSelector::Process ( Long64_t  entry)
virtual

Reimplemented from TSelector.

Definition at line 125 of file KVEventSelector.cpp.

◆ RecalculateGlobalVariables()

void KVEventSelector::RecalculateGlobalVariables ( )
private

Use this method if you change e.g. the particle selection criteria in your Analysis() method and want to recalculate the values of all global variables for your new selection.

WARNING: the global variables are calculated automatically for you for each event before method Analysis() is called. In order for the correct particles to be included in this calculation, make sure that at the END of Analysis() you reset the selection criteria.

Definition at line 243 of file KVEventSelector.cpp.

◆ SaveHistos()

virtual void KVEventSelector::SaveHistos ( const Char_t = "",
Option_t = "recreate",
Bool_t  = kFALSE 
)
inlinevirtual

Definition at line 674 of file KVEventSelector.h.

◆ SetAdditionalBranchAddress()

virtual void KVEventSelector::SetAdditionalBranchAddress ( )
inlinevirtual

To implement in child classes if user needs to initialize other branches in the analysed TTree/TChain in addition to the one containing the KVEvent objects

Access the analysed TTree/TChain through member variable fChain

Definition at line 702 of file KVEventSelector.h.

◆ SetAnalysisFrame()

void KVEventSelector::SetAnalysisFrame ( )
inlineprivate

If this analysis class is used in a context where the events correspond to a known reaction for which the kinematics have been defined, we can define the centre of mass ("CM") frame for the particles in the event.

Definition at line 275 of file KVEventSelector.h.

◆ SetBranchName()

void KVEventSelector::SetBranchName ( const Char_t n)
inline

Definition at line 334 of file KVEventSelector.h.

◆ SetCombinedOutputFile()

void KVEventSelector::SetCombinedOutputFile ( const TString filename)
inlineprivate

Call in InitAnalysis() to set the name of the single output file containing all histograms and TTrees produced by analysis (but see also SetJobOutputFileName).

This is equivalent to running the analysis with option

Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char 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.

try to initialise output file

Definition at line 241 of file KVEventSelector.h.

◆ SetCurrentRun()

virtual void KVEventSelector::SetCurrentRun ( KVDBRun )
inlinevirtual

Reimplemented in KVINDRAEventSelector, and KVReconEventSelector.

Definition at line 342 of file KVEventSelector.h.

◆ SetEvent()

void KVEventSelector::SetEvent ( KVEvent e)
inlineprivate

Definition at line 264 of file KVEventSelector.h.

◆ SetEventsReadInterval()

void KVEventSelector::SetEventsReadInterval ( Long64_t  N)
inline

Definition at line 293 of file KVEventSelector.h.

◆ SetInputList()

virtual void KVEventSelector::SetInputList ( TList input)
inlinevirtual

Reimplemented from TSelector.

Definition at line 323 of file KVEventSelector.h.

◆ SetJobOutputFileName()

void KVEventSelector::SetJobOutputFileName ( const TString filename)
inline

Call in InitAnalysis() to set the name of the output file containing all histograms and TTrees produced by analysis.

For interactive jobs or jobs using PROOF, filename will be used for the ROOT file.

For jobs using a batch system to execute many jobs in parallel, this will be replaced by the job name plus the '.root' extension.

Parameters
filenamename to use for ROOT file

Definition at line 715 of file KVEventSelector.h.

◆ SetObject()

virtual void KVEventSelector::SetObject ( TObject obj)
inlinevirtual

Reimplemented from TSelector.

Definition at line 319 of file KVEventSelector.h.

◆ SetOpt()

void KVEventSelector::SetOpt ( const Char_t option,
const Char_t value 
)
inline

Definition at line 679 of file KVEventSelector.h.

◆ SetParticleConditions()

void KVEventSelector::SetParticleConditions ( const KVParticleCondition cond)
inline

Use this method to set further criteria for selecting "OK" particles in each event (in addition to any which may be set by default: see InitRun()).

This method must be called in the user's InitAnalysis() or InitRun() method.

Parameters
condparticle selection criteria (see KVParticleCondition)

Definition at line 575 of file KVEventSelector.h.

◆ SetTriggerConditionsForRun()

void KVEventSelector::SetTriggerConditionsForRun ( int  run)
inline

Call this method in your InitRun() method with the current run number in order to automatically reject events which are not consistent with the acquisition trigger

Parameters
runcurrent run number

Definition at line 729 of file KVEventSelector.h.

◆ SetUpAuxEventChain()

void KVEventSelector::SetUpAuxEventChain ( )
private

Called by SlaveBegin() when user gives the following options:

Definition at line 493 of file KVEventSelector.cpp.

◆ SlaveBegin()

void KVEventSelector::SlaveBegin ( TTree tree)
virtual

Reimplemented from TSelector.

Reimplemented in KVFAZIASelector.

Definition at line 62 of file KVEventSelector.cpp.

◆ SlaveTerminate()

void KVEventSelector::SlaveTerminate ( )
virtual

Reimplemented from TSelector.

Definition at line 189 of file KVEventSelector.cpp.

◆ Terminate()

void KVEventSelector::Terminate ( )
virtual

Reimplemented from TSelector.

Definition at line 215 of file KVEventSelector.cpp.

◆ UnsetOpt()

void KVEventSelector::UnsetOpt ( const Char_t opt)
inline

Definition at line 691 of file KVEventSelector.h.

◆ Version()

virtual Int_t KVEventSelector::Version ( ) const
inlinevirtual

Reimplemented from TSelector.

Definition at line 297 of file KVEventSelector.h.

Member Data Documentation

◆ AuxEvent

KVEvent* KVEventSelector::AuxEvent
private

[optional] events in fAuxChain

Definition at line 199 of file KVEventSelector.h.

◆ b_Event

TBranch* KVEventSelector::b_Event
private

List of branches.

Definition at line 202 of file KVEventSelector.h.

◆ Event

KVEvent* KVEventSelector::Event
private

Declaration of leaf types.

the events to be analysed

Definition at line 198 of file KVEventSelector.h.

◆ fAuxChain

TTree* KVEventSelector::fAuxChain
private

[optional] pointer to another TTree or TChain which may be used during analysis

Definition at line 195 of file KVEventSelector.h.

◆ fBranchName

KVString KVEventSelector::fBranchName
private

name of branch which contains events to analyse

Definition at line 208 of file KVEventSelector.h.

◆ fChain

TTree* KVEventSelector::fChain
private

pointer to the analyzed TTree or TChain

Definition at line 194 of file KVEventSelector.h.

◆ fCombinedOutputFile

KVString KVEventSelector::fCombinedOutputFile
private

name for ROOT file containing histos and/or trees produced by analysis

Definition at line 222 of file KVEventSelector.h.

◆ fDisableCreateTreeFile

Bool_t KVEventSelector::fDisableCreateTreeFile
private

used with PROOF

Definition at line 227 of file KVEventSelector.h.

◆ fEventsRead

Long64_t KVEventSelector::fEventsRead
private

number of events read

Definition at line 214 of file KVEventSelector.h.

◆ fEventsReadInterval

Long64_t KVEventSelector::fEventsReadInterval
private

interval at which to print number of events read

Definition at line 215 of file KVEventSelector.h.

◆ fFirstEvent

Bool_t KVEventSelector::fFirstEvent
private

set to kFALSE after first event is read

Definition at line 212 of file KVEventSelector.h.

◆ fGlobalVariableAbortEventAnalysis

Bool_t KVEventSelector::fGlobalVariableAbortEventAnalysis
private

Definition at line 206 of file KVEventSelector.h.

◆ fGlobalVariables

KVUniqueNameList KVEventSelector::fGlobalVariables
private

Lists of global variables with different selection criteria.

Definition at line 205 of file KVEventSelector.h.

◆ fNotifyCalled

Bool_t KVEventSelector::fNotifyCalled
private

avoid multiple calls to Notify/InitRun

Definition at line 221 of file KVEventSelector.h.

◆ fOptionList

KVUserAnalysisOptionList KVEventSelector::fOptionList
private

parsed list of options given to TTree::Process

Definition at line 225 of file KVEventSelector.h.

◆ fPartCond

KVParticleCondition KVEventSelector::fPartCond
private

(optional) conditions for selecting particles

Definition at line 210 of file KVEventSelector.h.

◆ fTreeEntry

Long64_t KVEventSelector::fTreeEntry
private

current tree entry number

Definition at line 216 of file KVEventSelector.h.

◆ lhisto

KVHashList KVEventSelector::lhisto
private

list of histograms added with AddHisto

Definition at line 218 of file KVEventSelector.h.

◆ ltree

KVHashList KVEventSelector::ltree
private

list of trees added with AddTree

Definition at line 219 of file KVEventSelector.h.

◆ mergeFile

TProofOutputFile* KVEventSelector::mergeFile = nullptr
private

output file for trees and histos

Definition at line 229 of file KVEventSelector.h.

◆ writeFile

TFile* KVEventSelector::writeFile = nullptr
private

Definition at line 228 of file KVEventSelector.h.