Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 /// ---------------------------------------------------------------------------
0002 /*! \file   TupleInterfaces.cc
0003  *  \author Derek Anderson
0004  *  \date   03.05.2024
0005  *
0006  *  TNtuple-related interfaces.
0007  */
0008 /// ---------------------------------------------------------------------------
0009 
0010 #define SCORRELATORUTILITIES_TUPLEINTERFACES_CC
0011 
0012 // namespace definition
0013 #include "TupleInterfaces.h"
0014 
0015 // make common namespaces implicit
0016 using namespace std;
0017 
0018 
0019 
0020 // tuple interfaces ===========================================================
0021 
0022 namespace SColdQcdCorrelatorAnalysis {
0023 
0024   // --------------------------------------------------------------------------
0025   //! Add a tag to a vector of TNtuple leaves
0026   // --------------------------------------------------------------------------
0027   void Interfaces::AddTagToLeaves(const string tag, vector<string>& leaves) {
0028 
0029     for (string& leaf : leaves) {
0030       leaf.append(tag);
0031     }
0032     return;
0033 
0034   }  // end 'AddTagToLeaves(vector<string>)'
0035 
0036 
0037 
0038   // --------------------------------------------------------------------------
0039   //! Combine two vectors of TNtuple leaves
0040   // --------------------------------------------------------------------------
0041   void Interfaces::CombineLeafLists(const vector<string>& addends, vector<string>& toAddTo) {
0042 
0043     for (string addend : addends) {
0044       toAddTo.push_back(addend);
0045     }
0046     return;
0047 
0048   }  // end 'CombineLeafLists(vector<string>&, vector<string>&)'
0049 
0050 
0051 
0052   // --------------------------------------------------------------------------
0053   //! Flatten a vector of TNtuple leaves into a colon-separated string
0054   // --------------------------------------------------------------------------
0055   string Interfaces::FlattenLeafList(const vector<string>& leaves) {
0056 
0057     string flattened("");
0058     for (size_t iLeaf = 0; iLeaf < leaves.size(); iLeaf++) {
0059       flattened.append(leaves[iLeaf]);
0060       if ((iLeaf + 1) != leaves.size()) {
0061         flattened.append(":");
0062       }
0063     }
0064     return flattened;
0065 
0066   }  // end 'FlattenLeafList(vector<string>&)'
0067 
0068 }  // end SColdQcdCorrelatorAnalysis namespace
0069 
0070 // end ------------------------------------------------------------------------