void FormEfficiencyCalibration::update_data() { double max = 0; std::set<double> flagged; fit_data_.sample_name_ = ui->isotopes->current_isotope().toStdString(); for (auto &q : fit_data_.peaks()) { // q.second.flagged = false; for (auto &p : ui->isotopes->current_isotope_gammas()) { double diff = abs(q.second.energy - p.energy); if (diff < ui->doubleEpsilonE->value()) { Qpx::Peak pk = q.second; //BROKEN // pk.flagged = true; pk.intensity_theoretical_ = p.abundance; pk.efficiency_relative_ = (pk.cps_best / pk.intensity_theoretical_); if (pk.efficiency_relative_ > max) max = pk.efficiency_relative_; flagged.insert(pk.energy); } } } ui->isotopes->select_energies(flagged); //BROKEN if (max > 0) { for (auto &q : fit_data_.peaks()) { // if (q.second.intensity_theoretical_ > 0) // q.second.efficiency_relative_ = q.second.efficiency_relative_ / max; } } if (!fit_data_.metadata_.name.empty()) //should be ==Qpx::Setting() peak_sets_[fit_data_.metadata_.name] = fit_data_; // ui->plotSpectrum->update_fit(contents_changed); replot_calib(); rebuild_table(true); toggle_push(); }
static int hash_insert_internal(hash_t * tablePtr, void *key, void *value) { hash_entry_t *hPtr; unsigned int hash; int i; if (tablePtr->hashKeyFn) { hash = tablePtr->hashKeyFn(key); i = hash & tablePtr->mask; } else { hash = (unsigned int) key; i = RANDOM_INDEX(tablePtr, hash); } /* * Search all of the entries in the appropriate bucket. */ if (tablePtr->compareKeysFn) { compare_hash_keys_fn compareKeysFn = tablePtr->compareKeysFn; for (hPtr = tablePtr->buckets[i]; hPtr != NULL; hPtr = hPtr->nextPtr) { if (hash != (unsigned int) hPtr->hash) { continue; } if (compareKeysFn(key, hPtr->key) == 0) { if (tablePtr->valueDestroyFn && value != hPtr->value) tablePtr->valueDestroyFn(hPtr->value); hPtr->value = value; return 0; } } } else { for (hPtr = tablePtr->buckets[i]; hPtr != NULL; hPtr = hPtr->nextPtr) { if (hash != (unsigned int) hPtr->hash) { continue; } if (key == hPtr->key) { if (tablePtr->valueDestroyFn && value != hPtr->value) tablePtr->valueDestroyFn(hPtr->value); hPtr->value = value; return 0; } } } /* * Entry not found. Add a new one to the bucket. */ hPtr = alc_calloc(tablePtr->alc, 1, sizeof(hash_entry_t)); hPtr->key = key; hPtr->value = value; hPtr->tablePtr = tablePtr; hPtr->hash = hash; hPtr->nextPtr = tablePtr->buckets[i]; tablePtr->buckets[i] = hPtr; tablePtr->numEntries++; /* * If the table has exceeded a decent size, rebuild it with many * more buckets. */ if (tablePtr->numEntries >= tablePtr->rebuildSize) { rebuild_table(tablePtr); } return 1; }
void FormEfficiencyCalibration::selection_changed_in_calib_plot() { selected_peaks_ = ui->PlotCalib->get_selected_pts(); ui->plotSpectrum->set_selected_peaks(ui->PlotCalib->get_selected_pts()); rebuild_table(false); toggle_push(); }