Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:16:19

0001 #include "PHNodeIntegrate.h"
0002 
0003 #include "PHCompositeNode.h"
0004 #include "PHDataNode.h"
0005 #include "PHIODataNode.h"
0006 #include "PHNode.h"
0007 #include "PHObject.h"
0008 #include "getClass.h"
0009 
0010 #include <iostream>
0011 #include <string>
0012 
0013 void PHNodeIntegrate::perform(PHNode *node)
0014 {
0015   if (verbosity > 0)
0016   {
0017     std::cout << "PHNodeIntegrate: Integrating " << node->getName() << std::endl;
0018   }
0019   if (node->getType() == "PHDataNode" || node->getType() == "PHIODataNode")
0020   {
0021     if (node->getObjectType() == "PHObject")
0022     {
0023       // NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
0024       PHObject *obj = static_cast<PHDataNode<PHObject> *>(node)->getData();
0025       if (obj->Integrate())
0026       {
0027       // NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
0028         PHObject *sumobj = findNode::getClass<PHObject>(runsumnode, node->getName());
0029         if (sumobj)
0030         {
0031           sumobj->Integrate(obj);
0032           // now copy the summed object to the runwise node
0033           // since the runwise nodes were copied from the input file
0034           // we are guaranteed that it exists (and we handle only
0035           // objects which come from the current input file
0036           PHObject *runobj = findNode::getClass<PHObject>(runnode, node->getName());
0037           runobj->CopyFrom(sumobj);
0038         }
0039         else
0040         {
0041           // since this object was also copied to the node tree we only need
0042           // to store it in case a second file gets opened where this one then
0043           // serves as the object which contains the sum
0044           sumobj = obj->CloneMe();
0045           PHIODataNode<PHObject> *sumobjnode = new PHIODataNode<PHObject>(sumobj, node->getName(), "PHObject");
0046           runsumnode->addNode(sumobjnode);
0047         }
0048       }
0049     }
0050   }
0051 }