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$ |
f9cb2fec |
18 | Revision 1.3 2002/10/22 15:12:14 alibrary |
19 | Introducing Riostream.h |
20 | |
eae0fe66 |
21 | Revision 1.2 2002/10/14 14:57:40 hristov |
22 | Merging the VirtualMC branch to the main development branch (HEAD) |
23 | |
b9d0a01d |
24 | Revision 1.1.2.8 2002/10/08 16:33:17 iglez2 |
25 | LSOUIT is set to true before the second call to flukam. |
26 | |
27 | Revision 1.1.2.7 2002/10/08 09:30:37 iglez2 |
28 | Solved stupid missing ; |
29 | |
30 | Revision 1.1.2.6 2002/10/07 13:40:22 iglez2 |
31 | First implementations of the PDG <--> Fluka Id conversion routines |
32 | |
33 | Revision 1.1.2.5 2002/09/26 16:26:03 iglez2 |
34 | Added verbosity |
35 | Call to gAlice->Generator()->Generate() |
36 | |
37 | Revision 1.1.2.4 2002/09/26 13:22:23 iglez2 |
38 | Naive implementation of ProcessRun and ProcessEvent |
39 | Opening/Closing of input file (fInputFileName) with FORTRAN unit 5 before/after the first call to flukam inside Init() |
40 | |
41 | Revision 1.1.2.3 2002/09/20 15:35:51 iglez2 |
42 | Modification of LFDRTR. Value is passed to FLUKA !!! |
43 | |
44 | Revision 1.1.2.2 2002/09/18 14:34:44 iglez2 |
45 | Revised version with all pure virtual methods implemented |
46 | |
47 | Revision 1.1.2.1 2002/07/24 08:49:41 alibrary |
48 | Adding TFluka to VirtualMC |
49 | |
50 | Revision 1.1 2002/07/05 13:10:07 morsch |
51 | First commit of Fluka interface. |
52 | |
03ca248b |
53 | */ |
54 | |
eae0fe66 |
55 | #include <Riostream.h> |
b9d0a01d |
56 | |
03ca248b |
57 | #include "TFluka.h" |
b9d0a01d |
58 | #include "TCallf77.h" //For the fortran calls |
59 | #include "Fdblprc.h" //(DBLPRC) fluka common |
60 | #include "Fiounit.h" //(IOUNIT) fluka common |
61 | #include "Fepisor.h" //(EPISOR) fluka common |
f9cb2fec |
62 | #include "Fpart.h" //(PART) fluka common |
b9d0a01d |
63 | #include "TVirtualMC.h" |
64 | |
65 | // Fluka methods that may be needed. |
66 | #ifndef WIN32 |
67 | # define flukam flukam_ |
68 | # define fluka_openinp fluka_openinp_ |
69 | # define fluka_closeinp fluka_closeinp_ |
f9cb2fec |
70 | # define mcihad mcihad_ |
71 | # define mpdgha mpdgha_ |
b9d0a01d |
72 | #else |
73 | # define flukam FLUKAM |
74 | # define fluka_openinp FLUKA_OPENINP |
75 | # define fluka_closeinp FLUKA_CLOSEINP |
f9cb2fec |
76 | # define mcihad MCIHAD |
77 | # define mpdgha MPDGHA |
b9d0a01d |
78 | #endif |
79 | |
80 | extern "C" |
81 | { |
82 | // |
83 | // Prototypes for FLUKA functions |
84 | // |
85 | void type_of_call flukam(const int&); |
86 | void type_of_call fluka_openinp(const int&, DEFCHARA); |
87 | void type_of_call fluka_closeinp(const int&); |
f9cb2fec |
88 | int type_of_call mcihad(const int&); |
89 | int type_of_call mpdgha(const int&); |
b9d0a01d |
90 | } |
91 | |
92 | // |
93 | // Class implementation for ROOT |
94 | // |
03ca248b |
95 | ClassImp(TFluka) |
b9d0a01d |
96 | |
97 | // |
98 | // TFluka methods. |
99 | //____________________________________________________________________________ |
100 | TFluka::TFluka() |
101 | :TVirtualMC(), |
102 | fVerbosityLevel(0), |
103 | fInputFileName("") |
104 | { |
105 | // |
106 | // Default constructor |
107 | // |
108 | } |
109 | |
110 | //____________________________________________________________________________ |
111 | TFluka::TFluka(const char *title, Int_t verbosity) |
112 | :TVirtualMC("TFluka",title), |
113 | fVerbosityLevel(verbosity), |
114 | fInputFileName("") |
115 | { |
116 | if (fVerbosityLevel >=3) |
117 | cout << "==> TFluka::TFluka(" << title << ") constructor called." << endl; |
118 | |
119 | if (fVerbosityLevel >=3) |
120 | cout << "<== TFluka::TFluka(" << title << ") constructor called." << endl; |
121 | } |
122 | |
123 | //____________________________________________________________________________ |
124 | void TFluka::Init() { |
125 | if (fVerbosityLevel >=3) |
126 | cout << "==> TFluka::Init() called." << endl; |
127 | |
128 | if (fVerbosityLevel >=2) |
129 | cout << "\t* Changing lfdrtr = (" << (GLOBAL.lfdrtr?'T':'F') |
130 | << ") in fluka..." << endl; |
131 | GLOBAL.lfdrtr = true; |
132 | |
133 | if (fVerbosityLevel >=2) |
134 | cout << "\t* Opening file " << fInputFileName << endl; |
135 | const char* fname = fInputFileName; |
136 | fluka_openinp(lunin, PASSCHARA(fname)); |
137 | |
138 | if (fVerbosityLevel >=2) |
139 | cout << "\t* Calling flukam..." << endl; |
140 | flukam(0); |
141 | |
142 | if (fVerbosityLevel >=2) |
143 | cout << "\t* Closing file " << fInputFileName << endl; |
144 | fluka_closeinp(lunin); |
145 | |
146 | if (fVerbosityLevel >=3) |
147 | cout << "<== TFluka::Init() called." << endl; |
148 | } |
149 | |
150 | //____________________________________________________________________________ |
151 | void TFluka::ProcessEvent() { |
152 | if (fVerbosityLevel >=3) |
153 | cout << "==> TFluka::ProcessEvent() called." << endl; |
154 | |
155 | if (fVerbosityLevel >=3) |
156 | cout << "<== TFluka::ProcessEvent() called." << endl; |
157 | } |
158 | |
159 | //____________________________________________________________________________ |
160 | void TFluka::ProcessRun(Int_t nevent) { |
161 | if (fVerbosityLevel >=3) |
162 | cout << "==> TFluka::ProcessRun(" << nevent << ") called." |
163 | << endl; |
164 | |
165 | if (fVerbosityLevel >=2) { |
166 | cout << "\t* GLOBAL.fdrtr = " << (GLOBAL.lfdrtr?'T':'F') << endl; |
167 | cout << "\t* Calling flukam again..." << endl; |
168 | } |
169 | fApplication->GeneratePrimaries(); |
170 | EPISOR.lsouit = true; |
171 | flukam(0); |
172 | |
173 | if (fVerbosityLevel >=3) |
174 | cout << "<== TFluka::ProcessRun(" << nevent << ") called." |
175 | << endl; |
176 | } |
177 | |
178 | //_____________________________________________________________________________ |
179 | Int_t TFluka::IdFromPDG(Int_t pdg) const |
180 | { |
181 | // |
f9cb2fec |
182 | // Return Fluka code from PDG and pseudo ENDF code |
183 | |
184 | // MCIHAD() goes from pdg to fluka internal. |
185 | Int_t intfluka = mcihad(pdg); |
186 | // KPTOIP array goes from internal to official |
187 | return GetFlukaKPTOIP(intfluka); |
b9d0a01d |
188 | } |
189 | |
190 | //_____________________________________________________________________________ |
191 | Int_t TFluka::PDGFromId(Int_t id) const |
192 | { |
193 | // |
f9cb2fec |
194 | // Return PDG code and pseudo ENDF code from Fluka code |
b9d0a01d |
195 | |
f9cb2fec |
196 | //IPTOKP array goes from official to internal |
197 | Int_t intfluka = GetFlukaIPTOKP(id); |
198 | //MPKDHA() goes from internal to PDG |
199 | return mpdgha(intfluka); |
200 | |
b9d0a01d |
201 | } |