Crombie Tools
TreeContainer Class Reference

Can be called from the CrombieTools.CommonTools.TreeContainer module. More...

#include <TreeContainer.h>

Public Member Functions

 TreeContainer (TString fileName="")
 TreeContainer Constructor. More...
 
virtual ~TreeContainer ()
 
void AddDirectory (TString directoryName, TString searchFor=".root")
 Adds all of the files located in a particular directory. More...
 
void AddFile (TString fileName)
 Adds another file to the list of files contained in TreeContainer. More...
 
void AddFriendName (TString name)
 Add a friend to look for in each file. More...
 
void AddKeepBranch (TString name)
 Use this to keep only certain branches when trees are returned. More...
 
void MakeFile (TString fileName="", TString treeName="")
 Write a single TTree into a TFile. More...
 
std::vector< TFile * > ReturnFileList ()
 Return vector of TFile pointers read by the TreeContainer. More...
 
std::vector< TString > ReturnFileNames ()
 Return vector of file names read by the TreeContainer. More...
 
TTree * ReturnTree (TString Name="", TFile *inFile=NULL)
 Return all of the trees contained as a single TTree pointer. More...
 
std::vector< TTree * > ReturnTreeList (TString Name="")
 Return all of the trees contained as a vector of TTree pointers. More...
 
void SetOutputFileName (TString name)
 Use this to set an output file to place a single tree. More...
 
void SetPrinting (Bool_t printing)
 Set the printing level for debugging. More...
 
void SetSkimmingCut (TCut cut)
 Set a cut to apply to returned trees. More...
 
void SetTreeName (TString TreeName)
 Sets the name of the tree searched for in the input files. More...
 

Private Member Functions

TTree * SkimTree (TTree *tree, TFile *inFile)
 

Private Attributes

std::vector< TFile * > fFileList
 List of files. More...
 
std::vector< TString > fFileNames
 Used to track names of files where tree list come from. More...
 
std::vector< TString > fFriendNames
 
std::vector< TString > fKeepBranches
 Branches kept in the event of skimming. More...
 
TString fOutputFileName = "output.root"
 Potential output file name of skim. More...
 
Bool_t fPrinting = false
 Printer for debugging. More...
 
TCut fSkimmingCut = ""
 Cut to return only branches meeting given conditions. More...
 
TTree * fTree = NULL
 Keep pointer to be deleted at end. More...
 
std::vector< TTree * > fTreeList
 List of trees. More...
 
TString fTreeName = "events"
 Name of Trees looking for. More...
 
TFile * tempFile = NULL
 Pointer to File. More...
 
TTree * tempFriend = NULL
 
TTree * tempTree = NULL
 Pointer to Tree. More...
 

Detailed Description

Can be called from the CrombieTools.CommonTools.TreeContainer module.

Capable of holding many trees and skimming them. Probably just a poor reimplementation of TChain, but I have code that depends on this now.

Definition at line 26 of file TreeContainer.h.

Constructor & Destructor Documentation

§ TreeContainer()

TreeContainer::TreeContainer ( TString  fileName = "")

TreeContainer Constructor.

Parameters
fileNamecan either be the name of a single file or a directory. If it's a file, that file is opened. If it's a directory, all the .root files in that directory are opened

§ ~TreeContainer()

TreeContainer::~TreeContainer ( )
virtual

Definition at line 29 of file TreeContainer.cc.

References fFileList, and fTree.

Member Function Documentation

§ AddDirectory()

void TreeContainer::AddDirectory ( TString  directoryName,
TString  searchFor = ".root" 
)

Adds all of the files located in a particular directory.

Definition at line 54 of file TreeContainer.cc.

References crombie_completion::dir, fFileList, fFileNames, fPrinting, and tempFile.

Referenced by TmvaClassifier::Apply().

§ AddFile()

void TreeContainer::AddFile ( TString  fileName)

Adds another file to the list of files contained in TreeContainer.

Definition at line 41 of file TreeContainer.cc.

References fFileList, fFileNames, fPrinting, and tempFile.

§ AddFriendName()

void TreeContainer::AddFriendName ( TString  name)
inline

Add a friend to look for in each file.

Definition at line 54 of file TreeContainer.h.

References fFriendNames.

§ AddKeepBranch()

void TreeContainer::AddKeepBranch ( TString  name)
inline

Use this to keep only certain branches when trees are returned.

Definition at line 59 of file TreeContainer.h.

References fKeepBranches.

§ MakeFile()

void TreeContainer::MakeFile ( TString  fileName = "",
TString  treeName = "" 
)

Write a single TTree into a TFile.

Definition at line 166 of file TreeContainer.cc.

References fOutputFileName, fTree, fTreeName, dojob::outFile, ReturnTree(), SetOutputFileName(), and SetTreeName().

§ ReturnFileList()

std::vector<TFile*> TreeContainer::ReturnFileList ( )
inline

Return vector of TFile pointers read by the TreeContainer.

Definition at line 68 of file TreeContainer.h.

References fFileList.

§ ReturnFileNames()

std::vector<TString> TreeContainer::ReturnFileNames ( )
inline

Return vector of file names read by the TreeContainer.

Definition at line 66 of file TreeContainer.h.

References fFileNames.

Referenced by TmvaClassifier::Apply().

§ ReturnTree()

TTree * TreeContainer::ReturnTree ( TString  Name = "",
TFile *  inFile = NULL 
)

Return all of the trees contained as a single TTree pointer.

Definition at line 101 of file TreeContainer.cc.

References fTree, fTreeList, ReturnTreeList(), SetTreeName(), and tempTree.

Referenced by TmvaClassifier::Apply(), MakeFile(), and TmvaClassifier::TmvaClassify().

§ ReturnTreeList()

std::vector< TTree * > TreeContainer::ReturnTreeList ( TString  Name = "")

Return all of the trees contained as a vector of TTree pointers.

Definition at line 131 of file TreeContainer.cc.

References fFileList, fFriendNames, fKeepBranches, fPrinting, fSkimmingCut, fTreeList, fTreeName, SetTreeName(), SkimTree(), tempFriend, and tempTree.

Referenced by TmvaClassifier::Apply(), and ReturnTree().

§ SetOutputFileName()

void TreeContainer::SetOutputFileName ( TString  name)
inline

Use this to set an output file to place a single tree.

Definition at line 61 of file TreeContainer.h.

References fOutputFileName.

Referenced by MakeFile().

§ SetPrinting()

void TreeContainer::SetPrinting ( Bool_t  printing)
inline

Set the printing level for debugging.

Definition at line 56 of file TreeContainer.h.

References fPrinting.

§ SetSkimmingCut()

void TreeContainer::SetSkimmingCut ( TCut  cut)
inline

Set a cut to apply to returned trees.

Definition at line 63 of file TreeContainer.h.

References fSkimmingCut.

Referenced by TmvaClassifier::Apply(), and TmvaClassifier::TmvaClassify().

§ SetTreeName()

void TreeContainer::SetTreeName ( TString  TreeName)
inline

Sets the name of the tree searched for in the input files.

Definition at line 52 of file TreeContainer.h.

References fTreeName, and oldmaketree::TreeName.

Referenced by MakeFile(), ReturnTree(), and ReturnTreeList().

§ SkimTree()

TTree * TreeContainer::SkimTree ( TTree *  tree,
TFile *  inFile 
)
private

Definition at line 78 of file TreeContainer.cc.

References fKeepBranches, and fSkimmingCut.

Referenced by ReturnTreeList().

Member Data Documentation

§ fFileList

std::vector<TFile*> TreeContainer::fFileList
private

List of files.

Definition at line 78 of file TreeContainer.h.

Referenced by AddDirectory(), AddFile(), ReturnFileList(), ReturnTreeList(), and ~TreeContainer().

§ fFileNames

std::vector<TString> TreeContainer::fFileNames
private

Used to track names of files where tree list come from.

Definition at line 86 of file TreeContainer.h.

Referenced by AddDirectory(), AddFile(), and ReturnFileNames().

§ fFriendNames

std::vector<TString> TreeContainer::fFriendNames
private

Definition at line 77 of file TreeContainer.h.

Referenced by AddFriendName(), and ReturnTreeList().

§ fKeepBranches

std::vector<TString> TreeContainer::fKeepBranches
private

Branches kept in the event of skimming.

Definition at line 82 of file TreeContainer.h.

Referenced by AddKeepBranch(), ReturnTreeList(), and SkimTree().

§ fOutputFileName

TString TreeContainer::fOutputFileName = "output.root"
private

Potential output file name of skim.

Definition at line 83 of file TreeContainer.h.

Referenced by MakeFile(), and SetOutputFileName().

§ fPrinting

Bool_t TreeContainer::fPrinting = false
private

Printer for debugging.

Definition at line 72 of file TreeContainer.h.

Referenced by AddDirectory(), AddFile(), ReturnTreeList(), and SetPrinting().

§ fSkimmingCut

TCut TreeContainer::fSkimmingCut = ""
private

Cut to return only branches meeting given conditions.

Definition at line 84 of file TreeContainer.h.

Referenced by ReturnTreeList(), SetSkimmingCut(), and SkimTree().

§ fTree

TTree* TreeContainer::fTree = NULL
private

Keep pointer to be deleted at end.

Definition at line 80 of file TreeContainer.h.

Referenced by MakeFile(), ReturnTree(), and ~TreeContainer().

§ fTreeList

std::vector<TTree*> TreeContainer::fTreeList
private

List of trees.

Definition at line 79 of file TreeContainer.h.

Referenced by ReturnTree(), and ReturnTreeList().

§ fTreeName

TString TreeContainer::fTreeName = "events"
private

Name of Trees looking for.

Definition at line 76 of file TreeContainer.h.

Referenced by MakeFile(), ReturnTreeList(), and SetTreeName().

§ tempFile

TFile* TreeContainer::tempFile = NULL
private

Pointer to File.

Definition at line 73 of file TreeContainer.h.

Referenced by AddDirectory(), and AddFile().

§ tempFriend

TTree* TreeContainer::tempFriend = NULL
private

Definition at line 75 of file TreeContainer.h.

Referenced by ReturnTreeList().

§ tempTree

TTree* TreeContainer::tempTree = NULL
private

Pointer to Tree.

Definition at line 74 of file TreeContainer.h.

Referenced by ReturnTree(), and ReturnTreeList().


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