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