Line data Source code
1 : /**************************************************************************
2 : * Copyright(c) 1998-2016, ALICE Experiment at CERN, All rights reserved. *
3 : * *
4 : * Author: The ALICE Off-line Project. *
5 : * Contributors are mentioned in the code where appropriate. *
6 : * *
7 : * Permission to use, copy, modify and distribute this software and its *
8 : * documentation strictly for non-commercial purposes is hereby granted *
9 : * without fee, provided that the above copyright notice appears in all *
10 : * copies and that both the copyright notice and this permission notice *
11 : * appear in the supporting documentation. The authors make no claims *
12 : * about the suitability of this software for any purpose. It is *
13 : * provided "as is" without express or implied warranty. *
14 : **************************************************************************/
15 :
16 : #include "TMCProcess.h"
17 : #include "TDatabasePDG.h"
18 :
19 : #include "AliRun.h"
20 : #include "AliVParticle.h"
21 : #include "AliGenToyEventHeader.h"
22 :
23 : #include "AliGenToy.h"
24 :
25 : AliGenToy::AliGenToy(const std::string &name) :
26 0 : AliGenerator(),
27 0 : fHeader(nullptr),
28 0 : fNProduced(0),
29 0 : fEventWeight(1.),
30 0 : fEventVertex(3)
31 0 : {
32 0 : SetName(name.c_str());
33 0 : }
34 :
35 0 : AliGenToy::~AliGenToy()
36 0 : {
37 :
38 0 : }
39 :
40 : void AliGenToy::Init()
41 : {
42 :
43 0 : }
44 :
45 : void AliGenToy::Generate()
46 : {
47 : // prepare event header
48 0 : delete fHeader;
49 0 : fHeader = new AliGenToyEventHeader(GetName());
50 :
51 0 : fNProduced = 0;
52 0 : fEventWeight = 1.;
53 0 : fEventVertex.Reset();
54 :
55 : // run user generate
56 0 : UserGenerate();
57 :
58 : // finalize and add header
59 0 : fHeader->SetNProduced(fNProduced);
60 0 : fHeader->SetEventWeight(fEventWeight);
61 0 : fHeader->SetPrimaryVertex(fEventVertex);
62 :
63 0 : if (fContainer)
64 0 : fContainer->AddHeader(fHeader);
65 : else
66 0 : gAlice->SetGenEventHeader(fHeader);
67 0 : }
68 :
69 : void AliGenToy::SetCentrality(Double_t cent)
70 : {
71 0 : fHeader->SetCentrality(cent);
72 0 : }
73 :
74 : Int_t AliGenToy::AddParticle(const AliVParticle &part)
75 : {
76 : const Int_t done = 0;
77 : const Int_t parent = 0;
78 : const TMCProcess mech = kPPrimary;
79 : const Float_t weight = 1.;
80 : const Int_t is = 0;
81 :
82 0 : Int_t ntr;
83 :
84 0 : PushTrack(done, parent, part.PdgCode(),
85 0 : part.Px(), part.Py(), part.Pz(), part.E(),
86 : 0., 0., 0., 0.,
87 : 0., 0., 0.,
88 : mech, ntr, weight, is);
89 0 : ++fNProduced;
90 :
91 0 : return ntr;
92 0 : }
93 :
94 : Int_t AliGenToy::AddParticle(const TLorentzVector &part)
95 : {
96 : const Int_t done = 0;
97 : const Int_t parent = 0;
98 : const Int_t pdg = 0;
99 : const TMCProcess mech = kPPrimary;
100 : const Float_t weight = 1.;
101 : const Int_t is = 0;
102 :
103 0 : Int_t ntr;
104 :
105 0 : PushTrack(done, parent, pdg,
106 0 : part.Px(), part.Py(), part.Pz(), part.E(),
107 : 0., 0., 0., 0.,
108 : 0., 0., 0.,
109 : mech, ntr, weight, is);
110 0 : ++fNProduced;
111 :
112 0 : return ntr;
113 0 : }
114 :
115 : Int_t AliGenToy::AddParticle(Double_t px, Double_t py, Double_t pz, Int_t pdg)
116 : {
117 : const Int_t done = 0;
118 : const Int_t parent = 0;
119 : const TMCProcess mech = kPPrimary;
120 : const Float_t weight = 1.;
121 : const Int_t is = 0;
122 :
123 0 : const TParticlePDG *partPDG = TDatabasePDG::Instance()->GetParticle(pdg);
124 0 : const Float_t m = partPDG ? partPDG->Mass() : 0.;
125 0 : const Float_t e = TMath::Sqrt(px*px + py*py + pz*pz + m*m);
126 :
127 0 : Int_t ntr;
128 :
129 0 : PushTrack(done, parent, pdg,
130 0 : px, py, pz, e,
131 : 0., 0., 0., 0.,
132 : 0., 0., 0.,
133 : mech, ntr, weight, is);
134 0 : ++fNProduced;
135 :
136 0 : return ntr;
137 0 : }
|