47 LOG(error) <<
"Pythia8Generator: firstEvent must be >= 0, got "
52 LOG(info) <<
"Open external file with charm or beauty hadrons: "
55 LOG(error) <<
"Pythia8Generator: error opening input file " << *
fextFile;
62 LOG(error) <<
"Pythia8Generator: cannot find tree pythia6 in file "
71 LOG(error) <<
"Pythia8Generator: firstEvent " <<
firstEvent
72 <<
" is out of range for " <<
fNevents <<
" entries";
81 ok &= (
fTree->SetBranchAddress(
"id", &
hid) >= 0);
82 ok &= (
fTree->SetBranchAddress(
"px", &
hpx) >= 0);
83 ok &= (
fTree->SetBranchAddress(
"py", &
hpy) >= 0);
84 ok &= (
fTree->SetBranchAddress(
"pz", &
hpz) >= 0);
85 ok &= (
fTree->SetBranchAddress(
"E", &
hE) >= 0);
86 ok &= (
fTree->SetBranchAddress(
"M", &
hM) >= 0);
87 ok &= (
fTree->SetBranchAddress(
"mid", &
mid) >= 0);
88 ok &= (
fTree->SetBranchAddress(
"mpx", &
mpx) >= 0);
89 ok &= (
fTree->SetBranchAddress(
"mpy", &
mpy) >= 0);
90 ok &= (
fTree->SetBranchAddress(
"mpz", &
mpz) >= 0);
91 ok &= (
fTree->SetBranchAddress(
"mE", &
mE) >= 0);
94 <<
"Pythia8Generator: failed to bind one or more required branches";
101 if (
fTree->GetBranch(
"k")) {
102 fTree->SetBranchAddress(
"k", &
ck);
103 if (
fTree->GetBranch(
"a0")) {
104 for (Int_t i = 0; i < 16; i++) {
118 fPythia->readString(
"ProcessLevel:all = off");
122 n =
fPythia->particleData.nextId(n);
123 std::shared_ptr<Pythia8::ParticleDataEntry> p =
124 fPythia->particleData.particleDataEntryPtr(n);
126 std::string particle = std::to_string(n) +
":mayDecay = false";
128 LOGF(info,
"Made %s stable for Pythia, should decay in Geant4",
135 fPythia->settings.mode(
"Beams:idB", 2212);
136 fPythia->settings.mode(
"Beams:frameType", 2);
138 fPythia->settings.parm(
"Beams:eB", 0.);
150 <<
"Pythia8Generator: Using geometry-based target coordinates startZ="
157 TGeoVolume* top = gGeoManager->GetTopVolume();
160 LOGF(error,
"target not found, %s, program will crash",
163 Double_t z_middle = target->GetMatrix()->GetTranslation()[2];
164 TGeoBBox* sha =
dynamic_cast<TGeoBBox*
>(target->GetVolume()->GetShape());
165 startZ = z_middle - sha->GetDZ();
166 endZ = z_middle + sha->GetDZ();
187 Double_t x, y, z, px, py, pz, dl, e, tof;
191 LOG(fatal) <<
"Pythia8Generator::ReadEvent: no external input tree is set; "
192 "standalone generation is not implemented. Call "
193 "UseExternalFile() before generating.";
202 LOG(warning) <<
"End of input file. Rewind.";
207 if (
static_cast<int>(
mE[0]) == 0) {
211 if (
static_cast<int>(fabs(
hid[0])) == 431) {
215 if (
static_cast<int>(
mE[0]) == 0) {
219 if (
static_cast<int>(fabs(
hid[0])) == 431 || isDs) {
220 Double_t rnr = gRandom->Uniform(0, 1);
232 Double_t prob2int = -1.;
235 Double_t zinterStart =
start[2];
238 Int_t nInter =
ck[0];
242 for (Int_t nI = 0; nI < nInter; nI++) {
246 Double_t intLengthFactor = 1;
248 intLengthFactor = 1.16;
257 const Double_t from[3] = {
xOff,
yOff, zinterStart};
258 constexpr int kMaxTries = 100000;
260 while (prob2int < rndm && tries < kMaxTries) {
263 zinter = gRandom->Uniform(zinterStart,
end[2]);
264 Double_t point[3] = {
xOff,
yOff, zinter};
266 Double_t interLength =
267 mparam[8] * intLengthFactor *
269 TGeoNode* node = gGeoManager->FindNode(point[0], point[1], point[2]);
270 TGeoMaterial* mat =
nullptr;
271 if (node && !gGeoManager->IsOutside()) {
272 mat = node->GetVolume()->GetMaterial();
279 rndm = gRandom->Uniform(0., 1.);
281 if (prob2int < rndm) {
283 zinter = zinterStart;
286 zinterStart = zinter;
290 for (Int_t c = 0; c < 2; c++) {
296 id =
static_cast<Int_t
>(
hid[0]);
297 fPythia->event.append(
id, 1, 0, 0,
hpx[0],
hpy[0],
hpz[0],
hE[0],
hM[0], 0.,
300 Double_t tau0 =
fPythia->particleData.tau0(
id);
301 dl = gRandom->Exp(tau0) /
hM[0];
303 Int_t addedParticles = 0;
318 for (Int_t ii = 1; ii <
fPythia->event.size(); ii++) {
320 Bool_t wanttracking =
false;
321 if (
fPythia->event[ii].isFinal()) {
325 z =
fPythia->event[ii].zProd() + dl *
fPythia->event[1].pz() + zinter;
332 z =
fPythia->event[ii].zProd() + zinter;
333 x =
fPythia->event[ii].xProd();
334 y =
fPythia->event[ii].yProd();
341 im =
fPythia->event[ii].mother1() + key;
350 key += addedParticles - 1;