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