AliRoot Core  3dc7879 (3dc7879)
AliTreePlayer Class Reference

Set of functions to extend functionality of the TTreePlayer. More...

#include <AliTreePlayer.h>

Inheritance diagram for AliTreePlayer:

Public Types

enum  TStatType {
  kUndef =-1, kEntries, kSum, kMean,
  kRMS, kMedian, kLTM, kLTMRMS,
  kMedianLeft, kMedianRight, kMax, kMin
}
 

Public Member Functions

 AliTreePlayer ()
 
 AliTreePlayer (const char *name, const char *title)
 

Static Public Member Functions

static TObjArrayselectMetadata (TTree *tree, TString query, Int_t verbose, TString *idList=NULL)
 
static TObjArrayselectTreeInfo (TTree *tree, TString query, Int_t verbose)
 
static Int_t selectWhatWhereOrderBy (TTree *tree, TString what, TString where, TString orderBy, Int_t firstentry, Int_t nentries, TString outputFormat, TString outputName)
 
static TString printSelectedTreeInfo (TTree *tree, TString infoType, TString regExpFriend, TString regExpTag, Int_t verbose)
 
static TObjArrayMakeHistograms (TTree *tree, TString hisString, TString defaultCut, Int_t firstEntry, Int_t lastEntry, Int_t chunkSize=-1, Int_t verbose=1)
 
static TPad * DrawHistograms (TPad *pad, TObjArray *hisArray, TString drawExpression, TObjArray *keepArray=0, Int_t verbose=0)
 
static void MakeCacheTree (TTree *tree, TString varList, TString outFile, TString outTree, TCut selection, Int_t nEntries=-1, Int_t firstEntry=0)
 Fill tree with information specified in varList of TTreeFormulas Used to cache CPU consuming formulas In case input tree is "flat" - not array output tree can be used as a friend .... More...
 
template<typename T >
static Long64_t BinarySearchSmaller (Long64_t n, const T *array, T value)
 
static Int_t GetStatType (const TString &stat)
 
static void AddStatInfo (TTree *treeLeft, TTree *treeRight, const TString refQuery, Double_t deltaT, const TString statString="median:medianLeft:medianRight:RMS:Mean:LTM0.60:LTMRMS0.60:Max:Min", Int_t maxEntries=100000000)
 
static TTree * LoadTrees (const char *inputDataList, const char *chRegExp, const char *chNotReg, TString inputFileSelection, TString axisAlias, TString axisTitle)
 LoadTrees and and append friend trees. More...
 

Detailed Description

Set of functions to extend functionality of the TTreePlayer.

  • Input data sources - TTree Friend trees
  • Data source can be configured independently using class AliExternalInfo and subdet of fuctionality in the TStatToolkit
    • friend relation
    • indices
    • metatadata for branches,aliases (class, Axis,AxisTitle,Legen, Html, description ...)

      Functionality

  • function to support metadata and collumn annotation
  • filtering function (branch, aliases metadata)
  • select function - export to (json, csv, html, JIRA) + metadata (not yet implemented)

    • subset of metadata for columns included in select export outputName.metadata
      • select function - for root trees
    • to be done using TTree::CopyTree functionality switching ON/OFF selected branches - metadata should be exported automatically (to check)

    See example usage in the test macro AliTreePlayerTest.C

    AliTreePlayerTest.C::testAll();
    AliTreePlayerTest.C::testSelectMetadata()
    AliTreePlayerTest.C::testselectTreeInfo()
Author
Marian Ivanov

Definition at line 94 of file AliTreePlayer.h.

Member Enumeration Documentation

Enumerator
kUndef 
kEntries 
kSum 
kMean 
kRMS 
kMedian 
kLTM 
kLTMRMS 
kMedianLeft 
kMedianRight 
kMax 
kMin 

Definition at line 107 of file AliTreePlayer.h.

Constructor & Destructor Documentation

AliTreePlayer::AliTreePlayer ( )
inline

Definition at line 96 of file AliTreePlayer.h.

AliTreePlayer::AliTreePlayer ( const char *  name,
const char *  title 
)

Dummy AliTreePlayerConstructor

Parameters
name
title

Definition at line 184 of file AliTreePlayer.cxx.

Member Function Documentation

void AliTreePlayer::AddStatInfo ( TTree *  treeLeft,
TTree *  treeRight,
const TString  refQuery,
Double_t  deltaT,
const TString  statString = "median:medianLeft:medianRight:RMS:Mean:LTM0.60:LTMRMS0.60:Max:Min",
Int_t  maxEntries = 100000000 
)
static
Parameters
treeLeft
treeRight
refQuery
deltaT
statString
maxEntries

Definition at line 909 of file AliTreePlayer.cxx.

template<typename T >
Long64_t AliTreePlayer::BinarySearchSmaller ( Long64_t  n,
const T *  array,
value 
)
static

Binary search in an array of n values to locate value. Array is supposed to be sorted prior to this call.

Template Parameters
T- template (float,double,int ..)
Parameters
n- size of array
array- pointer to raw array
value- value to find
Returns
nearest element smaller than value.

Definition at line 142 of file AliTreePlayer.h.

Referenced by AddStatInfo().

TPad * AliTreePlayer::DrawHistograms ( TPad *  pad,
TObjArray hisArray,
TString  drawExpression,
TObjArray keepArray = 0,
Int_t  verbose = 0 
)
static

Definition at line 1324 of file AliTreePlayer.cxx.

Referenced by makeP4Report().

Int_t AliTreePlayer::GetStatType ( const TString &  stat)
static

Get the enumeration type from a string

Parameters
stat- enumuration tyle as a string
Returns
Get the enumeration type from a string

Definition at line 871 of file AliTreePlayer.cxx.

Referenced by AddStatInfo().

TTree * AliTreePlayer::LoadTrees ( const char *  inputDataList,
const char *  chRegExp,
const char *  chNotReg,
TString  inputFileSelection,
TString  axisAlias,
TString  axisTitle 
)
static

LoadTrees and and append friend trees.

Parameters
inputDataList- command returning input data list - line with #tag:value for the metadata definition
chRegExp- regular expression - trees to include
chNotReg- regular expression - trees to exclude
inputFileSelection- : separated input file selection
axisAlias- axis names
axisTitle- axis titles
Returns
- resulting tree

read metadata #tag:value information - signed by # at the beginning of the line

add metadata to all files ....

Definition at line 1587 of file AliTreePlayer.cxx.

void AliTreePlayer::MakeCacheTree ( TTree *  tree,
TString  varList,
TString  outFile,
TString  outTree,
TCut  selection,
Int_t  nEntries = -1,
Int_t  firstEntry = 0 
)
static

Fill tree with information specified in varList of TTreeFormulas Used to cache CPU consuming formulas In case input tree is "flat" - not array output tree can be used as a friend ....

Parameters
tree- TTree with input
varList- list of TTreeFormulas to export
outFile- output file name
outTree- output tree name
selection- tree selection
firstEntry- first entry to export
nEntries- number of nEntries to export

Definition at line 1551 of file AliTreePlayer.cxx.

Referenced by cacheTree().

TObjArray * AliTreePlayer::MakeHistograms ( TTree *  tree,
TString  hisString,
TString  defaultCut,
Int_t  firstEntry,
Int_t  lastEntry,
Int_t  chunkSize = -1,
Int_t  verbose = 1 
)
static

Create list of histograms specified by selection Should be rough equivalent of the "ALICE train" TTree->Draw(); a.) Data are read only once b.) values expression are reused (evaluated only once) c.) Axis labelling and names of variables extracted from the tree metadata (.AxisTitle)

  • default cut
    • default selection applied common for all histograms (can be empty)
  • hisString : - semicolomn separated string
    • his0;his1; ...; hisN
  • histogram syntax:
    • var0:var1:...:<#weight>>>hisName(bins0,min0,max0,bins1,min0,min, minValue,maxValue)
    • Syntax:
      • vari are histogramming expression
      • weight (or cut) entry is optional
        • default cut is always applied, weight is applied on top
    • ranges syntax:
      • nbins,max,min where max and min are double or format strings
        • in case format string % specified using (Fraction, mean,meanFraction, rms, rmsFraction)
          • fraction.sigma
          • #cumulant
          • range for bin content can be specified in the same format (by default is not set)
CPU time to process one histogram or set of histograms (in particular case of esdTrack queries) is the same - and it is determined (90 %) by tree->GetEntry
THn * his0= (THn*)hisArray->At(0);
his0->Projection(0)->Draw("");
tree->SetLineColor(2);
TStopwatch timer; tree->Draw("esdTrack.Pt()","(esdTrack.fFlags&0x40)>0&&esdTrack.fTPCncls>70","same",60000); timer.Print();
Parameters
tree- input tree
hisString- selection string
defaultCut- default selection applied common for all histograms (can be empty)
firstEntry- first entry to process
lastEntry- last entry to process
chunkSize- chunk size
verbose- verbosity
Returns
- TObjArray of N-dimensional histograms

Example usage:

chunkSize=10000;
verbose=7;
chinput=gSystem->ExpandPathName("$NOTES/JIRA/PWGPP-227/data/2016/LHC16t/000267161/pass1_CENT_wSDD/filteredLocal.list");
TString defaultCut="esdTrack.fTPCncls>70";
TTree *tree=(TTree*)AliXRDPROOFtoolkit::MakeChain(chinput, "highPt", 0, 1000000000,0);
TString hisString="";
hisString+="esdTrack.Pt():#esdTrack.fTPCncls>70>>hisPtAll(100,0,30);";
hisString+="esdTrack.GetAlpha():#esdTrack.fTPCncls>70>>hisAlpha(90,-3.2,3.2);";
hisString+="esdTrack.GetTgl():#esdTrack.fTPCncls>70>>hisTgl(20,-1.2,1.2);";
hisString+="esdTrack.Pt():esdTrack.GetAlpha():esdTrack.GetTgl():#esdTrack.fTPCncls>70>>hisPtPhiThetaAll(100,0,30,90,-3.2,3.2,20,-1.2,1.2);";
hisString+="esdTrack.Pt():#(esdTrack.fFlags&0x4)>0>>hisPtITS(100,1,10);";
hisString+="esdTrack.fIp.Pt():#(esdTrack.fFlags&0x4)>0>>hisPtTPCOnly(100,1,10);";
TStopwatch timer; hisArray = AliTreePlayer::MakeHistograms(tree, hisString, "(esdTrack.fFlags&0x40)>0&&esdTrack.fTPCncls>70",0,60000,100000); timer.Print();

Definition at line 1118 of file AliTreePlayer.cxx.

TString AliTreePlayer::printSelectedTreeInfo ( TTree *  tree,
TString  infoType,
TString  regExpFriend,
TString  regExpTag,
Int_t  verbose 
)
static
Parameters
tree- input master tree pointer
infoType- array in which information is queried - "branch" "alias" "metaData" and logical or
regExpFriend- regular expression patter, where to seek (default empty - master tree)
regExpTag- regular expression tag to be queried - use non case sensitive Contain ( use as ^regExpTag$ to get full match )
verbose- verbosity flag
Returns
return selected string

Definition at line 427 of file AliTreePlayer.cxx.

TObjArray * AliTreePlayer::selectMetadata ( TTree *  tree,
TString  query,
Int_t  verbose,
TString *  idList = NULL 
)
static

Selected metadata fil filing query retun TObjArray of selected metadata

Parameters
tree
query
verbose
Returns
TObjArray of selected metadata

Example usage:

query="[AxisTitle]"; // only metadata with metadata axis existing
query="[class]"; // only metadata with metadata class existing
query="[class==\"Base&&Log&&Stat\"]"; // metadata class contains
//
AliTreePlayer::selectMetadata(treeLogbook, "[class==\"Logbook&&(Stat||Base)\"]",0)->Print();
AliTreePlayer::selectMetadata(testTree, "[Axis==\"counts\"]",0)->Print();

Definition at line 210 of file AliTreePlayer.cxx.

Referenced by drawLogbook(), logbookAddMetadata(), qaitsAddMetadata(), qatpcAddMetadata(), qatrdAddMetadata(), testSelectMetadata(), and TPCDataVolumeDemo().

TObjArray * AliTreePlayer::selectTreeInfo ( TTree *  tree,
TString  query,
Int_t  verbose 
)
static

Find all branches containing "Data string" and having class base search follow only branches - does not not enter into classes == - for exact match : - for contain Implemented using TFormula interpreter:

  • TODO - not case sensitive (should be part of unit test)
    Parameters
    tree- input tree
    query- query string
    verbose- verbosity
    Returns
    ### Implementation using TFormula
    TString query="([.name==Data])&&([.class==base]||[.class==Data])";
    ==>
    TFormula (x[0])&&(x[1]||x[2])

    Example cases :

AliTreePlayer::selectTreeInfo(treeTPC, "([.name:mean] && [.name:MIP])",0)->Print();
AliTreePlayer:: selectTreeInfo(treeLogbook, "([.name:ata] && [.AxisTitle:size])",0)->Print();
In case of problems unit test in separate file
-- AliTreePlayerTest.C::testselectTreeInfo()

Definition at line 310 of file AliTreePlayer.cxx.

Referenced by testselectTreeInfo().

Int_t AliTreePlayer::selectWhatWhereOrderBy ( TTree *  tree,
TString  what,
TString  where,
TString  orderBy,
Int_t  firstentry,
Int_t  nentries,
TString  outputFormat,
TString  outputName 
)
static
Parameters
tree- input tree
what- variables to export (any valid TTree formula or class (in case ob JSON export))
where- selection criteria as in the TTree::Draw
firstentry- first entry in tree to export
nentries- number of entries to
outputFormat- output format (csv,json, elastic json - for bulk export,html table)
outputName
Returns
- status

Definition at line 504 of file AliTreePlayer.cxx.

Referenced by CheckProductions(), ExportMCAnchorJSON(), makeHTMLPage(), testConvertTree(), testExportBinary(), testExportClass(), and testselectWhatWhereOrderByForTRD().


The documentation for this class was generated from the following files: