| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

RootIOUserDataProxy.cc

Go to the documentation of this file.
00001 #include "RootIOSvc/RootIOUserDataProxy.h"
00002 
00003 #include "TTree.h"
00004 #include <vector>
00005 
00006 using namespace std;
00007 
00008 RootIOUserDataProxy::RootIOUserDataProxy(const std::string& varName, 
00009                                          const std::string& cppType,
00010                                          char* address)
00011   : m_varName(varName),
00012     m_cppType(cppType),
00013     m_address(address)
00014 {
00015     // If ccpType is not one of these then it is assumed to be an object
00016     const char* knownPOD[] = { "int", "float", 0 };
00017     const char* rootTypes[] = { "Int_t", "Float_t", 0 };
00018 
00019     m_isObject = true;
00020     for (int ind=0; knownPOD[ind]; ++ind) {
00021         if (m_cppType == knownPOD[ind]) {
00022             m_isObject = false;
00023             break;
00024         }
00025         if (m_cppType == rootTypes[ind]) {
00026             m_cppType = knownPOD[ind];
00027             m_isObject = false;
00028             break;
00029         }
00030     }
00031 }
00032 
00033 RootIOUserDataProxy::~RootIOUserDataProxy()
00034 {
00035 }
00036     
00037 
00038 bool RootIOUserDataProxy::branch(TTree* tree)
00039 {
00040     // handle known object types needing template to trigger write Branch() call
00041     if (m_cppType == "int") {
00042         tree->Branch(m_varName.c_str(),address<void>(),"Int_t/I");
00043         return true;
00044     }
00045 
00046     if (m_cppType == "float") {
00047         tree->Branch(m_varName.c_str(),address<void>(),"Float_t/F");
00048         return true;
00049     }
00050 
00051     if (m_cppType == "vector<int>") {
00052         tree->Branch(m_varName.c_str(), address< std::vector<int> >());
00053         return true;
00054     }
00055     
00056     if (m_cppType == "vector<float>") {
00057         tree->Branch(m_varName.c_str(), address< std::vector<float> >());
00058         return true;
00059     }
00060     
00061     return false;
00062 }
00063 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:18:19 2011 for RootIOSvc by doxygen 1.4.7