diff --git a/include/iact_data/zfits_acada_data_source.hpp b/include/iact_data/zfits_acada_data_source.hpp index 7a9792e4..5de4f7f0 100644 --- a/include/iact_data/zfits_acada_data_source.hpp +++ b/include/iact_data/zfits_acada_data_source.hpp @@ -94,7 +94,7 @@ class ZFITSSingleFileACADACameraEventDataSource: data_stream_type* get_data_stream() override; static config_type default_config(); - const config_type& config() const { return config_; } + config_type config() const { return config_; } private: std::string filename_; @@ -137,7 +137,7 @@ class ZFITSACADACameraEventDataSource: void set_next_index(uint64_t next_index) override; static config_type default_config(); - const config_type& config() const { return config_; } + config_type config() const { return config_; } protected: using BaseDataSource::source_; diff --git a/src/iact_data/parallel_event_dispatcher.cpp b/src/iact_data/parallel_event_dispatcher.cpp index 4a40ea4b..f8d36d95 100644 --- a/src/iact_data/parallel_event_dispatcher.cpp +++ b/src/iact_data/parallel_event_dispatcher.cpp @@ -255,28 +255,33 @@ void ParallelEventDispatcher:: process_cta_zfits_run(const std::string& filename, const calin::ix::iact_data::event_dispatcher::EventDispatcherConfig& config) { - CTAZFITSDataSource cta_file(filename, config.decoder(), config.zfits()); - TelescopeRunConfiguration* run_config = cta_file.get_run_configuration(); + auto* cta_file = new CTAZFITSDataSource (filename, config.decoder(), config.zfits()); + TelescopeRunConfiguration* run_config = cta_file->get_run_configuration(); - unsigned nfragments = cta_file.num_fragments(); + unsigned nfragments = cta_file->num_fragments(); unsigned nthread = std::min(std::max(config.nthread(), 1U), nfragments); if(nthread == 1) { try { - process_src(&cta_file, run_config, config.log_frequency()); + process_src(cta_file, run_config, config.log_frequency()); } catch(...) { + delete cta_file; delete run_config; throw; } } else { + auto* src_factory = new CTAZFITSDataSourceFactory(cta_file); try { - CTAZFITSDataSourceFactory src_factory(&cta_file); - process_src_factory(&src_factory, run_config, config.log_frequency(), nthread); + process_src_factory(src_factory, run_config, config.log_frequency(), nthread); } catch(...) { + delete src_factory; + delete cta_file; delete run_config; throw; } + delete src_factory; } + delete cta_file; delete run_config; } diff --git a/src/iact_data/zfits_acada_data_source.cpp b/src/iact_data/zfits_acada_data_source.cpp index a81d6c3b..6d5cd33f 100644 --- a/src/iact_data/zfits_acada_data_source.cpp +++ b/src/iact_data/zfits_acada_data_source.cpp @@ -482,29 +482,7 @@ ZFITSACADACameraEventDataSource(const std::string& filename, const config_type& filename, config), true), config_(config), run_header_(nullptr) { - if(source_) { - run_header_ = source_->get_run_header(); - data_stream_ = source_->get_data_stream(); - } - if((run_header_ == nullptr - or (is_message_type() and data_stream_ == nullptr)) - and opener_->num_sources() > 1) { - // In this case the first file fragment is missing the RunHeader or DataStream, search - // for it in later fragments then reopen the first fragment - - while((run_header_ == nullptr or data_stream_ == nullptr) and isource_ < opener_->num_sources()) - { - ++isource_; - open_file(); - if(run_header_ == nullptr) - run_header_ = source_ ? source_->get_run_header() : nullptr; - if(data_stream_ == nullptr) - data_stream_ = source_ ? source_->get_data_stream() : nullptr; - } - - isource_ = 0; - open_file(); - } + // nothing to see here } template @@ -530,14 +508,14 @@ void ZFITSACADACameraEventDataSource::load_run_header() } while((run_header_ == nullptr or (is_message_type() and data_stream_ == nullptr)) - and isource_num_sources()-1) + and (isource_+1)num_sources()) { ++isource_; open_file(); - if(run_header_ == nullptr) - run_header_ = source_ ? source_->get_run_header() : nullptr; - if(data_stream_ == nullptr) - data_stream_ = source_ ? source_->get_data_stream() : nullptr; + if(source_) { + if(run_header_ == nullptr)run_header_ = source_->get_run_header(); + if(data_stream_ == nullptr)data_stream_ = source_->get_data_stream(); + } } if(isource_ != saved_isource) { isource_ = saved_isource;