many macro functions are now methodes of AliRICH
[u/mrichter/AliRoot.git] / TFluka / TFluka.cxx
CommitLineData
829fb838 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
18//
19// Realisation of the TVirtualMC interface for the FLUKA code
20// (See official web side http://www.fluka.org/).
21//
22// This implementation makes use of the TGeo geometry modeller.
23// User configuration is via automatic generation of FLUKA input cards.
24//
25// Authors:
26// A. Fasso
27// E. Futo
28// A. Gheata
29// A. Morsch
30//
31
32#include <Riostream.h>
33
829fb838 34#include "TFluka.h"
35#include "TCallf77.h" //For the fortran calls
36#include "Fdblprc.h" //(DBLPRC) fluka common
37#include "Fepisor.h" //(EPISOR) fluka common
07f5b33e 38#include "Ffinuc.h" //(FINUC) fluka common
829fb838 39#include "Fiounit.h" //(IOUNIT) fluka common
40#include "Fpaprop.h" //(PAPROP) fluka common
41#include "Fpart.h" //(PART) fluka common
42#include "Ftrackr.h" //(TRACKR) fluka common
43#include "Fpaprop.h" //(PAPROP) fluka common
44#include "Ffheavy.h" //(FHEAVY) fluka common
3a625972 45#include "Fopphst.h" //(OPPHST) fluka common
07f5b33e 46#include "Fstack.h" //(STACK) fluka common
47#include "Fstepsz.h" //(STEPSZ) fluka common
7b203b6e 48#include "Fopphst.h" //(OPPHST) fluka common
829fb838 49
50#include "TVirtualMC.h"
3a625972 51#include "TMCProcess.h"
829fb838 52#include "TGeoManager.h"
53#include "TGeoMaterial.h"
54#include "TGeoMedium.h"
55#include "TFlukaMCGeometry.h"
6f5667d1 56#include "TGeoMCGeometry.h"
829fb838 57#include "TFlukaCerenkov.h"
1df5fa54 58#include "TFlukaConfigOption.h"
b496f27c 59#include "TFlukaScoringOption.h"
829fb838 60#include "TLorentzVector.h"
b496f27c 61#include "TArrayI.h"
829fb838 62
63// Fluka methods that may be needed.
64#ifndef WIN32
65# define flukam flukam_
66# define fluka_openinp fluka_openinp_
67# define fluka_closeinp fluka_closeinp_
68# define mcihad mcihad_
69# define mpdgha mpdgha_
70#else
71# define flukam FLUKAM
72# define fluka_openinp FLUKA_OPENINP
73# define fluka_closeinp FLUKA_CLOSEINP
74# define mcihad MCIHAD
75# define mpdgha MPDGHA
76#endif
77
78extern "C"
79{
80 //
81 // Prototypes for FLUKA functions
82 //
83 void type_of_call flukam(const int&);
84 void type_of_call fluka_openinp(const int&, DEFCHARA);
85 void type_of_call fluka_closeinp(const int&);
86 int type_of_call mcihad(const int&);
87 int type_of_call mpdgha(const int&);
88}
89
90//
91// Class implementation for ROOT
92//
93ClassImp(TFluka)
94
95//
96//----------------------------------------------------------------------------
97// TFluka constructors and destructors.
98//______________________________________________________________________________
99TFluka::TFluka()
100 :TVirtualMC(),
101 fVerbosityLevel(0),
1df5fa54 102 fInputFileName(""),
103 fProcesses(0),
104 fCuts(0),
105 fUserScore(0)
829fb838 106{
107 //
108 // Default constructor
109 //
110 fGeneratePemf = kFALSE;
111 fNVolumes = 0;
112 fCurrentFlukaRegion = -1;
113 fGeom = 0;
114 fMCGeo = 0;
115 fMaterials = 0;
116 fDummyBoundary = 0;
117 fFieldFlag = 1;
bd3d5c8a 118 fStopped = 0;
b496f27c 119 fStopEvent = 0;
120 fStopRun = 0;
121 fNEvent = 0;
829fb838 122}
123
124//______________________________________________________________________________
125TFluka::TFluka(const char *title, Int_t verbosity, Bool_t isRootGeometrySupported)
126 :TVirtualMC("TFluka",title, isRootGeometrySupported),
127 fVerbosityLevel(verbosity),
128 fInputFileName(""),
129 fTrackIsEntering(0),
130 fTrackIsExiting(0),
1df5fa54 131 fTrackIsNew(0),
132 fProcesses(new TObjArray(100)),
133 fCuts(new TObjArray(100)),
134 fUserScore(new TObjArray(100))
829fb838 135{
136 // create geometry interface
7f13be31 137 if (fVerbosityLevel >=3)
138 cout << "<== TFluka::TFluka(" << title << ") constructor called." << endl;
139 SetCoreInputFileName();
140 SetInputFileName();
141 SetGeneratePemf(kFALSE);
829fb838 142 fNVolumes = 0;
143 fCurrentFlukaRegion = -1;
144 fDummyBoundary = 0;
145 fFieldFlag = 1;
146 fGeneratePemf = kFALSE;
147 fMCGeo = new TGeoMCGeometry("MCGeo", "TGeo Implementation of VirtualMCGeometry", kTRUE);
3b8c325d 148 fGeom = new TFlukaMCGeometry("geom", "FLUKA VMC Geometry");
829fb838 149 if (verbosity > 2) fGeom->SetDebugMode(kTRUE);
150 fMaterials = 0;
bd3d5c8a 151 fStopped = 0;
b496f27c 152 fStopEvent = 0;
153 fStopRun = 0;
154 fNEvent = 0;
829fb838 155}
156
157//______________________________________________________________________________
158TFluka::~TFluka() {
159// Destructor
1df5fa54 160 if (fVerbosityLevel >=3)
161 cout << "<== TFluka::~TFluka() destructor called." << endl;
162
163 delete fGeom;
164 delete fMCGeo;
165
166 if (fCuts) {
167 fCuts->Delete();
168 delete fCuts;
169 }
170
171 if (fProcesses) {
172 fProcesses->Delete();
173 delete fProcesses;
174 }
175
176
829fb838 177}
178
179//
180//______________________________________________________________________________
181// TFluka control methods
182//______________________________________________________________________________
183void TFluka::Init() {
184//
185// Geometry initialisation
186//
187 if (fVerbosityLevel >=3) cout << "==> TFluka::Init() called." << endl;
188
189 if (!gGeoManager) new TGeoManager("geom", "FLUKA geometry");
190 fApplication->ConstructGeometry();
191 TGeoVolume *top = (TGeoVolume*)gGeoManager->GetListOfVolumes()->First();
192 gGeoManager->SetTopVolume(top);
193 gGeoManager->CloseGeometry("di");
194 gGeoManager->DefaultColors(); // to be removed
195 fNVolumes = fGeom->NofVolumes();
196 fGeom->CreateFlukaMatFile("flukaMat.inp");
197 if (fVerbosityLevel >=3) {
198 printf("== Number of volumes: %i\n ==", fNVolumes);
199 cout << "\t* InitPhysics() - Prepare input file to be called" << endl;
200 }
3b8c325d 201 // now we have TGeo geometry created and we have to patch FlukaVmc.inp
829fb838 202 // with the material mapping file FlukaMat.inp
203}
204
205
206//______________________________________________________________________________
207void TFluka::FinishGeometry() {
208//
209// Build-up table with region to medium correspondance
210//
211 if (fVerbosityLevel >=3) {
212 cout << "==> TFluka::FinishGeometry() called." << endl;
213 printf("----FinishGeometry - nothing to do with TGeo\n");
214 cout << "<== TFluka::FinishGeometry() called." << endl;
215 }
216}
217
218//______________________________________________________________________________
219void TFluka::BuildPhysics() {
220//
221// Prepare FLUKA input files and call FLUKA physics initialisation
222//
223
224 if (fVerbosityLevel >=3)
225 cout << "==> TFluka::BuildPhysics() called." << endl;
226// Prepare input file with the current physics settings
227 InitPhysics();
228 cout << "\t* InitPhysics() - Prepare input file was called" << endl;
229
230 if (fVerbosityLevel >=2)
231 cout << "\t* Changing lfdrtr = (" << (GLOBAL.lfdrtr?'T':'F')
232 << ") in fluka..." << endl;
233 GLOBAL.lfdrtr = true;
234
235 if (fVerbosityLevel >=2)
236 cout << "\t* Opening file " << fInputFileName << endl;
237 const char* fname = fInputFileName;
238 fluka_openinp(lunin, PASSCHARA(fname));
239
240 if (fVerbosityLevel >=2)
241 cout << "\t* Calling flukam..." << endl;
242 flukam(1);
243
244 if (fVerbosityLevel >=2)
245 cout << "\t* Closing file " << fInputFileName << endl;
246 fluka_closeinp(lunin);
247
248 FinishGeometry();
249
250 if (fVerbosityLevel >=3)
251 cout << "<== TFluka::Init() called." << endl;
252
253
254 if (fVerbosityLevel >=3)
255 cout << "<== TFluka::BuildPhysics() called." << endl;
256}
257
258//______________________________________________________________________________
259void TFluka::ProcessEvent() {
260//
261// Process one event
262//
b496f27c 263 if (fStopRun) {
264 printf("User Run Abortion: No more events handled !\n");
265 fNEvent += 1;
266 return;
267 }
268
269 if (fVerbosityLevel >=3)
270 cout << "==> TFluka::ProcessEvent() called." << endl;
271 fApplication->GeneratePrimaries();
272 EPISOR.lsouit = true;
273 flukam(1);
274 if (fVerbosityLevel >=3)
275 cout << "<== TFluka::ProcessEvent() called." << endl;
276 //
277 // Increase event number
278 //
279 fNEvent += 1;
829fb838 280}
281
282//______________________________________________________________________________
283Bool_t TFluka::ProcessRun(Int_t nevent) {
284//
285// Run steering
286//
287
288 if (fVerbosityLevel >=3)
289 cout << "==> TFluka::ProcessRun(" << nevent << ") called."
290 << endl;
291
292 if (fVerbosityLevel >=2) {
293 cout << "\t* GLOBAL.fdrtr = " << (GLOBAL.lfdrtr?'T':'F') << endl;
294 cout << "\t* Calling flukam again..." << endl;
295 }
296
297 fApplication->InitGeometry();
298 Int_t todo = TMath::Abs(nevent);
299 for (Int_t ev = 0; ev < todo; ev++) {
300 fApplication->BeginEvent();
301 ProcessEvent();
302 fApplication->FinishEvent();
303 }
304
305 if (fVerbosityLevel >=3)
306 cout << "<== TFluka::ProcessRun(" << nevent << ") called."
307 << endl;
308 return kTRUE;
309}
310
311//_____________________________________________________________________________
312// methods for building/management of geometry
313
314// functions from GCONS
315//____________________________________________________________________________
316void TFluka::Gfmate(Int_t imat, char *name, Float_t &a, Float_t &z,
317 Float_t &dens, Float_t &radl, Float_t &absl,
318 Float_t* /*ubuf*/, Int_t& /*nbuf*/) {
319//
320 TGeoMaterial *mat;
321 TIter next (gGeoManager->GetListOfMaterials());
322 while ((mat = (TGeoMaterial*)next())) {
323 if (mat->GetUniqueID() == (UInt_t)imat) break;
324 }
325 if (!mat) {
326 Error("Gfmate", "no material with index %i found", imat);
327 return;
328 }
329 sprintf(name, "%s", mat->GetName());
330 a = mat->GetA();
331 z = mat->GetZ();
332 dens = mat->GetDensity();
333 radl = mat->GetRadLen();
334 absl = mat->GetIntLen();
335}
336
337//______________________________________________________________________________
338void TFluka::Gfmate(Int_t imat, char *name, Double_t &a, Double_t &z,
339 Double_t &dens, Double_t &radl, Double_t &absl,
340 Double_t* /*ubuf*/, Int_t& /*nbuf*/) {
341//
342 TGeoMaterial *mat;
343 TIter next (gGeoManager->GetListOfMaterials());
344 while ((mat = (TGeoMaterial*)next())) {
345 if (mat->GetUniqueID() == (UInt_t)imat) break;
346 }
347 if (!mat) {
348 Error("Gfmate", "no material with index %i found", imat);
349 return;
350 }
351 sprintf(name, "%s", mat->GetName());
352 a = mat->GetA();
353 z = mat->GetZ();
354 dens = mat->GetDensity();
355 radl = mat->GetRadLen();
356 absl = mat->GetIntLen();
357}
358
359// detector composition
360//______________________________________________________________________________
361void TFluka::Material(Int_t& kmat, const char* name, Double_t a,
362 Double_t z, Double_t dens, Double_t radl, Double_t absl,
363 Float_t* buf, Int_t nwbuf) {
364//
365 Double_t* dbuf = fGeom->CreateDoubleArray(buf, nwbuf);
366 Material(kmat, name, a, z, dens, radl, absl, dbuf, nwbuf);
367 delete [] dbuf;
368}
369
370//______________________________________________________________________________
371void TFluka::Material(Int_t& kmat, const char* name, Double_t a,
372 Double_t z, Double_t dens, Double_t radl, Double_t absl,
373 Double_t* /*buf*/, Int_t /*nwbuf*/) {
374//
375 TGeoMaterial *mat;
376 kmat = gGeoManager->GetListOfMaterials()->GetSize();
377 if ((z-Int_t(z)) > 1E-3) {
378 mat = fGeom->GetMakeWrongMaterial(z);
379 if (mat) {
380 mat->SetRadLen(radl,absl);
381 mat->SetUniqueID(kmat);
382 return;
383 }
384 }
385 gGeoManager->Material(name, a, z, dens, kmat, radl, absl);
386}
387
388//______________________________________________________________________________
389void TFluka::Mixture(Int_t& kmat, const char *name, Float_t *a,
390 Float_t *z, Double_t dens, Int_t nlmat, Float_t *wmat) {
391//
392 Double_t* da = fGeom->CreateDoubleArray(a, TMath::Abs(nlmat));
393 Double_t* dz = fGeom->CreateDoubleArray(z, TMath::Abs(nlmat));
394 Double_t* dwmat = fGeom->CreateDoubleArray(wmat, TMath::Abs(nlmat));
395
396 Mixture(kmat, name, da, dz, dens, nlmat, dwmat);
397 for (Int_t i=0; i<nlmat; i++) {
398 a[i] = da[i]; z[i] = dz[i]; wmat[i] = dwmat[i];
399 }
400
401 delete [] da;
402 delete [] dz;
403 delete [] dwmat;
404}
405
406//______________________________________________________________________________
407void TFluka::Mixture(Int_t& kmat, const char *name, Double_t *a,
408 Double_t *z, Double_t dens, Int_t nlmat, Double_t *wmat) {
409//
410 // Defines mixture OR COMPOUND IMAT as composed by
411 // THE BASIC NLMAT materials defined by arrays A,Z and WMAT
412 //
413 // If NLMAT > 0 then wmat contains the proportion by
414 // weights of each basic material in the mixture.
415 //
416 // If nlmat < 0 then WMAT contains the number of atoms
417 // of a given kind into the molecule of the COMPOUND
418 // In this case, WMAT in output is changed to relative
419 // weigths.
420 //
421 Int_t i,j;
422 if (nlmat < 0) {
423 nlmat = - nlmat;
424 Double_t amol = 0;
425 for (i=0;i<nlmat;i++) {
426 amol += a[i]*wmat[i];
427 }
428 for (i=0;i<nlmat;i++) {
429 wmat[i] *= a[i]/amol;
430 }
431 }
432 kmat = gGeoManager->GetListOfMaterials()->GetSize();
433 // Check if we have elements with fractional Z
434 TGeoMaterial *mat = 0;
435 TGeoMixture *mix = 0;
436 Bool_t mixnew = kFALSE;
437 for (i=0; i<nlmat; i++) {
438 if (z[i]-Int_t(z[i]) < 1E-3) continue;
439 // We have found an element with fractional Z -> loop mixtures to look for it
440 for (j=0; j<kmat; j++) {
441 mat = (TGeoMaterial*)gGeoManager->GetListOfMaterials()->At(j);
442 if (!mat) break;
443 if (!mat->IsMixture()) continue;
444 mix = (TGeoMixture*)mat;
445 if (TMath::Abs(z[i]-mix->GetZ()) >1E-3) continue;
446// printf(" FOUND component %i as mixture %s\n", i, mat->GetName());
447 mixnew = kTRUE;
448 break;
449 }
450 if (!mixnew) Warning("Mixture","%s : cannot find component %i with fractional Z=%f\n", name, i, z[i]);
451 break;
452 }
453 if (mixnew) {
454 Int_t nlmatnew = nlmat+mix->GetNelements()-1;
455 Double_t *anew = new Double_t[nlmatnew];
456 Double_t *znew = new Double_t[nlmatnew];
457 Double_t *wmatnew = new Double_t[nlmatnew];
458 Int_t ind=0;
459 for (j=0; j<nlmat; j++) {
460 if (j==i) continue;
461 anew[ind] = a[j];
462 znew[ind] = z[j];
463 wmatnew[ind] = wmat[j];
464 ind++;
465 }
466 for (j=0; j<mix->GetNelements(); j++) {
467 anew[ind] = mix->GetAmixt()[j];
468 znew[ind] = mix->GetZmixt()[j];
469 wmatnew[ind] = wmat[i]*mix->GetWmixt()[j];
470 ind++;
471 }
472 Mixture(kmat, name, anew, znew, dens, nlmatnew, wmatnew);
473 delete [] anew;
474 delete [] znew;
475 delete [] wmatnew;
476 return;
477 }
478 // Now we need to compact identical elements within the mixture
479 // First check if this happens
480 mixnew = kFALSE;
481 for (i=0; i<nlmat-1; i++) {
482 for (j=i+1; j<nlmat; j++) {
483 if (z[i] == z[j]) {
484 mixnew = kTRUE;
485 break;
486 }
487 }
488 if (mixnew) break;
489 }
490 if (mixnew) {
491 Int_t nlmatnew = 0;
492 Double_t *anew = new Double_t[nlmat];
493 Double_t *znew = new Double_t[nlmat];
494 memset(znew, 0, nlmat*sizeof(Double_t));
495 Double_t *wmatnew = new Double_t[nlmat];
496 Bool_t skipi;
497 for (i=0; i<nlmat; i++) {
498 skipi = kFALSE;
499 for (j=0; j<nlmatnew; j++) {
500 if (z[i] == z[j]) {
501 wmatnew[j] += wmat[i];
502 skipi = kTRUE;
503 break;
504 }
505 }
506 if (skipi) continue;
507 anew[nlmatnew] = a[i];
508 znew[nlmatnew] = z[i];
509 wmatnew[nlmatnew] = wmat[i];
510 nlmatnew++;
511 }
512 Mixture(kmat, name, anew, znew, dens, nlmatnew, wmatnew);
513 delete [] anew;
514 delete [] znew;
515 delete [] wmatnew;
516 return;
517 }
518 gGeoManager->Mixture(name, a, z, dens, nlmat, wmat, kmat);
519}
520
521//______________________________________________________________________________
522void TFluka::Medium(Int_t& kmed, const char *name, Int_t nmat,
523 Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd,
524 Double_t stemax, Double_t deemax, Double_t epsil,
525 Double_t stmin, Float_t* ubuf, Int_t nbuf) {
b2129742 526 // Define a medium
527 //
829fb838 528 kmed = gGeoManager->GetListOfMedia()->GetSize()+1;
529 fMCGeo->Medium(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax,
530 epsil, stmin, ubuf, nbuf);
531}
532
533//______________________________________________________________________________
534void TFluka::Medium(Int_t& kmed, const char *name, Int_t nmat,
535 Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd,
536 Double_t stemax, Double_t deemax, Double_t epsil,
537 Double_t stmin, Double_t* ubuf, Int_t nbuf) {
b2129742 538 // Define a medium
539 //
829fb838 540 kmed = gGeoManager->GetListOfMedia()->GetSize()+1;
541 fMCGeo->Medium(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax,
542 epsil, stmin, ubuf, nbuf);
543}
544
545//______________________________________________________________________________
546void TFluka::Matrix(Int_t& krot, Double_t thetaX, Double_t phiX,
547 Double_t thetaY, Double_t phiY, Double_t thetaZ,
548 Double_t phiZ) {
549//
550 krot = gGeoManager->GetListOfMatrices()->GetEntriesFast();
551 fMCGeo->Matrix(krot, thetaX, phiX, thetaY, phiY, thetaZ, phiZ);
552}
553
554//______________________________________________________________________________
555void TFluka::Gstpar(Int_t itmed, const char* param, Double_t parval) {
556//
557//
7b203b6e 558// Check if material is used
559 if (fVerbosityLevel >=3)
560 printf("Gstpar called with %6d %5s %12.4e %6d\n", itmed, param, parval, fGeom->GetFlukaMaterial(itmed));
561 Int_t* reglist;
562 Int_t nreg;
c1c801f9 563 reglist = fGeom->GetMaterialList(fGeom->GetFlukaMaterial(itmed), nreg);
564 if (nreg == 0) {
565 return;
566 }
567
7b203b6e 568//
829fb838 569 Bool_t process = kFALSE;
570 if (strncmp(param, "DCAY", 4) == 0 ||
571 strncmp(param, "PAIR", 4) == 0 ||
572 strncmp(param, "COMP", 4) == 0 ||
573 strncmp(param, "PHOT", 4) == 0 ||
574 strncmp(param, "PFIS", 4) == 0 ||
575 strncmp(param, "DRAY", 4) == 0 ||
576 strncmp(param, "ANNI", 4) == 0 ||
577 strncmp(param, "BREM", 4) == 0 ||
578 strncmp(param, "MUNU", 4) == 0 ||
579 strncmp(param, "CKOV", 4) == 0 ||
580 strncmp(param, "HADR", 4) == 0 ||
581 strncmp(param, "LOSS", 4) == 0 ||
582 strncmp(param, "MULS", 4) == 0 ||
583 strncmp(param, "RAYL", 4) == 0)
584 {
585 process = kTRUE;
586 }
587 if (process) {
588 SetProcess(param, Int_t (parval), fGeom->GetFlukaMaterial(itmed));
589 } else {
590 SetCut(param, parval, fGeom->GetFlukaMaterial(itmed));
591 }
592}
593
594// functions from GGEOM
595//_____________________________________________________________________________
596void TFluka::Gsatt(const char *name, const char *att, Int_t val)
597{
6f5667d1 598 // Set visualisation attributes for one volume
829fb838 599 char vname[5];
600 fGeom->Vname(name,vname);
601 char vatt[5];
602 fGeom->Vname(att,vatt);
603 gGeoManager->SetVolumeAttribute(vname, vatt, val);
604}
605
606//______________________________________________________________________________
607Int_t TFluka::Gsvolu(const char *name, const char *shape, Int_t nmed,
608 Float_t *upar, Int_t np) {
609//
610 return fMCGeo->Gsvolu(name, shape, nmed, upar, np);
611}
612
613//______________________________________________________________________________
614Int_t TFluka::Gsvolu(const char *name, const char *shape, Int_t nmed,
615 Double_t *upar, Int_t np) {
616//
617 return fMCGeo->Gsvolu(name, shape, nmed, upar, np);
618}
619
620//______________________________________________________________________________
621void TFluka::Gsdvn(const char *name, const char *mother, Int_t ndiv,
622 Int_t iaxis) {
623//
624 fMCGeo->Gsdvn(name, mother, ndiv, iaxis);
625}
626
627//______________________________________________________________________________
628void TFluka::Gsdvn2(const char *name, const char *mother, Int_t ndiv,
629 Int_t iaxis, Double_t c0i, Int_t numed) {
630//
631 fMCGeo->Gsdvn2(name, mother, ndiv, iaxis, c0i, numed);
632}
633
634//______________________________________________________________________________
635void TFluka::Gsdvt(const char *name, const char *mother, Double_t step,
636 Int_t iaxis, Int_t numed, Int_t ndvmx) {
637//
638 fMCGeo->Gsdvt(name, mother, step, iaxis, numed, ndvmx);
639}
640
641//______________________________________________________________________________
642void TFluka::Gsdvt2(const char *name, const char *mother, Double_t step,
643 Int_t iaxis, Double_t c0, Int_t numed, Int_t ndvmx) {
644//
645 fMCGeo->Gsdvt2(name, mother, step, iaxis, c0, numed, ndvmx);
646}
647
648//______________________________________________________________________________
649void TFluka::Gsord(const char * /*name*/, Int_t /*iax*/) {
650//
651// Nothing to do with TGeo
652}
653
654//______________________________________________________________________________
655void TFluka::Gspos(const char *name, Int_t nr, const char *mother,
656 Double_t x, Double_t y, Double_t z, Int_t irot,
657 const char *konly) {
658//
659 fMCGeo->Gspos(name, nr, mother, x, y, z, irot, konly);
660}
661
662//______________________________________________________________________________
663void TFluka::Gsposp(const char *name, Int_t nr, const char *mother,
664 Double_t x, Double_t y, Double_t z, Int_t irot,
665 const char *konly, Float_t *upar, Int_t np) {
666 //
667 fMCGeo->Gsposp(name, nr, mother, x, y, z, irot, konly, upar, np);
668}
669
670//______________________________________________________________________________
671void TFluka::Gsposp(const char *name, Int_t nr, const char *mother,
672 Double_t x, Double_t y, Double_t z, Int_t irot,
673 const char *konly, Double_t *upar, Int_t np) {
674 //
675 fMCGeo->Gsposp(name, nr, mother, x, y, z, irot, konly, upar, np);
676}
677
678//______________________________________________________________________________
679void TFluka::Gsbool(const char* /*onlyVolName*/, const char* /*manyVolName*/) {
680//
681// Nothing to do with TGeo
682}
683
684//______________________________________________________________________________
685void TFluka::SetCerenkov(Int_t itmed, Int_t npckov, Float_t* ppckov,
686 Float_t* absco, Float_t* effic, Float_t* rindex) {
687//
688// Set Cerenkov properties for medium itmed
689//
690// npckov: number of sampling points
691// ppckov: energy values
692// absco: absorption length
693// effic: quantum efficiency
694// rindex: refraction index
695//
696//
697//
698// Create object holding Cerenkov properties
699//
700 TFlukaCerenkov* cerenkovProperties = new TFlukaCerenkov(npckov, ppckov, absco, effic, rindex);
701//
702// Pass object to medium
703 TGeoMedium* medium = gGeoManager->GetMedium(itmed);
704 medium->SetCerenkovProperties(cerenkovProperties);
705}
706
707//______________________________________________________________________________
708void TFluka::SetCerenkov(Int_t /*itmed*/, Int_t /*npckov*/, Double_t * /*ppckov*/,
709 Double_t * /*absco*/, Double_t * /*effic*/, Double_t * /*rindex*/) {
710//
711// Not implemented with TGeo - what G4 did ? Any FLUKA card generated?
712 Warning("SetCerenkov", "Not implemented with TGeo");
713}
714
715// Euclid
716//______________________________________________________________________________
717void TFluka::WriteEuclid(const char* /*fileName*/, const char* /*topVol*/,
718 Int_t /*number*/, Int_t /*nlevel*/) {
719//
720// Not with TGeo
721 Warning("WriteEuclid", "Not implemented with TGeo");
722}
723
724
725
726//_____________________________________________________________________________
727// methods needed by the stepping
728//____________________________________________________________________________
729
730Int_t TFluka::GetMedium() const {
731//
732// Get the medium number for the current fluka region
733//
734 return fGeom->GetMedium(); // this I need to check due to remapping !!!
735}
736
737
738
739//____________________________________________________________________________
740// particle table usage
741// ID <--> PDG transformations
742//_____________________________________________________________________________
743Int_t TFluka::IdFromPDG(Int_t pdg) const
744{
745 //
746 // Return Fluka code from PDG and pseudo ENDF code
747
748 // Catch the feedback photons
749 if (pdg == 50000051) return (-1);
750 // MCIHAD() goes from pdg to fluka internal.
751 Int_t intfluka = mcihad(pdg);
752 // KPTOIP array goes from internal to official
753 return GetFlukaKPTOIP(intfluka);
754}
755
756//______________________________________________________________________________
757Int_t TFluka::PDGFromId(Int_t id) const
758{
759 //
760 // Return PDG code and pseudo ENDF code from Fluka code
f926898e 761 // Alpha He3 Triton Deuteron gen. ion opt. photon
762 Int_t idSpecial[6] = {10020040, 10020030, 10010030, 10010020, 10000000, 50000050};
829fb838 763 // IPTOKP array goes from official to internal
764
765 if (id == -1) {
766// Cerenkov photon
bd3d5c8a 767 if (fVerbosityLevel >= 3)
829fb838 768 printf("\n PDGFromId: Cerenkov Photon \n");
769 return 50000050;
770 }
771// Error id
772 if (id == 0 || id < -6 || id > 250) {
f926898e 773 if (fVerbosityLevel >= 3)
829fb838 774 printf("PDGFromId: Error id = 0\n");
775 return -1;
776 }
777// Good id
f926898e 778 if (id > 0) {
779 Int_t intfluka = GetFlukaIPTOKP(id);
780 if (intfluka == 0) {
781 if (fVerbosityLevel >= 3)
782 printf("PDGFromId: Error intfluka = 0: %d\n", id);
783 return -1;
784 } else if (intfluka < 0) {
785 if (fVerbosityLevel >= 3)
786 printf("PDGFromId: Error intfluka < 0: %d\n", id);
787 return -1;
788 }
789 if (fVerbosityLevel >= 3)
790 printf("mpdgha called with %d %d \n", id, intfluka);
791 // MPDGHA() goes from fluka internal to pdg.
792 return mpdgha(intfluka);
793 } else {
794 // ions and optical photons
795 return idSpecial[id + 6];
829fb838 796 }
829fb838 797}
798
bd3d5c8a 799void TFluka::StopTrack()
800{
801 // Set stopping conditions
802 // Works for photons and charged particles
803 fStopped = kTRUE;
804}
805
829fb838 806//_____________________________________________________________________________
807// methods for physics management
808//____________________________________________________________________________
809//
810// set methods
811//
812
1df5fa54 813void TFluka::SetProcess(const char* flagName, Int_t flagValue, Int_t imed)
829fb838 814{
815// Set process user flag for material imat
816//
1df5fa54 817 TFlukaConfigOption* proc = new TFlukaConfigOption(flagName, flagValue, imed);
818 fProcesses->Add(proc);
829fb838 819}
820
821//______________________________________________________________________________
822Bool_t TFluka::SetProcess(const char* flagName, Int_t flagValue)
823{
824// Set process user flag
825//
1df5fa54 826//
827// Update if already in the list
828//
829fb838 829
1df5fa54 830 TIter next(fProcesses);
831 TFlukaConfigOption* proc;
832 while((proc = (TFlukaConfigOption*)next()))
833 {
834 if (strcmp(proc->GetName(), flagName) == 0) {
835 proc->SetFlag(flagValue);
836 proc->SetMedium(-1);
837 return kTRUE;
829fb838 838 }
1df5fa54 839 }
840//
841// If not create a new process
842//
843
844 proc = new TFlukaConfigOption(flagName, flagValue);
845 fProcesses->Add(proc);
846
847 return kTRUE;
829fb838 848}
849
850//______________________________________________________________________________
851void TFluka::SetCut(const char* cutName, Double_t cutValue, Int_t imed)
852{
853// Set user cut value for material imed
854//
1df5fa54 855 TFlukaConfigOption* cut = new TFlukaConfigOption(cutName, cutValue, imed);
856 fCuts->Add(cut);
829fb838 857}
858
859//______________________________________________________________________________
860Bool_t TFluka::SetCut(const char* cutName, Double_t cutValue)
861{
862// Set user cut value
863//
1df5fa54 864//
865// Update if already in the list
866//
867
868 TIter next(fCuts);
869 TFlukaConfigOption* cut;
870 while((cut = (TFlukaConfigOption*)next()))
871 {
872 if (strcmp(cut->GetName(), cutName) == 0) {
873 cut->SetCut(cutValue);
874 return kTRUE;
829fb838 875 }
1df5fa54 876 }
877//
878// If not create a new process
879//
880
881 cut = new TFlukaConfigOption(cutName, cutValue);
882 fCuts->Add(cut);
883
884 return kTRUE;
829fb838 885}
886
b496f27c 887void TFluka::SetUserScoring(const char* option, Int_t npar, Float_t what[12])
888{
889//
890// Ads a user scoring option to th list
891//
892 TFlukaScoringOption* opt = new TFlukaScoringOption(option, "User Scoring", npar, what);
893 fUserScore->Add(opt);
894}
895
896
829fb838 897//______________________________________________________________________________
898Double_t TFluka::Xsec(char*, Double_t, Int_t, Int_t)
899{
900 printf("WARNING: Xsec not yet implemented !\n"); return -1.;
901}
902
903
904//______________________________________________________________________________
905void TFluka::InitPhysics()
906{
907//
908// Physics initialisation with preparation of FLUKA input cards
909//
1df5fa54 910 printf("=>InitPhysics\n");
911 Int_t j, k;
b2129742 912 Double_t theCut;
829fb838 913
3b8c325d 914 FILE *pFlukaVmcCoreInp, *pFlukaVmcFlukaMat, *pFlukaVmcInp;
829fb838 915
916 Double_t zero = 0.0;
917 Double_t one = 1.0;
918 Double_t two = 2.0;
919 Double_t three = 3.0;
920
921 Float_t fLastMaterial = fGeom->GetLastMaterialIndex();
922 if (fVerbosityLevel >= 3) printf(" last FLUKA material is %g\n", fLastMaterial);
923
924 // Prepare Cerenkov
925 TObjArray *matList = GetFlukaMaterials();
926 Int_t nmaterial = matList->GetEntriesFast();
927 fMaterials = new Int_t[nmaterial+3];
928
929// construct file names
930
3b8c325d 931 TString sFlukaVmcCoreInp = getenv("ALICE_ROOT");
932 sFlukaVmcCoreInp +="/TFluka/input/";
933 TString sFlukaVmcTmp = "flukaMat.inp";
934 TString sFlukaVmcInp = GetInputFileName();
935 sFlukaVmcCoreInp += GetCoreInputFileName();
829fb838 936
937// open files
938
3b8c325d 939 if ((pFlukaVmcCoreInp = fopen(sFlukaVmcCoreInp.Data(),"r")) == NULL) {
940 printf("\nCannot open file %s\n",sFlukaVmcCoreInp.Data());
829fb838 941 exit(1);
942 }
3b8c325d 943 if ((pFlukaVmcFlukaMat = fopen(sFlukaVmcTmp.Data(),"r")) == NULL) {
944 printf("\nCannot open file %s\n",sFlukaVmcTmp.Data());
829fb838 945 exit(1);
946 }
3b8c325d 947 if ((pFlukaVmcInp = fopen(sFlukaVmcInp.Data(),"w")) == NULL) {
948 printf("\nCannot open file %s\n",sFlukaVmcInp.Data());
829fb838 949 exit(1);
950 }
951
952// copy core input file
953 Char_t sLine[255];
954 Float_t fEventsPerRun;
955
3b8c325d 956 while ((fgets(sLine,255,pFlukaVmcCoreInp)) != NULL) {
829fb838 957 if (strncmp(sLine,"GEOEND",6) != 0)
3b8c325d 958 fprintf(pFlukaVmcInp,"%s",sLine); // copy until GEOEND card
829fb838 959 else {
3b8c325d 960 fprintf(pFlukaVmcInp,"GEOEND\n"); // add GEOEND card
829fb838 961 goto flukamat;
962 }
963 } // end of while until GEOEND card
964
965
966 flukamat:
3b8c325d 967 while ((fgets(sLine,255,pFlukaVmcFlukaMat)) != NULL) { // copy flukaMat.inp file
968 fprintf(pFlukaVmcInp,"%s\n",sLine);
829fb838 969 }
970
3b8c325d 971 while ((fgets(sLine,255,pFlukaVmcCoreInp)) != NULL) {
829fb838 972 if (strncmp(sLine,"START",5) != 0)
3b8c325d 973 fprintf(pFlukaVmcInp,"%s\n",sLine);
829fb838 974 else {
975 sscanf(sLine+10,"%10f",&fEventsPerRun);
976 goto fin;
977 }
978 } //end of while until START card
979
980fin:
981// in G3 the process control values meaning can be different for
982// different processes, but for most of them is:
983// 0 process is not activated
984// 1 process is activated WITH generation of secondaries
985// 2 process is activated WITHOUT generation of secondaries
986// if process does not generate secondaries => 1 same as 2
987//
988// Exceptions:
989// MULS: also 3
990// LOSS: also 3, 4
991// RAYL: only 0,1
992// HADR: may be > 2
993//
994
995// Loop over number of SetProcess calls
3b8c325d 996 fprintf(pFlukaVmcInp,"*----------------------------------------------------------------------------- \n");
997 fprintf(pFlukaVmcInp,"*----- The following data are generated from SetProcess and SetCut calls ----- \n");
998 fprintf(pFlukaVmcInp,"*----------------------------------------------------------------------------- \n");
829fb838 999
1df5fa54 1000// Outer loop over processes
1001 TIter next(fProcesses);
1002 TFlukaConfigOption *proc;
1003// Inner loop over processes
1004 TIter nextp(fProcesses);
1005 TFlukaConfigOption *procp;
1006// Loop over cuts
1007 TIter nextc(fCuts);
1008 TFlukaConfigOption *cut = 0x0;
1009
1010 while((proc = (TFlukaConfigOption*)next())) {
829fb838 1011 Float_t matMin = three;
1012 Float_t matMax = fLastMaterial;
1013 Bool_t global = kTRUE;
1df5fa54 1014 if (proc->Medium() != -1) {
7b203b6e 1015 Int_t mat;
1016 if ((mat = proc->Medium()) >= GetFlukaMaterials()->GetEntries()) continue;
1017 matMin = Float_t(mat);
829fb838 1018 matMax = matMin;
1019 global = kFALSE;
7b203b6e 1020
1021 fprintf(pFlukaVmcInp,"*\n*Material specific process setting for #%8d \n", mat);
829fb838 1022 }
1023
1024 // annihilation
1025 // G3 default value: 1
1026 // G4 processes: G4eplusAnnihilation/G4IeplusAnnihilation
1027 // Particles: e+
1028 // Physics: EM
1029 // flag = 0 no annihilation
1030 // flag = 1 annihilation, decays processed
1031 // flag = 2 annihilation, no decay product stored
1032 // gMC ->SetProcess("ANNI",1); // EMFCUT -1. 0. 0. 3. lastmat 0. ANNH-THR
1df5fa54 1033 if (strncmp(proc->GetName(),"ANNI",4) == 0) {
1034 if (proc->Flag() == 1 || proc->Flag() == 2) {
3b8c325d 1035 fprintf(pFlukaVmcInp,"*\n*Kinetic energy threshold (GeV) for e+ annihilation - resets to default=0.\n");
1036 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('ANNI',1) or SetProcess('ANNI',2)\n");
829fb838 1037 // -one = kinetic energy threshold (GeV) for e+ annihilation (resets to default=0)
1038 // zero = not used
1039 // zero = not used
1040 // matMin = lower bound of the material indices in which the respective thresholds apply
1041 // matMax = upper bound of the material indices in which the respective thresholds apply
1042 // one = step length in assigning indices
1043 // "ANNH-THR";
3b8c325d 1044 fprintf(pFlukaVmcInp,"EMFCUT %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fANNH-THR\n",-one,zero,zero,matMin,matMax,one);
829fb838 1045 }
1df5fa54 1046 else if (proc->Flag() == 0) {
3b8c325d 1047 fprintf(pFlukaVmcInp,"*\n*No annihilation - no FLUKA card generated\n");
1048 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('ANNI',0)\n");
829fb838 1049 }
1050 else {
3b8c325d 1051 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('ANNI',?) call.\n");
1052 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1053 }
1054 }
1055
1056 // bremsstrahlung and pair production are both activated
1057 // G3 default value: 1
1058 // G4 processes: G4eBremsstrahlung/G4IeBremsstrahlung,
1059 // G4MuBremsstrahlung/G4IMuBremsstrahlung,
1060 // G4LowEnergyBremstrahlung
1061 // Particles: e-/e+; mu+/mu-
1062 // Physics: EM
1063 // flag = 0 no bremsstrahlung
1064 // flag = 1 bremsstrahlung, photon processed
1065 // flag = 2 bremsstrahlung, no photon stored
1066 // gMC ->SetProcess("BREM",1); // PAIRBREM 2. 0. 0. 3. lastmat
1067 // EMFCUT -1. 0. 0. 3. lastmat 0. ELPO-THR
1068 // G3 default value: 1
1069 // G4 processes: G4GammaConversion,
1070 // G4MuPairProduction/G4IMuPairProduction
1071 // G4LowEnergyGammaConversion
1072 // Particles: gamma, mu
1073 // Physics: EM
1074 // flag = 0 no delta rays
1075 // flag = 1 delta rays, secondaries processed
1076 // flag = 2 delta rays, no secondaries stored
d160cb78 1077
1df5fa54 1078 else if ((strncmp(proc->GetName(),"PAIR",4) == 0) && (proc->Flag() == 1 || proc->Flag() == 2)) {
829fb838 1079
1df5fa54 1080 nextp.Reset();
1081
1082 while ((procp = (TFlukaConfigOption*)nextp())) {
1083 if ((strncmp(procp->GetName(),"BREM",4) == 0) &&
d160cb78 1084 (proc->Flag() == 1) &&
1df5fa54 1085 (procp->Medium() == proc->Medium())) {
3b8c325d 1086 fprintf(pFlukaVmcInp,"*\n*Bremsstrahlung and pair production by muons and charged hadrons both activated\n");
1087 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('BREM',1) and SetProcess('PAIR',1)\n");
1088 fprintf(pFlukaVmcInp,"*Energy threshold set by call SetCut('BCUTM',cut) or set to 0.\n");
1089 fprintf(pFlukaVmcInp,"*Energy threshold set by call SetCut('PPCUTM',cut) or set to 0.\n");
829fb838 1090 // three = bremsstrahlung and pair production by muons and charged hadrons both are activated
3b8c325d 1091 fprintf(pFlukaVmcInp,"PAIRBREM %10.1f",three);
829fb838 1092 // direct pair production by muons
1093 // G4 particles: "e-", "e+"
1094 // G3 default value: 0.01 GeV
1095 //gMC ->SetCut("PPCUTM",cut); // total energy cut for direct pair prod. by muons
b2129742 1096 theCut = 0.0;
1df5fa54 1097 nextc.Reset();
1098 while ((cut = (TFlukaConfigOption*)nextc())) {
1099 if (strncmp(cut->GetName(), "PPCUTM", 6) == 0 &&
b2129742 1100 (cut->Medium() == proc->Medium())) theCut = cut->Cut();
829fb838 1101 }
b2129742 1102 fprintf(pFlukaVmcInp,"%10.4g",theCut);
1103 // theCut; = e+, e- kinetic energy threshold (in GeV) for explicit pair production.
829fb838 1104 // muon and hadron bremsstrahlung
1105 // G4 particles: "gamma"
1106 // G3 default value: CUTGAM=0.001 GeV
1107 //gMC ->SetCut("BCUTM",cut); // cut for muon and hadron bremsstrahlung
b2129742 1108 theCut = 0.0;
1df5fa54 1109 nextc.Reset();
1110 while ((cut = (TFlukaConfigOption*)nextc())) {
1111 if (strncmp(cut->GetName(), "BCUTM", 5) == 0 &&
b2129742 1112 (cut->Medium() == proc->Medium())) theCut = cut->Cut();
829fb838 1113 }
b2129742 1114 fprintf(pFlukaVmcInp,"%10.4g%10.1f%10.1f\n",theCut,matMin,matMax);
1115 // theCut = photon energy threshold (GeV) for explicit bremsstrahlung production
829fb838 1116 // matMin = lower bound of the material indices in which the respective thresholds apply
1117 // matMax = upper bound of the material indices in which the respective thresholds apply
1118
1119 // for e+ and e-
3b8c325d 1120 fprintf(pFlukaVmcInp,"*\n*Kinetic energy threshold (GeV) for e+/e- bremsstrahlung - resets to default=0.\n");
1121 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('BREM',1);\n");
b2129742 1122 theCut = -1.0;
1df5fa54 1123 nextc.Reset();
1124 while ((cut = (TFlukaConfigOption*)nextc())) {
1125 if (strncmp(cut->GetName(), "BCUTE", 5) == 0 &&
b2129742 1126 (cut->Medium() == proc->Medium())) theCut = cut->Cut();
829fb838 1127 }
b2129742 1128 //theCut = kinetic energy threshold (GeV) for e+/e- bremsstrahlung (resets to default=0)
829fb838 1129 // zero = not used
1130 // zero = not used
1131 // matMin = lower bound of the material indices in which the respective thresholds apply
1132 // matMax = upper bound of the material indices in which the respective thresholds apply
1133 // one = step length in assigning indices
1134 // "ELPO-THR";
b2129742 1135 fprintf(pFlukaVmcInp,"EMFCUT %10.4g%10.1f%10.1f%10.1f%10.1f%10.1fELPO-THR\n",theCut,zero,zero,matMin,matMax,one);
829fb838 1136
d160cb78 1137 // for gamma -> e+ and e-
1138 fprintf(pFlukaVmcInp,"*\n*Pair production by photons is activated\n");
3b8c325d 1139 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('PAIR',1);\n");
b2129742 1140 theCut = -1.0;
1df5fa54 1141 nextc.Reset();
1142 while ((cut = (TFlukaConfigOption*)nextc())) {
d160cb78 1143 if (strncmp(cut->GetName(), "CUTELE", 6) == 0 &&
b2129742 1144 (cut->Medium() == proc->Medium())) theCut = cut->Cut();
829fb838 1145 }
b2129742 1146 // theCut = energy threshold (GeV) for gamma pair production (< 0.0 : resets to default, = 0.0 : ignored)
829fb838 1147 // matMin = lower bound of the material indices in which the respective thresholds apply
1148 // matMax = upper bound of the material indices in which the respective thresholds apply
1149 // one = step length in assigning indices
b2129742 1150 fprintf(pFlukaVmcInp,"EMFCUT %10.1f%10.1f%10.4g%10.1f%10.1f%10.1fPHOT-THR\n",zero,zero,theCut,matMin,matMax,one);
829fb838 1151 goto BOTH;
1152 } // end of if for BREM
1153 } // end of loop for BREM
1154
1155 // only pair production by muons and charged hadrons is activated
3b8c325d 1156 fprintf(pFlukaVmcInp,"*\n*Pair production by muons and charged hadrons is activated\n");
1157 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('PAIR',1) or SetProcess('PAIR',2)\n");
1158 fprintf(pFlukaVmcInp,"*Energy threshold set by call SetCut('PPCUTM',cut) or set to 0.\n");
829fb838 1159 // direct pair production by muons
1160 // G4 particles: "e-", "e+"
1161 // G3 default value: 0.01 GeV
1162 //gMC ->SetCut("PPCUTM",cut); // total energy cut for direct pair prod. by muons
1163 // one = pair production by muons and charged hadrons is activated
1164 // zero = e+, e- kinetic energy threshold (in GeV) for explicit pair production.
1165 // zero = no explicit bremsstrahlung production is simulated
1166 // matMin = lower bound of the material indices in which the respective thresholds apply
1167 // matMax = upper bound of the material indices in which the respective thresholds apply
3b8c325d 1168 fprintf(pFlukaVmcInp,"PAIRBREM %10.1f%10.1f%10.1f%10.1f%10.1f\n",one,zero,zero,matMin,matMax);
829fb838 1169
d160cb78 1170 // for gamma -> e+ and e-
3b8c325d 1171 fprintf(pFlukaVmcInp,"*\n*Pair production by electrons is activated\n");
1172 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('PAIR',1) or SetProcess('PAIR',2)\n");
b2129742 1173 theCut = -1.0;
1df5fa54 1174 nextc.Reset();
1175 while ((cut = (TFlukaConfigOption*)nextc())) {
d160cb78 1176 if (strncmp(cut->GetName(), "CUTELE", 6) == 0 &&
b2129742 1177 (cut->Medium() == proc->Medium())) theCut = cut->Cut();
829fb838 1178 }
1179 // zero = energy threshold (GeV) for Compton scattering (= 0.0 : ignored)
1180 // zero = energy threshold (GeV) for Photoelectric (= 0.0 : ignored)
b2129742 1181 // theCut = energy threshold (GeV) for gamma pair production (< 0.0 : resets to default, = 0.0 : ignored)
829fb838 1182 // matMin = lower bound of the material indices in which the respective thresholds apply
1183 // matMax = upper bound of the material indices in which the respective thresholds apply
1184 // one = step length in assigning indices
b2129742 1185 fprintf(pFlukaVmcInp,"EMFCUT %10.1f%10.1f%10.4g%10.1f%10.1f%10.1fPHOT-THR\n",zero,zero,theCut,matMin,matMax,one);
829fb838 1186
1187 BOTH:
1188 k = 0;
1189 } // end of if for PAIR
1190
1191
1192
1193 // bremsstrahlung
1194 // G3 default value: 1
1195 // G4 processes: G4eBremsstrahlung/G4IeBremsstrahlung,
1196 // G4MuBremsstrahlung/G4IMuBremsstrahlung,
1197 // G4LowEnergyBremstrahlung
1198 // Particles: e-/e+; mu+/mu-
1199 // Physics: EM
1200 // flag = 0 no bremsstrahlung
1201 // flag = 1 bremsstrahlung, photon processed
1202 // flag = 2 bremsstrahlung, no photon stored
1203 // gMC ->SetProcess("BREM",1); // PAIRBREM 2. 0. 0. 3. lastmat
1204 // EMFCUT -1. 0. 0. 3. lastmat 0. ELPO-THR
1df5fa54 1205 else if (strncmp(proc->GetName(),"BREM",4) == 0) {
1206 nextp.Reset();
1207 while((procp = (TFlukaConfigOption*)nextp())) {
1208 if ((strncmp(procp->GetName(),"PAIR",4) == 0) &&
1209 procp->Flag() == 1 &&
1210 (procp->Medium() == proc->Medium())) goto NOBREM;
829fb838 1211 }
d160cb78 1212 if (proc->Flag() == 1) {
3b8c325d 1213 fprintf(pFlukaVmcInp,"*\n*Bremsstrahlung by muons and charged hadrons is activated\n");
1214 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('BREM',1) or SetProcess('BREM',2)\n");
1215 fprintf(pFlukaVmcInp,"*Energy threshold set by call SetCut('BCUTM',cut) or set to 0.\n");
829fb838 1216 // two = bremsstrahlung by muons and charged hadrons is activated
1217 // zero = no meaning
1218 // muon and hadron bremsstrahlung
1219 // G4 particles: "gamma"
1220 // G3 default value: CUTGAM=0.001 GeV
1221 //gMC ->SetCut("BCUTM",cut); // cut for muon and hadron bremsstrahlung
b2129742 1222 theCut = 0.0;
1df5fa54 1223 nextc.Reset();
1224 while ((cut = (TFlukaConfigOption*)nextc())) {
1225 if (strncmp(cut->GetName(), "BCUTM", 5) == 0 &&
b2129742 1226 (cut->Medium() == proc->Medium())) theCut = cut->Cut();
829fb838 1227 }
b2129742 1228 // theCut = photon energy threshold (GeV) for explicit bremsstrahlung production
829fb838 1229 // matMin = lower bound of the material indices in which the respective thresholds apply
1230 // matMax = upper bound of the material indices in which the respective thresholds apply
b2129742 1231 fprintf(pFlukaVmcInp,"PAIRBREM %10.1f%10.1f%10.4g%10.1f%10.1f\n",two,zero,theCut,matMin,matMax);
829fb838 1232
1233 // for e+ and e-
3b8c325d 1234 fprintf(pFlukaVmcInp,"*\n*Kinetic energy threshold (GeV) for e+/e- bremsstrahlung - resets to default=0.\n");
1235 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('BREM',1);");
829fb838 1236 // - one = kinetic energy threshold (GeV) for e+/e- bremsstrahlung (resets to default=0)
1237 // zero = not used
1238 // zero = not used
1239 // matMin = lower bound of the material indices in which the respective thresholds apply
1240 // matMax = upper bound of the material indices in which the respective thresholds apply
1241 // one = step length in assigning indices
1242 //"ELPO-THR";
d160cb78 1243 theCut = -1.0;
1244 nextc.Reset();
1245 while ((cut = (TFlukaConfigOption*)nextc())) {
1246 if (strncmp(cut->GetName(), "CUTGAM", 6) == 0 &&
1247 (cut->Medium() == proc->Medium())) theCut = cut->Cut();
1248 }
1249 fprintf(pFlukaVmcInp,"EMFCUT %10.4g%10.1f%10.1f%10.1f%10.1f%10.1fELPO-THR\n", theCut,zero,zero,matMin,matMax,one);
829fb838 1250 }
1df5fa54 1251 else if (proc->Flag() == 0) {
3b8c325d 1252 fprintf(pFlukaVmcInp,"*\n*No bremsstrahlung - no FLUKA card generated\n");
1253 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('BREM',0)\n");
829fb838 1254 }
1255 else {
3b8c325d 1256 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('BREM',?) call.\n");
1257 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1258 }
1259 NOBREM:
1260 j = 0;
1df5fa54 1261 } // end of else if (strncmp(proc->GetName(),"BREM",4) == 0)
829fb838 1262
1263 // Cerenkov photon generation
1264 // G3 default value: 0
1265 // G4 process: G4Cerenkov
1266 //
1267 // Particles: charged
1268 // Physics: Optical
1269 // flag = 0 no Cerenkov photon generation
1270 // flag = 1 Cerenkov photon generation
1271 // flag = 2 Cerenkov photon generation with primary stopped at each step
1272 //xx gMC ->SetProcess("CKOV",1); // ??? Cerenkov photon generation
1273
1df5fa54 1274 else if (strncmp(proc->GetName(),"CKOV",4) == 0) {
1275 if ((proc->Flag() == 1 || proc->Flag() == 2) && global) {
829fb838 1276 // Write comments
3b8c325d 1277 fprintf(pFlukaVmcInp, "* \n");
1278 fprintf(pFlukaVmcInp, "*Cerenkov photon generation\n");
1279 fprintf(pFlukaVmcInp, "*Generated from call: SetProcess('CKOV',1) or SetProcess('CKOV',2)\n");
829fb838 1280 // Loop over media
1281 for (Int_t im = 0; im < nmaterial; im++)
1282 {
1283 TGeoMaterial* material = dynamic_cast<TGeoMaterial*> (matList->At(im));
1284 Int_t idmat = material->GetIndex();
1285
1df5fa54 1286 if (!global && idmat != proc->Medium()) continue;
829fb838 1287
1288 fMaterials[idmat] = im;
1289 // Skip media with no Cerenkov properties
1290 TFlukaCerenkov* cerenkovProp;
1291 if (!(cerenkovProp = dynamic_cast<TFlukaCerenkov*>(material->GetCerenkovProperties()))) continue;
1292 //
1293 // This medium has Cerenkov properties
1294 //
1295 //
1296 // Write OPT-PROD card for each medium
1297 Float_t emin = cerenkovProp->GetMinimumEnergy();
1298 Float_t emax = cerenkovProp->GetMaximumEnergy();
3b8c325d 1299 fprintf(pFlukaVmcInp, "OPT-PROD %10.4g%10.4g%10.4g%10.4g%10.4g%10.4gCERENKOV\n", emin, emax, 0.,
829fb838 1300 Float_t(idmat), Float_t(idmat), 0.);
1301 //
1302 // Write OPT-PROP card for each medium
1303 // Forcing FLUKA to call user routines (queffc.cxx, rflctv.cxx, rfrndx.cxx)
1304 //
3b8c325d 1305 fprintf(pFlukaVmcInp, "OPT-PROP %10.4g%10.4g%10.4g%10.1f%10.1f%10.1fWV-LIMIT\n",
829fb838 1306 cerenkovProp->GetMinimumWavelength(),
1307 cerenkovProp->GetMaximumWavelength(),
1308 cerenkovProp->GetMaximumWavelength(),
1309 Float_t(idmat), Float_t(idmat), 0.0);
1310
1311 if (cerenkovProp->IsMetal()) {
3b8c325d 1312 fprintf(pFlukaVmcInp, "OPT-PROP %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fMETAL\n",
829fb838 1313 -100., -100., -100.,
1314 Float_t(idmat), Float_t(idmat), 0.0);
1315 } else {
3b8c325d 1316 fprintf(pFlukaVmcInp, "OPT-PROP %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",
829fb838 1317 -100., -100., -100.,
1318 Float_t(idmat), Float_t(idmat), 0.0);
1319 }
1320
1321
1322 for (Int_t j = 0; j < 3; j++) {
3b8c325d 1323 fprintf(pFlukaVmcInp, "OPT-PROP %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f&\n",
829fb838 1324 -100., -100., -100.,
1325 Float_t(idmat), Float_t(idmat), 0.0);
1326 }
1327 // Photon detection efficiency user defined
1328
1329 if (cerenkovProp->IsSensitive())
3b8c325d 1330 fprintf(pFlukaVmcInp, "OPT-PROP %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fSENSITIV\n",
829fb838 1331 -100., -100., -100.,
1332 Float_t(idmat), Float_t(idmat), 0.0);
1333
1334 } // materials
1df5fa54 1335 } else if (proc->Flag() == 0) {
3b8c325d 1336 fprintf(pFlukaVmcInp,"*\n*No Cerenkov photon generation\n");
1337 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('CKOV',0)\n");
829fb838 1338 // zero = not used
1339 // zero = not used
1340 // zero = not used
1341 // matMin = lower bound of the material indices in which the respective thresholds apply
1342 // matMax = upper bound of the material indices in which the respective thresholds apply
1343 // one = step length in assigning indices
1344 //"CERE-OFF";
3b8c325d 1345 fprintf(pFlukaVmcInp,"OPT-PROD %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fCERE-OFF\n",zero,zero,zero,matMin,matMax,one);
829fb838 1346 }
1347 else {
3b8c325d 1348 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('CKOV',?) call.\n");
1349 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1350 }
1df5fa54 1351 } // end of else if (strncmp(proc->GetName(),"CKOV",4) == 0)
829fb838 1352
1353 // Compton scattering
1354 // G3 default value: 1
1355 // G4 processes: G4ComptonScattering,
1356 // G4LowEnergyCompton,
1357 // G4PolarizedComptonScattering
1358 // Particles: gamma
1359 // Physics: EM
1360 // flag = 0 no Compton scattering
1361 // flag = 1 Compton scattering, electron processed
1362 // flag = 2 Compton scattering, no electron stored
1363 // gMC ->SetProcess("COMP",1); // EMFCUT -1. 0. 0. 3. lastmat 0. PHOT-THR
1df5fa54 1364 else if (strncmp(proc->GetName(),"COMP",4) == 0) {
1365 if (proc->Flag() == 1 || proc->Flag() == 2) {
3b8c325d 1366 fprintf(pFlukaVmcInp,"*\n*Energy threshold (GeV) for Compton scattering - resets to default=0.\n");
1367 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('COMP',1);\n");
829fb838 1368 // - one = energy threshold (GeV) for Compton scattering - resets to default=0.
1369 // zero = not used
1370 // zero = not used
1371 // matMin = lower bound of the material indices in which the respective thresholds apply
1372 // matMax = upper bound of the material indices in which the respective thresholds apply
1373 // one = step length in assigning indices
1374 //"PHOT-THR";
d160cb78 1375 theCut = -1.0;
1376 nextc.Reset();
1377 while ((cut = (TFlukaConfigOption*)nextc())) {
1378 if (strncmp(cut->GetName(), "CUTELE", 6) == 0 &&
1379 (cut->Medium() == proc->Medium())) theCut = cut->Cut();
1380 }
1381 fprintf(pFlukaVmcInp,"EMFCUT %10.4g%10.1f%10.1f%10.1f%10.1f%10.1fPHOT-THR\n",theCut,zero,zero,matMin,matMax,one);
829fb838 1382 }
1df5fa54 1383 else if (proc->Flag() == 0) {
3b8c325d 1384 fprintf(pFlukaVmcInp,"*\n*No Compton scattering - no FLUKA card generated\n");
1385 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('COMP',0)\n");
829fb838 1386 }
1387 else {
3b8c325d 1388 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('COMP',?) call.\n");
1389 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1390 }
1df5fa54 1391 } // end of else if (strncmp(proc->GetName(),"COMP",4) == 0)
829fb838 1392
1393 // decay
1394 // G3 default value: 1
1395 // G4 process: G4Decay
1396 //
1397 // Particles: all which decay is applicable for
1398 // Physics: General
1399 // flag = 0 no decays
1400 // flag = 1 decays, secondaries processed
1401 // flag = 2 decays, no secondaries stored
7f13be31 1402 //gMC ->SetProcess("DCAY",0); // not available
83ec523a 1403 else if ((strncmp(proc->GetName(),"DCAY",4) == 0) && proc->Flag() == 0)
7f13be31 1404 cout << "SetProcess for flag =" << proc->GetName() << " value=" << proc->Flag() << " not avaliable!" << endl;
1405 else if ((strncmp(proc->GetName(),"DCAY",4) == 0) && proc->Flag() == 1) {
1406 // Nothing to do decays are switched on by default
1407 }
1408
829fb838 1409
1410 // delta-ray
1411 // G3 default value: 2
1412 // !! G4 treats delta rays in different way
1413 // G4 processes: G4eIonisation/G4IeIonization,
1414 // G4MuIonisation/G4IMuIonization,
1415 // G4hIonisation/G4IhIonisation
1416 // Particles: charged
1417 // Physics: EM
1418 // flag = 0 no energy loss
1419 // flag = 1 restricted energy loss fluctuations
1420 // flag = 2 complete energy loss fluctuations
1421 // flag = 3 same as 1
1422 // flag = 4 no energy loss fluctuations
1423 // gMC ->SetProcess("DRAY",0); // DELTARAY 1.E+6 0. 0. 3. lastmat 0.
1df5fa54 1424 else if (strncmp(proc->GetName(),"DRAY",4) == 0) {
1425 if (proc->Flag() == 0 || proc->Flag() == 4) {
3b8c325d 1426 fprintf(pFlukaVmcInp,"*\n*Kinetic energy threshold (GeV) for delta ray production\n");
1427 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('DRAY',0) or SetProcess('DRAY',4)\n");
1428 fprintf(pFlukaVmcInp,"*No delta ray production by muons - threshold set artificially high\n");
829fb838 1429 Double_t emin = 1.0e+6; // kinetic energy threshold (GeV) for delta ray production (discrete energy transfer)
1430 // zero = ignored
1431 // zero = ignored
1432 // matMin = lower bound of the material indices in which the respective thresholds apply
1433 // matMax = upper bound of the material indices in which the respective thresholds apply
1434 // one = step length in assigning indices
3b8c325d 1435 fprintf(pFlukaVmcInp,"DELTARAY %10.4g%10.1f%10.1f%10.1f%10.1f%10.1f\n",emin,zero,zero,matMin,matMax,one);
829fb838 1436 }
1df5fa54 1437 else if (proc->Flag() == 1 || proc->Flag() == 2 || proc->Flag() == 3) {
3b8c325d 1438 fprintf(pFlukaVmcInp,"*\n*Kinetic energy threshold (GeV) for delta ray production\n");
1439 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('DRAY',flag), flag=1,2,3\n");
1440 fprintf(pFlukaVmcInp,"*Delta ray production by muons switched on\n");
1441 fprintf(pFlukaVmcInp,"*Energy threshold set by call SetCut('DCUTM',cut) or set to 1.0e+6.\n");
b2129742 1442 theCut = 1.0e+6;
1df5fa54 1443 nextc.Reset();
b2129742 1444 //
1445 // Check cut one delta-rays from electrons
1446 //
1df5fa54 1447 while ((cut = (TFlukaConfigOption*)nextc())) {
1448 if (strncmp(cut->GetName(), "DCUTM", 5) == 0 &&
b2129742 1449 cut->Medium() == proc->Medium()) theCut = cut->Cut();
829fb838 1450 }
b2129742 1451 // theCut = kinetic energy threshold (GeV) for delta ray production (discrete energy transfer)
829fb838 1452 // zero = ignored
1453 // zero = ignored
1454 // matMin = lower bound of the material indices in which the respective thresholds apply
1455 // matMax = upper bound of the material indices in which the respective thresholds apply
1456 // one = step length in assigning indices
b2129742 1457 fprintf(pFlukaVmcInp,"DELTARAY %10.4g%10.1f%10.1f%10.1f%10.1f%10.1f\n",theCut,zero,zero,matMin,matMax,one);
829fb838 1458 }
1459 else {
3b8c325d 1460 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('DRAY',?) call.\n");
1461 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1462 }
1df5fa54 1463 } // end of else if (strncmp(proc->GetName(),"DRAY",4) == 0)
829fb838 1464
1465 // hadronic process
1466 // G3 default value: 1
1467 // G4 processes: all defined by TG4PhysicsConstructorHadron
1468 //
1469 // Particles: hadrons
1470 // Physics: Hadron
1471 // flag = 0 no multiple scattering
1472 // flag = 1 hadronic interactions, secondaries processed
1473 // flag = 2 hadronic interactions, no secondaries stored
1474 // gMC ->SetProcess("HADR",1); // ??? hadronic process
1475 //Select pure GEANH (HADR 1) or GEANH/NUCRIN (HADR 3) ?????
1df5fa54 1476 else if (strncmp(proc->GetName(),"HADR",4) == 0) {
1477 if (proc->Flag() == 1 || proc->Flag() == 2) {
3b8c325d 1478 fprintf(pFlukaVmcInp,"*\n*Hadronic interaction is ON by default in FLUKA\n");
1479 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1480 }
1df5fa54 1481 else if (proc->Flag() == 0) {
3b8c325d 1482 fprintf(pFlukaVmcInp,"*\n*Hadronic interaction is set OFF\n");
1483 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('HADR',0);\n");
1484 fprintf(pFlukaVmcInp,"*Switching off hadronic interactions not foreseen in FLUKA\n");
1485 fprintf(pFlukaVmcInp,"THRESHOL %10.1f%10.1f%10.1f%10.1e%10.1f\n",zero, zero, zero, 1.e10, zero);
829fb838 1486 }
1487 else {
3b8c325d 1488 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('HADR',?) call.\n");
1489 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1490 }
1df5fa54 1491 } // end of else if (strncmp(proc->GetName(),"HADR",4) == 0)
829fb838 1492
1493
1494 // energy loss
1495 // G3 default value: 2
1496 // G4 processes: G4eIonisation/G4IeIonization,
1497 // G4MuIonisation/G4IMuIonization,
1498 // G4hIonisation/G4IhIonisation
1499 //
1500 // Particles: charged
1501 // Physics: EM
1502 // flag=0 no energy loss
1503 // flag=1 restricted energy loss fluctuations
1504 // flag=2 complete energy loss fluctuations
1505 // flag=3 same as 1
1506 // flag=4 no energy loss fluctuations
1507 // If the value ILOSS is changed, then (in G3) cross-sections and energy
1508 // loss tables must be recomputed via the command 'PHYSI'
1509 // gMC ->SetProcess("LOSS",2); // ??? IONFLUCT ? energy loss
1df5fa54 1510 else if (strncmp(proc->GetName(),"LOSS",4) == 0) {
d160cb78 1511 if (proc->Flag() > 0 || proc->Flag() < 4) { // restricted energy loss fluctuations
3b8c325d 1512 fprintf(pFlukaVmcInp,"*\n*Restricted energy loss fluctuations\n");
1513 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('LOSS',1) or SetProcess('LOSS',3)\n");
829fb838 1514 // one = restricted energy loss fluctuations (for hadrons and muons) switched on
1515 // one = restricted energy loss fluctuations (for e+ and e-) switched on
1516 // one = minimal accuracy
1517 // matMin = lower bound of the material indices in which the respective thresholds apply
1518 // upper bound of the material indices in which the respective thresholds apply
d160cb78 1519 fprintf(pFlukaVmcInp,"IONFLUCT %10.1f%10.1f%10.1f%10.1f%10.1f\n",one, one, 4., matMin, matMax);
829fb838 1520 }
1df5fa54 1521 else if (proc->Flag() == 4) { // no energy loss fluctuations
3b8c325d 1522 fprintf(pFlukaVmcInp,"*\n*No energy loss fluctuations\n");
1523 fprintf(pFlukaVmcInp,"*\n*Generated from call: SetProcess('LOSS',4)\n");
829fb838 1524 // - one = restricted energy loss fluctuations (for hadrons and muons) switched off
1525 // - one = restricted energy loss fluctuations (for e+ and e-) switched off
1526 // one = minimal accuracy
1527 // matMin = lower bound of the material indices in which the respective thresholds apply
1528 // matMax = upper bound of the material indices in which the respective thresholds apply
3b8c325d 1529 fprintf(pFlukaVmcInp,"IONFLUCT %10.1f%10.1f%10.1f%10.1f%10.1f\n",-one,-one,one,matMin,matMax);
829fb838 1530 }
1531 else {
3b8c325d 1532 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('LOSS',?) call.\n");
1533 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1534 }
1df5fa54 1535 } // end of else if (strncmp(proc->GetName(),"LOSS",4) == 0)
829fb838 1536
1537
1538 // multiple scattering
1539 // G3 default value: 1
1540 // G4 process: G4MultipleScattering/G4IMultipleScattering
1541 //
1542 // Particles: charged
1543 // Physics: EM
1544 // flag = 0 no multiple scattering
1545 // flag = 1 Moliere or Coulomb scattering
1546 // flag = 2 Moliere or Coulomb scattering
1547 // flag = 3 Gaussian scattering
1548 // gMC ->SetProcess("MULS",1); // MULSOPT multiple scattering
1df5fa54 1549 else if (strncmp(proc->GetName(),"MULS",4) == 0) {
1550 if (proc->Flag() == 1 || proc->Flag() == 2 || proc->Flag() == 3) {
3b8c325d 1551 fprintf(pFlukaVmcInp,"*\n*Multiple scattering is ON by default for e+e- and for hadrons/muons\n");
1552 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1553 }
1df5fa54 1554 else if (proc->Flag() == 0) {
3b8c325d 1555 fprintf(pFlukaVmcInp,"*\n*Multiple scattering is set OFF\n");
1556 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('MULS',0);\n");
829fb838 1557 // zero = ignored
1558 // three = multiple scattering for hadrons and muons is completely suppressed
1559 // three = multiple scattering for e+ and e- is completely suppressed
1560 // matMin = lower bound of the material indices in which the respective thresholds apply
1561 // matMax = upper bound of the material indices in which the respective thresholds apply
3b8c325d 1562 fprintf(pFlukaVmcInp,"MULSOPT %10.1f%10.1f%10.1f%10.1f%10.1f\n",zero,three,three,matMin,matMax);
829fb838 1563 }
1564 else {
3b8c325d 1565 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('MULS',?) call.\n");
1566 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1567 }
1df5fa54 1568 } // end of else if (strncmp(proc->GetName(),"MULS",4) == 0)
829fb838 1569
1570
1571 // muon nuclear interaction
1572 // G3 default value: 0
1573 // G4 processes: G4MuNuclearInteraction,
1574 // G4MuonMinusCaptureAtRest
1575 //
1576 // Particles: mu
1577 // Physics: Not set
1578 // flag = 0 no muon-nuclear interaction
1579 // flag = 1 nuclear interaction, secondaries processed
1580 // flag = 2 nuclear interaction, secondaries not processed
1581 // gMC ->SetProcess("MUNU",1); // MUPHOTON 1. 0. 0. 3. lastmat
1df5fa54 1582 else if (strncmp(proc->GetName(),"MUNU",4) == 0) {
1583 if (proc->Flag() == 1) {
3b8c325d 1584 fprintf(pFlukaVmcInp,"*\n*Muon nuclear interactions with production of secondary hadrons\n");
1585 fprintf(pFlukaVmcInp,"*\n*Generated from call: SetProcess('MUNU',1);\n");
829fb838 1586 // one = full simulation of muon nuclear interactions and production of secondary hadrons
1587 // zero = ratio of longitudinal to transverse virtual photon cross-section - Default = 0.25.
1588 // zero = fraction of rho-like interactions ( must be < 1) - Default = 0.75.
1589 // matMin = lower bound of the material indices in which the respective thresholds apply
1590 // matMax = upper bound of the material indices in which the respective thresholds apply
3b8c325d 1591 fprintf(pFlukaVmcInp,"MUPHOTON %10.1f%10.1f%10.1f%10.1f%10.1f\n",one,zero,zero,matMin,matMax);
829fb838 1592 }
1df5fa54 1593 else if (proc->Flag() == 2) {
3b8c325d 1594 fprintf(pFlukaVmcInp,"*\n*Muon nuclear interactions without production of secondary hadrons\n");
1595 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('MUNU',2);\n");
829fb838 1596 // two = full simulation of muon nuclear interactions and production of secondary hadrons
1597 // zero = ratio of longitudinal to transverse virtual photon cross-section - Default = 0.25.
1598 // zero = fraction of rho-like interactions ( must be < 1) - Default = 0.75.
1599 // matMin = lower bound of the material indices in which the respective thresholds apply
1600 // matMax = upper bound of the material indices in which the respective thresholds apply
3b8c325d 1601 fprintf(pFlukaVmcInp,"MUPHOTON %10.1f%10.1f%10.1f%10.1f%10.1f\n",two,zero,zero,matMin,matMax);
829fb838 1602 }
1df5fa54 1603 else if (proc->Flag() == 0) {
3b8c325d 1604 fprintf(pFlukaVmcInp,"*\n*No muon nuclear interaction - no FLUKA card generated\n");
1605 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('MUNU',0)\n");
829fb838 1606 }
1607 else {
3b8c325d 1608 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('MUNU',?) call.\n");
1609 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1610 }
1df5fa54 1611 } // end of else if (strncmp(proc->GetName(),"MUNU",4) == 0)
829fb838 1612
1613
1614 // photofission
1615 // G3 default value: 0
1616 // G4 process: ??
1617 //
1618 // Particles: gamma
1619 // Physics: ??
1620 // gMC ->SetProcess("PFIS",0); // PHOTONUC -1. 0. 0. 3. lastmat 0.
1621 // flag = 0 no photon fission
1622 // flag = 1 photon fission, secondaries processed
1623 // flag = 2 photon fission, no secondaries stored
1df5fa54 1624 else if (strncmp(proc->GetName(),"PFIS",4) == 0) {
1625 if (proc->Flag() == 0) {
3b8c325d 1626 fprintf(pFlukaVmcInp,"*\n*No photonuclear interactions\n");
1627 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('PFIS',0);\n");
829fb838 1628 // - one = no photonuclear interactions
1629 // zero = not used
1630 // zero = not used
1631 // matMin = lower bound of the material indices in which the respective thresholds apply
1632 // matMax = upper bound of the material indices in which the respective thresholds apply
3b8c325d 1633 fprintf(pFlukaVmcInp,"PHOTONUC %10.1f%10.1f%10.1f%10.1f%10.1f\n",-one,zero,zero,matMin,matMax);
829fb838 1634 }
1df5fa54 1635 else if (proc->Flag() == 1) {
3b8c325d 1636 fprintf(pFlukaVmcInp,"*\n*Photon nuclear interactions are activated at all energies\n");
1637 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('PFIS',1);\n");
829fb838 1638 // one = photonuclear interactions are activated at all energies
1639 // zero = not used
1640 // zero = not used
1641 // matMin = lower bound of the material indices in which the respective thresholds apply
1642 // matMax = upper bound of the material indices in which the respective thresholds apply
3b8c325d 1643 fprintf(pFlukaVmcInp,"PHOTONUC %10.1f%10.1f%10.1f%10.1f%10.1f\n",one,zero,zero,matMin,matMax);
829fb838 1644 }
1df5fa54 1645 else if (proc->Flag() == 0) {
3b8c325d 1646 fprintf(pFlukaVmcInp,"*\n*No photofission - no FLUKA card generated\n");
1647 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('PFIS',0)\n");
829fb838 1648 }
1649 else {
3b8c325d 1650 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('PFIS',?) call.\n");
1651 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1652 }
1653 }
1654
1655
1656 // photo electric effect
1657 // G3 default value: 1
1658 // G4 processes: G4PhotoElectricEffect
1659 // G4LowEnergyPhotoElectric
1660 // Particles: gamma
1661 // Physics: EM
1662 // flag = 0 no photo electric effect
1663 // flag = 1 photo electric effect, electron processed
1664 // flag = 2 photo electric effect, no electron stored
1665 // gMC ->SetProcess("PHOT",1); // EMFCUT 0. -1. 0. 3. lastmat 0. PHOT-THR
1df5fa54 1666 else if (strncmp(proc->GetName(),"PHOT",4) == 0) {
d160cb78 1667 if (proc->Flag() == 1) {
3b8c325d 1668 fprintf(pFlukaVmcInp,"*\n*Photo electric effect is activated\n");
1669 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('PHOT',1);\n");
829fb838 1670 // zero = ignored
1671 // - one = resets to default=0.
1672 // zero = ignored
1673 // matMin = lower bound of the material indices in which the respective thresholds apply
1674 // matMax = upper bound of the material indices in which the respective thresholds apply
1675 // one = step length in assigning indices
1676 //"PHOT-THR";
d160cb78 1677 theCut = -1.0;
1678 nextc.Reset();
1679 while ((cut = (TFlukaConfigOption*)nextc())) {
1680 if (strncmp(cut->GetName(), "CUTELE", 6) == 0 &&
1681 (cut->Medium() == proc->Medium())) theCut = cut->Cut();
1682 }
1683 fprintf(pFlukaVmcInp,"EMFCUT %10.1f%10.4g%10.1f%10.1f%10.1f%10.1fPHOT-THR\n",zero,theCut,zero,matMin,matMax,one);
829fb838 1684 }
1df5fa54 1685 else if (proc->Flag() == 0) {
3b8c325d 1686 fprintf(pFlukaVmcInp,"*\n*No photo electric effect - no FLUKA card generated\n");
1687 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('PHOT',0)\n");
829fb838 1688 }
1689 else {
3b8c325d 1690 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('PHOT',?) call.\n");
1691 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1692 }
1df5fa54 1693 } // else if (strncmp(proc->GetName(),"PHOT",4) == 0)
829fb838 1694
1695
1696 // Rayleigh scattering
1697 // G3 default value: 0
1698 // G4 process: G4OpRayleigh
1699 //
1700 // Particles: optical photon
1701 // Physics: Optical
1702 // flag = 0 Rayleigh scattering off
1703 // flag = 1 Rayleigh scattering on
1704 //xx gMC ->SetProcess("RAYL",1);
1df5fa54 1705 else if (strncmp(proc->GetName(),"RAYL",4) == 0) {
1706 if (proc->Flag() == 1) {
3b8c325d 1707 fprintf(pFlukaVmcInp,"*\n*Rayleigh scattering is ON by default in FLUKA\n");
1708 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1709 }
1df5fa54 1710 else if (proc->Flag() == 0) {
3b8c325d 1711 fprintf(pFlukaVmcInp,"*\n*Rayleigh scattering is set OFF\n");
1712 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('RAYL',0);\n");
829fb838 1713 // - one = no Rayleigh scattering and no binding corrections for Compton
1714 // matMin = lower bound of the material indices in which the respective thresholds apply
1715 // matMax = upper bound of the material indices in which the respective thresholds apply
3b8c325d 1716 fprintf(pFlukaVmcInp,"EMFRAY %10.1f%10.1f%10.1f%10.1f\n",-one,three,matMin,matMax);
829fb838 1717 }
1718 else {
3b8c325d 1719 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('RAYL',?) call.\n");
1720 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1721 }
1df5fa54 1722 } // end of else if (strncmp(proc->GetName(),"RAYL",4) == 0)
829fb838 1723
1724
1725 // synchrotron radiation in magnetic field
1726 // G3 default value: 0
1727 // G4 process: G4SynchrotronRadiation
1728 //
1729 // Particles: ??
1730 // Physics: Not set
1731 // flag = 0 no synchrotron radiation
1732 // flag = 1 synchrotron radiation
1733 //xx gMC ->SetProcess("SYNC",1); // synchrotron radiation generation
1df5fa54 1734 else if (strncmp(proc->GetName(),"SYNC",4) == 0) {
3b8c325d 1735 fprintf(pFlukaVmcInp,"*\n*Synchrotron radiation generation is NOT implemented in FLUKA\n");
1736 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1737 }
1738
1739
1740 // Automatic calculation of tracking medium parameters
1741 // flag = 0 no automatic calculation
1742 // flag = 1 automatic calculation
1743 //xx gMC ->SetProcess("AUTO",1); // ??? automatic computation of the tracking medium parameters
1df5fa54 1744 else if (strncmp(proc->GetName(),"AUTO",4) == 0) {
3b8c325d 1745 fprintf(pFlukaVmcInp,"*\n*Automatic calculation of tracking medium parameters is always ON in FLUKA\n");
1746 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1747 }
1748
1749
1750 // To control energy loss fluctuation model
1751 // flag = 0 Urban model
1752 // flag = 1 PAI model
1753 // flag = 2 PAI+ASHO model (not active at the moment)
1754 //xx gMC ->SetProcess("STRA",1); // ??? energy fluctuation model
1df5fa54 1755 else if (strncmp(proc->GetName(),"STRA",4) == 0) {
1756 if (proc->Flag() == 0 || proc->Flag() == 2 || proc->Flag() == 3) {
3b8c325d 1757 fprintf(pFlukaVmcInp,"*\n*Ionization energy losses calculation is activated\n");
1758 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('STRA',n);, n=0,1,2\n");
829fb838 1759 // one = restricted energy loss fluctuations (for hadrons and muons) switched on
1760 // one = restricted energy loss fluctuations (for e+ and e-) switched on
1761 // one = minimal accuracy
1762 // matMin = lower bound of the material indices in which the respective thresholds apply
1763 // matMax = upper bound of the material indices in which the respective thresholds apply
3b8c325d 1764 fprintf(pFlukaVmcInp,"IONFLUCT %10.1f%10.1f%10.1f%10.1f%10.1f\n",one,one,one,matMin,matMax);
829fb838 1765 }
1766 else {
3b8c325d 1767 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('STRA',?) call.\n");
1768 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1769 }
1df5fa54 1770 } // else if (strncmp(proc->GetName(),"STRA",4) == 0)
829fb838 1771
1772
1773
1774
1775 else { // processes not yet treated
1776
1777 // light photon absorption (Cerenkov photons)
1778 // it is turned on when Cerenkov process is turned on
1779 // G3 default value: 0
1780 // G4 process: G4OpAbsorption, G4OpBoundaryProcess
1781 //
1782 // Particles: optical photon
1783 // Physics: Optical
1784 // flag = 0 no absorption of Cerenkov photons
1785 // flag = 1 absorption of Cerenkov photons
1786 // gMC ->SetProcess("LABS",2); // ??? Cerenkov light absorption
1787
1788
1789
1df5fa54 1790 cout << "SetProcess for flag=" << proc->GetName() << " value=" << proc->Flag() << " not yet implemented!" << endl;
829fb838 1791 }
1792 } //end of loop number of SetProcess calls
1793
1794
1795// Loop over number of SetCut calls
1df5fa54 1796
1797 nextc.Reset();
1798 while ((cut = (TFlukaConfigOption*)nextc())) {
829fb838 1799 Float_t matMin = three;
1800 Float_t matMax = fLastMaterial;
1801 Bool_t global = kTRUE;
1df5fa54 1802 if (cut->Medium() != -1) {
7b203b6e 1803 Int_t mat;
1804 if ((mat = cut->Medium()) >= GetFlukaMaterials()->GetEntries()) continue;
1805 matMin = Float_t(mat);
1806 matMax = matMin;
1807 global = kFALSE;
1808 TGeoMaterial* material = (TGeoMaterial*) (GetFlukaMaterials())->At(GetMaterialIndex(mat));
c1c801f9 1809 fprintf(pFlukaVmcInp,"*\n*Material specific cut setting for #%8d %s %s %13.3e\n",
1810 mat, material->GetName(), cut->GetName(), cut->Cut());
b2129742 1811
7b203b6e 1812 }
b2129742 1813
829fb838 1814 // cuts handled in SetProcess calls
b2129742 1815 if (strncmp(cut->GetName(),"BCUTM",5) == 0) continue;
1816 else if (strncmp(cut->GetName(),"BCUTE",5) == 0) continue;
1817 else if (strncmp(cut->GetName(),"DCUTM",5) == 0) continue;
1df5fa54 1818 else if (strncmp(cut->GetName(),"PPCUTM",6) == 0) continue;
829fb838 1819
829fb838 1820 // gammas
1821 // G4 particles: "gamma"
1822 // G3 default value: 0.001 GeV
1823 // gMC ->SetCut("CUTGAM",cut); // cut for gammas
1824
1df5fa54 1825 else if (strncmp(cut->GetName(),"CUTGAM",6) == 0 && global) {
b2129742 1826 fprintf(pFlukaVmcInp,"*\n*Cut for gamma\n");
1827 fprintf(pFlukaVmcInp,"*Generated from call: SetCut('CUTGAM',cut);\n");
1828 fprintf(pFlukaVmcInp,"EMFCUT %10.4g%10.4g%10.1f%10.1f%10.1f%10.1f\n",
1829 zero, cut->Cut(), zero, zero, Float_t(fGeom->NofVolumes()), one);
829fb838 1830 }
1df5fa54 1831 else if (strncmp(cut->GetName(),"CUTGAM",6) == 0 && !global) {
b2129742 1832 // loop over materials for EMFCUT FLUKA cards
1833 for (j=0; j < matMax-matMin+1; j++) {
1834 Int_t nreg, imat, *reglist;
1835 Float_t ireg;
1836 imat = (Int_t) matMin + j;
1837 reglist = fGeom->GetMaterialList(imat, nreg);
1838 // loop over regions of a given material
1839 for (Int_t k = 0; k < nreg; k++) {
1840 ireg = reglist[k];
1841 fprintf(pFlukaVmcInp,"EMFCUT %10.4g%10.4g%10.1f%10.1f%10.1f%10.1f\n", zero, cut->Cut(), zero, ireg, ireg, one);
1842 }
1843 }
829fb838 1844 } // end of else if for gamma
b2129742 1845
829fb838 1846
1847 // electrons
1848 // G4 particles: "e-"
1849 // ?? positrons
1850 // G3 default value: 0.001 GeV
1851 //gMC ->SetCut("CUTELE",cut); // cut for e+,e-
1df5fa54 1852 else if (strncmp(cut->GetName(),"CUTELE",6) == 0 && global) {
b2129742 1853 fprintf(pFlukaVmcInp,"*\n*Cut for electrons\n");
1854 fprintf(pFlukaVmcInp,"*Generated from call: SetCut('CUTELE',cut);\n");
1855 fprintf(pFlukaVmcInp,"EMFCUT %10.4g%10.4g%10.1f%10.1f%10.1f%10.1f\n",
1856 -cut->Cut(), zero, zero, zero, Float_t(fGeom->NofVolumes()), one);
829fb838 1857 }
1df5fa54 1858 else if (strncmp(cut->GetName(),"CUTELE",6) == 0 && !global) {
b2129742 1859 // loop over materials for EMFCUT FLUKA cards
1860 for (j=0; j < matMax-matMin+1; j++) {
1861 Int_t nreg, imat, *reglist;
1862 Float_t ireg;
1863 imat = (Int_t) matMin + j;
1864 reglist = fGeom->GetMaterialList(imat, nreg);
1865 // loop over regions of a given material
1866 for (k=0; k<nreg; k++) {
1867 ireg = reglist[k];
1868 fprintf(pFlukaVmcInp,"EMFCUT %10.4g%10.4g%10.1f%10.1f%10.1f%10.1f\n", -cut->Cut(), zero, zero, ireg, ireg, one);
1869 }
1870 }
829fb838 1871 } // end of else if for electrons
1872
1873
1874 // neutral hadrons
1875 // G4 particles: of type "baryon", "meson", "nucleus" with zero charge
1876 // G3 default value: 0.01 GeV
1877 //gMC ->SetCut("CUTNEU",cut); // cut for neutral hadrons
1df5fa54 1878 else if (strncmp(cut->GetName(),"CUTNEU",6) == 0 && global) {
3b8c325d 1879 fprintf(pFlukaVmcInp,"*\n*Cut for neutral hadrons\n");
1880 fprintf(pFlukaVmcInp,"*Generated from call: SetCut('CUTNEU',cut);\n");
829fb838 1881
1882 // 8.0 = Neutron
1883 // 9.0 = Antineutron
3b8c325d 1884 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),8.0,9.0);
829fb838 1885
1886 // 12.0 = Kaon zero long
1887 // 12.0 = Kaon zero long
3b8c325d 1888 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),12.0,12.0);
829fb838 1889
1890 // 17.0 = Lambda, 18.0 = Antilambda
1891 // 19.0 = Kaon zero short
3b8c325d 1892 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),17.0,19.0);
829fb838 1893
1894 // 22.0 = Sigma zero, Pion zero, Kaon zero
1895 // 25.0 = Antikaon zero
3b8c325d 1896 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),22.0,25.0);
829fb838 1897
1898 // 32.0 = Antisigma zero
1899 // 32.0 = Antisigma zero
3b8c325d 1900 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),32.0,32.0);
829fb838 1901
1902 // 34.0 = Xi zero
1903 // 35.0 = AntiXi zero
3b8c325d 1904 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),34.0,35.0);
829fb838 1905
1906 // 47.0 = D zero
1907 // 48.0 = AntiD zero
3b8c325d 1908 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),47.0,48.0);
829fb838 1909
1910 // 53.0 = Xi_c zero
1911 // 53.0 = Xi_c zero
3b8c325d 1912 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),53.0,53.0);
829fb838 1913
1914 // 55.0 = Xi'_c zero
1915 // 56.0 = Omega_c zero
3b8c325d 1916 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),55.0,56.0);
829fb838 1917
1918 // 59.0 = AntiXi_c zero
1919 // 59.0 = AntiXi_c zero
3b8c325d 1920 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),59.0,59.0);
829fb838 1921
1922 // 61.0 = AntiXi'_c zero
1923 // 62.0 = AntiOmega_c zero
3b8c325d 1924 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),61.0,62.0);
829fb838 1925 }
1926
1927 // charged hadrons
1928 // G4 particles: of type "baryon", "meson", "nucleus" with non-zero charge
1929 // G3 default value: 0.01 GeV
1930 //gMC ->SetCut("CUTHAD",cut); // cut for charged hadrons
1df5fa54 1931 else if (strncmp(cut->GetName(),"CUTHAD",6) == 0 && global) {
3b8c325d 1932 fprintf(pFlukaVmcInp,"*\n*Cut for charged hadrons\n");
1933 fprintf(pFlukaVmcInp,"*Generated from call: SetCut('CUTHAD',cut);\n");
829fb838 1934
1935 // 1.0 = Proton
1936 // 2.0 = Antiproton
3b8c325d 1937 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),1.0,2.0);
829fb838 1938
1939 // 13.0 = Positive Pion, Negative Pion, Positive Kaon
1940 // 16.0 = Negative Kaon
3b8c325d 1941 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),13.0,16.0);
829fb838 1942
1943 // 20.0 = Negative Sigma
1944 // 21.0 = Positive Sigma
3b8c325d 1945 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),20.0,21.0);
829fb838 1946
1947 // 31.0 = Antisigma minus
1948 // 33.0 = Antisigma plus
1949 // 2.0 = step length
3b8c325d 1950 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f%10.1f\n",-cut->Cut(),31.0,33.0,2.0);
829fb838 1951
1952 // 36.0 = Negative Xi, Positive Xi, Omega minus
1953 // 39.0 = Antiomega
3b8c325d 1954 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),36.0,39.0);
829fb838 1955
1956 // 45.0 = D plus
1957 // 46.0 = D minus
3b8c325d 1958 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),45.0,46.0);
829fb838 1959
1960 // 49.0 = D_s plus, D_s minus, Lambda_c plus
1961 // 52.0 = Xi_c plus
3b8c325d 1962 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),49.0,52.0);
829fb838 1963
1964 // 54.0 = Xi'_c plus
1965 // 60.0 = AntiXi'_c minus
1966 // 6.0 = step length
3b8c325d 1967 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f%10.1f\n",-cut->Cut(),54.0,60.0,6.0);
829fb838 1968
1969 // 57.0 = Antilambda_c minus
1970 // 58.0 = AntiXi_c minus
3b8c325d 1971 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),57.0,58.0);
829fb838 1972 }
1973
1974 // muons
1975 // G4 particles: "mu+", "mu-"
1976 // G3 default value: 0.01 GeV
1977 //gMC ->SetCut("CUTMUO",cut); // cut for mu+, mu-
1df5fa54 1978 else if (strncmp(cut->GetName(),"CUTMUO",6)== 0 && global) {
3b8c325d 1979 fprintf(pFlukaVmcInp,"*\n*Cut for muons\n");
1980 fprintf(pFlukaVmcInp,"*Generated from call: SetCut('CUTMUO',cut);\n");
829fb838 1981 // 10.0 = Muon+
1982 // 11.0 = Muon-
3b8c325d 1983 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),10.0,11.0);
829fb838 1984 }
1985
1986 //
1987 // time of flight cut in seconds
1988 // G4 particles: all
1989 // G3 default value: 0.01 GeV
1990 //gMC ->SetCut("TOFMAX",tofmax); // time of flight cuts in seconds
1df5fa54 1991 else if (strncmp(cut->GetName(),"TOFMAX",6) == 0) {
3b8c325d 1992 fprintf(pFlukaVmcInp,"*\n*Time of flight cuts in seconds\n");
1993 fprintf(pFlukaVmcInp,"*Generated from call: SetCut('TOFMAX',tofmax);\n");
829fb838 1994 // zero = ignored
1995 // zero = ignored
1996 // -6.0 = lower bound of the particle numbers for which the transport time cut-off and/or the start signal is to be applied
1997 // 64.0 = upper bound of the particle numbers for which the transport time cut-off and/or the start signal is to be applied
3b8c325d 1998 fprintf(pFlukaVmcInp,"TIME-CUT %10.4g%10.1f%10.1f%10.1f%10.1f\n",cut->Cut()*1.e9,zero,zero,-6.0,64.0);
829fb838 1999 }
2000
2001 else if (global){
1df5fa54 2002 cout << "SetCut for flag=" << cut->GetName() << " value=" << cut->Cut() << " not yet implemented!" << endl;
829fb838 2003 }
2004 else {
1df5fa54 2005 cout << "SetCut for flag=" << cut->GetName() << " value=" << cut->Cut() << " (material specific) not yet implemented!" << endl;
829fb838 2006 }
2007
2008 } //end of loop over SetCut calls
2009
2010// Add START and STOP card
3b8c325d 2011 fprintf(pFlukaVmcInp,"START %10.1f\n",fEventsPerRun);
2012 fprintf(pFlukaVmcInp,"STOP \n");
829fb838 2013
2014
2015// Close files
2016
3b8c325d 2017 fclose(pFlukaVmcCoreInp);
2018 fclose(pFlukaVmcFlukaMat);
2019 fclose(pFlukaVmcInp);
829fb838 2020
2021} // end of InitPhysics
2022
2023
2024//______________________________________________________________________________
07f5b33e 2025void TFluka::SetMaxStep(Double_t step)
829fb838 2026{
07f5b33e 2027// Set the maximum step size
2028 if (step > 1.e4) return;
2029
2030 Int_t mreg, latt;
2031 fGeom->GetCurrentRegion(mreg, latt);
2032 STEPSZ.stepmx[mreg - 1] = step;
829fb838 2033}
2034
2f09b80e 2035
2036Double_t TFluka::MaxStep() const
2037{
2038// Return the maximum for current medium
2039 Int_t mreg, latt;
2040 fGeom->GetCurrentRegion(mreg, latt);
2041 return (STEPSZ.stepmx[mreg - 1]);
2042}
2043
829fb838 2044//______________________________________________________________________________
2045void TFluka::SetMaxNStep(Int_t)
2046{
2047// SetMaxNStep is dummy procedure in TFluka !
2048 if (fVerbosityLevel >=3)
2049 cout << "SetMaxNStep is dummy procedure in TFluka !" << endl;
2050}
2051
2052//______________________________________________________________________________
2053void TFluka::SetUserDecay(Int_t)
2054{
2055// SetUserDecay is dummy procedure in TFluka !
2056 if (fVerbosityLevel >=3)
2057 cout << "SetUserDecay is dummy procedure in TFluka !" << endl;
2058}
2059
2060//
2061// dynamic properties
2062//
2063//______________________________________________________________________________
2064void TFluka::TrackPosition(TLorentzVector& position) const
2065{
2066// Return the current position in the master reference frame of the
2067// track being transported
2068// TRACKR.atrack = age of the particle
2069// TRACKR.xtrack = x-position of the last point
2070// TRACKR.ytrack = y-position of the last point
2071// TRACKR.ztrack = z-position of the last point
2072 Int_t caller = GetCaller();
2073 if (caller == 3 || caller == 6 || caller == 11 || caller == 12) { //bxdraw,endraw,usdraw
2074 position.SetX(GetXsco());
2075 position.SetY(GetYsco());
2076 position.SetZ(GetZsco());
2077 position.SetT(TRACKR.atrack);
2078 }
2079 else if (caller == 4) { // mgdraw
2080 position.SetX(TRACKR.xtrack[TRACKR.ntrack]);
2081 position.SetY(TRACKR.ytrack[TRACKR.ntrack]);
2082 position.SetZ(TRACKR.ztrack[TRACKR.ntrack]);
2083 position.SetT(TRACKR.atrack);
2084 }
2085 else if (caller == 5) { // sodraw
2086 position.SetX(TRACKR.xtrack[TRACKR.ntrack]);
2087 position.SetY(TRACKR.ytrack[TRACKR.ntrack]);
2088 position.SetZ(TRACKR.ztrack[TRACKR.ntrack]);
2089 position.SetT(0);
2090 }
2091 else
2092 Warning("TrackPosition","position not available");
2093}
2094
2095//______________________________________________________________________________
2096void TFluka::TrackPosition(Double_t& x, Double_t& y, Double_t& z) const
2097{
2098// Return the current position in the master reference frame of the
2099// track being transported
2100// TRACKR.atrack = age of the particle
2101// TRACKR.xtrack = x-position of the last point
2102// TRACKR.ytrack = y-position of the last point
2103// TRACKR.ztrack = z-position of the last point
2104 Int_t caller = GetCaller();
2105 if (caller == 3 || caller == 6 || caller == 11 || caller == 12) { //bxdraw,endraw,usdraw
2106 x = GetXsco();
2107 y = GetYsco();
2108 z = GetZsco();
2109 }
2110 else if (caller == 4 || caller == 5) { // mgdraw, sodraw
2111 x = TRACKR.xtrack[TRACKR.ntrack];
2112 y = TRACKR.ytrack[TRACKR.ntrack];
2113 z = TRACKR.ztrack[TRACKR.ntrack];
2114 }
2115 else
2116 Warning("TrackPosition","position not available");
2117}
2118
2119//______________________________________________________________________________
2120void TFluka::TrackMomentum(TLorentzVector& momentum) const
2121{
2122// Return the direction and the momentum (GeV/c) of the track
2123// currently being transported
2124// TRACKR.ptrack = momentum of the particle (not always defined, if
2125// < 0 must be obtained from etrack)
2126// TRACKR.cx,y,ztrck = direction cosines of the current particle
2127// TRACKR.etrack = total energy of the particle
2128// TRACKR.jtrack = identity number of the particle
2129// PAPROP.am[TRACKR.jtrack] = particle mass in gev
2130 Int_t caller = GetCaller();
2131 if (caller != 2) { // not eedraw
2132 if (TRACKR.ptrack >= 0) {
2133 momentum.SetPx(TRACKR.ptrack*TRACKR.cxtrck);
2134 momentum.SetPy(TRACKR.ptrack*TRACKR.cytrck);
2135 momentum.SetPz(TRACKR.ptrack*TRACKR.cztrck);
2136 momentum.SetE(TRACKR.etrack);
2137 return;
2138 }
2139 else {
2140 Double_t p = sqrt(TRACKR.etrack*TRACKR.etrack - PAPROP.am[TRACKR.jtrack+6]*PAPROP.am[TRACKR.jtrack+6]);
2141 momentum.SetPx(p*TRACKR.cxtrck);
2142 momentum.SetPy(p*TRACKR.cytrck);
2143 momentum.SetPz(p*TRACKR.cztrck);
2144 momentum.SetE(TRACKR.etrack);
2145 return;
2146 }
2147 }
2148 else
2149 Warning("TrackMomentum","momentum not available");
2150}
2151
2152//______________________________________________________________________________
2153void TFluka::TrackMomentum(Double_t& px, Double_t& py, Double_t& pz, Double_t& e) const
2154{
2155// Return the direction and the momentum (GeV/c) of the track
2156// currently being transported
2157// TRACKR.ptrack = momentum of the particle (not always defined, if
2158// < 0 must be obtained from etrack)
2159// TRACKR.cx,y,ztrck = direction cosines of the current particle
2160// TRACKR.etrack = total energy of the particle
2161// TRACKR.jtrack = identity number of the particle
2162// PAPROP.am[TRACKR.jtrack] = particle mass in gev
2163 Int_t caller = GetCaller();
2164 if (caller != 2) { // not eedraw
2165 if (TRACKR.ptrack >= 0) {
2166 px = TRACKR.ptrack*TRACKR.cxtrck;
2167 py = TRACKR.ptrack*TRACKR.cytrck;
2168 pz = TRACKR.ptrack*TRACKR.cztrck;
2169 e = TRACKR.etrack;
2170 return;
2171 }
2172 else {
2173 Double_t p = sqrt(TRACKR.etrack*TRACKR.etrack - PAPROP.am[TRACKR.jtrack+6]*PAPROP.am[TRACKR.jtrack+6]);
2174 px = p*TRACKR.cxtrck;
2175 py = p*TRACKR.cytrck;
2176 pz = p*TRACKR.cztrck;
2177 e = TRACKR.etrack;
2178 return;
2179 }
2180 }
2181 else
2182 Warning("TrackMomentum","momentum not available");
2183}
2184
2185//______________________________________________________________________________
2186Double_t TFluka::TrackStep() const
2187{
2188// Return the length in centimeters of the current step
2189// TRACKR.ctrack = total curved path
2190 Int_t caller = GetCaller();
2191 if (caller == 11 || caller==12 || caller == 3 || caller == 6) //bxdraw,endraw,usdraw
2192 return 0.0;
2193 else if (caller == 4) //mgdraw
2194 return TRACKR.ctrack;
2195 else
2196 return -1.0;
2197}
2198
2199//______________________________________________________________________________
2200Double_t TFluka::TrackLength() const
2201{
2202// TRACKR.cmtrck = cumulative curved path since particle birth
2203 Int_t caller = GetCaller();
2204 if (caller == 11 || caller==12 || caller == 3 || caller == 4 || caller == 6) //bxdraw,endraw,mgdraw,usdraw
2205 return TRACKR.cmtrck;
2206 else
2207 return -1.0;
2208}
2209
2210//______________________________________________________________________________
2211Double_t TFluka::TrackTime() const
2212{
2213// Return the current time of flight of the track being transported
2214// TRACKR.atrack = age of the particle
2215 Int_t caller = GetCaller();
2216 if (caller == 11 || caller==12 || caller == 3 || caller == 4 || caller == 6) //bxdraw,endraw,mgdraw,usdraw
2217 return TRACKR.atrack;
2218 else
2219 return -1;
2220}
2221
2222//______________________________________________________________________________
2223Double_t TFluka::Edep() const
2224{
2225// Energy deposition
2226// if TRACKR.ntrack = 0, TRACKR.mtrack = 0:
2227// -->local energy deposition (the value and the point are not recorded in TRACKR)
2228// but in the variable "rull" of the procedure "endraw.cxx"
2229// if TRACKR.ntrack > 0, TRACKR.mtrack = 0:
2230// -->no energy loss along the track
2231// if TRACKR.ntrack > 0, TRACKR.mtrack > 0:
2232// -->energy loss distributed along the track
07f5b33e 2233// TRACKR.dtrack = energy deposition of the jth deposition event
829fb838 2234
2235 // If coming from bxdraw we have 2 steps of 0 length and 0 edep
2236 Int_t caller = GetCaller();
2237 if (caller == 11 || caller==12) return 0.0;
2238 Double_t sum = 0;
2239 for ( Int_t j=0;j<TRACKR.mtrack;j++) {
2240 sum +=TRACKR.dtrack[j];
2241 }
2242 if (TRACKR.ntrack == 0 && TRACKR.mtrack == 0)
2243 return fRull + sum;
2244 else {
2245 return sum;
2246 }
2247}
2248
2249//______________________________________________________________________________
2250Int_t TFluka::TrackPid() const
2251{
2252// Return the id of the particle transported
2253// TRACKR.jtrack = identity number of the particle
2254 Int_t caller = GetCaller();
f926898e 2255 if (caller != 2) { // not eedraw
2256 return PDGFromId(TRACKR.jtrack);
2257 }
829fb838 2258 else
2259 return -1000;
2260}
2261
2262//______________________________________________________________________________
2263Double_t TFluka::TrackCharge() const
2264{
2265// Return charge of the track currently transported
2266// PAPROP.ichrge = electric charge of the particle
2267// TRACKR.jtrack = identity number of the particle
2268 Int_t caller = GetCaller();
2269 if (caller != 2) // not eedraw
2270 return PAPROP.ichrge[TRACKR.jtrack+6];
2271 else
2272 return -1000.0;
2273}
2274
2275//______________________________________________________________________________
2276Double_t TFluka::TrackMass() const
2277{
2278// PAPROP.am = particle mass in GeV
2279// TRACKR.jtrack = identity number of the particle
2280 Int_t caller = GetCaller();
2281 if (caller != 2) // not eedraw
2282 return PAPROP.am[TRACKR.jtrack+6];
2283 else
2284 return -1000.0;
2285}
2286
2287//______________________________________________________________________________
2288Double_t TFluka::Etot() const
2289{
2290// TRACKR.etrack = total energy of the particle
2291 Int_t caller = GetCaller();
2292 if (caller != 2) // not eedraw
2293 return TRACKR.etrack;
2294 else
2295 return -1000.0;
2296}
2297
2298//
2299// track status
2300//
2301//______________________________________________________________________________
2302Bool_t TFluka::IsNewTrack() const
2303{
2304// Return true for the first call of Stepping()
2305 return fTrackIsNew;
2306}
2307
0dabe425 2308void TFluka::SetTrackIsNew(Bool_t flag)
2309{
2310// Return true for the first call of Stepping()
2311 fTrackIsNew = flag;
2312
2313}
2314
2315
829fb838 2316//______________________________________________________________________________
2317Bool_t TFluka::IsTrackInside() const
2318{
2319// True if the track is not at the boundary of the current volume
2320// In Fluka a step is always inside one kind of material
2321// If the step would go behind the region of one material,
2322// it will be shortened to reach only the boundary.
2323// Therefore IsTrackInside() is always true.
2324 Int_t caller = GetCaller();
2325 if (caller == 11 || caller==12) // bxdraw
2326 return 0;
2327 else
2328 return 1;
2329}
2330
2331//______________________________________________________________________________
2332Bool_t TFluka::IsTrackEntering() const
2333{
2334// True if this is the first step of the track in the current volume
2335
2336 Int_t caller = GetCaller();
2337 if (caller == 11) // bxdraw entering
2338 return 1;
2339 else return 0;
2340}
2341
2342//______________________________________________________________________________
2343Bool_t TFluka::IsTrackExiting() const
2344{
2345// True if track is exiting volume
2346//
2347 Int_t caller = GetCaller();
2348 if (caller == 12) // bxdraw exiting
2349 return 1;
2350 else return 0;
2351}
2352
2353//______________________________________________________________________________
2354Bool_t TFluka::IsTrackOut() const
2355{
2356// True if the track is out of the setup
2357// means escape
2358// Icode = 14: escape - call from Kaskad
2359// Icode = 23: escape - call from Emfsco
2360// Icode = 32: escape - call from Kasneu
2361// Icode = 40: escape - call from Kashea
2362// Icode = 51: escape - call from Kasoph
2363 if (fIcode == 14 ||
2364 fIcode == 23 ||
2365 fIcode == 32 ||
2366 fIcode == 40 ||
2367 fIcode == 51) return 1;
2368 else return 0;
2369}
2370
2371//______________________________________________________________________________
2372Bool_t TFluka::IsTrackDisappeared() const
2373{
2374// means all inelastic interactions and decays
2375// fIcode from usdraw
2376 if (fIcode == 101 || // inelastic interaction
2377 fIcode == 102 || // particle decay
0dabe425 2378 fIcode == 103 || // delta ray generation by hadron
2379 fIcode == 104 || // direct pair production
2380 fIcode == 105 || // bremsstrahlung (muon)
2381 fIcode == 208 || // bremsstrahlung (electron)
829fb838 2382 fIcode == 214 || // in-flight annihilation
2383 fIcode == 215 || // annihilation at rest
2384 fIcode == 217 || // pair production
0dabe425 2385 fIcode == 219 || // Compton scattering
2386 fIcode == 221 || // Photoelectric effect
2387 fIcode == 300 || // hadronic interaction
2388 fIcode == 400 // delta-ray
2389 ) return 1;
829fb838 2390 else return 0;
2391}
2392
2393//______________________________________________________________________________
2394Bool_t TFluka::IsTrackStop() const
2395{
2396// True if the track energy has fallen below the threshold
2397// means stopped by signal or below energy threshold
2398// Icode = 12: stopping particle - call from Kaskad
2399// Icode = 15: time kill - call from Kaskad
2400// Icode = 21: below threshold, iarg=1 - call from Emfsco
2401// Icode = 22: below threshold, iarg=2 - call from Emfsco
2402// Icode = 24: time kill - call from Emfsco
2403// Icode = 31: below threshold - call from Kasneu
2404// Icode = 33: time kill - call from Kasneu
2405// Icode = 41: time kill - call from Kashea
2406// Icode = 52: time kill - call from Kasoph
2407 if (fIcode == 12 ||
2408 fIcode == 15 ||
2409 fIcode == 21 ||
2410 fIcode == 22 ||
2411 fIcode == 24 ||
2412 fIcode == 31 ||
2413 fIcode == 33 ||
2414 fIcode == 41 ||
2415 fIcode == 52) return 1;
2416 else return 0;
2417}
2418
2419//______________________________________________________________________________
2420Bool_t TFluka::IsTrackAlive() const
2421{
2422// means not disappeared or not out
2423 if (IsTrackDisappeared() || IsTrackOut() ) return 0;
2424 else return 1;
2425}
2426
2427//
2428// secondaries
2429//
2430
2431//______________________________________________________________________________
2432Int_t TFluka::NSecondaries() const
2433
2434{
2435// Number of secondary particles generated in the current step
2436// FINUC.np = number of secondaries except light and heavy ions
2437// FHEAVY.npheav = number of secondaries for light and heavy secondary ions
7b203b6e 2438 Int_t caller = GetCaller();
2439 if (caller == 6) // valid only after usdraw
2440 return FINUC.np + FHEAVY.npheav;
2441 else if (caller == 50) {
2442 // Cerenkov Photon production
2443 return fNCerenkov;
2444 }
829fb838 2445 return 0;
2446} // end of NSecondaries
2447
2448//______________________________________________________________________________
2449void TFluka::GetSecondary(Int_t isec, Int_t& particleId,
2450 TLorentzVector& position, TLorentzVector& momentum)
2451{
2452// Copy particles from secondary stack to vmc stack
2453//
2454
7b203b6e 2455 Int_t caller = GetCaller();
2456 if (caller == 6) { // valid only after usdraw
2457 if (FINUC.np > 0) {
2458 // Hadronic interaction
2459 if (isec >= 0 && isec < FINUC.np) {
2460 particleId = PDGFromId(FINUC.kpart[isec]);
2461 position.SetX(fXsco);
2462 position.SetY(fYsco);
2463 position.SetZ(fZsco);
2464 position.SetT(TRACKR.atrack);
2465 momentum.SetPx(FINUC.plr[isec]*FINUC.cxr[isec]);
2466 momentum.SetPy(FINUC.plr[isec]*FINUC.cyr[isec]);
2467 momentum.SetPz(FINUC.plr[isec]*FINUC.czr[isec]);
2468 momentum.SetE(FINUC.tki[isec] + PAPROP.am[FINUC.kpart[isec]+6]);
2469 }
2470 else if (isec >= FINUC.np && isec < FINUC.np + FHEAVY.npheav) {
2471 Int_t jsec = isec - FINUC.np;
2472 particleId = FHEAVY.kheavy[jsec]; // this is Fluka id !!!
2473 position.SetX(fXsco);
2474 position.SetY(fYsco);
2475 position.SetZ(fZsco);
2476 position.SetT(TRACKR.atrack);
2477 momentum.SetPx(FHEAVY.pheavy[jsec]*FHEAVY.cxheav[jsec]);
2478 momentum.SetPy(FHEAVY.pheavy[jsec]*FHEAVY.cyheav[jsec]);
2479 momentum.SetPz(FHEAVY.pheavy[jsec]*FHEAVY.czheav[jsec]);
2480 if (FHEAVY.tkheav[jsec] >= 3 && FHEAVY.tkheav[jsec] <= 6)
2481 momentum.SetE(FHEAVY.tkheav[jsec] + PAPROP.am[jsec+6]);
2482 else if (FHEAVY.tkheav[jsec] > 6)
2483 momentum.SetE(FHEAVY.tkheav[jsec] + FHEAVY.amnhea[jsec]); // to be checked !!!
2484 }
2485 else
2486 Warning("GetSecondary","isec out of range");
2487 }
2488 } else if (caller == 50) {
2489 Int_t index = OPPHST.lstopp - isec;
2490 position.SetX(OPPHST.xoptph[index]);
2491 position.SetY(OPPHST.yoptph[index]);
2492 position.SetZ(OPPHST.zoptph[index]);
2493 position.SetT(OPPHST.agopph[index]);
2494 Double_t p = OPPHST.poptph[index];
2495
2496 momentum.SetPx(p * OPPHST.txopph[index]);
2497 momentum.SetPy(p * OPPHST.tyopph[index]);
2498 momentum.SetPz(p * OPPHST.tzopph[index]);
2499 momentum.SetE(p);
829fb838 2500 }
2501 else
7b203b6e 2502 Warning("GetSecondary","no secondaries available");
2503
829fb838 2504} // end of GetSecondary
2505
7b203b6e 2506
829fb838 2507//______________________________________________________________________________
2508TMCProcess TFluka::ProdProcess(Int_t) const
2509
2510{
2511// Name of the process that has produced the secondary particles
2512// in the current step
0dabe425 2513
2514 Int_t mugamma = (TRACKR.jtrack == 7 || TRACKR.jtrack == 10 || TRACKR.jtrack == 11);
2515
b496f27c 2516 if (fIcode == 102) return kPDecay;
0dabe425 2517 else if (fIcode == 104 || fIcode == 217) return kPPair;
b496f27c 2518 else if (fIcode == 219) return kPCompton;
2519 else if (fIcode == 221) return kPPhotoelectric;
0dabe425 2520 else if (fIcode == 105 || fIcode == 208) return kPBrem;
2521 else if (fIcode == 103 || fIcode == 400) return kPDeltaRay;
2522 else if (fIcode == 210 || fIcode == 212) return kPDeltaRay;
2523 else if (fIcode == 214 || fIcode == 215) return kPAnnihilation;
b496f27c 2524 else if (fIcode == 101) return kPHadronic;
829fb838 2525 else if (fIcode == 101) {
b496f27c 2526 if (!mugamma) return kPHadronic;
2527 else if (TRACKR.jtrack == 7) return kPPhotoFission;
2528 else return kPMuonNuclear;
829fb838 2529 }
b496f27c 2530 else if (fIcode == 225) return kPRayleigh;
829fb838 2531// Fluka codes 100, 300 and 400 still to be investigasted
b496f27c 2532 else return kPNoProcess;
829fb838 2533}
2534
829fb838 2535
b496f27c 2536Int_t TFluka::StepProcesses(TArrayI &proc) const
2537{
2538 //
2539 // Return processes active in the current step
2540 //
2541 proc.Set(1);
2542 TMCProcess iproc;
2543 switch (fIcode) {
2544 case 15:
2545 case 24:
2546 case 33:
2547 case 41:
2548 case 52:
2549 iproc = kPTOFlimit;
2550 break;
2551 case 12:
2552 case 14:
2553 case 21:
2554 case 22:
2555 case 23:
2556 case 31:
2557 case 32:
2558 case 40:
2559 case 51:
6fd5baa4 2560 iproc = kPStop;
b496f27c 2561 break;
2562 case 50:
2563 iproc = kPLightAbsorption;
2564 break;
6fd5baa4 2565 case 59:
2566 iproc = kPLightRefraction;
b496f27c 2567 case 20:
2568 iproc = kPPhotoelectric;
2569 break;
2570 default:
2571 iproc = ProdProcess(0);
2572 }
07f5b33e 2573 proc[0] = iproc;
b496f27c 2574 return 1;
2575}
829fb838 2576//______________________________________________________________________________
2577Int_t TFluka::VolId2Mate(Int_t id) const
2578{
2579//
2580// Returns the material number for a given volume ID
2581//
2582 return fMCGeo->VolId2Mate(id);
2583}
2584
2585//______________________________________________________________________________
2586const char* TFluka::VolName(Int_t id) const
2587{
2588//
2589// Returns the volume name for a given volume ID
2590//
2591 return fMCGeo->VolName(id);
2592}
2593
2594//______________________________________________________________________________
2595Int_t TFluka::VolId(const Text_t* volName) const
2596{
2597//
2598// Converts from volume name to volume ID.
2599// Time consuming. (Only used during set-up)
2600// Could be replaced by hash-table
2601//
2602 return fMCGeo->VolId(volName);
2603}
2604
2605//______________________________________________________________________________
2606Int_t TFluka::CurrentVolID(Int_t& copyNo) const
2607{
2608//
2609// Return the logical id and copy number corresponding to the current fluka region
2610//
2611 if (gGeoManager->IsOutside()) return 0;
2612 TGeoNode *node = gGeoManager->GetCurrentNode();
2613 copyNo = node->GetNumber();
2614 Int_t id = node->GetVolume()->GetNumber();
2615 return id;
2616}
2617
2618//______________________________________________________________________________
2619Int_t TFluka::CurrentVolOffID(Int_t off, Int_t& copyNo) const
2620{
2621//
2622// Return the logical id and copy number of off'th mother
2623// corresponding to the current fluka region
2624//
2625 if (off<0 || off>gGeoManager->GetLevel()) return 0;
2626 if (off==0) return CurrentVolID(copyNo);
2627 TGeoNode *node = gGeoManager->GetMother(off);
2628 if (!node) return 0;
2629 copyNo = node->GetNumber();
2630 return node->GetVolume()->GetNumber();
2631}
2632
2633//______________________________________________________________________________
2634const char* TFluka::CurrentVolName() const
2635{
2636//
2637// Return the current volume name
2638//
2639 if (gGeoManager->IsOutside()) return 0;
2640 return gGeoManager->GetCurrentVolume()->GetName();
2641}
2642
2643//______________________________________________________________________________
2644const char* TFluka::CurrentVolOffName(Int_t off) const
2645{
2646//
2647// Return the volume name of the off'th mother of the current volume
2648//
2649 if (off<0 || off>gGeoManager->GetLevel()) return 0;
2650 if (off==0) return CurrentVolName();
2651 TGeoNode *node = gGeoManager->GetMother(off);
2652 if (!node) return 0;
2653 return node->GetVolume()->GetName();
2654}
2655
2656//______________________________________________________________________________
2657Int_t TFluka::CurrentMaterial(Float_t & /*a*/, Float_t & /*z*/,
2658 Float_t & /*dens*/, Float_t & /*radl*/, Float_t & /*absl*/) const
2659{
2660//
2661// Return the current medium number ??? what about material properties
2662//
2663 Int_t copy;
2664 Int_t id = TFluka::CurrentVolID(copy);
2665 Int_t med = TFluka::VolId2Mate(id);
2666 return med;
2667}
2668
2669//______________________________________________________________________________
2670void TFluka::Gmtod(Float_t* xm, Float_t* xd, Int_t iflag)
2671{
2672// Transforms a position from the world reference frame
2673// to the current volume reference frame.
2674//
2675// Geant3 desription:
2676// ==================
2677// Computes coordinates XD (in DRS)
2678// from known coordinates XM in MRS
2679// The local reference system can be initialized by
2680// - the tracking routines and GMTOD used in GUSTEP
2681// - a call to GMEDIA(XM,NUMED)
2682// - a call to GLVOLU(NLEVEL,NAMES,NUMBER,IER)
2683// (inverse routine is GDTOM)
2684//
2685// If IFLAG=1 convert coordinates
2686// IFLAG=2 convert direction cosinus
2687//
2688// ---
2689 Double_t xmL[3], xdL[3];
2690 Int_t i;
2691 for (i=0;i<3;i++) xmL[i]=xm[i];
2692 if (iflag == 1) gGeoManager->MasterToLocal(xmL,xdL);
2693 else gGeoManager->MasterToLocalVect(xmL,xdL);
2694 for (i=0;i<3;i++) xd[i] = xdL[i];
2695}
2696
2697//______________________________________________________________________________
2698void TFluka::Gmtod(Double_t* xm, Double_t* xd, Int_t iflag)
2699{
2700 if (iflag == 1) gGeoManager->MasterToLocal(xm,xd);
2701 else gGeoManager->MasterToLocalVect(xm,xd);
2702}
2703
2704//______________________________________________________________________________
2705void TFluka::Gdtom(Float_t* xd, Float_t* xm, Int_t iflag)
2706{
2707// Transforms a position from the current volume reference frame
2708// to the world reference frame.
2709//
2710// Geant3 desription:
2711// ==================
2712// Computes coordinates XM (Master Reference System
2713// knowing the coordinates XD (Detector Ref System)
2714// The local reference system can be initialized by
2715// - the tracking routines and GDTOM used in GUSTEP
2716// - a call to GSCMED(NLEVEL,NAMES,NUMBER)
2717// (inverse routine is GMTOD)
2718//
2719// If IFLAG=1 convert coordinates
2720// IFLAG=2 convert direction cosinus
2721//
2722// ---
2723 Double_t xmL[3], xdL[3];
2724 Int_t i;
2725 for (i=0;i<3;i++) xdL[i] = xd[i];
2726 if (iflag == 1) gGeoManager->LocalToMaster(xdL,xmL);
2727 else gGeoManager->LocalToMasterVect(xdL,xmL);
2728 for (i=0;i<3;i++) xm[i]=xmL[i];
2729}
2730
2731//______________________________________________________________________________
2732void TFluka::Gdtom(Double_t* xd, Double_t* xm, Int_t iflag)
2733{
2734 if (iflag == 1) gGeoManager->LocalToMaster(xd,xm);
2735 else gGeoManager->LocalToMasterVect(xd,xm);
2736}
2737
2738//______________________________________________________________________________
2739TObjArray *TFluka::GetFlukaMaterials()
2740{
2741 return fGeom->GetMatList();
2742}
2743
2744//______________________________________________________________________________
2745void TFluka::SetMreg(Int_t l)
2746{
2747// Set current fluka region
2748 fCurrentFlukaRegion = l;
2749 fGeom->SetMreg(l);
2750}
2751
2752
b496f27c 2753
2754
2755TString TFluka::ParticleName(Int_t pdg) const
2756{
2757 // Return particle name for particle with pdg code pdg.
2758 Int_t ifluka = IdFromPDG(pdg);
2759 return TString((CHPPRP.btype[ifluka+6]), 8);
2760}
2761
2762
2763Double_t TFluka::ParticleMass(Int_t pdg) const
2764{
2765 // Return particle mass for particle with pdg code pdg.
2766 Int_t ifluka = IdFromPDG(pdg);
2767 return (PAPROP.am[ifluka+6]);
2768}
2769
2770Double_t TFluka::ParticleCharge(Int_t pdg) const
2771{
2772 // Return particle charge for particle with pdg code pdg.
2773 Int_t ifluka = IdFromPDG(pdg);
2774 return Double_t(PAPROP.ichrge[ifluka+6]);
2775}
2776
2777Double_t TFluka::ParticleLifeTime(Int_t pdg) const
2778{
2779 // Return particle lifetime for particle with pdg code pdg.
2780 Int_t ifluka = IdFromPDG(pdg);
2781 return (PAPROP.thalf[ifluka+6]);
2782}
2783
2784void TFluka::Gfpart(Int_t pdg, char* name, Int_t& type, Float_t& mass, Float_t& charge, Float_t& tlife)
2785{
2786 // Retrieve particle properties for particle with pdg code pdg.
2787
2788 strcpy(name, ParticleName(pdg).Data());
2789 type = ParticleMCType(pdg);
2790 mass = ParticleMass(pdg);
2791 charge = ParticleCharge(pdg);
2792 tlife = ParticleLifeTime(pdg);
2793}
2794
2795
2796
3a625972 2797#define pushcerenkovphoton pushcerenkovphoton_
7b203b6e 2798#define usersteppingckv usersteppingckv_
3a625972 2799
2800
2801extern "C" {
2802 void pushcerenkovphoton(Double_t & px, Double_t & py, Double_t & pz, Double_t & e,
2803 Double_t & vx, Double_t & vy, Double_t & vz, Double_t & tof,
2804 Double_t & polx, Double_t & poly, Double_t & polz, Double_t & wgt, Int_t& ntr)
2805 {
2806 //
2807 // Pushes one cerenkov photon to the stack
2808 //
2809
2810 TFluka* fluka = (TFluka*) gMC;
2811 TVirtualMCStack* cppstack = fluka->GetStack();
bd3d5c8a 2812 Int_t parent = TRACKR.ispusr[mkbmx2-1];
921e0994 2813 cppstack->PushTrack(0, parent, 50000050,
3a625972 2814 px, py, pz, e,
2815 vx, vy, vz, tof,
2816 polx, poly, polz,
2817 kPCerenkov, ntr, wgt, 0);
2818 }
7b203b6e 2819
2820 void usersteppingckv(Int_t & nphot, Int_t & mreg, Double_t & x, Double_t & y, Double_t & z)
2821 {
2822 //
2823 // Calls stepping in order to signal cerenkov production
2824 //
2825 TFluka *fluka = (TFluka*)gMC;
2826 fluka->SetMreg(mreg);
2827 fluka->SetXsco(x);
2828 fluka->SetYsco(y);
2829 fluka->SetZsco(z);
2830 fluka->SetNCerenkov(nphot);
2831 fluka->SetCaller(50);
2832 printf("userstepping ckv: %10d %10d %13.3f %13.3f %13.2f\n", nphot, mreg, x, y, z);
2833 (TVirtualMCApplication::Instance())->Stepping();
2834 }
3a625972 2835}
829fb838 2836