Skip to content

Commit

Permalink
Change decoder config types
Browse files Browse the repository at this point in the history
  • Loading branch information
sfegan committed Sep 24, 2024
1 parent e35df7e commit 9dae0ae
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 13 deletions.
20 changes: 11 additions & 9 deletions include/iact_data/nectarcam_acada_event_decoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ class NectarCam_ACADACameraEventDecoder_R1v1:
public calin::iact_data::unified_acada_event_decoder::Unified_ACADACameraEventDecoder_R1v1
{
public:
CALIN_TYPEALIAS(config_type,
calin::iact_data::unified_acada_event_decoder::Unified_ACADACameraEventDecoder_R1v1::config_type);
CALIN_TYPEALIAS(config_type, calin::ix::iact_data::
nectarcam_data_source::NectarCamCameraEventDecoderConfig);

CALIN_TYPEALIAS(message_set_type, calin::iact_data::acada_data_source::ACADA_MessageSet_R1v1);
CALIN_TYPEALIAS(event_type, calin::iact_data::acada_data_source::ACADA_MessageSet_R1v1::event_type);
Expand All @@ -244,17 +244,19 @@ class NectarCam_ACADACameraEventDecoder_R1v1:

NectarCam_ACADACameraEventDecoder_R1v1* clone() const override;

static calin::ix::iact_data::cta_data_source::UnifiedCameraEventDecoderConfig default_config() {
return force_nectarcam_camera_type(Unified_ACADACameraEventDecoder_R1v1::default_config());
}
calin::ix::iact_data::nectarcam_data_source::NectarCamCameraEventDecoderConfig config() const;

protected:
static inline calin::ix::iact_data::cta_data_source::UnifiedCameraEventDecoderConfig force_nectarcam_camera_type(
config_type config) {
config.set_camera_type(calin::ix::iact_data::cta_data_source::NECTARCAM);
static calin::ix::iact_data::nectarcam_data_source::NectarCamCameraEventDecoderConfig default_config() {
config_type config = config_type::default_instance();
// config.set_nmc_xml_suffix(".NMC.xml");
config.set_separate_channel_waveforms(true);
return config;
}

protected:
static inline calin::ix::iact_data::cta_data_source::UnifiedCameraEventDecoderConfig unified_decoder_config(
config_type config);

};


Expand Down
34 changes: 33 additions & 1 deletion include/iact_data/nectarcam_data_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class NectarCamZFITSDataSource_R1v0:
const config_type& config = default_config());
virtual ~NectarCamZFITSDataSource_R1v0();
private:
nectarcam_acada_event_decoder::NectarCam_ACADACameraEventDecoder_R1v0* decoder_;
calin::iact_data::nectarcam_acada_event_decoder::NectarCam_ACADACameraEventDecoder_R1v0* decoder_;
};

/*
Expand All @@ -156,6 +156,38 @@ class NectarCamZFITSDataSource_R1v0:
*/

class NectarCamZFITSDataSource_R1v1:
public calin::iact_data::zfits_data_source::ZFITSDataSource<
calin::iact_data::acada_data_source::ACADA_MessageSet_R1v1>
{
public:
CALIN_TYPEALIAS(config_type,
ZFITSDataSource<calin::iact_data::acada_data_source::ACADA_MessageSet_R1v1>::config_type);
CALIN_TYPEALIAS(decoder_config_type,
calin::ix::iact_data::nectarcam_data_source::NectarCamCameraEventDecoderConfig);

calin::ix::iact_data::nectarcam_data_source::NectarCamCameraEventDecoderConfig decoder_config() const {
return decoder_->config(); }

static calin::ix::iact_data::nectarcam_data_source::NectarCamCameraEventDecoderConfig default_decoder_config() {
return calin::iact_data::nectarcam_acada_event_decoder::NectarCam_ACADACameraEventDecoder_R1v1::default_config();
}

NectarCamZFITSDataSource_R1v1(const std::string& filename,
calin::iact_data::zfits_acada_data_source::
ZFITSACADACameraEventDataSource<calin::iact_data::acada_data_source::ACADA_MessageSet_R1v1>* acada_zfits,
const decoder_config_type& decoder_config = default_decoder_config(),
bool adopt_acada_zfits = false);
NectarCamZFITSDataSource_R1v1(const std::string& filename,
const config_type& config,
const decoder_config_type& decoder_config = default_decoder_config());
NectarCamZFITSDataSource_R1v1(const std::string& filename,
const decoder_config_type& decoder_config = default_decoder_config(),
const config_type& config = default_config());
virtual ~NectarCamZFITSDataSource_R1v1();
private:
calin::iact_data::nectarcam_acada_event_decoder::NectarCam_ACADACameraEventDecoder_R1v1* decoder_;
};

/*
Expand Down
14 changes: 13 additions & 1 deletion src/iact_data/cta_data_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,16 @@ CTAZFITSDataSource::construct_delegate(std::string filename,
"CTAZFITSDataSource::construct_delegate: R1v0 data format not supported with camera type: "
+ CameraType_Name(decoder_config.camera_type()));
}
} else if(config.data_model() == calin::ix::iact_data::zfits_data_source::ACADA_DATA_MODEL_R1V1) {
if(decoder_config.camera_type() == AUTO_DETECT) {
return new NectarCamZFITSDataSource_R1v1(filename, config, decoder_config.nectarcam());
} else if(decoder_config.camera_type() == NECTARCAM) {
return new NectarCamZFITSDataSource_R1v1(filename, config, decoder_config.nectarcam());
} else {
throw std::runtime_error(
"CTAZFITSDataSource::construct_delegate: R1v1 data format not supported with camera type: "
+ CameraType_Name(decoder_config.camera_type()));
}
} else {
throw std::runtime_error(
"CTAZFITSDataSource::construct_delegate: unsupported data format: "
Expand All @@ -237,7 +247,9 @@ CTAZFITSDataSource::copy_base_data_source(
throw std::runtime_error(
"CTAZFITSDataSource::copy_base_data_source: File not found: " + filename);

if(auto* zfits = dynamic_cast<zfits_data_source::ZFITSDataSource_R1v0*>(base_data_source->delegate())) {
if(auto* zfits = dynamic_cast<zfits_data_source::ZFITSDataSource_R1v1*>(base_data_source->delegate())) {
return new zfits_data_source::ZFITSDataSource_R1v1(filename, zfits, config);
} else if(auto* zfits = dynamic_cast<zfits_data_source::ZFITSDataSource_R1v0*>(base_data_source->delegate())) {
return new zfits_data_source::ZFITSDataSource_R1v0(filename, zfits, config);
}else if(auto* zfits = dynamic_cast<zfits_data_source::ZFITSDataSource_L0*>(base_data_source->delegate())) {
return new zfits_data_source::ZFITSDataSource_L0(filename, zfits, config);
Expand Down
24 changes: 23 additions & 1 deletion src/iact_data/nectarcam_acada_event_decoder_r1v1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ NectarCam_ACADACameraEventDecoder_R1v1::
NectarCam_ACADACameraEventDecoder_R1v1(const std::string& filename,
const config_type& config):
calin::iact_data::unified_acada_event_decoder::Unified_ACADACameraEventDecoder_R1v1(
filename, force_nectarcam_camera_type(config))
filename, unified_decoder_config(config))
{
// nothing to see here
}
Expand Down Expand Up @@ -308,3 +308,25 @@ NectarCam_ACADACameraEventDecoder_R1v1* NectarCam_ACADACameraEventDecoder_R1v1::
{
return new NectarCam_ACADACameraEventDecoder_R1v1(*this);
}

calin::ix::iact_data::cta_data_source::UnifiedCameraEventDecoderConfig
NectarCam_ACADACameraEventDecoder_R1v1::unified_decoder_config(config_type config) {
auto unified_config =
calin::iact_data::unified_acada_event_decoder::Unified_ACADACameraEventDecoder_R1v1::default_config();
unified_config.set_camera_type(calin::ix::iact_data::cta_data_source::NECTARCAM);
unified_config.set_separate_channel_waveforms(config.separate_channel_waveforms());
unified_config.set_include_serialized_raw_data(config.separate_channel_waveforms());
return unified_config;
}

calin::ix::iact_data::nectarcam_data_source::NectarCamCameraEventDecoderConfig
NectarCam_ACADACameraEventDecoder_R1v1::config() const
{
calin::ix::iact_data::nectarcam_data_source::NectarCamCameraEventDecoderConfig config;
auto unified_config =
calin::iact_data::unified_acada_event_decoder::Unified_ACADACameraEventDecoder_R1v1::config();
config.set_camera_type(calin::ix::iact_data::nectarcam_data_source::NectarCamCameraEventDecoderConfig::NECTARCAM);
config.set_separate_channel_waveforms(unified_config.separate_channel_waveforms());
config.set_include_serialized_raw_data(unified_config.separate_channel_waveforms());
return config;
}
39 changes: 38 additions & 1 deletion src/iact_data/nectarcam_data_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,43 @@ NectarCamZFITSDataSource_R1v0::~NectarCamZFITSDataSource_R1v0()
*/

NectarCamZFITSDataSource_R1v1::
NectarCamZFITSDataSource_R1v1(const std::string& filename,
calin::iact_data::zfits_acada_data_source::
ZFITSACADACameraEventDataSource<calin::iact_data::acada_data_source::ACADA_MessageSet_R1v1>* acada_zfits,
const decoder_config_type& decoder_config, bool adopt_acada_zfits):
calin::iact_data::zfits_data_source::ZFITSDataSource_R1v1(
acada_zfits,
decoder_ = new NectarCam_ACADACameraEventDecoder_R1v1(filename, decoder_config),
adopt_acada_zfits, /* adopt_decoder_= */ false)
{
// nothing to see here
}

NectarCamZFITSDataSource_R1v1::
NectarCamZFITSDataSource_R1v1(const std::string& filename,
const config_type& config, const decoder_config_type& decoder_config):
calin::iact_data::zfits_data_source::ZFITSDataSource_R1v1(filename,
decoder_ = new NectarCam_ACADACameraEventDecoder_R1v1(filename, decoder_config),
/* adopt_decoder_= */ false /* we delete it! */, config)
{
// nothing to see here
}


NectarCamZFITSDataSource_R1v1::
NectarCamZFITSDataSource_R1v1(const std::string& filename,
const decoder_config_type& decoder_config, const config_type& config):
NectarCamZFITSDataSource_R1v1(filename, config, decoder_config)
{
// nothing to see here
}

NectarCamZFITSDataSource_R1v1::~NectarCamZFITSDataSource_R1v1()
{
delete decoder_;
}

/*
AAA tttt
Expand Down Expand Up @@ -257,7 +294,7 @@ NectarCamZFITSDataSource::construct_delegate(std::string filename,
case calin::ix::iact_data::zfits_data_source::ACADA_DATA_MODEL_R1V0:
return new NectarCamZFITSDataSource_R1v0(filename, config, decoder_config);
case calin::ix::iact_data::zfits_data_source::ACADA_DATA_MODEL_R1V1:
throw std::runtime_error("NectarCamZFITSDataSource::construct_delegate: R1v1 not supported yet");
return new NectarCamZFITSDataSource_R1v1(filename, config, decoder_config);
default:
throw std::runtime_error("NectarCamZFITSDataSource::construct_delegate: Requested data model not known");
}
Expand Down

0 comments on commit 9dae0ae

Please sign in to comment.