Skip to content

Commit

Permalink
Change handling of muon candidate flag
Browse files Browse the repository at this point in the history
  • Loading branch information
sfegan committed Oct 7, 2024
1 parent d6267b7 commit 8d0a2ea
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 17 deletions.
1 change: 1 addition & 0 deletions include/diagnostics/run_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class RunInfoDiagnosticsParallelEventVisitor:
calin::ix::iact_data::telescope_run_configuration::TelescopeRunConfiguration* run_config_ = nullptr;
calin::math::histogram::SimpleHist trigger_type_code_hist_ = { 1.0, -1.0, 256.0 };
calin::math::histogram::SimpleHist trigger_type_code_diff_hist_ = { 1.0, -256.0, 256.0 };
calin::math::histogram::SimpleHist muon_candidate_elapsed_time_hist_ = { 1.0, -60.0, 7200.0 };
};

} } } // namespace calin::diagnostics::run_info
8 changes: 6 additions & 2 deletions proto/diagnostics/run_info.proto
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ message RunInfoConfig {
(CFO).desc = "Resolution of event number histogram.", (CFO).units="events" ];
double event_time_histogram_resolution = 11 [
(CFO).desc = "Resolution of event time histograms.", (CFO).units="s" ];
double log10_delta_t_histogram_binsize = 12 [
double event_time_histogram_max = 12 [
(CFO).desc = "Maximum of event time histogram.", (CFO).units="s" ];
double event_time_histogram_min = 13 [
(CFO).desc = "Minimum of event time histogram.", (CFO).units="s" ];
double log10_delta_t_histogram_binsize = 14 [
(CFO).desc = "Resolution of log10(delta-T) histograms." ];
double delta_t_timeslice = 13 [
double delta_t_timeslice = 15 [
(CFO).desc = "Resolution of time-dependent delta-T histogram time slices.",
(CFO).units="s" ];
CameraRunInfoConfig default_nectarcam_config = 100;
Expand Down
3 changes: 2 additions & 1 deletion proto/iact_data/telescope_event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@ enum TriggerType {
TRIGGER_FORCED_BY_ARRAY = 6;
TRIGGER_UCTS_AUX = 7;
TRIGGER_MULTIPLE = 8;
TRIGGER_MUON = 9;
};

enum ImageTreatmentMode {
Expand Down Expand Up @@ -469,6 +468,8 @@ message TelescopeEvent {
(CFO).desc = "Flag for whether array trigger was received." ];
int64 array_event_number = 6 [
(CFO).desc = "Array event number or \"-1\" if not received." ];
bool is_muon_candidate = 7 [
(CFO).desc = "Muon candidate flag set for event." ];

bool all_modules_present = 10 [
(CFO).desc = "True if all modules are present in the image." ];
Expand Down
34 changes: 21 additions & 13 deletions src/diagnostics/run_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ RunInfoDiagnosticsParallelEventVisitor::RunInfoDiagnosticsParallelEventVisitor(
partials_(google::protobuf::Arena::CreateMessage<calin::ix::diagnostics::run_info::PartialRunInfo>(arena_)),
run_config_(google::protobuf::Arena::CreateMessage<calin::ix::iact_data::telescope_run_configuration::TelescopeRunConfiguration>(arena_))
{
// nothing to see here
muon_candidate_elapsed_time_hist_ = calin::math::histogram::SimpleHist(
config_.event_time_histogram_resolution(),
config_.event_time_histogram_min(), config_.event_time_histogram_max());
}

RunInfoDiagnosticsParallelEventVisitor::~RunInfoDiagnosticsParallelEventVisitor()
Expand Down Expand Up @@ -147,6 +149,7 @@ bool RunInfoDiagnosticsParallelEventVisitor::visit_telescope_run(

trigger_type_code_hist_.clear();
trigger_type_code_diff_hist_.clear();
muon_candidate_elapsed_time_hist_.clear();

calin::ix::diagnostics::run_info::RunInfoConfig config = config_;
if(config.module_counter_test_id_size() == 0 and
Expand Down Expand Up @@ -291,12 +294,10 @@ bool RunInfoDiagnosticsParallelEventVisitor::visit_telescope_event(uint64_t seq_
partials_->increment_num_mono_trigger(cdts.mono_trigger());
partials_->increment_num_stereo_trigger(cdts.stereo_trigger());
partials_->increment_num_busy_trigger(cdts.busy_trigger());
partials_->increment_num_muon_candidate(cdts.muon_candidate());
trigger_type_code_diff_hist_.insert(int(tib.trigger_type()) - int(cdts.trigger_type() & 0x7c));
partials_->increment_num_tib_ucts_trigger_code_mismatch_if(tib.trigger_type() != (cdts.trigger_type() & 0x7c));
} else {
switch(event->trigger_type()) {
case TRIGGER_MUON: partials_->increment_num_muon_candidate(); // FALLTHROUGH
case TRIGGER_PHYSICS: partials_->increment_num_mono_trigger(); break;
case TRIGGER_FORCED_BY_ARRAY: partials_->increment_num_stereo_trigger(); break;
default: break;
Expand All @@ -312,11 +313,9 @@ bool RunInfoDiagnosticsParallelEventVisitor::visit_telescope_event(uint64_t seq_
partials_->increment_num_pedestal_trigger(cdts.pedestal_trigger());
partials_->increment_num_slow_control_trigger(cdts.slow_control_trigger());
partials_->increment_num_busy_trigger(cdts.busy_trigger());
partials_->increment_num_muon_candidate(cdts.muon_candidate());
trigger_type_code_hist_.insert(cdts.trigger_type());
} else {
switch(event->trigger_type()) {
case TRIGGER_MUON: partials_->increment_num_muon_candidate(); // FALLTHROUGH
case TRIGGER_PHYSICS: partials_->increment_num_mono_trigger(); break;
case TRIGGER_SOFTWARE: partials_->increment_num_slow_control_trigger(); break;
case TRIGGER_PEDESTAL: partials_->increment_num_pedestal_trigger(); break;
Expand All @@ -330,11 +329,18 @@ bool RunInfoDiagnosticsParallelEventVisitor::visit_telescope_event(uint64_t seq_
};
}

// MUON CANDIDATE
partials_->increment_num_muon_candidate(event->is_muon_candidate());

// EVENT TIME
if(event->has_absolute_event_time() and event->absolute_event_time().time_ns()>0) {
auto t = event->absolute_event_time().time_ns();
partials_->set_max_event_time(std::max(partials_->max_event_time(), t));
partials_->set_min_event_time(std::min(partials_->min_event_time(), t));
if(event->is_muon_candidate()) {
double elapsed_time_sec = (t-run_config_->run_start_time().time_ns())*1e-9;
muon_candidate_elapsed_time_hist_.insert(elapsed_time_sec);
}
}

// CAMERA CLOCK TIMES
Expand Down Expand Up @@ -396,6 +402,8 @@ calin::ix::diagnostics::run_info::RunInfoConfig RunInfoDiagnosticsParallelEventV

config.set_event_number_histogram_resolution(10000);
config.set_event_time_histogram_resolution(1.0);
config.set_event_time_histogram_max(7200.0);
config.set_event_time_histogram_min(-60.0);
config.set_log10_delta_t_histogram_binsize(0.01);
config.set_delta_t_timeslice(100.0);

Expand Down Expand Up @@ -454,6 +462,8 @@ bool RunInfoDiagnosticsParallelEventVisitor::merge_results()
trigger_type_code_hist_.clear();
parent_->trigger_type_code_diff_hist_.insert_hist(trigger_type_code_diff_hist_);
trigger_type_code_diff_hist_.clear();
parent_->muon_candidate_elapsed_time_hist_.insert_hist(muon_candidate_elapsed_time_hist_);
muon_candidate_elapsed_time_hist_.clear();
}
return true;
}
Expand Down Expand Up @@ -558,14 +568,18 @@ void RunInfoDiagnosticsParallelEventVisitor::integrate_partials()
trigger_type_code_diff_hist_.dump_as_compactified_proto(0, 0,
results_->mutable_tib_ucts_trigger_code_diff_histogram());

const double thistmin = -60.0;
const double thistmax = 7200.0;
muon_candidate_elapsed_time_hist_.dump_as_proto(
results_->mutable_elapsed_time_histogram_muon_candidate());

if(partials_->event_number_sequence_size() > 0)
{
calin::math::histogram::Histogram1D event_number_hist {
config_.event_number_histogram_resolution(), 0.0, 1.0e9,
double(run_config_->camera_layout().first_event_number()) };

const double thistmin = config_.event_time_histogram_min();
const double thistmax = config_.event_time_histogram_max();

calin::math::histogram::Histogram1D elapsed_time_hist {
config_.event_time_histogram_resolution(), thistmin, thistmax, 0.0 };
calin::math::histogram::Histogram1D trigger_physics_elapsed_time_hist {
Expand All @@ -582,8 +596,6 @@ void RunInfoDiagnosticsParallelEventVisitor::integrate_partials()
config_.event_time_histogram_resolution(), thistmin, thistmax, 0.0 };
calin::math::histogram::Histogram1D trigger_ucts_aux_elapsed_time_hist {
config_.event_time_histogram_resolution(), thistmin, thistmax, 0.0 };
calin::math::histogram::Histogram1D trigger_muon_candidate_time_hist {
config_.event_time_histogram_resolution(), thistmin, thistmax, 0.0 };

for(int ievent=0; ievent<partials_->event_number_sequence_size(); ++ievent) {
event_number_hist.insert(partials_->event_number_sequence(ievent));
Expand All @@ -606,8 +618,6 @@ void RunInfoDiagnosticsParallelEventVisitor::integrate_partials()
trigger_forced_array_elapsed_time_hist.insert(elapsed_time_sec); break;
case calin::ix::iact_data::telescope_event::TRIGGER_UCTS_AUX:
trigger_ucts_aux_elapsed_time_hist.insert(elapsed_time_sec); break;
case calin::ix::iact_data::telescope_event::TRIGGER_MUON:
trigger_muon_candidate_time_hist.insert(elapsed_time_sec); break;
case calin::ix::iact_data::telescope_event::TRIGGER_UNKNOWN:
case calin::ix::iact_data::telescope_event::TRIGGER_MULTIPLE:
default:
Expand Down Expand Up @@ -635,8 +645,6 @@ void RunInfoDiagnosticsParallelEventVisitor::integrate_partials()
results_->mutable_elapsed_time_histogram_trigger_forced_array());
trigger_ucts_aux_elapsed_time_hist.dump_as_proto(
results_->mutable_elapsed_time_histogram_trigger_ucts_aux());
trigger_muon_candidate_time_hist.dump_as_proto(
results_->mutable_elapsed_time_histogram_muon_candidate());

auto event_index = calin::util::algorithm::argsort(
partials_->event_number_sequence().begin(), partials_->event_number_sequence().end());
Expand Down
6 changes: 5 additions & 1 deletion src/iact_data/unified_acada_event_decoder_r1v1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ decode(calin::ix::iact_data::telescope_event::TelescopeEvent* calin_event,
case 0: calin_event->set_trigger_type(TRIGGER_EXTERNAL_FLASHER); break;
case 1: calin_event->set_trigger_type(TRIGGER_INTERNAL_FLASHER); break;
case 2: calin_event->set_trigger_type(TRIGGER_PEDESTAL); break;
case 16: calin_event->set_trigger_type(TRIGGER_MUON); break;
case 16: calin_event->set_trigger_type(TRIGGER_PHYSICS);
calin_event->set_is_muon_candidate(true); break;
case 17: calin_event->set_trigger_type(TRIGGER_FORCED_BY_ARRAY); break;
case 24: calin_event->set_trigger_type(TRIGGER_SOFTWARE); break;
case 32:
Expand Down Expand Up @@ -242,6 +243,9 @@ decode(calin::ix::iact_data::telescope_event::TelescopeEvent* calin_event,
calin_clock->set_time_value(cdts.pps_counter()*10000000ULL + cdts.clock_counter());
calin_clock->set_time_sequence_id(0);
calin_clock->set_time_value_may_be_suspect(clock_may_be_suspect);

calin_event->set_is_muon_candidate(calin_event->is_muon_candidate()
|| cdts.muon_candidate());
} else {
calin_event->set_camera_clock_index(1,-1);
calin_event->set_camera_clock_index(2,-1);
Expand Down

0 comments on commit 8d0a2ea

Please sign in to comment.