Skip to content

Commit a4c670e

Browse files
committed
Add new ACADA ZFits data source components
1 parent 2cc84bd commit a4c670e

6 files changed

+723
-36
lines changed

include/iact_data/zfits_acada_data_source.hpp

+13-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ZFITSSingleFileACADACameraEventDataSource:
4141
CALIN_TYPEALIAS(header_type, HeaderMessage);
4242

4343
ZFITSSingleFileACADACameraEventDataSource(const std::string& filename,
44-
config_type config = default_config());
44+
const config_type& config = default_config());
4545
virtual ~ZFITSSingleFileACADACameraEventDataSource();
4646

4747
const event_type* borrow_next_event(uint64_t& seq_index_out) override;
@@ -77,6 +77,9 @@ class ZFITSACADACameraEventDataSource:
7777
calin::ix::iact_data::zfits_data_source::ZFITSDataSourceConfig);
7878
CALIN_TYPEALIAS(event_type, EventMessage);
7979
CALIN_TYPEALIAS(header_type, HeaderMessage);
80+
CALIN_TYPEALIAS(BaseDataSource, calin::io::data_source::BasicChainedRandomAccessDataSource<
81+
calin::iact_data::acada_data_source::
82+
ACADACameraEventRandomAccessDataSourceWithRunHeader<EventMessage,HeaderMessage> >);
8083

8184
ZFITSACADACameraEventDataSource(const std::string& filename,
8285
const config_type& config = default_config());
@@ -95,6 +98,13 @@ class ZFITSACADACameraEventDataSource:
9598
static config_type default_config();
9699
const config_type& config() const { return config_; }
97100

101+
protected:
102+
using BaseDataSource::source_;
103+
using BaseDataSource::opener_;
104+
using BaseDataSource::isource_;
105+
using BaseDataSource::seq_index_;
106+
using BaseDataSource::open_file;
107+
98108
private:
99109
config_type config_;
100110
header_type* run_header_ = nullptr;
@@ -111,15 +121,13 @@ class ZFITSACADACameraEventDataSourceOpener:
111121
calin::ix::iact_data::zfits_data_source::ZFITSDataSourceConfig);
112122
CALIN_TYPEALIAS(event_type, EventMessage);
113123
CALIN_TYPEALIAS(header_type, HeaderMessage);
114-
CALIN_TYPEALIAS(data_source_type, calin::iact_data::acada_data_source::
115-
ACADACameraEventRandomAccessDataSourceWithRunHeader<EventMessage,HeaderMessage>);
116124

117125
ZFITSACADACameraEventDataSourceOpener(std::string filename,
118-
const config_type config = default_config());
126+
const config_type& config = default_config());
119127
virtual ~ZFITSACADACameraEventDataSourceOpener();
120128
unsigned num_sources() const override;
121129
std::string source_name(unsigned isource) const override;
122-
data_source_type* open(unsigned isource) override;
130+
ZFITSSingleFileACADACameraEventDataSource<EventMessage,HeaderMessage>* open(unsigned isource) override;
123131
bool has_opened_file() { return has_opened_file_; }
124132

125133
static config_type default_config();

include/iact_data/zfits_data_source.hpp

+102
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,14 @@
2727
#include <calin_global_definitions.hpp>
2828
#include <calin_global_config.hpp>
2929
#include <io/chained_data_source.hpp>
30+
3031
#include <iact_data/actl_event_decoder.hpp>
3132
#include <iact_data/zfits_actl_data_source.hpp>
33+
34+
#include <iact_data/acada_data_source.hpp>
35+
#include <iact_data/acada_event_decoder.hpp>
36+
#include <iact_data/zfits_acada_data_source.hpp>
37+
3238
#include <iact_data/zfits_data_source.pb.h>
3339
#include <iact_data/telescope_data_source.hpp>
3440

@@ -40,6 +46,102 @@ namespace calin { namespace iact_data { namespace zfits_data_source {
4046

4147
#ifdef CALIN_HAVE_CTA_CAMERASTOACTL
4248

49+
template<typename EventMessage, typename HeaderMessage>
50+
class ZFITSSingleFileDataSource:
51+
public calin::iact_data::telescope_data_source::
52+
TelescopeRandomAccessDataSourceWithRunConfig
53+
{
54+
public:
55+
CALIN_TYPEALIAS(config_type,
56+
calin::ix::iact_data::zfits_data_source::ZFITSDataSourceConfig);
57+
58+
ZFITSSingleFileDataSource(
59+
calin::iact_data::zfits_acada_data_source::
60+
ZFITSSingleFileACADACameraEventDataSource<EventMessage,HeaderMessage>* actl_zfits,
61+
bool dont_decode_run_configuration,
62+
calin::iact_data::acada_event_decoder::
63+
ACADACameraEventDecoder<EventMessage,HeaderMessage>* decoder,
64+
bool adopt_decoder = false,
65+
bool adopt_actl_zfits = false);
66+
67+
ZFITSSingleFileDataSource(const std::string& filename,
68+
calin::iact_data::acada_event_decoder::
69+
ACADACameraEventDecoder<EventMessage,HeaderMessage>* decoder,
70+
bool adopt_decoder = false,
71+
const config_type& config = default_config());
72+
73+
virtual ~ZFITSSingleFileDataSource();
74+
75+
calin::ix::iact_data::telescope_event::TelescopeEvent* get_next(
76+
uint64_t& seq_index_out, google::protobuf::Arena** arena = nullptr) override;
77+
uint64_t size() override;
78+
void set_next_index(uint64_t next_index) override;
79+
80+
calin::ix::iact_data::telescope_run_configuration::
81+
TelescopeRunConfiguration* get_run_configuration() override;
82+
83+
static config_type default_config();
84+
85+
private:
86+
calin::iact_data::acada_event_decoder::
87+
ACADACameraEventDecoder<EventMessage,HeaderMessage>* decoder_;
88+
bool adopt_decoder_ = false;
89+
calin::iact_data::zfits_acada_data_source::
90+
ZFITSSingleFileACADACameraEventDataSource<EventMessage,HeaderMessage>* acada_zfits_ = nullptr;
91+
bool adopt_acada_zfits_ = false;
92+
calin::ix::iact_data::telescope_run_configuration::
93+
TelescopeRunConfiguration* run_config_ = nullptr;
94+
};
95+
96+
template<typename EventMessage, typename HeaderMessage>
97+
class ZFITSDataSource:
98+
public calin::iact_data::telescope_data_source::
99+
TelescopeRandomAccessDataSourceWithRunConfig,
100+
public calin::io::data_source::FragmentList
101+
{
102+
public:
103+
CALIN_TYPEALIAS(config_type,
104+
calin::ix::iact_data::zfits_data_source::ZFITSDataSourceConfig);
105+
106+
ZFITSDataSource(const std::string& filename,
107+
calin::iact_data::acada_event_decoder::
108+
ACADACameraEventDecoder<EventMessage,HeaderMessage>* decoder,
109+
bool adopt_decoder = false,
110+
const config_type& config = default_config());
111+
112+
ZFITSDataSource(const std::string& filename,
113+
ZFITSDataSource<EventMessage,HeaderMessage>* base_datasource,
114+
const config_type& config = default_config());
115+
116+
virtual ~ZFITSDataSource();
117+
118+
calin::ix::iact_data::telescope_event::TelescopeEvent* get_next(
119+
uint64_t& seq_index_out, google::protobuf::Arena** arena = nullptr) override;
120+
121+
uint64_t size() override;
122+
void set_next_index(uint64_t next_index) override;
123+
124+
calin::ix::iact_data::telescope_run_configuration::
125+
TelescopeRunConfiguration* get_run_configuration() override;
126+
127+
unsigned current_fragment_index() const override;
128+
unsigned num_fragments() const override;
129+
std::string fragment_name(unsigned index) const override;
130+
131+
static config_type default_config();
132+
133+
protected:
134+
135+
calin::iact_data::acada_event_decoder::
136+
ACADACameraEventDecoder<EventMessage,HeaderMessage>* decoder_;
137+
bool adopt_decoder_ = false;
138+
calin::iact_data::zfits_acada_data_source::
139+
ZFITSACADACameraEventDataSource<EventMessage,HeaderMessage>* acada_zfits_ = nullptr;
140+
bool adopt_acada_zfits_ = false;
141+
calin::ix::iact_data::telescope_run_configuration::
142+
TelescopeRunConfiguration* run_config_ = nullptr;
143+
};
144+
43145
/*
44146
45147
LLLLLLLLLLL 000000000

src/iact_data/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ set(CALIN_SOURCES algorithms.cpp
2828
if(CTA_CAMERASTOACTL_FOUND)
2929
set(CALIN_SOURCES ${CALIN_SOURCES}
3030
acada_data_source.cpp zfits_acada_data_source.cpp acada_event_decoder.cpp
31+
zfits_data_source.cpp
3132
actl_event_decoder.cpp
3233
nectarcam_actl_l0_event_decoder.cpp nectarcam_actl_r1_event_decoder.cpp
3334
lstcam_actl_r1_event_decoder.cpp

0 commit comments

Comments
 (0)