#include "Kinematics.h" #include #include Kinematics::Kinematics() : sys(nullptr), save_tree_flag(false), do_plotter_flag(false), global_generator(new TRandom3(0)) { std::cout<<"----------GWM Kinematics Simulation----------"<>junk>>m_outfile_name; input>>junk>>junk; if(junk == "yes") save_tree_flag = true; input>>junk>>junk; if(junk == "yes") do_plotter_flag = true; std::vector avec, zvec, svec; int z, a, s; getline(input, junk); getline(input, junk); input>>junk>>m_rxn_type; getline(input, junk); getline(input, junk); switch(m_rxn_type) { case 0: { sys = new ReactionSystem(); m_rxn_type = ONESTEP_DECAY; for(int i=0; i<3; i++) { input>>z>>a; avec.push_back(a); zvec.push_back(z); } break; } case 1: { sys = new ReactionSystem(); m_rxn_type = ONESTEP_RXN; for(int i=0; i<3; i++) { input>>z>>a; avec.push_back(a); zvec.push_back(z); } break; } case 2: { sys = new TwoStepSystem(); m_rxn_type = TWOSTEP; for(int i=0; i<4; i++) { input>>z>>a; avec.push_back(a); zvec.push_back(z); } break; } case 3: { sys = new ThreeStepSystem(); m_rxn_type = THREESTEP; for(int i=0; i<5; i++) { input>>z>>a; avec.push_back(a); zvec.push_back(z); } break; } default: return false; } sys->SetNuclei(zvec, avec); int nlayers; double thickness; getline(input, junk); getline(input, junk); input>>junk>>junk; input>>junk>>nlayers; for(int i=0; i>junk>>junk>>thickness; getline(input, junk); getline(input, junk); avec.clear(); zvec.clear(); svec.clear(); while(input>>z) { if(z == 0) break; input>>a>>s; zvec.push_back(z); avec.push_back(a); svec.push_back(s); } sys->AddTargetLayer(zvec, avec, svec, thickness); input>>junk; } double par1, par2; getline(input, junk); getline(input, junk); input>>junk>>m_nsamples; input>>junk>>par1>>junk>>par2; sys->SetBeamDistro(par1, par2); input>>junk>>par1>>junk>>par2; sys->SetTheta1Range(par1, par2); input>>junk>>par1>>junk>>par2; sys->SetExcitationDistro(par1, par2); sys->SetRandomGenerator(global_generator); std::cout<<"Reaction equation: "<Branch("target", &targ); tree->Branch("projectile", &proj); tree->Branch("ejectile", &eject); tree->Branch("residual", &residual); } //For progress tracking int percent5 = 0.05*m_nsamples; int count = 0; int npercent = 0; for(int i=0; iRunSystem(); if(save_tree_flag) { targ = ConvertNucleus(sys->GetTarget()); proj = ConvertNucleus(sys->GetProjectile()); eject = ConvertNucleus(sys->GetEjectile()); residual = ConvertNucleus(sys->GetResidual()); tree->Fill(); } if(do_plotter_flag) { plotman.FillData(sys->GetTarget()); plotman.FillData(sys->GetProjectile()); plotman.FillData(sys->GetEjectile()); plotman.FillData(sys->GetResidual()); } } output->cd(); if(save_tree_flag) tree->Write(tree->GetName(), TObject::kOverwrite); if(do_plotter_flag) { plotman.GetTable()->Write(); plotman.ClearTable(); } output->Close(); } void Kinematics::RunOneStepDecay() { TFile* output = TFile::Open(m_outfile_name.c_str(), "RECREATE"); TTree* tree; NucData targ, eject, residual; if(save_tree_flag) { tree = new TTree("DataTree","DataTree"); tree->Branch("target", &targ); tree->Branch("ejectile", &eject); tree->Branch("residual", &residual); } //For progress tracking int percent5 = 0.05*m_nsamples; int count = 0; int npercent = 0; for(int i=0; iRunSystem(); if(save_tree_flag) { targ = ConvertNucleus(sys->GetTarget()); eject = ConvertNucleus(sys->GetEjectile()); residual = ConvertNucleus(sys->GetResidual()); tree->Fill(); } if(do_plotter_flag) { plotman.FillData(sys->GetTarget()); plotman.FillData(sys->GetEjectile()); plotman.FillData(sys->GetResidual()); } } output->cd(); if(save_tree_flag) tree->Write(tree->GetName(), TObject::kOverwrite); if(do_plotter_flag) { plotman.GetTable()->Write(); plotman.ClearTable(); } output->Close(); } void Kinematics::RunTwoStep() { TwoStepSystem* this_sys = dynamic_cast(sys); if(this_sys == nullptr) { return; } TFile* output = TFile::Open(m_outfile_name.c_str(), "RECREATE"); TTree* tree; NucData targ, proj, eject, residual, break1, break2; if(save_tree_flag) { tree = new TTree("DataTree","DataTree"); tree->Branch("target", &targ); tree->Branch("projectile", &proj); tree->Branch("ejectile", &eject); tree->Branch("residual", &residual); tree->Branch("breakup1", &break1); tree->Branch("breakup2", &break2); } //For progress tracking int percent5 = 0.05*m_nsamples; int count = 0; int npercent = 0; for(int i=0; iRunSystem(); if(save_tree_flag) { targ = ConvertNucleus(this_sys->GetTarget()); proj = ConvertNucleus(this_sys->GetProjectile()); eject = ConvertNucleus(this_sys->GetEjectile()); residual = ConvertNucleus(this_sys->GetResidual()); break1 = ConvertNucleus(this_sys->GetBreakup1()); break2 = ConvertNucleus(this_sys->GetBreakup2()); tree->Fill(); } if(do_plotter_flag) { plotman.FillData(this_sys->GetTarget()); plotman.FillData(this_sys->GetProjectile()); plotman.FillData(this_sys->GetEjectile()); plotman.FillData(this_sys->GetResidual()); plotman.FillData(this_sys->GetBreakup1()); plotman.FillData(this_sys->GetBreakup2()); } } output->cd(); if(save_tree_flag) tree->Write(tree->GetName(), TObject::kOverwrite); if(do_plotter_flag) { plotman.GetTable()->Write(); plotman.ClearTable(); } output->Close(); } void Kinematics::RunThreeStep() { ThreeStepSystem* this_sys = dynamic_cast(sys); if(this_sys == nullptr) { return; } TFile* output = TFile::Open(m_outfile_name.c_str(), "RECREATE"); TTree* tree; NucData targ, proj, eject, residual, break1, break2, break3, break4; if(save_tree_flag) { tree = new TTree("DataTree","DataTree"); tree->Branch("target", &targ); tree->Branch("projectile", &proj); tree->Branch("ejectile", &eject); tree->Branch("residual", &residual); tree->Branch("breakup1", &break1); tree->Branch("breakup2", &break2); tree->Branch("breakup3", &break3); tree->Branch("breakup4", &break4); } //For progress updating int percent5 = 0.05*m_nsamples; int count = 0; int npercent = 0; for(int i=0; iRunSystem(); if(save_tree_flag) { targ = ConvertNucleus(this_sys->GetTarget()); proj = ConvertNucleus(this_sys->GetProjectile()); eject = ConvertNucleus(this_sys->GetEjectile()); residual = ConvertNucleus(this_sys->GetResidual()); break1 = ConvertNucleus(this_sys->GetBreakup1()); break2 = ConvertNucleus(this_sys->GetBreakup2()); break3 = ConvertNucleus(this_sys->GetBreakup3()); break4 = ConvertNucleus(this_sys->GetBreakup4()); tree->Fill(); } if(do_plotter_flag) { plotman.FillData(this_sys->GetTarget()); plotman.FillData(this_sys->GetProjectile()); plotman.FillData(this_sys->GetEjectile()); plotman.FillData(this_sys->GetResidual()); plotman.FillData(this_sys->GetBreakup1()); plotman.FillData(this_sys->GetBreakup2()); plotman.FillData(this_sys->GetBreakup3()); plotman.FillData(this_sys->GetBreakup4()); } } output->cd(); if(save_tree_flag) tree->Write(tree->GetName(), TObject::kOverwrite); if(do_plotter_flag) { plotman.GetTable()->Write(); plotman.ClearTable(); } output->Close(); }