]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVGEN/AliGenBeamGas.cxx
Code causing warning messages corrected.
[u/mrichter/AliRoot.git] / EVGEN / AliGenBeamGas.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 // Generator to simulate beam gas interactions.
20 // At present single interactions are read from an external file. 
21 // Several interactions are combined in one event.
22
23
24 #include "AliGenBeamGas.h"
25 #include "AliRun.h"
26
27 #include <TParticle.h>
28 #include <TFile.h>
29 #include <TTree.h>
30
31
32 ClassImp(AliGenBeamGas)
33
34 AliGenBeamGas::AliGenBeamGas()
35     :AliGenExtFile()
36 {
37 //  Constructor
38 //
39     fInteractions = 1;
40     fOsigma[0] =    0.;
41     fOsigma[1] =    0.;
42     fOsigma[2] = 2000.;
43 }
44
45 AliGenBeamGas::AliGenBeamGas(const AliGenBeamGas & beamgas):
46     AliGenExtFile(beamgas)
47 {
48 // Copy constructor
49     beamgas.Copy(*this);
50 }
51 //____________________________________________________________
52
53 AliGenBeamGas::~AliGenBeamGas()
54 {
55 // Destructor
56     delete fReader;
57 }
58
59 //___________________________________________________________
60 void AliGenBeamGas::Init()
61 {
62 // Initialize
63     AliGenExtFile::Init();
64 }
65
66     
67 void AliGenBeamGas::Generate()
68 {
69 // Generate particles
70
71   Float_t polar[3]  = {0,0,0};
72   Float_t origin[3] = {0,0,0};
73   Float_t p[3];
74   Float_t random[2];
75   Int_t i, nt;
76   Int_t nInt = 0;
77   
78   while(nInt < fInteractions) {
79 //
80       Rndm(random,2);
81 //
82 //  Interaction vertex
83 //
84       origin[2] = 2. * fOsigma[2] * random[0] - fOsigma[2];
85 //
86 //    beam 1 or 2
87 //      
88       Float_t ibeam = (random[1] < 0.5) ? -1. : 1.;
89       
90 //
91 //    Read next event
92 //      
93       Int_t nTracks = fReader->NextEvent();     
94       if (nTracks == 0) {
95           // printf("\n No more events !!! !\n");
96           Warning("AliGenBeamGas::Generate",
97                   "\nNo more events in external file!!!\n Last event may be empty or incomplete.\n");
98           return;
99       }
100       
101       //
102       // Stack filling loop
103       //
104       for (i = 0; i < nTracks; i++) {
105           TParticle* iparticle = fReader->NextParticle();
106           p[0] = iparticle->Px();
107           p[1] = iparticle->Py();
108           p[2] = iparticle->Pz() * ibeam;
109         
110           Int_t idpart     = iparticle->GetPdgCode();
111           Int_t decayed    = iparticle->GetFirstDaughter();
112           Int_t doTracking = fTrackIt && (decayed < 0) && (TMath::Abs(idpart) > 10);
113           PushTrack(doTracking,-1,idpart,p,origin,polar,0,kPPrimary,nt);
114           KeepTrack(nt);
115       } // track loop
116       nInt++;
117   } // event loop
118 //
119   SetHighWaterMark(nt);
120 //
121   CdEventFile();
122 }
123
124
125
126 void AliGenBeamGas::Copy(AliGenBeamGas&) const
127 {
128     //
129     // Copy 
130     //
131     Fatal("Copy","Not implemented!\n");
132 }
133
134
135
136
137
138