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