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