Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:13:21

0001 /// ---------------------------------------------------------------------------
0002 /*! \file   TreeInterfaces.cc
0003  *  \author Derek Anderson
0004  *  \date   03.05.2024
0005  *
0006  *  TTree-related interfaces.
0007  */
0008 /// ---------------------------------------------------------------------------
0009 
0010 #define SCORRELATORUTILITIES_TREEINTERFACES_CC
0011 
0012 // namespace definition
0013 #include "TreeInterfaces.h"
0014 
0015 // make common namespaces implicit
0016 using namespace std;
0017 
0018 
0019 
0020 // TTree interfaces ===========================================================
0021 
0022 namespace SColdQcdCorrelatorAnalysis {
0023 
0024   // --------------------------------------------------------------------------
0025   //! Get a particular entry from a generic TTree-derived object
0026   // --------------------------------------------------------------------------
0027   template <typename T> int64_t Interfaces::GetEntry(
0028     T* tree,
0029     const uint64_t entry
0030   ) {
0031 
0032     int64_t status = numeric_limits<int64_t>::min();
0033     if (!tree) {
0034       status = 0;
0035     } else {
0036       status = tree -> GetEntry(entry);
0037     }
0038     return status;
0039 
0040   }  // end 'GetEntry(T*, uint64_t)'
0041 
0042   // specific instantiations of `GetEntry()`
0043   template int64_t Interfaces::GetEntry(TTree* tree, const uint64_t entry);
0044   template int64_t Interfaces::GetEntry(TChain* tree, const uint64_t entry);
0045   template int64_t Interfaces::GetEntry(TNtuple* tree, const uint64_t entry);
0046 
0047 
0048 
0049   // --------------------------------------------------------------------------
0050   //! Load a generic TTree-derived object
0051   // --------------------------------------------------------------------------
0052   template <typename T> int64_t Interfaces::LoadTree(
0053     T* tree,
0054     const uint64_t entry,
0055     int& current
0056   ) {
0057 
0058     // check for tree & load
0059     int     number = numeric_limits<int>::min();
0060     int64_t status = numeric_limits<int64_t>::min();
0061     if (!tree) {
0062       status = -5;
0063     } else {
0064       number = tree -> GetTreeNumber();
0065       status = tree -> LoadTree(entry);
0066     }
0067 
0068     // update current tree number if need be
0069     const bool isStatusGood = (status >= 0);
0070     const bool isNotCurrent = (number != current);
0071     if (isStatusGood && isNotCurrent) {
0072       current = tree -> GetTreeNumber();
0073     }
0074     return status;
0075 
0076   }  // end 'LoadTree(uint64_t)'
0077 
0078   // specific instantiations of `LoadTree()`
0079   template int64_t Interfaces::LoadTree(TTree* tree, const uint64_t entry, int& current);
0080   template int64_t Interfaces::LoadTree(TChain* tree, const uint64_t entry, int& current);
0081   template int64_t Interfaces::LoadTree(TNtuple* tree, const uint64_t entry, int& current);
0082 
0083 }  // end SColdQcdCorrelatorAnalysis namespace
0084 
0085 // end ------------------------------------------------------------------------