some warnings removed
[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
803d1ab0 16/* $Id$ */
4c039060 17
675e9664 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
116cbefd 24#include <stdlib.h>
c5970876 25
1578254f 26#include <TDatabasePDG.h>
116cbefd 27#include <TPDGCode.h>
28
29#include "AliGenHalo.h"
30#include "AliRun.h"
f87cfe57 31
fe4da5cc 32 ClassImp(AliGenHalo)
33 AliGenHalo::AliGenHalo()
34 :AliGenerator(-1)
35{
f87cfe57 36// Constructor
fe4da5cc 37 fName="Halo";
38 fTitle="Halo from LHC Tunnel";
fe4da5cc 39//
40// Read all particles
41 fNpart=-1;
42 fp=0;
43}
44
45AliGenHalo::AliGenHalo(Int_t npart)
46 :AliGenerator(npart)
47{
f87cfe57 48// Constructor
fe4da5cc 49 fName="Halo";
50 fTitle="Halo from LHC Tunnel";
fe4da5cc 51//
52// Read all particles
53 fNpart=-1;
54 fp=0;
55}
56
f87cfe57 57AliGenHalo::AliGenHalo(const AliGenHalo & Halo)
58{
59// copy constructor
60}
61
62
fe4da5cc 63//____________________________________________________________
64AliGenHalo::~AliGenHalo()
65{
f87cfe57 66// Destructor
fe4da5cc 67}
68
69//____________________________________________________________
70void AliGenHalo::Init()
f87cfe57 71{
72// Initialisation
73}
fe4da5cc 74
75//____________________________________________________________
76void AliGenHalo::Generate()
77{
f87cfe57 78// Generate from input file
fe4da5cc 79 FILE *fp = fopen(fFileName,"r");
80 if (fp) {
bd1cece1 81 printf("\n File %s opened for reading ! \n ", (char*) &fFileName);
fe4da5cc 82 } else {
bd1cece1 83 printf("\n Opening of file %s failed ! \n ", (char*) &fFileName);
fe4da5cc 84 }
85//
86// MARS particle codes
f87cfe57 87 const Int_t kmars[12]={0,kProton,kNeutron,kPiPlus,kPiMinus,kKPlus,kKMinus,
1578254f 88 kMuonPlus,kMuonMinus,kGamma,kElectron,kPositron};
fe4da5cc 89
90 Float_t polar[3]= {0,0,0};
91 Float_t origin[3];
92 Float_t p[3], p0;
93 Float_t ekin, wgt, tx, ty, tz, txy;
1578254f 94 Float_t amass;
fe4da5cc 95 //
1578254f 96 Int_t ipart, ncols, nt;
fe4da5cc 97
98 Int_t nread=0;
99 origin[2]=2650;
100
101 while(1) {
102 ncols = fscanf(fp,"%i %f %f %f %f %f %f",
103 &ipart, &ekin, &wgt,
104 &origin[0], &origin[1],
105 &tx, &ty);
106 if (ncols < 0) break;
107 nread++;
108 if (fNpart !=-1 && nread > fNpart) break;
f87cfe57 109 ipart = kmars[ipart];
1578254f 110 amass = TDatabasePDG::Instance()->GetParticle(ipart)->Mass();
fe4da5cc 111 p0=sqrt(ekin*ekin + 2.*amass);
112
113 txy=TMath::Sqrt(tx*tx+ty*ty);
114 if (txy == 1.) {
115 tz=0;
116 } else {
117 tz=-TMath::Sqrt(1.-txy);
118 }
119 p[0]=p0*tx;
120 p[1]=p0*ty;
121 p[2]=p0*tz;
122 fParentWeight=wgt;
642f15cf 123 PushTrack(fTrackIt,-1,ipart,p,origin,polar,0,kPNoProcess,nt,fParentWeight);
124// PushTrack(fTrackIt,-1,ipart,p,origin,polar,0,"Halo+",nt,fParentWeight);
fe4da5cc 125 origin[2]=-origin[2];
126 p[2]=-p[2];
642f15cf 127 PushTrack(fTrackIt,-1,ipart,p,origin,polar,0,kPNoProcess,nt,fParentWeight);
128// PushTrack(fTrackIt,-1,ipart,p,origin,polar,0,"Halo-",nt,fParentWeight);
fe4da5cc 129 origin[2]=-origin[2];
130 p[2]=-p[2];
131 }
132}
133
134
f87cfe57 135AliGenHalo& AliGenHalo::operator=(const AliGenHalo& rhs)
136{
137// Assignment operator
138 return *this;
139}
140
fe4da5cc 141
142
143
144
145
146
147