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