]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TGeant3/gucode.cxx
Introduced PDG code everywhere and use of TParticlePDG.
[u/mrichter/AliRoot.git] / TGeant3 / gucode.cxx
1 #include "AliCallf77.h"
2 #include "TGeant3.h"
3 #include "AliRun.h"
4
5 #ifndef WIN32
6 #  define gudigi gudigi_
7 #  define guhadr guhadr_
8 #  define guout  guout_
9 #  define guphad guphad_
10 #  define gudcay gudcay_
11 #  define guiget guiget_
12 #  define guinme guinme_
13 #  define guinti guinti_
14 #  define gunear gunear_
15 #  define guskip guskip_
16 #  define guview guview_
17 #  define gupara gupara_
18 #  define gudtim gudtim_
19 #  define guplsh guplsh_
20 #  define gutrev gutrev_
21 #  define gutrak gutrak_
22 #  define guswim guswim_
23 #  define gufld  gufld_
24 #  define gustep gustep_
25 #  define gukine gukine_
26 #  define uglast uglast_
27
28 #  define gheish gheish_
29 #  define flufin flufin_
30 #  define gfmfin gfmfin_
31 #  define gpghei gpghei_
32 #  define fldist fldist_
33 #  define gfmdis gfmdis_
34 #  define ghelx3 ghelx3_
35 #  define ghelix ghelix_
36 #  define grkuta grkuta_
37 #  define gtrack gtrack_
38 #  define gtreve_root gtreve_root_
39 #  define glast  glast_
40
41 #else
42 #  define gudigi GUDIGI
43 #  define guhadr GUHADR
44 #  define guout  GUOUT
45 #  define guphad GUPHAD
46 #  define gudcay GUDCAY
47 #  define guiget GUIGET
48 #  define guinme GUINME
49 #  define guinti GUINTI
50 #  define gunear GUNEAR
51 #  define guskip GUSKIP
52 #  define guview GUVIEW
53 #  define gupara GUPARA
54 #  define gudtim GUDTIM
55 #  define guplsh GUPLSH
56 #  define gutrev GUTREV
57 #  define gutrak GUTRAK
58 #  define guswim GUSWIM
59 #  define gufld  GUFLD
60 #  define gustep GUSTEP
61 #  define gukine GUKINE
62 #  define uglast UGLAST
63
64 #  define gheish GHEISH
65 #  define flufin FLUFIN
66 #  define gfmfin GFMFIN
67 #  define gpghei GPGHEI
68 #  define fldist FLDIST
69 #  define gfmdis GFMDIS
70 #  define ghelx3 GHELX3
71 #  define ghelix GHELIX
72 #  define grkuta GRKUTA
73 #  define gtrack GTRACK
74 #  define gtreve_root GTREVE_ROOT
75 #  define glast  GLAST
76
77 #endif
78
79 extern "C" type_of_call void gheish();
80 extern "C" type_of_call void flufin();
81 extern "C" type_of_call void gfmfin();
82 extern "C" type_of_call void gpghei();
83 extern "C" type_of_call void fldist();
84 extern "C" type_of_call void gfmdis();
85 extern "C" type_of_call void ghelx3(Float_t&, Float_t&, Float_t*, Float_t*);
86 extern "C" type_of_call void ghelix(Float_t&, Float_t&, Float_t*, Float_t*);
87 extern "C" type_of_call void grkuta(Float_t&, Float_t&, Float_t*, Float_t*);
88 extern "C" type_of_call void gtrack();
89 extern "C" type_of_call void gtreve_root();
90 extern "C" type_of_call void glast();
91
92
93 extern "C" type_of_call {
94
95 //______________________________________________________________________
96 void gudigi() 
97 {
98 //
99 //    ******************************************************************
100 //    *                                                                *
101 //    *       User routine to digitize one event                       *
102 //    *                                                                *
103 //    *    ==>Called by : GTRIG                                        *
104 //    *                                                                *
105 //    ******************************************************************
106
107 }
108
109
110 //______________________________________________________________________
111 void guhadr()
112 {
113 //
114 //    ******************************************************************
115 //    *                                                                *
116 //    *       User routine to generate one hadronic interaction        *
117 //    *                                                                *
118 //    *    ==>Called by : GTHADR,GTNEUT                                *
119 //    *                                                                *
120 //    ******************************************************************
121 //
122 //
123 //    ------------------------------------------------------------------
124 //
125       TGeant3 *geant3=(TGeant3*)AliMC::GetMC();
126       Int_t ihadr=geant3->Gcphys()->ihadr;
127       if (ihadr<4)       gheish();
128       else if (ihadr==4) flufin();
129       else               gfmfin();
130 }
131
132 //______________________________________________________________________
133 void guout()
134 {
135 //
136 //    ******************************************************************
137 //    *                                                                *
138 //    *       User routine called at the end of each event             *
139 //    *                                                                *
140 //    *    ==>Called by : GTRIG                                        *
141 //    *                                                                *
142 //    ******************************************************************
143 //
144 //
145 //    ------------------------------------------------------------------
146 //
147 }
148
149 //______________________________________________________________________
150 void guphad()
151 {
152 //
153 //    ******************************************************************
154 //    *                                                                *
155 //    *       User routine to compute Hadron. inter. probabilities     *
156 //    *                                                                *
157 //    *    ==>Called by : GTHADR,GTNEUT                                *
158 //    *                                                                *
159 //    ******************************************************************
160 //
161 //
162 //    ------------------------------------------------------------------
163 //
164       TGeant3 *geant3=(TGeant3*)AliMC::GetMC();
165       Int_t ihadr=geant3->Gcphys()->ihadr;
166       if (ihadr<4)       gpghei();
167       else if (ihadr==4) fldist();
168       else               gfmdis();
169 }
170
171 //______________________________________________________________________
172 void gudcay()
173 {
174 //
175 //    ******************************************************************
176 //    *                                                                *
177 //    *       User routine to decay particles                          *
178 //    *                                                                *
179 //    *    ==>Called by : GDECAY                                       *
180 //    *                                                                *
181 //    ******************************************************************
182 //
183 //
184 //    ------------------------------------------------------------------
185 //
186 }
187
188 //______________________________________________________________________
189 void guiget(Int_t&, Int_t&, Int_t&)
190 {
191 //
192 //    ******************************************************************
193 //    *                                                                *
194 //    *       User routine for interactive control of GEANT            *
195 //    *                                                                *
196 //    *    ==>Called by : <GXINT>, GINCOM                              *
197 //    *                                                                *
198 //    ******************************************************************
199 //
200 //
201 //    ------------------------------------------------------------------
202 //
203 }
204
205 //______________________________________________________________________
206 void guinme(Float_t*, Int_t&, Float_t*, Int_t& IYES)
207 {
208 //
209 //    **********************************************
210 //    *                                            *
211 //    *    USER ROUTINE TO PROVIDE GINME FUNCTION  *
212 //    *    FOR ALL USER SHAPES IDENTIFIED BY THE   *
213 //    *    SHAPE NUMBER SH. POINT IS GIVEN IN X    *
214 //    *    THE PARAMETERS ARE GIVEN IN P. IYES IS  *
215 //    *    RETURNED 1 IF POINT IS IN, 0 IF POINT   *
216 //    *    IS OUT AND LESS THAN ZERO IF SHAPE      *
217 //    *    NUMBER IS NOT SUPPORTED.                *
218 //    *                                            *
219 //    *    ==>Called by : GINME                    *
220 //    *                                            *
221 //    **********************************************
222 //
223       IYES=-1;
224 }
225
226 //______________________________________________________________________
227 void guinti()
228 {
229 //
230 //    ******************************************************************
231 //    *                                                                *
232 //    *       User routine for interactive version                     *
233 //    *                                                                *
234 //    *    ==>Called by : <GXINT>,  GINTRI                             *
235 //    *                                                                *
236 //    ******************************************************************
237 //
238 //
239 //    ------------------------------------------------------------------
240 //
241 }
242
243 //______________________________________________________________________
244 void gunear(Int_t&, Int_t&, Float_t*, Int_t&)
245 {
246 //
247 //    ******************************************************************
248 //    *                                                                *
249 //    *    User search                                                 *
250 //    *       ISEARC to identify the given volume                      *
251 //    *       ICALL  to identify the calling routine                   *
252 //    *              1 GMEDIA like                                     *
253 //    *              2 GNEXT like                                      *
254 //    *       X      coordinates (+direction for ICALL=2)              *
255 //    *       JNEAR  address of default list of neighbours             *
256 //    *              (list to be overwriten by user)                   *
257 //    *                                                                *
258 //    *    Called by : GFTRAC, GINVOL, GTMEDI, GTNEXT, GNEXT, GMEDIA   *
259 //    *                                                                *
260 //    ******************************************************************
261 //
262 //
263 //    ------------------------------------------------------------------
264 //
265 }
266
267 //______________________________________________________________________
268 void guskip(Int_t& ISKIP)
269 {
270 //
271 //    ******************************************************************
272 //    *                                                                *
273 //    *   User routine to skip unwanted tracks                         *
274 //    *                                                                *
275 //    *   Called by : GSSTAK                                           *
276 //    *   Author    : F.Bruyant                                        *
277 //    *                                                                *
278 //    ******************************************************************
279 //
280 //
281 //    ------------------------------------------------------------------
282 //
283       ISKIP = 0;
284 }
285
286 //______________________________________________________________________
287 void guswim(Float_t& CHARGE, Float_t& STEP, Float_t* VECT, Float_t* VOUT)
288 {
289 //
290 //    ******************************************************************
291 //    *                                                                *
292 //    *       User routine to control tracking of one track            *
293 //    *       in a magnetic field                                      *
294 //    *                                                                *
295 //    *    ==>Called by : GTELEC,GTHADR,GTMUON                         *
296 //    *                                                                *
297 //    ******************************************************************
298 //
299 //
300 //    ------------------------------------------------------------------
301 //
302   TGeant3 *geant3=(TGeant3*)AliMC::GetMC();
303   Int_t ifield=geant3->Gctmed()->ifield;
304   Float_t fieldm=geant3->Gctmed()->fieldm;
305
306   if (ifield==3) {
307     Float_t fldcharge = fieldm*CHARGE;
308     ghelx3(fldcharge,STEP,VECT,VOUT);
309   }
310   else if (ifield==2) ghelix(CHARGE,STEP,VECT,VOUT);
311   else                grkuta(CHARGE,STEP,VECT,VOUT);
312 }
313
314 //______________________________________________________________________
315 void guview(Int_t&, Int_t&, DEFCHARD, Int_t& DEFCHARL)
316 {
317 //
318 //    ******************************************************************
319 //    *                                                                *
320 //    *       User routine for interactive version                     *
321 //    *                                                                *
322 //    *    ==>Called by : <GXINT>, GINC1                               *
323 //    *                                                                *
324 //    ******************************************************************
325 //
326 //
327 //    ------------------------------------------------------------------
328 //
329 }
330
331 //______________________________________________________________________
332 void gupara()
333 {
334 //
335 //    ******************************************************************
336 //    *                                                                *
337 //    *       User routine called every time a particle falls below    *
338 //    *       parametrization threshold. This routine should create    *
339 //    *       the parametrization stack, and, when this is full,       *
340 //    *       parametrize the shower and track the geantinos.          *
341 //    *                                                                *
342 //    *    ==>Called by : GTRACK                                       *
343 //    *                                                                *
344 //    ******************************************************************
345 //
346 //
347 //    ------------------------------------------------------------------
348 //
349 }
350
351 //______________________________________________________________________
352 Float_t gudtim(Float_t&, Float_t&, Int_t&, Int_t&)
353 {
354 //
355 //    ******************************************************************
356 //    *                                                                *
357 //    *       User function called by GCDRIF to return drift time      *
358 //    *                                                                *
359 //    *    ==>Called by : GCDRIF                                       *
360 //    *                                                                *
361 //    ******************************************************************
362 //
363 //
364 //    ------------------------------------------------------------------
365 //
366       return 0;
367 }
368
369
370 //______________________________________________________________________
371 Float_t guplsh(Int_t&, Int_t&)
372 {
373 //
374 //    ******************************************************************
375 //    *                                                                *
376 //    *                                                                *
377 //    *    ==>Called by : GLISUR                                       *
378 //    *                                                                *
379 //    ******************************************************************
380 //
381 //
382 //    ------------------------------------------------------------------
383 //
384 //
385 //*** By default this defines perfect smoothness
386       return 1;
387 }
388
389 //______________________________________________________________________
390 void gutrak()
391 {
392 //
393 //    ******************************************************************
394 //    *                                                                *
395 //    *       User routine to control tracking of one track            *
396 //    *                                                                *
397 //    *    ==>Called by : GTREVE                                       *
398 //    *                                                                *
399 //    ******************************************************************
400 //
401 //
402 //    ------------------------------------------------------------------
403 //
404      Int_t ndet = gAlice->Modules()->GetLast();
405      TObjArray &dets = *gAlice->Modules();
406      AliModule *module;
407      Int_t i;
408
409      for(i=0; i<=ndet; i++)
410        if((module = (AliModule*)dets[i]))
411          module->PreTrack();
412
413      gtrack();
414
415      for(i=0; i<=ndet; i++)
416        if((module = (AliModule*)dets[i]))
417          module->PostTrack();
418 }
419
420 //______________________________________________________________________
421 void gutrev()
422 {
423 //
424 //    ******************************************************************
425 //    *                                                                *
426 //    *       User routine to control tracking of one event            *
427 //    *                                                                *
428 //    *    ==>Called by : GTRIG                                        *
429 //    *                                                                *
430 //    ******************************************************************
431 //
432 //
433 //    ------------------------------------------------------------------
434 //
435   gtreve_root();
436 }
437
438
439 //______________________________________________________________________
440 void gufld(Float_t *x, Float_t *b)
441 {
442       if(gAlice->Field()) {
443          gAlice->Field()->Field(x,b);
444       } else {
445          printf("No mag field defined!\n");
446          b[0]=b[1]=b[2]=0;
447       }
448 }
449
450 //______________________________________________________________________
451 void gustep()
452 {
453 //
454 //    ******************************************************************
455 //    *                                                                *
456 //    *       User routine called at the end of each tracking step     *
457 //    *       INWVOL is different from 0 when the track has reached    *
458 //    *              a volume boundary                                 *
459 //    *       ISTOP is different from 0 if the track has stopped       *
460 //    *                                                                *
461 //    *    ==>Called by : GTRACK                                       *
462 //    *                                                                *
463 //    ******************************************************************
464 //
465
466   AliMC* pMC = AliMC::GetMC();
467   TGeant3 *geant3=(TGeant3*)pMC;
468
469   Float_t x[3];
470   Float_t r;
471   Int_t ipp, jk, id, nt;
472   Float_t polar[3]={0,0,0};
473   char chproc[11];
474   
475   // --- Standard GEANT debug routine 
476   if(geant3->Gcflag()->idebug) geant3->Gdebug();
477
478   //     Stop particle if outside user defined tracking region 
479   pMC->TrackPosition(x);
480   r=TMath::Sqrt(x[0]*x[0]+x[1]*x[1]);
481   if (r > gAlice->TrackingRmax() || TMath::Abs(x[2]) > gAlice->TrackingZmax()) {
482         pMC->StopTrack();
483   }
484   // --- Add new created particles 
485   if (pMC->NSecondaries() > 0) {
486     pMC->ProdProcess(chproc);
487     for (jk = 0; jk < geant3->Gcking()->ngkine; ++jk) {
488       ipp = Int_t (geant3->Gcking()->gkin[jk][4]+0.5);
489       // --- Skip neutrinos! 
490       if (ipp != 4) {
491         gAlice->SetTrack(1,gAlice->CurrentTrack(),gMC->PDGFromId(ipp), geant3->Gcking()->gkin[jk], 
492                          geant3->Gckin3()->gpos[jk], polar,geant3->Gctrak()->tofg, chproc, nt);
493       }
494     }
495   }
496
497   // --- Particle leaving the setup ?
498   if (!pMC->TrackOut()) 
499     if ((id=gAlice->DetFromMate(geant3->Gctmed()->numed)) >= 0) gAlice->StepManager(id);
500 }
501
502 //______________________________________________________________________
503 void gukine ()
504 {
505 //
506 //    ******************************************************************
507 //    *                                                                *
508 //    *       Read or Generates Kinematics for primary tracks          *
509 //    *                                                                *
510 //    *    ==>Called by : GTRIG                                        *
511 //    *                                                                *
512 //    ******************************************************************
513 //
514 //
515 //    ------------------------------------------------------------------
516 //
517   gAlice->Generator()->Generate();
518 }
519
520
521 //______________________________________________________________________
522 void uglast()
523 {
524 //
525 //    ******************************************************************
526 //    *                                                                *
527 //    *       User routine called at the end of the run                *
528 //    *                                                                *
529 //    *    ==>Called by : GRUN                                         *
530 //    *                                                                *
531 //    ******************************************************************
532 //
533 //
534 }
535 }