]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVGEN/AliGenHalo.cxx
Introduction of the Copyright and cvs Log
[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 */
19
20 #include "AliGenHalo.h"
21 #include "AliGenMUONlib.h"
22 #include "AliMC.h"
23 #include "AliRun.h"
24 #include "AliPDG.h"
25
26 #include <TDirectory.h>
27 #include <TDatabasePDG.h>
28 #include <TFile.h>
29 #include <TTree.h>
30 #include <stdlib.h>
31  ClassImp(AliGenHalo)
32      AliGenHalo::AliGenHalo()
33          :AliGenerator(-1)
34 {
35     fName="Halo";
36     fTitle="Halo from LHC Tunnel";
37     // Set the default file 
38     fFileName="~/marsip/marsip5.mu";
39 //
40 //  Read all particles
41     fNpart=-1;
42     fp=0;
43 }
44
45 AliGenHalo::AliGenHalo(Int_t npart)
46     :AliGenerator(npart)
47 {
48     fName="Halo";
49     fTitle="Halo from LHC Tunnel";
50     // Set the default file 
51     fFileName="~/marsip/marsip5.mu";
52 //
53 //  Read all particles
54     fNpart=-1;
55     fp=0;
56 }
57
58 //____________________________________________________________
59 AliGenHalo::~AliGenHalo()
60 {
61 }
62
63 //____________________________________________________________
64 void AliGenHalo::Init() 
65 {}
66
67 //____________________________________________________________
68 void AliGenHalo::Generate()
69 {
70     FILE *fp = fopen(fFileName,"r");
71     if (fp) {
72         printf("\n File %s opened for reading ! \n ", fFileName);
73     } else {
74         printf("\n Opening of file %s failed ! \n ", fFileName);
75     }
76 //
77 // MARS particle codes
78     // const Int_t imars[12]={0,14, 13, 8, 9, 11, 12, 5, 6, 1, 3, 2};
79   const Int_t imars[12]={0,kProton,kNeutron,kPiPlus,kPiMinus,kKPlus,kKMinus,
80                          kMuonPlus,kMuonMinus,kGamma,kElectron,kPositron};
81  
82   Float_t polar[3]= {0,0,0};
83   Float_t origin[3];
84   Float_t p[3], p0;
85   Float_t ekin, wgt, tx, ty, tz, txy;
86   Float_t amass;
87   //
88   Int_t ipart, ncols, nt;
89   
90   Int_t nread=0;
91   origin[2]=2650;
92   
93   while(1) {
94       ncols = fscanf(fp,"%i %f %f %f %f %f %f",
95                      &ipart, &ekin, &wgt, 
96                      &origin[0], &origin[1],
97                      &tx, &ty);
98       if (ncols < 0) break;
99       nread++;
100       if (fNpart !=-1 && nread > fNpart) break;
101       ipart = imars[ipart];
102       amass = TDatabasePDG::Instance()->GetParticle(ipart)->Mass();
103       p0=sqrt(ekin*ekin + 2.*amass);
104       
105       txy=TMath::Sqrt(tx*tx+ty*ty);
106       if (txy == 1.) {
107           tz=0;
108       } else {
109           tz=-TMath::Sqrt(1.-txy);
110       }
111       p[0]=p0*tx;
112       p[1]=p0*ty;
113       p[2]=p0*tz;
114       fParentWeight=wgt;
115       gAlice->SetTrack(1,-1,ipart,p,origin,polar,0,"Halo+",nt,fParentWeight);
116       origin[2]=-origin[2];
117       p[2]=-p[2];
118       gAlice->SetTrack(1,-1,ipart,p,origin,polar,0,"Halo-",nt,fParentWeight);
119       origin[2]=-origin[2];
120       p[2]=-p[2];
121   }
122 }
123  
124
125
126
127
128
129
130
131