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

DrawSnarl.cxx

Go to the documentation of this file.
00001 // $Id: DrawSnarl.cxx,v 1.11 2009/09/18 22:33:08 jyuko Exp $
00002 
00003 //C++
00004 #include <cmath>
00005 #include <fstream>
00006 #include <iostream>
00007 
00008 // MINOS
00009 #include "Util/UtilString.h"
00010 
00011 //Local
00012 #include "PhysicsNtuple/Factory.h"
00013 #include "PhysicsNtuple/Default.h"
00014 
00015 #include "EventDisplay.h"
00016 #include "DrawSnarl.h"
00017 
00018 REGISTER_ANP_OBJECT(AlgSnarl,DrawSnarl)
00019 
00020 using namespace std;
00021 
00022 //----------------------------------------------------------------------
00023 Anp::DrawSnarl::DrawSnarl()
00024    :fDrawSnarlEmpty(false)
00025 {
00026 }
00027 
00028 //----------------------------------------------------------------------
00029 Anp::DrawSnarl::~DrawSnarl()
00030 {
00031   cout<<" create instance of display"<<endl;
00032    EventDisplay::Instance().Init();
00033 }
00034 
00035 //----------------------------------------------------------------------
00036 bool Anp::DrawSnarl::Run(Record &record)
00037 {
00038    if(!fDrawSnarlEmpty && record.GetNEvents() < 1)
00039    {
00040       return true;
00041    }
00042 
00043    if(record.GetHeader().IsValid())
00044    {
00045        EventDisplay::Instance().Add(record);
00046    }
00047 
00048    return true;
00049 }
00050 
00051 //----------------------------------------------------------------------
00052 void Anp::DrawSnarl::Config(const Registry &reg)
00053 {
00054    vector<string> tablist;
00055 
00056    const char *value_char = 0;
00057    if(reg.Get("DrawSnarlEmpty", value_char) && value_char)
00058    {
00059       if(strcmp(value_char, "yes") == 0)
00060       {
00061          fDrawSnarlEmpty = true;
00062       }
00063       else if(strcmp(value_char, "no") == 0)
00064       {
00065          fDrawSnarlEmpty = false;
00066       }
00067    }
00068 
00069    value_char = 0;
00070    if(reg.Get("EventTabList", value_char) && value_char)
00071    {
00072       UtilString::StringTok(tablist, string(value_char), ", ");
00073    }
00074    else
00075    {
00076       cerr << "DrawSnarl::Config() - EventTabList Registry key doesn't exist" << endl;
00077       return;
00078    }
00079    
00080    for(vector<string>::const_iterator sit = tablist.begin(); sit != tablist.end(); ++sit)
00081    {
00082       EventTabPtr tab = EventDisplay::Instance().Add(*sit);
00083       
00084       if(tab.valid())
00085       {
00086          fTabs.push_back(tab);
00087          cout << "Created and adopted tab: " << *sit << endl;
00088       }
00089    }
00090 
00091    string tpath;
00092 
00093    value_char = 0;
00094    if(reg.Get("TabConfigPath", value_char) && value_char)
00095    {
00096       tpath = value_char;
00097    }
00098    else
00099    {
00100       tpath = std::string(std::getenv("SRT_PRIVATE_CONTEXT")) + "/PhysicsNtuple/Draw";
00101    }
00102    
00103    if(!ReadRegistry(tpath + "/TabConfig.txt", fConfig, false))
00104    {
00105       cerr << "DrawSnarl::Config - failed to read Registry with configurations" << endl;
00106    }
00107 
00108    for(TabVec::const_iterator cit = fTabs.begin(); cit != fTabs.end(); ++cit) 
00109    {
00110       const string cpath = tpath + "/" + (*cit) -> GetName() + ".txt";
00111       ifstream infile(cpath.c_str(), ios::in);
00112 
00113       if(infile && infile.is_open())
00114       {
00115          Registry reg;
00116          if(ReadRegistry(cpath, reg, false))
00117          {
00118             (*cit) -> Config(reg);
00119          }
00120       }
00121       else
00122       {
00123          (*cit) -> Config(fConfig);
00124       }
00125 
00126       infile.close();
00127    }
00128 
00129    if(reg.KeyExists("PrintConfig"))
00130    {
00131       cout << "DrawSnarl::Config" << endl
00132            << "   DrawSnarlEmpty = " << fDrawSnarlEmpty << endl;
00133    }
00134 }

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