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