Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add energy and particle specimen to hepmc3 run information attributes #7

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ cpp/cmake-build-debug/
python/.ipynb_checkpoints/

*.log

*~

build/
22 changes: 14 additions & 8 deletions cpp/abconv/ConfigProvider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,24 @@ ab::convert::ConfigProvider::from_hepmc_file(const std::shared_ptr<HepMC3::Reade
beam_particles.push_back(prt);
}
}
HepMC3::ConstGenParticlePtr hadron;
HepMC3::ConstGenParticlePtr lepton;
if(beam_particles[0]->momentum().e() > beam_particles[1]->momentum().e()) {
hadron = beam_particles[0];
lepton = beam_particles[1];

HepMC3::ConstGenParticlePtr ion;
HepMC3::ConstGenParticlePtr electron;

if(beam_particles[0]->pid()==11) {
electron = beam_particles[0];
ion = beam_particles[1];
}
else if(beam_particles[1]->pid()==11) {
electron = beam_particles[1];
ion = beam_particles[0];
}
else {
hadron = beam_particles[1];
lepton = beam_particles[0];
std::cerr << "No electron found in the two beam particles" << std::endl;
throw std::invalid_argument("No electron found");
}

return ab::EicConfigurator::config(hadron->momentum().e(), lepton->momentum().e(), beam_config);
return ab::EicConfigurator::config(ion, electron, beam_config);
}

ab::AfterburnerConfig ab::convert::ConfigProvider::from_preset_name(const string &name) {
Expand Down
55 changes: 32 additions & 23 deletions cpp/abconv/Converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void ab::abconv::Converter::convert() {
}
if (evt.event_number() < _first_event_number) continue;

if (_last_event_number && evt.event_number() > _last_event_number) continue;
if (_last_event_number && evt.event_number() > _last_event_number) break;

if(0 == events_processed) {
// The first event, determine beams configuration
Expand Down Expand Up @@ -199,27 +199,36 @@ HepMC3::ConstGenParticles ab::abconv::Converter::get_beam_particles(const HepMC3
}

void ab::abconv::Converter::ab_config_to_run_info(const std::shared_ptr<HepMC3::GenRunInfo>& run_info, ab::AfterburnerConfig cfg) {
using namespace HepMC3;
run_info->add_attribute("ab_afterburner_is_used", std::make_shared<BoolAttribute>(true));
run_info->add_attribute("ab_crossing_angle", std::make_shared<DoubleAttribute>(cfg.crossing_angle_hor));
run_info->add_attribute("ab_use_beam_bunch_sim", std::make_shared<BoolAttribute>(cfg.use_beam_bunch_sim));

run_info->add_attribute("ab_hadron_divergence_hor", std::make_shared<DoubleAttribute>(cfg.hadron_beam.divergence_hor));
run_info->add_attribute("ab_hadron_divergence_ver", std::make_shared<DoubleAttribute>(cfg.hadron_beam.divergence_ver));
run_info->add_attribute("ab_hadron_beta_crab_hor", std::make_shared<DoubleAttribute>(cfg.hadron_beam.beta_crab_hor));
run_info->add_attribute("ab_hadron_beta_star_hor", std::make_shared<DoubleAttribute>(cfg.hadron_beam.beta_star_hor));
run_info->add_attribute("ab_hadron_beta_star_ver", std::make_shared<DoubleAttribute>(cfg.hadron_beam.beta_star_ver));
run_info->add_attribute("ab_hadron_rms_emittance_hor", std::make_shared<DoubleAttribute>(cfg.hadron_beam.rms_emittance_hor));
run_info->add_attribute("ab_hadron_rms_emittance_ver", std::make_shared<DoubleAttribute>(cfg.hadron_beam.rms_emittance_ver));
run_info->add_attribute("ab_hadron_rms_bunch_length", std::make_shared<DoubleAttribute>(cfg.hadron_beam.rms_bunch_length));

run_info->add_attribute("ab_lepton_divergence_hor", std::make_shared<DoubleAttribute>(cfg.lepton_beam.divergence_hor));
run_info->add_attribute("ab_lepton_divergence_ver", std::make_shared<DoubleAttribute>(cfg.lepton_beam.divergence_ver));
run_info->add_attribute("ab_lepton_beta_crab_hor", std::make_shared<DoubleAttribute>(cfg.lepton_beam.beta_crab_hor));
run_info->add_attribute("ab_lepton_beta_star_hor", std::make_shared<DoubleAttribute>(cfg.lepton_beam.beta_star_hor));
run_info->add_attribute("ab_lepton_beta_star_ver", std::make_shared<DoubleAttribute>(cfg.lepton_beam.beta_star_ver));
run_info->add_attribute("ab_lepton_rms_emittance_hor", std::make_shared<DoubleAttribute>(cfg.lepton_beam.rms_emittance_hor));
run_info->add_attribute("ab_lepton_rms_emittance_ver", std::make_shared<DoubleAttribute>(cfg.lepton_beam.rms_emittance_ver));
run_info->add_attribute("ab_lepton_rms_bunch_length", std::make_shared<DoubleAttribute>(cfg.lepton_beam.rms_bunch_length));
using namespace HepMC3;

run_info->add_attribute("ab_afterburner_is_used", std::make_shared<BoolAttribute>(true));
run_info->add_attribute("afterburner_config_name", std::make_shared<StringAttribute>(cfg.name));

run_info->add_attribute("ion_beam_energy", std::make_shared<DoubleAttribute>(cfg.ion_beam.energy));
run_info->add_attribute("electron_beam_energy", std::make_shared<DoubleAttribute>(cfg.electron_beam.energy));

run_info->add_attribute("ion_beam_pdg", std::make_shared<IntAttribute>(cfg.ion_beam.pdg));
run_info->add_attribute("electron_beam_pdg", std::make_shared<IntAttribute>(cfg.electron_beam.pdg));

run_info->add_attribute("ab_crossing_angle", std::make_shared<DoubleAttribute>(cfg.crossing_angle_hor));
run_info->add_attribute("ab_use_beam_bunch_sim", std::make_shared<BoolAttribute>(cfg.use_beam_bunch_sim));

run_info->add_attribute("ab_ion_divergence_hor", std::make_shared<DoubleAttribute>(cfg.ion_beam.divergence_hor));
run_info->add_attribute("ab_ion_divergence_ver", std::make_shared<DoubleAttribute>(cfg.ion_beam.divergence_ver));
run_info->add_attribute("ab_ion_beta_crab_hor", std::make_shared<DoubleAttribute>(cfg.ion_beam.beta_crab_hor));
run_info->add_attribute("ab_ion_beta_star_hor", std::make_shared<DoubleAttribute>(cfg.ion_beam.beta_star_hor));
run_info->add_attribute("ab_ion_beta_star_ver", std::make_shared<DoubleAttribute>(cfg.ion_beam.beta_star_ver));
run_info->add_attribute("ab_ion_rms_emittance_hor", std::make_shared<DoubleAttribute>(cfg.ion_beam.rms_emittance_hor));
run_info->add_attribute("ab_ion_rms_emittance_ver", std::make_shared<DoubleAttribute>(cfg.ion_beam.rms_emittance_ver));
run_info->add_attribute("ab_ion_rms_bunch_length", std::make_shared<DoubleAttribute>(cfg.ion_beam.rms_bunch_length));

run_info->add_attribute("ab_electron_divergence_hor", std::make_shared<DoubleAttribute>(cfg.electron_beam.divergence_hor));
run_info->add_attribute("ab_electron_divergence_ver", std::make_shared<DoubleAttribute>(cfg.electron_beam.divergence_ver));
run_info->add_attribute("ab_electron_beta_crab_hor", std::make_shared<DoubleAttribute>(cfg.electron_beam.beta_crab_hor));
run_info->add_attribute("ab_electron_beta_star_hor", std::make_shared<DoubleAttribute>(cfg.electron_beam.beta_star_hor));
run_info->add_attribute("ab_electron_beta_star_ver", std::make_shared<DoubleAttribute>(cfg.electron_beam.beta_star_ver));
run_info->add_attribute("ab_electron_rms_emittance_hor", std::make_shared<DoubleAttribute>(cfg.electron_beam.rms_emittance_hor));
run_info->add_attribute("ab_electron_rms_emittance_ver", std::make_shared<DoubleAttribute>(cfg.electron_beam.rms_emittance_ver));
run_info->add_attribute("ab_electron_rms_bunch_length", std::make_shared<DoubleAttribute>(cfg.electron_beam.rms_bunch_length));
}

Loading