mEmcGeaParamsModule.C

Go to the documentation of this file.
00001 #include "mEmcGeaParamsModule.h"
00002 
00003 #include "emcparWrapper.h"
00004 
00005 #include "dEmcGeaParamsWrapper.h"
00006 
00007 #include "dEmcGeometryWrapper.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 // Default constructor and destructor to pacify CINT
00021 mEmcGeaParamsModule::mEmcGeaParamsModule()
00022 {
00023   name = "mEmcGeaParamsModule";
00024 }
00025 
00026 PHBoolean
00027 mEmcGeaParamsModule::event(PHCompositeNode *root) {
00028  PHPointerList<PHNode> nodes;
00029  PHNodeIterator i(root), *j;
00030  PHNode *n;
00031  TableNode_t *d;
00032  PHTable *w;
00033  PHCompositeNode *geaNode, *parNode, *outNode;
00034 
00035  parNode = static_cast<PHCompositeNode*>(i.findFirst("PHCompositeNode", "PAR"));
00036  if (!parNode) {
00037    parNode = new PHCompositeNode("PAR");
00038    root->addNode(parNode);
00039  }
00040 
00041  geaNode = static_cast<PHCompositeNode*>(i.findFirst("PHCompositeNode", "GEA"));
00042  if (!geaNode) {
00043    geaNode = new PHCompositeNode("GEA");
00044    root->addNode(geaNode);
00045  }
00046 
00047 // Insert code here to navigate node hierarchy and find
00048 // or create specific nodes to pass to physics module...
00049 
00050   outNode = geaNode;
00051   n = i.findFirst("PHIODataNode", "emcpar");
00052   if (!n) {
00053     cout << "ERROR:  'in' parameter emcpar not found" << endl;
00054      w = new emcparWrapper("emcpar", 10);
00055      if (!w) {
00056        return 1;
00057      }
00058      n = new TableNode_t(w,"emcpar");
00059      outNode->addNode(n);
00060   }
00061   nodes.append(n);
00062 
00063   outNode = parNode;
00064   j = new PHNodeIterator(outNode);
00065   if (!(d = static_cast<TableNode_t*>(j->findFirst("PHIODataNode","dEmcGeaParams")))) {
00066      w = new dEmcGeaParamsWrapper("dEmcGeaParams", 400);
00067      if (!w) {
00068        return 1;
00069      }
00070      d = new TableNode_t(w,"dEmcGeaParams");
00071      outNode->addNode(d);
00072   }
00073   delete j;
00074   nodes.append(d);
00075 
00076   outNode = parNode;
00077   j = new PHNodeIterator(outNode);
00078   if (!(d = static_cast<TableNode_t*>(j->findFirst("PHIODataNode","dEmcGeometry")))) {
00079      w = new dEmcGeometryWrapper("dEmcGeometry", 30000);
00080      if (!w) {
00081        return 1;
00082      }
00083      d = new TableNode_t(w,"dEmcGeometry");
00084      outNode->addNode(d);
00085   }
00086   delete j;
00087   nodes.append(d);
00088 
00089   return callPAM(nodes);
00090 }