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