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