/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

ReconInputSvc.cc
Go to the documentation of this file.
00001 #include "ReconInputSvc/ReconInputSvc.h"
00002 #include "RidxHandler.h"
00003 #include "PerEvent/PerPhyEvent.h"
00004 #include "LafKernel/PhyEvent.h"
00005 #include "LafKernel/SvcFactory.h"
00006 #include <fstream>
00007 
00008 DECLARE_SERVICE(ReconInputSvc);
00009 
00010 ReconInputSvc::ReconInputSvc(const std::string& name)
00011     : SvcBase(name),
00012       m_entry(-1),
00013       m_evt(0),
00014       m_ridxHandler(0)
00015 {
00016     m_name = "ReconInputSvc";  //to avoid naming confusion
00017     setOption("InputFiles",       m_files);
00018     setOption("PreferredRecTree", m_preferredRecTree = "Event/Rec/AdScaled");
00019     setOption("PreferredEnergy",  m_preferredEnergy  = "enrec");
00020     parse_files();
00021 }
00022 
00023 ReconInputSvc::~ReconInputSvc()
00024 {
00025 }
00026 
00027 bool ReconInputSvc::initialize()
00028 {
00029     m_evt = new PerPhyEvent(m_files, m_preferredRecTree, m_preferredEnergy);
00030     PhyEvent::m_inputFlist = m_files;
00031     return true;
00032 }
00033 
00034 bool ReconInputSvc::finalize()
00035 {
00036     delete m_evt;
00037     if ( m_ridxHandler != 0 ) delete m_ridxHandler;
00038     return true;
00039 }
00040 
00041 EvtObject* ReconInputSvc::next(int nth)
00042 {
00043     PhyEvent* res = 0;
00044     m_entry += nth;
00045     if ( m_ridxHandler == 0 ) {
00046         res = m_evt->makePhyEvent(m_entry);
00047     }
00048     else {
00049         if ( m_ridxHandler->seek(m_entry) ) {
00050             res = m_evt->makePhyEvent(m_ridxHandler->fIndex(), m_ridxHandler->eIndex());
00051         }
00052     }
00053     return res;
00054 }
00055 
00056 const std::string& ReconInputSvc::fname(int num)
00057 {
00058     return m_files.at(num);
00059 }
00060 
00061 void ReconInputSvc::parse_files()
00062 {
00063     std::string first = m_files[0];
00064     if ( first.substr(first.length()-5) == ".list" ) {
00065         std::vector<std::string> infiles;
00066         for(std::vector<std::string>::iterator it=m_files.begin(); it!=m_files.end(); ++it){
00067             std::ifstream  fs((*it).c_str());
00068             std::string fname;
00069             while ( (fs>>fname).good() ) {
00070                 //std::cout << fname << std::endl;
00071                 infiles.push_back(fname);
00072             }
00073         }
00074         m_files = infiles;
00075     }
00076 
00077     first = m_files[0];
00078     if ( first.substr(first.length()-5) == ".ridx" ) {
00079         m_ridxHandler = new RidxHandler(m_files);
00080         m_files = m_ridxHandler->rootFiles();
00081     }
00082 
00083     first = m_files[0];
00084     if ( first.substr(first.length()-5) != ".root" ) {
00085         LogFatal << "Only .list/ridx/root input files are permitted !" << std::endl;
00086     }
00087 }
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:51:07 for ReconInputSvc by doxygen 1.7.4