mEmcPerfectModule.C

Go to the documentation of this file.
00001 #include "mEmcPerfectModule.h"
00002 
00003 #include "dEmcGeaHitWrapper.h"
00004 
00005 #include "dEmcClusterLocalWrapper.h"
00006 
00007 #include "dEmcGeaClusterTrackWrapper.h"
00008 
00009 #include "PHNode.h"
00010 #include "PHCompositeNode.h"
00011 #include "PHIODataNode.h"
00012 #include "PHNodeIterator.h"
00013 #include "PHTable.hh"
00014 
00015 #include <iostream>
00016 using namespace std;
00017 
00018 typedef PHIODataNode<PHTable> TableNode_t;
00019 
00020 PHBoolean
00021 mEmcPerfectModule::event(PHCompositeNode *root) {
00022  PHPointerList<PHNode> nodes;
00023  PHNodeIterator i(root), *j;
00024  PHNode *n;
00025  TableNode_t *d;
00026  PHTable *w;
00027  PHCompositeNode *emcNode, *dstNode, *outNode;
00028 
00029  emcNode = static_cast<PHCompositeNode*>(i.findFirst("PHCompositeNode", "EMC"));
00030  if (!emcNode) {
00031    emcNode = new PHCompositeNode("EMC");
00032    root->addNode(emcNode);
00033  }
00034 
00035  dstNode = static_cast<PHCompositeNode*>(i.findFirst("PHCompositeNode", "DST"));
00036  if (!dstNode) {
00037    dstNode = new PHCompositeNode("DST");
00038    root->addNode(dstNode);
00039  }
00040 
00041 // Insert code here to navigate node hierarchy and find
00042 // or create specific nodes to pass to physics module...
00043 
00044   outNode = emcNode;
00045   n = i.findFirst("PHIODataNode", "dEmcGeaHit");
00046   if (!n) {
00047     cout << "ERROR:  'in' parameter dEmcGeaHit not found" << endl;
00048      w = new dEmcGeaHitWrapper("dEmcGeaHit", 405000);
00049      if (!w) {
00050        return 1;
00051      }
00052      n = new TableNode_t(w,"dEmcGeaHit");
00053      outNode->addNode(n);
00054   }
00055   nodes.append(n);
00056 
00057   outNode = dstNode;
00058   j = new PHNodeIterator(outNode);
00059   if (!(d = static_cast<TableNode_t*>(j->findFirst("PHIODataNode","dEmcClusterLocal")))) {
00060      w = new dEmcClusterLocalWrapper("dEmcClusterLocal", 6000);
00061      if (!w) {
00062        return 1;
00063      }
00064      d = new TableNode_t(w,"dEmcClusterLocal");
00065      outNode->addNode(d);
00066   }
00067   delete j;
00068   nodes.append(d);
00069 
00070   outNode = emcNode;
00071   j = new PHNodeIterator(outNode);
00072   if (!(d = static_cast<TableNode_t*>(j->findFirst("PHIODataNode","dEmcGeaClusterTrack")))) {
00073      w = new dEmcGeaClusterTrackWrapper("dEmcGeaClusterTrack", 10);
00074      if (!w) {
00075        return 1;
00076      }
00077      d = new TableNode_t(w,"dEmcGeaClusterTrack");
00078      outNode->addNode(d);
00079   }
00080   delete j;
00081   nodes.append(d);
00082 
00083   return callPAM(nodes);
00084 }