00001 #include "mEmcGeaClusterEval2Module.h"
00002
00003 #include "dEmcEventWrapper.h"
00004
00005 #include "dEmcGeaTrackWrapper.h"
00006
00007 #include "dEmcGeaTowerTrackWrapper.h"
00008
00009 #include "dEmcClusterExtWrapper.h"
00010
00011 #include "dEmcGeaTrackClusterWrapper.h"
00012
00013 #include "dEmcGeaClusterTrackWrapper.h"
00014
00015 #include "PHNode.h"
00016 #include "PHCompositeNode.h"
00017 #include "PHIODataNode.h"
00018 #include "PHNodeIterator.h"
00019 #include "PHTable.hh"
00020
00021 #include <iostream>
00022 using namespace std;
00023
00024 typedef PHIODataNode<PHTable> TableNode_t;
00025
00026 PHBoolean
00027 mEmcGeaClusterEval2Module::event(PHCompositeNode *root) {
00028 PHPointerList<PHNode> nodes;
00029 PHNodeIterator i(root), *j;
00030 PHNode *n;
00031 TableNode_t *d;
00032 PHTable *w;
00033 PHCompositeNode *emcNode, *dstNode, *evaNode, *outNode;
00034
00035 emcNode = static_cast<PHCompositeNode*>(i.findFirst("PHCompositeNode", "EMC"));
00036 if (!emcNode) {
00037 emcNode = new PHCompositeNode("EMC");
00038 root->addNode(emcNode);
00039 }
00040
00041 dstNode = static_cast<PHCompositeNode*>(i.findFirst("PHCompositeNode", "DST"));
00042 if (!dstNode) {
00043 dstNode = new PHCompositeNode("DST");
00044 root->addNode(dstNode);
00045 }
00046
00047 evaNode = static_cast<PHCompositeNode*>(i.findFirst("PHCompositeNode", "EVA"));
00048 if (!evaNode) {
00049 evaNode = new PHCompositeNode("EVA");
00050 root->addNode(evaNode);
00051 }
00052
00053
00054
00055
00056
00057 outNode = emcNode;
00058 n = i.findFirst("PHIODataNode", "dEmcEvent");
00059 if (!n) {
00060 cout << "ERROR: 'in' parameter dEmcEvent not found" << endl;
00061 w = new dEmcEventWrapper("dEmcEvent", 1);
00062 if (!w) {
00063 return 1;
00064 }
00065 n = new TableNode_t(w,"dEmcEvent");
00066 outNode->addNode(n);
00067 }
00068 nodes.append(n);
00069
00070 outNode = evaNode;
00071 n = i.findFirst("PHIODataNode", "dEmcGeaTrack");
00072 if (!n) {
00073 cout << "ERROR: 'in' parameter dEmcGeaTrack not found" << endl;
00074 w = new dEmcGeaTrackWrapper("dEmcGeaTrack", 10);
00075 if (!w) {
00076 return 1;
00077 }
00078 n = new TableNode_t(w,"dEmcGeaTrack");
00079 outNode->addNode(n);
00080 }
00081 nodes.append(n);
00082
00083 outNode = evaNode;
00084 n = i.findFirst("PHIODataNode", "dEmcGeaTowerTrack");
00085 if (!n) {
00086 cout << "ERROR: 'in' parameter dEmcGeaTowerTrack not found" << endl;
00087 w = new dEmcGeaTowerTrackWrapper("dEmcGeaTowerTrack", 15000);
00088 if (!w) {
00089 return 1;
00090 }
00091 n = new TableNode_t(w,"dEmcGeaTowerTrack");
00092 outNode->addNode(n);
00093 }
00094 nodes.append(n);
00095
00096 outNode = dstNode;
00097 n = i.findFirst("PHIODataNode", "dEmcClusterExt");
00098 if (!n) {
00099 cout << "ERROR: 'in' parameter dEmcClusterExt not found" << endl;
00100 w = new dEmcClusterExtWrapper("dEmcClusterExt", 10);
00101 if (!w) {
00102 return 1;
00103 }
00104 n = new TableNode_t(w,"dEmcClusterExt");
00105 outNode->addNode(n);
00106 }
00107 nodes.append(n);
00108
00109 outNode = evaNode;
00110 j = new PHNodeIterator(outNode);
00111 if (!(d = static_cast<TableNode_t*>(j->findFirst("PHIODataNode","dEmcGeaTrackCluster")))) {
00112 w = new dEmcGeaTrackClusterWrapper("dEmcGeaTrackCluster", 10);
00113 if (!w) {
00114 return 1;
00115 }
00116 d = new TableNode_t(w,"dEmcGeaTrackCluster");
00117 outNode->addNode(d);
00118 }
00119 delete j;
00120 nodes.append(d);
00121
00122 outNode = evaNode;
00123 j = new PHNodeIterator(outNode);
00124 if (!(d = static_cast<TableNode_t*>(j->findFirst("PHIODataNode","dEmcGeaClusterTrack")))) {
00125 w = new dEmcGeaClusterTrackWrapper("dEmcGeaClusterTrack", 10);
00126 if (!w) {
00127 return 1;
00128 }
00129 d = new TableNode_t(w,"dEmcGeaClusterTrack");
00130 outNode->addNode(d);
00131 }
00132 delete j;
00133 nodes.append(d);
00134
00135 return callPAM(nodes);
00136 }