]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TFluka/TFluka.cxx
export AliBitPacking.h
[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
1df5fa54 825//
826//
827// Update if already in the list
829fb838 828//
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
1077 // gMC ->SetProcess("PAIR",1); // PAIRBREM 1. 0. 0. 3. lastmat
1078 // EMFCUT 0. 0. -1. 3. lastmat 0. PHOT-THR
1df5fa54 1079 else if ((strncmp(proc->GetName(),"PAIR",4) == 0) && (proc->Flag() == 1 || proc->Flag() == 2)) {
829fb838 1080
1df5fa54 1081 nextp.Reset();
1082
1083 while ((procp = (TFlukaConfigOption*)nextp())) {
1084 if ((strncmp(procp->GetName(),"BREM",4) == 0) &&
1085 (proc->Flag() == 1 || procp->Flag() == 2) &&
1086 (procp->Medium() == proc->Medium())) {
3b8c325d 1087 fprintf(pFlukaVmcInp,"*\n*Bremsstrahlung and pair production by muons and charged hadrons both activated\n");
1088 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('BREM',1) and SetProcess('PAIR',1)\n");
1089 fprintf(pFlukaVmcInp,"*Energy threshold set by call SetCut('BCUTM',cut) or set to 0.\n");
1090 fprintf(pFlukaVmcInp,"*Energy threshold set by call SetCut('PPCUTM',cut) or set to 0.\n");
829fb838 1091 // three = bremsstrahlung and pair production by muons and charged hadrons both are activated
3b8c325d 1092 fprintf(pFlukaVmcInp,"PAIRBREM %10.1f",three);
829fb838 1093 // direct pair production by muons
1094 // G4 particles: "e-", "e+"
1095 // G3 default value: 0.01 GeV
1096 //gMC ->SetCut("PPCUTM",cut); // total energy cut for direct pair prod. by muons
b2129742 1097 theCut = 0.0;
1df5fa54 1098 nextc.Reset();
1099 while ((cut = (TFlukaConfigOption*)nextc())) {
1100 if (strncmp(cut->GetName(), "PPCUTM", 6) == 0 &&
b2129742 1101 (cut->Medium() == proc->Medium())) theCut = cut->Cut();
829fb838 1102 }
b2129742 1103 fprintf(pFlukaVmcInp,"%10.4g",theCut);
1104 // theCut; = e+, e- kinetic energy threshold (in GeV) for explicit pair production.
829fb838 1105 // muon and hadron bremsstrahlung
1106 // G4 particles: "gamma"
1107 // G3 default value: CUTGAM=0.001 GeV
1108 //gMC ->SetCut("BCUTM",cut); // cut for muon and hadron bremsstrahlung
b2129742 1109 theCut = 0.0;
1df5fa54 1110 nextc.Reset();
1111 while ((cut = (TFlukaConfigOption*)nextc())) {
1112 if (strncmp(cut->GetName(), "BCUTM", 5) == 0 &&
b2129742 1113 (cut->Medium() == proc->Medium())) theCut = cut->Cut();
829fb838 1114 }
b2129742 1115 fprintf(pFlukaVmcInp,"%10.4g%10.1f%10.1f\n",theCut,matMin,matMax);
1116 // theCut = photon energy threshold (GeV) for explicit bremsstrahlung production
829fb838 1117 // matMin = lower bound of the material indices in which the respective thresholds apply
1118 // matMax = upper bound of the material indices in which the respective thresholds apply
1119
1120 // for e+ and e-
3b8c325d 1121 fprintf(pFlukaVmcInp,"*\n*Kinetic energy threshold (GeV) for e+/e- bremsstrahlung - resets to default=0.\n");
1122 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('BREM',1);\n");
b2129742 1123 theCut = -1.0;
1df5fa54 1124 nextc.Reset();
1125 while ((cut = (TFlukaConfigOption*)nextc())) {
1126 if (strncmp(cut->GetName(), "BCUTE", 5) == 0 &&
b2129742 1127 (cut->Medium() == proc->Medium())) theCut = cut->Cut();
829fb838 1128 }
b2129742 1129 //theCut = kinetic energy threshold (GeV) for e+/e- bremsstrahlung (resets to default=0)
829fb838 1130 // zero = not used
1131 // zero = not used
1132 // matMin = lower bound of the material indices in which the respective thresholds apply
1133 // matMax = upper bound of the material indices in which the respective thresholds apply
1134 // one = step length in assigning indices
1135 // "ELPO-THR";
b2129742 1136 fprintf(pFlukaVmcInp,"EMFCUT %10.4g%10.1f%10.1f%10.1f%10.1f%10.1fELPO-THR\n",theCut,zero,zero,matMin,matMax,one);
829fb838 1137
1138 // for e+ and e-
3b8c325d 1139 fprintf(pFlukaVmcInp,"*\n*Pair production by electrons is activated\n");
1140 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('PAIR',1);\n");
b2129742 1141 theCut = -1.0;
1df5fa54 1142 nextc.Reset();
1143 while ((cut = (TFlukaConfigOption*)nextc())) {
1144 if (strncmp(cut->GetName(), "CUTGAM", 6) == 0 &&
b2129742 1145 (cut->Medium() == proc->Medium())) theCut = cut->Cut();
829fb838 1146 }
b2129742 1147 // theCut = energy threshold (GeV) for gamma pair production (< 0.0 : resets to default, = 0.0 : ignored)
829fb838 1148 // matMin = lower bound of the material indices in which the respective thresholds apply
1149 // matMax = upper bound of the material indices in which the respective thresholds apply
1150 // one = step length in assigning indices
b2129742 1151 fprintf(pFlukaVmcInp,"EMFCUT %10.1f%10.1f%10.4g%10.1f%10.1f%10.1fPHOT-THR\n",zero,zero,theCut,matMin,matMax,one);
829fb838 1152 goto BOTH;
1153 } // end of if for BREM
1154 } // end of loop for BREM
1155
1156 // only pair production by muons and charged hadrons is activated
3b8c325d 1157 fprintf(pFlukaVmcInp,"*\n*Pair production by muons and charged hadrons is activated\n");
1158 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('PAIR',1) or SetProcess('PAIR',2)\n");
1159 fprintf(pFlukaVmcInp,"*Energy threshold set by call SetCut('PPCUTM',cut) or set to 0.\n");
829fb838 1160 // direct pair production by muons
1161 // G4 particles: "e-", "e+"
1162 // G3 default value: 0.01 GeV
1163 //gMC ->SetCut("PPCUTM",cut); // total energy cut for direct pair prod. by muons
1164 // one = pair production by muons and charged hadrons is activated
1165 // zero = e+, e- kinetic energy threshold (in GeV) for explicit pair production.
1166 // zero = no explicit bremsstrahlung production is simulated
1167 // matMin = lower bound of the material indices in which the respective thresholds apply
1168 // matMax = upper bound of the material indices in which the respective thresholds apply
3b8c325d 1169 fprintf(pFlukaVmcInp,"PAIRBREM %10.1f%10.1f%10.1f%10.1f%10.1f\n",one,zero,zero,matMin,matMax);
829fb838 1170
1171 // for e+ and e-
3b8c325d 1172 fprintf(pFlukaVmcInp,"*\n*Pair production by electrons is activated\n");
1173 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('PAIR',1) or SetProcess('PAIR',2)\n");
b2129742 1174 theCut = -1.0;
1df5fa54 1175 nextc.Reset();
1176 while ((cut = (TFlukaConfigOption*)nextc())) {
1177 if (strncmp(cut->GetName(), "CUTGAM", 6) == 0 &&
b2129742 1178 (cut->Medium() == proc->Medium())) theCut = cut->Cut();
829fb838 1179 }
1180 // zero = energy threshold (GeV) for Compton scattering (= 0.0 : ignored)
1181 // zero = energy threshold (GeV) for Photoelectric (= 0.0 : ignored)
b2129742 1182 // theCut = energy threshold (GeV) for gamma pair production (< 0.0 : resets to default, = 0.0 : ignored)
829fb838 1183 // matMin = lower bound of the material indices in which the respective thresholds apply
1184 // matMax = upper bound of the material indices in which the respective thresholds apply
1185 // one = step length in assigning indices
b2129742 1186 fprintf(pFlukaVmcInp,"EMFCUT %10.1f%10.1f%10.4g%10.1f%10.1f%10.1fPHOT-THR\n",zero,zero,theCut,matMin,matMax,one);
829fb838 1187
1188 BOTH:
1189 k = 0;
1190 } // end of if for PAIR
1191
1192
1193
1194 // bremsstrahlung
1195 // G3 default value: 1
1196 // G4 processes: G4eBremsstrahlung/G4IeBremsstrahlung,
1197 // G4MuBremsstrahlung/G4IMuBremsstrahlung,
1198 // G4LowEnergyBremstrahlung
1199 // Particles: e-/e+; mu+/mu-
1200 // Physics: EM
1201 // flag = 0 no bremsstrahlung
1202 // flag = 1 bremsstrahlung, photon processed
1203 // flag = 2 bremsstrahlung, no photon stored
1204 // gMC ->SetProcess("BREM",1); // PAIRBREM 2. 0. 0. 3. lastmat
1205 // EMFCUT -1. 0. 0. 3. lastmat 0. ELPO-THR
1df5fa54 1206 else if (strncmp(proc->GetName(),"BREM",4) == 0) {
1207 nextp.Reset();
1208 while((procp = (TFlukaConfigOption*)nextp())) {
1209 if ((strncmp(procp->GetName(),"PAIR",4) == 0) &&
1210 procp->Flag() == 1 &&
1211 (procp->Medium() == proc->Medium())) goto NOBREM;
829fb838 1212 }
1df5fa54 1213 if (proc->Flag() == 1 || proc->Flag() == 2) {
3b8c325d 1214 fprintf(pFlukaVmcInp,"*\n*Bremsstrahlung by muons and charged hadrons is activated\n");
1215 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('BREM',1) or SetProcess('BREM',2)\n");
1216 fprintf(pFlukaVmcInp,"*Energy threshold set by call SetCut('BCUTM',cut) or set to 0.\n");
829fb838 1217 // two = bremsstrahlung by muons and charged hadrons is activated
1218 // zero = no meaning
1219 // muon and hadron bremsstrahlung
1220 // G4 particles: "gamma"
1221 // G3 default value: CUTGAM=0.001 GeV
1222 //gMC ->SetCut("BCUTM",cut); // cut for muon and hadron bremsstrahlung
b2129742 1223 theCut = 0.0;
1df5fa54 1224 nextc.Reset();
1225 while ((cut = (TFlukaConfigOption*)nextc())) {
1226 if (strncmp(cut->GetName(), "BCUTM", 5) == 0 &&
b2129742 1227 (cut->Medium() == proc->Medium())) theCut = cut->Cut();
829fb838 1228 }
b2129742 1229 // theCut = photon energy threshold (GeV) for explicit bremsstrahlung production
829fb838 1230 // matMin = lower bound of the material indices in which the respective thresholds apply
1231 // matMax = upper bound of the material indices in which the respective thresholds apply
b2129742 1232 fprintf(pFlukaVmcInp,"PAIRBREM %10.1f%10.1f%10.4g%10.1f%10.1f\n",two,zero,theCut,matMin,matMax);
829fb838 1233
1234 // for e+ and e-
3b8c325d 1235 fprintf(pFlukaVmcInp,"*\n*Kinetic energy threshold (GeV) for e+/e- bremsstrahlung - resets to default=0.\n");
1236 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('BREM',1);");
829fb838 1237 // - one = kinetic energy threshold (GeV) for e+/e- bremsstrahlung (resets to default=0)
1238 // zero = not used
1239 // zero = not used
1240 // matMin = lower bound of the material indices in which the respective thresholds apply
1241 // matMax = upper bound of the material indices in which the respective thresholds apply
1242 // one = step length in assigning indices
1243 //"ELPO-THR";
3b8c325d 1244 fprintf(pFlukaVmcInp,"EMFCUT %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fELPO-THR\n",-one,zero,zero,matMin,matMax,one);
829fb838 1245 }
1df5fa54 1246 else if (proc->Flag() == 0) {
3b8c325d 1247 fprintf(pFlukaVmcInp,"*\n*No bremsstrahlung - no FLUKA card generated\n");
1248 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('BREM',0)\n");
829fb838 1249 }
1250 else {
3b8c325d 1251 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('BREM',?) call.\n");
1252 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1253 }
1254 NOBREM:
1255 j = 0;
1df5fa54 1256 } // end of else if (strncmp(proc->GetName(),"BREM",4) == 0)
829fb838 1257
1258 // Cerenkov photon generation
1259 // G3 default value: 0
1260 // G4 process: G4Cerenkov
1261 //
1262 // Particles: charged
1263 // Physics: Optical
1264 // flag = 0 no Cerenkov photon generation
1265 // flag = 1 Cerenkov photon generation
1266 // flag = 2 Cerenkov photon generation with primary stopped at each step
1267 //xx gMC ->SetProcess("CKOV",1); // ??? Cerenkov photon generation
1268
1df5fa54 1269 else if (strncmp(proc->GetName(),"CKOV",4) == 0) {
1270 if ((proc->Flag() == 1 || proc->Flag() == 2) && global) {
829fb838 1271 // Write comments
3b8c325d 1272 fprintf(pFlukaVmcInp, "* \n");
1273 fprintf(pFlukaVmcInp, "*Cerenkov photon generation\n");
1274 fprintf(pFlukaVmcInp, "*Generated from call: SetProcess('CKOV',1) or SetProcess('CKOV',2)\n");
829fb838 1275 // Loop over media
1276 for (Int_t im = 0; im < nmaterial; im++)
1277 {
1278 TGeoMaterial* material = dynamic_cast<TGeoMaterial*> (matList->At(im));
1279 Int_t idmat = material->GetIndex();
1280
1df5fa54 1281 if (!global && idmat != proc->Medium()) continue;
829fb838 1282
1283 fMaterials[idmat] = im;
1284 // Skip media with no Cerenkov properties
1285 TFlukaCerenkov* cerenkovProp;
1286 if (!(cerenkovProp = dynamic_cast<TFlukaCerenkov*>(material->GetCerenkovProperties()))) continue;
1287 //
1288 // This medium has Cerenkov properties
1289 //
1290 //
1291 // Write OPT-PROD card for each medium
1292 Float_t emin = cerenkovProp->GetMinimumEnergy();
1293 Float_t emax = cerenkovProp->GetMaximumEnergy();
3b8c325d 1294 fprintf(pFlukaVmcInp, "OPT-PROD %10.4g%10.4g%10.4g%10.4g%10.4g%10.4gCERENKOV\n", emin, emax, 0.,
829fb838 1295 Float_t(idmat), Float_t(idmat), 0.);
1296 //
1297 // Write OPT-PROP card for each medium
1298 // Forcing FLUKA to call user routines (queffc.cxx, rflctv.cxx, rfrndx.cxx)
1299 //
3b8c325d 1300 fprintf(pFlukaVmcInp, "OPT-PROP %10.4g%10.4g%10.4g%10.1f%10.1f%10.1fWV-LIMIT\n",
829fb838 1301 cerenkovProp->GetMinimumWavelength(),
1302 cerenkovProp->GetMaximumWavelength(),
1303 cerenkovProp->GetMaximumWavelength(),
1304 Float_t(idmat), Float_t(idmat), 0.0);
1305
1306 if (cerenkovProp->IsMetal()) {
3b8c325d 1307 fprintf(pFlukaVmcInp, "OPT-PROP %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fMETAL\n",
829fb838 1308 -100., -100., -100.,
1309 Float_t(idmat), Float_t(idmat), 0.0);
1310 } else {
3b8c325d 1311 fprintf(pFlukaVmcInp, "OPT-PROP %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",
829fb838 1312 -100., -100., -100.,
1313 Float_t(idmat), Float_t(idmat), 0.0);
1314 }
1315
1316
1317 for (Int_t j = 0; j < 3; j++) {
3b8c325d 1318 fprintf(pFlukaVmcInp, "OPT-PROP %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f&\n",
829fb838 1319 -100., -100., -100.,
1320 Float_t(idmat), Float_t(idmat), 0.0);
1321 }
1322 // Photon detection efficiency user defined
1323
1324 if (cerenkovProp->IsSensitive())
3b8c325d 1325 fprintf(pFlukaVmcInp, "OPT-PROP %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fSENSITIV\n",
829fb838 1326 -100., -100., -100.,
1327 Float_t(idmat), Float_t(idmat), 0.0);
1328
1329 } // materials
1df5fa54 1330 } else if (proc->Flag() == 0) {
3b8c325d 1331 fprintf(pFlukaVmcInp,"*\n*No Cerenkov photon generation\n");
1332 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('CKOV',0)\n");
829fb838 1333 // zero = not used
1334 // zero = not used
1335 // zero = not used
1336 // matMin = lower bound of the material indices in which the respective thresholds apply
1337 // matMax = upper bound of the material indices in which the respective thresholds apply
1338 // one = step length in assigning indices
1339 //"CERE-OFF";
3b8c325d 1340 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 1341 }
1342 else {
3b8c325d 1343 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('CKOV',?) call.\n");
1344 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1345 }
1df5fa54 1346 } // end of else if (strncmp(proc->GetName(),"CKOV",4) == 0)
829fb838 1347
1348 // Compton scattering
1349 // G3 default value: 1
1350 // G4 processes: G4ComptonScattering,
1351 // G4LowEnergyCompton,
1352 // G4PolarizedComptonScattering
1353 // Particles: gamma
1354 // Physics: EM
1355 // flag = 0 no Compton scattering
1356 // flag = 1 Compton scattering, electron processed
1357 // flag = 2 Compton scattering, no electron stored
1358 // gMC ->SetProcess("COMP",1); // EMFCUT -1. 0. 0. 3. lastmat 0. PHOT-THR
1df5fa54 1359 else if (strncmp(proc->GetName(),"COMP",4) == 0) {
1360 if (proc->Flag() == 1 || proc->Flag() == 2) {
3b8c325d 1361 fprintf(pFlukaVmcInp,"*\n*Energy threshold (GeV) for Compton scattering - resets to default=0.\n");
1362 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('COMP',1);\n");
829fb838 1363 // - one = energy threshold (GeV) for Compton scattering - resets to default=0.
1364 // zero = not used
1365 // zero = not used
1366 // matMin = lower bound of the material indices in which the respective thresholds apply
1367 // matMax = upper bound of the material indices in which the respective thresholds apply
1368 // one = step length in assigning indices
1369 //"PHOT-THR";
3b8c325d 1370 fprintf(pFlukaVmcInp,"EMFCUT %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fPHOT-THR\n",-one,zero,zero,matMin,matMax,one);
829fb838 1371 }
1df5fa54 1372 else if (proc->Flag() == 0) {
3b8c325d 1373 fprintf(pFlukaVmcInp,"*\n*No Compton scattering - no FLUKA card generated\n");
1374 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('COMP',0)\n");
829fb838 1375 }
1376 else {
3b8c325d 1377 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('COMP',?) call.\n");
1378 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1379 }
1df5fa54 1380 } // end of else if (strncmp(proc->GetName(),"COMP",4) == 0)
829fb838 1381
1382 // decay
1383 // G3 default value: 1
1384 // G4 process: G4Decay
1385 //
1386 // Particles: all which decay is applicable for
1387 // Physics: General
1388 // flag = 0 no decays
1389 // flag = 1 decays, secondaries processed
1390 // flag = 2 decays, no secondaries stored
7f13be31 1391 //gMC ->SetProcess("DCAY",0); // not available
83ec523a 1392 else if ((strncmp(proc->GetName(),"DCAY",4) == 0) && proc->Flag() == 0)
7f13be31 1393 cout << "SetProcess for flag =" << proc->GetName() << " value=" << proc->Flag() << " not avaliable!" << endl;
1394 else if ((strncmp(proc->GetName(),"DCAY",4) == 0) && proc->Flag() == 1) {
1395 // Nothing to do decays are switched on by default
1396 }
1397
829fb838 1398
1399 // delta-ray
1400 // G3 default value: 2
1401 // !! G4 treats delta rays in different way
1402 // G4 processes: G4eIonisation/G4IeIonization,
1403 // G4MuIonisation/G4IMuIonization,
1404 // G4hIonisation/G4IhIonisation
1405 // Particles: charged
1406 // Physics: EM
1407 // flag = 0 no energy loss
1408 // flag = 1 restricted energy loss fluctuations
1409 // flag = 2 complete energy loss fluctuations
1410 // flag = 3 same as 1
1411 // flag = 4 no energy loss fluctuations
1412 // gMC ->SetProcess("DRAY",0); // DELTARAY 1.E+6 0. 0. 3. lastmat 0.
1df5fa54 1413 else if (strncmp(proc->GetName(),"DRAY",4) == 0) {
1414 if (proc->Flag() == 0 || proc->Flag() == 4) {
3b8c325d 1415 fprintf(pFlukaVmcInp,"*\n*Kinetic energy threshold (GeV) for delta ray production\n");
1416 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('DRAY',0) or SetProcess('DRAY',4)\n");
1417 fprintf(pFlukaVmcInp,"*No delta ray production by muons - threshold set artificially high\n");
829fb838 1418 Double_t emin = 1.0e+6; // kinetic energy threshold (GeV) for delta ray production (discrete energy transfer)
1419 // zero = ignored
1420 // zero = ignored
1421 // matMin = lower bound of the material indices in which the respective thresholds apply
1422 // matMax = upper bound of the material indices in which the respective thresholds apply
1423 // one = step length in assigning indices
3b8c325d 1424 fprintf(pFlukaVmcInp,"DELTARAY %10.4g%10.1f%10.1f%10.1f%10.1f%10.1f\n",emin,zero,zero,matMin,matMax,one);
829fb838 1425 }
1df5fa54 1426 else if (proc->Flag() == 1 || proc->Flag() == 2 || proc->Flag() == 3) {
3b8c325d 1427 fprintf(pFlukaVmcInp,"*\n*Kinetic energy threshold (GeV) for delta ray production\n");
1428 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('DRAY',flag), flag=1,2,3\n");
1429 fprintf(pFlukaVmcInp,"*Delta ray production by muons switched on\n");
1430 fprintf(pFlukaVmcInp,"*Energy threshold set by call SetCut('DCUTM',cut) or set to 1.0e+6.\n");
b2129742 1431 theCut = 1.0e+6;
1df5fa54 1432 nextc.Reset();
b2129742 1433 //
1434 // Check cut one delta-rays from electrons
1435 //
1df5fa54 1436 while ((cut = (TFlukaConfigOption*)nextc())) {
1437 if (strncmp(cut->GetName(), "DCUTM", 5) == 0 &&
b2129742 1438 cut->Medium() == proc->Medium()) theCut = cut->Cut();
829fb838 1439 }
b2129742 1440 // theCut = kinetic energy threshold (GeV) for delta ray production (discrete energy transfer)
829fb838 1441 // zero = ignored
1442 // zero = ignored
1443 // matMin = lower bound of the material indices in which the respective thresholds apply
1444 // matMax = upper bound of the material indices in which the respective thresholds apply
1445 // one = step length in assigning indices
b2129742 1446 fprintf(pFlukaVmcInp,"DELTARAY %10.4g%10.1f%10.1f%10.1f%10.1f%10.1f\n",theCut,zero,zero,matMin,matMax,one);
829fb838 1447 }
1448 else {
3b8c325d 1449 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('DRAY',?) call.\n");
1450 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1451 }
1df5fa54 1452 } // end of else if (strncmp(proc->GetName(),"DRAY",4) == 0)
829fb838 1453
1454 // hadronic process
1455 // G3 default value: 1
1456 // G4 processes: all defined by TG4PhysicsConstructorHadron
1457 //
1458 // Particles: hadrons
1459 // Physics: Hadron
1460 // flag = 0 no multiple scattering
1461 // flag = 1 hadronic interactions, secondaries processed
1462 // flag = 2 hadronic interactions, no secondaries stored
1463 // gMC ->SetProcess("HADR",1); // ??? hadronic process
1464 //Select pure GEANH (HADR 1) or GEANH/NUCRIN (HADR 3) ?????
1df5fa54 1465 else if (strncmp(proc->GetName(),"HADR",4) == 0) {
1466 if (proc->Flag() == 1 || proc->Flag() == 2) {
3b8c325d 1467 fprintf(pFlukaVmcInp,"*\n*Hadronic interaction is ON by default in FLUKA\n");
1468 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1469 }
1df5fa54 1470 else if (proc->Flag() == 0) {
3b8c325d 1471 fprintf(pFlukaVmcInp,"*\n*Hadronic interaction is set OFF\n");
1472 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('HADR',0);\n");
1473 fprintf(pFlukaVmcInp,"*Switching off hadronic interactions not foreseen in FLUKA\n");
1474 fprintf(pFlukaVmcInp,"THRESHOL %10.1f%10.1f%10.1f%10.1e%10.1f\n",zero, zero, zero, 1.e10, zero);
829fb838 1475 }
1476 else {
3b8c325d 1477 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('HADR',?) call.\n");
1478 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1479 }
1df5fa54 1480 } // end of else if (strncmp(proc->GetName(),"HADR",4) == 0)
829fb838 1481
1482
1483 // energy loss
1484 // G3 default value: 2
1485 // G4 processes: G4eIonisation/G4IeIonization,
1486 // G4MuIonisation/G4IMuIonization,
1487 // G4hIonisation/G4IhIonisation
1488 //
1489 // Particles: charged
1490 // Physics: EM
1491 // flag=0 no energy loss
1492 // flag=1 restricted energy loss fluctuations
1493 // flag=2 complete energy loss fluctuations
1494 // flag=3 same as 1
1495 // flag=4 no energy loss fluctuations
1496 // If the value ILOSS is changed, then (in G3) cross-sections and energy
1497 // loss tables must be recomputed via the command 'PHYSI'
1498 // gMC ->SetProcess("LOSS",2); // ??? IONFLUCT ? energy loss
1df5fa54 1499 else if (strncmp(proc->GetName(),"LOSS",4) == 0) {
1500 if (proc->Flag() == 2) { // complete energy loss fluctuations
3b8c325d 1501 fprintf(pFlukaVmcInp,"*\n*Complete energy loss fluctuations do not exist in FLUKA\n");
1502 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('LOSS',2);\n");
1503 fprintf(pFlukaVmcInp,"*flag=2=complete energy loss fluctuations\n");
1504 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1505 }
1df5fa54 1506 else if (proc->Flag() == 1 || proc->Flag() == 3) { // restricted energy loss fluctuations
3b8c325d 1507 fprintf(pFlukaVmcInp,"*\n*Restricted energy loss fluctuations\n");
1508 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('LOSS',1) or SetProcess('LOSS',3)\n");
829fb838 1509 // one = restricted energy loss fluctuations (for hadrons and muons) switched on
1510 // one = restricted energy loss fluctuations (for e+ and e-) switched on
1511 // one = minimal accuracy
1512 // matMin = lower bound of the material indices in which the respective thresholds apply
1513 // upper bound of the material indices in which the respective thresholds apply
3b8c325d 1514 fprintf(pFlukaVmcInp,"IONFLUCT %10.1f%10.1f%10.1f%10.1f%10.1f\n",one,one,one,matMin,matMax);
829fb838 1515 }
1df5fa54 1516 else if (proc->Flag() == 4) { // no energy loss fluctuations
3b8c325d 1517 fprintf(pFlukaVmcInp,"*\n*No energy loss fluctuations\n");
1518 fprintf(pFlukaVmcInp,"*\n*Generated from call: SetProcess('LOSS',4)\n");
829fb838 1519 // - one = restricted energy loss fluctuations (for hadrons and muons) switched off
1520 // - one = restricted energy loss fluctuations (for e+ and e-) switched off
1521 // one = minimal accuracy
1522 // matMin = lower bound of the material indices in which the respective thresholds apply
1523 // matMax = upper bound of the material indices in which the respective thresholds apply
3b8c325d 1524 fprintf(pFlukaVmcInp,"IONFLUCT %10.1f%10.1f%10.1f%10.1f%10.1f\n",-one,-one,one,matMin,matMax);
829fb838 1525 }
1526 else {
3b8c325d 1527 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('LOSS',?) call.\n");
1528 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1529 }
1df5fa54 1530 } // end of else if (strncmp(proc->GetName(),"LOSS",4) == 0)
829fb838 1531
1532
1533 // multiple scattering
1534 // G3 default value: 1
1535 // G4 process: G4MultipleScattering/G4IMultipleScattering
1536 //
1537 // Particles: charged
1538 // Physics: EM
1539 // flag = 0 no multiple scattering
1540 // flag = 1 Moliere or Coulomb scattering
1541 // flag = 2 Moliere or Coulomb scattering
1542 // flag = 3 Gaussian scattering
1543 // gMC ->SetProcess("MULS",1); // MULSOPT multiple scattering
1df5fa54 1544 else if (strncmp(proc->GetName(),"MULS",4) == 0) {
1545 if (proc->Flag() == 1 || proc->Flag() == 2 || proc->Flag() == 3) {
3b8c325d 1546 fprintf(pFlukaVmcInp,"*\n*Multiple scattering is ON by default for e+e- and for hadrons/muons\n");
1547 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1548 }
1df5fa54 1549 else if (proc->Flag() == 0) {
3b8c325d 1550 fprintf(pFlukaVmcInp,"*\n*Multiple scattering is set OFF\n");
1551 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('MULS',0);\n");
829fb838 1552 // zero = ignored
1553 // three = multiple scattering for hadrons and muons is completely suppressed
1554 // three = multiple scattering for e+ and e- is completely suppressed
1555 // matMin = lower bound of the material indices in which the respective thresholds apply
1556 // matMax = upper bound of the material indices in which the respective thresholds apply
3b8c325d 1557 fprintf(pFlukaVmcInp,"MULSOPT %10.1f%10.1f%10.1f%10.1f%10.1f\n",zero,three,three,matMin,matMax);
829fb838 1558 }
1559 else {
3b8c325d 1560 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('MULS',?) call.\n");
1561 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1562 }
1df5fa54 1563 } // end of else if (strncmp(proc->GetName(),"MULS",4) == 0)
829fb838 1564
1565
1566 // muon nuclear interaction
1567 // G3 default value: 0
1568 // G4 processes: G4MuNuclearInteraction,
1569 // G4MuonMinusCaptureAtRest
1570 //
1571 // Particles: mu
1572 // Physics: Not set
1573 // flag = 0 no muon-nuclear interaction
1574 // flag = 1 nuclear interaction, secondaries processed
1575 // flag = 2 nuclear interaction, secondaries not processed
1576 // gMC ->SetProcess("MUNU",1); // MUPHOTON 1. 0. 0. 3. lastmat
1df5fa54 1577 else if (strncmp(proc->GetName(),"MUNU",4) == 0) {
1578 if (proc->Flag() == 1) {
3b8c325d 1579 fprintf(pFlukaVmcInp,"*\n*Muon nuclear interactions with production of secondary hadrons\n");
1580 fprintf(pFlukaVmcInp,"*\n*Generated from call: SetProcess('MUNU',1);\n");
829fb838 1581 // one = full simulation of muon nuclear interactions and production of secondary hadrons
1582 // zero = ratio of longitudinal to transverse virtual photon cross-section - Default = 0.25.
1583 // zero = fraction of rho-like interactions ( must be < 1) - Default = 0.75.
1584 // matMin = lower bound of the material indices in which the respective thresholds apply
1585 // matMax = upper bound of the material indices in which the respective thresholds apply
3b8c325d 1586 fprintf(pFlukaVmcInp,"MUPHOTON %10.1f%10.1f%10.1f%10.1f%10.1f\n",one,zero,zero,matMin,matMax);
829fb838 1587 }
1df5fa54 1588 else if (proc->Flag() == 2) {
3b8c325d 1589 fprintf(pFlukaVmcInp,"*\n*Muon nuclear interactions without production of secondary hadrons\n");
1590 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('MUNU',2);\n");
829fb838 1591 // two = full simulation of muon nuclear interactions and production of secondary hadrons
1592 // zero = ratio of longitudinal to transverse virtual photon cross-section - Default = 0.25.
1593 // zero = fraction of rho-like interactions ( must be < 1) - Default = 0.75.
1594 // matMin = lower bound of the material indices in which the respective thresholds apply
1595 // matMax = upper bound of the material indices in which the respective thresholds apply
3b8c325d 1596 fprintf(pFlukaVmcInp,"MUPHOTON %10.1f%10.1f%10.1f%10.1f%10.1f\n",two,zero,zero,matMin,matMax);
829fb838 1597 }
1df5fa54 1598 else if (proc->Flag() == 0) {
3b8c325d 1599 fprintf(pFlukaVmcInp,"*\n*No muon nuclear interaction - no FLUKA card generated\n");
1600 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('MUNU',0)\n");
829fb838 1601 }
1602 else {
3b8c325d 1603 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('MUNU',?) call.\n");
1604 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1605 }
1df5fa54 1606 } // end of else if (strncmp(proc->GetName(),"MUNU",4) == 0)
829fb838 1607
1608
1609 // photofission
1610 // G3 default value: 0
1611 // G4 process: ??
1612 //
1613 // Particles: gamma
1614 // Physics: ??
1615 // gMC ->SetProcess("PFIS",0); // PHOTONUC -1. 0. 0. 3. lastmat 0.
1616 // flag = 0 no photon fission
1617 // flag = 1 photon fission, secondaries processed
1618 // flag = 2 photon fission, no secondaries stored
1df5fa54 1619 else if (strncmp(proc->GetName(),"PFIS",4) == 0) {
1620 if (proc->Flag() == 0) {
3b8c325d 1621 fprintf(pFlukaVmcInp,"*\n*No photonuclear interactions\n");
1622 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('PFIS',0);\n");
829fb838 1623 // - one = no photonuclear interactions
1624 // zero = not used
1625 // zero = not used
1626 // matMin = lower bound of the material indices in which the respective thresholds apply
1627 // matMax = upper bound of the material indices in which the respective thresholds apply
3b8c325d 1628 fprintf(pFlukaVmcInp,"PHOTONUC %10.1f%10.1f%10.1f%10.1f%10.1f\n",-one,zero,zero,matMin,matMax);
829fb838 1629 }
1df5fa54 1630 else if (proc->Flag() == 1) {
3b8c325d 1631 fprintf(pFlukaVmcInp,"*\n*Photon nuclear interactions are activated at all energies\n");
1632 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('PFIS',1);\n");
829fb838 1633 // one = photonuclear interactions are activated at all energies
1634 // zero = not used
1635 // zero = not used
1636 // matMin = lower bound of the material indices in which the respective thresholds apply
1637 // matMax = upper bound of the material indices in which the respective thresholds apply
3b8c325d 1638 fprintf(pFlukaVmcInp,"PHOTONUC %10.1f%10.1f%10.1f%10.1f%10.1f\n",one,zero,zero,matMin,matMax);
829fb838 1639 }
1df5fa54 1640 else if (proc->Flag() == 0) {
3b8c325d 1641 fprintf(pFlukaVmcInp,"*\n*No photofission - no FLUKA card generated\n");
1642 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('PFIS',0)\n");
829fb838 1643 }
1644 else {
3b8c325d 1645 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('PFIS',?) call.\n");
1646 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1647 }
1648 }
1649
1650
1651 // photo electric effect
1652 // G3 default value: 1
1653 // G4 processes: G4PhotoElectricEffect
1654 // G4LowEnergyPhotoElectric
1655 // Particles: gamma
1656 // Physics: EM
1657 // flag = 0 no photo electric effect
1658 // flag = 1 photo electric effect, electron processed
1659 // flag = 2 photo electric effect, no electron stored
1660 // gMC ->SetProcess("PHOT",1); // EMFCUT 0. -1. 0. 3. lastmat 0. PHOT-THR
1df5fa54 1661 else if (strncmp(proc->GetName(),"PHOT",4) == 0) {
1662 if (proc->Flag() == 1 || proc->Flag() == 2) {
3b8c325d 1663 fprintf(pFlukaVmcInp,"*\n*Photo electric effect is activated\n");
1664 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('PHOT',1);\n");
829fb838 1665 // zero = ignored
1666 // - one = resets to default=0.
1667 // zero = ignored
1668 // matMin = lower bound of the material indices in which the respective thresholds apply
1669 // matMax = upper bound of the material indices in which the respective thresholds apply
1670 // one = step length in assigning indices
1671 //"PHOT-THR";
3b8c325d 1672 fprintf(pFlukaVmcInp,"EMFCUT %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fPHOT-THR\n",zero,-one,zero,matMin,matMax,one);
829fb838 1673 }
1df5fa54 1674 else if (proc->Flag() == 0) {
3b8c325d 1675 fprintf(pFlukaVmcInp,"*\n*No photo electric effect - no FLUKA card generated\n");
1676 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('PHOT',0)\n");
829fb838 1677 }
1678 else {
3b8c325d 1679 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('PHOT',?) call.\n");
1680 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1681 }
1df5fa54 1682 } // else if (strncmp(proc->GetName(),"PHOT",4) == 0)
829fb838 1683
1684
1685 // Rayleigh scattering
1686 // G3 default value: 0
1687 // G4 process: G4OpRayleigh
1688 //
1689 // Particles: optical photon
1690 // Physics: Optical
1691 // flag = 0 Rayleigh scattering off
1692 // flag = 1 Rayleigh scattering on
1693 //xx gMC ->SetProcess("RAYL",1);
1df5fa54 1694 else if (strncmp(proc->GetName(),"RAYL",4) == 0) {
1695 if (proc->Flag() == 1) {
3b8c325d 1696 fprintf(pFlukaVmcInp,"*\n*Rayleigh scattering is ON by default in FLUKA\n");
1697 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1698 }
1df5fa54 1699 else if (proc->Flag() == 0) {
3b8c325d 1700 fprintf(pFlukaVmcInp,"*\n*Rayleigh scattering is set OFF\n");
1701 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('RAYL',0);\n");
829fb838 1702 // - one = no Rayleigh scattering and no binding corrections for Compton
1703 // matMin = lower bound of the material indices in which the respective thresholds apply
1704 // matMax = upper bound of the material indices in which the respective thresholds apply
3b8c325d 1705 fprintf(pFlukaVmcInp,"EMFRAY %10.1f%10.1f%10.1f%10.1f\n",-one,three,matMin,matMax);
829fb838 1706 }
1707 else {
3b8c325d 1708 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('RAYL',?) call.\n");
1709 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1710 }
1df5fa54 1711 } // end of else if (strncmp(proc->GetName(),"RAYL",4) == 0)
829fb838 1712
1713
1714 // synchrotron radiation in magnetic field
1715 // G3 default value: 0
1716 // G4 process: G4SynchrotronRadiation
1717 //
1718 // Particles: ??
1719 // Physics: Not set
1720 // flag = 0 no synchrotron radiation
1721 // flag = 1 synchrotron radiation
1722 //xx gMC ->SetProcess("SYNC",1); // synchrotron radiation generation
1df5fa54 1723 else if (strncmp(proc->GetName(),"SYNC",4) == 0) {
3b8c325d 1724 fprintf(pFlukaVmcInp,"*\n*Synchrotron radiation generation is NOT implemented in FLUKA\n");
1725 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1726 }
1727
1728
1729 // Automatic calculation of tracking medium parameters
1730 // flag = 0 no automatic calculation
1731 // flag = 1 automatic calculation
1732 //xx gMC ->SetProcess("AUTO",1); // ??? automatic computation of the tracking medium parameters
1df5fa54 1733 else if (strncmp(proc->GetName(),"AUTO",4) == 0) {
3b8c325d 1734 fprintf(pFlukaVmcInp,"*\n*Automatic calculation of tracking medium parameters is always ON in FLUKA\n");
1735 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1736 }
1737
1738
1739 // To control energy loss fluctuation model
1740 // flag = 0 Urban model
1741 // flag = 1 PAI model
1742 // flag = 2 PAI+ASHO model (not active at the moment)
1743 //xx gMC ->SetProcess("STRA",1); // ??? energy fluctuation model
1df5fa54 1744 else if (strncmp(proc->GetName(),"STRA",4) == 0) {
1745 if (proc->Flag() == 0 || proc->Flag() == 2 || proc->Flag() == 3) {
3b8c325d 1746 fprintf(pFlukaVmcInp,"*\n*Ionization energy losses calculation is activated\n");
1747 fprintf(pFlukaVmcInp,"*Generated from call: SetProcess('STRA',n);, n=0,1,2\n");
829fb838 1748 // one = restricted energy loss fluctuations (for hadrons and muons) switched on
1749 // one = restricted energy loss fluctuations (for e+ and e-) switched on
1750 // one = minimal accuracy
1751 // matMin = lower bound of the material indices in which the respective thresholds apply
1752 // matMax = upper bound of the material indices in which the respective thresholds apply
3b8c325d 1753 fprintf(pFlukaVmcInp,"IONFLUCT %10.1f%10.1f%10.1f%10.1f%10.1f\n",one,one,one,matMin,matMax);
829fb838 1754 }
1755 else {
3b8c325d 1756 fprintf(pFlukaVmcInp,"*\n*Illegal flag value in SetProcess('STRA',?) call.\n");
1757 fprintf(pFlukaVmcInp,"*No FLUKA card generated\n");
829fb838 1758 }
1df5fa54 1759 } // else if (strncmp(proc->GetName(),"STRA",4) == 0)
829fb838 1760
1761
1762
1763
1764 else { // processes not yet treated
1765
1766 // light photon absorption (Cerenkov photons)
1767 // it is turned on when Cerenkov process is turned on
1768 // G3 default value: 0
1769 // G4 process: G4OpAbsorption, G4OpBoundaryProcess
1770 //
1771 // Particles: optical photon
1772 // Physics: Optical
1773 // flag = 0 no absorption of Cerenkov photons
1774 // flag = 1 absorption of Cerenkov photons
1775 // gMC ->SetProcess("LABS",2); // ??? Cerenkov light absorption
1776
1777
1778
1df5fa54 1779 cout << "SetProcess for flag=" << proc->GetName() << " value=" << proc->Flag() << " not yet implemented!" << endl;
829fb838 1780 }
1781 } //end of loop number of SetProcess calls
1782
1783
1784// Loop over number of SetCut calls
1df5fa54 1785
1786 nextc.Reset();
1787 while ((cut = (TFlukaConfigOption*)nextc())) {
829fb838 1788 Float_t matMin = three;
1789 Float_t matMax = fLastMaterial;
1790 Bool_t global = kTRUE;
1df5fa54 1791 if (cut->Medium() != -1) {
7b203b6e 1792 Int_t mat;
1793 if ((mat = cut->Medium()) >= GetFlukaMaterials()->GetEntries()) continue;
1794 matMin = Float_t(mat);
1795 matMax = matMin;
1796 global = kFALSE;
1797 TGeoMaterial* material = (TGeoMaterial*) (GetFlukaMaterials())->At(GetMaterialIndex(mat));
c1c801f9 1798 fprintf(pFlukaVmcInp,"*\n*Material specific cut setting for #%8d %s %s %13.3e\n",
1799 mat, material->GetName(), cut->GetName(), cut->Cut());
b2129742 1800
7b203b6e 1801 }
b2129742 1802
829fb838 1803 // cuts handled in SetProcess calls
b2129742 1804 if (strncmp(cut->GetName(),"BCUTM",5) == 0) continue;
1805 else if (strncmp(cut->GetName(),"BCUTE",5) == 0) continue;
1806 else if (strncmp(cut->GetName(),"DCUTM",5) == 0) continue;
1df5fa54 1807 else if (strncmp(cut->GetName(),"PPCUTM",6) == 0) continue;
829fb838 1808
829fb838 1809 // gammas
1810 // G4 particles: "gamma"
1811 // G3 default value: 0.001 GeV
1812 // gMC ->SetCut("CUTGAM",cut); // cut for gammas
1813
1df5fa54 1814 else if (strncmp(cut->GetName(),"CUTGAM",6) == 0 && global) {
b2129742 1815 fprintf(pFlukaVmcInp,"*\n*Cut for gamma\n");
1816 fprintf(pFlukaVmcInp,"*Generated from call: SetCut('CUTGAM',cut);\n");
1817 fprintf(pFlukaVmcInp,"EMFCUT %10.4g%10.4g%10.1f%10.1f%10.1f%10.1f\n",
1818 zero, cut->Cut(), zero, zero, Float_t(fGeom->NofVolumes()), one);
829fb838 1819 }
1df5fa54 1820 else if (strncmp(cut->GetName(),"CUTGAM",6) == 0 && !global) {
b2129742 1821 // loop over materials for EMFCUT FLUKA cards
1822 for (j=0; j < matMax-matMin+1; j++) {
1823 Int_t nreg, imat, *reglist;
1824 Float_t ireg;
1825 imat = (Int_t) matMin + j;
1826 reglist = fGeom->GetMaterialList(imat, nreg);
1827 // loop over regions of a given material
1828 for (Int_t k = 0; k < nreg; k++) {
1829 ireg = reglist[k];
1830 fprintf(pFlukaVmcInp,"EMFCUT %10.4g%10.4g%10.1f%10.1f%10.1f%10.1f\n", zero, cut->Cut(), zero, ireg, ireg, one);
1831 }
1832 }
829fb838 1833 } // end of else if for gamma
b2129742 1834
829fb838 1835
1836 // electrons
1837 // G4 particles: "e-"
1838 // ?? positrons
1839 // G3 default value: 0.001 GeV
1840 //gMC ->SetCut("CUTELE",cut); // cut for e+,e-
1df5fa54 1841 else if (strncmp(cut->GetName(),"CUTELE",6) == 0 && global) {
b2129742 1842 fprintf(pFlukaVmcInp,"*\n*Cut for electrons\n");
1843 fprintf(pFlukaVmcInp,"*Generated from call: SetCut('CUTELE',cut);\n");
1844 fprintf(pFlukaVmcInp,"EMFCUT %10.4g%10.4g%10.1f%10.1f%10.1f%10.1f\n",
1845 -cut->Cut(), zero, zero, zero, Float_t(fGeom->NofVolumes()), one);
829fb838 1846 }
1df5fa54 1847 else if (strncmp(cut->GetName(),"CUTELE",6) == 0 && !global) {
b2129742 1848 // loop over materials for EMFCUT FLUKA cards
1849 for (j=0; j < matMax-matMin+1; j++) {
1850 Int_t nreg, imat, *reglist;
1851 Float_t ireg;
1852 imat = (Int_t) matMin + j;
1853 reglist = fGeom->GetMaterialList(imat, nreg);
1854 // loop over regions of a given material
1855 for (k=0; k<nreg; k++) {
1856 ireg = reglist[k];
1857 fprintf(pFlukaVmcInp,"EMFCUT %10.4g%10.4g%10.1f%10.1f%10.1f%10.1f\n", -cut->Cut(), zero, zero, ireg, ireg, one);
1858 }
1859 }
829fb838 1860 } // end of else if for electrons
1861
1862
1863 // neutral hadrons
1864 // G4 particles: of type "baryon", "meson", "nucleus" with zero charge
1865 // G3 default value: 0.01 GeV
1866 //gMC ->SetCut("CUTNEU",cut); // cut for neutral hadrons
1df5fa54 1867 else if (strncmp(cut->GetName(),"CUTNEU",6) == 0 && global) {
3b8c325d 1868 fprintf(pFlukaVmcInp,"*\n*Cut for neutral hadrons\n");
1869 fprintf(pFlukaVmcInp,"*Generated from call: SetCut('CUTNEU',cut);\n");
829fb838 1870
1871 // 8.0 = Neutron
1872 // 9.0 = Antineutron
3b8c325d 1873 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),8.0,9.0);
829fb838 1874
1875 // 12.0 = Kaon zero long
1876 // 12.0 = Kaon zero long
3b8c325d 1877 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),12.0,12.0);
829fb838 1878
1879 // 17.0 = Lambda, 18.0 = Antilambda
1880 // 19.0 = Kaon zero short
3b8c325d 1881 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),17.0,19.0);
829fb838 1882
1883 // 22.0 = Sigma zero, Pion zero, Kaon zero
1884 // 25.0 = Antikaon zero
3b8c325d 1885 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),22.0,25.0);
829fb838 1886
1887 // 32.0 = Antisigma zero
1888 // 32.0 = Antisigma zero
3b8c325d 1889 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),32.0,32.0);
829fb838 1890
1891 // 34.0 = Xi zero
1892 // 35.0 = AntiXi zero
3b8c325d 1893 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),34.0,35.0);
829fb838 1894
1895 // 47.0 = D zero
1896 // 48.0 = AntiD zero
3b8c325d 1897 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),47.0,48.0);
829fb838 1898
1899 // 53.0 = Xi_c zero
1900 // 53.0 = Xi_c zero
3b8c325d 1901 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),53.0,53.0);
829fb838 1902
1903 // 55.0 = Xi'_c zero
1904 // 56.0 = Omega_c zero
3b8c325d 1905 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),55.0,56.0);
829fb838 1906
1907 // 59.0 = AntiXi_c zero
1908 // 59.0 = AntiXi_c zero
3b8c325d 1909 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),59.0,59.0);
829fb838 1910
1911 // 61.0 = AntiXi'_c zero
1912 // 62.0 = AntiOmega_c zero
3b8c325d 1913 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),61.0,62.0);
829fb838 1914 }
1915
1916 // charged hadrons
1917 // G4 particles: of type "baryon", "meson", "nucleus" with non-zero charge
1918 // G3 default value: 0.01 GeV
1919 //gMC ->SetCut("CUTHAD",cut); // cut for charged hadrons
1df5fa54 1920 else if (strncmp(cut->GetName(),"CUTHAD",6) == 0 && global) {
3b8c325d 1921 fprintf(pFlukaVmcInp,"*\n*Cut for charged hadrons\n");
1922 fprintf(pFlukaVmcInp,"*Generated from call: SetCut('CUTHAD',cut);\n");
829fb838 1923
1924 // 1.0 = Proton
1925 // 2.0 = Antiproton
3b8c325d 1926 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),1.0,2.0);
829fb838 1927
1928 // 13.0 = Positive Pion, Negative Pion, Positive Kaon
1929 // 16.0 = Negative Kaon
3b8c325d 1930 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),13.0,16.0);
829fb838 1931
1932 // 20.0 = Negative Sigma
1933 // 21.0 = Positive Sigma
3b8c325d 1934 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),20.0,21.0);
829fb838 1935
1936 // 31.0 = Antisigma minus
1937 // 33.0 = Antisigma plus
1938 // 2.0 = step length
3b8c325d 1939 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f%10.1f\n",-cut->Cut(),31.0,33.0,2.0);
829fb838 1940
1941 // 36.0 = Negative Xi, Positive Xi, Omega minus
1942 // 39.0 = Antiomega
3b8c325d 1943 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),36.0,39.0);
829fb838 1944
1945 // 45.0 = D plus
1946 // 46.0 = D minus
3b8c325d 1947 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),45.0,46.0);
829fb838 1948
1949 // 49.0 = D_s plus, D_s minus, Lambda_c plus
1950 // 52.0 = Xi_c plus
3b8c325d 1951 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),49.0,52.0);
829fb838 1952
1953 // 54.0 = Xi'_c plus
1954 // 60.0 = AntiXi'_c minus
1955 // 6.0 = step length
3b8c325d 1956 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f%10.1f\n",-cut->Cut(),54.0,60.0,6.0);
829fb838 1957
1958 // 57.0 = Antilambda_c minus
1959 // 58.0 = AntiXi_c minus
3b8c325d 1960 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),57.0,58.0);
829fb838 1961 }
1962
1963 // muons
1964 // G4 particles: "mu+", "mu-"
1965 // G3 default value: 0.01 GeV
1966 //gMC ->SetCut("CUTMUO",cut); // cut for mu+, mu-
1df5fa54 1967 else if (strncmp(cut->GetName(),"CUTMUO",6)== 0 && global) {
3b8c325d 1968 fprintf(pFlukaVmcInp,"*\n*Cut for muons\n");
1969 fprintf(pFlukaVmcInp,"*Generated from call: SetCut('CUTMUO',cut);\n");
829fb838 1970 // 10.0 = Muon+
1971 // 11.0 = Muon-
3b8c325d 1972 fprintf(pFlukaVmcInp,"PART-THR %10.4g%10.1f%10.1f\n",-cut->Cut(),10.0,11.0);
829fb838 1973 }
1974
1975 //
1976 // time of flight cut in seconds
1977 // G4 particles: all
1978 // G3 default value: 0.01 GeV
1979 //gMC ->SetCut("TOFMAX",tofmax); // time of flight cuts in seconds
1df5fa54 1980 else if (strncmp(cut->GetName(),"TOFMAX",6) == 0) {
3b8c325d 1981 fprintf(pFlukaVmcInp,"*\n*Time of flight cuts in seconds\n");
1982 fprintf(pFlukaVmcInp,"*Generated from call: SetCut('TOFMAX',tofmax);\n");
829fb838 1983 // zero = ignored
1984 // zero = ignored
1985 // -6.0 = lower bound of the particle numbers for which the transport time cut-off and/or the start signal is to be applied
1986 // 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 1987 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 1988 }
1989
1990 else if (global){
1df5fa54 1991 cout << "SetCut for flag=" << cut->GetName() << " value=" << cut->Cut() << " not yet implemented!" << endl;
829fb838 1992 }
1993 else {
1df5fa54 1994 cout << "SetCut for flag=" << cut->GetName() << " value=" << cut->Cut() << " (material specific) not yet implemented!" << endl;
829fb838 1995 }
1996
1997 } //end of loop over SetCut calls
1998
1999// Add START and STOP card
3b8c325d 2000 fprintf(pFlukaVmcInp,"START %10.1f\n",fEventsPerRun);
2001 fprintf(pFlukaVmcInp,"STOP \n");
829fb838 2002
2003
2004// Close files
2005
3b8c325d 2006 fclose(pFlukaVmcCoreInp);
2007 fclose(pFlukaVmcFlukaMat);
2008 fclose(pFlukaVmcInp);
829fb838 2009
2010} // end of InitPhysics
2011
2012
2013//______________________________________________________________________________
07f5b33e 2014void TFluka::SetMaxStep(Double_t step)
829fb838 2015{
07f5b33e 2016// Set the maximum step size
2017 if (step > 1.e4) return;
2018
2019 Int_t mreg, latt;
2020 fGeom->GetCurrentRegion(mreg, latt);
2021 STEPSZ.stepmx[mreg - 1] = step;
829fb838 2022}
2023
2f09b80e 2024
2025Double_t TFluka::MaxStep() const
2026{
2027// Return the maximum for current medium
2028 Int_t mreg, latt;
2029 fGeom->GetCurrentRegion(mreg, latt);
2030 return (STEPSZ.stepmx[mreg - 1]);
2031}
2032
829fb838 2033//______________________________________________________________________________
2034void TFluka::SetMaxNStep(Int_t)
2035{
2036// SetMaxNStep is dummy procedure in TFluka !
2037 if (fVerbosityLevel >=3)
2038 cout << "SetMaxNStep is dummy procedure in TFluka !" << endl;
2039}
2040
2041//______________________________________________________________________________
2042void TFluka::SetUserDecay(Int_t)
2043{
2044// SetUserDecay is dummy procedure in TFluka !
2045 if (fVerbosityLevel >=3)
2046 cout << "SetUserDecay is dummy procedure in TFluka !" << endl;
2047}
2048
2049//
2050// dynamic properties
2051//
2052//______________________________________________________________________________
2053void TFluka::TrackPosition(TLorentzVector& position) const
2054{
2055// Return the current position in the master reference frame of the
2056// track being transported
2057// TRACKR.atrack = age of the particle
2058// TRACKR.xtrack = x-position of the last point
2059// TRACKR.ytrack = y-position of the last point
2060// TRACKR.ztrack = z-position of the last point
2061 Int_t caller = GetCaller();
2062 if (caller == 3 || caller == 6 || caller == 11 || caller == 12) { //bxdraw,endraw,usdraw
2063 position.SetX(GetXsco());
2064 position.SetY(GetYsco());
2065 position.SetZ(GetZsco());
2066 position.SetT(TRACKR.atrack);
2067 }
2068 else if (caller == 4) { // mgdraw
2069 position.SetX(TRACKR.xtrack[TRACKR.ntrack]);
2070 position.SetY(TRACKR.ytrack[TRACKR.ntrack]);
2071 position.SetZ(TRACKR.ztrack[TRACKR.ntrack]);
2072 position.SetT(TRACKR.atrack);
2073 }
2074 else if (caller == 5) { // sodraw
2075 position.SetX(TRACKR.xtrack[TRACKR.ntrack]);
2076 position.SetY(TRACKR.ytrack[TRACKR.ntrack]);
2077 position.SetZ(TRACKR.ztrack[TRACKR.ntrack]);
2078 position.SetT(0);
2079 }
2080 else
2081 Warning("TrackPosition","position not available");
2082}
2083
2084//______________________________________________________________________________
2085void TFluka::TrackPosition(Double_t& x, Double_t& y, Double_t& z) const
2086{
2087// Return the current position in the master reference frame of the
2088// track being transported
2089// TRACKR.atrack = age of the particle
2090// TRACKR.xtrack = x-position of the last point
2091// TRACKR.ytrack = y-position of the last point
2092// TRACKR.ztrack = z-position of the last point
2093 Int_t caller = GetCaller();
2094 if (caller == 3 || caller == 6 || caller == 11 || caller == 12) { //bxdraw,endraw,usdraw
2095 x = GetXsco();
2096 y = GetYsco();
2097 z = GetZsco();
2098 }
2099 else if (caller == 4 || caller == 5) { // mgdraw, sodraw
2100 x = TRACKR.xtrack[TRACKR.ntrack];
2101 y = TRACKR.ytrack[TRACKR.ntrack];
2102 z = TRACKR.ztrack[TRACKR.ntrack];
2103 }
2104 else
2105 Warning("TrackPosition","position not available");
2106}
2107
2108//______________________________________________________________________________
2109void TFluka::TrackMomentum(TLorentzVector& momentum) const
2110{
2111// Return the direction and the momentum (GeV/c) of the track
2112// currently being transported
2113// TRACKR.ptrack = momentum of the particle (not always defined, if
2114// < 0 must be obtained from etrack)
2115// TRACKR.cx,y,ztrck = direction cosines of the current particle
2116// TRACKR.etrack = total energy of the particle
2117// TRACKR.jtrack = identity number of the particle
2118// PAPROP.am[TRACKR.jtrack] = particle mass in gev
2119 Int_t caller = GetCaller();
2120 if (caller != 2) { // not eedraw
2121 if (TRACKR.ptrack >= 0) {
2122 momentum.SetPx(TRACKR.ptrack*TRACKR.cxtrck);
2123 momentum.SetPy(TRACKR.ptrack*TRACKR.cytrck);
2124 momentum.SetPz(TRACKR.ptrack*TRACKR.cztrck);
2125 momentum.SetE(TRACKR.etrack);
2126 return;
2127 }
2128 else {
2129 Double_t p = sqrt(TRACKR.etrack*TRACKR.etrack - PAPROP.am[TRACKR.jtrack+6]*PAPROP.am[TRACKR.jtrack+6]);
2130 momentum.SetPx(p*TRACKR.cxtrck);
2131 momentum.SetPy(p*TRACKR.cytrck);
2132 momentum.SetPz(p*TRACKR.cztrck);
2133 momentum.SetE(TRACKR.etrack);
2134 return;
2135 }
2136 }
2137 else
2138 Warning("TrackMomentum","momentum not available");
2139}
2140
2141//______________________________________________________________________________
2142void TFluka::TrackMomentum(Double_t& px, Double_t& py, Double_t& pz, Double_t& e) const
2143{
2144// Return the direction and the momentum (GeV/c) of the track
2145// currently being transported
2146// TRACKR.ptrack = momentum of the particle (not always defined, if
2147// < 0 must be obtained from etrack)
2148// TRACKR.cx,y,ztrck = direction cosines of the current particle
2149// TRACKR.etrack = total energy of the particle
2150// TRACKR.jtrack = identity number of the particle
2151// PAPROP.am[TRACKR.jtrack] = particle mass in gev
2152 Int_t caller = GetCaller();
2153 if (caller != 2) { // not eedraw
2154 if (TRACKR.ptrack >= 0) {
2155 px = TRACKR.ptrack*TRACKR.cxtrck;
2156 py = TRACKR.ptrack*TRACKR.cytrck;
2157 pz = TRACKR.ptrack*TRACKR.cztrck;
2158 e = TRACKR.etrack;
2159 return;
2160 }
2161 else {
2162 Double_t p = sqrt(TRACKR.etrack*TRACKR.etrack - PAPROP.am[TRACKR.jtrack+6]*PAPROP.am[TRACKR.jtrack+6]);
2163 px = p*TRACKR.cxtrck;
2164 py = p*TRACKR.cytrck;
2165 pz = p*TRACKR.cztrck;
2166 e = TRACKR.etrack;
2167 return;
2168 }
2169 }
2170 else
2171 Warning("TrackMomentum","momentum not available");
2172}
2173
2174//______________________________________________________________________________
2175Double_t TFluka::TrackStep() const
2176{
2177// Return the length in centimeters of the current step
2178// TRACKR.ctrack = total curved path
2179 Int_t caller = GetCaller();
2180 if (caller == 11 || caller==12 || caller == 3 || caller == 6) //bxdraw,endraw,usdraw
2181 return 0.0;
2182 else if (caller == 4) //mgdraw
2183 return TRACKR.ctrack;
2184 else
2185 return -1.0;
2186}
2187
2188//______________________________________________________________________________
2189Double_t TFluka::TrackLength() const
2190{
2191// TRACKR.cmtrck = cumulative curved path since particle birth
2192 Int_t caller = GetCaller();
2193 if (caller == 11 || caller==12 || caller == 3 || caller == 4 || caller == 6) //bxdraw,endraw,mgdraw,usdraw
2194 return TRACKR.cmtrck;
2195 else
2196 return -1.0;
2197}
2198
2199//______________________________________________________________________________
2200Double_t TFluka::TrackTime() const
2201{
2202// Return the current time of flight of the track being transported
2203// TRACKR.atrack = age of the particle
2204 Int_t caller = GetCaller();
2205 if (caller == 11 || caller==12 || caller == 3 || caller == 4 || caller == 6) //bxdraw,endraw,mgdraw,usdraw
2206 return TRACKR.atrack;
2207 else
2208 return -1;
2209}
2210
2211//______________________________________________________________________________
2212Double_t TFluka::Edep() const
2213{
2214// Energy deposition
2215// if TRACKR.ntrack = 0, TRACKR.mtrack = 0:
2216// -->local energy deposition (the value and the point are not recorded in TRACKR)
2217// but in the variable "rull" of the procedure "endraw.cxx"
2218// if TRACKR.ntrack > 0, TRACKR.mtrack = 0:
2219// -->no energy loss along the track
2220// if TRACKR.ntrack > 0, TRACKR.mtrack > 0:
2221// -->energy loss distributed along the track
07f5b33e 2222// TRACKR.dtrack = energy deposition of the jth deposition event
829fb838 2223
2224 // If coming from bxdraw we have 2 steps of 0 length and 0 edep
2225 Int_t caller = GetCaller();
2226 if (caller == 11 || caller==12) return 0.0;
2227 Double_t sum = 0;
2228 for ( Int_t j=0;j<TRACKR.mtrack;j++) {
2229 sum +=TRACKR.dtrack[j];
2230 }
2231 if (TRACKR.ntrack == 0 && TRACKR.mtrack == 0)
2232 return fRull + sum;
2233 else {
2234 return sum;
2235 }
2236}
2237
2238//______________________________________________________________________________
2239Int_t TFluka::TrackPid() const
2240{
2241// Return the id of the particle transported
2242// TRACKR.jtrack = identity number of the particle
2243 Int_t caller = GetCaller();
f926898e 2244 if (caller != 2) { // not eedraw
2245 return PDGFromId(TRACKR.jtrack);
2246 }
829fb838 2247 else
2248 return -1000;
2249}
2250
2251//______________________________________________________________________________
2252Double_t TFluka::TrackCharge() const
2253{
2254// Return charge of the track currently transported
2255// PAPROP.ichrge = electric charge of the particle
2256// TRACKR.jtrack = identity number of the particle
2257 Int_t caller = GetCaller();
2258 if (caller != 2) // not eedraw
2259 return PAPROP.ichrge[TRACKR.jtrack+6];
2260 else
2261 return -1000.0;
2262}
2263
2264//______________________________________________________________________________
2265Double_t TFluka::TrackMass() const
2266{
2267// PAPROP.am = particle mass in GeV
2268// TRACKR.jtrack = identity number of the particle
2269 Int_t caller = GetCaller();
2270 if (caller != 2) // not eedraw
2271 return PAPROP.am[TRACKR.jtrack+6];
2272 else
2273 return -1000.0;
2274}
2275
2276//______________________________________________________________________________
2277Double_t TFluka::Etot() const
2278{
2279// TRACKR.etrack = total energy of the particle
2280 Int_t caller = GetCaller();
2281 if (caller != 2) // not eedraw
2282 return TRACKR.etrack;
2283 else
2284 return -1000.0;
2285}
2286
2287//
2288// track status
2289//
2290//______________________________________________________________________________
2291Bool_t TFluka::IsNewTrack() const
2292{
2293// Return true for the first call of Stepping()
2294 return fTrackIsNew;
2295}
2296
0dabe425 2297void TFluka::SetTrackIsNew(Bool_t flag)
2298{
2299// Return true for the first call of Stepping()
2300 fTrackIsNew = flag;
2301
2302}
2303
2304
829fb838 2305//______________________________________________________________________________
2306Bool_t TFluka::IsTrackInside() const
2307{
2308// True if the track is not at the boundary of the current volume
2309// In Fluka a step is always inside one kind of material
2310// If the step would go behind the region of one material,
2311// it will be shortened to reach only the boundary.
2312// Therefore IsTrackInside() is always true.
2313 Int_t caller = GetCaller();
2314 if (caller == 11 || caller==12) // bxdraw
2315 return 0;
2316 else
2317 return 1;
2318}
2319
2320//______________________________________________________________________________
2321Bool_t TFluka::IsTrackEntering() const
2322{
2323// True if this is the first step of the track in the current volume
2324
2325 Int_t caller = GetCaller();
2326 if (caller == 11) // bxdraw entering
2327 return 1;
2328 else return 0;
2329}
2330
2331//______________________________________________________________________________
2332Bool_t TFluka::IsTrackExiting() const
2333{
2334// True if track is exiting volume
2335//
2336 Int_t caller = GetCaller();
2337 if (caller == 12) // bxdraw exiting
2338 return 1;
2339 else return 0;
2340}
2341
2342//______________________________________________________________________________
2343Bool_t TFluka::IsTrackOut() const
2344{
2345// True if the track is out of the setup
2346// means escape
2347// Icode = 14: escape - call from Kaskad
2348// Icode = 23: escape - call from Emfsco
2349// Icode = 32: escape - call from Kasneu
2350// Icode = 40: escape - call from Kashea
2351// Icode = 51: escape - call from Kasoph
2352 if (fIcode == 14 ||
2353 fIcode == 23 ||
2354 fIcode == 32 ||
2355 fIcode == 40 ||
2356 fIcode == 51) return 1;
2357 else return 0;
2358}
2359
2360//______________________________________________________________________________
2361Bool_t TFluka::IsTrackDisappeared() const
2362{
2363// means all inelastic interactions and decays
2364// fIcode from usdraw
2365 if (fIcode == 101 || // inelastic interaction
2366 fIcode == 102 || // particle decay
0dabe425 2367 fIcode == 103 || // delta ray generation by hadron
2368 fIcode == 104 || // direct pair production
2369 fIcode == 105 || // bremsstrahlung (muon)
2370 fIcode == 208 || // bremsstrahlung (electron)
829fb838 2371 fIcode == 214 || // in-flight annihilation
2372 fIcode == 215 || // annihilation at rest
2373 fIcode == 217 || // pair production
0dabe425 2374 fIcode == 219 || // Compton scattering
2375 fIcode == 221 || // Photoelectric effect
2376 fIcode == 300 || // hadronic interaction
2377 fIcode == 400 // delta-ray
2378 ) return 1;
829fb838 2379 else return 0;
2380}
2381
2382//______________________________________________________________________________
2383Bool_t TFluka::IsTrackStop() const
2384{
2385// True if the track energy has fallen below the threshold
2386// means stopped by signal or below energy threshold
2387// Icode = 12: stopping particle - call from Kaskad
2388// Icode = 15: time kill - call from Kaskad
2389// Icode = 21: below threshold, iarg=1 - call from Emfsco
2390// Icode = 22: below threshold, iarg=2 - call from Emfsco
2391// Icode = 24: time kill - call from Emfsco
2392// Icode = 31: below threshold - call from Kasneu
2393// Icode = 33: time kill - call from Kasneu
2394// Icode = 41: time kill - call from Kashea
2395// Icode = 52: time kill - call from Kasoph
2396 if (fIcode == 12 ||
2397 fIcode == 15 ||
2398 fIcode == 21 ||
2399 fIcode == 22 ||
2400 fIcode == 24 ||
2401 fIcode == 31 ||
2402 fIcode == 33 ||
2403 fIcode == 41 ||
2404 fIcode == 52) return 1;
2405 else return 0;
2406}
2407
2408//______________________________________________________________________________
2409Bool_t TFluka::IsTrackAlive() const
2410{
2411// means not disappeared or not out
2412 if (IsTrackDisappeared() || IsTrackOut() ) return 0;
2413 else return 1;
2414}
2415
2416//
2417// secondaries
2418//
2419
2420//______________________________________________________________________________
2421Int_t TFluka::NSecondaries() const
2422
2423{
2424// Number of secondary particles generated in the current step
2425// FINUC.np = number of secondaries except light and heavy ions
2426// FHEAVY.npheav = number of secondaries for light and heavy secondary ions
7b203b6e 2427 Int_t caller = GetCaller();
2428 if (caller == 6) // valid only after usdraw
2429 return FINUC.np + FHEAVY.npheav;
2430 else if (caller == 50) {
2431 // Cerenkov Photon production
2432 return fNCerenkov;
2433 }
829fb838 2434 return 0;
2435} // end of NSecondaries
2436
2437//______________________________________________________________________________
2438void TFluka::GetSecondary(Int_t isec, Int_t& particleId,
2439 TLorentzVector& position, TLorentzVector& momentum)
2440{
2441// Copy particles from secondary stack to vmc stack
2442//
2443
7b203b6e 2444 Int_t caller = GetCaller();
2445 if (caller == 6) { // valid only after usdraw
2446 if (FINUC.np > 0) {
2447 // Hadronic interaction
2448 if (isec >= 0 && isec < FINUC.np) {
2449 particleId = PDGFromId(FINUC.kpart[isec]);
2450 position.SetX(fXsco);
2451 position.SetY(fYsco);
2452 position.SetZ(fZsco);
2453 position.SetT(TRACKR.atrack);
2454 momentum.SetPx(FINUC.plr[isec]*FINUC.cxr[isec]);
2455 momentum.SetPy(FINUC.plr[isec]*FINUC.cyr[isec]);
2456 momentum.SetPz(FINUC.plr[isec]*FINUC.czr[isec]);
2457 momentum.SetE(FINUC.tki[isec] + PAPROP.am[FINUC.kpart[isec]+6]);
2458 }
2459 else if (isec >= FINUC.np && isec < FINUC.np + FHEAVY.npheav) {
2460 Int_t jsec = isec - FINUC.np;
2461 particleId = FHEAVY.kheavy[jsec]; // this is Fluka id !!!
2462 position.SetX(fXsco);
2463 position.SetY(fYsco);
2464 position.SetZ(fZsco);
2465 position.SetT(TRACKR.atrack);
2466 momentum.SetPx(FHEAVY.pheavy[jsec]*FHEAVY.cxheav[jsec]);
2467 momentum.SetPy(FHEAVY.pheavy[jsec]*FHEAVY.cyheav[jsec]);
2468 momentum.SetPz(FHEAVY.pheavy[jsec]*FHEAVY.czheav[jsec]);
2469 if (FHEAVY.tkheav[jsec] >= 3 && FHEAVY.tkheav[jsec] <= 6)
2470 momentum.SetE(FHEAVY.tkheav[jsec] + PAPROP.am[jsec+6]);
2471 else if (FHEAVY.tkheav[jsec] > 6)
2472 momentum.SetE(FHEAVY.tkheav[jsec] + FHEAVY.amnhea[jsec]); // to be checked !!!
2473 }
2474 else
2475 Warning("GetSecondary","isec out of range");
2476 }
2477 } else if (caller == 50) {
2478 Int_t index = OPPHST.lstopp - isec;
2479 position.SetX(OPPHST.xoptph[index]);
2480 position.SetY(OPPHST.yoptph[index]);
2481 position.SetZ(OPPHST.zoptph[index]);
2482 position.SetT(OPPHST.agopph[index]);
2483 Double_t p = OPPHST.poptph[index];
2484
2485 momentum.SetPx(p * OPPHST.txopph[index]);
2486 momentum.SetPy(p * OPPHST.tyopph[index]);
2487 momentum.SetPz(p * OPPHST.tzopph[index]);
2488 momentum.SetE(p);
829fb838 2489 }
2490 else
7b203b6e 2491 Warning("GetSecondary","no secondaries available");
2492
829fb838 2493} // end of GetSecondary
2494
7b203b6e 2495
829fb838 2496//______________________________________________________________________________
2497TMCProcess TFluka::ProdProcess(Int_t) const
2498
2499{
2500// Name of the process that has produced the secondary particles
2501// in the current step
0dabe425 2502
2503 Int_t mugamma = (TRACKR.jtrack == 7 || TRACKR.jtrack == 10 || TRACKR.jtrack == 11);
2504
b496f27c 2505 if (fIcode == 102) return kPDecay;
0dabe425 2506 else if (fIcode == 104 || fIcode == 217) return kPPair;
b496f27c 2507 else if (fIcode == 219) return kPCompton;
2508 else if (fIcode == 221) return kPPhotoelectric;
0dabe425 2509 else if (fIcode == 105 || fIcode == 208) return kPBrem;
2510 else if (fIcode == 103 || fIcode == 400) return kPDeltaRay;
2511 else if (fIcode == 210 || fIcode == 212) return kPDeltaRay;
2512 else if (fIcode == 214 || fIcode == 215) return kPAnnihilation;
b496f27c 2513 else if (fIcode == 101) return kPHadronic;
829fb838 2514 else if (fIcode == 101) {
b496f27c 2515 if (!mugamma) return kPHadronic;
2516 else if (TRACKR.jtrack == 7) return kPPhotoFission;
2517 else return kPMuonNuclear;
829fb838 2518 }
b496f27c 2519 else if (fIcode == 225) return kPRayleigh;
829fb838 2520// Fluka codes 100, 300 and 400 still to be investigasted
b496f27c 2521 else return kPNoProcess;
829fb838 2522}
2523
829fb838 2524
b496f27c 2525Int_t TFluka::StepProcesses(TArrayI &proc) const
2526{
2527 //
2528 // Return processes active in the current step
2529 //
2530 proc.Set(1);
2531 TMCProcess iproc;
2532 switch (fIcode) {
2533 case 15:
2534 case 24:
2535 case 33:
2536 case 41:
2537 case 52:
2538 iproc = kPTOFlimit;
2539 break;
2540 case 12:
2541 case 14:
2542 case 21:
2543 case 22:
2544 case 23:
2545 case 31:
2546 case 32:
2547 case 40:
2548 case 51:
2549 iproc = kPStop;
2550 break;
2551 case 50:
2552 iproc = kPLightAbsorption;
2553 break;
2554 case 20:
2555 iproc = kPPhotoelectric;
2556 break;
2557 default:
2558 iproc = ProdProcess(0);
2559 }
07f5b33e 2560 proc[0] = iproc;
b496f27c 2561 return 1;
2562}
829fb838 2563//______________________________________________________________________________
2564Int_t TFluka::VolId2Mate(Int_t id) const
2565{
2566//
2567// Returns the material number for a given volume ID
2568//
2569 return fMCGeo->VolId2Mate(id);
2570}
2571
2572//______________________________________________________________________________
2573const char* TFluka::VolName(Int_t id) const
2574{
2575//
2576// Returns the volume name for a given volume ID
2577//
2578 return fMCGeo->VolName(id);
2579}
2580
2581//______________________________________________________________________________
2582Int_t TFluka::VolId(const Text_t* volName) const
2583{
2584//
2585// Converts from volume name to volume ID.
2586// Time consuming. (Only used during set-up)
2587// Could be replaced by hash-table
2588//
2589 return fMCGeo->VolId(volName);
2590}
2591
2592//______________________________________________________________________________
2593Int_t TFluka::CurrentVolID(Int_t& copyNo) const
2594{
2595//
2596// Return the logical id and copy number corresponding to the current fluka region
2597//
2598 if (gGeoManager->IsOutside()) return 0;
2599 TGeoNode *node = gGeoManager->GetCurrentNode();
2600 copyNo = node->GetNumber();
2601 Int_t id = node->GetVolume()->GetNumber();
2602 return id;
2603}
2604
2605//______________________________________________________________________________
2606Int_t TFluka::CurrentVolOffID(Int_t off, Int_t& copyNo) const
2607{
2608//
2609// Return the logical id and copy number of off'th mother
2610// corresponding to the current fluka region
2611//
2612 if (off<0 || off>gGeoManager->GetLevel()) return 0;
2613 if (off==0) return CurrentVolID(copyNo);
2614 TGeoNode *node = gGeoManager->GetMother(off);
2615 if (!node) return 0;
2616 copyNo = node->GetNumber();
2617 return node->GetVolume()->GetNumber();
2618}
2619
2620//______________________________________________________________________________
2621const char* TFluka::CurrentVolName() const
2622{
2623//
2624// Return the current volume name
2625//
2626 if (gGeoManager->IsOutside()) return 0;
2627 return gGeoManager->GetCurrentVolume()->GetName();
2628}
2629
2630//______________________________________________________________________________
2631const char* TFluka::CurrentVolOffName(Int_t off) const
2632{
2633//
2634// Return the volume name of the off'th mother of the current volume
2635//
2636 if (off<0 || off>gGeoManager->GetLevel()) return 0;
2637 if (off==0) return CurrentVolName();
2638 TGeoNode *node = gGeoManager->GetMother(off);
2639 if (!node) return 0;
2640 return node->GetVolume()->GetName();
2641}
2642
2643//______________________________________________________________________________
2644Int_t TFluka::CurrentMaterial(Float_t & /*a*/, Float_t & /*z*/,
2645 Float_t & /*dens*/, Float_t & /*radl*/, Float_t & /*absl*/) const
2646{
2647//
2648// Return the current medium number ??? what about material properties
2649//
2650 Int_t copy;
2651 Int_t id = TFluka::CurrentVolID(copy);
2652 Int_t med = TFluka::VolId2Mate(id);
2653 return med;
2654}
2655
2656//______________________________________________________________________________
2657void TFluka::Gmtod(Float_t* xm, Float_t* xd, Int_t iflag)
2658{
2659// Transforms a position from the world reference frame
2660// to the current volume reference frame.
2661//
2662// Geant3 desription:
2663// ==================
2664// Computes coordinates XD (in DRS)
2665// from known coordinates XM in MRS
2666// The local reference system can be initialized by
2667// - the tracking routines and GMTOD used in GUSTEP
2668// - a call to GMEDIA(XM,NUMED)
2669// - a call to GLVOLU(NLEVEL,NAMES,NUMBER,IER)
2670// (inverse routine is GDTOM)
2671//
2672// If IFLAG=1 convert coordinates
2673// IFLAG=2 convert direction cosinus
2674//
2675// ---
2676 Double_t xmL[3], xdL[3];
2677 Int_t i;
2678 for (i=0;i<3;i++) xmL[i]=xm[i];
2679 if (iflag == 1) gGeoManager->MasterToLocal(xmL,xdL);
2680 else gGeoManager->MasterToLocalVect(xmL,xdL);
2681 for (i=0;i<3;i++) xd[i] = xdL[i];
2682}
2683
2684//______________________________________________________________________________
2685void TFluka::Gmtod(Double_t* xm, Double_t* xd, Int_t iflag)
2686{
2687 if (iflag == 1) gGeoManager->MasterToLocal(xm,xd);
2688 else gGeoManager->MasterToLocalVect(xm,xd);
2689}
2690
2691//______________________________________________________________________________
2692void TFluka::Gdtom(Float_t* xd, Float_t* xm, Int_t iflag)
2693{
2694// Transforms a position from the current volume reference frame
2695// to the world reference frame.
2696//
2697// Geant3 desription:
2698// ==================
2699// Computes coordinates XM (Master Reference System
2700// knowing the coordinates XD (Detector Ref System)
2701// The local reference system can be initialized by
2702// - the tracking routines and GDTOM used in GUSTEP
2703// - a call to GSCMED(NLEVEL,NAMES,NUMBER)
2704// (inverse routine is GMTOD)
2705//
2706// If IFLAG=1 convert coordinates
2707// IFLAG=2 convert direction cosinus
2708//
2709// ---
2710 Double_t xmL[3], xdL[3];
2711 Int_t i;
2712 for (i=0;i<3;i++) xdL[i] = xd[i];
2713 if (iflag == 1) gGeoManager->LocalToMaster(xdL,xmL);
2714 else gGeoManager->LocalToMasterVect(xdL,xmL);
2715 for (i=0;i<3;i++) xm[i]=xmL[i];
2716}
2717
2718//______________________________________________________________________________
2719void TFluka::Gdtom(Double_t* xd, Double_t* xm, Int_t iflag)
2720{
2721 if (iflag == 1) gGeoManager->LocalToMaster(xd,xm);
2722 else gGeoManager->LocalToMasterVect(xd,xm);
2723}
2724
2725//______________________________________________________________________________
2726TObjArray *TFluka::GetFlukaMaterials()
2727{
2728 return fGeom->GetMatList();
2729}
2730
2731//______________________________________________________________________________
2732void TFluka::SetMreg(Int_t l)
2733{
2734// Set current fluka region
2735 fCurrentFlukaRegion = l;
2736 fGeom->SetMreg(l);
2737}
2738
2739
b496f27c 2740
2741
2742TString TFluka::ParticleName(Int_t pdg) const
2743{
2744 // Return particle name for particle with pdg code pdg.
2745 Int_t ifluka = IdFromPDG(pdg);
2746 return TString((CHPPRP.btype[ifluka+6]), 8);
2747}
2748
2749
2750Double_t TFluka::ParticleMass(Int_t pdg) const
2751{
2752 // Return particle mass for particle with pdg code pdg.
2753 Int_t ifluka = IdFromPDG(pdg);
2754 return (PAPROP.am[ifluka+6]);
2755}
2756
2757Double_t TFluka::ParticleCharge(Int_t pdg) const
2758{
2759 // Return particle charge for particle with pdg code pdg.
2760 Int_t ifluka = IdFromPDG(pdg);
2761 return Double_t(PAPROP.ichrge[ifluka+6]);
2762}
2763
2764Double_t TFluka::ParticleLifeTime(Int_t pdg) const
2765{
2766 // Return particle lifetime for particle with pdg code pdg.
2767 Int_t ifluka = IdFromPDG(pdg);
2768 return (PAPROP.thalf[ifluka+6]);
2769}
2770
2771void TFluka::Gfpart(Int_t pdg, char* name, Int_t& type, Float_t& mass, Float_t& charge, Float_t& tlife)
2772{
2773 // Retrieve particle properties for particle with pdg code pdg.
2774
2775 strcpy(name, ParticleName(pdg).Data());
2776 type = ParticleMCType(pdg);
2777 mass = ParticleMass(pdg);
2778 charge = ParticleCharge(pdg);
2779 tlife = ParticleLifeTime(pdg);
2780}
2781
2782
2783
3a625972 2784#define pushcerenkovphoton pushcerenkovphoton_
7b203b6e 2785#define usersteppingckv usersteppingckv_
3a625972 2786
2787
2788extern "C" {
2789 void pushcerenkovphoton(Double_t & px, Double_t & py, Double_t & pz, Double_t & e,
2790 Double_t & vx, Double_t & vy, Double_t & vz, Double_t & tof,
2791 Double_t & polx, Double_t & poly, Double_t & polz, Double_t & wgt, Int_t& ntr)
2792 {
2793 //
2794 // Pushes one cerenkov photon to the stack
2795 //
2796
2797 TFluka* fluka = (TFluka*) gMC;
2798 TVirtualMCStack* cppstack = fluka->GetStack();
bd3d5c8a 2799 Int_t parent = TRACKR.ispusr[mkbmx2-1];
921e0994 2800 cppstack->PushTrack(0, parent, 50000050,
3a625972 2801 px, py, pz, e,
2802 vx, vy, vz, tof,
2803 polx, poly, polz,
2804 kPCerenkov, ntr, wgt, 0);
2805 }
7b203b6e 2806
2807 void usersteppingckv(Int_t & nphot, Int_t & mreg, Double_t & x, Double_t & y, Double_t & z)
2808 {
2809 //
2810 // Calls stepping in order to signal cerenkov production
2811 //
2812 TFluka *fluka = (TFluka*)gMC;
2813 fluka->SetMreg(mreg);
2814 fluka->SetXsco(x);
2815 fluka->SetYsco(y);
2816 fluka->SetZsco(z);
2817 fluka->SetNCerenkov(nphot);
2818 fluka->SetCaller(50);
2819 printf("userstepping ckv: %10d %10d %13.3f %13.3f %13.2f\n", nphot, mreg, x, y, z);
2820 (TVirtualMCApplication::Instance())->Stepping();
2821 }
3a625972 2822}
829fb838 2823