]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TFluka/TFluka.cxx
Change noise spectrum
[u/mrichter/AliRoot.git] / TFluka / TFluka.cxx
CommitLineData
03ca248b 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/*
17$Log$
bf3aa28e 18Revision 1.4 2002/11/04 16:00:46 iglez2
19The conversion between ID and PDG now uses Fluka routines and arrays which is more consistent.
20
f9cb2fec 21Revision 1.3 2002/10/22 15:12:14 alibrary
22Introducing Riostream.h
23
eae0fe66 24Revision 1.2 2002/10/14 14:57:40 hristov
25Merging the VirtualMC branch to the main development branch (HEAD)
26
b9d0a01d 27Revision 1.1.2.8 2002/10/08 16:33:17 iglez2
28LSOUIT is set to true before the second call to flukam.
29
30Revision 1.1.2.7 2002/10/08 09:30:37 iglez2
31Solved stupid missing ;
32
33Revision 1.1.2.6 2002/10/07 13:40:22 iglez2
34First implementations of the PDG <--> Fluka Id conversion routines
35
36Revision 1.1.2.5 2002/09/26 16:26:03 iglez2
37Added verbosity
38Call to gAlice->Generator()->Generate()
39
40Revision 1.1.2.4 2002/09/26 13:22:23 iglez2
41Naive implementation of ProcessRun and ProcessEvent
42Opening/Closing of input file (fInputFileName) with FORTRAN unit 5 before/after the first call to flukam inside Init()
43
44Revision 1.1.2.3 2002/09/20 15:35:51 iglez2
45Modification of LFDRTR. Value is passed to FLUKA !!!
46
47Revision 1.1.2.2 2002/09/18 14:34:44 iglez2
48Revised version with all pure virtual methods implemented
49
50Revision 1.1.2.1 2002/07/24 08:49:41 alibrary
51Adding TFluka to VirtualMC
52
53Revision 1.1 2002/07/05 13:10:07 morsch
54First commit of Fluka interface.
55
03ca248b 56*/
57
eae0fe66 58#include <Riostream.h>
b9d0a01d 59
03ca248b 60#include "TFluka.h"
b9d0a01d 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
f9cb2fec 65#include "Fpart.h" //(PART) fluka common
b9d0a01d 66#include "TVirtualMC.h"
67
bf3aa28e 68#include "TG4GeometryManager.h" //For the geometry management
69#include "TG4DetConstruction.h" //For the detector construction
70
71#include "FGeometryInit.hh"
72
b9d0a01d 73// Fluka methods that may be needed.
74#ifndef WIN32
75# define flukam flukam_
76# define fluka_openinp fluka_openinp_
77# define fluka_closeinp fluka_closeinp_
f9cb2fec 78# define mcihad mcihad_
79# define mpdgha mpdgha_
b9d0a01d 80#else
81# define flukam FLUKAM
82# define fluka_openinp FLUKA_OPENINP
83# define fluka_closeinp FLUKA_CLOSEINP
f9cb2fec 84# define mcihad MCIHAD
85# define mpdgha MPDGHA
b9d0a01d 86#endif
87
88extern "C"
89{
90 //
91 // Prototypes for FLUKA functions
92 //
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&);
f9cb2fec 96 int type_of_call mcihad(const int&);
97 int type_of_call mpdgha(const int&);
b9d0a01d 98}
99
100//
101// Class implementation for ROOT
102//
03ca248b 103ClassImp(TFluka)
b9d0a01d 104
105//
bf3aa28e 106//----------------------------------------------------------------------------
107// TFluka constructors and destructors.
b9d0a01d 108//____________________________________________________________________________
109TFluka::TFluka()
110 :TVirtualMC(),
111 fVerbosityLevel(0),
bf3aa28e 112 fInputFileName(""),
113 fDetector(0)
b9d0a01d 114{
115 //
116 // Default constructor
117 //
118}
119
b9d0a01d 120TFluka::TFluka(const char *title, Int_t verbosity)
121 :TVirtualMC("TFluka",title),
122 fVerbosityLevel(verbosity),
bf3aa28e 123 fInputFileName(""),
124 fDetector(0)
b9d0a01d 125{
126 if (fVerbosityLevel >=3)
127 cout << "==> TFluka::TFluka(" << title << ") constructor called." << endl;
128
bf3aa28e 129
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();
138 if (geominit)
139 geominit->setDetConstruction(fDetector);
140 else {
141 cerr << "ERROR: Could not create FGeometryInit!" << endl;
142 cerr << " Exiting!!!" << endl;
143 abort();
144 }
145
b9d0a01d 146 if (fVerbosityLevel >=3)
147 cout << "<== TFluka::TFluka(" << title << ") constructor called." << endl;
148}
149
bf3aa28e 150TFluka::~TFluka() {
151 if (fVerbosityLevel >=3)
152 cout << "==> TFluka::~TFluka() destructor called." << endl;
153
154 delete fGeometryManager;
155
156 if (fVerbosityLevel >=3)
157 cout << "<== TFluka::~TFluka() destructor called." << endl;
158}
159
160//
161//_____________________________________________________________________________
162// TFluka control methods
b9d0a01d 163//____________________________________________________________________________
164void TFluka::Init() {
165 if (fVerbosityLevel >=3)
166 cout << "==> TFluka::Init() called." << endl;
167
168 if (fVerbosityLevel >=2)
169 cout << "\t* Changing lfdrtr = (" << (GLOBAL.lfdrtr?'T':'F')
170 << ") in fluka..." << endl;
171 GLOBAL.lfdrtr = true;
172
173 if (fVerbosityLevel >=2)
174 cout << "\t* Opening file " << fInputFileName << endl;
175 const char* fname = fInputFileName;
176 fluka_openinp(lunin, PASSCHARA(fname));
177
178 if (fVerbosityLevel >=2)
179 cout << "\t* Calling flukam..." << endl;
bf3aa28e 180 flukam(1);
b9d0a01d 181
182 if (fVerbosityLevel >=2)
183 cout << "\t* Closing file " << fInputFileName << endl;
184 fluka_closeinp(lunin);
185
186 if (fVerbosityLevel >=3)
187 cout << "<== TFluka::Init() called." << endl;
188}
189
bf3aa28e 190void TFluka::FinishGeometry() {
191 if (fVerbosityLevel >=3)
192 cout << "==> TFluka::FinishGeometry() called." << endl;
193
194 fGeometryManager->Ggclos();
195
196 if (fVerbosityLevel >=3)
197 cout << "<== TFluka::FinishGeometry() called." << endl;
198}
199
200void TFluka::BuildPhysics() {
201 if (fVerbosityLevel >=3)
202 cout << "==> TFluka::BuildPhysics() called." << endl;
203
204
205 if (fVerbosityLevel >=3)
206 cout << "<== TFluka::BuildPhysics() called." << endl;
207}
208
b9d0a01d 209void TFluka::ProcessEvent() {
210 if (fVerbosityLevel >=3)
211 cout << "==> TFluka::ProcessEvent() called." << endl;
212
213 if (fVerbosityLevel >=3)
214 cout << "<== TFluka::ProcessEvent() called." << endl;
215}
216
bf3aa28e 217
b9d0a01d 218void TFluka::ProcessRun(Int_t nevent) {
219 if (fVerbosityLevel >=3)
220 cout << "==> TFluka::ProcessRun(" << nevent << ") called."
221 << endl;
222
223 if (fVerbosityLevel >=2) {
224 cout << "\t* GLOBAL.fdrtr = " << (GLOBAL.lfdrtr?'T':'F') << endl;
225 cout << "\t* Calling flukam again..." << endl;
226 }
227 fApplication->GeneratePrimaries();
228 EPISOR.lsouit = true;
bf3aa28e 229 flukam(1);
b9d0a01d 230
231 if (fVerbosityLevel >=3)
232 cout << "<== TFluka::ProcessRun(" << nevent << ") called."
233 << endl;
234}
235
bf3aa28e 236//_____________________________________________________________________________
237// methods for building/management of geometry
238//____________________________________________________________________________
239// functions from GCONS
240void 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) {
243//
244 fGeometryManager->Gfmate(imat, name, a, z, dens, radl, absl, ubuf, nbuf);
245}
246
247void 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) {
250//
251 fGeometryManager->Gfmate(imat, name, a, z, dens, radl, absl, ubuf, nbuf);
252}
253
254// detector composition
255void 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) {
258//
259 fGeometryManager
260 ->Material(kmat, name, a, z, dens, radl, absl, buf, nwbuf);
261}
262void 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) {
265//
266 fGeometryManager
267 ->Material(kmat, name, a, z, dens, radl, absl, buf, nwbuf);
268}
269
270void TFluka::Mixture(Int_t& kmat, const char *name, Float_t *a,
271 Float_t *z, Double_t dens, Int_t nlmat, Float_t *wmat) {
272//
273 fGeometryManager
274 ->Mixture(kmat, name, a, z, dens, nlmat, wmat);
275}
276void TFluka::Mixture(Int_t& kmat, const char *name, Double_t *a,
277 Double_t *z, Double_t dens, Int_t nlmat, Double_t *wmat) {
278//
279 fGeometryManager
280 ->Mixture(kmat, name, a, z, dens, nlmat, wmat);
281}
282
283void 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) {
287 //
288 fGeometryManager
289 ->Medium(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax,
290 epsil, stmin, ubuf, nbuf);
291}
292void 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) {
296 //
297 fGeometryManager
298 ->Medium(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax,
299 epsil, stmin, ubuf, nbuf);
300}
301
302void TFluka::Matrix(Int_t& krot, Double_t thetaX, Double_t phiX,
303 Double_t thetaY, Double_t phiY, Double_t thetaZ,
304 Double_t phiZ) {
305//
306 fGeometryManager
307 ->Matrix(krot, thetaX, phiX, thetaY, phiY, thetaZ, phiZ);
308}
309
310void TFluka::Gstpar(Int_t itmed, const char *param, Double_t parval) {
311//
312 fGeometryManager->Gstpar(itmed, param, parval);
313}
314
315// functions from GGEOM
316Int_t TFluka::Gsvolu(const char *name, const char *shape, Int_t nmed,
317 Float_t *upar, Int_t np) {
318//
319 return fGeometryManager->Gsvolu(name, shape, nmed, upar, np);
320}
321Int_t TFluka::Gsvolu(const char *name, const char *shape, Int_t nmed,
322 Double_t *upar, Int_t np) {
323//
324 return fGeometryManager->Gsvolu(name, shape, nmed, upar, np);
325}
326
327void TFluka::Gsdvn(const char *name, const char *mother, Int_t ndiv,
328 Int_t iaxis) {
329//
330 fGeometryManager->Gsdvn(name, mother, ndiv, iaxis);
331}
332
333void TFluka::Gsdvn2(const char *name, const char *mother, Int_t ndiv,
334 Int_t iaxis, Double_t c0i, Int_t numed) {
335//
336 fGeometryManager->Gsdvn2(name, mother, ndiv, iaxis, c0i, numed);
337}
338
339void TFluka::Gsdvt(const char *name, const char *mother, Double_t step,
340 Int_t iaxis, Int_t numed, Int_t ndvmx) {
341//
342 fGeometryManager->Gsdvt(name, mother, step, iaxis, numed, ndvmx);
343}
344
345void TFluka::Gsdvt2(const char *name, const char *mother, Double_t step,
346 Int_t iaxis, Double_t c0, Int_t numed, Int_t ndvmx) {
347//
348 fGeometryManager->Gsdvt2(name, mother, step, iaxis, c0, numed, ndvmx);
349}
350
351void TFluka::Gsord(const char *name, Int_t iax) {
352//
353 fGeometryManager->Gsord(name, iax);
354}
355
356void TFluka::Gspos(const char *name, Int_t nr, const char *mother,
357 Double_t x, Double_t y, Double_t z, Int_t irot,
358 const char *konly) {
359//
360 fGeometryManager->Gspos(name, nr, mother, x, y, z, irot, konly);
361}
362
363void 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) {
366 //
367 fGeometryManager->Gsposp(name, nr, mother, x, y, z, irot, konly, upar, np);
368}
369void 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) {
372 //
373 fGeometryManager->Gsposp(name, nr, mother, x, y, z, irot, konly, upar, np);
374}
375
376void TFluka::Gsbool(const char* onlyVolName, const char* manyVolName) {
377//
378 fGeometryManager->Gsbool(onlyVolName, manyVolName);
379}
380
381void TFluka::SetCerenkov(Int_t itmed, Int_t npckov, Float_t *ppckov,
382 Float_t *absco, Float_t *effic, Float_t *rindex) {
383//
384 fGeometryManager->SetCerenkov(itmed, npckov, ppckov, absco, effic, rindex);
385}
386void TFluka::SetCerenkov(Int_t itmed, Int_t npckov, Double_t *ppckov,
387 Double_t *absco, Double_t *effic, Double_t *rindex) {
388//
389 fGeometryManager->SetCerenkov(itmed, npckov, ppckov, absco, effic, rindex);
390}
391
392// Euclid
393void TFluka::WriteEuclid(const char* fileName, const char* topVol,
394 Int_t number, Int_t nlevel) {
395//
396 fGeometryManager->WriteEuclid(fileName, topVol, number, nlevel);
397}
398
399
400
401
402
403
404//____________________________________________________________________________
405// ID <--> PDG transformations
b9d0a01d 406//_____________________________________________________________________________
407Int_t TFluka::IdFromPDG(Int_t pdg) const
408{
409 //
f9cb2fec 410 // Return Fluka code from PDG and pseudo ENDF code
411
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);
b9d0a01d 416}
417
b9d0a01d 418Int_t TFluka::PDGFromId(Int_t id) const
419{
420 //
f9cb2fec 421 // Return PDG code and pseudo ENDF code from Fluka code
b9d0a01d 422
f9cb2fec 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);
427
b9d0a01d 428}