Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 2 additions & 61 deletions src/clas-stringspinner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@ static double beam_energy = 10.60410;
static std::string target_type = "proton";
static std::string pol_type = "UU";
static std::string spin_type[nObj] = {"", ""};
static std::string patch_boost = "beam";
static std::vector<int> cut_inclusive = {};
static std::vector<double> cut_theta = {};
static std::string config_name = "clas12";
static std::vector<std::string> config_overrides = {};
static int seed = -1;
static bool enable_count_before_cuts = false;
static bool enable_verbose_mode = false;
static bool enable_patch_boost = false;

//////////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -170,25 +168,11 @@ CUTS FOR EVENT SELECTION:
of all particles used in --cut-inclusive to have
MIN <= theta <= MAX, with units in degrees

MISCELLANEOUS OPTIONS:

--patch-boost temporary patch for boost issue:
https://gitlab.com/Pythia8/releases/-/issues/529
this option ensures the event record is boosted
back to the fixed-target rest frame
- needed for Pythia v8.312, and possibly earlier
- available choices:
'beam' = derive boost from beam momentum
'target' = derive boost from target momentum
'none' = do not apply any boost
default: {patch_boost:?}

OPTIONS FOR OSG COMPATIBILITY:

--trig NUM_EVENTS same as --num-events
--docker unused
)" + std::string("\n"),
fmt::arg("patch_boost", patch_boost),
fmt::arg("num_events", num_events),
fmt::arg("out_file", out_file),
fmt::arg("beam_energy", beam_energy),
Expand Down Expand Up @@ -255,7 +239,6 @@ int main(int argc, char** argv)
opt_config,
opt_seed,
opt_set,
opt_patch_boost,
opt_help,
opt_version,
opt_count_before_cuts,
Expand All @@ -276,7 +259,6 @@ int main(int argc, char** argv)
{"config", required_argument, nullptr, opt_config},
{"seed", required_argument, nullptr, opt_seed},
{"set", required_argument, nullptr, opt_set},
{"patch-boost", required_argument, nullptr, opt_patch_boost},
{"help", no_argument, nullptr, opt_help},
{"version", no_argument, nullptr, opt_version},
{"count-before-cuts", no_argument, nullptr, opt_count_before_cuts},
Expand Down Expand Up @@ -315,7 +297,6 @@ int main(int argc, char** argv)
case opt_config: config_name = std::string(optarg); break;
case opt_seed: seed = std::stoi(optarg); break;
case opt_set: config_overrides.push_back(std::string(optarg)); break;
case opt_patch_boost: patch_boost = std::string(optarg); break;
case opt_count_before_cuts: enable_count_before_cuts = true; break;
case opt_verbose: enable_verbose_mode = true; break;
case opt_help:
Expand Down Expand Up @@ -357,7 +338,6 @@ int main(int argc, char** argv)
Verbose(fmt::format("{:>30} = {:?}", "target-spin", spin_type[objTarget]));
Verbose(fmt::format("{:>30} = ({}) [{}]", "cut-inclusive", fmt::join(cut_inclusive, ", "), enable_cut_inclusive ? "enabled" : "disabled"));
Verbose(fmt::format("{:>30} = ({}) [{}]", "cut-theta", fmt::join(cut_theta, ", "), enable_cut_theta ? "enabled" : "disabled"));
Verbose(fmt::format("{:>30} = {:?}", "patch-boost", patch_boost));
Verbose(fmt::format("{:>30} = {}", "seed", seed));
Verbose(fmt::format("{:>30} = {}", "config", config_name));
Verbose(fmt::format("{:-^82}", ""));
Expand Down Expand Up @@ -473,23 +453,6 @@ int main(int argc, char** argv)
Verbose(fmt::format("{:>30} = ({})", fmt::format("{} spin vector", obj == objBeam ? "quark" : obj_name[obj]), fmt::join(spin_vec[obj], ", ")));
}

// settings for boost patch, for boosting the Pythia Event record frame back to the lab frame (fixed-target rest frame)
int patch_boost_particle_row = -1;
int patch_boost_particle_pdg = 0;
if(patch_boost == "beam") {
enable_patch_boost = true;
patch_boost_particle_row = BEAM_ROW;
patch_boost_particle_pdg = BEAM_PDG;
} else if(patch_boost == "target") {
enable_patch_boost = true;
patch_boost_particle_row = TARGET_ROW;
patch_boost_particle_pdg = target_pdg;
} else if(patch_boost == "none") {
enable_patch_boost = false;
} else {
return Error(fmt::format("option '--patch-boost' has unknown value {:?}", patch_boost));
}

// configure pythia
/// plugin stringspinner hooks
auto fhooks = std::make_shared<Pythia8::SimpleStringSpinner>();
Expand Down Expand Up @@ -548,37 +511,15 @@ int main(int argc, char** argv)
if(enable_count_before_cuts)
evnum++;

// boost event record back to lab frame
// see <https://gitlab.com/Pythia8/releases/-/issues/529> for details
if(enable_patch_boost) {
auto const& par__evt = evt[patch_boost_particle_row]; // beam (or target) momentum in event frame
auto const& par__proc = proc[patch_boost_particle_row]; // beam (or target) momentum in hard-process frame, which is assumed to be the lab frame
// check that we are using the correct beam (or target) particle
if(par__evt.status() != -12) {
EventError("patch-boost particle is not an incoming beam (or target) particle");
continue;
}
if(par__evt.id() != patch_boost_particle_pdg) {
EventError(fmt::format("patch-boost particle does not have the expected PDG: {} != {}", par__evt.id(), patch_boost_particle_pdg));
continue;
}
if(par__evt.id() != par__proc.id()) {
EventError("patch-boost particle PDG mismatch between event record and hard-process record");
continue;
}
// perform the boost
Pythia8::RotBstMatrix boost_to_lab;
boost_to_lab.bst(par__evt.p(), par__proc.p());
evt.rotbst(boost_to_lab);
}
// check that the event-record frame matches the hard-process frame, which is assumed to be the lab frame
// see <https://gitlab.com/Pythia8/releases/-/issues/529> for details
for(auto const& [name, row] : std::vector<std::pair<std::string,int>>{{"beam", BEAM_ROW}, {"target", TARGET_ROW}}) {
auto diff = std::max(
std::abs(evt[row].pz() - proc[row].pz()),
std::abs(evt[row].e() - proc[row].e())
);
if(diff > 0.0001)
EventError(fmt::format("mismatch of event-frame and hard-process-frame {} momentum; use '--verbose' for details', and consider changing the value of the '--patch-boost' option", name));
EventError(fmt::format("mismatch of event-frame and hard-process-frame {} momentum; see https://gitlab.com/Pythia8/releases/-/issues/529", name));
Verbose(fmt::format("hard process {:<8} pz = {:<20.10} E = {:<20.10}", name, proc[row].pz(), proc[row].e()));
Verbose(fmt::format("event record {:<8} pz = {:<20.10} E = {:<20.10}", name, evt[row].pz(), evt[row].e()));
}
Expand Down