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