]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVGEN/AliGenHalo.cxx
Working prints removed
[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 /* $Id$ */
17
18 // Read background particles from a boundary source
19 // Very specialized generator to simulate background from beam halo.
20 // The input file is a text file specially prepared 
21 // for this purpose.
22 // Author: andreas.morsch@cern.ch
23
24 #include <stdlib.h>
25
26 #include <TDatabasePDG.h>
27 #include <TPDGCode.h>
28
29 #include "AliGenHalo.h"
30 #include "AliRun.h"
31
32 ClassImp(AliGenHalo)
33
34 AliGenHalo::AliGenHalo()
35     :AliGenerator(-1),
36      fp(0),
37      fFileName(0)
38 {
39 // Constructor
40     fName="Halo";
41     fTitle="Halo from LHC Tunnel";
42 //
43 //  Read all particles
44     fNpart=-1;
45 }
46
47 AliGenHalo::AliGenHalo(Int_t npart)
48     :AliGenerator(npart),
49      fp(0),
50      fFileName(0)
51 {
52 // Constructor
53     fName="Halo";
54     fTitle="Halo from LHC Tunnel";
55 //
56 //  Read all particles
57     fNpart=-1;
58 }
59
60 AliGenHalo::AliGenHalo(const AliGenHalo & Halo)
61     :AliGenerator(Halo),
62      fp(0),
63      fFileName(0)
64 {
65 // Copy constructor
66     Halo.Copy(*this);
67 }
68
69
70 //____________________________________________________________
71 AliGenHalo::~AliGenHalo()
72 {
73 // Destructor
74 }
75
76 //____________________________________________________________
77 void AliGenHalo::Init() 
78 {
79 // Initialisation
80 }
81
82 //____________________________________________________________
83 void AliGenHalo::Generate()
84 {
85 // Generate from input file
86     fp = fopen(fFileName,"r");
87     if (fp) {
88         printf("\n File %s opened for reading ! \n ", (char*) &fFileName);
89     } else {
90         printf("\n Opening of file %s failed ! \n ",  (char*) &fFileName);
91     }
92 //
93 // MARS particle codes
94   const Int_t kmars[12]={0,kProton,kNeutron,kPiPlus,kPiMinus,kKPlus,kKMinus,
95                          kMuonPlus,kMuonMinus,kGamma,kElectron,kPositron};
96  
97   Float_t polar[3]= {0,0,0};
98   Float_t origin[3];
99   Float_t p[3], p0;
100   Float_t ekin, wgt, tx, ty, tz, txy;
101   Float_t amass;
102   //
103   Int_t ipart, ncols, nt;
104   
105   Int_t nread=0;
106   origin[2]=2650;
107   
108   while(1) {
109       ncols = fscanf(fp,"%i %f %f %f %f %f %f",
110                      &ipart, &ekin, &wgt, 
111                      &origin[0], &origin[1],
112                      &tx, &ty);
113       if (ncols < 0) break;
114       nread++;
115       if (fNpart !=-1 && nread > fNpart) break;
116       ipart = kmars[ipart];
117       amass = TDatabasePDG::Instance()->GetParticle(ipart)->Mass();
118       p0=sqrt(ekin*ekin + 2.*amass);
119       
120       txy=TMath::Sqrt(tx*tx+ty*ty);
121       if (txy == 1.) {
122           tz=0;
123       } else {
124           tz=-TMath::Sqrt(1.-txy);
125       }
126       p[0]=p0*tx;
127       p[1]=p0*ty;
128       p[2]=p0*tz;
129       fParentWeight=wgt;
130       PushTrack(fTrackIt,-1,ipart,p,origin,polar,0,kPNoProcess,nt,fParentWeight);
131 //    PushTrack(fTrackIt,-1,ipart,p,origin,polar,0,"Halo+",nt,fParentWeight);
132       origin[2]=-origin[2];
133       p[2]=-p[2];
134       PushTrack(fTrackIt,-1,ipart,p,origin,polar,0,kPNoProcess,nt,fParentWeight);
135 //    PushTrack(fTrackIt,-1,ipart,p,origin,polar,0,"Halo-",nt,fParentWeight);
136       origin[2]=-origin[2];
137       p[2]=-p[2];
138   }
139 }
140  
141
142 AliGenHalo& AliGenHalo::operator=(const  AliGenHalo& rhs)
143 {
144 // Assignment operator
145     rhs.Copy(*this);
146     return *this;
147 }
148
149
150 void AliGenHalo::Copy(TObject&) const
151 {
152     //
153     // Copy 
154   //
155     Fatal("Copy","Not implemented!\n");
156 }
157
158
159
160
161
162
163
164