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