]>
Commit | Line | Data |
---|---|---|
b9d0a01d | 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 "Fcaslim.h" //(CASLIM) fluka common | |
16 | ||
17 | //Virutal MC | |
18 | #include "TFluka.h" | |
19 | #include "TVirtualMCStack.h" | |
45dc600a | 20 | #include "TVirtualMCApplication.h" |
b9d0a01d | 21 | #include "TParticle.h" |
22 | #include "TVector3.h" | |
23 | ||
24 | //Other | |
eae0fe66 | 25 | #include <Riostream.h> |
b9d0a01d | 26 | |
27 | #ifndef WIN32 | |
28 | # define source source_ | |
29 | # define geocrs geocrs_ | |
30 | # define georeg georeg_ | |
31 | # define geohsm geohsm_ | |
32 | # define soevsv soevsv_ | |
33 | #else | |
34 | # define source SOURCE | |
35 | # define geocrs GEOCRS | |
36 | # define georeg GEOREG | |
37 | # define geohsm GEOHSM | |
38 | # define soevsv SOEVSV | |
39 | #endif | |
40 | ||
b9d0a01d | 41 | extern "C" { |
42 | // | |
43 | // Prototypes for FLUKA functions | |
44 | // | |
45 | void type_of_call geocrs(Double_t &, Double_t &, Double_t &); | |
46 | void type_of_call georeg(Double_t &, Double_t &, Double_t &, | |
47 | Int_t &, Int_t &); | |
48 | void type_of_call geohsm(Int_t &, Int_t &, Int_t &, Int_t &); | |
49 | void type_of_call soevsv(); | |
50 | /* | |
51 | *----------------------------------------------------------------------* | |
52 | * * | |
53 | * Created on 07 january 1990 by Alfredo Ferrari & Paola Sala * | |
54 | * Infn - Milan * | |
55 | * * | |
56 | * Last change on 21-jun-98 by Alfredo Ferrari * | |
57 | * * | |
58 | * C++ version on 27-sep-02 by Isidro Gonzalez * | |
59 | * * | |
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. * | |
64 | * * | |
65 | *----------------------------------------------------------------------*/ | |
66 | ||
67 | void source(Int_t& nomore) { | |
68 | #ifdef METHODDEBUG | |
69 | cout << "==> source(" << nomore << ")" << endl; | |
70 | #endif | |
71 | ||
72 | cout << "\t* EPISOR.lsouit = " << (EPISOR.lsouit?'T':'F') << endl; | |
73 | ||
74 | static Bool_t lfirst = true; | |
75 | /*======================================================================* | |
76 | * * | |
77 | * BASIC VERSION * | |
78 | * * | |
79 | *======================================================================*/ | |
80 | nomore = 0; | |
81 | /* +-------------------------------------------------------------------* | |
82 | * | First call initializations:*/ | |
83 | if (lfirst) { | |
84 | ||
85 | /*| *** The following 3 cards are mandatory ***/ | |
86 | ||
87 | EPISOR.tkesum = zerzer; | |
88 | lfirst = false; | |
89 | EPISOR.lussrc = true; | |
90 | /*| *** User initialization ***/ | |
398b7205 | 91 | } else { |
92 | TVirtualMCApplication::Instance()->PostTrack(); | |
93 | TVirtualMCApplication::Instance()->FinishPrimary(); | |
b9d0a01d | 94 | } |
398b7205 | 95 | |
96 | ||
b9d0a01d | 97 | /* | |
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 | |
102 | */ | |
103 | ||
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(); | |
108 | //Get next particle | |
109 | Int_t itrack = -1; | |
22229ba5 | 110 | TParticle* particle = cppstack->PopNextTrack(itrack); |
b9d0a01d | 111 | |
112 | //Exit if itrack is negative (-1). Set lsouit to false to mark last track for | |
113 | //this event | |
114 | if (itrack<0) { | |
115 | nomore = 1; | |
116 | EPISOR.lsouit = false; | |
117 | cout << "\t* EPISOR.lsouit = " << (EPISOR.lsouit?'T':'F') << endl; | |
118 | cout << "\t* No more particles. Exiting..." << endl; | |
119 | #ifdef METHODDEBUG | |
120 | cout << "<== source(" << nomore << ")" << endl; | |
121 | #endif | |
122 | return; | |
123 | } | |
124 | ||
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; | |
b9d0a01d | 132 | cout << "\t\t+ P = (" |
133 | << particle->Px() << " , " | |
134 | << particle->Py() << " , " | |
135 | << particle->Pz() << " ) --> " | |
136 | << particle->P() << " GeV" << endl; | |
b9d0a01d | 137 | /* Lstack is the stack counter: of course any time source is called it |
138 | * must be =0 | |
139 | */ | |
45dc600a | 140 | |
b9d0a01d | 141 | STACK.lstack++; |
b1d2c71c | 142 | //cout << "\t* Storing particle parameters in the stack, lstack = " |
143 | // << STACK.lstack << endl; | |
b9d0a01d | 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 | |
148 | * card | |
149 | */ | |
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) | |
154 | */ | |
155 | STACK.lo[STACK.lstack] = 1; | |
156 | /* User dependent flag:*/ | |
157 | STACK.louse[STACK.lstack] = 0; | |
158 | /* User dependent spare variables:*/ | |
148ba0b4 | 159 | Int_t ispr = 0; |
160 | for (ispr = 0; ispr < mkbmx1; ispr++) | |
b9d0a01d | 161 | STACK.sparek[STACK.lstack][ispr] = zerzer; |
162 | /* User dependent spare flags:*/ | |
148ba0b4 | 163 | for (ispr = 0; ispr < mkbmx2; ispr++) |
b9d0a01d | 164 | STACK.ispark[STACK.lstack][ispr] = 0; |
165 | /* Save the track number of the stack particle:*/ | |
5d298556 | 166 | STACK.ispark[STACK.lstack][mkbmx2-1] = itrack; |
b9d0a01d | 167 | STACK.nparma++; |
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 | |
172 | * Particle age (s) | |
173 | */ | |
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(); | |
184 | ||
185 | /* Particle momentum*/ | |
186 | //STACK.pmom [STACK.lstack] = BEAM.pbeam; | |
187 | STACK.pmom [STACK.lstack] = particle->P(); | |
188 | ||
189 | /* PMOM (lstack) = SQRT ( TKE (stack) * ( TKE (lstack) + TWOTWO | |
190 | * & * AM (ILO(lstack)) ) ) | |
191 | * Cosines (tx,ty,tz) | |
192 | */ | |
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(); | |
57dd4539 | 198 | Double_t cosz = TMath::Sqrt(oneone - cosx*cosx - cosy*cosy); |
199 | if (particle->Pz() < 0.) cosz = -cosz; | |
b9d0a01d | 200 | STACK.tx [STACK.lstack] = cosx; |
201 | STACK.ty [STACK.lstack] = cosy; | |
202 | STACK.tz [STACK.lstack] = cosz; | |
203 | ||
204 | /* Polarization cosines: | |
205 | */ | |
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; | |
216 | } | |
217 | else { | |
218 | STACK.txpol [STACK.lstack] = -twotwo; | |
219 | STACK.typol [STACK.lstack] = +zerzer; | |
220 | STACK.tzpol [STACK.lstack] = +zerzer; | |
221 | } | |
222 | ||
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(); | |
231 | ||
b9d0a01d | 232 | /* Calculate the total kinetic energy of the primaries: don't change*/ |
233 | Int_t st_ilo = STACK.ilo[STACK.lstack]; | |
234 | if ( st_ilo != 0 ) | |
235 | EPISOR.tkesum += | |
236 | ((STACK.tke[STACK.lstack] + PAPROP.amdisc[st_ilo+6]) | |
237 | * STACK.wt[STACK.lstack]); | |
238 | else | |
239 | EPISOR.tkesum += (STACK.tke[STACK.lstack] * STACK.wt[STACK.lstack]); | |
240 | ||
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: | |
245 | */ | |
246 | geocrs( STACK.tx[STACK.lstack], | |
247 | STACK.ty[STACK.lstack], | |
248 | STACK.tz[STACK.lstack] ); | |
249 | Int_t idisc; | |
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 | |
255 | ||
256 | /* Do not change these cards:*/ | |
257 | Int_t igeohsm1 = 1; | |
258 | Int_t igeohsm2 = -11; | |
259 | geohsm ( STACK.nhspnt[STACK.lstack], igeohsm1, igeohsm2, LTCLCM.mlattc ); | |
260 | STACK.nlattc[STACK.lstack] = LTCLCM.mlattc; | |
261 | soevsv(); | |
398b7205 | 262 | TVirtualMCApplication::Instance()->BeginPrimary(); |
45dc600a | 263 | TVirtualMCApplication::Instance()->PreTrack(); |
b9d0a01d | 264 | #ifdef METHODDEBUG |
265 | cout << "<== source(" << nomore << ")" << endl; | |
266 | #endif | |
267 | } | |
268 | } |