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