#include "EventFile.hh" #include "JDAQEvent.hh" #include "JDAQTimeslice.hh" #include //-------------------------------------------------------------- // SocketEventReader //-------------------------------------------------------------- #ifdef HAVEJPP #include "JDAQ/JDAQEventIO.hh" #include "JDAQ/JDAQTimesliceIO.hh" JFitEventFile::~JFitEventFile() { if (jevt) delete jevt; } #endif JppEventFile:: ~JppEventFile() { if (daqevent) delete daqevent; } JppTimesliceFile:: ~JppTimesliceFile() { if (timeslice) delete timeslice; } //-------------------------------------------------------------- string _stagedir() { if (getenv("TMPDIR")) return getenv("TMPDIR"); return "/scratch/"; } string EventFile::stagedir = _stagedir(); bool EventFile::read_timeslices = false; string EventFile::timeslice_treename = "KM3NET_TIMESLICE"; //-------------------------------------------------------------------------- BaseEventFile* EventFile::create_impl( TFile* rfile ) { for(auto f : _registered_filetypes() ) { if ( f->can_open( rfile ) ) { impl = f->clone(); } } if ( !impl ) fatal ("do not know how to open TFile" ); return impl; } BaseEventFile* EventFile::create_impl( string filename_) { if ( startswith( filename_, "controlhost:") ) { string hostname = replace_all( filename_, "controlhost:", ""); #ifdef HAVEJPPX impl = new SocketEventReader(); impl -> open( hostname ); return impl; #else cout << " AAnet compiled without jpp -> cannot use controlhost socket " << endl; throw std::runtime_error("no socket"); #endif } string filename = stage_file( filename_, stagedir ); // returns "" if file does not exists filename = unzip_file( filename ); // does nothting if not needed if (filename == "" ) { cout << "==============================================" << endl; cout << " input file does not exist " << endl; cout << " " << filename_ << endl; cout << "==============================================" << endl; throw std::runtime_error("bad filename"); } if ( EvtEventFile().can_open( filename ) ) impl = new EvtEventFile(); // else if ( LeshouchesEventFile().can_open( filename )) impl = new LeshouchesEventFile(); if ( JppEventFile().can_open( filename ) && !read_timeslices ) { if (!impl) impl = new JppEventFile(); } #ifdef HAVEJPP // if ( JFitEventFile().can_open( filename ) && !read_timeslices ) // { // if (!impl) fatal ("JFit events can only be read together with KM3NET_EVENTS"); // print ("adding slave eventfile to read jfit results"); // impl-> slave = new JFitEventFile(); // } #endif else if ( JppTimesliceFile( timeslice_treename ).can_open( filename ) && read_timeslices ) { if (!impl) impl = new JppTimesliceFile( timeslice_treename ); } if ( AaEventFile().can_open( filename ) ) { if (impl && ! impl->slave ) // open as secondary for MC reading only { impl->slave = new AaEventFile( &evt , true ); } else { impl = new AaEventFile( &evt ); } } #ifdef HAVEANTCC if ( AntccEventFile().can_open( filename ) ) { print ("antcc can open it"); if ( impl && !impl->slave) // open een secondary tree { impl->slave = new AntccEventFile(); } else // antcc wil be the primary tree { if (!impl) impl = new AntccEventFile(); } } #endif for(auto f : _registered_filetypes() ) { if (f->can_open( filename ) ) { impl = f->clone(); } } if ( !impl ) fatal ("do not know how to open file", filename ); return impl; }