mEmcRawToLongModule.C

Go to the documentation of this file.
00001 #include "mEmcRawToLongModule.h"
00002 
00003 #include "dEmcRawDataWrapper.h"
00004 
00005 #include "dEmcDCMLongDataWrapper.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 mEmcRawToLongModule::event(PHCompositeNode *root) {
00020 
00021   // This is for backward compatibility - selects the default in and out nodes
00022 
00023   return event(root,"dEmcRawData","dEmcDCMLongData");
00024 }
00025 
00026 PHBoolean
00027 mEmcRawToLongModule::event(PHCompositeNode *root,PHString dEmcRawNodeName,PHString dEmcDCMLongNodeName) {
00028 
00029  PHPointerList<PHNode> nodes;
00030  PHNodeIterator i(root), *j;
00031  PHNode *n;
00032  TableNode_t *d;
00033  PHTable *w;
00034  PHCompositeNode *dcmNode, *emcNode, *outNode;
00035 
00036  emcNode = static_cast<PHCompositeNode*>(i.findFirst("PHCompositeNode", "EMC"));
00037  if (!emcNode) {
00038    emcNode = new PHCompositeNode("EMC");
00039    root->addNode(emcNode);
00040  }
00041 
00042  dcmNode = static_cast<PHCompositeNode*>(i.findFirst("PHCompositeNode", "DCM"));
00043  if (!dcmNode) {
00044    dcmNode = new PHCompositeNode("DCM");
00045    root->addNode(dcmNode);
00046  }
00047 
00048 // Insert code here to navigate node hierarchy and find
00049 // or create specific nodes to pass to physics module...
00050 
00051  outNode = emcNode;
00052   n = i.findFirst("PHIODataNode", dEmcRawNodeName);
00053   if (!n) {
00054     cout << "ERROR:  'in' parameter dEmcRawData not found" << endl;
00055     char *dEmcRawNodeNameChar = dEmcRawNodeName.getString();
00056      w = new dEmcRawDataWrapper(dEmcRawNodeNameChar, 15000);
00057      if (!w) {
00058        return 1;
00059      }
00060      n = new TableNode_t(w,dEmcRawNodeName);
00061      outNode->addNode(n);
00062   }
00063   nodes.append(n);
00064 
00065   outNode = dcmNode;
00066   j = new PHNodeIterator(outNode);
00067   if (!(d = static_cast<TableNode_t*>(j->findFirst("PHIODataNode",dEmcDCMLongNodeName)))) {
00068     char *dEmcDCMLongNodeNameChar = dEmcDCMLongNodeName.getString();
00069      w = new dEmcDCMLongDataWrapper(dEmcDCMLongNodeNameChar, 500);
00070      if (!w) {
00071        return 1;
00072      }
00073      d = new TableNode_t(w,dEmcDCMLongNodeName);
00074 
00075      w->Print((Option_t*)0);
00076 
00077      outNode->addNode(d);
00078   }
00079   delete j;
00080   nodes.append(d);
00081 
00082   return callPAM(nodes);
00083 }