JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
QwRootTree Class Reference

Wrapper class for ROOT tree management with vector-based data storage. More...

#include <QwRootFile.h>

+ Collaboration diagram for QwRootTree:

Public Member Functions

 QwRootTree (const std::string &name, const std::string &desc, const std::string &prefix="")
 Constructor with name, and description.
 
 QwRootTree (const QwRootTree *tree, const std::string &prefix="")
 Constructor with existing tree.
 
template<class T>
 QwRootTree (const std::string &name, const std::string &desc, T &object, const std::string &prefix="")
 Constructor with name, description, and object.
 
template<class T>
 QwRootTree (const QwRootTree *tree, T &object, const std::string &prefix="")
 Constructor with existing tree, and object.
 
virtual ~QwRootTree ()
 Destructor.
 
template<class T>
void FillTreeBranches (const T &object)
 Fill the branches for generic objects.
 
Long64_t AutoSave (Option_t *option)
 
Int_t Fill ()
 Fill the tree.
 
void Print () const
 Print the tree name and description.
 
TTree * GetTree () const
 Get the tree pointer for low level operations.
 

Private Member Functions

void ConstructNewTree ()
 Construct the tree.
 
void ConstructUnitsBranch ()
 
void ConstructIndexTo (QwRootTree *to)
 Construct index from this tree to another tree.
 
template<class T>
void ConstructBranchAndVector (T &object)
 Construct the branches and vector for generic objects.
 
const std::string & GetName () const
 Get the name of the tree.
 
const std::string & GetDesc () const
 Get the description of the tree.
 
const std::string & GetPrefix () const
 Get the description of the tree.
 
std::string GetType () const
 Get the object type.
 
void SetPrescaling (UInt_t num_to_save, UInt_t num_to_skip)
 Set tree prescaling parameters.
 
void SetMaxTreeSize (Long64_t maxsize=1900000000)
 Set maximum tree size.
 
void SetAutoFlush (Long64_t autoflush=30000000)
 Set autoflush size.
 
void SetAutoSave (Long64_t autosave=300000000)
 Set autosave size.
 
void SetBasketSize (Int_t basketsize=16000)
 Set basket size.
 
void SetCircular (Long64_t buff=100000)
 

Private Attributes

TTree * fTree
 Tree pointer.
 
QwRootTreeBranchVector fVector
 Vector of leaves.
 
const std::string fName
 Name, description.
 
const std::string fDesc
 
const std::string fPrefix
 
std::string fType
 Object type.
 
UInt_t fCurrentEvent
 Tree prescaling parameters.
 
UInt_t fNumEventsCycle
 
UInt_t fNumEventsToSave
 
UInt_t fNumEventsToSkip
 
Long64_t fMaxTreeSize
 Maximum tree size, autoflush and autosave.
 
Long64_t fAutoFlush
 
Long64_t fAutoSave
 
Int_t fBasketSize
 

Static Private Attributes

static const TString kUnitsName = "ppm/D:ppb/D:um/D:mm/D:mV_uA/D:V_uA/D"
 
static Double_t kUnitsValue [] = { 1e-6, 1e-9, 1e-3, 1 , 1e-3, 1}
 

Friends

class QwRootFile
 

Detailed Description

Wrapper class for ROOT tree management with vector-based data storage.

Provides functionality to write to ROOT trees using vectors of doubles, with support for branch construction, event filtering, and tree sharing. Handles both new tree creation and attachment to existing trees, enabling multiple subsystems to contribute data to a single ROOT tree.

Definition at line 369 of file QwRootFile.h.

Constructor & Destructor Documentation

◆ QwRootTree() [1/4]

QwRootTree::QwRootTree ( const std::string & name,
const std::string & desc,
const std::string & prefix = "" )
inline

Constructor with name, and description.

Definition at line 374 of file QwRootFile.h.

375 : fName(name),fDesc(desc),fPrefix(prefix),fType("type undefined"),
377 // Construct tree
379 }
void ConstructNewTree()
Construct the tree.
Definition QwRootFile.h:426
UInt_t fCurrentEvent
Tree prescaling parameters.
Definition QwRootFile.h:557
const std::string fPrefix
Definition QwRootFile.h:539
UInt_t fNumEventsToSave
Definition QwRootFile.h:559
UInt_t fNumEventsToSkip
Definition QwRootFile.h:560
const std::string fName
Name, description.
Definition QwRootFile.h:537
std::string fType
Object type.
Definition QwRootFile.h:550
UInt_t fNumEventsCycle
Definition QwRootFile.h:558
const std::string fDesc
Definition QwRootFile.h:538

References ConstructNewTree(), fCurrentEvent, fDesc, fName, fNumEventsCycle, fNumEventsToSave, fNumEventsToSkip, fPrefix, and fType.

Referenced by ConstructIndexTo(), QwRootTree(), and QwRootTree().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ QwRootTree() [2/4]

QwRootTree::QwRootTree ( const QwRootTree * tree,
const std::string & prefix = "" )
inline

Constructor with existing tree.

Definition at line 382 of file QwRootFile.h.

383 : fName(tree->GetName()),fDesc(tree->GetDesc()),fPrefix(prefix),fType("type undefined"),
385 QwMessage << "Existing tree: " << tree->GetName() << ", " << tree->GetDesc() << QwLog::endl;
386 fTree = tree->fTree;
387 }
#define QwMessage
Predefined log drain for regular messages.
Definition QwLog.h:49
static std::ostream & endl(std::ostream &)
End of the line.
Definition QwLog.cc:297
const std::string & GetDesc() const
Get the description of the tree.
Definition QwRootFile.h:544
TTree * fTree
Tree pointer.
Definition QwRootFile.h:531
const std::string & GetName() const
Get the name of the tree.
Definition QwRootFile.h:542

References QwLog::endl(), fCurrentEvent, fDesc, fName, fNumEventsCycle, fNumEventsToSave, fNumEventsToSkip, fPrefix, fTree, fType, GetDesc(), GetName(), QwMessage, and QwRootTree().

+ Here is the call graph for this function:

◆ QwRootTree() [3/4]

template<class T>
QwRootTree::QwRootTree ( const std::string & name,
const std::string & desc,
T & object,
const std::string & prefix = "" )
inline

Constructor with name, description, and object.

Definition at line 391 of file QwRootFile.h.

392 : fName(name),fDesc(desc),fPrefix(prefix),fType("type undefined"),
394 // Construct tree
396
397 // Construct branch
399
400 // Construct branches and vector
402 }
void ConstructUnitsBranch()
Definition QwRootFile.h:440
void ConstructBranchAndVector(T &object)
Construct the branches and vector for generic objects.
Definition QwRootFile.h:453

References ConstructBranchAndVector(), ConstructNewTree(), ConstructUnitsBranch(), fCurrentEvent, fDesc, fName, fNumEventsCycle, fNumEventsToSave, fNumEventsToSkip, fPrefix, and fType.

+ Here is the call graph for this function:

◆ QwRootTree() [4/4]

template<class T>
QwRootTree::QwRootTree ( const QwRootTree * tree,
T & object,
const std::string & prefix = "" )
inline

Constructor with existing tree, and object.

Definition at line 406 of file QwRootFile.h.

407 : fName(tree->GetName()),fDesc(tree->GetDesc()),fPrefix(prefix),fType("type undefined"),
409 QwMessage << "Existing tree: " << tree->GetName() << ", " << tree->GetDesc() << QwLog::endl;
410 fTree = tree->fTree;
411
412 // Construct branches and vector
414 }

References ConstructBranchAndVector(), QwLog::endl(), fCurrentEvent, fDesc, fName, fNumEventsCycle, fNumEventsToSave, fNumEventsToSkip, fPrefix, fTree, fType, GetDesc(), GetName(), QwMessage, and QwRootTree().

+ Here is the call graph for this function:

◆ ~QwRootTree()

virtual QwRootTree::~QwRootTree ( )
inlinevirtual

Destructor.

Definition at line 417 of file QwRootFile.h.

417{ }

Member Function Documentation

◆ AutoSave()

Long64_t QwRootTree::AutoSave ( Option_t * option)
inline

Definition at line 488 of file QwRootFile.h.

488 {
489 return fTree->AutoSave(option);
490 }

References fTree.

◆ ConstructBranchAndVector()

template<class T>
void QwRootTree::ConstructBranchAndVector ( T & object)
inlineprivate

Construct the branches and vector for generic objects.

Definition at line 453 of file QwRootFile.h.

453 {
454 // Reserve space for the branch vector
456 // Associate branches with vector
457 TString prefix = Form("%s",fPrefix.c_str());
458 object.ConstructBranchAndVector(fTree, prefix, fVector);
459
460 // Store the type of object
461 fType = typeid(object).name();
462
463 // Check memory reservation
464 if (fVector.size() > BRANCH_VECTOR_MAX_SIZE) {
465 QwError << "The branch vector is too large: " << fVector.size() << " leaves! "
466 << "The maximum size is " << BRANCH_VECTOR_MAX_SIZE << "."
467 << QwLog::endl;
468 exit(-1);
469 }
470 }
#define QwError
Predefined log drain for errors.
Definition QwLog.h:39
#define BRANCH_VECTOR_MAX_SIZE
Definition QwRootFile.h:44
QwRootTreeBranchVector fVector
Vector of leaves.
Definition QwRootFile.h:533

References BRANCH_VECTOR_MAX_SIZE, QwLog::endl(), fPrefix, fTree, fType, fVector, and QwError.

Referenced by QwRootTree(), and QwRootTree().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ConstructIndexTo()

void QwRootTree::ConstructIndexTo ( QwRootTree * to)
inlineprivate

Construct index from this tree to another tree.

Definition at line 446 of file QwRootFile.h.

446 {
447 std::string name = "previous_entry_in_" + to->fName;
448 fTree->Branch(name.c_str(), &(to->fCurrentEvent));
449 }

References fCurrentEvent, fName, fTree, and QwRootTree().

+ Here is the call graph for this function:

◆ ConstructNewTree()

void QwRootTree::ConstructNewTree ( )
inlineprivate

Construct the tree.

Definition at line 426 of file QwRootFile.h.

426 {
427 QwMessage << "New tree: " << fName << ", " << fDesc << QwLog::endl;
428
429 fTree = new TTree(fName.c_str(), fDesc.c_str());
430
431 // Ensure tree is in the current directory
432 if (gDirectory) {
433 fTree->SetDirectory(gDirectory);
434
435 } else {
436
437 }
438 }

References QwLog::endl(), fDesc, fName, fTree, and QwMessage.

Referenced by QwRootTree(), and QwRootTree().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ConstructUnitsBranch()

void QwRootTree::ConstructUnitsBranch ( )
inlineprivate

Definition at line 440 of file QwRootFile.h.

440 {
441 std::string name = "units";
442 fTree->Branch(name.c_str(), &kUnitsValue, kUnitsName);
443 }
static const TString kUnitsName
Definition QwRootFile.h:422
static Double_t kUnitsValue[]
Definition QwRootFile.h:20

References fTree, kUnitsName, and kUnitsValue.

Referenced by QwRootTree().

+ Here is the caller graph for this function:

◆ Fill()

Int_t QwRootTree::Fill ( )
inline

Fill the tree.

Definition at line 493 of file QwRootFile.h.

493 {
495
496 // Tree prescaling
497 if (fNumEventsCycle > 0) {
500 return 0;
501 }
502
503 // Fill the tree
504 Int_t retval = fTree->Fill();
505 // Check for errors
506 if (retval < 0) {
507 QwError << "Writing tree failed! Check disk space or quota." << QwLog::endl;
508 exit(retval);
509 }
510 return retval;
511 }

References QwLog::endl(), fCurrentEvent, fNumEventsCycle, fNumEventsToSave, fTree, and QwError.

+ Here is the call graph for this function:

◆ FillTreeBranches()

template<class T>
void QwRootTree::FillTreeBranches ( const T & object)
inline

Fill the branches for generic objects.

Definition at line 477 of file QwRootFile.h.

477 {
478 if (typeid(object).name() == fType) {
479 // Fill the branch vector
480 object.FillTreeVector(fVector);
481 } else {
482 QwError << "Attempting to fill tree vector for type " << fType << " with "
483 << "object of type " << typeid(object).name() << QwLog::endl;
484 exit(-1);
485 }
486 }

References QwLog::endl(), fType, fVector, and QwError.

+ Here is the call graph for this function:

◆ GetDesc()

const std::string & QwRootTree::GetDesc ( ) const
inlineprivate

Get the description of the tree.

Definition at line 544 of file QwRootFile.h.

544{ return fDesc; };

References fDesc.

Referenced by QwRootTree(), and QwRootTree().

+ Here is the caller graph for this function:

◆ GetName()

const std::string & QwRootTree::GetName ( ) const
inlineprivate

Get the name of the tree.

Definition at line 542 of file QwRootFile.h.

542{ return fName; };

References fName.

Referenced by Print(), QwRootTree(), and QwRootTree().

+ Here is the caller graph for this function:

◆ GetPrefix()

const std::string & QwRootTree::GetPrefix ( ) const
inlineprivate

Get the description of the tree.

Definition at line 546 of file QwRootFile.h.

546{ return fPrefix; };

References fPrefix.

Referenced by Print().

+ Here is the caller graph for this function:

◆ GetTree()

TTree * QwRootTree::GetTree ( ) const
inline

Get the tree pointer for low level operations.

Definition at line 523 of file QwRootFile.h.

523{ return fTree; };

References fTree.

◆ GetType()

std::string QwRootTree::GetType ( ) const
inlineprivate

Get the object type.

Definition at line 553 of file QwRootFile.h.

553{ return fType; };

References fType.

Referenced by Print().

+ Here is the caller graph for this function:

◆ Print()

void QwRootTree::Print ( ) const
inline

Print the tree name and description.

Definition at line 515 of file QwRootFile.h.

515 {
516 QwMessage << GetName() << ", " << GetType();
517 if (fPrefix != "")
518 QwMessage << " (prefix " << GetPrefix() << ")";
520 }
const std::string & GetPrefix() const
Get the description of the tree.
Definition QwRootFile.h:546
std::string GetType() const
Get the object type.
Definition QwRootFile.h:553

References QwLog::endl(), fPrefix, GetName(), GetPrefix(), GetType(), and QwMessage.

+ Here is the call graph for this function:

◆ SetAutoFlush()

void QwRootTree::SetAutoFlush ( Long64_t autoflush = 30000000)
inlineprivate

Set autoflush size.

Definition at line 583 of file QwRootFile.h.

583 {
584 fAutoFlush = autoflush;
585 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,26,00)
586 if (fTree) fTree->SetAutoFlush(autoflush);
587 #endif
588 }
Long64_t fAutoFlush
Definition QwRootFile.h:572

References fAutoFlush, and fTree.

Referenced by QwRootFile::ConstructTreeBranches().

+ Here is the caller graph for this function:

◆ SetAutoSave()

void QwRootTree::SetAutoSave ( Long64_t autosave = 300000000)
inlineprivate

Set autosave size.

Definition at line 591 of file QwRootFile.h.

591 {
592 fAutoSave = autosave;
593 if (fTree) fTree->SetAutoSave(autosave);
594 }
Long64_t fAutoSave
Definition QwRootFile.h:573

References fAutoSave, and fTree.

Referenced by QwRootFile::ConstructTreeBranches().

+ Here is the caller graph for this function:

◆ SetBasketSize()

void QwRootTree::SetBasketSize ( Int_t basketsize = 16000)
inlineprivate

Set basket size.

Definition at line 597 of file QwRootFile.h.

597 {
598 fBasketSize = basketsize;
599 if (fTree) fTree->SetBasketSize("*",basketsize);
600 }
Int_t fBasketSize
Definition QwRootFile.h:574

References fBasketSize, and fTree.

Referenced by QwRootFile::ConstructTreeBranches().

+ Here is the caller graph for this function:

◆ SetCircular()

void QwRootTree::SetCircular ( Long64_t buff = 100000)
inlineprivate

Definition at line 603 of file QwRootFile.h.

603 {
604 if (fTree) fTree->SetCircular(buff);
605 }

References fTree.

Referenced by QwRootFile::ConstructTreeBranches().

+ Here is the caller graph for this function:

◆ SetMaxTreeSize()

void QwRootTree::SetMaxTreeSize ( Long64_t maxsize = 1900000000)
inlineprivate

Set maximum tree size.

Definition at line 577 of file QwRootFile.h.

577 {
578 fMaxTreeSize = maxsize;
579 if (fTree) fTree->SetMaxTreeSize(maxsize);
580 }
Long64_t fMaxTreeSize
Maximum tree size, autoflush and autosave.
Definition QwRootFile.h:571

References fMaxTreeSize, and fTree.

Referenced by QwRootFile::ConstructTreeBranches().

+ Here is the caller graph for this function:

◆ SetPrescaling()

void QwRootTree::SetPrescaling ( UInt_t num_to_save,
UInt_t num_to_skip )
inlineprivate

Set tree prescaling parameters.

Definition at line 563 of file QwRootFile.h.

563 {
564 fNumEventsToSave = num_to_save;
565 fNumEventsToSkip = num_to_skip;
567 }

References fNumEventsCycle, fNumEventsToSave, and fNumEventsToSkip.

Referenced by QwRootFile::ConstructTreeBranches().

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ QwRootFile

friend class QwRootFile
friend

Definition at line 526 of file QwRootFile.h.

References QwRootFile.

Referenced by QwRootFile.

Field Documentation

◆ fAutoFlush

Long64_t QwRootTree::fAutoFlush
private

Definition at line 572 of file QwRootFile.h.

Referenced by SetAutoFlush().

◆ fAutoSave

Long64_t QwRootTree::fAutoSave
private

Definition at line 573 of file QwRootFile.h.

Referenced by SetAutoSave().

◆ fBasketSize

Int_t QwRootTree::fBasketSize
private

Definition at line 574 of file QwRootFile.h.

Referenced by SetBasketSize().

◆ fCurrentEvent

UInt_t QwRootTree::fCurrentEvent
private

Tree prescaling parameters.

Definition at line 557 of file QwRootFile.h.

Referenced by ConstructIndexTo(), Fill(), QwRootTree(), QwRootTree(), QwRootTree(), and QwRootTree().

◆ fDesc

const std::string QwRootTree::fDesc
private

Definition at line 538 of file QwRootFile.h.

Referenced by ConstructNewTree(), GetDesc(), QwRootTree(), QwRootTree(), QwRootTree(), and QwRootTree().

◆ fMaxTreeSize

Long64_t QwRootTree::fMaxTreeSize
private

Maximum tree size, autoflush and autosave.

Definition at line 571 of file QwRootFile.h.

Referenced by SetMaxTreeSize().

◆ fName

const std::string QwRootTree::fName
private

Name, description.

Definition at line 537 of file QwRootFile.h.

Referenced by ConstructIndexTo(), ConstructNewTree(), GetName(), QwRootTree(), QwRootTree(), QwRootTree(), and QwRootTree().

◆ fNumEventsCycle

UInt_t QwRootTree::fNumEventsCycle
private

Definition at line 558 of file QwRootFile.h.

Referenced by Fill(), QwRootTree(), QwRootTree(), QwRootTree(), QwRootTree(), and SetPrescaling().

◆ fNumEventsToSave

UInt_t QwRootTree::fNumEventsToSave
private

Definition at line 559 of file QwRootFile.h.

Referenced by Fill(), QwRootTree(), QwRootTree(), QwRootTree(), QwRootTree(), and SetPrescaling().

◆ fNumEventsToSkip

UInt_t QwRootTree::fNumEventsToSkip
private

Definition at line 560 of file QwRootFile.h.

Referenced by QwRootTree(), QwRootTree(), QwRootTree(), QwRootTree(), and SetPrescaling().

◆ fPrefix

const std::string QwRootTree::fPrefix
private

◆ fTree

◆ fType

std::string QwRootTree::fType
private

◆ fVector

QwRootTreeBranchVector QwRootTree::fVector
private

Vector of leaves.

Definition at line 533 of file QwRootFile.h.

Referenced by ConstructBranchAndVector(), and FillTreeBranches().

◆ kUnitsName

const TString QwRootTree::kUnitsName = "ppm/D:ppb/D:um/D:mm/D:mV_uA/D:V_uA/D"
staticprivate

Definition at line 422 of file QwRootFile.h.

Referenced by ConstructUnitsBranch().

◆ kUnitsValue

Double_t QwRootTree::kUnitsValue = { 1e-6, 1e-9, 1e-3, 1 , 1e-3, 1}
staticprivate

Definition at line 20 of file QwRootFile.h.

Referenced by ConstructUnitsBranch().


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