114 Double_t px, Double_t py,
117 Double_t theta = atan(sqrt(x * x + y * y) / z);
118 Double_t c = cos(theta);
119 Double_t s = sin(theta);
121 Double_t px1 = c * px + s * pz;
122 Double_t pzr = -s * px + c * pz;
123 Double_t phi = atan2(y, x);
127 Double_t pxr = c * px1 - s * py;
128 Double_t pyr = s * px1 + c * py;
131 return {pxr, pyr, pzr};
201 Double_t start[3] = {0., 0.,
startZ};
202 Double_t end[3] = {0., 0.,
endZ};
208 Double_t bparam = 0.;
211 cout <<
"Info GenieGenerator: MaterialBudget " << start[2] <<
" - "
213 cout <<
"Info GenieGenerator: MaterialBudget " << bparam << endl;
214 cout <<
"Info GenieGenerator: MaterialBudget 0 " << mparam[0] << endl;
215 cout <<
"Info GenieGenerator: MaterialBudget 1 " << mparam[1] << endl;
216 cout <<
"Info GenieGenerator: MaterialBudget 2 " << mparam[2] << endl;
217 cout <<
"Info GenieGenerator: MaterialBudget 3 " << mparam[3] << endl;
218 cout <<
"Info GenieGenerator: MaterialBudget 4 " << mparam[4] << endl;
219 cout <<
"Info GenieGenerator: MaterialBudget 5 " << mparam[5] << endl;
220 cout <<
"Info GenieGenerator: MaterialBudget 6 " << mparam[6] << endl;
221 cout <<
"Info GenieGenerator: MaterialBudget " << mparam[0] * mparam[4]
225 printf(
"Reading (log10(p),log10(pt)) Hists from file: %s\n",
227 for (Int_t idnu = 12; idnu < 17; idnu += 2) {
228 for (Int_t idadd = -1; idadd < 2; idadd += 2) {
229 Int_t idhnu =
static_cast<int>(idbase + idnu);
230 if (idadd < 0) idhnu += 1000;
231 sprintf(ts,
"%d", idhnu);
234 TH2* h2tmp =
dynamic_cast<TH2*
>(
fInputFile->Get(ts));
235 printf(
"HISTID=%d, Title:%s\n", idhnu, h2tmp->GetTitle());
236 sprintf(ts,
"px_%d", idhnu);
239 pxhist[idhnu] = h2tmp->ProjectionX(ts, 1, -1);
240 Int_t nbinx = h2tmp->GetNbinsX();
243 for (Int_t k = 1; k < nbinx + 1; k += 1) {
244 sprintf(ts,
"h%d%d", idhnu, k);
246 pyslice[idhnu][k] = h2tmp->ProjectionY(ts, k, k);
255 LOG(warning) <<
"End of input file. Rewind.";
260 LOG(info) <<
"Info GenieGenerator: neutrino event-nr " <<
fn << endl;
265 Double_t pout[3] = {0., 0., -1.};
269 while (pout[2] < 0.) {
271 Int_t idhnu = TMath::Abs(
neu) + idbase;
272 if (
neu < 0) idhnu += 1000;
273 Int_t nbinmx =
pxhist[idhnu]->GetNbinsX();
274 Double_t pl10 = log10(
pzv);
275 Int_t nbx =
pxhist[idhnu]->FindBin(pl10);
276 if (nbx < 1) nbx = 1;
277 if (nbx > nbinmx) nbx = nbinmx;
278 Double_t ptlog10 =
pyslice[idhnu][nbx]->GetRandom();
280 Double_t pt = pow(10., ptlog10) - 0.01;
282 Double_t phi = gRandom->Uniform(0., 2 * TMath::Pi());
283 pout[0] = cos(phi) * pt;
284 pout[1] = sin(phi) * pt;
285 pout[2] =
pzv *
pzv - pt * pt;
288 pout[2] = TMath::Sqrt(pout[2]);
289 if (gRandom->Uniform(-1., 1.) < 0.) pout[0] = -pout[0];
290 if (gRandom->Uniform(-1., 1.) < 0.) pout[1] = -pout[1];
292 start[0] = (pout[0] / pout[2]) * (start[2] -
ztarget);
293 start[1] = (pout[1] / pout[2]) * (start[2] -
ztarget);
294 txnu = pout[0] / pout[2];
295 tynu = pout[1] / pout[2];
296 end[0] = txnu * (end[2] -
ztarget);
297 end[1] = tynu * (end[2] -
ztarget);
302 Double_t prob2int = -1.;
306 while (prob2int < gRandom->Uniform(0., 1.)) {
309 z = gRandom->Uniform(start[2], end[2]);
312 if (mparam[6] < 0.5) {
319 TGeoNode* node = gGeoManager->FindNode(x, y, z);
320 TGeoMaterial* mat =
nullptr;
321 if (node && !gGeoManager->IsOutside()) {
322 mat = node->GetVolume()->GetMaterial();
325 prob2int = mat->GetDensity() / mparam[7];
327 LOG(warning) <<
" GenieGenerator: prob2int > Maximum density????"
328 << prob2int <<
" maxrho:" << mparam[7]
329 <<
" material: " << mat->GetName() << endl;
336 Double_t zrelative = z -
ztarget;
337 Double_t tof = TMath::Sqrt(x * x + y * y + zrelative * zrelative) /
340 neu, pout[0], pout[1], pout[2], x, y, z, -1,
false,
341 TMath::Sqrt(pout[0] * pout[0] + pout[1] * pout[1] + pout[2] * pout[2]),
342 tof, mparam[0] * mparam[4]);
349 Int_t oLPdgCode =
neu;
351 oLPdgCode = copysign(TMath::Abs(
neu) - 1,
neu);
356 cpg->AddTrack(oLPdgCode, pp[0], pp[1], pp[2], x, y, z, 0,
true,
El, tof,
357 mparam[0] * mparam[4]);
360 for (
int i = 0; i <
nf; i++) {
362 cpg->AddTrack(
pdgf[i], pp[0], pp[1], pp[2], x, y, z, 0,
true,
Ef[i], tof,
363 mparam[0] * mparam[4]);