KaliVeda
Toolkit for HIC analysis
|
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:
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
:
where [options]
is a list of options in the form BranchName=toto, ...
.
The following options MUST be given:
The following are optional options:
When AuxFiles
is used, the user can access the events in these files in her Analysis() method by doing the following:
Any other options can be defined by the user and parsed in her analysis class with methods IsOptGiven() and GetOpt()
The 5 methods listed above will be called in the following order during a typical analysis:
User's histograms and/or TTrees are therefore initialised in InitAnalysis(), as well as any required 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:
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.
In order to use a KVEventSelector with PROOF:
Histograms can also be declared 'on the fly' in the Analysis() method in the same way;
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;
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:
Definition at line 191 of file KVEventSelector.h.
#include <KVEventSelector.h>
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 | |
KVEvent * | AuxEvent |
[optional] events in fAuxChain | |
TBranch * | b_Event |
List of branches. | |
KVEvent * | Event |
Declaration of leaf types. | |
TTree * | fAuxChain |
[optional] pointer to another TTree or TChain which may be used during analysis | |
KVString | fBranchName |
name of branch which contains events to analyse | |
TTree * | fChain |
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 | |
TProofOutputFile * | mergeFile = nullptr |
output file for trees and histos | |
TFile * | writeFile = 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 TClass * | Class () |
static const char * | Class_Name () |
static constexpr Version_t | Class_Version () |
static const char * | DeclFileName () |
static TSelector * | GetSelector (const char *filename) |
static Bool_t | IsStandardDraw (const char *selec) |
Static Public Member Functions inherited from TObject | |
static TClass * | Class () |
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 |
TList * | fInput |
TObject * | fObject |
TString | fOption |
TSelectorList * | fOutput |
Long64_t | fStatus |
Protected Attributes inherited from TObject | |
kOnlyPrepStep | |
|
inline |
Definition at line 288 of file KVEventSelector.h.
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.
Declare a TTree to be used in analysis. This method must be called when using PROOF.
Definition at line 301 of file KVEventSelector.cpp.
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())
class_name | global variable class to use (see list here: Global Variables ) |
name | name of new global variable |
Definition at line 545 of file KVEventSelector.h.
Add the global variable to the default list (see GetGVList()).
Equivalent to GetGVList()->AddGV(vg)
vg | pointer to a heap-allocated KVVarGlob object |
Definition at line 530 of file KVEventSelector.h.
|
inline |
Create a new list of global variables with given name and an optional particle selection.
[in] | list_name | name 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 |
Definition at line 473 of file KVEventSelector.h.
|
inline |
Add a user histogram to the analysis. The name of the histogram can later be used in calls to FillHisto().
HistoType | valid ROOT histogram class name |
args | arguments required by constructor of HistoType class |
Definition at line 603 of file KVEventSelector.h.
Create TTree and add to list of trees to be filled during analysis. name
can be used to fill individual TTree with FillTree().
Definition at line 374 of file KVEventSelector.cpp.
Definition at line 610 of file KVEventSelector.h.
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:
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:
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.
Definition at line 453 of file KVEventSelector.h.
Check whether the end of run is reached for the current tree
Definition at line 269 of file KVEventSelector.h.
Reimplemented from TSelector.
Definition at line 21 of file KVEventSelector.cpp.
|
privatevirtual |
Reimplemented in KVFAZIASelector.
Definition at line 174 of file KVEventSelector.cpp.
|
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.
Definition at line 363 of file KVEventSelector.cpp.
Reimplemented in KVDataQualityAuditSelector, and KVEventFiltering.
Definition at line 461 of file KVEventSelector.h.
Reimplemented in KVDataQualityAuditSelector, and KVEventFiltering.
Definition at line 457 of file KVEventSelector.h.
Definition at line 412 of file KVEventSelector.cpp.
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.
Definition at line 428 of file KVEventSelector.cpp.
Definition at line 452 of file KVEventSelector.cpp.
|
private |
Definition at line 475 of file KVEventSelector.cpp.
|
private |
Definition at line 440 of file KVEventSelector.cpp.
|
private |
Definition at line 464 of file KVEventSelector.cpp.
Call TTree::Fill() for TTree with given name, or for all trees associated with analysis if no name given.
tree_name | [optional] name of individual TTree to fill |
Definition at line 524 of file KVEventSelector.cpp.
Definition at line 338 of file KVEventSelector.h.
Reimplemented from TSelector.
Reimplemented in KVFAZIASelector.
Definition at line 307 of file KVEventSelector.h.
|
inline |
Access current event when called from Analysis() method
Definition at line 349 of file KVEventSelector.h.
|
inline |
Definition at line 356 of file KVEventSelector.h.
|
inline |
Definition at line 315 of file KVEventSelector.h.
Definition at line 311 of file KVEventSelector.h.
Access global variable in the default list of global variables for the analysis (see GetGVList())
This is equivalent to GetGVList()->GetGV( name ).
name | name of global variable to retrieve |
Definition at line 558 of file KVEventSelector.h.
list_name | name of global variable list (default value: "default") |
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.
list_name | name of global variable list to access |
Definition at line 519 of file KVEventSelector.h.
name | name of histogram |
Definition at line 658 of file KVEventSelector.h.
|
inline |
Definition at line 640 of file KVEventSelector.h.
Definition at line 687 of file KVEventSelector.h.
Reimplemented from TSelector.
Definition at line 327 of file KVEventSelector.h.
name | name of TTree |
Definition at line 667 of file KVEventSelector.h.
|
inline |
GetTreeList.
Definition at line 649 of file KVEventSelector.h.
Reimplemented from TSelector.
Reimplemented in KVFAZIASelector, KVINDRAEventSelector, and KVReconEventSelector.
Definition at line 579 of file KVEventSelector.cpp.
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:
Note that by using these methods as shown here
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:
See KVGVList::MakeBranches() and Automatic TTree branch creation and filling.
Reimplemented in KVDataQualityAuditSelector, and KVEventFiltering.
Definition at line 397 of file KVEventSelector.h.
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.
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
gDataAnalyser->GetKinematics()
: see KVDataAnalyser::GetKinematics())gMultiDetArray
: see Detector Array Geometries in the Users Guide)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:
Reimplemented in KVDataQualityAuditSelector_E789, KVDataQualityAuditSelector_E818, KVDataQualityAuditSelector, and KVEventFiltering.
Definition at line 418 of file KVEventSelector.h.
Definition at line 683 of file KVEventSelector.h.
|
virtual |
Reimplemented from TObject.
Reimplemented in KVFAZIASelector.
Definition at line 652 of file KVEventSelector.cpp.
|
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.
Reimplemented in KVFAZIASelector.
Definition at line 555 of file KVEventSelector.cpp.
Reimplemented from TSelector.
Definition at line 125 of file KVEventSelector.cpp.
|
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.
|
inlinevirtual |
Definition at line 674 of file KVEventSelector.h.
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.
|
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.
Definition at line 334 of file KVEventSelector.h.
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
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.
Reimplemented in KVINDRAEventSelector, and KVReconEventSelector.
Definition at line 342 of file KVEventSelector.h.
Definition at line 264 of file KVEventSelector.h.
Definition at line 293 of file KVEventSelector.h.
Reimplemented from TSelector.
Definition at line 323 of file KVEventSelector.h.
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.
filename | name to use for ROOT file |
Definition at line 715 of file KVEventSelector.h.
Reimplemented from TSelector.
Definition at line 319 of file KVEventSelector.h.
Definition at line 679 of file KVEventSelector.h.
|
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.
cond | particle selection criteria (see KVParticleCondition) |
Definition at line 575 of file KVEventSelector.h.
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
run | current run number |
Definition at line 729 of file KVEventSelector.h.
|
private |
Called by SlaveBegin() when user gives the following options:
Definition at line 493 of file KVEventSelector.cpp.
Reimplemented from TSelector.
Reimplemented in KVFAZIASelector.
Definition at line 62 of file KVEventSelector.cpp.
|
virtual |
Reimplemented from TSelector.
Definition at line 189 of file KVEventSelector.cpp.
|
virtual |
Reimplemented from TSelector.
Definition at line 215 of file KVEventSelector.cpp.
Definition at line 691 of file KVEventSelector.h.
Reimplemented from TSelector.
Definition at line 297 of file KVEventSelector.h.
|
private |
[optional] events in fAuxChain
Definition at line 199 of file KVEventSelector.h.
|
private |
List of branches.
Definition at line 202 of file KVEventSelector.h.
|
private |
Declaration of leaf types.
the events to be analysed
Definition at line 198 of file KVEventSelector.h.
|
private |
[optional] pointer to another TTree or TChain which may be used during analysis
Definition at line 195 of file KVEventSelector.h.
|
private |
name of branch which contains events to analyse
Definition at line 208 of file KVEventSelector.h.
|
private |
pointer to the analyzed TTree or TChain
Definition at line 194 of file KVEventSelector.h.
|
private |
name for ROOT file containing histos and/or trees produced by analysis
Definition at line 222 of file KVEventSelector.h.
|
private |
used with PROOF
Definition at line 227 of file KVEventSelector.h.
|
private |
number of events read
Definition at line 214 of file KVEventSelector.h.
|
private |
interval at which to print number of events read
Definition at line 215 of file KVEventSelector.h.
|
private |
set to kFALSE after first event is read
Definition at line 212 of file KVEventSelector.h.
|
private |
Definition at line 206 of file KVEventSelector.h.
|
private |
Lists of global variables with different selection criteria.
Definition at line 205 of file KVEventSelector.h.
|
private |
avoid multiple calls to Notify/InitRun
Definition at line 221 of file KVEventSelector.h.
|
private |
parsed list of options given to TTree::Process
Definition at line 225 of file KVEventSelector.h.
|
private |
(optional) conditions for selecting particles
Definition at line 210 of file KVEventSelector.h.
|
private |
current tree entry number
Definition at line 216 of file KVEventSelector.h.
|
private |
list of histograms added with AddHisto
Definition at line 218 of file KVEventSelector.h.
|
private |
list of trees added with AddTree
Definition at line 219 of file KVEventSelector.h.
|
private |
output file for trees and histos
Definition at line 229 of file KVEventSelector.h.
|
private |
Definition at line 228 of file KVEventSelector.h.