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 ***/
93 * +-------------------------------------------------------------------*
94 * Push one source particle to the stack. Note that you could as well
95 * push many but this way we reserve a maximum amount of space in the
96 * stack for the secondaries to be generated
99 // Get the pointer to the VMC
100 TVirtualMC* fluka = TFluka::GetMC();
101 // Get the stack produced from the generator
102 TVirtualMCStack* cppstack = fluka->GetStack();
104 if (STACK.lstack != 1) {
105 TVirtualMCApplication::Instance()->PostTrack();
106 TVirtualMCApplication::Instance()->FinishPrimary();
109 TParticle* particle = cppstack->GetNextTrack(itrack);
111 //Exit if itrack is negative (-1). Set lsouit to false to mark last track for
115 EPISOR.lsouit = false;
116 cout << "\t* EPISOR.lsouit = " << (EPISOR.lsouit?'T':'F') << endl;
117 cout << "\t* No more particles. Exiting..." << endl;
119 cout << "<== source(" << nomore << ")" << endl;
124 //Get some info about the particle and print it
125 TVector3 polarisation;
126 particle->GetPolarisation(polarisation);
127 cout << "\t* Particle " << itrack << " retrieved..." << endl;
128 cout << "\t\t+ Name = " << particle->GetName() << endl;
129 cout << "\t\t+ PDG/Fluka code = " << particle->GetPdgCode()
130 << " / " << fluka->IdFromPDG(particle->GetPdgCode()) << endl;
131 cout << "\t\t+ P = ("
132 << particle->Px() << " , "
133 << particle->Py() << " , "
134 << particle->Pz() << " ) --> "
135 << particle->P() << " GeV" << endl;
136 /* Lstack is the stack counter: of course any time source is called it
141 //cout << "\t* Storing particle parameters in the stack, lstack = "
142 // << STACK.lstack << endl;
143 /* Wt is the weight of the particle*/
144 STACK.wt[STACK.lstack] = oneone;
145 STARS.weipri += STACK.wt[STACK.lstack];
146 /* Particle type (1=proton.....). Ijbeam is the type set by the BEAM
149 //STACK.ilo[STACK.lstack] = BEAM.ijbeam;
150 STACK.ilo[STACK.lstack] = fluka-> IdFromPDG(particle->GetPdgCode());
151 /* From this point .....
152 * Particle generation (1 for primaries)
154 STACK.lo[STACK.lstack] = 1;
155 /* User dependent flag:*/
156 STACK.louse[STACK.lstack] = 0;
157 /* User dependent spare variables:*/
159 for (ispr = 0; ispr < mkbmx1; ispr++)
160 STACK.sparek[STACK.lstack][ispr] = zerzer;
161 /* User dependent spare flags:*/
162 for (ispr = 0; ispr < mkbmx2; ispr++)
163 STACK.ispark[STACK.lstack][ispr] = 0;
164 /* Save the track number of the stack particle:*/
165 STACK.ispark[STACK.lstack][mkbmx2-1] = itrack;
167 STACK.numpar[STACK.lstack] = STACK.nparma;
168 STACK.nevent[STACK.lstack] = 0;
169 STACK.dfnear[STACK.lstack] = +zerzer;
170 /* ... to this point: don't change anything
173 STACK.agestk[STACK.lstack] = +zerzer;
174 STACK.aknshr[STACK.lstack] = -twotwo;
175 /* Group number for "low" energy neutrons, set to 0 anyway*/
176 STACK.igroup[STACK.lstack] = 0;
177 /* Kinetic energy of the particle (GeV)*/
178 //STACK.tke[STACK.lstack] =
179 //sqrt( BEAM.pbeam*BEAM.pbeam +
180 // PAPROP.am[BEAM.ijbeam+6]*PAPROP.am[BEAM.ijbeam+6] )
181 //- PAPROP.am[BEAM.ijbeam+6];
182 STACK.tke[STACK.lstack] = particle->Energy() - particle->GetMass();
184 /* Particle momentum*/
185 //STACK.pmom [STACK.lstack] = BEAM.pbeam;
186 STACK.pmom [STACK.lstack] = particle->P();
188 /* PMOM (lstack) = SQRT ( TKE (stack) * ( TKE (lstack) + TWOTWO
189 * & * AM (ILO(lstack)) ) )
192 //STACK.tx [STACK.lstack] = BEAM.tinx;
193 //STACK.ty [STACK.lstack] = BEAM.tiny;
194 //STACK.tz [STACK.lstack] = BEAM.tinz;
195 Double_t cosx = particle->Px()/particle->P();
196 Double_t cosy = particle->Py()/particle->P();
197 Double_t cosz = TMath::Sqrt(oneone - cosx*cosx - cosy*cosy);
198 if (particle->Pz() < 0.) cosz = -cosz;
199 STACK.tx [STACK.lstack] = cosx;
200 STACK.ty [STACK.lstack] = cosy;
201 STACK.tz [STACK.lstack] = cosz;
203 /* Polarization cosines:
205 //STACK.txpol [STACK.lstack] = -twotwo;
206 //STACK.typol [STACK.lstack] = +zerzer;
207 //STACK.tzpol [STACK.lstack] = +zerzer;
208 if (polarisation.Mag()) {
209 Double_t cospolx = polarisation.Px()/polarisation.Mag();
210 Double_t cospoly = polarisation.Py()/polarisation.Mag();
211 Double_t cospolz = sqrt(oneone - cospolx*cospolx - cospoly*cospoly);
212 STACK.tx [STACK.lstack] = cospolx;
213 STACK.ty [STACK.lstack] = cospoly;
214 STACK.tz [STACK.lstack] = cospolz;
217 STACK.txpol [STACK.lstack] = -twotwo;
218 STACK.typol [STACK.lstack] = +zerzer;
219 STACK.tzpol [STACK.lstack] = +zerzer;
222 /* Particle coordinates*/
223 //STACK.xa [STACK.lstack] = BEAM.xina;
224 //STACK.ya [STACK.lstack] = BEAM.yina;
225 //STACK.za [STACK.lstack] = BEAM.zina
226 //Vertext coordinates;
227 STACK.xa [STACK.lstack] = particle->Vx();
228 STACK.ya [STACK.lstack] = particle->Vy();
229 STACK.za [STACK.lstack] = particle->Vz();
231 /* Calculate the total kinetic energy of the primaries: don't change*/
232 Int_t st_ilo = STACK.ilo[STACK.lstack];
235 ((STACK.tke[STACK.lstack] + PAPROP.amdisc[st_ilo+6])
236 * STACK.wt[STACK.lstack]);
238 EPISOR.tkesum += (STACK.tke[STACK.lstack] * STACK.wt[STACK.lstack]);
240 /* Here we ask for the region number of the hitting point.
241 * NREG (LSTACK) = ...
242 * The following line makes the starting region search much more
243 * robust if particles are starting very close to a boundary:
245 geocrs( STACK.tx[STACK.lstack],
246 STACK.ty[STACK.lstack],
247 STACK.tz[STACK.lstack] );
249 georeg ( STACK.xa[STACK.lstack],
250 STACK.ya[STACK.lstack],
251 STACK.za[STACK.lstack],
252 STACK.nreg[STACK.lstack],
253 idisc);//<-- dummy return variable not used
255 /* Do not change these cards:*/
257 Int_t igeohsm2 = -11;
258 geohsm ( STACK.nhspnt[STACK.lstack], igeohsm1, igeohsm2, LTCLCM.mlattc );
259 STACK.nlattc[STACK.lstack] = LTCLCM.mlattc;
261 TVirtualMCApplication::Instance()->PreTrack();
263 cout << "<== source(" << nomore << ")" << endl;