Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 /// ---------------------------------------------------------------------------
0002 /*! \file   NodeInterfaces.cc
0003  *  \author Derek Anderson
0004  *  \date   03.05.2024
0005  *
0006  *  F4A node-related interfaces.
0007  */
0008 /// ---------------------------------------------------------------------------
0009 
0010 #define SCORRELATORUTILITIES_NODEINTERFACES_CC
0011 
0012 // namespace definition
0013 #include "NodeInterfaces.h"
0014 
0015 // make common namespaces implicit
0016 using namespace std;
0017 using namespace findNode;
0018 
0019 
0020 
0021 // node interfaces ============================================================
0022 
0023 namespace SColdQcdCorrelatorAnalysis {
0024 
0025   // --------------------------------------------------------------------------
0026   //! Remove forbidden characters from a node name
0027   // --------------------------------------------------------------------------
0028   void Interfaces::CleanseNodeName(string& nameToClean) {
0029 
0030     for (const auto& [bad, good] : Const::MapBadOntoGoodStrings()) {
0031       size_t position;
0032       while ((position = nameToClean.find(bad)) != string::npos) {
0033         nameToClean.replace(position, 1, good);
0034       }
0035     }  // end bad-good pair loop
0036     return;
0037 
0038   }  // end 'CleanseNodeName(string&)'
0039 
0040 
0041 
0042   // --------------------------------------------------------------------------
0043   //! Create node
0044   // --------------------------------------------------------------------------
0045   template <typename T> void Interfaces::CreateNode(
0046     PHCompositeNode* topNode,
0047     string newNodeName, T& objectInNode
0048   ) {
0049 
0050     // make sure node name is okay
0051     CleanseNodeName(newNodeName);
0052 
0053     // find DST node
0054     PHNodeIterator   itNode(topNode);
0055     PHCompositeNode* dstNode = dynamic_cast<PHCompositeNode*>(itNode.findFirst("PHCompositeNode", "DST"));
0056     if (!dstNode) {
0057       dstNode = new PHCompositeNode("DST");
0058       topNode -> addNode(dstNode);
0059     }
0060 
0061     // create node and exit
0062     PHIODataNode<PHObject>* newNode = new PHIODataNode<PHObject>(objectInNode, newNodeName.c_str(), "PHObject");
0063     dstNode -> addNode(newNode);
0064     return;
0065 
0066   }  // end 'CreateNode(PHCompositeNode*, string, T&)'
0067 
0068 }  // end SColdQcdCorrelatorAnalysis namespace
0069 
0070 // end ------------------------------------------------------------------------