]>
Commit | Line | Data |
---|---|---|
4c039060 | 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$ | |
675e9664 | 18 | Revision 1.9 2000/11/30 07:12:50 alibrary |
19 | Introducing new Rndm and QA classes | |
20 | ||
65fb704d | 21 | Revision 1.8 2000/10/02 15:20:40 morsch |
22 | Direct reference to default input file removed. | |
23 | ||
3459d6b6 | 24 | Revision 1.7 2000/06/30 12:19:07 morsch |
25 | Type of fFileName changed to TString, fp has been !-ed. | |
26 | ||
bd1cece1 | 27 | Revision 1.6 2000/06/09 20:36:01 morsch |
28 | All coding rule violations except RS3 corrected | |
29 | ||
f87cfe57 | 30 | Revision 1.5 1999/11/03 17:43:20 fca |
31 | New version from G.Martinez & A.Morsch | |
32 | ||
886b6f73 | 33 | Revision 1.4 1999/09/29 09:24:14 fca |
34 | Introduction of the Copyright and cvs Log | |
35 | ||
4c039060 | 36 | */ |
37 | ||
675e9664 | 38 | // Read background particles from a boundary source |
39 | // Very specialized generator to simulate background from beam halo. | |
40 | // The input file is a text file specially prepared | |
41 | // for this purpose. | |
42 | // Author: andreas.morsch@cern.ch | |
43 | ||
fe4da5cc | 44 | #include "AliGenHalo.h" |
fe4da5cc | 45 | #include "AliRun.h" |
c5970876 | 46 | #include "AliPDG.h" |
47 | ||
1578254f | 48 | #include <TDatabasePDG.h> |
fe4da5cc | 49 | #include <stdlib.h> |
f87cfe57 | 50 | |
fe4da5cc | 51 | ClassImp(AliGenHalo) |
52 | AliGenHalo::AliGenHalo() | |
53 | :AliGenerator(-1) | |
54 | { | |
f87cfe57 | 55 | // Constructor |
fe4da5cc | 56 | fName="Halo"; |
57 | fTitle="Halo from LHC Tunnel"; | |
fe4da5cc | 58 | // |
59 | // Read all particles | |
60 | fNpart=-1; | |
61 | fp=0; | |
62 | } | |
63 | ||
64 | AliGenHalo::AliGenHalo(Int_t npart) | |
65 | :AliGenerator(npart) | |
66 | { | |
f87cfe57 | 67 | // Constructor |
fe4da5cc | 68 | fName="Halo"; |
69 | fTitle="Halo from LHC Tunnel"; | |
fe4da5cc | 70 | // |
71 | // Read all particles | |
72 | fNpart=-1; | |
73 | fp=0; | |
74 | } | |
75 | ||
f87cfe57 | 76 | AliGenHalo::AliGenHalo(const AliGenHalo & Halo) |
77 | { | |
78 | // copy constructor | |
79 | } | |
80 | ||
81 | ||
fe4da5cc | 82 | //____________________________________________________________ |
83 | AliGenHalo::~AliGenHalo() | |
84 | { | |
f87cfe57 | 85 | // Destructor |
fe4da5cc | 86 | } |
87 | ||
88 | //____________________________________________________________ | |
89 | void AliGenHalo::Init() | |
f87cfe57 | 90 | { |
91 | // Initialisation | |
92 | } | |
fe4da5cc | 93 | |
94 | //____________________________________________________________ | |
95 | void AliGenHalo::Generate() | |
96 | { | |
f87cfe57 | 97 | // Generate from input file |
fe4da5cc | 98 | FILE *fp = fopen(fFileName,"r"); |
99 | if (fp) { | |
bd1cece1 | 100 | printf("\n File %s opened for reading ! \n ", (char*) &fFileName); |
fe4da5cc | 101 | } else { |
bd1cece1 | 102 | printf("\n Opening of file %s failed ! \n ", (char*) &fFileName); |
fe4da5cc | 103 | } |
104 | // | |
105 | // MARS particle codes | |
f87cfe57 | 106 | const Int_t kmars[12]={0,kProton,kNeutron,kPiPlus,kPiMinus,kKPlus,kKMinus, |
1578254f | 107 | kMuonPlus,kMuonMinus,kGamma,kElectron,kPositron}; |
fe4da5cc | 108 | |
109 | Float_t polar[3]= {0,0,0}; | |
110 | Float_t origin[3]; | |
111 | Float_t p[3], p0; | |
112 | Float_t ekin, wgt, tx, ty, tz, txy; | |
1578254f | 113 | Float_t amass; |
fe4da5cc | 114 | // |
1578254f | 115 | Int_t ipart, ncols, nt; |
fe4da5cc | 116 | |
117 | Int_t nread=0; | |
118 | origin[2]=2650; | |
119 | ||
120 | while(1) { | |
121 | ncols = fscanf(fp,"%i %f %f %f %f %f %f", | |
122 | &ipart, &ekin, &wgt, | |
123 | &origin[0], &origin[1], | |
124 | &tx, &ty); | |
125 | if (ncols < 0) break; | |
126 | nread++; | |
127 | if (fNpart !=-1 && nread > fNpart) break; | |
f87cfe57 | 128 | ipart = kmars[ipart]; |
1578254f | 129 | amass = TDatabasePDG::Instance()->GetParticle(ipart)->Mass(); |
fe4da5cc | 130 | p0=sqrt(ekin*ekin + 2.*amass); |
131 | ||
132 | txy=TMath::Sqrt(tx*tx+ty*ty); | |
133 | if (txy == 1.) { | |
134 | tz=0; | |
135 | } else { | |
136 | tz=-TMath::Sqrt(1.-txy); | |
137 | } | |
138 | p[0]=p0*tx; | |
139 | p[1]=p0*ty; | |
140 | p[2]=p0*tz; | |
141 | fParentWeight=wgt; | |
65fb704d | 142 | gAlice->SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,kPNoProcess,nt,fParentWeight); |
143 | // gAlice->SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,"Halo+",nt,fParentWeight); | |
fe4da5cc | 144 | origin[2]=-origin[2]; |
145 | p[2]=-p[2]; | |
65fb704d | 146 | gAlice->SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,kPNoProcess,nt,fParentWeight); |
147 | // gAlice->SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,"Halo-",nt,fParentWeight); | |
fe4da5cc | 148 | origin[2]=-origin[2]; |
149 | p[2]=-p[2]; | |
150 | } | |
151 | } | |
152 | ||
153 | ||
f87cfe57 | 154 | AliGenHalo& AliGenHalo::operator=(const AliGenHalo& rhs) |
155 | { | |
156 | // Assignment operator | |
157 | return *this; | |
158 | } | |
159 | ||
fe4da5cc | 160 | |
161 | ||
162 | ||
163 | ||
164 | ||
165 | ||
166 |