Friend.cpp

Go to the documentation of this file.
00001 
00002 #include "cafe/Friend.hpp"
00003 #include "cafe/Config.hpp"
00004 
00005 #include <iostream>
00006 #include "TFile.h"
00007 #include "TTree.h"
00008 
00009 
00010 namespace cafe {
00011 
00012     Friend::Friend(const char *name)
00013         : Processor(name)
00014     {
00015         Config config(name);
00016         _fileName = config.get("File", "");
00017         _treeName = config.get("Tree", "");
00018         if(_fileName.size() > 0) {
00019             _pattern = _fileName;
00020         }
00021     }
00022 
00023     void Friend::inputFileOpened(TFile *file)
00024     {
00025         using namespace std;
00026 
00027         if(_fileName.size() == 0 || _treeName.size() == 0) return;
00028 
00029         std::string new_name = _pattern.replace(file->GetName());
00030 
00031         out() << "Friend[" << name() << "] Adding " 
00032               << _treeName << " from file: " 
00033               << new_name  << std::endl;
00034 
00035         if(TTree *tree = static_cast<TTree*>(file->Get("TMBTree"))) {
00036             tree->AddFriend(_treeName.c_str(), new_name.c_str());
00037         }
00038         
00039     }
00040 
00041 }

Generated on Thu Apr 3 04:14:23 2008 for CAF by doxygen 1.3.4