Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

PisaHelper.h

Go to the documentation of this file.
00001 #ifndef __PISAHELPER_H__
00002 #define __PISAHELPER_H__
00003 
00004 #include "PHTypedNodeIterator.h"
00005 #include "PHIODataNode.h"
00006 #include "phool.h"
00007 #include <iostream>
00008 
00009 class TGeoManager;
00010 
00014 class PisaHelper
00015 {
00016  public:
00017 
00018   static TGeoManager* getGeoManager();
00019 
00020   static PHCompositeNode* getPisaNode(PHCompositeNode* top,
00021                                       const char* pisanodename = "PISA")
00022   {
00023     PHNodeIterator iter(top);
00024     PHCompositeNode* pisanode = 
00025       dynamic_cast<PHCompositeNode*>
00026       (iter.findFirst("PHCompositeNode",pisanodename));
00027     if (!pisanode)
00028       {
00029         std::cerr << PHWHERE << "Cannot find " << pisanodename
00030                   << " under topnode" 
00031                   << std::endl;
00032         return 0;
00033       }
00034     return pisanode;
00035   }
00036 
00037   template <class T>
00038   static T* getClass(PHCompositeNode* top, const char* name,
00039                      const char* subtop = "PISA")
00040   {
00041     PHCompositeNode* sub = getPisaNode(top,subtop);
00042     PHTypedNodeIterator<T> iter(sub);
00043     PHIODataNode<T> *Node = iter.find(name);
00044     if (Node)
00045       {
00046         return dynamic_cast<T*>(Node->getData());
00047       }
00048     return 0;
00049   }
00050   
00051 };
00052 
00053 #endif