ECCE @ EIC 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 
13 using namespace std;
14 
16 {
17  if (verbosity > 0)
18  {
19  cout << "PHNodeIntegrate: Integrating " << node->getName() << endl;
20  }
21  if (node->getType() == "PHDataNode" || node->getType() == "PHIODataNode")
22  {
23  if (node->getObjectType() == "PHObject")
24  {
25  PHObject *obj = static_cast<PHDataNode<PHObject> *>(node)->getData();
26  if (obj->Integrate())
27  {
28  PHObject *sumobj = findNode::getClass<PHObject>(runsumnode, node->getName());
29  if (sumobj)
30  {
31  sumobj->Integrate(obj);
32  // now copy the summed object to the runwise node
33  // since the runwise nodes were copied from the input file
34  // we are guaranteed that it exists (and we handle only
35  // objects which come from the current input file
36  PHObject *runobj = findNode::getClass<PHObject>(runnode, node->getName());
37  runobj->CopyFrom(sumobj);
38  }
39  else
40  {
41  // since this object was also copied to the node tree we only need
42  // to store it in case a second file gets opened where this one then
43  // serves as the object which contains the sum
44  sumobj = obj->CloneMe();
45  PHIODataNode<PHObject> *sumobjnode = new PHIODataNode<PHObject>(sumobj, node->getName(), "PHObject");
46  runsumnode->addNode(sumobjnode);
47  }
48  }
49  }
50  }
51 }