Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHNodeIntegrate.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHNodeIntegrate.cc
1 #include "PHNodeIntegrate.h"
2 
3 #include "PHCompositeNode.h"
4 #include "PHDataNode.h"
5 #include "PHIODataNode.h"
6 #include "PHNode.h"
7 #include "PHObject.h"
8 #include "getClass.h"
9 
10 #include <iostream>
11 #include <string>
12 
14 {
15  if (verbosity > 0)
16  {
17  std::cout << "PHNodeIntegrate: Integrating " << node->getName() << std::endl;
18  }
19  if (node->getType() == "PHDataNode" || node->getType() == "PHIODataNode")
20  {
21  if (node->getObjectType() == "PHObject")
22  {
23  PHObject *obj = static_cast<PHDataNode<PHObject> *>(node)->getData();
24  if (obj->Integrate())
25  {
26  PHObject *sumobj = findNode::getClass<PHObject>(runsumnode, node->getName());
27  if (sumobj)
28  {
29  sumobj->Integrate(obj);
30  // now copy the summed object to the runwise node
31  // since the runwise nodes were copied from the input file
32  // we are guaranteed that it exists (and we handle only
33  // objects which come from the current input file
34  PHObject *runobj = findNode::getClass<PHObject>(runnode, node->getName());
35  runobj->CopyFrom(sumobj);
36  }
37  else
38  {
39  // since this object was also copied to the node tree we only need
40  // to store it in case a second file gets opened where this one then
41  // serves as the object which contains the sum
42  sumobj = obj->CloneMe();
43  PHIODataNode<PHObject> *sumobjnode = new PHIODataNode<PHObject>(sumobj, node->getName(), "PHObject");
44  runsumnode->addNode(sumobjnode);
45  }
46  }
47  }
48  }
49 }