Update of simple generator
[u/mrichter/AliRoot.git] / TRD / AliTRDsimpleGen.cxx
CommitLineData
16bf9884 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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/*
ee7e3ede 17$Log$
18Revision 1.1 2001/11/06 17:19:41 cblume
19Add detailed geometry and simple simulator
20
16bf9884 21*/
22
23///////////////////////////////////////////////////////////////////////////////
24// //
25// Particle generator for the simplescopic TRD simulator //
26// //
27///////////////////////////////////////////////////////////////////////////////
28
29#include <stdlib.h>
30
31#include <TRandom.h>
ee7e3ede 32#include <TMCProcess.h>
33
34#include "AliRun.h"
16bf9884 35
36#include "AliTRDsimpleGen.h"
37#include "AliTRDsimpleMC.h"
38
39ClassImp(AliTRDsimpleGen)
40
41//_____________________________________________________________________________
42AliTRDsimpleGen::AliTRDsimpleGen():TObject()
43{
44 //
45 // AliTRDsimpleGen default constructor
46 //
47
48 fPdg = 211;
49 fMomMin = 1.0;
50 fMomMax = 1.0;
51
52}
53
54//_____________________________________________________________________________
55AliTRDsimpleGen::AliTRDsimpleGen(const AliTRDsimpleGen &g)
56{
57 //
58 // AliTRDsimpleGen copy constructor
59 //
60
61 ((AliTRDsimpleGen &) g).Copy(*this);
62
63}
64
65//_____________________________________________________________________________
66AliTRDsimpleGen::~AliTRDsimpleGen()
67{
68 //
69 // AliTRDsimpleGen destructor
70 //
71
72}
73
74//_____________________________________________________________________________
75AliTRDsimpleGen &AliTRDsimpleGen::operator=(const AliTRDsimpleGen &g)
76{
77 //
78 // Assignment operator
79 //
80
81 if (this != &g) ((AliTRDsimpleGen &) g).Copy(*this);
82 return *this;
83
84}
85
86//_____________________________________________________________________________
87void AliTRDsimpleGen::Copy(TObject &g)
88{
89 //
90 // Copy function
91 //
92
93 ((AliTRDsimpleGen &) g).fPdg = fPdg;
94 ((AliTRDsimpleGen &) g).fMomMin = fMomMin;
95 ((AliTRDsimpleGen &) g).fMomMax = fMomMax;
96
97}
98
99//_____________________________________________________________________________
100void AliTRDsimpleGen::NewParticle(Int_t ievent)
101{
102 //
103 // Generate a new particle and initialize the MC object
104 //
105
106 if (ievent == 0) {
107 printf("\n");
108 printf("<AliTRDsimpleGen> Generate particles with PDG code %d\n",fPdg);
109 if (fMomMax > fMomMin) {
110 printf("<AliTRDsimpleGen> Momentum range = %4.2f - %4.2f GeV/c\n"
111 ,fMomMin,fMomMax);
112 }
113 else {
114 printf("<AliTRDsimpleGen> Fixed momentum = %4.2f GeV/c\n"
115 ,fMomMax);
116 }
117 printf("\n");
ee7e3ede 118
119 // Add one dummy particle to the stack so that AddHit will work
120 Float_t mom[3] = { 0.0 };
121 Float_t vtx[3] = { 0.0 };
122 Float_t pol[3] = { 0.0 };
123 Int_t ntr = 0;
124 gAlice->SetTrack(0,-1,fPdg,mom,vtx,pol,0.0,kPPrimary,ntr);
125
16bf9884 126 }
127
128 Double_t p = fMomMax;
129 if (fMomMax > fMomMin) {
130 p = (fMomMax - fMomMin) * gRandom->Rndm() + fMomMin;
131 }
132
133 Double_t px = p;
134 Double_t py = 0.0;
135 Double_t pz = 0.0;
136
137 ((AliTRDsimpleMC *) gMC)->NewTrack(ievent,fPdg,px,py,pz);
138
139}