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 "Fcaslim.h" //(CASLIM) fluka common
19 #include "TVirtualMCStack.h"
20 #include "TVirtualMCApplication.h"
21 #include "TParticle.h"
25 #include <Riostream.h>
28 # define source source_
29 # define geocrs geocrs_
30 # define georeg georeg_
31 # define geohsm geohsm_
32 # define soevsv soevsv_
34 # define source SOURCE
35 # define geocrs GEOCRS
36 # define georeg GEOREG
37 # define geohsm GEOHSM
38 # define soevsv SOEVSV
43 // Prototypes for FLUKA functions
45 void type_of_call geocrs(Double_t &, Double_t &, Double_t &);
46 void type_of_call georeg(Double_t &, Double_t &, Double_t &,
48 void type_of_call geohsm(Int_t &, Int_t &, Int_t &, Int_t &);
49 void type_of_call soevsv();
51 *----------------------------------------------------------------------*
53 * Created on 07 january 1990 by Alfredo Ferrari & Paola Sala *
56 * Last change on 21-jun-98 by Alfredo Ferrari *
58 * C++ version on 27-sep-02 by Isidro Gonzalez *
60 * This is just an example of a possible user written source routine. *
61 * note that the beam card still has some meaning - in the scoring the *
62 * maximum momentum used in deciding the binning is taken from the *
63 * beam momentum. Other beam card parameters are obsolete. *
65 *----------------------------------------------------------------------*/
67 void source(Int_t& nomore) {
69 cout << "==> source(" << nomore << ")" << endl;
72 cout << "\t* EPISOR.lsouit = " << (EPISOR.lsouit?'T':'F') << endl;
74 static Bool_t lfirst = true;
75 /*======================================================================*
79 *======================================================================*/
81 /* +-------------------------------------------------------------------*
82 * | First call initializations:*/
85 /*| *** The following 3 cards are mandatory ***/
87 EPISOR.tkesum = zerzer;
90 /*| *** User initialization ***/
92 TVirtualMCApplication::Instance()->PostTrack();
93 TVirtualMCApplication::Instance()->FinishPrimary();
98 * +-------------------------------------------------------------------*
99 * Push one source particle to the stack. Note that you could as well
100 * push many but this way we reserve a maximum amount of space in the
101 * stack for the secondaries to be generated
104 // Get the pointer to the VMC
105 TVirtualMC* fluka = TFluka::GetMC();
106 // Get the stack produced from the generator
107 TVirtualMCStack* cppstack = fluka->GetStack();
110 TParticle* particle = cppstack->PopNextTrack(itrack);
112 //Exit if itrack is negative (-1). Set lsouit to false to mark last track for
116 EPISOR.lsouit = false;
117 cout << "\t* EPISOR.lsouit = " << (EPISOR.lsouit?'T':'F') << endl;
118 cout << "\t* No more particles. Exiting..." << endl;
120 cout << "<== source(" << nomore << ")" << endl;
125 //Get some info about the particle and print it
126 TVector3 polarisation;
127 particle->GetPolarisation(polarisation);
128 cout << "\t* Particle " << itrack << " retrieved..." << endl;
129 cout << "\t\t+ Name = " << particle->GetName() << endl;
130 cout << "\t\t+ PDG/Fluka code = " << particle->GetPdgCode()
131 << " / " << fluka->IdFromPDG(particle->GetPdgCode()) << endl;
132 cout << "\t\t+ P = ("
133 << particle->Px() << " , "
134 << particle->Py() << " , "
135 << particle->Pz() << " ) --> "
136 << particle->P() << " GeV" << endl;
137 /* Lstack is the stack counter: of course any time source is called it
142 //cout << "\t* Storing particle parameters in the stack, lstack = "
143 // << STACK.lstack << endl;
144 /* Wt is the weight of the particle*/
145 STACK.wt[STACK.lstack] = oneone;
146 STARS.weipri += STACK.wt[STACK.lstack];
147 /* Particle type (1=proton.....). Ijbeam is the type set by the BEAM
150 //STACK.ilo[STACK.lstack] = BEAM.ijbeam;
151 STACK.ilo[STACK.lstack] = fluka-> IdFromPDG(particle->GetPdgCode());
152 /* From this point .....
153 * Particle generation (1 for primaries)
155 STACK.lo[STACK.lstack] = 1;
156 /* User dependent flag:*/
157 STACK.louse[STACK.lstack] = 0;
158 /* User dependent spare variables:*/
160 for (ispr = 0; ispr < mkbmx1; ispr++)
161 STACK.sparek[STACK.lstack][ispr] = zerzer;
162 /* User dependent spare flags:*/
163 for (ispr = 0; ispr < mkbmx2; ispr++)
164 STACK.ispark[STACK.lstack][ispr] = 0;
165 /* Save the track number of the stack particle:*/
166 STACK.ispark[STACK.lstack][mkbmx2-1] = itrack;
168 STACK.numpar[STACK.lstack] = STACK.nparma;
169 STACK.nevent[STACK.lstack] = 0;
170 STACK.dfnear[STACK.lstack] = +zerzer;
171 /* ... to this point: don't change anything
174 STACK.agestk[STACK.lstack] = +zerzer;
175 STACK.aknshr[STACK.lstack] = -twotwo;
176 /* Group number for "low" energy neutrons, set to 0 anyway*/
177 STACK.igroup[STACK.lstack] = 0;
178 /* Kinetic energy of the particle (GeV)*/
179 //STACK.tke[STACK.lstack] =
180 //sqrt( BEAM.pbeam*BEAM.pbeam +
181 // PAPROP.am[BEAM.ijbeam+6]*PAPROP.am[BEAM.ijbeam+6] )
182 //- PAPROP.am[BEAM.ijbeam+6];
183 STACK.tke[STACK.lstack] = particle->Energy() - particle->GetMass();
185 /* Particle momentum*/
186 //STACK.pmom [STACK.lstack] = BEAM.pbeam;
187 STACK.pmom [STACK.lstack] = particle->P();
189 /* PMOM (lstack) = SQRT ( TKE (stack) * ( TKE (lstack) + TWOTWO
190 * & * AM (ILO(lstack)) ) )
193 //STACK.tx [STACK.lstack] = BEAM.tinx;
194 //STACK.ty [STACK.lstack] = BEAM.tiny;
195 //STACK.tz [STACK.lstack] = BEAM.tinz;
196 Double_t cosx = particle->Px()/particle->P();
197 Double_t cosy = particle->Py()/particle->P();
198 Double_t cosz = TMath::Sqrt(oneone - cosx*cosx - cosy*cosy);
199 if (particle->Pz() < 0.) cosz = -cosz;
200 STACK.tx [STACK.lstack] = cosx;
201 STACK.ty [STACK.lstack] = cosy;
202 STACK.tz [STACK.lstack] = cosz;
204 /* Polarization cosines:
206 //STACK.txpol [STACK.lstack] = -twotwo;
207 //STACK.typol [STACK.lstack] = +zerzer;
208 //STACK.tzpol [STACK.lstack] = +zerzer;
209 if (polarisation.Mag()) {
210 Double_t cospolx = polarisation.Px()/polarisation.Mag();
211 Double_t cospoly = polarisation.Py()/polarisation.Mag();
212 Double_t cospolz = sqrt(oneone - cospolx*cospolx - cospoly*cospoly);
213 STACK.tx [STACK.lstack] = cospolx;
214 STACK.ty [STACK.lstack] = cospoly;
215 STACK.tz [STACK.lstack] = cospolz;
218 STACK.txpol [STACK.lstack] = -twotwo;
219 STACK.typol [STACK.lstack] = +zerzer;
220 STACK.tzpol [STACK.lstack] = +zerzer;
223 /* Particle coordinates*/
224 //STACK.xa [STACK.lstack] = BEAM.xina;
225 //STACK.ya [STACK.lstack] = BEAM.yina;
226 //STACK.za [STACK.lstack] = BEAM.zina
227 //Vertext coordinates;
228 STACK.xa [STACK.lstack] = particle->Vx();
229 STACK.ya [STACK.lstack] = particle->Vy();
230 STACK.za [STACK.lstack] = particle->Vz();
232 /* Calculate the total kinetic energy of the primaries: don't change*/
233 Int_t st_ilo = STACK.ilo[STACK.lstack];
236 ((STACK.tke[STACK.lstack] + PAPROP.amdisc[st_ilo+6])
237 * STACK.wt[STACK.lstack]);
239 EPISOR.tkesum += (STACK.tke[STACK.lstack] * STACK.wt[STACK.lstack]);
241 /* Here we ask for the region number of the hitting point.
242 * NREG (LSTACK) = ...
243 * The following line makes the starting region search much more
244 * robust if particles are starting very close to a boundary:
246 geocrs( STACK.tx[STACK.lstack],
247 STACK.ty[STACK.lstack],
248 STACK.tz[STACK.lstack] );
250 georeg ( STACK.xa[STACK.lstack],
251 STACK.ya[STACK.lstack],
252 STACK.za[STACK.lstack],
253 STACK.nreg[STACK.lstack],
254 idisc);//<-- dummy return variable not used
256 /* Do not change these cards:*/
258 Int_t igeohsm2 = -11;
259 geohsm ( STACK.nhspnt[STACK.lstack], igeohsm1, igeohsm2, LTCLCM.mlattc );
260 STACK.nlattc[STACK.lstack] = LTCLCM.mlattc;
262 TVirtualMCApplication::Instance()->BeginPrimary();
263 TVirtualMCApplication::Instance()->PreTrack();
265 cout << "<== source(" << nomore << ")" << endl;