FairShip
Loading...
Searching...
No Matches
tPythia6Generator.cxx
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2// SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP
3// Collaboration
4
5#include "tPythia6Generator.h"
6
7#include <cmath>
8
9#include "FairPrimaryGenerator.h"
10#include "TPythia6.h"
11#include "TROOT.h"
12#include "TRandom1.h"
13using std::cout;
14using std::endl;
15// ----- Default constructor -------------------------------------------
17 fMom = 400; // muon
18 fDeepCopy = kFALSE; // copy complete pythia event
19 fPythia = TPythia6::Instance();
20 fPionKaonDecay = kFALSE;
21 fType = "gamma/mu-"; // muon proton scattering
22 fTarget = "p+";
23}
24// -------------------------------------------------------------------------
25
26// ----- Default constructor -------------------------------------------
28 fPythia->SetMRPY(1, gRandom->GetSeed());
29
30 cout << "Muon Momentum " << fMom << endl;
31
32 if (fPionKaonDecay) {
33 // let also pion and kaon decay
34 fPythia->SetMDCY(fPythia->Pycomp(211), 1, 100);
35 fPythia->SetMDCY(fPythia->Pycomp(321), 1, 100);
36 }
37 fPythia->SetMSEL(1); // msel 2 includes diffractive parts
38 // fPythia->SetMSUB(91,0); // elastic scattering
39 fPythia->SetPARP(2, 2); // To get below 10 GeV, you have to change PARP(2)
40
41 /* compass settings
42 # CKIN(10) = 100
43 # MSEL = 2 # include elastic and diffractive to mbias
44 # MSTJ = 1 default, string fragmentation
45 */
46
47 fPythia->Initialize("FIXT", fType, fTarget, fMom);
48
49 return kTRUE;
50}
51// -------------------------------------------------------------------------
52
53// ----- Destructor ----------------------------------------------------
55// -------------------------------------------------------------------------
56
57// ----- Passing the event ---------------------------------------------
58Bool_t tPythia6Generator::ReadEvent(FairPrimaryGenerator* cpg) {
59 Int_t npart = 0;
60 while (npart == 0) {
61 fPythia->GenerateEvent();
62 // remove all unnecessary stuff
63 fPythia->Pyedit(2);
64 npart = fPythia->GetN();
65 };
66
67 for (Int_t ii = 1; ii < fPythia->GetN() + 1; ii++) {
68 Bool_t wanttracking = false;
69 if (fPythia->GetK(ii, 1) == 1) {
70 wanttracking = true;
71 }
72 Int_t id = fPythia->GetK(ii, 2);
73 Double_t z = fPythia->GetV(ii, 3) / 10.;
74 Double_t x = fPythia->GetV(ii, 1) / 10.;
75 Double_t y = fPythia->GetV(ii, 2) / 10.;
76 Double_t pz = fPythia->GetP(ii, 3);
77 Double_t px = fPythia->GetP(ii, 1);
78 Double_t py = fPythia->GetP(ii, 2);
79 Int_t im = fPythia->GetV(ii, 4);
80 // cout << "debug p6 "<<id<<" "<< pz << endl;
81 // copy blind complete pythia event
82 if (fDeepCopy || wanttracking) {
83 cpg->AddTrack(id, px, py, pz, x, y, z, im, wanttracking);
84 }
85 }
86 return kTRUE;
87}
Bool_t Init() override
Bool_t ReadEvent(FairPrimaryGenerator *) override
~tPythia6Generator() override