Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

HistManModule.cxx

Go to the documentation of this file.
00001 #include "HistManModule.h"
00002 
00003 #include <TSystem.h>
00004 
00005 #include <Registry/Registry.h>
00006 
00007 #include <JobControl/JobCModuleRegistry.h>
00008 JOBMODULE(HistManModule,"HistMan","Save HistMan histograms in a file");
00009 
00010 #include <string>
00011 using namespace std;
00012 
00013 HistManModule::HistManModule()
00014 {
00015 }
00016 
00017 HistManModule::~HistManModule()
00018 {
00019 }
00020 
00021 static string make_name(const char* path, const char* ext)
00022 {
00023     string ret = gSystem->BaseName(path);
00024     string::size_type s = ret.find(".");
00025     return ret.substr(0,s) + ext;
00026 }
00027 
00028 void HistManModule::EndFile()
00029 {
00030     const char* fileext = "";
00031     this->GetConfig().Get("FileExtension",fileext);
00032     if (! (fileext && fileext[0])) return;
00033 
00034     string filename = make_name(this->GetLastFile(),fileext);
00035 
00036     HistMan hm("");
00037     hm.WriteOut(filename.c_str());
00038 }
00039 
00040 void HistManModule::EndJob()
00041 {
00042     const char* fileext = "";
00043     this->GetConfig().Get("FileExtension",fileext);
00044     if (fileext && fileext[0]) return;
00045 
00046     const char* filename = "histman.root";
00047     this->GetConfig().Get("OutputFilename",filename);
00048     HistMan hm("");
00049     hm.WriteOut(filename);
00050 }
00051     
00052 const Registry& HistManModule::DefaultConfig() const
00053 {
00054     static Registry r;
00055     if (!r.Size()) {
00056         r.Set("OutputFilename","histman.root");
00057         r.Set("FileExtension","");
00058     }
00059     return r;
00060 }
00061 
00062 JobCResult HistManModule::Put(const MomNavigator *)
00063 {
00064     // dummy so we can get our EndJob done.
00065     return JobCResult::kAOK;
00066 }
00067 
00068 
00069 HistMan HistManModule::GetHistMan(JobCModule& mod, const char* subdir)
00070 {
00071     if (subdir) 
00072         return HistMan(Form("%s/%s",mod.GetUniqueName(),subdir));
00073     return HistMan(mod.GetUniqueName());
00074 }

Generated on Mon Feb 15 11:06:47 2010 for loon by  doxygen 1.3.9.1