Introducing Header instead of Log
[u/mrichter/AliRoot.git] / EVGEN / AliGenHalo.cxx
CommitLineData
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$
a99cf51f 18Revision 1.10 2000/12/21 16:24:06 morsch
19Coding convention clean-up
20
675e9664 21Revision 1.9 2000/11/30 07:12:50 alibrary
22Introducing new Rndm and QA classes
23
65fb704d 24Revision 1.8 2000/10/02 15:20:40 morsch
25Direct reference to default input file removed.
26
3459d6b6 27Revision 1.7 2000/06/30 12:19:07 morsch
28Type of fFileName changed to TString, fp has been !-ed.
29
bd1cece1 30Revision 1.6 2000/06/09 20:36:01 morsch
31All coding rule violations except RS3 corrected
32
f87cfe57 33Revision 1.5 1999/11/03 17:43:20 fca
34New version from G.Martinez & A.Morsch
35
886b6f73 36Revision 1.4 1999/09/29 09:24:14 fca
37Introduction of the Copyright and cvs Log
38
4c039060 39*/
40
675e9664 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
fe4da5cc 47#include "AliGenHalo.h"
fe4da5cc 48#include "AliRun.h"
c5970876 49#include "AliPDG.h"
50
1578254f 51#include <TDatabasePDG.h>
fe4da5cc 52#include <stdlib.h>
f87cfe57 53
fe4da5cc 54 ClassImp(AliGenHalo)
55 AliGenHalo::AliGenHalo()
56 :AliGenerator(-1)
57{
f87cfe57 58// Constructor
fe4da5cc 59 fName="Halo";
60 fTitle="Halo from LHC Tunnel";
fe4da5cc 61//
62// Read all particles
63 fNpart=-1;
64 fp=0;
65}
66
67AliGenHalo::AliGenHalo(Int_t npart)
68 :AliGenerator(npart)
69{
f87cfe57 70// Constructor
fe4da5cc 71 fName="Halo";
72 fTitle="Halo from LHC Tunnel";
fe4da5cc 73//
74// Read all particles
75 fNpart=-1;
76 fp=0;
77}
78
f87cfe57 79AliGenHalo::AliGenHalo(const AliGenHalo & Halo)
80{
81// copy constructor
82}
83
84
fe4da5cc 85//____________________________________________________________
86AliGenHalo::~AliGenHalo()
87{
f87cfe57 88// Destructor
fe4da5cc 89}
90
91//____________________________________________________________
92void AliGenHalo::Init()
f87cfe57 93{
94// Initialisation
95}
fe4da5cc 96
97//____________________________________________________________
98void AliGenHalo::Generate()
99{
f87cfe57 100// Generate from input file
fe4da5cc 101 FILE *fp = fopen(fFileName,"r");
102 if (fp) {
bd1cece1 103 printf("\n File %s opened for reading ! \n ", (char*) &fFileName);
fe4da5cc 104 } else {
bd1cece1 105 printf("\n Opening of file %s failed ! \n ", (char*) &fFileName);
fe4da5cc 106 }
107//
108// MARS particle codes
f87cfe57 109 const Int_t kmars[12]={0,kProton,kNeutron,kPiPlus,kPiMinus,kKPlus,kKMinus,
1578254f 110 kMuonPlus,kMuonMinus,kGamma,kElectron,kPositron};
fe4da5cc 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;
1578254f 116 Float_t amass;
fe4da5cc 117 //
1578254f 118 Int_t ipart, ncols, nt;
fe4da5cc 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;
f87cfe57 131 ipart = kmars[ipart];
1578254f 132 amass = TDatabasePDG::Instance()->GetParticle(ipart)->Mass();
fe4da5cc 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;
a99cf51f 145 SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,kPNoProcess,nt,fParentWeight);
146// SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,"Halo+",nt,fParentWeight);
fe4da5cc 147 origin[2]=-origin[2];
148 p[2]=-p[2];
a99cf51f 149 SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,kPNoProcess,nt,fParentWeight);
150// SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,"Halo-",nt,fParentWeight);
fe4da5cc 151 origin[2]=-origin[2];
152 p[2]=-p[2];
153 }
154}
155
156
f87cfe57 157AliGenHalo& AliGenHalo::operator=(const AliGenHalo& rhs)
158{
159// Assignment operator
160 return *this;
161}
162
fe4da5cc 163
164
165
166
167
168
169