Fluka user source routine using AliGenerator.
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 25 Nov 2003 15:31:05 +0000 (15:31 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 25 Nov 2003 15:31:05 +0000 (15:31 +0000)
TFluka/source_bg.cxx [new file with mode: 0644]
TFluka/source_f.cxx [new file with mode: 0644]
TFluka/source_ff.cxx [new file with mode: 0644]
TFluka/source_halo.cxx [new file with mode: 0644]
TFluka/source_pp.cxx [new file with mode: 0644]
TFluka/source_ray.cxx [new file with mode: 0644]

diff --git a/TFluka/source_bg.cxx b/TFluka/source_bg.cxx
new file mode 100644 (file)
index 0000000..b80fd60
--- /dev/null
@@ -0,0 +1,259 @@
+#define METHODDEBUG
+
+// Fortran 
+#include "TCallf77.h"
+
+// Fluka commons
+#include "Fdblprc.h"  //(DBLPRC) fluka common
+#include "Fdimpar.h"  //(DIMPAR) fluka parameters
+#include "Fepisor.h"  //(EPISOR) fluka common
+#include "Fstack.h"   //(STACK)  fluka common
+#include "Fstars.h"   //(STARS)  fluka common
+#include "Fbeam.h"    //(BEAM)   fluka common
+#include "Fpaprop.h"  //(PAPROP) fluka common
+#include "Fltclcm.h"  //(LTCLCM) fluka common
+#include "Fpart.h"  
+//#include "Fcaslim.h"  //(CASLIM) fluka common
+
+//Virutal MC
+#include "AliGenerator.h"
+#include "AliStack.h"
+#include "../THijing/AliGenHijing.h"
+
+#include "TVirtualMCStack.h"
+#include "TParticle.h"
+#include "TVector3.h"
+#include "TRandom.h"
+
+//Other
+#include <Riostream.h>
+
+#ifndef WIN32
+# define source source_
+# define geocrs geocrs_
+# define georeg georeg_
+# define geohsm geohsm_
+# define soevsv soevsv_
+# define mcihad mcihad_
+# define source_bg source_bg__
+#else
+# define source SOURCE
+# define geocrs GEOCRS
+# define georeg GEOREG
+# define geohsm GEOHSM
+# define soevsv SOEVSV
+# define mcihad MCIHAD
+# define source_bg SOURCE_BG
+#endif
+
+extern "C" {
+  //
+  // Prototypes for FLUKA functions
+  //
+  void type_of_call geocrs(Double_t &, Double_t &, Double_t &);
+  void type_of_call georeg(Double_t &, Double_t &, Double_t &, 
+                          Int_t &, Int_t &);
+  void type_of_call geohsm(Int_t &, Int_t &, Int_t &, Int_t &);
+  void type_of_call soevsv();
+  int  type_of_call mcihad(const int&);
+ /*
+   *----------------------------------------------------------------------*
+   *                                                                      *
+   *     Created on 07 january 1990   by    Alfredo Ferrari & Paola Sala  *
+   *                                                   Infn - Milan       *
+   *                                                                      *
+   *     Last change on 21-jun-98     by    Alfredo Ferrari               *
+   *                                                                      *
+   *     C++ version on 27-sep-02     by    Isidro Gonzalez               *
+   *                                                                      *
+   *  This is just an example of a possible user written source routine.  *
+   *  note that the beam card still has some meaning - in the scoring the *
+   *  maximum momentum used in deciding the binning is taken from the     *
+   *  beam momentum.  Other beam card parameters are obsolete.            *
+   *                                                                      *
+   *----------------------------------------------------------------------*/
+
+  void source_bg(Int_t& nomore) {
+
+      static Bool_t lfirst       = true;
+      static AliGenHijing* gener = 0;
+      static AliStack* stack     = 0;  
+
+      nomore = 0;
+      TParticle* particle;
+      Int_t itrack = -1;
+      if (lfirst) {
+         EPISOR.tkesum = zerzer;
+         lfirst = false;
+         EPISOR.lussrc = true;
+//
+// The generator
+//
+         gener  = new AliGenHijing(-1);
+// beam energy 
+         gener->SetEnergyCMS(7000.);
+// reference frame
+         gener->SetReferenceFrame("LAB");
+// projectile
+         gener->SetProjectile("P",  1,  1);
+         gener->SetTarget    ("A", 16,  8);
+// tell hijing to keep the full parent child chain
+         gener->KeepFullEvent();
+// enable jet quenching
+         gener->SetJetQuenching(0);
+// enable shadowing
+         gener->SetShadowing(0);
+// neutral pion and heavy particle decays switched off
+         gener->SetDecaysOff(1);
+// Don't track spectators
+         gener->SetSpectators(0);
+// The particle stack
+         stack = new AliStack(1000);
+         gener->SetStack(stack);
+         gener->Init();
+
+      } else {
+         //
+         // Generate event
+         stack->Reset();
+         gener->Generate();
+         Int_t npart = stack->GetNprimary();
+         // Vertex
+         Float_t za   =  4000. * gRandom->Rndm() - 2000.;
+         // Direction
+         Float_t dir  = (gRandom->Rndm() < 0.5) ? 1. : -1.;
+         
+         
+         for (Int_t part=0; part<npart; part++) {
+             particle = stack->Particle(part);
+             Int_t ic = particle->GetFirstDaughter();
+             if (ic != -1) continue;
+             Int_t pdg = particle->GetPdgCode();
+             Int_t intfluka = mcihad(pdg);
+             Int_t ifl = GetFlukaKPTOIP(intfluka);
+             TVector3 polarisation;
+             particle->GetPolarisation(polarisation);
+
+             STACK.lstack++;
+
+             printf("Particle %5d %5d %5d %10s %10.3f %10.3f %10.3f \n", STACK.lstack, pdg, ifl, 
+                    particle->GetName(), particle->Px(), particle->Py(), particle->Pz());
+             
+
+             
+             /* Wt is the weight of the particle*/
+             STACK.wt[STACK.lstack] = oneone;
+             STARS.weipri += STACK.wt[STACK.lstack];
+             
+             STACK.ilo[STACK.lstack] = ifl;
+             /* From this point .....
+              * Particle generation (1 for primaries)
+              */
+             STACK.lo[STACK.lstack] = 1;
+             
+             /* User dependent flag:*/
+             STACK.louse[STACK.lstack] = 0;
+             
+             /* User dependent spare variables:*/
+             Int_t ispr = 0;
+             for (ispr = 0; ispr < mkbmx1; ispr++)
+                 STACK.sparek[STACK.lstack][ispr] = zerzer;
+             
+             /* User dependent spare flags:*/
+             for (ispr = 0; ispr < mkbmx2; ispr++)
+                 STACK.ispark[STACK.lstack][ispr] = 0;
+             
+             /* Save the track number of the stack particle:*/
+             STACK.ispark[STACK.lstack][mkbmx2-1] = itrack;
+             STACK.nparma++;
+             STACK.numpar[STACK.lstack] = STACK.nparma;
+             STACK.nevent[STACK.lstack] = 0;
+             STACK.dfnear[STACK.lstack] = +zerzer;
+             
+             /* Particle age (s)*/
+             STACK.agestk[STACK.lstack] = +zerzer;
+             STACK.aknshr[STACK.lstack] = -twotwo;
+             
+             /* Group number for "low" energy neutrons, set to 0 anyway*/
+             STACK.igroup[STACK.lstack] = 0;
+             
+             /* Kinetic energy */
+             STACK.tke[STACK.lstack] = particle->Energy() - particle->GetMass();
+             
+             
+             /* Particle momentum*/
+             STACK.pmom [STACK.lstack] = particle->P();
+             
+             /* Cosines (tx,ty,tz)*/
+             Double_t cosx = particle->Px()/particle->P();
+             Double_t cosy = particle->Py()/particle->P();
+             Double_t cosz = TMath::Sqrt(oneone - cosx*cosx - cosy*cosy);
+             if (particle->Pz() < 0.)   cosz = -cosz;
+             cosz *= dir;
+             
+             STACK.tx [STACK.lstack] = cosx;
+             STACK.ty [STACK.lstack] = cosy;
+             STACK.tz [STACK.lstack] = cosz;
+             
+             /* Polarization cosines:*/
+             if (polarisation.Mag()) {
+                 Double_t cospolx = polarisation.Px()/polarisation.Mag();
+                 Double_t cospoly = polarisation.Py()/polarisation.Mag();
+                 Double_t cospolz = sqrt(oneone - cospolx*cospolx - cospoly*cospoly);
+                 STACK.tx [STACK.lstack] = cospolx;
+                 STACK.ty [STACK.lstack] = cospoly;
+                 STACK.tz [STACK.lstack] = cospolz;
+             }
+             else {
+                 STACK.txpol [STACK.lstack] = -twotwo;
+                 STACK.typol [STACK.lstack] = +zerzer;
+                 STACK.tzpol [STACK.lstack] = +zerzer;
+             }
+             
+             /* Particle coordinates*/
+             STACK.xa [STACK.lstack] = particle->Vx();
+             STACK.ya [STACK.lstack] = particle->Vy();
+             STACK.za [STACK.lstack] = za;
+             
+             printf("Particle Vertex %10.3f %10.3f %10.3f %10.3f \n",  
+                    STACK.xa [STACK.lstack],  STACK.ya [STACK.lstack],  STACK.za [STACK.lstack], dir);
+             
+             
+             
+             /*  Calculate the total kinetic energy of the primaries: don't change*/
+             Int_t st_ilo =  STACK.ilo[STACK.lstack];
+             if ( st_ilo != 0 )
+                 EPISOR.tkesum += 
+                     ((STACK.tke[STACK.lstack] + PAPROP.amdisc[st_ilo+6])
+                      * STACK.wt[STACK.lstack]);
+             else
+                 EPISOR.tkesum += (STACK.tke[STACK.lstack] * STACK.wt[STACK.lstack]);
+             
+             /*  Here we ask for the region number of the hitting point.
+              *     NREG (LSTACK) = ...
+              *  The following line makes the starting region search much more
+              *  robust if particles are starting very close to a boundary:
+              */
+             geocrs( STACK.tx[STACK.lstack], 
+                     STACK.ty[STACK.lstack], 
+                     STACK.tz[STACK.lstack] );
+             
+             Int_t idisc;
+             
+             georeg ( STACK.xa[STACK.lstack], 
+                      STACK.ya[STACK.lstack], 
+                      STACK.za[STACK.lstack],
+                      STACK.nreg[STACK.lstack], 
+                      idisc);//<-- dummy return variable not used
+             /*  Do not change these cards:*/
+             Int_t igeohsm1 = 1;
+             Int_t igeohsm2 = -11;
+             geohsm ( STACK.nhspnt[STACK.lstack], igeohsm1, igeohsm2, LTCLCM.mlattc );
+             STACK.nlattc[STACK.lstack] = LTCLCM.mlattc;
+             soevsv();
+         }
+      }
+  }
+}
+
+    
diff --git a/TFluka/source_f.cxx b/TFluka/source_f.cxx
new file mode 100644 (file)
index 0000000..d721541
--- /dev/null
@@ -0,0 +1,233 @@
+#define METHODDEBUG
+
+// Fortran 
+#include "TCallf77.h"
+
+// Fluka commons
+#include "Fdblprc.h"  //(DBLPRC) fluka common
+#include "Fdimpar.h"  //(DIMPAR) fluka parameters
+#include "Fepisor.h"  //(EPISOR) fluka common
+#include "Fstack.h"   //(STACK)  fluka common
+#include "Fstars.h"   //(STARS)  fluka common
+#include "Fbeam.h"    //(BEAM)   fluka common
+#include "Fpaprop.h"  //(PAPROP) fluka common
+#include "Fltclcm.h"  //(LTCLCM) fluka common
+#include "Fpart.h"  
+//#include "Fcaslim.h"  //(CASLIM) fluka common
+
+//Virutal MC
+#include "AliGenerator.h"
+#include "AliStack.h"
+#include "../PYTHIA6/AliGenPythia.h"
+
+#include "TVirtualMCStack.h"
+#include "TParticle.h"
+#include "TVector3.h"
+
+//Other
+#include <Riostream.h>
+
+#ifndef WIN32
+# define source source_
+# define geocrs geocrs_
+# define georeg georeg_
+# define geohsm geohsm_
+# define soevsv soevsv_
+# define mcihad mcihad_
+# define source_f source_f__
+#else
+# define source SOURCE
+# define geocrs GEOCRS
+# define georeg GEOREG
+# define geohsm GEOHSM
+# define soevsv SOEVSV
+# define mcihad MCIHAD
+# define source_f SOURCE_F
+#endif
+
+extern "C" {
+  //
+  // Prototypes for FLUKA functions
+  //
+  void type_of_call geocrs(Double_t &, Double_t &, Double_t &);
+  void type_of_call georeg(Double_t &, Double_t &, Double_t &, 
+                          Int_t &, Int_t &);
+  void type_of_call geohsm(Int_t &, Int_t &, Int_t &, Int_t &);
+  void type_of_call soevsv();
+  int  type_of_call mcihad(const int&);
+ /*
+   *----------------------------------------------------------------------*
+   *                                                                      *
+   *     Created on 07 january 1990   by    Alfredo Ferrari & Paola Sala  *
+   *                                                   Infn - Milan       *
+   *                                                                      *
+   *     Last change on 21-jun-98     by    Alfredo Ferrari               *
+   *                                                                      *
+   *     C++ version on 27-sep-02     by    Isidro Gonzalez               *
+   *                                                                      *
+   *  This is just an example of a possible user written source routine.  *
+   *  note that the beam card still has some meaning - in the scoring the *
+   *  maximum momentum used in deciding the binning is taken from the     *
+   *  beam momentum.  Other beam card parameters are obsolete.            *
+   *                                                                      *
+   *----------------------------------------------------------------------*/
+
+  void source_f(Int_t& nomore) {
+
+      static Bool_t lfirst       = true;
+      static AliGenPythia* gener = 0;
+      static AliStack* stack     = 0;  
+
+      nomore = 0;
+      TParticle* particle;
+      Int_t itrack = -1;
+      if (lfirst) {
+         printf("source_f first call \n");
+         EPISOR.tkesum = zerzer;
+         lfirst = false;
+         EPISOR.lussrc = true;
+         gener  = new AliGenPythia(1);
+         gener->SetEnergyCMS(14000.);
+         gener->SetProcess(kPyMb);
+         stack = new AliStack(1000);
+         gener->SetStack(stack);
+         gener->Init();
+
+      } else {
+         //
+         // Generate event
+         printf("Calling Generate() %p \n", gener);
+         stack->Reset();
+         gener->Generate();
+         Int_t npart = stack->GetNprimary();
+         printf("%d Particles on the stack \n", npart);
+         for (Int_t part=0; part<npart; part++) {
+             particle = stack->Particle(part);
+             Int_t st = particle->GetStatusCode();
+             if (st != 1) continue;
+             Int_t pdg = particle->GetPdgCode();
+             Int_t intfluka = mcihad(pdg);
+             Int_t ifl = GetFlukaKPTOIP(intfluka);
+             TVector3 polarisation;
+             particle->GetPolarisation(polarisation);
+
+             STACK.lstack++;
+
+             printf("Particle %5d %5d %5d %10s %10.3f %10.3f %10.3f \n", STACK.lstack, pdg, ifl, 
+                    particle->GetName(), particle->Px(), particle->Py(), particle->Pz());
+             
+
+             
+             /* Wt is the weight of the particle*/
+             STACK.wt[STACK.lstack] = oneone;
+             STARS.weipri += STACK.wt[STACK.lstack];
+             
+             STACK.ilo[STACK.lstack] = ifl;
+             /* From this point .....
+              * Particle generation (1 for primaries)
+              */
+             STACK.lo[STACK.lstack] = 1;
+             
+             /* User dependent flag:*/
+             STACK.louse[STACK.lstack] = 0;
+             
+             /* User dependent spare variables:*/
+             Int_t ispr = 0;
+             for (ispr = 0; ispr < mkbmx1; ispr++)
+                 STACK.sparek[STACK.lstack][ispr] = zerzer;
+             
+             /* User dependent spare flags:*/
+             for (ispr = 0; ispr < mkbmx2; ispr++)
+                 STACK.ispark[STACK.lstack][ispr] = 0;
+             
+             /* Save the track number of the stack particle:*/
+             STACK.ispark[STACK.lstack][mkbmx2-1] = itrack;
+             STACK.nparma++;
+             STACK.numpar[STACK.lstack] = STACK.nparma;
+             STACK.nevent[STACK.lstack] = 0;
+             STACK.dfnear[STACK.lstack] = +zerzer;
+             
+             /* Particle age (s)*/
+             STACK.agestk[STACK.lstack] = +zerzer;
+             STACK.aknshr[STACK.lstack] = -twotwo;
+             
+             /* Group number for "low" energy neutrons, set to 0 anyway*/
+             STACK.igroup[STACK.lstack] = 0;
+             
+             /* Kinetic energy */
+             STACK.tke[STACK.lstack] = particle->Energy() - particle->GetMass();
+             
+             
+             /* Particle momentum*/
+             STACK.pmom [STACK.lstack] = particle->P();
+             
+             /* Cosines (tx,ty,tz)*/
+             Double_t cosx = particle->Px()/particle->P();
+             Double_t cosy = particle->Py()/particle->P();
+             Double_t cosz = TMath::Sqrt(oneone - cosx*cosx - cosy*cosy);
+             if (particle->Pz() < 0.) cosz = -cosz;
+             STACK.tx [STACK.lstack] = cosx;
+             STACK.ty [STACK.lstack] = cosy;
+             STACK.tz [STACK.lstack] = cosz;
+             
+             /* Polarization cosines:*/
+             if (polarisation.Mag()) {
+                 Double_t cospolx = polarisation.Px()/polarisation.Mag();
+                 Double_t cospoly = polarisation.Py()/polarisation.Mag();
+                 Double_t cospolz = sqrt(oneone - cospolx*cospolx - cospoly*cospoly);
+                 STACK.tx [STACK.lstack] = cospolx;
+                 STACK.ty [STACK.lstack] = cospoly;
+                 STACK.tz [STACK.lstack] = cospolz;
+             }
+             else {
+                 STACK.txpol [STACK.lstack] = -twotwo;
+                 STACK.typol [STACK.lstack] = +zerzer;
+                 STACK.tzpol [STACK.lstack] = +zerzer;
+             }
+             
+             /* Particle coordinates*/
+             // Vertext coordinates;
+             STACK.xa [STACK.lstack] = particle->Vx();
+             STACK.ya [STACK.lstack] = particle->Vy();
+             STACK.za [STACK.lstack] = particle->Vz();
+             
+             /*  Calculate the total kinetic energy of the primaries: don't change*/
+             Int_t st_ilo =  STACK.ilo[STACK.lstack];
+             if ( st_ilo != 0 )
+                 EPISOR.tkesum += 
+                     ((STACK.tke[STACK.lstack] + PAPROP.amdisc[st_ilo+6])
+                      * STACK.wt[STACK.lstack]);
+             else
+                 EPISOR.tkesum += (STACK.tke[STACK.lstack] * STACK.wt[STACK.lstack]);
+             
+             /*  Here we ask for the region number of the hitting point.
+              *     NREG (LSTACK) = ...
+              *  The following line makes the starting region search much more
+              *  robust if particles are starting very close to a boundary:
+              */
+             geocrs( STACK.tx[STACK.lstack], 
+                     STACK.ty[STACK.lstack], 
+                     STACK.tz[STACK.lstack] );
+             
+             Int_t idisc;
+             
+             georeg ( STACK.xa[STACK.lstack], 
+                      STACK.ya[STACK.lstack], 
+                      STACK.za[STACK.lstack],
+                      STACK.nreg[STACK.lstack], 
+                      idisc);//<-- dummy return variable not used
+             /*  Do not change these cards:*/
+             Int_t igeohsm1 = 1;
+             Int_t igeohsm2 = -11;
+             geohsm ( STACK.nhspnt[STACK.lstack], igeohsm1, igeohsm2, LTCLCM.mlattc );
+             STACK.nlattc[STACK.lstack] = LTCLCM.mlattc;
+             soevsv();
+//
+//  Pre-track actions at for primary tracks
+//
+         }
+      }
+  }
+}
+
+    
diff --git a/TFluka/source_ff.cxx b/TFluka/source_ff.cxx
new file mode 100644 (file)
index 0000000..d721541
--- /dev/null
@@ -0,0 +1,233 @@
+#define METHODDEBUG
+
+// Fortran 
+#include "TCallf77.h"
+
+// Fluka commons
+#include "Fdblprc.h"  //(DBLPRC) fluka common
+#include "Fdimpar.h"  //(DIMPAR) fluka parameters
+#include "Fepisor.h"  //(EPISOR) fluka common
+#include "Fstack.h"   //(STACK)  fluka common
+#include "Fstars.h"   //(STARS)  fluka common
+#include "Fbeam.h"    //(BEAM)   fluka common
+#include "Fpaprop.h"  //(PAPROP) fluka common
+#include "Fltclcm.h"  //(LTCLCM) fluka common
+#include "Fpart.h"  
+//#include "Fcaslim.h"  //(CASLIM) fluka common
+
+//Virutal MC
+#include "AliGenerator.h"
+#include "AliStack.h"
+#include "../PYTHIA6/AliGenPythia.h"
+
+#include "TVirtualMCStack.h"
+#include "TParticle.h"
+#include "TVector3.h"
+
+//Other
+#include <Riostream.h>
+
+#ifndef WIN32
+# define source source_
+# define geocrs geocrs_
+# define georeg georeg_
+# define geohsm geohsm_
+# define soevsv soevsv_
+# define mcihad mcihad_
+# define source_f source_f__
+#else
+# define source SOURCE
+# define geocrs GEOCRS
+# define georeg GEOREG
+# define geohsm GEOHSM
+# define soevsv SOEVSV
+# define mcihad MCIHAD
+# define source_f SOURCE_F
+#endif
+
+extern "C" {
+  //
+  // Prototypes for FLUKA functions
+  //
+  void type_of_call geocrs(Double_t &, Double_t &, Double_t &);
+  void type_of_call georeg(Double_t &, Double_t &, Double_t &, 
+                          Int_t &, Int_t &);
+  void type_of_call geohsm(Int_t &, Int_t &, Int_t &, Int_t &);
+  void type_of_call soevsv();
+  int  type_of_call mcihad(const int&);
+ /*
+   *----------------------------------------------------------------------*
+   *                                                                      *
+   *     Created on 07 january 1990   by    Alfredo Ferrari & Paola Sala  *
+   *                                                   Infn - Milan       *
+   *                                                                      *
+   *     Last change on 21-jun-98     by    Alfredo Ferrari               *
+   *                                                                      *
+   *     C++ version on 27-sep-02     by    Isidro Gonzalez               *
+   *                                                                      *
+   *  This is just an example of a possible user written source routine.  *
+   *  note that the beam card still has some meaning - in the scoring the *
+   *  maximum momentum used in deciding the binning is taken from the     *
+   *  beam momentum.  Other beam card parameters are obsolete.            *
+   *                                                                      *
+   *----------------------------------------------------------------------*/
+
+  void source_f(Int_t& nomore) {
+
+      static Bool_t lfirst       = true;
+      static AliGenPythia* gener = 0;
+      static AliStack* stack     = 0;  
+
+      nomore = 0;
+      TParticle* particle;
+      Int_t itrack = -1;
+      if (lfirst) {
+         printf("source_f first call \n");
+         EPISOR.tkesum = zerzer;
+         lfirst = false;
+         EPISOR.lussrc = true;
+         gener  = new AliGenPythia(1);
+         gener->SetEnergyCMS(14000.);
+         gener->SetProcess(kPyMb);
+         stack = new AliStack(1000);
+         gener->SetStack(stack);
+         gener->Init();
+
+      } else {
+         //
+         // Generate event
+         printf("Calling Generate() %p \n", gener);
+         stack->Reset();
+         gener->Generate();
+         Int_t npart = stack->GetNprimary();
+         printf("%d Particles on the stack \n", npart);
+         for (Int_t part=0; part<npart; part++) {
+             particle = stack->Particle(part);
+             Int_t st = particle->GetStatusCode();
+             if (st != 1) continue;
+             Int_t pdg = particle->GetPdgCode();
+             Int_t intfluka = mcihad(pdg);
+             Int_t ifl = GetFlukaKPTOIP(intfluka);
+             TVector3 polarisation;
+             particle->GetPolarisation(polarisation);
+
+             STACK.lstack++;
+
+             printf("Particle %5d %5d %5d %10s %10.3f %10.3f %10.3f \n", STACK.lstack, pdg, ifl, 
+                    particle->GetName(), particle->Px(), particle->Py(), particle->Pz());
+             
+
+             
+             /* Wt is the weight of the particle*/
+             STACK.wt[STACK.lstack] = oneone;
+             STARS.weipri += STACK.wt[STACK.lstack];
+             
+             STACK.ilo[STACK.lstack] = ifl;
+             /* From this point .....
+              * Particle generation (1 for primaries)
+              */
+             STACK.lo[STACK.lstack] = 1;
+             
+             /* User dependent flag:*/
+             STACK.louse[STACK.lstack] = 0;
+             
+             /* User dependent spare variables:*/
+             Int_t ispr = 0;
+             for (ispr = 0; ispr < mkbmx1; ispr++)
+                 STACK.sparek[STACK.lstack][ispr] = zerzer;
+             
+             /* User dependent spare flags:*/
+             for (ispr = 0; ispr < mkbmx2; ispr++)
+                 STACK.ispark[STACK.lstack][ispr] = 0;
+             
+             /* Save the track number of the stack particle:*/
+             STACK.ispark[STACK.lstack][mkbmx2-1] = itrack;
+             STACK.nparma++;
+             STACK.numpar[STACK.lstack] = STACK.nparma;
+             STACK.nevent[STACK.lstack] = 0;
+             STACK.dfnear[STACK.lstack] = +zerzer;
+             
+             /* Particle age (s)*/
+             STACK.agestk[STACK.lstack] = +zerzer;
+             STACK.aknshr[STACK.lstack] = -twotwo;
+             
+             /* Group number for "low" energy neutrons, set to 0 anyway*/
+             STACK.igroup[STACK.lstack] = 0;
+             
+             /* Kinetic energy */
+             STACK.tke[STACK.lstack] = particle->Energy() - particle->GetMass();
+             
+             
+             /* Particle momentum*/
+             STACK.pmom [STACK.lstack] = particle->P();
+             
+             /* Cosines (tx,ty,tz)*/
+             Double_t cosx = particle->Px()/particle->P();
+             Double_t cosy = particle->Py()/particle->P();
+             Double_t cosz = TMath::Sqrt(oneone - cosx*cosx - cosy*cosy);
+             if (particle->Pz() < 0.) cosz = -cosz;
+             STACK.tx [STACK.lstack] = cosx;
+             STACK.ty [STACK.lstack] = cosy;
+             STACK.tz [STACK.lstack] = cosz;
+             
+             /* Polarization cosines:*/
+             if (polarisation.Mag()) {
+                 Double_t cospolx = polarisation.Px()/polarisation.Mag();
+                 Double_t cospoly = polarisation.Py()/polarisation.Mag();
+                 Double_t cospolz = sqrt(oneone - cospolx*cospolx - cospoly*cospoly);
+                 STACK.tx [STACK.lstack] = cospolx;
+                 STACK.ty [STACK.lstack] = cospoly;
+                 STACK.tz [STACK.lstack] = cospolz;
+             }
+             else {
+                 STACK.txpol [STACK.lstack] = -twotwo;
+                 STACK.typol [STACK.lstack] = +zerzer;
+                 STACK.tzpol [STACK.lstack] = +zerzer;
+             }
+             
+             /* Particle coordinates*/
+             // Vertext coordinates;
+             STACK.xa [STACK.lstack] = particle->Vx();
+             STACK.ya [STACK.lstack] = particle->Vy();
+             STACK.za [STACK.lstack] = particle->Vz();
+             
+             /*  Calculate the total kinetic energy of the primaries: don't change*/
+             Int_t st_ilo =  STACK.ilo[STACK.lstack];
+             if ( st_ilo != 0 )
+                 EPISOR.tkesum += 
+                     ((STACK.tke[STACK.lstack] + PAPROP.amdisc[st_ilo+6])
+                      * STACK.wt[STACK.lstack]);
+             else
+                 EPISOR.tkesum += (STACK.tke[STACK.lstack] * STACK.wt[STACK.lstack]);
+             
+             /*  Here we ask for the region number of the hitting point.
+              *     NREG (LSTACK) = ...
+              *  The following line makes the starting region search much more
+              *  robust if particles are starting very close to a boundary:
+              */
+             geocrs( STACK.tx[STACK.lstack], 
+                     STACK.ty[STACK.lstack], 
+                     STACK.tz[STACK.lstack] );
+             
+             Int_t idisc;
+             
+             georeg ( STACK.xa[STACK.lstack], 
+                      STACK.ya[STACK.lstack], 
+                      STACK.za[STACK.lstack],
+                      STACK.nreg[STACK.lstack], 
+                      idisc);//<-- dummy return variable not used
+             /*  Do not change these cards:*/
+             Int_t igeohsm1 = 1;
+             Int_t igeohsm2 = -11;
+             geohsm ( STACK.nhspnt[STACK.lstack], igeohsm1, igeohsm2, LTCLCM.mlattc );
+             STACK.nlattc[STACK.lstack] = LTCLCM.mlattc;
+             soevsv();
+//
+//  Pre-track actions at for primary tracks
+//
+         }
+      }
+  }
+}
+
+    
diff --git a/TFluka/source_halo.cxx b/TFluka/source_halo.cxx
new file mode 100644 (file)
index 0000000..c921084
--- /dev/null
@@ -0,0 +1,232 @@
+#define METHODDEBUG
+
+// Fortran 
+#include "TCallf77.h"
+
+// Fluka commons
+#include "Fdblprc.h"  //(DBLPRC) fluka common
+#include "Fdimpar.h"  //(DIMPAR) fluka parameters
+#include "Fepisor.h"  //(EPISOR) fluka common
+#include "Fstack.h"   //(STACK)  fluka common
+#include "Fstars.h"   //(STARS)  fluka common
+#include "Fbeam.h"    //(BEAM)   fluka common
+#include "Fpaprop.h"  //(PAPROP) fluka common
+#include "Fltclcm.h"  //(LTCLCM) fluka common
+#include "Fpart.h"  
+//#include "Fcaslim.h"  //(CASLIM) fluka common
+
+//Virutal MC
+#include "AliGenerator.h"
+#include "AliStack.h"
+#include "../EVGEN/AliGenHaloProtvino.h"
+
+#include "TVirtualMCStack.h"
+#include "TParticle.h"
+#include "TVector3.h"
+#include "TRandom.h"
+
+//Other
+#include <Riostream.h>
+
+#ifndef WIN32
+# define source source_
+# define geocrs geocrs_
+# define georeg georeg_
+# define geohsm geohsm_
+# define soevsv soevsv_
+# define mcihad mcihad_
+# define source_halo source_halo__
+#else
+# define source SOURCE
+# define geocrs GEOCRS
+# define georeg GEOREG
+# define geohsm GEOHSM
+# define soevsv SOEVSV
+# define mcihad MCIHAD
+# define source_halo SOURCE_HALO
+#endif
+
+extern "C" {
+  //
+  // Prototypes for FLUKA functions
+  //
+  void type_of_call geocrs(Double_t &, Double_t &, Double_t &);
+  void type_of_call georeg(Double_t &, Double_t &, Double_t &, 
+                          Int_t &, Int_t &);
+  void type_of_call geohsm(Int_t &, Int_t &, Int_t &, Int_t &);
+  void type_of_call soevsv();
+  int  type_of_call mcihad(const int&);
+ /*
+   *----------------------------------------------------------------------*
+   *                                                                      *
+   *     Created on 07 january 1990   by    Alfredo Ferrari & Paola Sala  *
+   *                                                   Infn - Milan       *
+   *                                                                      *
+   *     Last change on 21-jun-98     by    Alfredo Ferrari               *
+   *                                                                      *
+   *     C++ version on 27-sep-02     by    Isidro Gonzalez               *
+   *                                                                      *
+   *  This is just an example of a possible user written source routine.  *
+   *  note that the beam card still has some meaning - in the scoring the *
+   *  maximum momentum used in deciding the binning is taken from the     *
+   *  beam momentum.  Other beam card parameters are obsolete.            *
+   *                                                                      *
+   *----------------------------------------------------------------------*/
+
+  void source_halo(Int_t& nomore) {
+
+      static Bool_t lfirst               = true;
+      static AliGenHaloProtvino* gener   = 0;
+      static AliStack* stack             = 0;  
+
+      nomore = 0;
+      TParticle* particle;
+      Int_t itrack = -1;
+      if (lfirst) {
+         EPISOR.tkesum = zerzer;
+         lfirst = false;
+         EPISOR.lussrc = true;
+//
+// The generator
+//
+         gener  = new AliGenHaloProtvino(10);
+         gener->SetFileName("/home/morsch/AliRoot/newio/data/ir.2.ring.one.b.10.m");
+         gener->SetSide(2);
+         gener->SetRunPeriod();
+         
+         
+// The particle stack
+         stack = new AliStack(1000);
+         gener->SetStack(stack);
+         gener->Init();
+
+      } else {
+         //
+         // Generate event
+         stack->Reset();
+         gener->Generate();
+         Int_t npart = stack->GetNprimary();
+         for (Int_t part = 1; part < npart; part += 2) {
+             particle = stack->Particle(part);
+             STACK.lstack++;
+             Int_t pdg = particle->GetPdgCode();
+             Int_t intfluka = mcihad(pdg);
+             Int_t ifl = GetFlukaKPTOIP(intfluka);
+             Float_t wgt = particle->GetWeight();
+             
+             printf("Particle %5d %10s %10.3f %10.3f %10.3f %10.3f\n", 
+                    STACK.lstack, 
+                    particle->GetName(), 
+                    particle->Px(), particle->Py(), particle->Pz(), wgt);
+             
+
+             
+             /* Wt is the weight of the particle*/
+             STACK.wt[STACK.lstack] = wgt;
+             STARS.weipri += STACK.wt[STACK.lstack];
+             
+             STACK.ilo[STACK.lstack] = ifl;
+             /* From this point .....
+              * Particle generation (1 for primaries)
+              */
+             STACK.lo[STACK.lstack] = 1;
+             
+             /* User dependent flag:*/
+             STACK.louse[STACK.lstack] = 0;
+             
+             /* User dependent spare variables:*/
+             Int_t ispr = 0;
+             for (ispr = 0; ispr < mkbmx1; ispr++)
+                 STACK.sparek[STACK.lstack][ispr] = zerzer;
+             
+             /* User dependent spare flags:*/
+             for (ispr = 0; ispr < mkbmx2; ispr++)
+                 STACK.ispark[STACK.lstack][ispr] = 0;
+             
+             /* Save the track number of the stack particle:*/
+             STACK.ispark[STACK.lstack][mkbmx2-1] = itrack;
+             STACK.nparma++;
+             STACK.numpar[STACK.lstack] = STACK.nparma;
+             STACK.nevent[STACK.lstack] = 0;
+             STACK.dfnear[STACK.lstack] = +zerzer;
+             
+             /* Particle age (s)*/
+             STACK.agestk[STACK.lstack] = +zerzer;
+             STACK.aknshr[STACK.lstack] = -twotwo;
+             
+             /* Group number for "low" energy neutrons, set to 0 anyway*/
+             STACK.igroup[STACK.lstack] = 0;
+             
+             /* Kinetic energy */
+             STACK.tke[STACK.lstack] = particle->Energy() - particle->GetMass();
+             
+             
+             /* Particle momentum*/
+             STACK.pmom [STACK.lstack] = particle->P();
+             
+             /* Cosines (tx,ty,tz)*/
+             Double_t cosx = particle->Px()/particle->P();
+             Double_t cosy = particle->Py()/particle->P();
+             Double_t cosz = TMath::Sqrt(oneone - cosx*cosx - cosy*cosy);
+             if (particle->Pz() < 0.)   cosz = -cosz;
+             
+             STACK.tx [STACK.lstack] =   cosx;
+             STACK.ty [STACK.lstack] =   cosy;
+             STACK.tz [STACK.lstack] =   cosz;
+             
+             /* Polarization cosines:*/
+             
+             STACK.txpol [STACK.lstack] = -twotwo;
+             STACK.typol [STACK.lstack] = +zerzer;
+             STACK.tzpol [STACK.lstack] = +zerzer;
+             
+             /* Particle coordinates*/
+             STACK.xa [STACK.lstack] =   particle->Vx();
+             STACK.ya [STACK.lstack] =   particle->Vy();
+             STACK.za [STACK.lstack] =   particle->Vz();
+             
+             
+             
+             /*  Calculate the total kinetic energy of the primaries: don't change*/
+             Int_t st_ilo =  STACK.ilo[STACK.lstack];
+             if ( st_ilo != 0 )
+                 EPISOR.tkesum += 
+                     ((STACK.tke[STACK.lstack] + PAPROP.amdisc[st_ilo+6])
+                      * STACK.wt[STACK.lstack]);
+             else
+                 EPISOR.tkesum += (STACK.tke[STACK.lstack] * STACK.wt[STACK.lstack]);
+             
+             /*  Here we ask for the region number of the hitting point.
+              *     NREG (LSTACK) = ...
+              *  The following line makes the starting region search much more
+              *  robust if particles are starting very close to a boundary:
+              */
+             geocrs( STACK.tx[STACK.lstack], 
+                     STACK.ty[STACK.lstack], 
+                     STACK.tz[STACK.lstack] );
+
+             
+             Int_t idisc;
+             
+             georeg ( STACK.xa[STACK.lstack], 
+                      STACK.ya[STACK.lstack], 
+                      STACK.za[STACK.lstack],
+                      STACK.nreg[STACK.lstack], 
+                      idisc);//<-- dummy return variable not used
+             printf("Particle Vertex %10.3f %10.3f %10.3f %5d\n",  
+                    STACK.xa [STACK.lstack],  STACK.ya [STACK.lstack],  STACK.za [STACK.lstack], 
+                    STACK.nreg[STACK.lstack]);
+             
+
+             /*  Do not change these cards:*/
+             Int_t igeohsm1 = 1;
+             Int_t igeohsm2 = -11;
+             geohsm ( STACK.nhspnt[STACK.lstack], igeohsm1, igeohsm2, LTCLCM.mlattc );
+             STACK.nlattc[STACK.lstack] = LTCLCM.mlattc;
+             soevsv();
+         }
+      }
+  }
+}
+
+    
diff --git a/TFluka/source_pp.cxx b/TFluka/source_pp.cxx
new file mode 100644 (file)
index 0000000..828c33e
--- /dev/null
@@ -0,0 +1,230 @@
+#define METHODDEBUG
+
+// Fortran 
+#include "TCallf77.h"
+
+// Fluka commons
+#include "Fdblprc.h"  //(DBLPRC) fluka common
+#include "Fdimpar.h"  //(DIMPAR) fluka parameters
+#include "Fepisor.h"  //(EPISOR) fluka common
+#include "Fstack.h"   //(STACK)  fluka common
+#include "Fstars.h"   //(STARS)  fluka common
+#include "Fbeam.h"    //(BEAM)   fluka common
+#include "Fpaprop.h"  //(PAPROP) fluka common
+#include "Fltclcm.h"  //(LTCLCM) fluka common
+#include "Fpart.h"  
+//#include "Fcaslim.h"  //(CASLIM) fluka common
+
+//Virutal MC
+#include "AliGenerator.h"
+#include "AliStack.h"
+#include "../PYTHIA6/AliGenPythia.h"
+
+#include "TVirtualMCStack.h"
+#include "TParticle.h"
+#include "TVector3.h"
+
+//Other
+#include <Riostream.h>
+
+#ifndef WIN32
+# define source source_
+# define geocrs geocrs_
+# define georeg georeg_
+# define geohsm geohsm_
+# define soevsv soevsv_
+# define mcihad mcihad_
+# define source_pp source_pp__
+#else
+# define source SOURCE
+# define geocrs GEOCRS
+# define georeg GEOREG
+# define geohsm GEOHSM
+# define soevsv SOEVSV
+# define mcihad MCIHAD
+# define source_pp SOURCE_PP
+#endif
+
+extern "C" {
+  //
+  // Prototypes for FLUKA functions
+  //
+  void type_of_call geocrs(Double_t &, Double_t &, Double_t &);
+  void type_of_call georeg(Double_t &, Double_t &, Double_t &, 
+                          Int_t &, Int_t &);
+  void type_of_call geohsm(Int_t &, Int_t &, Int_t &, Int_t &);
+  void type_of_call soevsv();
+  int  type_of_call mcihad(const int&);
+ /*
+   *----------------------------------------------------------------------*
+   *                                                                      *
+   *     Created on 07 january 1990   by    Alfredo Ferrari & Paola Sala  *
+   *                                                   Infn - Milan       *
+   *                                                                      *
+   *     Last change on 21-jun-98     by    Alfredo Ferrari               *
+   *                                                                      *
+   *     C++ version on 27-sep-02     by    Isidro Gonzalez               *
+   *                                                                      *
+   *  This is just an example of a possible user written source routine.  *
+   *  note that the beam card still has some meaning - in the scoring the *
+   *  maximum momentum used in deciding the binning is taken from the     *
+   *  beam momentum.  Other beam card parameters are obsolete.            *
+   *                                                                      *
+   *----------------------------------------------------------------------*/
+
+  void source_pp(Int_t& nomore) {
+
+      static Bool_t lfirst       = true;
+      static AliGenPythia* gener = 0;
+      static AliStack* stack     = 0;  
+
+      nomore = 0;
+      TParticle* particle;
+      Int_t itrack = -1;
+      if (lfirst) {
+         EPISOR.tkesum = zerzer;
+         lfirst = false;
+         EPISOR.lussrc = true;
+         gener  = new AliGenPythia(1);
+         gener->SetEnergyCMS(14000.);
+         gener->SetProcess(kPyMb);
+         stack = new AliStack(1000);
+         gener->SetStack(stack);
+         gener->Init();
+
+      } else {
+         //
+         // Generate event
+         stack->Reset();
+         gener->Generate();
+         Int_t npart = stack->GetNprimary();
+         for (Int_t part=0; part<npart; part++) {
+             particle = stack->Particle(part);
+             Int_t st = particle->GetStatusCode();
+             if (st != 1) continue;
+             Int_t pdg = particle->GetPdgCode();
+             Int_t intfluka = mcihad(pdg);
+             Int_t ifl = GetFlukaKPTOIP(intfluka);
+             TVector3 polarisation;
+             particle->GetPolarisation(polarisation);
+
+             STACK.lstack++;
+
+             printf("Particle %5d %5d %5d %10s %10.3f %10.3f %10.3f \n", STACK.lstack, pdg, ifl, 
+                    particle->GetName(), particle->Px(), particle->Py(), particle->Pz());
+             
+
+             
+             /* Wt is the weight of the particle*/
+             STACK.wt[STACK.lstack] = oneone;
+             STARS.weipri += STACK.wt[STACK.lstack];
+             
+             STACK.ilo[STACK.lstack] = ifl;
+             /* From this point .....
+              * Particle generation (1 for primaries)
+              */
+             STACK.lo[STACK.lstack] = 1;
+             
+             /* User dependent flag:*/
+             STACK.louse[STACK.lstack] = 0;
+             
+             /* User dependent spare variables:*/
+             Int_t ispr = 0;
+             for (ispr = 0; ispr < mkbmx1; ispr++)
+                 STACK.sparek[STACK.lstack][ispr] = zerzer;
+             
+             /* User dependent spare flags:*/
+             for (ispr = 0; ispr < mkbmx2; ispr++)
+                 STACK.ispark[STACK.lstack][ispr] = 0;
+             
+             /* Save the track number of the stack particle:*/
+             STACK.ispark[STACK.lstack][mkbmx2-1] = itrack;
+             STACK.nparma++;
+             STACK.numpar[STACK.lstack] = STACK.nparma;
+             STACK.nevent[STACK.lstack] = 0;
+             STACK.dfnear[STACK.lstack] = +zerzer;
+             
+             /* Particle age (s)*/
+             STACK.agestk[STACK.lstack] = +zerzer;
+             STACK.aknshr[STACK.lstack] = -twotwo;
+             
+             /* Group number for "low" energy neutrons, set to 0 anyway*/
+             STACK.igroup[STACK.lstack] = 0;
+             
+             /* Kinetic energy */
+             STACK.tke[STACK.lstack] = particle->Energy() - particle->GetMass();
+             
+             
+             /* Particle momentum*/
+             STACK.pmom [STACK.lstack] = particle->P();
+             
+             /* Cosines (tx,ty,tz)*/
+             Double_t cosx = particle->Px()/particle->P();
+             Double_t cosy = particle->Py()/particle->P();
+             Double_t cosz = TMath::Sqrt(oneone - cosx*cosx - cosy*cosy);
+             if (particle->Pz() < 0.) cosz = -cosz;
+             STACK.tx [STACK.lstack] = cosx;
+             STACK.ty [STACK.lstack] = cosy;
+             STACK.tz [STACK.lstack] = cosz;
+             
+             /* Polarization cosines:*/
+             if (polarisation.Mag()) {
+                 Double_t cospolx = polarisation.Px()/polarisation.Mag();
+                 Double_t cospoly = polarisation.Py()/polarisation.Mag();
+                 Double_t cospolz = sqrt(oneone - cospolx*cospolx - cospoly*cospoly);
+                 STACK.tx [STACK.lstack] = cospolx;
+                 STACK.ty [STACK.lstack] = cospoly;
+                 STACK.tz [STACK.lstack] = cospolz;
+             }
+             else {
+                 STACK.txpol [STACK.lstack] = -twotwo;
+                 STACK.typol [STACK.lstack] = +zerzer;
+                 STACK.tzpol [STACK.lstack] = +zerzer;
+             }
+             
+             /* Particle coordinates*/
+             // Vertext coordinates;
+             STACK.xa [STACK.lstack] = particle->Vx();
+             STACK.ya [STACK.lstack] = particle->Vy();
+             STACK.za [STACK.lstack] = particle->Vz();
+             
+             /*  Calculate the total kinetic energy of the primaries: don't change*/
+             Int_t st_ilo =  STACK.ilo[STACK.lstack];
+             if ( st_ilo != 0 )
+                 EPISOR.tkesum += 
+                     ((STACK.tke[STACK.lstack] + PAPROP.amdisc[st_ilo+6])
+                      * STACK.wt[STACK.lstack]);
+             else
+                 EPISOR.tkesum += (STACK.tke[STACK.lstack] * STACK.wt[STACK.lstack]);
+             
+             /*  Here we ask for the region number of the hitting point.
+              *     NREG (LSTACK) = ...
+              *  The following line makes the starting region search much more
+              *  robust if particles are starting very close to a boundary:
+              */
+             geocrs( STACK.tx[STACK.lstack], 
+                     STACK.ty[STACK.lstack], 
+                     STACK.tz[STACK.lstack] );
+             
+             Int_t idisc;
+             
+             georeg ( STACK.xa[STACK.lstack], 
+                      STACK.ya[STACK.lstack], 
+                      STACK.za[STACK.lstack],
+                      STACK.nreg[STACK.lstack], 
+                      idisc);//<-- dummy return variable not used
+             /*  Do not change these cards:*/
+             Int_t igeohsm1 = 1;
+             Int_t igeohsm2 = -11;
+             geohsm ( STACK.nhspnt[STACK.lstack], igeohsm1, igeohsm2, LTCLCM.mlattc );
+             STACK.nlattc[STACK.lstack] = LTCLCM.mlattc;
+             soevsv();
+//
+//  Pre-track actions at for primary tracks
+//
+         }
+      }
+  }
+}
+
+    
diff --git a/TFluka/source_ray.cxx b/TFluka/source_ray.cxx
new file mode 100644 (file)
index 0000000..eee0cc8
--- /dev/null
@@ -0,0 +1,219 @@
+// Fortran 
+#include "TCallf77.h"
+
+// Fluka commons
+#include "Fdblprc.h"  //(DBLPRC) fluka common
+#include "Fdimpar.h"  //(DIMPAR) fluka parameters
+#include "Fepisor.h"  //(EPISOR) fluka common
+#include "Fstack.h"   //(STACK)  fluka common
+#include "Fstars.h"   //(STARS)  fluka common
+#include "Fbeam.h"    //(BEAM)   fluka common
+#include "Fpaprop.h"  //(PAPROP) fluka common
+#include "Fltclcm.h"  //(LTCLCM) fluka common
+#include "Fpart.h"  
+//#include "Fcaslim.h"  //(CASLIM) fluka common
+
+#include "TVector3.h"
+#include "TRandom.h"
+#include "TParticle.h"
+#include "../EVGEN/AliGenScan.h"
+#include "AliStack.h"
+
+//Other
+#include <Riostream.h>
+
+#ifndef WIN32
+# define source source_
+# define geocrs geocrs_
+# define georeg georeg_
+# define geohsm geohsm_
+# define soevsv soevsv_
+# define mcihad mcihad_
+# define source_ray source_ray__
+#else
+# define source SOURCE
+# define geocrs GEOCRS
+# define georeg GEOREG
+# define geohsm GEOHSM
+# define soevsv SOEVSV
+# define mcihad MCIHAD
+# define source_ray SOURCE_RAY
+#endif
+
+extern "C" {
+  //
+  // Prototypes for FLUKA functions
+  //
+  void type_of_call geocrs(Double_t &, Double_t &, Double_t &);
+  void type_of_call georeg(Double_t &, Double_t &, Double_t &, 
+                          Int_t &, Int_t &);
+  void type_of_call geohsm(Int_t &, Int_t &, Int_t &, Int_t &);
+  void type_of_call soevsv();
+  int  type_of_call mcihad(const int&);
+ /*
+   *----------------------------------------------------------------------*
+   *                                                                      *
+   *     Created on 07 january 1990   by    Alfredo Ferrari & Paola Sala  *
+   *                                                   Infn - Milan       *
+   *                                                                      *
+   *     Last change on 21-jun-98     by    Alfredo Ferrari               *
+   *                                                                      *
+   *     C++ version on 27-sep-02     by    Isidro Gonzalez               *
+   *                                                                      *
+   *  This is just an example of a possible user written source routine.  *
+   *  note that the beam card still has some meaning - in the scoring the *
+   *  maximum momentum used in deciding the binning is taken from the     *
+   *  beam momentum.  Other beam card parameters are obsolete.            *
+   *                                                                      *
+   *----------------------------------------------------------------------*/
+
+  void source_ray(Int_t& nomore) {
+
+      static Bool_t lfirst       = true;
+      static AliGenScan* gener   = 0;
+      static AliStack* stack     = 0;  
+
+      nomore = 0;
+      TParticle* particle = 0;
+      Int_t itrack        = -1;
+      if (lfirst) {
+         EPISOR.tkesum = zerzer;
+         lfirst = false;
+         EPISOR.lussrc = true;
+//
+// The generator
+//
+         gener  = new AliGenScan(0);
+         gener->SetRange(40, -200., 200., 40, -200., 200., 1, -700., -699.);
+         gener->SetPart(0);
+         gener->SetThetaRange(180., 180.);
+         gener->SetPhiRange(0.,0.);
+         
+         
+// Stack 
+         stack = new AliStack(10000);
+         gener->SetStack(stack);
+         gener->Init();
+
+      } else {
+         //
+         // Generate event
+         stack->Reset();
+         gener->Generate();
+         Int_t npart = stack->GetNprimary();
+         for (Int_t part = 0; part < npart; part++) {
+             STACK.lstack++;
+             particle = stack->Particle(part);
+             
+             printf("Particle %5d %10s %10.3f %10.3f %10.3f \n", 
+                    STACK.lstack, particle->GetName(), 
+                    particle->Px(), particle->Py(), particle->Pz());
+             
+
+             
+             /* Wt is the weight of the particle*/
+             STACK.wt[STACK.lstack] = oneone;
+             STARS.weipri += STACK.wt[STACK.lstack];
+             
+             // ray
+             STACK.ilo[STACK.lstack] = 0;
+             /* From this point .....
+              * Particle generation (1 for primaries)
+              */
+             STACK.lo[STACK.lstack] = 1;
+             
+             /* User dependent flag:*/
+             STACK.louse[STACK.lstack] = 0;
+             
+             /* User dependent spare variables:*/
+             Int_t ispr = 0;
+             for (ispr = 0; ispr < mkbmx1; ispr++)
+                 STACK.sparek[STACK.lstack][ispr] = zerzer;
+             
+             /* User dependent spare flags:*/
+             for (ispr = 0; ispr < mkbmx2; ispr++)
+                 STACK.ispark[STACK.lstack][ispr] = 0;
+             
+             /* Save the track number of the stack particle:*/
+             STACK.ispark[STACK.lstack][mkbmx2-1] = itrack;
+             STACK.nparma++;
+             STACK.numpar[STACK.lstack] = STACK.nparma;
+             STACK.nevent[STACK.lstack] = 0;
+             STACK.dfnear[STACK.lstack] = +zerzer;
+             
+             /* Particle age (s)*/
+             STACK.agestk[STACK.lstack] = +zerzer;
+             STACK.aknshr[STACK.lstack] = -twotwo;
+             
+             /* Group number for "low" energy neutrons, set to 0 anyway*/
+             STACK.igroup[STACK.lstack] = 0;
+             
+             /* Kinetic energy */
+             STACK.tke[STACK.lstack] = particle->Energy() - particle->GetMass();
+             
+             
+             /* Particle momentum*/
+             STACK.pmom [STACK.lstack] = particle->P();
+             
+             /* Cosines (tx,ty,tz)*/
+             Double_t cosx = particle->Px()/particle->P();
+             Double_t cosy = particle->Py()/particle->P();
+             Double_t cosz = TMath::Sqrt(oneone - cosx*cosx - cosy*cosy);
+             if (particle->Pz() < 0.) cosz = -cosz;
+             
+             STACK.tx [STACK.lstack] = cosx;
+             STACK.ty [STACK.lstack] = cosy;
+             STACK.tz [STACK.lstack] = cosz;
+             
+             /* Polarization cosines:*/
+             STACK.txpol [STACK.lstack] = -twotwo;
+             STACK.typol [STACK.lstack] = +zerzer;
+             STACK.tzpol [STACK.lstack] = +zerzer;
+             
+             /* Particle coordinates*/
+             STACK.xa [STACK.lstack] =   particle->Vx();
+             STACK.ya [STACK.lstack] =   particle->Vy();
+             STACK.za [STACK.lstack] =   particle->Vz();
+             
+             printf("Particle Vertex %10.3f %10.3f %10.3f  \n",  
+                    STACK.xa [STACK.lstack],  STACK.ya [STACK.lstack],  STACK.za [STACK.lstack]);
+             
+             
+             
+             /*  Calculate the total kinetic energy of the primaries: don't change*/
+             Int_t st_ilo =  STACK.ilo[STACK.lstack];
+             if ( st_ilo != 0 )
+                 EPISOR.tkesum += 
+                     ((STACK.tke[STACK.lstack] + PAPROP.amdisc[st_ilo+6])
+                      * STACK.wt[STACK.lstack]);
+             else
+                 EPISOR.tkesum += (STACK.tke[STACK.lstack] * STACK.wt[STACK.lstack]);
+             
+             /*  Here we ask for the region number of the hitting point.
+              *     NREG (LSTACK) = ...
+              *  The following line makes the starting region search much more
+              *  robust if particles are starting very close to a boundary:
+              */
+             geocrs( STACK.tx[STACK.lstack], 
+                     STACK.ty[STACK.lstack], 
+                     STACK.tz[STACK.lstack] );
+             
+             Int_t idisc;
+             
+             georeg ( STACK.xa[STACK.lstack], 
+                      STACK.ya[STACK.lstack], 
+                      STACK.za[STACK.lstack],
+                      STACK.nreg[STACK.lstack], 
+                      idisc);//<-- dummy return variable not used
+             /*  Do not change these cards:*/
+             Int_t igeohsm1 = 1;
+             Int_t igeohsm2 = -11;
+             geohsm ( STACK.nhspnt[STACK.lstack], igeohsm1, igeohsm2, LTCLCM.mlattc );
+             STACK.nlattc[STACK.lstack] = LTCLCM.mlattc;
+             soevsv();
+         }
+      }
+  }
+}
+
+