mEmcDCMToRawModule.C

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