1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.4 2002/11/04 16:00:46 iglez2
19 The conversion between ID and PDG now uses Fluka routines and arrays which is more consistent.
21 Revision 1.3 2002/10/22 15:12:14 alibrary
22 Introducing Riostream.h
24 Revision 1.2 2002/10/14 14:57:40 hristov
25 Merging the VirtualMC branch to the main development branch (HEAD)
27 Revision 1.1.2.8 2002/10/08 16:33:17 iglez2
28 LSOUIT is set to true before the second call to flukam.
30 Revision 1.1.2.7 2002/10/08 09:30:37 iglez2
31 Solved stupid missing ;
33 Revision 1.1.2.6 2002/10/07 13:40:22 iglez2
34 First implementations of the PDG <--> Fluka Id conversion routines
36 Revision 1.1.2.5 2002/09/26 16:26:03 iglez2
38 Call to gAlice->Generator()->Generate()
40 Revision 1.1.2.4 2002/09/26 13:22:23 iglez2
41 Naive implementation of ProcessRun and ProcessEvent
42 Opening/Closing of input file (fInputFileName) with FORTRAN unit 5 before/after the first call to flukam inside Init()
44 Revision 1.1.2.3 2002/09/20 15:35:51 iglez2
45 Modification of LFDRTR. Value is passed to FLUKA !!!
47 Revision 1.1.2.2 2002/09/18 14:34:44 iglez2
48 Revised version with all pure virtual methods implemented
50 Revision 1.1.2.1 2002/07/24 08:49:41 alibrary
51 Adding TFluka to VirtualMC
53 Revision 1.1 2002/07/05 13:10:07 morsch
54 First commit of Fluka interface.
58 #include <Riostream.h>
61 #include "TCallf77.h" //For the fortran calls
62 #include "Fdblprc.h" //(DBLPRC) fluka common
63 #include "Fiounit.h" //(IOUNIT) fluka common
64 #include "Fepisor.h" //(EPISOR) fluka common
65 #include "Fpart.h" //(PART) fluka common
66 #include "TVirtualMC.h"
68 #include "TG4GeometryManager.h" //For the geometry management
69 #include "TG4DetConstruction.h" //For the detector construction
71 #include "FGeometryInit.hh"
73 // Fluka methods that may be needed.
75 # define flukam flukam_
76 # define fluka_openinp fluka_openinp_
77 # define fluka_closeinp fluka_closeinp_
78 # define mcihad mcihad_
79 # define mpdgha mpdgha_
81 # define flukam FLUKAM
82 # define fluka_openinp FLUKA_OPENINP
83 # define fluka_closeinp FLUKA_CLOSEINP
84 # define mcihad MCIHAD
85 # define mpdgha MPDGHA
91 // Prototypes for FLUKA functions
93 void type_of_call flukam(const int&);
94 void type_of_call fluka_openinp(const int&, DEFCHARA);
95 void type_of_call fluka_closeinp(const int&);
96 int type_of_call mcihad(const int&);
97 int type_of_call mpdgha(const int&);
101 // Class implementation for ROOT
106 //----------------------------------------------------------------------------
107 // TFluka constructors and destructors.
108 //____________________________________________________________________________
116 // Default constructor
120 TFluka::TFluka(const char *title, Int_t verbosity)
121 :TVirtualMC("TFluka",title),
122 fVerbosityLevel(verbosity),
126 if (fVerbosityLevel >=3)
127 cout << "==> TFluka::TFluka(" << title << ") constructor called." << endl;
130 // create geometry manager
131 if (fVerbosityLevel >=2)
132 cout << "\t* Creating G4 Geometry manager..." << endl;
133 fGeometryManager = new TG4GeometryManager();
134 if (fVerbosityLevel >=2)
135 cout << "\t* Creating G4 Detector..." << endl;
136 fDetector = new TG4DetConstruction();
137 FGeometryInit* geominit = FGeometryInit::GetInstance();
139 geominit->setDetConstruction(fDetector);
141 cerr << "ERROR: Could not create FGeometryInit!" << endl;
142 cerr << " Exiting!!!" << endl;
146 if (fVerbosityLevel >=3)
147 cout << "<== TFluka::TFluka(" << title << ") constructor called." << endl;
151 if (fVerbosityLevel >=3)
152 cout << "==> TFluka::~TFluka() destructor called." << endl;
154 delete fGeometryManager;
156 if (fVerbosityLevel >=3)
157 cout << "<== TFluka::~TFluka() destructor called." << endl;
161 //_____________________________________________________________________________
162 // TFluka control methods
163 //____________________________________________________________________________
164 void TFluka::Init() {
165 if (fVerbosityLevel >=3)
166 cout << "==> TFluka::Init() called." << endl;
168 if (fVerbosityLevel >=2)
169 cout << "\t* Changing lfdrtr = (" << (GLOBAL.lfdrtr?'T':'F')
170 << ") in fluka..." << endl;
171 GLOBAL.lfdrtr = true;
173 if (fVerbosityLevel >=2)
174 cout << "\t* Opening file " << fInputFileName << endl;
175 const char* fname = fInputFileName;
176 fluka_openinp(lunin, PASSCHARA(fname));
178 if (fVerbosityLevel >=2)
179 cout << "\t* Calling flukam..." << endl;
182 if (fVerbosityLevel >=2)
183 cout << "\t* Closing file " << fInputFileName << endl;
184 fluka_closeinp(lunin);
186 if (fVerbosityLevel >=3)
187 cout << "<== TFluka::Init() called." << endl;
190 void TFluka::FinishGeometry() {
191 if (fVerbosityLevel >=3)
192 cout << "==> TFluka::FinishGeometry() called." << endl;
194 fGeometryManager->Ggclos();
196 if (fVerbosityLevel >=3)
197 cout << "<== TFluka::FinishGeometry() called." << endl;
200 void TFluka::BuildPhysics() {
201 if (fVerbosityLevel >=3)
202 cout << "==> TFluka::BuildPhysics() called." << endl;
205 if (fVerbosityLevel >=3)
206 cout << "<== TFluka::BuildPhysics() called." << endl;
209 void TFluka::ProcessEvent() {
210 if (fVerbosityLevel >=3)
211 cout << "==> TFluka::ProcessEvent() called." << endl;
213 if (fVerbosityLevel >=3)
214 cout << "<== TFluka::ProcessEvent() called." << endl;
218 void TFluka::ProcessRun(Int_t nevent) {
219 if (fVerbosityLevel >=3)
220 cout << "==> TFluka::ProcessRun(" << nevent << ") called."
223 if (fVerbosityLevel >=2) {
224 cout << "\t* GLOBAL.fdrtr = " << (GLOBAL.lfdrtr?'T':'F') << endl;
225 cout << "\t* Calling flukam again..." << endl;
227 fApplication->GeneratePrimaries();
228 EPISOR.lsouit = true;
231 if (fVerbosityLevel >=3)
232 cout << "<== TFluka::ProcessRun(" << nevent << ") called."
236 //_____________________________________________________________________________
237 // methods for building/management of geometry
238 //____________________________________________________________________________
239 // functions from GCONS
240 void TFluka::Gfmate(Int_t imat, char *name, Float_t &a, Float_t &z,
241 Float_t &dens, Float_t &radl, Float_t &absl,
242 Float_t* ubuf, Int_t& nbuf) {
244 fGeometryManager->Gfmate(imat, name, a, z, dens, radl, absl, ubuf, nbuf);
247 void TFluka::Gfmate(Int_t imat, char *name, Double_t &a, Double_t &z,
248 Double_t &dens, Double_t &radl, Double_t &absl,
249 Double_t* ubuf, Int_t& nbuf) {
251 fGeometryManager->Gfmate(imat, name, a, z, dens, radl, absl, ubuf, nbuf);
254 // detector composition
255 void TFluka::Material(Int_t& kmat, const char* name, Double_t a,
256 Double_t z, Double_t dens, Double_t radl, Double_t absl,
257 Float_t* buf, Int_t nwbuf) {
260 ->Material(kmat, name, a, z, dens, radl, absl, buf, nwbuf);
262 void TFluka::Material(Int_t& kmat, const char* name, Double_t a,
263 Double_t z, Double_t dens, Double_t radl, Double_t absl,
264 Double_t* buf, Int_t nwbuf) {
267 ->Material(kmat, name, a, z, dens, radl, absl, buf, nwbuf);
270 void TFluka::Mixture(Int_t& kmat, const char *name, Float_t *a,
271 Float_t *z, Double_t dens, Int_t nlmat, Float_t *wmat) {
274 ->Mixture(kmat, name, a, z, dens, nlmat, wmat);
276 void TFluka::Mixture(Int_t& kmat, const char *name, Double_t *a,
277 Double_t *z, Double_t dens, Int_t nlmat, Double_t *wmat) {
280 ->Mixture(kmat, name, a, z, dens, nlmat, wmat);
283 void TFluka::Medium(Int_t& kmed, const char *name, Int_t nmat,
284 Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd,
285 Double_t stemax, Double_t deemax, Double_t epsil,
286 Double_t stmin, Float_t* ubuf, Int_t nbuf) {
289 ->Medium(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax,
290 epsil, stmin, ubuf, nbuf);
292 void TFluka::Medium(Int_t& kmed, const char *name, Int_t nmat,
293 Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd,
294 Double_t stemax, Double_t deemax, Double_t epsil,
295 Double_t stmin, Double_t* ubuf, Int_t nbuf) {
298 ->Medium(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax,
299 epsil, stmin, ubuf, nbuf);
302 void TFluka::Matrix(Int_t& krot, Double_t thetaX, Double_t phiX,
303 Double_t thetaY, Double_t phiY, Double_t thetaZ,
307 ->Matrix(krot, thetaX, phiX, thetaY, phiY, thetaZ, phiZ);
310 void TFluka::Gstpar(Int_t itmed, const char *param, Double_t parval) {
312 fGeometryManager->Gstpar(itmed, param, parval);
315 // functions from GGEOM
316 Int_t TFluka::Gsvolu(const char *name, const char *shape, Int_t nmed,
317 Float_t *upar, Int_t np) {
319 return fGeometryManager->Gsvolu(name, shape, nmed, upar, np);
321 Int_t TFluka::Gsvolu(const char *name, const char *shape, Int_t nmed,
322 Double_t *upar, Int_t np) {
324 return fGeometryManager->Gsvolu(name, shape, nmed, upar, np);
327 void TFluka::Gsdvn(const char *name, const char *mother, Int_t ndiv,
330 fGeometryManager->Gsdvn(name, mother, ndiv, iaxis);
333 void TFluka::Gsdvn2(const char *name, const char *mother, Int_t ndiv,
334 Int_t iaxis, Double_t c0i, Int_t numed) {
336 fGeometryManager->Gsdvn2(name, mother, ndiv, iaxis, c0i, numed);
339 void TFluka::Gsdvt(const char *name, const char *mother, Double_t step,
340 Int_t iaxis, Int_t numed, Int_t ndvmx) {
342 fGeometryManager->Gsdvt(name, mother, step, iaxis, numed, ndvmx);
345 void TFluka::Gsdvt2(const char *name, const char *mother, Double_t step,
346 Int_t iaxis, Double_t c0, Int_t numed, Int_t ndvmx) {
348 fGeometryManager->Gsdvt2(name, mother, step, iaxis, c0, numed, ndvmx);
351 void TFluka::Gsord(const char *name, Int_t iax) {
353 fGeometryManager->Gsord(name, iax);
356 void TFluka::Gspos(const char *name, Int_t nr, const char *mother,
357 Double_t x, Double_t y, Double_t z, Int_t irot,
360 fGeometryManager->Gspos(name, nr, mother, x, y, z, irot, konly);
363 void TFluka::Gsposp(const char *name, Int_t nr, const char *mother,
364 Double_t x, Double_t y, Double_t z, Int_t irot,
365 const char *konly, Float_t *upar, Int_t np) {
367 fGeometryManager->Gsposp(name, nr, mother, x, y, z, irot, konly, upar, np);
369 void TFluka::Gsposp(const char *name, Int_t nr, const char *mother,
370 Double_t x, Double_t y, Double_t z, Int_t irot,
371 const char *konly, Double_t *upar, Int_t np) {
373 fGeometryManager->Gsposp(name, nr, mother, x, y, z, irot, konly, upar, np);
376 void TFluka::Gsbool(const char* onlyVolName, const char* manyVolName) {
378 fGeometryManager->Gsbool(onlyVolName, manyVolName);
381 void TFluka::SetCerenkov(Int_t itmed, Int_t npckov, Float_t *ppckov,
382 Float_t *absco, Float_t *effic, Float_t *rindex) {
384 fGeometryManager->SetCerenkov(itmed, npckov, ppckov, absco, effic, rindex);
386 void TFluka::SetCerenkov(Int_t itmed, Int_t npckov, Double_t *ppckov,
387 Double_t *absco, Double_t *effic, Double_t *rindex) {
389 fGeometryManager->SetCerenkov(itmed, npckov, ppckov, absco, effic, rindex);
393 void TFluka::WriteEuclid(const char* fileName, const char* topVol,
394 Int_t number, Int_t nlevel) {
396 fGeometryManager->WriteEuclid(fileName, topVol, number, nlevel);
404 //____________________________________________________________________________
405 // ID <--> PDG transformations
406 //_____________________________________________________________________________
407 Int_t TFluka::IdFromPDG(Int_t pdg) const
410 // Return Fluka code from PDG and pseudo ENDF code
412 // MCIHAD() goes from pdg to fluka internal.
413 Int_t intfluka = mcihad(pdg);
414 // KPTOIP array goes from internal to official
415 return GetFlukaKPTOIP(intfluka);
418 Int_t TFluka::PDGFromId(Int_t id) const
421 // Return PDG code and pseudo ENDF code from Fluka code
423 //IPTOKP array goes from official to internal
424 Int_t intfluka = GetFlukaIPTOKP(id);
425 //MPKDHA() goes from internal to PDG
426 return mpdgha(intfluka);