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