File indexing completed on 2025-08-05 08:21:37
0001 #include "MakeSimpleTree.h"
0002 #include "MySimpleTree.h"
0003 #include "MyTClonesArray.h"
0004
0005 #include <fun4all/Fun4AllReturnCodes.h>
0006
0007 #include <phool/getClass.h>
0008 #include <phool/PHCompositeNode.h>
0009 #include <phool/PHIODataNode.h>
0010 #include <phool/PHNodeIterator.h>
0011
0012 MakeSimpleTree::MakeSimpleTree(const std::string &name): SubsysReco(name)
0013 {
0014 return;
0015 }
0016
0017 int
0018 MakeSimpleTree::Init(PHCompositeNode *topNode)
0019 {
0020 PHNodeIterator iter(topNode);
0021
0022 PHCompositeNode *dstNode;
0023 dstNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "DST"));
0024 if (!dstNode)
0025 {
0026 std::cout << PHWHERE << "DST Node missing doing nothing" << std::endl;
0027 return -1;
0028 }
0029
0030
0031
0032
0033
0034
0035
0036
0037 MySimpleTree *mytree = new MySimpleTree();
0038 PHIODataNode <PHObject> *newNode = new PHIODataNode <PHObject>(mytree,"MYSIMPLETREE","PHObject");
0039 dstNode->addNode(newNode);
0040 MyTClonesArray *mycontainer = new MyTClonesArray();
0041 newNode = new PHIODataNode <PHObject>(mycontainer,"MYTCARRAY","PHObject");
0042 dstNode->addNode(newNode);
0043 return 0;
0044 }
0045
0046 int
0047 MakeSimpleTree::process_event(PHCompositeNode *topNode)
0048 {
0049 static int i = 0;
0050 MySimpleTree *mytree = findNode::getClass<MySimpleTree>(topNode,"MYSIMPLETREE");
0051 float f = i;
0052 mytree->MyFloat(f);
0053 mytree->MyInt(i);
0054 MyTClonesArray *mycontainer = findNode::getClass<MyTClonesArray>(topNode,"MYTCARRAY");
0055 for (int j=0; j<i;j++)
0056 {
0057 MySimpleTree *item = mycontainer->GetNewItem();
0058 item->MyFloat(f);
0059 item->MyInt(i);
0060 }
0061 mycontainer->MyEventInt(i);
0062 mycontainer->MyEventFloat(f);
0063 i++;
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073 if (i % 2)
0074 {
0075 return Fun4AllReturnCodes::DISCARDEVENT;
0076 }
0077 return Fun4AllReturnCodes::EVENT_OK;
0078 }