]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVGEN/AliGenHalo.cxx
Coding convention rules obeyed
[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$
3459d6b6 18Revision 1.7 2000/06/30 12:19:07 morsch
19Type of fFileName changed to TString, fp has been !-ed.
20
bd1cece1 21Revision 1.6 2000/06/09 20:36:01 morsch
22All coding rule violations except RS3 corrected
23
f87cfe57 24Revision 1.5 1999/11/03 17:43:20 fca
25New version from G.Martinez & A.Morsch
26
886b6f73 27Revision 1.4 1999/09/29 09:24:14 fca
28Introduction of the Copyright and cvs Log
29
4c039060 30*/
31
fe4da5cc 32#include "AliGenHalo.h"
fe4da5cc 33#include "AliRun.h"
c5970876 34#include "AliPDG.h"
35
1578254f 36#include <TDatabasePDG.h>
fe4da5cc 37#include <stdlib.h>
f87cfe57 38
fe4da5cc 39 ClassImp(AliGenHalo)
40 AliGenHalo::AliGenHalo()
41 :AliGenerator(-1)
42{
f87cfe57 43// Constructor
fe4da5cc 44 fName="Halo";
45 fTitle="Halo from LHC Tunnel";
fe4da5cc 46//
47// Read all particles
48 fNpart=-1;
49 fp=0;
50}
51
52AliGenHalo::AliGenHalo(Int_t npart)
53 :AliGenerator(npart)
54{
f87cfe57 55// Constructor
fe4da5cc 56 fName="Halo";
57 fTitle="Halo from LHC Tunnel";
fe4da5cc 58//
59// Read all particles
60 fNpart=-1;
61 fp=0;
62}
63
f87cfe57 64AliGenHalo::AliGenHalo(const AliGenHalo & Halo)
65{
66// copy constructor
67}
68
69
fe4da5cc 70//____________________________________________________________
71AliGenHalo::~AliGenHalo()
72{
f87cfe57 73// Destructor
fe4da5cc 74}
75
76//____________________________________________________________
77void AliGenHalo::Init()
f87cfe57 78{
79// Initialisation
80}
fe4da5cc 81
82//____________________________________________________________
83void AliGenHalo::Generate()
84{
f87cfe57 85// Generate from input file
fe4da5cc 86 FILE *fp = fopen(fFileName,"r");
87 if (fp) {
bd1cece1 88 printf("\n File %s opened for reading ! \n ", (char*) &fFileName);
fe4da5cc 89 } else {
bd1cece1 90 printf("\n Opening of file %s failed ! \n ", (char*) &fFileName);
fe4da5cc 91 }
92//
93// MARS particle codes
f87cfe57 94 const Int_t kmars[12]={0,kProton,kNeutron,kPiPlus,kPiMinus,kKPlus,kKMinus,
1578254f 95 kMuonPlus,kMuonMinus,kGamma,kElectron,kPositron};
fe4da5cc 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;
1578254f 101 Float_t amass;
fe4da5cc 102 //
1578254f 103 Int_t ipart, ncols, nt;
fe4da5cc 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;
f87cfe57 116 ipart = kmars[ipart];
1578254f 117 amass = TDatabasePDG::Instance()->GetParticle(ipart)->Mass();
fe4da5cc 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;
886b6f73 130 gAlice->SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,"Halo+",nt,fParentWeight);
fe4da5cc 131 origin[2]=-origin[2];
132 p[2]=-p[2];
886b6f73 133 gAlice->SetTrack(fTrackIt,-1,ipart,p,origin,polar,0,"Halo-",nt,fParentWeight);
fe4da5cc 134 origin[2]=-origin[2];
135 p[2]=-p[2];
136 }
137}
138
139
f87cfe57 140AliGenHalo& AliGenHalo::operator=(const AliGenHalo& rhs)
141{
142// Assignment operator
143 return *this;
144}
145
fe4da5cc 146
147
148
149
150
151
152