]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TFluka/source_halo.cxx
Compiler Warning removed
[u/mrichter/AliRoot.git] / TFluka / source_halo.cxx
1 #define METHODDEBUG
2
3 // Fortran 
4 #include "TCallf77.h"
5
6 // Fluka commons
7 #include "Fdblprc.h"  //(DBLPRC) fluka common
8 #include "Fdimpar.h"  //(DIMPAR) fluka parameters
9 #include "Fepisor.h"  //(EPISOR) fluka common
10 #include "Fstack.h"   //(STACK)  fluka common
11 #include "Fstars.h"   //(STARS)  fluka common
12 #include "Fbeam.h"    //(BEAM)   fluka common
13 #include "Fpaprop.h"  //(PAPROP) fluka common
14 #include "Fltclcm.h"  //(LTCLCM) fluka common
15 #include "Fpart.h"  
16 //#include "Fcaslim.h"  //(CASLIM) fluka common
17
18 //Virutal MC
19 #include "AliGenerator.h"
20 #include "AliStack.h"
21 #include "../EVGEN/AliGenHaloProtvino.h"
22
23 #include "TVirtualMCStack.h"
24 #include "TParticle.h"
25 #include "TVector3.h"
26 #include "TRandom.h"
27
28 //Other
29 #include <Riostream.h>
30
31 #ifndef WIN32
32 # define source source_
33 # define geocrs geocrs_
34 # define georeg georeg_
35 # define geohsm geohsm_
36 # define soevsv soevsv_
37 # define mcihad mcihad_
38 # define source_halo source_halo__
39 #else
40 # define source SOURCE
41 # define geocrs GEOCRS
42 # define georeg GEOREG
43 # define geohsm GEOHSM
44 # define soevsv SOEVSV
45 # define mcihad MCIHAD
46 # define source_halo SOURCE_HALO
47 #endif
48
49 extern "C" {
50   //
51   // Prototypes for FLUKA functions
52   //
53   void type_of_call geocrs(Double_t &, Double_t &, Double_t &);
54   void type_of_call georeg(Double_t &, Double_t &, Double_t &, 
55                            Int_t &, Int_t &);
56   void type_of_call geohsm(Int_t &, Int_t &, Int_t &, Int_t &);
57   void type_of_call soevsv();
58   int  type_of_call mcihad(const int&);
59  /*
60    *----------------------------------------------------------------------*
61    *                                                                      *
62    *     Created on 07 january 1990   by    Alfredo Ferrari & Paola Sala  *
63    *                                                   Infn - Milan       *
64    *                                                                      *
65    *     Last change on 21-jun-98     by    Alfredo Ferrari               *
66    *                                                                      *
67    *     C++ version on 27-sep-02     by    Isidro Gonzalez               *
68    *                                                                      *
69    *  This is just an example of a possible user written source routine.  *
70    *  note that the beam card still has some meaning - in the scoring the *
71    *  maximum momentum used in deciding the binning is taken from the     *
72    *  beam momentum.  Other beam card parameters are obsolete.            *
73    *                                                                      *
74    *----------------------------------------------------------------------*/
75
76   void source_halo(Int_t& nomore) {
77
78       static Bool_t lfirst               = true;
79       static AliGenHaloProtvino* gener   = 0;
80       static AliStack* stack             = 0;   
81
82       nomore = 0;
83       TParticle* particle;
84       Int_t itrack = -1;
85       if (lfirst) {
86           EPISOR.tkesum = zerzer;
87           lfirst = false;
88           EPISOR.lussrc = true;
89 //
90 // The generator
91 //
92           gener  = new AliGenHaloProtvino(10);
93           gener->SetFileName("/home/morsch/AliRoot/newio/data/ir.2.ring.one.b.10.m");
94           gener->SetSide(2);
95           gener->SetRunPeriod();
96           
97           
98 // The particle stack
99           stack = new AliStack(1000);
100           gener->SetStack(stack);
101           gener->Init();
102
103       } else {
104           //
105           // Generate event
106           stack->Reset();
107           gener->Generate();
108           Int_t npart = stack->GetNprimary();
109           for (Int_t part = 1; part < npart; part += 2) {
110               particle = stack->Particle(part);
111               STACK.lstack++;
112               Int_t pdg = particle->GetPdgCode();
113               Int_t intfluka = mcihad(pdg);
114               Int_t ifl = GetFlukaKPTOIP(intfluka);
115               Float_t wgt = particle->GetWeight();
116               
117               printf("Particle %5d %10s %10.3f %10.3f %10.3f %10.3f\n", 
118                      STACK.lstack, 
119                      particle->GetName(), 
120                      particle->Px(), particle->Py(), particle->Pz(), wgt);
121               
122
123               
124               /* Wt is the weight of the particle*/
125               STACK.wt[STACK.lstack] = wgt;
126               STARS.weipri += STACK.wt[STACK.lstack];
127               
128               STACK.ilo[STACK.lstack] = ifl;
129               /* From this point .....
130                * Particle generation (1 for primaries)
131                */
132               STACK.lo[STACK.lstack] = 1;
133               
134               /* User dependent flag:*/
135               STACK.louse[STACK.lstack] = 0;
136               
137               /* User dependent spare variables:*/
138               Int_t ispr = 0;
139               for (ispr = 0; ispr < mkbmx1; ispr++)
140                   STACK.sparek[STACK.lstack][ispr] = zerzer;
141               
142               /* User dependent spare flags:*/
143               for (ispr = 0; ispr < mkbmx2; ispr++)
144                   STACK.ispark[STACK.lstack][ispr] = 0;
145               
146               /* Save the track number of the stack particle:*/
147               STACK.ispark[STACK.lstack][mkbmx2-1] = itrack;
148               STACK.nparma++;
149               STACK.numpar[STACK.lstack] = STACK.nparma;
150               STACK.nevent[STACK.lstack] = 0;
151               STACK.dfnear[STACK.lstack] = +zerzer;
152               
153               /* Particle age (s)*/
154               STACK.agestk[STACK.lstack] = +zerzer;
155               STACK.aknshr[STACK.lstack] = -twotwo;
156               
157               /* Group number for "low" energy neutrons, set to 0 anyway*/
158               STACK.igroup[STACK.lstack] = 0;
159               
160               /* Kinetic energy */
161               STACK.tke[STACK.lstack] = particle->Energy() - particle->GetMass();
162               
163               
164               /* Particle momentum*/
165               STACK.pmom [STACK.lstack] = particle->P();
166               
167               /* Cosines (tx,ty,tz)*/
168               Double_t cosx = particle->Px()/particle->P();
169               Double_t cosy = particle->Py()/particle->P();
170               Double_t cosz = TMath::Sqrt(oneone - cosx*cosx - cosy*cosy);
171               if (particle->Pz() < 0.)   cosz = -cosz;
172               
173               STACK.tx [STACK.lstack] =   cosx;
174               STACK.ty [STACK.lstack] =   cosy;
175               STACK.tz [STACK.lstack] =   cosz;
176               
177               /* Polarization cosines:*/
178               
179               STACK.txpol [STACK.lstack] = -twotwo;
180               STACK.typol [STACK.lstack] = +zerzer;
181               STACK.tzpol [STACK.lstack] = +zerzer;
182               
183               /* Particle coordinates*/
184               STACK.xa [STACK.lstack] =   particle->Vx();
185               STACK.ya [STACK.lstack] =   particle->Vy();
186               STACK.za [STACK.lstack] =   particle->Vz();
187               
188               
189               
190               /*  Calculate the total kinetic energy of the primaries: don't change*/
191               Int_t st_ilo =  STACK.ilo[STACK.lstack];
192               if ( st_ilo != 0 )
193                   EPISOR.tkesum += 
194                       ((STACK.tke[STACK.lstack] + PAPROP.amdisc[st_ilo+6])
195                        * STACK.wt[STACK.lstack]);
196               else
197                   EPISOR.tkesum += (STACK.tke[STACK.lstack] * STACK.wt[STACK.lstack]);
198               
199               /*  Here we ask for the region number of the hitting point.
200                *     NREG (LSTACK) = ...
201                *  The following line makes the starting region search much more
202                *  robust if particles are starting very close to a boundary:
203                */
204               geocrs( STACK.tx[STACK.lstack], 
205                       STACK.ty[STACK.lstack], 
206                       STACK.tz[STACK.lstack] );
207
208               
209               Int_t idisc;
210               
211               georeg ( STACK.xa[STACK.lstack], 
212                        STACK.ya[STACK.lstack], 
213                        STACK.za[STACK.lstack],
214                        STACK.nreg[STACK.lstack], 
215                        idisc);//<-- dummy return variable not used
216               printf("Particle Vertex %10.3f %10.3f %10.3f %5d\n",  
217                      STACK.xa [STACK.lstack],  STACK.ya [STACK.lstack],  STACK.za [STACK.lstack], 
218                      STACK.nreg[STACK.lstack]);
219               
220
221               /*  Do not change these cards:*/
222               Int_t igeohsm1 = 1;
223               Int_t igeohsm2 = -11;
224               geohsm ( STACK.nhspnt[STACK.lstack], igeohsm1, igeohsm2, LTCLCM.mlattc );
225               STACK.nlattc[STACK.lstack] = LTCLCM.mlattc;
226               soevsv();
227           }
228       }
229   }
230 }
231
232