mEmcFEMToDCMModule.C

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