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