]>
Commit | Line | Data |
---|---|---|
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> | |
37b09b91 | 33 | #include <TList.h> |
829fb838 | 34 | |
829fb838 | 35 | #include "TFluka.h" |
a9ea1616 | 36 | #include "TFlukaCodes.h" |
829fb838 | 37 | #include "TCallf77.h" //For the fortran calls |
38 | #include "Fdblprc.h" //(DBLPRC) fluka common | |
81f1d030 | 39 | #include "Fsourcm.h" //(SOURCM) fluka common |
40 | #include "Fgenstk.h" //(GENSTK) fluka common | |
829fb838 | 41 | #include "Fiounit.h" //(IOUNIT) fluka common |
42 | #include "Fpaprop.h" //(PAPROP) fluka common | |
43 | #include "Fpart.h" //(PART) fluka common | |
44 | #include "Ftrackr.h" //(TRACKR) fluka common | |
45 | #include "Fpaprop.h" //(PAPROP) fluka common | |
46 | #include "Ffheavy.h" //(FHEAVY) fluka common | |
3a625972 | 47 | #include "Fopphst.h" //(OPPHST) fluka common |
81f1d030 | 48 | #include "Fflkstk.h" //(FLKSTK) fluka common |
07f5b33e | 49 | #include "Fstepsz.h" //(STEPSZ) fluka common |
7b203b6e | 50 | #include "Fopphst.h" //(OPPHST) fluka common |
a9ea1616 | 51 | #include "Fltclcm.h" //(LTCLCM) fluka common |
f2a98602 | 52 | #include "Falldlt.h" //(ALLDLT) fluka common |
829fb838 | 53 | |
54 | #include "TVirtualMC.h" | |
3a625972 | 55 | #include "TMCProcess.h" |
829fb838 | 56 | #include "TGeoManager.h" |
57 | #include "TGeoMaterial.h" | |
58 | #include "TGeoMedium.h" | |
59 | #include "TFlukaMCGeometry.h" | |
6f5667d1 | 60 | #include "TGeoMCGeometry.h" |
829fb838 | 61 | #include "TFlukaCerenkov.h" |
1df5fa54 | 62 | #include "TFlukaConfigOption.h" |
b496f27c | 63 | #include "TFlukaScoringOption.h" |
829fb838 | 64 | #include "TLorentzVector.h" |
b496f27c | 65 | #include "TArrayI.h" |
a9ea1616 | 66 | #include "TArrayD.h" |
78df7be0 | 67 | #include "TDatabasePDG.h" |
4aba9d66 | 68 | #include "TStopwatch.h" |
69 | ||
829fb838 | 70 | |
71 | // Fluka methods that may be needed. | |
72 | #ifndef WIN32 | |
73 | # define flukam flukam_ | |
74 | # define fluka_openinp fluka_openinp_ | |
8e5bf079 | 75 | # define fluka_openout fluka_openout_ |
829fb838 | 76 | # define fluka_closeinp fluka_closeinp_ |
77 | # define mcihad mcihad_ | |
78 | # define mpdgha mpdgha_ | |
2047b055 | 79 | # define newplo newplo_ |
4aba9d66 | 80 | # define genout genout_ |
81 | # define flkend flkend_ | |
829fb838 | 82 | #else |
83 | # define flukam FLUKAM | |
84 | # define fluka_openinp FLUKA_OPENINP | |
8e5bf079 | 85 | # define fluka_openout FLUKA_OPENOUT |
829fb838 | 86 | # define fluka_closeinp FLUKA_CLOSEINP |
87 | # define mcihad MCIHAD | |
88 | # define mpdgha MPDGHA | |
eea53470 | 89 | # define newplo NEWPLO |
4aba9d66 | 90 | # define genout GENOUT |
91 | # define flkend FLKEND | |
829fb838 | 92 | #endif |
93 | ||
94 | extern "C" | |
95 | { | |
96 | // | |
97 | // Prototypes for FLUKA functions | |
98 | // | |
99 | void type_of_call flukam(const int&); | |
eea53470 | 100 | void type_of_call newplo(); |
4aba9d66 | 101 | void type_of_call genout(); |
102 | void type_of_call flkend(); | |
829fb838 | 103 | void type_of_call fluka_openinp(const int&, DEFCHARA); |
8e5bf079 | 104 | void type_of_call fluka_openout(const int&, DEFCHARA); |
829fb838 | 105 | void type_of_call fluka_closeinp(const int&); |
106 | int type_of_call mcihad(const int&); | |
107 | int type_of_call mpdgha(const int&); | |
108 | } | |
109 | ||
110 | // | |
111 | // Class implementation for ROOT | |
112 | // | |
113 | ClassImp(TFluka) | |
114 | ||
115 | // | |
116 | //---------------------------------------------------------------------------- | |
117 | // TFluka constructors and destructors. | |
118 | //______________________________________________________________________________ | |
119 | TFluka::TFluka() | |
120 | :TVirtualMC(), | |
121 | fVerbosityLevel(0), | |
4aba9d66 | 122 | fNEvent(0), |
1df5fa54 | 123 | fInputFileName(""), |
4aba9d66 | 124 | fCoreInputFileName(""), |
125 | fCaller(kNoCaller), | |
126 | fIcode(kNoProcess), | |
127 | fNewReg(-1), | |
128 | fRull(0), | |
129 | fXsco(0), | |
130 | fYsco(0), | |
131 | fZsco(0), | |
132 | fTrackIsEntering(kFALSE), | |
133 | fTrackIsExiting(kFALSE), | |
134 | fTrackIsNew(kFALSE), | |
135 | fFieldFlag(kTRUE), | |
4aba9d66 | 136 | fDummyBoundary(kFALSE), |
137 | fStopped(kFALSE), | |
138 | fStopEvent(kFALSE), | |
139 | fStopRun(kFALSE), | |
5125d6e5 | 140 | fPrimaryElectronIndex(-1), |
1b7bf6a6 | 141 | fLowEnergyNeutronTransport(kFALSE), |
4aba9d66 | 142 | fMaterials(0), |
143 | fNVolumes(0), | |
144 | fCurrentFlukaRegion(-1), | |
145 | fNCerenkov(0), | |
146 | fGeom(0), | |
147 | fMCGeo(0), | |
fb2cbbec | 148 | fUserConfig(0), |
1df5fa54 | 149 | fUserScore(0) |
829fb838 | 150 | { |
151 | // | |
152 | // Default constructor | |
153 | // | |
82a3f706 | 154 | for (Int_t i = 0; i < 4; i++) fPint[i] = 0.; |
829fb838 | 155 | } |
156 | ||
157 | //______________________________________________________________________________ | |
158 | TFluka::TFluka(const char *title, Int_t verbosity, Bool_t isRootGeometrySupported) | |
159 | :TVirtualMC("TFluka",title, isRootGeometrySupported), | |
160 | fVerbosityLevel(verbosity), | |
4aba9d66 | 161 | fNEvent(0), |
829fb838 | 162 | fInputFileName(""), |
4aba9d66 | 163 | fCoreInputFileName(""), |
164 | fCaller(kNoCaller), | |
165 | fIcode(kNoProcess), | |
166 | fNewReg(-1), | |
167 | fRull(0), | |
168 | fXsco(0), | |
169 | fYsco(0), | |
170 | fZsco(0), | |
171 | fTrackIsEntering(kFALSE), | |
172 | fTrackIsExiting(kFALSE), | |
173 | fTrackIsNew(kFALSE), | |
174 | fFieldFlag(kTRUE), | |
4aba9d66 | 175 | fDummyBoundary(kFALSE), |
176 | fStopped(kFALSE), | |
177 | fStopEvent(kFALSE), | |
178 | fStopRun(kFALSE), | |
5125d6e5 | 179 | fPrimaryElectronIndex(-1), |
1b7bf6a6 | 180 | fLowEnergyNeutronTransport(kFALSE), |
4aba9d66 | 181 | fMaterials(0), |
182 | fNVolumes(0), | |
183 | fCurrentFlukaRegion(-1), | |
184 | fNCerenkov(0), | |
185 | fGeom(0), | |
186 | fMCGeo(0), | |
fb2cbbec | 187 | fUserConfig(new TObjArray(100)), |
1df5fa54 | 188 | fUserScore(new TObjArray(100)) |
829fb838 | 189 | { |
190 | // create geometry interface | |
82a3f706 | 191 | for (Int_t i = 0; i < 4; i++) fPint[i] = 0.; |
192 | ||
7f13be31 | 193 | if (fVerbosityLevel >=3) |
194 | cout << "<== TFluka::TFluka(" << title << ") constructor called." << endl; | |
195 | SetCoreInputFileName(); | |
196 | SetInputFileName(); | |
11e4ab84 | 197 | fMCGeo = new TGeoMCGeometry("MCGeo", "TGeo Implementation of VirtualMCGeometry", kFALSE); |
fb2cbbec | 198 | fGeom = new TFlukaMCGeometry("geom", "FLUKA VMC Geometry"); |
829fb838 | 199 | if (verbosity > 2) fGeom->SetDebugMode(kTRUE); |
8e5bf079 | 200 | PrintHeader(); |
829fb838 | 201 | } |
202 | ||
203 | //______________________________________________________________________________ | |
4aba9d66 | 204 | TFluka::~TFluka() |
205 | { | |
206 | // Destructor | |
1df5fa54 | 207 | if (fVerbosityLevel >=3) |
4aba9d66 | 208 | cout << "<== TFluka::~TFluka() destructor called." << endl; |
209 | if (fMaterials) delete [] fMaterials; | |
1df5fa54 | 210 | |
eac7af60 | 211 | // delete fGeom; |
212 | // delete fMCGeo; | |
1df5fa54 | 213 | |
fb2cbbec | 214 | if (fUserConfig) { |
4aba9d66 | 215 | fUserConfig->Delete(); |
216 | delete fUserConfig; | |
1df5fa54 | 217 | } |
6d184c54 | 218 | |
219 | if (fUserScore) { | |
4aba9d66 | 220 | fUserScore->Delete(); |
221 | delete fUserScore; | |
6d184c54 | 222 | } |
829fb838 | 223 | } |
224 | ||
225 | // | |
226 | //______________________________________________________________________________ | |
227 | // TFluka control methods | |
228 | //______________________________________________________________________________ | |
229 | void TFluka::Init() { | |
230 | // | |
231 | // Geometry initialisation | |
232 | // | |
233 | if (fVerbosityLevel >=3) cout << "==> TFluka::Init() called." << endl; | |
234 | ||
235 | if (!gGeoManager) new TGeoManager("geom", "FLUKA geometry"); | |
236 | fApplication->ConstructGeometry(); | |
d59acfe7 | 237 | if (!gGeoManager->IsClosed()) { |
238 | TGeoVolume *top = (TGeoVolume*)gGeoManager->GetListOfVolumes()->First(); | |
239 | gGeoManager->SetTopVolume(top); | |
240 | gGeoManager->CloseGeometry("di"); | |
241 | } else { | |
242 | TGeoNodeCache *cache = gGeoManager->GetCache(); | |
243 | if (!cache->HasIdArray()) { | |
a9ea1616 | 244 | Warning("Init", "Node ID tracking must be enabled with TFluka: enabling...\n"); |
d59acfe7 | 245 | cache->BuildIdArray(); |
246 | } | |
247 | } | |
829fb838 | 248 | fNVolumes = fGeom->NofVolumes(); |
249 | fGeom->CreateFlukaMatFile("flukaMat.inp"); | |
250 | if (fVerbosityLevel >=3) { | |
251 | printf("== Number of volumes: %i\n ==", fNVolumes); | |
252 | cout << "\t* InitPhysics() - Prepare input file to be called" << endl; | |
6d184c54 | 253 | } |
881cb248 | 254 | |
255 | fApplication->InitGeometry(); | |
661663fa | 256 | fApplication->ConstructOpGeometry(); |
78df7be0 | 257 | // |
258 | // Add ions to PDG Data base | |
259 | // | |
260 | AddParticlesToPdgDataBase(); | |
cee6a756 | 261 | // |
829fb838 | 262 | } |
263 | ||
264 | ||
265 | //______________________________________________________________________________ | |
266 | void TFluka::FinishGeometry() { | |
267 | // | |
268 | // Build-up table with region to medium correspondance | |
269 | // | |
270 | if (fVerbosityLevel >=3) { | |
271 | cout << "==> TFluka::FinishGeometry() called." << endl; | |
2753cb27 | 272 | printf("----FinishGeometry - applying misalignment if any\n"); |
829fb838 | 273 | cout << "<== TFluka::FinishGeometry() called." << endl; |
274 | } | |
2753cb27 | 275 | TVirtualMCApplication::Instance()->MisalignGeometry(); |
829fb838 | 276 | } |
277 | ||
278 | //______________________________________________________________________________ | |
279 | void TFluka::BuildPhysics() { | |
280 | // | |
281 | // Prepare FLUKA input files and call FLUKA physics initialisation | |
282 | // | |
283 | ||
284 | if (fVerbosityLevel >=3) | |
4aba9d66 | 285 | cout << "==> TFluka::BuildPhysics() called." << endl; |
6d184c54 | 286 | |
287 | ||
288 | if (fVerbosityLevel >=3) { | |
4aba9d66 | 289 | TList *medlist = gGeoManager->GetListOfMedia(); |
290 | TIter next(medlist); | |
291 | TGeoMedium* med = 0x0; | |
292 | TGeoMaterial* mat = 0x0; | |
293 | Int_t ic = 0; | |
294 | ||
295 | while((med = (TGeoMedium*)next())) | |
296 | { | |
297 | mat = med->GetMaterial(); | |
298 | printf("Medium %5d %12s %5d %5d\n", ic, (med->GetName()), med->GetId(), mat->GetIndex()); | |
299 | ic++; | |
300 | } | |
6d184c54 | 301 | } |
302 | ||
d23f4fcd | 303 | |
6d184c54 | 304 | // Prepare input file with the current physics settings |
305 | ||
829fb838 | 306 | InitPhysics(); |
b8a8a88c | 307 | // Open fortran files |
829fb838 | 308 | const char* fname = fInputFileName; |
309 | fluka_openinp(lunin, PASSCHARA(fname)); | |
8e5bf079 | 310 | fluka_openout(11, PASSCHARA("fluka.out")); |
b8a8a88c | 311 | // Read input cards |
4aba9d66 | 312 | cout << "==> TFluka::BuildPhysics() Read input cards." << endl; |
313 | TStopwatch timer; | |
314 | timer.Start(); | |
b8a8a88c | 315 | GLOBAL.lfdrtr = true; |
829fb838 | 316 | flukam(1); |
4aba9d66 | 317 | cout << "<== TFluka::BuildPhysics() Read input cards End" |
318 | << Form(" R:%.2fs C:%.2fs", timer.RealTime(),timer.CpuTime()) << endl; | |
b8a8a88c | 319 | // Close input file |
829fb838 | 320 | fluka_closeinp(lunin); |
b8a8a88c | 321 | // Finish geometry |
829fb838 | 322 | FinishGeometry(); |
829fb838 | 323 | } |
324 | ||
325 | //______________________________________________________________________________ | |
326 | void TFluka::ProcessEvent() { | |
327 | // | |
328 | // Process one event | |
329 | // | |
b496f27c | 330 | if (fStopRun) { |
4aba9d66 | 331 | Warning("ProcessEvent", "User Run Abortion: No more events handled !\n"); |
332 | fNEvent += 1; | |
333 | return; | |
b496f27c | 334 | } |
335 | ||
336 | if (fVerbosityLevel >=3) | |
4aba9d66 | 337 | cout << "==> TFluka::ProcessEvent() called." << endl; |
b496f27c | 338 | fApplication->GeneratePrimaries(); |
81f1d030 | 339 | SOURCM.lsouit = true; |
b496f27c | 340 | flukam(1); |
341 | if (fVerbosityLevel >=3) | |
4aba9d66 | 342 | cout << "<== TFluka::ProcessEvent() called." << endl; |
b496f27c | 343 | // |
344 | // Increase event number | |
345 | // | |
346 | fNEvent += 1; | |
829fb838 | 347 | } |
348 | ||
349 | //______________________________________________________________________________ | |
350 | Bool_t TFluka::ProcessRun(Int_t nevent) { | |
351 | // | |
352 | // Run steering | |
353 | // | |
4678abb9 | 354 | |
829fb838 | 355 | if (fVerbosityLevel >=3) |
356 | cout << "==> TFluka::ProcessRun(" << nevent << ") called." | |
4aba9d66 | 357 | << endl; |
829fb838 | 358 | |
359 | if (fVerbosityLevel >=2) { | |
360 | cout << "\t* GLOBAL.fdrtr = " << (GLOBAL.lfdrtr?'T':'F') << endl; | |
361 | cout << "\t* Calling flukam again..." << endl; | |
362 | } | |
363 | ||
829fb838 | 364 | Int_t todo = TMath::Abs(nevent); |
365 | for (Int_t ev = 0; ev < todo; ev++) { | |
4aba9d66 | 366 | TStopwatch timer; |
367 | timer.Start(); | |
829fb838 | 368 | fApplication->BeginEvent(); |
369 | ProcessEvent(); | |
370 | fApplication->FinishEvent(); | |
4aba9d66 | 371 | cout << "Event: "<< ev |
372 | << Form(" R:%.2fs C:%.2fs", timer.RealTime(),timer.CpuTime()) << endl; | |
829fb838 | 373 | } |
374 | ||
375 | if (fVerbosityLevel >=3) | |
376 | cout << "<== TFluka::ProcessRun(" << nevent << ") called." | |
4aba9d66 | 377 | << endl; |
378 | ||
eea53470 | 379 | // Write fluka specific scoring output |
4aba9d66 | 380 | genout(); |
eea53470 | 381 | newplo(); |
4aba9d66 | 382 | flkend(); |
eea53470 | 383 | |
829fb838 | 384 | return kTRUE; |
385 | } | |
386 | ||
387 | //_____________________________________________________________________________ | |
388 | // methods for building/management of geometry | |
389 | ||
390 | // functions from GCONS | |
391 | //____________________________________________________________________________ | |
392 | void TFluka::Gfmate(Int_t imat, char *name, Float_t &a, Float_t &z, | |
4aba9d66 | 393 | Float_t &dens, Float_t &radl, Float_t &absl, |
394 | Float_t* /*ubuf*/, Int_t& /*nbuf*/) { | |
829fb838 | 395 | // |
396 | TGeoMaterial *mat; | |
397 | TIter next (gGeoManager->GetListOfMaterials()); | |
398 | while ((mat = (TGeoMaterial*)next())) { | |
399 | if (mat->GetUniqueID() == (UInt_t)imat) break; | |
400 | } | |
401 | if (!mat) { | |
402 | Error("Gfmate", "no material with index %i found", imat); | |
403 | return; | |
404 | } | |
405 | sprintf(name, "%s", mat->GetName()); | |
406 | a = mat->GetA(); | |
407 | z = mat->GetZ(); | |
408 | dens = mat->GetDensity(); | |
409 | radl = mat->GetRadLen(); | |
410 | absl = mat->GetIntLen(); | |
411 | } | |
412 | ||
413 | //______________________________________________________________________________ | |
414 | void TFluka::Gfmate(Int_t imat, char *name, Double_t &a, Double_t &z, | |
4aba9d66 | 415 | Double_t &dens, Double_t &radl, Double_t &absl, |
416 | Double_t* /*ubuf*/, Int_t& /*nbuf*/) { | |
829fb838 | 417 | // |
418 | TGeoMaterial *mat; | |
419 | TIter next (gGeoManager->GetListOfMaterials()); | |
420 | while ((mat = (TGeoMaterial*)next())) { | |
421 | if (mat->GetUniqueID() == (UInt_t)imat) break; | |
422 | } | |
423 | if (!mat) { | |
424 | Error("Gfmate", "no material with index %i found", imat); | |
425 | return; | |
426 | } | |
427 | sprintf(name, "%s", mat->GetName()); | |
428 | a = mat->GetA(); | |
429 | z = mat->GetZ(); | |
430 | dens = mat->GetDensity(); | |
431 | radl = mat->GetRadLen(); | |
432 | absl = mat->GetIntLen(); | |
433 | } | |
434 | ||
435 | // detector composition | |
436 | //______________________________________________________________________________ | |
437 | void TFluka::Material(Int_t& kmat, const char* name, Double_t a, | |
4aba9d66 | 438 | Double_t z, Double_t dens, Double_t radl, Double_t absl, |
439 | Float_t* buf, Int_t nwbuf) { | |
829fb838 | 440 | // |
441 | Double_t* dbuf = fGeom->CreateDoubleArray(buf, nwbuf); | |
442 | Material(kmat, name, a, z, dens, radl, absl, dbuf, nwbuf); | |
443 | delete [] dbuf; | |
444 | } | |
445 | ||
446 | //______________________________________________________________________________ | |
447 | void TFluka::Material(Int_t& kmat, const char* name, Double_t a, | |
4aba9d66 | 448 | Double_t z, Double_t dens, Double_t radl, Double_t absl, |
449 | Double_t* /*buf*/, Int_t /*nwbuf*/) { | |
829fb838 | 450 | // |
fb2cbbec | 451 | // Define a material |
829fb838 | 452 | TGeoMaterial *mat; |
453 | kmat = gGeoManager->GetListOfMaterials()->GetSize(); | |
454 | if ((z-Int_t(z)) > 1E-3) { | |
455 | mat = fGeom->GetMakeWrongMaterial(z); | |
456 | if (mat) { | |
457 | mat->SetRadLen(radl,absl); | |
458 | mat->SetUniqueID(kmat); | |
459 | return; | |
460 | } | |
461 | } | |
462 | gGeoManager->Material(name, a, z, dens, kmat, radl, absl); | |
463 | } | |
464 | ||
465 | //______________________________________________________________________________ | |
466 | void TFluka::Mixture(Int_t& kmat, const char *name, Float_t *a, | |
4aba9d66 | 467 | Float_t *z, Double_t dens, Int_t nlmat, Float_t *wmat) { |
fb2cbbec | 468 | // |
469 | // Define a material mixture | |
829fb838 | 470 | // |
471 | Double_t* da = fGeom->CreateDoubleArray(a, TMath::Abs(nlmat)); | |
472 | Double_t* dz = fGeom->CreateDoubleArray(z, TMath::Abs(nlmat)); | |
473 | Double_t* dwmat = fGeom->CreateDoubleArray(wmat, TMath::Abs(nlmat)); | |
474 | ||
475 | Mixture(kmat, name, da, dz, dens, nlmat, dwmat); | |
476 | for (Int_t i=0; i<nlmat; i++) { | |
477 | a[i] = da[i]; z[i] = dz[i]; wmat[i] = dwmat[i]; | |
478 | } | |
479 | ||
480 | delete [] da; | |
481 | delete [] dz; | |
482 | delete [] dwmat; | |
483 | } | |
484 | ||
485 | //______________________________________________________________________________ | |
486 | void TFluka::Mixture(Int_t& kmat, const char *name, Double_t *a, | |
4aba9d66 | 487 | Double_t *z, Double_t dens, Int_t nlmat, Double_t *wmat) { |
829fb838 | 488 | // |
489 | // Defines mixture OR COMPOUND IMAT as composed by | |
490 | // THE BASIC NLMAT materials defined by arrays A,Z and WMAT | |
491 | // | |
492 | // If NLMAT > 0 then wmat contains the proportion by | |
493 | // weights of each basic material in the mixture. | |
494 | // | |
495 | // If nlmat < 0 then WMAT contains the number of atoms | |
496 | // of a given kind into the molecule of the COMPOUND | |
497 | // In this case, WMAT in output is changed to relative | |
498 | // weigths. | |
499 | // | |
500 | Int_t i,j; | |
501 | if (nlmat < 0) { | |
502 | nlmat = - nlmat; | |
503 | Double_t amol = 0; | |
504 | for (i=0;i<nlmat;i++) { | |
505 | amol += a[i]*wmat[i]; | |
506 | } | |
507 | for (i=0;i<nlmat;i++) { | |
508 | wmat[i] *= a[i]/amol; | |
509 | } | |
510 | } | |
511 | kmat = gGeoManager->GetListOfMaterials()->GetSize(); | |
512 | // Check if we have elements with fractional Z | |
513 | TGeoMaterial *mat = 0; | |
514 | TGeoMixture *mix = 0; | |
515 | Bool_t mixnew = kFALSE; | |
516 | for (i=0; i<nlmat; i++) { | |
517 | if (z[i]-Int_t(z[i]) < 1E-3) continue; | |
518 | // We have found an element with fractional Z -> loop mixtures to look for it | |
519 | for (j=0; j<kmat; j++) { | |
520 | mat = (TGeoMaterial*)gGeoManager->GetListOfMaterials()->At(j); | |
521 | if (!mat) break; | |
522 | if (!mat->IsMixture()) continue; | |
523 | mix = (TGeoMixture*)mat; | |
524 | if (TMath::Abs(z[i]-mix->GetZ()) >1E-3) continue; | |
829fb838 | 525 | mixnew = kTRUE; |
526 | break; | |
527 | } | |
528 | if (!mixnew) Warning("Mixture","%s : cannot find component %i with fractional Z=%f\n", name, i, z[i]); | |
529 | break; | |
530 | } | |
531 | if (mixnew) { | |
532 | Int_t nlmatnew = nlmat+mix->GetNelements()-1; | |
533 | Double_t *anew = new Double_t[nlmatnew]; | |
534 | Double_t *znew = new Double_t[nlmatnew]; | |
535 | Double_t *wmatnew = new Double_t[nlmatnew]; | |
536 | Int_t ind=0; | |
537 | for (j=0; j<nlmat; j++) { | |
538 | if (j==i) continue; | |
539 | anew[ind] = a[j]; | |
540 | znew[ind] = z[j]; | |
541 | wmatnew[ind] = wmat[j]; | |
542 | ind++; | |
543 | } | |
544 | for (j=0; j<mix->GetNelements(); j++) { | |
545 | anew[ind] = mix->GetAmixt()[j]; | |
546 | znew[ind] = mix->GetZmixt()[j]; | |
547 | wmatnew[ind] = wmat[i]*mix->GetWmixt()[j]; | |
548 | ind++; | |
549 | } | |
550 | Mixture(kmat, name, anew, znew, dens, nlmatnew, wmatnew); | |
551 | delete [] anew; | |
552 | delete [] znew; | |
553 | delete [] wmatnew; | |
554 | return; | |
555 | } | |
556 | // Now we need to compact identical elements within the mixture | |
557 | // First check if this happens | |
558 | mixnew = kFALSE; | |
559 | for (i=0; i<nlmat-1; i++) { | |
560 | for (j=i+1; j<nlmat; j++) { | |
561 | if (z[i] == z[j]) { | |
562 | mixnew = kTRUE; | |
563 | break; | |
564 | } | |
565 | } | |
566 | if (mixnew) break; | |
567 | } | |
568 | if (mixnew) { | |
569 | Int_t nlmatnew = 0; | |
570 | Double_t *anew = new Double_t[nlmat]; | |
571 | Double_t *znew = new Double_t[nlmat]; | |
572 | memset(znew, 0, nlmat*sizeof(Double_t)); | |
573 | Double_t *wmatnew = new Double_t[nlmat]; | |
574 | Bool_t skipi; | |
575 | for (i=0; i<nlmat; i++) { | |
576 | skipi = kFALSE; | |
577 | for (j=0; j<nlmatnew; j++) { | |
578 | if (z[i] == z[j]) { | |
579 | wmatnew[j] += wmat[i]; | |
580 | skipi = kTRUE; | |
581 | break; | |
582 | } | |
583 | } | |
584 | if (skipi) continue; | |
585 | anew[nlmatnew] = a[i]; | |
586 | znew[nlmatnew] = z[i]; | |
587 | wmatnew[nlmatnew] = wmat[i]; | |
588 | nlmatnew++; | |
589 | } | |
590 | Mixture(kmat, name, anew, znew, dens, nlmatnew, wmatnew); | |
591 | delete [] anew; | |
592 | delete [] znew; | |
593 | delete [] wmatnew; | |
594 | return; | |
595 | } | |
a8e4986c | 596 | gGeoManager->Mixture(name, a, z, dens, nlmat, wmat, kmat); |
829fb838 | 597 | } |
598 | ||
599 | //______________________________________________________________________________ | |
600 | void TFluka::Medium(Int_t& kmed, const char *name, Int_t nmat, | |
4aba9d66 | 601 | Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd, |
602 | Double_t stemax, Double_t deemax, Double_t epsil, | |
603 | Double_t stmin, Float_t* ubuf, Int_t nbuf) { | |
b2129742 | 604 | // Define a medium |
605 | // | |
829fb838 | 606 | kmed = gGeoManager->GetListOfMedia()->GetSize()+1; |
607 | fMCGeo->Medium(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax, | |
4aba9d66 | 608 | epsil, stmin, ubuf, nbuf); |
829fb838 | 609 | } |
610 | ||
611 | //______________________________________________________________________________ | |
612 | void TFluka::Medium(Int_t& kmed, const char *name, Int_t nmat, | |
4aba9d66 | 613 | Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd, |
614 | Double_t stemax, Double_t deemax, Double_t epsil, | |
615 | Double_t stmin, Double_t* ubuf, Int_t nbuf) { | |
b2129742 | 616 | // Define a medium |
617 | // | |
829fb838 | 618 | kmed = gGeoManager->GetListOfMedia()->GetSize()+1; |
619 | fMCGeo->Medium(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax, | |
4aba9d66 | 620 | epsil, stmin, ubuf, nbuf); |
829fb838 | 621 | } |
622 | ||
623 | //______________________________________________________________________________ | |
624 | void TFluka::Matrix(Int_t& krot, Double_t thetaX, Double_t phiX, | |
4aba9d66 | 625 | Double_t thetaY, Double_t phiY, Double_t thetaZ, |
626 | Double_t phiZ) { | |
627 | // | |
829fb838 | 628 | krot = gGeoManager->GetListOfMatrices()->GetEntriesFast(); |
629 | fMCGeo->Matrix(krot, thetaX, phiX, thetaY, phiY, thetaZ, phiZ); | |
630 | } | |
631 | ||
632 | //______________________________________________________________________________ | |
633 | void TFluka::Gstpar(Int_t itmed, const char* param, Double_t parval) { | |
634 | // | |
635 | // | |
7b203b6e | 636 | // |
829fb838 | 637 | Bool_t process = kFALSE; |
acf2e119 | 638 | Bool_t modelp = kFALSE; |
639 | ||
829fb838 | 640 | if (strncmp(param, "DCAY", 4) == 0 || |
641 | strncmp(param, "PAIR", 4) == 0 || | |
642 | strncmp(param, "COMP", 4) == 0 || | |
643 | strncmp(param, "PHOT", 4) == 0 || | |
644 | strncmp(param, "PFIS", 4) == 0 || | |
645 | strncmp(param, "DRAY", 4) == 0 || | |
646 | strncmp(param, "ANNI", 4) == 0 || | |
647 | strncmp(param, "BREM", 4) == 0 || | |
648 | strncmp(param, "MUNU", 4) == 0 || | |
649 | strncmp(param, "CKOV", 4) == 0 || | |
650 | strncmp(param, "HADR", 4) == 0 || | |
651 | strncmp(param, "LOSS", 4) == 0 || | |
652 | strncmp(param, "MULS", 4) == 0 || | |
695d8af9 | 653 | strncmp(param, "RAYL", 4) == 0 || |
654 | strncmp(param, "STRA", 4) == 0) | |
829fb838 | 655 | { |
656 | process = kTRUE; | |
657 | } | |
81f1d030 | 658 | |
acf2e119 | 659 | if (strncmp(param, "PRIMIO_N", 8) == 0 || |
660 | strncmp(param, "PRIMIO_E", 8) == 0) | |
661 | { | |
662 | modelp = kTRUE; | |
663 | } | |
664 | ||
829fb838 | 665 | if (process) { |
acf2e119 | 666 | // Process switch |
81f1d030 | 667 | SetProcess(param, Int_t (parval), itmed); |
acf2e119 | 668 | } else if (modelp) { |
669 | // Model parameters | |
670 | SetModelParameter(param, parval, itmed); | |
829fb838 | 671 | } else { |
acf2e119 | 672 | // Cuts |
81f1d030 | 673 | SetCut(param, parval, itmed); |
829fb838 | 674 | } |
acf2e119 | 675 | |
676 | ||
829fb838 | 677 | } |
678 | ||
679 | // functions from GGEOM | |
680 | //_____________________________________________________________________________ | |
681 | void TFluka::Gsatt(const char *name, const char *att, Int_t val) | |
682 | { | |
6f5667d1 | 683 | // Set visualisation attributes for one volume |
829fb838 | 684 | char vname[5]; |
685 | fGeom->Vname(name,vname); | |
686 | char vatt[5]; | |
687 | fGeom->Vname(att,vatt); | |
688 | gGeoManager->SetVolumeAttribute(vname, vatt, val); | |
689 | } | |
690 | ||
691 | //______________________________________________________________________________ | |
692 | Int_t TFluka::Gsvolu(const char *name, const char *shape, Int_t nmed, | |
4aba9d66 | 693 | Float_t *upar, Int_t np) { |
829fb838 | 694 | // |
695 | return fMCGeo->Gsvolu(name, shape, nmed, upar, np); | |
696 | } | |
697 | ||
698 | //______________________________________________________________________________ | |
699 | Int_t TFluka::Gsvolu(const char *name, const char *shape, Int_t nmed, | |
4aba9d66 | 700 | Double_t *upar, Int_t np) { |
829fb838 | 701 | // |
702 | return fMCGeo->Gsvolu(name, shape, nmed, upar, np); | |
703 | } | |
704 | ||
705 | //______________________________________________________________________________ | |
706 | void TFluka::Gsdvn(const char *name, const char *mother, Int_t ndiv, | |
4aba9d66 | 707 | Int_t iaxis) { |
829fb838 | 708 | // |
709 | fMCGeo->Gsdvn(name, mother, ndiv, iaxis); | |
710 | } | |
711 | ||
712 | //______________________________________________________________________________ | |
713 | void TFluka::Gsdvn2(const char *name, const char *mother, Int_t ndiv, | |
4aba9d66 | 714 | Int_t iaxis, Double_t c0i, Int_t numed) { |
829fb838 | 715 | // |
716 | fMCGeo->Gsdvn2(name, mother, ndiv, iaxis, c0i, numed); | |
717 | } | |
718 | ||
719 | //______________________________________________________________________________ | |
720 | void TFluka::Gsdvt(const char *name, const char *mother, Double_t step, | |
4aba9d66 | 721 | Int_t iaxis, Int_t numed, Int_t ndvmx) { |
722 | // | |
829fb838 | 723 | fMCGeo->Gsdvt(name, mother, step, iaxis, numed, ndvmx); |
724 | } | |
725 | ||
726 | //______________________________________________________________________________ | |
727 | void TFluka::Gsdvt2(const char *name, const char *mother, Double_t step, | |
4aba9d66 | 728 | Int_t iaxis, Double_t c0, Int_t numed, Int_t ndvmx) { |
829fb838 | 729 | // |
730 | fMCGeo->Gsdvt2(name, mother, step, iaxis, c0, numed, ndvmx); | |
731 | } | |
732 | ||
733 | //______________________________________________________________________________ | |
734 | void TFluka::Gsord(const char * /*name*/, Int_t /*iax*/) { | |
735 | // | |
736 | // Nothing to do with TGeo | |
737 | } | |
738 | ||
739 | //______________________________________________________________________________ | |
740 | void TFluka::Gspos(const char *name, Int_t nr, const char *mother, | |
4aba9d66 | 741 | Double_t x, Double_t y, Double_t z, Int_t irot, |
742 | const char *konly) { | |
829fb838 | 743 | // |
744 | fMCGeo->Gspos(name, nr, mother, x, y, z, irot, konly); | |
745 | } | |
746 | ||
747 | //______________________________________________________________________________ | |
748 | void TFluka::Gsposp(const char *name, Int_t nr, const char *mother, | |
4aba9d66 | 749 | Double_t x, Double_t y, Double_t z, Int_t irot, |
750 | const char *konly, Float_t *upar, Int_t np) { | |
829fb838 | 751 | // |
752 | fMCGeo->Gsposp(name, nr, mother, x, y, z, irot, konly, upar, np); | |
753 | } | |
754 | ||
755 | //______________________________________________________________________________ | |
756 | void TFluka::Gsposp(const char *name, Int_t nr, const char *mother, | |
4aba9d66 | 757 | Double_t x, Double_t y, Double_t z, Int_t irot, |
758 | const char *konly, Double_t *upar, Int_t np) { | |
829fb838 | 759 | // |
760 | fMCGeo->Gsposp(name, nr, mother, x, y, z, irot, konly, upar, np); | |
761 | } | |
762 | ||
763 | //______________________________________________________________________________ | |
764 | void TFluka::Gsbool(const char* /*onlyVolName*/, const char* /*manyVolName*/) { | |
765 | // | |
766 | // Nothing to do with TGeo | |
767 | } | |
768 | ||
a9ea1616 | 769 | //______________________________________________________________________ |
770 | Bool_t TFluka::GetTransformation(const TString &volumePath,TGeoHMatrix &mat) | |
771 | { | |
772 | // Returns the Transformation matrix between the volume specified | |
773 | // by the path volumePath and the Top or mater volume. The format | |
774 | // of the path volumePath is as follows (assuming ALIC is the Top volume) | |
775 | // "/ALIC_1/DDIP_1/S05I_2/S05H_1/S05G_3". Here ALIC is the top most | |
776 | // or master volume which has only 1 instance of. Of all of the daughter | |
777 | // volumes of ALICE, DDIP volume copy #1 is indicated. Similarly for | |
778 | // the daughter volume of DDIP is S05I copy #2 and so on. | |
779 | // Inputs: | |
780 | // TString& volumePath The volume path to the specific volume | |
781 | // for which you want the matrix. Volume name | |
782 | // hierarchy is separated by "/" while the | |
783 | // copy number is appended using a "_". | |
784 | // Outputs: | |
785 | // TGeoHMatrix &mat A matrix with its values set to those | |
786 | // appropriate to the Local to Master transformation | |
787 | // Return: | |
788 | // A logical value if kFALSE then an error occurred and no change to | |
789 | // mat was made. | |
790 | ||
791 | // We have to preserve the modeler state | |
792 | return fMCGeo->GetTransformation(volumePath, mat); | |
793 | } | |
794 | ||
795 | //______________________________________________________________________ | |
796 | Bool_t TFluka::GetShape(const TString &volumePath,TString &shapeType, | |
797 | TArrayD &par) | |
798 | { | |
799 | // Returns the shape and its parameters for the volume specified | |
800 | // by volumeName. | |
801 | // Inputs: | |
802 | // TString& volumeName The volume name | |
803 | // Outputs: | |
804 | // TString &shapeType Shape type | |
805 | // TArrayD &par A TArrayD of parameters with all of the | |
806 | // parameters of the specified shape. | |
807 | // Return: | |
808 | // A logical indicating whether there was an error in getting this | |
809 | // information | |
810 | return fMCGeo->GetShape(volumePath, shapeType, par); | |
811 | } | |
812 | ||
813 | //______________________________________________________________________ | |
814 | Bool_t TFluka::GetMaterial(const TString &volumeName, | |
815 | TString &name,Int_t &imat, | |
816 | Double_t &a,Double_t &z,Double_t &dens, | |
817 | Double_t &radl,Double_t &inter,TArrayD &par) | |
818 | { | |
819 | // Returns the Material and its parameters for the volume specified | |
820 | // by volumeName. | |
821 | // Note, Geant3 stores and uses mixtures as an element with an effective | |
822 | // Z and A. Consequently, if the parameter Z is not integer, then | |
823 | // this material represents some sort of mixture. | |
824 | // Inputs: | |
825 | // TString& volumeName The volume name | |
826 | // Outputs: | |
827 | // TSrting &name Material name | |
828 | // Int_t &imat Material index number | |
829 | // Double_t &a Average Atomic mass of material | |
830 | // Double_t &z Average Atomic number of material | |
831 | // Double_t &dens Density of material [g/cm^3] | |
832 | // Double_t &radl Average radiation length of material [cm] | |
833 | // Double_t &inter Average interaction length of material [cm] | |
834 | // TArrayD &par A TArrayD of user defined parameters. | |
835 | // Return: | |
836 | // kTRUE if no errors | |
837 | return fMCGeo->GetMaterial(volumeName,name,imat,a,z,dens,radl,inter,par); | |
838 | } | |
839 | ||
840 | //______________________________________________________________________ | |
841 | Bool_t TFluka::GetMedium(const TString &volumeName,TString &name, | |
842 | Int_t &imed,Int_t &nmat,Int_t &isvol,Int_t &ifield, | |
843 | Double_t &fieldm,Double_t &tmaxfd,Double_t &stemax, | |
844 | Double_t &deemax,Double_t &epsil, Double_t &stmin, | |
845 | TArrayD &par) | |
846 | { | |
847 | // Returns the Medium and its parameters for the volume specified | |
848 | // by volumeName. | |
849 | // Inputs: | |
850 | // TString& volumeName The volume name. | |
851 | // Outputs: | |
852 | // TString &name Medium name | |
853 | // Int_t &nmat Material number defined for this medium | |
854 | // Int_t &imed The medium index number | |
855 | // Int_t &isvol volume number defined for this medium | |
856 | // Int_t &iflield Magnetic field flag | |
857 | // Double_t &fieldm Magnetic field strength | |
858 | // Double_t &tmaxfd Maximum angle of deflection per step | |
859 | // Double_t &stemax Maximum step size | |
860 | // Double_t &deemax Maximum fraction of energy allowed to be lost | |
861 | // to continuous process. | |
862 | // Double_t &epsil Boundary crossing precision | |
863 | // Double_t &stmin Minimum step size allowed | |
864 | // TArrayD &par A TArrayD of user parameters with all of the | |
865 | // parameters of the specified medium. | |
866 | // Return: | |
867 | // kTRUE if there where no errors | |
868 | return fMCGeo->GetMedium(volumeName,name,imed,nmat,isvol,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin,par); | |
869 | } | |
870 | ||
829fb838 | 871 | //______________________________________________________________________________ |
872 | void TFluka::SetCerenkov(Int_t itmed, Int_t npckov, Float_t* ppckov, | |
4aba9d66 | 873 | Float_t* absco, Float_t* effic, Float_t* rindex) { |
829fb838 | 874 | // |
875 | // Set Cerenkov properties for medium itmed | |
876 | // | |
877 | // npckov: number of sampling points | |
878 | // ppckov: energy values | |
879 | // absco: absorption length | |
880 | // effic: quantum efficiency | |
881 | // rindex: refraction index | |
882 | // | |
883 | // | |
884 | // | |
885 | // Create object holding Cerenkov properties | |
b6a89226 | 886 | // |
887 | ||
829fb838 | 888 | TFlukaCerenkov* cerenkovProperties = new TFlukaCerenkov(npckov, ppckov, absco, effic, rindex); |
889 | // | |
890 | // Pass object to medium | |
891 | TGeoMedium* medium = gGeoManager->GetMedium(itmed); | |
892 | medium->SetCerenkovProperties(cerenkovProperties); | |
893 | } | |
894 | ||
b2be0e73 | 895 | void TFluka::SetCerenkov(Int_t itmed, Int_t npckov, Float_t* ppckov, |
4aba9d66 | 896 | Float_t* absco, Float_t* effic, Float_t* rindex, Float_t* rfl) { |
b2be0e73 | 897 | // |
898 | // Set Cerenkov properties for medium itmed | |
899 | // | |
900 | // npckov: number of sampling points | |
901 | // ppckov: energy values | |
902 | // absco: absorption length | |
903 | // effic: quantum efficiency | |
904 | // rindex: refraction index | |
905 | // rfl: reflectivity for boundary to medium itmed | |
906 | // | |
907 | // | |
908 | // Create object holding Cerenkov properties | |
909 | // | |
910 | TFlukaCerenkov* cerenkovProperties = new TFlukaCerenkov(npckov, ppckov, absco, effic, rindex, rfl); | |
911 | // | |
912 | // Pass object to medium | |
913 | TGeoMedium* medium = gGeoManager->GetMedium(itmed); | |
914 | medium->SetCerenkovProperties(cerenkovProperties); | |
915 | } | |
916 | ||
917 | ||
829fb838 | 918 | //______________________________________________________________________________ |
b6a89226 | 919 | void TFluka::SetCerenkov(Int_t itmed, Int_t npckov, Double_t *ppckov, |
920 | Double_t *absco, Double_t *effic, Double_t *rindex) { | |
921 | // | |
922 | // Set Cerenkov properties for medium itmed | |
829fb838 | 923 | // |
b6a89226 | 924 | // npckov: number of sampling points |
925 | // ppckov: energy values | |
926 | // absco: absorption length | |
927 | // effic: quantum efficiency | |
928 | // rindex: refraction index | |
929 | // | |
930 | ||
931 | // | |
932 | // Double_t version | |
933 | Float_t* fppckov = CreateFloatArray(ppckov, npckov); | |
934 | Float_t* fabsco = CreateFloatArray(absco, npckov); | |
935 | Float_t* feffic = CreateFloatArray(effic, npckov); | |
936 | Float_t* frindex = CreateFloatArray(rindex, npckov); | |
937 | ||
938 | SetCerenkov(itmed, npckov, fppckov, fabsco, feffic, frindex); | |
939 | ||
940 | delete [] fppckov; | |
941 | delete [] fabsco; | |
942 | delete [] feffic; | |
943 | delete [] frindex; | |
829fb838 | 944 | } |
b2be0e73 | 945 | |
b6a89226 | 946 | void TFluka::SetCerenkov(Int_t itmed, Int_t npckov, Double_t* ppckov, |
947 | Double_t* absco, Double_t* effic, Double_t* rindex, Double_t* rfl) { | |
b2be0e73 | 948 | // |
b6a89226 | 949 | // Set Cerenkov properties for medium itmed |
950 | // | |
951 | // npckov: number of sampling points | |
952 | // ppckov: energy values | |
953 | // absco: absorption length | |
954 | // effic: quantum efficiency | |
955 | // rindex: refraction index | |
956 | // rfl: reflectivity for boundary to medium itmed | |
957 | // | |
958 | ||
959 | // | |
960 | // // Double_t version | |
961 | Float_t* fppckov = CreateFloatArray(ppckov, npckov); | |
962 | Float_t* fabsco = CreateFloatArray(absco, npckov); | |
963 | Float_t* feffic = CreateFloatArray(effic, npckov); | |
964 | Float_t* frindex = CreateFloatArray(rindex, npckov); | |
965 | Float_t* frfl = CreateFloatArray(rfl, npckov); | |
966 | ||
967 | SetCerenkov(itmed, npckov, fppckov, fabsco, feffic, frindex, frfl); | |
968 | ||
969 | delete [] fppckov; | |
970 | delete [] fabsco; | |
971 | delete [] feffic; | |
972 | delete [] frindex; | |
973 | delete [] frfl; | |
b2be0e73 | 974 | } |
975 | ||
829fb838 | 976 | // Euclid |
977 | //______________________________________________________________________________ | |
978 | void TFluka::WriteEuclid(const char* /*fileName*/, const char* /*topVol*/, | |
979 | Int_t /*number*/, Int_t /*nlevel*/) { | |
980 | // | |
981 | // Not with TGeo | |
a9ea1616 | 982 | Warning("WriteEuclid", "Not implemented !"); |
829fb838 | 983 | } |
984 | ||
985 | ||
986 | ||
987 | //_____________________________________________________________________________ | |
988 | // methods needed by the stepping | |
989 | //____________________________________________________________________________ | |
990 | ||
991 | Int_t TFluka::GetMedium() const { | |
992 | // | |
993 | // Get the medium number for the current fluka region | |
994 | // | |
ab2afdda | 995 | if (gGeoManager->IsOutside()) { |
996 | return (-1); | |
997 | } else { | |
998 | return (fGeom->GetMedium()); // this I need to check due to remapping !!! | |
999 | } | |
829fb838 | 1000 | } |
1001 | ||
a9ea1616 | 1002 | //____________________________________________________________________________ |
1003 | Int_t TFluka::GetDummyRegion() const | |
1004 | { | |
1005 | // Returns index of the dummy region. | |
1006 | return fGeom->GetDummyRegion(); | |
1007 | } | |
829fb838 | 1008 | |
a9ea1616 | 1009 | //____________________________________________________________________________ |
1010 | Int_t TFluka::GetDummyLattice() const | |
1011 | { | |
1012 | // Returns index of the dummy lattice. | |
1013 | return fGeom->GetDummyLattice(); | |
1014 | } | |
829fb838 | 1015 | |
1016 | //____________________________________________________________________________ | |
1017 | // particle table usage | |
1018 | // ID <--> PDG transformations | |
1019 | //_____________________________________________________________________________ | |
1020 | Int_t TFluka::IdFromPDG(Int_t pdg) const | |
1021 | { | |
1022 | // | |
1023 | // Return Fluka code from PDG and pseudo ENDF code | |
1024 | ||
1025 | // Catch the feedback photons | |
a9ea1616 | 1026 | if (pdg == 50000051) return (kFLUKAoptical); |
829fb838 | 1027 | // MCIHAD() goes from pdg to fluka internal. |
1028 | Int_t intfluka = mcihad(pdg); | |
1029 | // KPTOIP array goes from internal to official | |
1030 | return GetFlukaKPTOIP(intfluka); | |
1031 | } | |
1032 | ||
1033 | //______________________________________________________________________________ | |
1034 | Int_t TFluka::PDGFromId(Int_t id) const | |
1035 | { | |
1036 | // | |
1037 | // Return PDG code and pseudo ENDF code from Fluka code | |
f926898e | 1038 | // Alpha He3 Triton Deuteron gen. ion opt. photon |
13858fbd | 1039 | Int_t idSpecial[6] = {GetIonPdg(2,4), GetIonPdg(2, 3), GetIonPdg(1,3), GetIonPdg(1,2), GetIonPdg(0,0), 50000050}; |
829fb838 | 1040 | // IPTOKP array goes from official to internal |
1041 | ||
a9ea1616 | 1042 | if (id == kFLUKAoptical) { |
829fb838 | 1043 | // Cerenkov photon |
4aba9d66 | 1044 | // if (fVerbosityLevel >= 3) |
1045 | // printf("\n PDGFromId: Cerenkov Photon \n"); | |
1046 | return 50000050; | |
829fb838 | 1047 | } |
1048 | // Error id | |
ece92b30 | 1049 | if (id == 0 || id < kFLUKAcodemin || id > kFLUKAcodemax) { |
66e5eb54 | 1050 | if (fVerbosityLevel >= 3) |
a9923346 | 1051 | printf("PDGFromId: Error id = 0 %5d %5d\n", id, fCaller); |
4aba9d66 | 1052 | return -1; |
829fb838 | 1053 | } |
1054 | // Good id | |
f926898e | 1055 | if (id > 0) { |
4aba9d66 | 1056 | Int_t intfluka = GetFlukaIPTOKP(id); |
1057 | if (intfluka == 0) { | |
1058 | if (fVerbosityLevel >= 3) | |
1059 | printf("PDGFromId: Error intfluka = 0: %d\n", id); | |
1060 | return -1; | |
1061 | } else if (intfluka < 0) { | |
1062 | if (fVerbosityLevel >= 3) | |
1063 | printf("PDGFromId: Error intfluka < 0: %d\n", id); | |
1064 | return -1; | |
1065 | } | |
1066 | // if (fVerbosityLevel >= 3) | |
1067 | // printf("mpdgha called with %d %d \n", id, intfluka); | |
1068 | return mpdgha(intfluka); | |
f926898e | 1069 | } else { |
4aba9d66 | 1070 | // ions and optical photons |
1071 | return idSpecial[id - kFLUKAcodemin]; | |
829fb838 | 1072 | } |
829fb838 | 1073 | } |
1074 | ||
bd3d5c8a | 1075 | void TFluka::StopTrack() |
1076 | { | |
1077 | // Set stopping conditions | |
1078 | // Works for photons and charged particles | |
1079 | fStopped = kTRUE; | |
1080 | } | |
1081 | ||
829fb838 | 1082 | //_____________________________________________________________________________ |
1083 | // methods for physics management | |
1084 | //____________________________________________________________________________ | |
1085 | // | |
1086 | // set methods | |
1087 | // | |
1088 | ||
1df5fa54 | 1089 | void TFluka::SetProcess(const char* flagName, Int_t flagValue, Int_t imed) |
829fb838 | 1090 | { |
1091 | // Set process user flag for material imat | |
1df5fa54 | 1092 | // |
1093 | // | |
1094 | // Update if already in the list | |
829fb838 | 1095 | // |
fb2cbbec | 1096 | TIter next(fUserConfig); |
1df5fa54 | 1097 | TFlukaConfigOption* proc; |
1098 | while((proc = (TFlukaConfigOption*)next())) | |
1099 | { | |
4aba9d66 | 1100 | if (proc->Medium() == imed) { |
1101 | proc->SetProcess(flagName, flagValue); | |
1102 | return; | |
1103 | } | |
1df5fa54 | 1104 | } |
fb2cbbec | 1105 | proc = new TFlukaConfigOption(imed); |
1106 | proc->SetProcess(flagName, flagValue); | |
1107 | fUserConfig->Add(proc); | |
1108 | } | |
1109 | ||
1110 | //______________________________________________________________________________ | |
1111 | Bool_t TFluka::SetProcess(const char* flagName, Int_t flagValue) | |
1112 | { | |
1113 | // Set process user flag | |
1df5fa54 | 1114 | // |
1df5fa54 | 1115 | // |
fb2cbbec | 1116 | SetProcess(flagName, flagValue, -1); |
1df5fa54 | 1117 | return kTRUE; |
829fb838 | 1118 | } |
1119 | ||
1120 | //______________________________________________________________________________ | |
1121 | void TFluka::SetCut(const char* cutName, Double_t cutValue, Int_t imed) | |
1122 | { | |
1123 | // Set user cut value for material imed | |
1124 | // | |
fb2cbbec | 1125 | TIter next(fUserConfig); |
1126 | TFlukaConfigOption* proc; | |
1127 | while((proc = (TFlukaConfigOption*)next())) | |
1128 | { | |
4aba9d66 | 1129 | if (proc->Medium() == imed) { |
1130 | proc->SetCut(cutName, cutValue); | |
1131 | return; | |
1132 | } | |
fb2cbbec | 1133 | } |
1134 | ||
1135 | proc = new TFlukaConfigOption(imed); | |
1136 | proc->SetCut(cutName, cutValue); | |
1137 | fUserConfig->Add(proc); | |
829fb838 | 1138 | } |
1139 | ||
acf2e119 | 1140 | |
1141 | //______________________________________________________________________________ | |
1142 | void TFluka::SetModelParameter(const char* parName, Double_t parValue, Int_t imed) | |
1143 | { | |
1144 | // Set model parameter for material imed | |
1145 | // | |
1146 | TIter next(fUserConfig); | |
1147 | TFlukaConfigOption* proc; | |
1148 | while((proc = (TFlukaConfigOption*)next())) | |
1149 | { | |
4aba9d66 | 1150 | if (proc->Medium() == imed) { |
1151 | proc->SetModelParameter(parName, parValue); | |
1152 | return; | |
1153 | } | |
acf2e119 | 1154 | } |
1155 | ||
1156 | proc = new TFlukaConfigOption(imed); | |
1157 | proc->SetModelParameter(parName, parValue); | |
1158 | fUserConfig->Add(proc); | |
1159 | } | |
1160 | ||
829fb838 | 1161 | //______________________________________________________________________________ |
1162 | Bool_t TFluka::SetCut(const char* cutName, Double_t cutValue) | |
1163 | { | |
1164 | // Set user cut value | |
1165 | // | |
1df5fa54 | 1166 | // |
fb2cbbec | 1167 | SetCut(cutName, cutValue, -1); |
1168 | return kTRUE; | |
829fb838 | 1169 | } |
1170 | ||
f450e9d0 | 1171 | |
6f1aaa8e | 1172 | void TFluka::SetUserScoring(const char* option, const char* sdum, Int_t npr, char* outfile, Float_t* what) |
b496f27c | 1173 | { |
1174 | // | |
f450e9d0 | 1175 | // Adds a user scoring option to the list |
b496f27c | 1176 | // |
6f1aaa8e | 1177 | TFlukaScoringOption* opt = new TFlukaScoringOption(option, sdum, npr,outfile,what); |
f450e9d0 | 1178 | fUserScore->Add(opt); |
1179 | } | |
1180 | //______________________________________________________________________________ | |
6f1aaa8e | 1181 | void TFluka::SetUserScoring(const char* option, const char* sdum, Int_t npr, char* outfile, Float_t* what, |
1182 | const char* det1, const char* det2, const char* det3) | |
f450e9d0 | 1183 | { |
1184 | // | |
1185 | // Adds a user scoring option to the list | |
1186 | // | |
6f1aaa8e | 1187 | TFlukaScoringOption* opt = new TFlukaScoringOption(option, sdum, npr, outfile, what, det1, det2, det3); |
b496f27c | 1188 | fUserScore->Add(opt); |
1189 | } | |
b496f27c | 1190 | |
829fb838 | 1191 | //______________________________________________________________________________ |
1192 | Double_t TFluka::Xsec(char*, Double_t, Int_t, Int_t) | |
1193 | { | |
a9ea1616 | 1194 | Warning("Xsec", "Not yet implemented.!\n"); return -1.; |
829fb838 | 1195 | } |
1196 | ||
1197 | ||
1198 | //______________________________________________________________________________ | |
1199 | void TFluka::InitPhysics() | |
1200 | { | |
1201 | // | |
1202 | // Physics initialisation with preparation of FLUKA input cards | |
1203 | // | |
fb2cbbec | 1204 | // Construct file names |
1205 | FILE *pFlukaVmcCoreInp, *pFlukaVmcFlukaMat, *pFlukaVmcInp; | |
fb2cbbec | 1206 | TString sFlukaVmcTmp = "flukaMat.inp"; |
1207 | TString sFlukaVmcInp = GetInputFileName(); | |
ff2d1491 | 1208 | TString sFlukaVmcCoreInp = GetCoreInputFileName(); |
fb2cbbec | 1209 | |
1210 | // Open files | |
1211 | if ((pFlukaVmcCoreInp = fopen(sFlukaVmcCoreInp.Data(),"r")) == NULL) { | |
4aba9d66 | 1212 | Warning("InitPhysics", "\nCannot open file %s\n",sFlukaVmcCoreInp.Data()); |
1213 | exit(1); | |
fb2cbbec | 1214 | } |
1215 | if ((pFlukaVmcFlukaMat = fopen(sFlukaVmcTmp.Data(),"r")) == NULL) { | |
4aba9d66 | 1216 | Warning("InitPhysics", "\nCannot open file %s\n",sFlukaVmcTmp.Data()); |
1217 | exit(1); | |
fb2cbbec | 1218 | } |
1219 | if ((pFlukaVmcInp = fopen(sFlukaVmcInp.Data(),"w")) == NULL) { | |
4aba9d66 | 1220 | Warning("InitPhysics", "\nCannot open file %s\n",sFlukaVmcInp.Data()); |
1221 | exit(1); | |
fb2cbbec | 1222 | } |
829fb838 | 1223 | |
fb2cbbec | 1224 | // Copy core input file |
1225 | Char_t sLine[255]; | |
1226 | Float_t fEventsPerRun; | |
829fb838 | 1227 | |
fb2cbbec | 1228 | while ((fgets(sLine,255,pFlukaVmcCoreInp)) != NULL) { |
4aba9d66 | 1229 | if (strncmp(sLine,"GEOEND",6) != 0) |
1230 | fprintf(pFlukaVmcInp,"%s",sLine); // copy until GEOEND card | |
1231 | else { | |
1232 | fprintf(pFlukaVmcInp,"GEOEND\n"); // add GEOEND card | |
1233 | goto flukamat; | |
1234 | } | |
fb2cbbec | 1235 | } // end of while until GEOEND card |
1236 | ||
829fb838 | 1237 | |
fb2cbbec | 1238 | flukamat: |
1239 | while ((fgets(sLine,255,pFlukaVmcFlukaMat)) != NULL) { // copy flukaMat.inp file | |
4aba9d66 | 1240 | fprintf(pFlukaVmcInp,"%s\n",sLine); |
fb2cbbec | 1241 | } |
1242 | ||
1243 | while ((fgets(sLine,255,pFlukaVmcCoreInp)) != NULL) { | |
8fc475a1 | 1244 | if (strncmp(sLine,"START",5) != 0) |
4aba9d66 | 1245 | fprintf(pFlukaVmcInp,"%s\n",sLine); |
1246 | else { | |
1247 | sscanf(sLine+10,"%10f",&fEventsPerRun); | |
1248 | goto fin; | |
1249 | } | |
8fc475a1 | 1250 | } //end of while until START card |
fb2cbbec | 1251 | |
1252 | fin: | |
829fb838 | 1253 | |
f450e9d0 | 1254 | |
1255 | // Pass information to configuration objects | |
829fb838 | 1256 | |
fb2cbbec | 1257 | Float_t fLastMaterial = fGeom->GetLastMaterialIndex(); |
1258 | TFlukaConfigOption::SetStaticInfo(pFlukaVmcInp, 3, fLastMaterial, fGeom); | |
1259 | ||
1260 | TIter next(fUserConfig); | |
1261 | TFlukaConfigOption* proc; | |
f450e9d0 | 1262 | while((proc = dynamic_cast<TFlukaConfigOption*> (next()))) proc->WriteFlukaInputCards(); |
1263 | // | |
1264 | // Process Fluka specific scoring options | |
1265 | // | |
1266 | TFlukaScoringOption::SetStaticInfo(pFlukaVmcInp, fGeom); | |
0bb2c369 | 1267 | Float_t loginp = -49.0; |
f450e9d0 | 1268 | Int_t inp = 0; |
1269 | Int_t nscore = fUserScore->GetEntries(); | |
1270 | ||
a9ea1616 | 1271 | TFlukaScoringOption *mopo = 0; |
1272 | TFlukaScoringOption *mopi = 0; | |
fb2cbbec | 1273 | |
f450e9d0 | 1274 | for (Int_t isc = 0; isc < nscore; isc++) |
1275 | { | |
4aba9d66 | 1276 | mopo = dynamic_cast<TFlukaScoringOption*> (fUserScore->At(isc)); |
1277 | char* fileName = mopo->GetFileName(); | |
1278 | Int_t size = strlen(fileName); | |
1279 | Float_t lun = -1.; | |
f450e9d0 | 1280 | // |
1281 | // Check if new output file has to be opened | |
4aba9d66 | 1282 | for (Int_t isci = 0; isci < isc; isci++) { |
1283 | ||
1284 | ||
1285 | mopi = dynamic_cast<TFlukaScoringOption*> (fUserScore->At(isci)); | |
1286 | if(strncmp(mopi->GetFileName(), fileName, size)==0) { | |
1287 | // | |
1288 | // No, the file already exists | |
1289 | lun = mopi->GetLun(); | |
1290 | mopo->SetLun(lun); | |
1291 | break; | |
1292 | } | |
1293 | } // inner loop | |
1294 | ||
1295 | if (lun == -1.) { | |
1296 | // Open new output file | |
1297 | inp++; | |
1298 | mopo->SetLun(loginp + inp); | |
1299 | mopo->WriteOpenFlukaFile(); | |
1300 | } | |
1301 | mopo->WriteFlukaInputCards(); | |
f450e9d0 | 1302 | } |
b8a8a88c | 1303 | |
1304 | // Add RANDOMIZ card | |
1305 | fprintf(pFlukaVmcInp,"RANDOMIZ %10.1f%10.0f\n", 1., Float_t(gRandom->GetSeed())); | |
8fc475a1 | 1306 | // Add START and STOP card |
1307 | fprintf(pFlukaVmcInp,"START %10.1f\n",fEventsPerRun); | |
f450e9d0 | 1308 | fprintf(pFlukaVmcInp,"STOP \n"); |
829fb838 | 1309 | |
1310 | ||
1311 | // Close files | |
3b8c325d | 1312 | fclose(pFlukaVmcCoreInp); |
1313 | fclose(pFlukaVmcFlukaMat); | |
1314 | fclose(pFlukaVmcInp); | |
fb2cbbec | 1315 | |
1316 | ||
1317 | // | |
1318 | // Initialisation needed for Cerenkov photon production and transport | |
1319 | TObjArray *matList = GetFlukaMaterials(); | |
1320 | Int_t nmaterial = matList->GetEntriesFast(); | |
9968e86c | 1321 | fMaterials = new Int_t[nmaterial+25]; |
fb2cbbec | 1322 | |
1323 | for (Int_t im = 0; im < nmaterial; im++) | |
1324 | { | |
4aba9d66 | 1325 | TGeoMaterial* material = dynamic_cast<TGeoMaterial*> (matList->At(im)); |
1326 | Int_t idmat = material->GetIndex(); | |
1327 | fMaterials[idmat] = im; | |
fb2cbbec | 1328 | } |
829fb838 | 1329 | } // end of InitPhysics |
1330 | ||
1331 | ||
1332 | //______________________________________________________________________________ | |
07f5b33e | 1333 | void TFluka::SetMaxStep(Double_t step) |
829fb838 | 1334 | { |
07f5b33e | 1335 | // Set the maximum step size |
4aba9d66 | 1336 | // if (step > 1.e4) return; |
07f5b33e | 1337 | |
4aba9d66 | 1338 | // Int_t mreg=0, latt=0; |
1339 | // fGeom->GetCurrentRegion(mreg, latt); | |
ff2d1491 | 1340 | |
1341 | ||
4aba9d66 | 1342 | Int_t mreg = fGeom->GetCurrentRegion(); |
9c0c08ce | 1343 | STEPSZ.stepmx[mreg - 1] = step; |
829fb838 | 1344 | } |
1345 | ||
2f09b80e | 1346 | |
1347 | Double_t TFluka::MaxStep() const | |
1348 | { | |
1349 | // Return the maximum for current medium | |
1350 | Int_t mreg, latt; | |
1351 | fGeom->GetCurrentRegion(mreg, latt); | |
1352 | return (STEPSZ.stepmx[mreg - 1]); | |
1353 | } | |
1354 | ||
829fb838 | 1355 | //______________________________________________________________________________ |
1356 | void TFluka::SetMaxNStep(Int_t) | |
1357 | { | |
1358 | // SetMaxNStep is dummy procedure in TFluka ! | |
1359 | if (fVerbosityLevel >=3) | |
1360 | cout << "SetMaxNStep is dummy procedure in TFluka !" << endl; | |
1361 | } | |
1362 | ||
1363 | //______________________________________________________________________________ | |
1364 | void TFluka::SetUserDecay(Int_t) | |
1365 | { | |
1366 | // SetUserDecay is dummy procedure in TFluka ! | |
1367 | if (fVerbosityLevel >=3) | |
1368 | cout << "SetUserDecay is dummy procedure in TFluka !" << endl; | |
1369 | } | |
1370 | ||
1371 | // | |
1372 | // dynamic properties | |
1373 | // | |
1374 | //______________________________________________________________________________ | |
1375 | void TFluka::TrackPosition(TLorentzVector& position) const | |
1376 | { | |
1377 | // Return the current position in the master reference frame of the | |
1378 | // track being transported | |
1379 | // TRACKR.atrack = age of the particle | |
1380 | // TRACKR.xtrack = x-position of the last point | |
1381 | // TRACKR.ytrack = y-position of the last point | |
1382 | // TRACKR.ztrack = z-position of the last point | |
a9ea1616 | 1383 | FlukaCallerCode_t caller = GetCaller(); |
1384 | if (caller == kENDRAW || caller == kUSDRAW || | |
1385 | caller == kBXExiting || caller == kBXEntering || | |
1386 | caller == kUSTCKV) { | |
42b936d1 | 1387 | position.SetX(GetXsco()); |
1388 | position.SetY(GetYsco()); | |
1389 | position.SetZ(GetZsco()); | |
1390 | position.SetT(TRACKR.atrack); | |
829fb838 | 1391 | } |
5125d6e5 | 1392 | else if (caller == kMGDRAW) { |
1393 | Int_t i = -1; | |
1394 | if ((i = fPrimaryElectronIndex) > -1) { | |
1395 | // Primary Electron Ionisation | |
15a8a899 | 1396 | Double_t x, y, z, t; |
1397 | GetPrimaryElectronPosition(i, x, y, z, t); | |
5125d6e5 | 1398 | position.SetX(x); |
1399 | position.SetY(y); | |
1400 | position.SetZ(z); | |
15a8a899 | 1401 | position.SetT(t); |
5125d6e5 | 1402 | } else { |
1403 | position.SetX(TRACKR.xtrack[TRACKR.ntrack]); | |
1404 | position.SetY(TRACKR.ytrack[TRACKR.ntrack]); | |
1405 | position.SetZ(TRACKR.ztrack[TRACKR.ntrack]); | |
1406 | position.SetT(TRACKR.atrack); | |
1407 | } | |
829fb838 | 1408 | } |
a9ea1616 | 1409 | else if (caller == kSODRAW) { |
42b936d1 | 1410 | Int_t ist = FLKSTK.npflka; |
1411 | position.SetX(FLKSTK.xflk[ist]); | |
1412 | position.SetY(FLKSTK.yflk[ist]); | |
1413 | position.SetZ(FLKSTK.zflk[ist]); | |
1414 | position.SetT(FLKSTK.agestk[ist]); | |
a9ea1616 | 1415 | } else if (caller == kMGResumedTrack) { |
42b936d1 | 1416 | position.SetX(TRACKR.spausr[0]); |
1417 | position.SetY(TRACKR.spausr[1]); | |
1418 | position.SetZ(TRACKR.spausr[2]); | |
1419 | position.SetT(TRACKR.spausr[3]); | |
829fb838 | 1420 | } |
1421 | else | |
42b936d1 | 1422 | Warning("TrackPosition","position not available"); |
829fb838 | 1423 | } |
1424 | ||
1425 | //______________________________________________________________________________ | |
1426 | void TFluka::TrackPosition(Double_t& x, Double_t& y, Double_t& z) const | |
1427 | { | |
1428 | // Return the current position in the master reference frame of the | |
1429 | // track being transported | |
1430 | // TRACKR.atrack = age of the particle | |
1431 | // TRACKR.xtrack = x-position of the last point | |
1432 | // TRACKR.ytrack = y-position of the last point | |
1433 | // TRACKR.ztrack = z-position of the last point | |
a9ea1616 | 1434 | FlukaCallerCode_t caller = GetCaller(); |
1435 | if (caller == kENDRAW || caller == kUSDRAW || | |
1436 | caller == kBXExiting || caller == kBXEntering || | |
1437 | caller == kUSTCKV) { | |
5125d6e5 | 1438 | x = GetXsco(); |
1439 | y = GetYsco(); | |
1440 | z = GetZsco(); | |
829fb838 | 1441 | } |
42b936d1 | 1442 | else if (caller == kMGDRAW) { |
5125d6e5 | 1443 | Int_t i = -1; |
1444 | if ((i = fPrimaryElectronIndex) > -1) { | |
15a8a899 | 1445 | Double_t t; |
1446 | GetPrimaryElectronPosition(i, x, y, z, t); | |
5125d6e5 | 1447 | } else { |
1448 | x = TRACKR.xtrack[TRACKR.ntrack]; | |
1449 | y = TRACKR.ytrack[TRACKR.ntrack]; | |
1450 | z = TRACKR.ztrack[TRACKR.ntrack]; | |
1451 | } | |
829fb838 | 1452 | } |
42b936d1 | 1453 | else if (caller == kSODRAW) { |
1454 | Int_t ist = FLKSTK.npflka; | |
1455 | x = FLKSTK.xflk[ist]; | |
1456 | y = FLKSTK.yflk[ist]; | |
1457 | z = FLKSTK.zflk[ist]; | |
1458 | } | |
a9ea1616 | 1459 | else if (caller == kMGResumedTrack) { |
42b936d1 | 1460 | x = TRACKR.spausr[0]; |
1461 | y = TRACKR.spausr[1]; | |
1462 | z = TRACKR.spausr[2]; | |
5d80a015 | 1463 | } |
829fb838 | 1464 | else |
42b936d1 | 1465 | Warning("TrackPosition","position not available"); |
829fb838 | 1466 | } |
1467 | ||
1468 | //______________________________________________________________________________ | |
1469 | void TFluka::TrackMomentum(TLorentzVector& momentum) const | |
1470 | { | |
1471 | // Return the direction and the momentum (GeV/c) of the track | |
1472 | // currently being transported | |
1473 | // TRACKR.ptrack = momentum of the particle (not always defined, if | |
1474 | // < 0 must be obtained from etrack) | |
1475 | // TRACKR.cx,y,ztrck = direction cosines of the current particle | |
1476 | // TRACKR.etrack = total energy of the particle | |
1477 | // TRACKR.jtrack = identity number of the particle | |
1478 | // PAPROP.am[TRACKR.jtrack] = particle mass in gev | |
a9ea1616 | 1479 | FlukaCallerCode_t caller = GetCaller(); |
1480 | FlukaProcessCode_t icode = GetIcode(); | |
1481 | ||
82a3f706 | 1482 | if (caller != kEEDRAW && |
1483 | caller != kMGResumedTrack && | |
1484 | caller != kSODRAW && | |
1485 | caller != kUSDRAW && | |
a9ea1616 | 1486 | (caller != kENDRAW || (icode != kEMFSCOstopping1 && icode != kEMFSCOstopping2))) { |
42b936d1 | 1487 | if (TRACKR.ptrack >= 0) { |
1488 | momentum.SetPx(TRACKR.ptrack*TRACKR.cxtrck); | |
1489 | momentum.SetPy(TRACKR.ptrack*TRACKR.cytrck); | |
1490 | momentum.SetPz(TRACKR.ptrack*TRACKR.cztrck); | |
1491 | momentum.SetE(TRACKR.etrack); | |
1492 | return; | |
1493 | } | |
1494 | else { | |
1495 | Double_t p = sqrt(TRACKR.etrack * TRACKR.etrack - ParticleMassFPC(TRACKR.jtrack) * ParticleMassFPC(TRACKR.jtrack)); | |
1496 | momentum.SetPx(p*TRACKR.cxtrck); | |
1497 | momentum.SetPy(p*TRACKR.cytrck); | |
1498 | momentum.SetPz(p*TRACKR.cztrck); | |
1499 | momentum.SetE(TRACKR.etrack); | |
1500 | return; | |
1501 | } | |
a9ea1616 | 1502 | } else if (caller == kMGResumedTrack) { |
42b936d1 | 1503 | momentum.SetPx(TRACKR.spausr[4]); |
1504 | momentum.SetPy(TRACKR.spausr[5]); | |
1505 | momentum.SetPz(TRACKR.spausr[6]); | |
1506 | momentum.SetE (TRACKR.spausr[7]); | |
1507 | return; | |
a9ea1616 | 1508 | } else if (caller == kENDRAW && (icode == kEMFSCOstopping1 || icode == kEMFSCOstopping2)) { |
1509 | momentum.SetPx(0.); | |
1510 | momentum.SetPy(0.); | |
1511 | momentum.SetPz(0.); | |
1512 | momentum.SetE(TrackMass()); | |
42b936d1 | 1513 | |
1514 | } else if (caller == kSODRAW) { | |
1515 | Int_t ist = FLKSTK.npflka; | |
1516 | Double_t p = FLKSTK.pmoflk[ist]; | |
1517 | Int_t ifl = FLKSTK.iloflk[ist]; | |
1518 | Double_t m = PAPROP.am[ifl + 6]; | |
1519 | Double_t e = TMath::Sqrt(p * p + m * m); | |
1520 | momentum.SetPx(p * FLKSTK.txflk[ist]); | |
1521 | momentum.SetPy(p * FLKSTK.tyflk[ist]); | |
1522 | momentum.SetPz(p * FLKSTK.tzflk[ist]); | |
1523 | momentum.SetE(e); | |
82a3f706 | 1524 | } else if (caller == kUSDRAW) { |
6df2c1cc | 1525 | if (icode == kEMFSCObrems || |
1526 | icode == kEMFSCOmoller || | |
1527 | icode == kEMFSCObhabha || | |
1528 | icode == kEMFSCOcompton ) | |
1529 | { | |
82a3f706 | 1530 | momentum.SetPx(fPint[0]); |
1531 | momentum.SetPy(fPint[1]); | |
1532 | momentum.SetPz(fPint[2]); | |
1533 | momentum.SetE(fPint[3]); | |
6df2c1cc | 1534 | } else if (icode == kKASKADdray || |
1535 | icode == kKASKADbrems || | |
1536 | icode == kKASKADpair) { | |
1537 | momentum.SetPx(GENSTK.plr[0] * GENSTK.cxr[0]); | |
1538 | momentum.SetPy(GENSTK.plr[0] * GENSTK.cyr[0]); | |
1539 | momentum.SetPz(GENSTK.plr[0] * GENSTK.czr[0]); | |
1540 | momentum.SetE (GENSTK.tki[0] + PAPROP.am[GENSTK.kpart[0]+6]); | |
82a3f706 | 1541 | } else { |
6df2c1cc | 1542 | Double_t p = sqrt(TRACKR.etrack * TRACKR.etrack |
1543 | - ParticleMassFPC(TRACKR.jtrack) | |
1544 | * ParticleMassFPC(TRACKR.jtrack)); | |
82a3f706 | 1545 | momentum.SetPx(p*TRACKR.cxtrck); |
1546 | momentum.SetPy(p*TRACKR.cytrck); | |
1547 | momentum.SetPz(p*TRACKR.cztrck); | |
1548 | momentum.SetE(TRACKR.etrack); | |
1549 | } | |
829fb838 | 1550 | } |
1551 | else | |
1552 | Warning("TrackMomentum","momentum not available"); | |
1553 | } | |
1554 | ||
1555 | //______________________________________________________________________________ | |
1556 | void TFluka::TrackMomentum(Double_t& px, Double_t& py, Double_t& pz, Double_t& e) const | |
1557 | { | |
1558 | // Return the direction and the momentum (GeV/c) of the track | |
1559 | // currently being transported | |
1560 | // TRACKR.ptrack = momentum of the particle (not always defined, if | |
1561 | // < 0 must be obtained from etrack) | |
1562 | // TRACKR.cx,y,ztrck = direction cosines of the current particle | |
1563 | // TRACKR.etrack = total energy of the particle | |
1564 | // TRACKR.jtrack = identity number of the particle | |
1565 | // PAPROP.am[TRACKR.jtrack] = particle mass in gev | |
a9ea1616 | 1566 | FlukaCallerCode_t caller = GetCaller(); |
1567 | FlukaProcessCode_t icode = GetIcode(); | |
42b936d1 | 1568 | if (caller != kEEDRAW && |
1569 | caller != kMGResumedTrack && | |
1570 | caller != kSODRAW && | |
82a3f706 | 1571 | caller != kUSDRAW && |
a9ea1616 | 1572 | (caller != kENDRAW || (icode != kEMFSCOstopping1 && icode != kEMFSCOstopping2))) { |
829fb838 | 1573 | if (TRACKR.ptrack >= 0) { |
1574 | px = TRACKR.ptrack*TRACKR.cxtrck; | |
1575 | py = TRACKR.ptrack*TRACKR.cytrck; | |
1576 | pz = TRACKR.ptrack*TRACKR.cztrck; | |
a9ea1616 | 1577 | e = TRACKR.etrack; |
829fb838 | 1578 | return; |
1579 | } | |
1580 | else { | |
ece92b30 | 1581 | Double_t p = sqrt(TRACKR.etrack * TRACKR.etrack - ParticleMassFPC(TRACKR.jtrack) * ParticleMassFPC(TRACKR.jtrack)); |
829fb838 | 1582 | px = p*TRACKR.cxtrck; |
1583 | py = p*TRACKR.cytrck; | |
1584 | pz = p*TRACKR.cztrck; | |
a9ea1616 | 1585 | e = TRACKR.etrack; |
829fb838 | 1586 | return; |
1587 | } | |
a9ea1616 | 1588 | } else if (caller == kMGResumedTrack) { |
5d80a015 | 1589 | px = TRACKR.spausr[4]; |
1590 | py = TRACKR.spausr[5]; | |
1591 | pz = TRACKR.spausr[6]; | |
1592 | e = TRACKR.spausr[7]; | |
0773d0ac | 1593 | return; |
a9ea1616 | 1594 | } else if (caller == kENDRAW && (icode == kEMFSCOstopping1 || icode == kEMFSCOstopping2)) { |
1595 | px = 0.; | |
1596 | py = 0.; | |
1597 | pz = 0.; | |
1598 | e = TrackMass(); | |
42b936d1 | 1599 | } else if (caller == kSODRAW) { |
1600 | Int_t ist = FLKSTK.npflka; | |
1601 | Double_t p = FLKSTK.pmoflk[ist]; | |
1602 | Int_t ifl = FLKSTK.iloflk[ist]; | |
1603 | Double_t m = PAPROP.am[ifl + 6]; | |
1604 | e = TMath::Sqrt(p * p + m * m); | |
1605 | px = p * FLKSTK.txflk[ist]; | |
1606 | py = p * FLKSTK.tyflk[ist]; | |
1607 | pz = p * FLKSTK.tzflk[ist]; | |
82a3f706 | 1608 | } else if (caller == kUSDRAW) { |
6df2c1cc | 1609 | if (icode == kEMFSCObrems || |
1610 | icode == kEMFSCOmoller || | |
1611 | icode == kEMFSCObhabha || | |
1612 | icode == kEMFSCOcompton ) | |
1613 | { | |
82a3f706 | 1614 | px = fPint[0]; |
1615 | py = fPint[1]; | |
1616 | pz = fPint[2]; | |
1617 | e = fPint[3]; | |
6df2c1cc | 1618 | } else if (icode == kKASKADdray || |
1619 | icode == kKASKADbrems || | |
1620 | icode == kKASKADpair) { | |
1621 | px = GENSTK.plr[0] * GENSTK.cxr[0]; | |
1622 | py = GENSTK.plr[0] * GENSTK.cyr[0]; | |
1623 | pz = GENSTK.plr[0] * GENSTK.czr[0]; | |
1624 | e = GENSTK.tki[0] + PAPROP.am[GENSTK.kpart[0]+6]; | |
82a3f706 | 1625 | } else { |
1626 | Double_t p = sqrt(TRACKR.etrack * TRACKR.etrack - ParticleMassFPC(TRACKR.jtrack) * ParticleMassFPC(TRACKR.jtrack)); | |
1627 | px = p*TRACKR.cxtrck; | |
1628 | py = p*TRACKR.cytrck; | |
1629 | pz = p*TRACKR.cztrck; | |
1630 | e = TRACKR.etrack; | |
1631 | } | |
829fb838 | 1632 | } |
1633 | else | |
42b936d1 | 1634 | Warning("TrackMomentum","momentum not available"); |
829fb838 | 1635 | } |
1636 | ||
1637 | //______________________________________________________________________________ | |
1638 | Double_t TFluka::TrackStep() const | |
1639 | { | |
1640 | // Return the length in centimeters of the current step | |
1641 | // TRACKR.ctrack = total curved path | |
42b936d1 | 1642 | FlukaCallerCode_t caller = GetCaller(); |
1643 | if (caller == kBXEntering || caller == kBXExiting || | |
1644 | caller == kENDRAW || caller == kUSDRAW || | |
1645 | caller == kUSTCKV || caller == kMGResumedTrack || | |
1646 | caller == kSODRAW) | |
1647 | return 0.0; | |
a9ea1616 | 1648 | else if (caller == kMGDRAW) |
829fb838 | 1649 | return TRACKR.ctrack; |
669cede4 | 1650 | else { |
1651 | Warning("TrackStep", "track step not available"); | |
1652 | return 0.0; | |
1653 | } | |
829fb838 | 1654 | } |
1655 | ||
1656 | //______________________________________________________________________________ | |
1657 | Double_t TFluka::TrackLength() const | |
1658 | { | |
1659 | // TRACKR.cmtrck = cumulative curved path since particle birth | |
a9ea1616 | 1660 | FlukaCallerCode_t caller = GetCaller(); |
1661 | if (caller == kBXEntering || caller == kBXExiting || | |
1662 | caller == kENDRAW || caller == kUSDRAW || caller == kMGDRAW || | |
1663 | caller == kUSTCKV) | |
829fb838 | 1664 | return TRACKR.cmtrck; |
a9ea1616 | 1665 | else if (caller == kMGResumedTrack) |
5d80a015 | 1666 | return TRACKR.spausr[8]; |
82a3f706 | 1667 | else if (caller == kSODRAW) |
1668 | return 0.0; | |
669cede4 | 1669 | else { |
82a3f706 | 1670 | Warning("TrackLength", "track length not available for caller %5d \n", caller); |
669cede4 | 1671 | return 0.0; |
1672 | } | |
829fb838 | 1673 | } |
1674 | ||
1675 | //______________________________________________________________________________ | |
1676 | Double_t TFluka::TrackTime() const | |
1677 | { | |
1678 | // Return the current time of flight of the track being transported | |
1679 | // TRACKR.atrack = age of the particle | |
a9ea1616 | 1680 | FlukaCallerCode_t caller = GetCaller(); |
15a8a899 | 1681 | if (caller == kMGDRAW) { |
1682 | Int_t i; | |
1683 | if ((i = fPrimaryElectronIndex) > -1) { | |
1684 | Double_t x, y, z, t; | |
1685 | GetPrimaryElectronPosition(i, x, y, z, t); | |
1686 | return t; | |
1687 | } else { | |
1688 | return TRACKR.atrack; | |
1689 | } | |
1690 | } else if (caller == kBXEntering || caller == kBXExiting || | |
1691 | caller == kENDRAW || caller == kUSDRAW || | |
1692 | caller == kUSTCKV) | |
829fb838 | 1693 | return TRACKR.atrack; |
a9ea1616 | 1694 | else if (caller == kMGResumedTrack) |
5d80a015 | 1695 | return TRACKR.spausr[3]; |
42b936d1 | 1696 | else if (caller == kSODRAW) { |
1697 | return (FLKSTK.agestk[FLKSTK.npflka]); | |
1698 | } | |
669cede4 | 1699 | else { |
1700 | Warning("TrackTime", "track time not available"); | |
1701 | return 0.0; | |
1702 | } | |
829fb838 | 1703 | } |
1704 | ||
1705 | //______________________________________________________________________________ | |
1706 | Double_t TFluka::Edep() const | |
1707 | { | |
1708 | // Energy deposition | |
1709 | // if TRACKR.ntrack = 0, TRACKR.mtrack = 0: | |
1710 | // -->local energy deposition (the value and the point are not recorded in TRACKR) | |
1711 | // but in the variable "rull" of the procedure "endraw.cxx" | |
1712 | // if TRACKR.ntrack > 0, TRACKR.mtrack = 0: | |
1713 | // -->no energy loss along the track | |
1714 | // if TRACKR.ntrack > 0, TRACKR.mtrack > 0: | |
1715 | // -->energy loss distributed along the track | |
07f5b33e | 1716 | // TRACKR.dtrack = energy deposition of the jth deposition event |
829fb838 | 1717 | |
1718 | // If coming from bxdraw we have 2 steps of 0 length and 0 edep | |
669cede4 | 1719 | // If coming from usdraw we just signal particle production - no edep |
1720 | // If just first time after resuming, no edep for the primary | |
a9ea1616 | 1721 | FlukaCallerCode_t caller = GetCaller(); |
ada781c7 | 1722 | |
a9ea1616 | 1723 | if (caller == kBXExiting || caller == kBXEntering || |
42b936d1 | 1724 | caller == kUSDRAW || caller == kMGResumedTrack || |
1725 | caller == kSODRAW) | |
1726 | return 0.0; | |
829fb838 | 1727 | Double_t sum = 0; |
5125d6e5 | 1728 | Int_t i = -1; |
09cdde8a | 1729 | |
ada781c7 | 1730 | // Material with primary ionisation activated but number of primary electrons nprim = 0 |
1731 | if (fPrimaryElectronIndex == -2) return 0.0; | |
1732 | // nprim > 0 | |
5125d6e5 | 1733 | if ((i = fPrimaryElectronIndex) > -1) { |
1734 | // Primary ionisation | |
ada781c7 | 1735 | sum = GetPrimaryElectronKineticEnergy(i); |
1736 | if (sum > 100.) { | |
1737 | printf("edep > 100. %d %d %f \n", i, ALLDLT.nalldl, sum); | |
1738 | } | |
1739 | return sum; | |
5125d6e5 | 1740 | } else { |
1741 | // Normal ionisation | |
1742 | if (TRACKR.mtrack > 1) printf("Edep: %6d\n", TRACKR.mtrack); | |
1743 | ||
1744 | for ( Int_t j=0;j<TRACKR.mtrack;j++) { | |
1745 | sum +=TRACKR.dtrack[j]; | |
1746 | } | |
1747 | if (TRACKR.ntrack == 0 && TRACKR.mtrack == 0) | |
1748 | return fRull + sum; | |
1749 | else { | |
1750 | return sum; | |
1751 | } | |
829fb838 | 1752 | } |
1753 | } | |
1754 | ||
18e0cabb | 1755 | //______________________________________________________________________________ |
1756 | Int_t TFluka::CorrectFlukaId() const | |
1757 | { | |
1758 | // since we don't put photons and e- created bellow transport cut on the vmc stack | |
1759 | // and there is a call to endraw for energy deposition for each of them | |
1760 | // and they have the track number of their parent, but different identity (pdg) | |
4aba9d66 | 1761 | // so we want to assign also their parent identity. |
cc7af78a | 1762 | |
a9923346 | 1763 | if( (IsTrackStop()) |
18e0cabb | 1764 | && TRACKR.ispusr[mkbmx2 - 4] == TRACKR.ispusr[mkbmx2 - 1] |
1765 | && TRACKR.jtrack != TRACKR.ispusr[mkbmx2 - 3] ) { | |
1766 | if (fVerbosityLevel >=3) | |
1767 | cout << "CorrectFlukaId() for icode=" << GetIcode() | |
1768 | << " track=" << TRACKR.ispusr[mkbmx2 - 1] | |
1769 | << " current PDG=" << PDGFromId(TRACKR.jtrack) | |
1770 | << " assign parent PDG=" << PDGFromId(TRACKR.ispusr[mkbmx2 - 3]) << endl; | |
1771 | return TRACKR.ispusr[mkbmx2 - 3]; // assign parent identity | |
1772 | } | |
13858fbd | 1773 | if (TRACKR.jtrack <= 64){ |
cc7af78a | 1774 | return TRACKR.jtrack; |
1775 | } else { | |
1776 | return TRACKR.j0trck; | |
1777 | } | |
18e0cabb | 1778 | } |
1779 | ||
1780 | ||
829fb838 | 1781 | //______________________________________________________________________________ |
1782 | Int_t TFluka::TrackPid() const | |
1783 | { | |
1784 | // Return the id of the particle transported | |
1785 | // TRACKR.jtrack = identity number of the particle | |
a9ea1616 | 1786 | FlukaCallerCode_t caller = GetCaller(); |
42b936d1 | 1787 | if (caller != kEEDRAW && caller != kSODRAW) { |
18e0cabb | 1788 | return PDGFromId( CorrectFlukaId() ); |
f926898e | 1789 | } |
42b936d1 | 1790 | else if (caller == kSODRAW) { |
1791 | return PDGFromId(FLKSTK.iloflk[FLKSTK.npflka]); | |
1792 | } | |
829fb838 | 1793 | else |
1794 | return -1000; | |
1795 | } | |
1796 | ||
1797 | //______________________________________________________________________________ | |
1798 | Double_t TFluka::TrackCharge() const | |
1799 | { | |
1800 | // Return charge of the track currently transported | |
1801 | // PAPROP.ichrge = electric charge of the particle | |
1802 | // TRACKR.jtrack = identity number of the particle | |
13858fbd | 1803 | |
a9ea1616 | 1804 | FlukaCallerCode_t caller = GetCaller(); |
42b936d1 | 1805 | if (caller != kEEDRAW && caller != kSODRAW) |
1806 | return PAPROP.ichrge[CorrectFlukaId() + 6]; | |
1807 | else if (caller == kSODRAW) { | |
1808 | Int_t ifl = PDGFromId(FLKSTK.iloflk[FLKSTK.npflka]); | |
1809 | return PAPROP.ichrge[ifl + 6]; | |
1810 | } | |
829fb838 | 1811 | else |
1812 | return -1000.0; | |
1813 | } | |
1814 | ||
1815 | //______________________________________________________________________________ | |
1816 | Double_t TFluka::TrackMass() const | |
1817 | { | |
1818 | // PAPROP.am = particle mass in GeV | |
1819 | // TRACKR.jtrack = identity number of the particle | |
a9ea1616 | 1820 | FlukaCallerCode_t caller = GetCaller(); |
42b936d1 | 1821 | if (caller != kEEDRAW && caller != kSODRAW) |
18e0cabb | 1822 | return PAPROP.am[CorrectFlukaId()+6]; |
42b936d1 | 1823 | else if (caller == kSODRAW) { |
82a3f706 | 1824 | Int_t ifl = FLKSTK.iloflk[FLKSTK.npflka]; |
42b936d1 | 1825 | return PAPROP.am[ifl + 6]; |
1826 | } | |
829fb838 | 1827 | else |
1828 | return -1000.0; | |
1829 | } | |
1830 | ||
1831 | //______________________________________________________________________________ | |
1832 | Double_t TFluka::Etot() const | |
1833 | { | |
1834 | // TRACKR.etrack = total energy of the particle | |
6df2c1cc | 1835 | FlukaCallerCode_t caller = GetCaller(); |
1836 | FlukaProcessCode_t icode = GetIcode(); | |
1837 | if (caller != kEEDRAW && caller != kSODRAW && caller != kUSDRAW) | |
1838 | { | |
1839 | return TRACKR.etrack; | |
1840 | } else if (caller == kUSDRAW) { | |
1841 | if (icode == kEMFSCObrems || | |
1842 | icode == kEMFSCOmoller || | |
1843 | icode == kEMFSCObhabha || | |
1844 | icode == kEMFSCOcompton ) { | |
1845 | return fPint[3]; | |
1846 | } | |
1847 | else if (icode == kKASKADdray || | |
1848 | icode == kKASKADbrems || | |
1849 | icode == kKASKADpair) { | |
1850 | return (GENSTK.tki[0] + PAPROP.am[GENSTK.kpart[0]+6]); | |
ca01d0af | 1851 | } else { |
1852 | return TRACKR.etrack; | |
6df2c1cc | 1853 | } |
ca01d0af | 1854 | |
6df2c1cc | 1855 | } |
42b936d1 | 1856 | else if (caller == kSODRAW) { |
1857 | Int_t ist = FLKSTK.npflka; | |
1858 | Double_t p = FLKSTK.pmoflk[ist]; | |
1859 | Int_t ifl = FLKSTK.iloflk[ist]; | |
1860 | Double_t m = PAPROP.am[ifl + 6]; | |
1861 | Double_t e = TMath::Sqrt(p * p + m * m); | |
1862 | return e; | |
1863 | } | |
ca01d0af | 1864 | printf("Etot %5d %5d \n", caller, icode); |
6df2c1cc | 1865 | |
1866 | return -1000.0; | |
829fb838 | 1867 | } |
1868 | ||
1869 | // | |
1870 | // track status | |
1871 | // | |
1872 | //______________________________________________________________________________ | |
1873 | Bool_t TFluka::IsNewTrack() const | |
1874 | { | |
1875 | // Return true for the first call of Stepping() | |
1876 | return fTrackIsNew; | |
1877 | } | |
1878 | ||
0dabe425 | 1879 | void TFluka::SetTrackIsNew(Bool_t flag) |
1880 | { | |
1881 | // Return true for the first call of Stepping() | |
1882 | fTrackIsNew = flag; | |
1883 | ||
1884 | } | |
1885 | ||
1886 | ||
829fb838 | 1887 | //______________________________________________________________________________ |
1888 | Bool_t TFluka::IsTrackInside() const | |
1889 | { | |
1890 | // True if the track is not at the boundary of the current volume | |
1891 | // In Fluka a step is always inside one kind of material | |
1892 | // If the step would go behind the region of one material, | |
1893 | // it will be shortened to reach only the boundary. | |
1894 | // Therefore IsTrackInside() is always true. | |
a9ea1616 | 1895 | FlukaCallerCode_t caller = GetCaller(); |
1896 | if (caller == kBXEntering || caller == kBXExiting) | |
829fb838 | 1897 | return 0; |
1898 | else | |
1899 | return 1; | |
1900 | } | |
1901 | ||
1902 | //______________________________________________________________________________ | |
1903 | Bool_t TFluka::IsTrackEntering() const | |
1904 | { | |
1905 | // True if this is the first step of the track in the current volume | |
1906 | ||
a9ea1616 | 1907 | FlukaCallerCode_t caller = GetCaller(); |
1908 | if (caller == kBXEntering) | |
829fb838 | 1909 | return 1; |
1910 | else return 0; | |
1911 | } | |
1912 | ||
1913 | //______________________________________________________________________________ | |
1914 | Bool_t TFluka::IsTrackExiting() const | |
1915 | { | |
1916 | // True if track is exiting volume | |
1917 | // | |
a9ea1616 | 1918 | FlukaCallerCode_t caller = GetCaller(); |
1919 | if (caller == kBXExiting) | |
829fb838 | 1920 | return 1; |
1921 | else return 0; | |
1922 | } | |
1923 | ||
1924 | //______________________________________________________________________________ | |
1925 | Bool_t TFluka::IsTrackOut() const | |
1926 | { | |
1927 | // True if the track is out of the setup | |
1928 | // means escape | |
a9ea1616 | 1929 | FlukaProcessCode_t icode = GetIcode(); |
1930 | ||
1931 | if (icode == kKASKADescape || | |
1932 | icode == kEMFSCOescape || | |
1933 | icode == kKASNEUescape || | |
1934 | icode == kKASHEAescape || | |
1935 | icode == kKASOPHescape) | |
1936 | return 1; | |
829fb838 | 1937 | else return 0; |
1938 | } | |
1939 | ||
1940 | //______________________________________________________________________________ | |
1941 | Bool_t TFluka::IsTrackDisappeared() const | |
1942 | { | |
a9ea1616 | 1943 | // All inelastic interactions and decays |
829fb838 | 1944 | // fIcode from usdraw |
a9ea1616 | 1945 | FlukaProcessCode_t icode = GetIcode(); |
1946 | if (icode == kKASKADinelint || // inelastic interaction | |
1947 | icode == kKASKADdecay || // particle decay | |
1948 | icode == kKASKADdray || // delta ray generation by hadron | |
1949 | icode == kKASKADpair || // direct pair production | |
1950 | icode == kKASKADbrems || // bremsstrahlung (muon) | |
1951 | icode == kEMFSCObrems || // bremsstrahlung (electron) | |
1952 | icode == kEMFSCOmoller || // Moller scattering | |
1953 | icode == kEMFSCObhabha || // Bhaba scattering | |
1954 | icode == kEMFSCOanniflight || // in-flight annihilation | |
1955 | icode == kEMFSCOannirest || // annihilation at rest | |
1956 | icode == kEMFSCOpair || // pair production | |
1957 | icode == kEMFSCOcompton || // Compton scattering | |
1958 | icode == kEMFSCOphotoel || // Photoelectric effect | |
1959 | icode == kKASNEUhadronic || // hadronic interaction | |
2047b055 | 1960 | icode == kKASHEAdray // delta-ray |
0dabe425 | 1961 | ) return 1; |
829fb838 | 1962 | else return 0; |
1963 | } | |
1964 | ||
1965 | //______________________________________________________________________________ | |
1966 | Bool_t TFluka::IsTrackStop() const | |
1967 | { | |
1968 | // True if the track energy has fallen below the threshold | |
1969 | // means stopped by signal or below energy threshold | |
a9ea1616 | 1970 | FlukaProcessCode_t icode = GetIcode(); |
18e0cabb | 1971 | if (icode == kKASKADstopping || // stopping particle |
1972 | icode == kKASKADtimekill || // time kill | |
1973 | icode == kEMFSCOstopping1 || // below user-defined cut-off | |
1974 | icode == kEMFSCOstopping2 || // below user cut-off | |
1975 | icode == kEMFSCOtimekill || // time kill | |
1976 | icode == kKASNEUstopping || // neutron below threshold | |
1977 | icode == kKASNEUtimekill || // time kill | |
1978 | icode == kKASHEAtimekill || // time kill | |
1979 | icode == kKASOPHtimekill) return 1; // time kill | |
829fb838 | 1980 | else return 0; |
1981 | } | |
1982 | ||
1983 | //______________________________________________________________________________ | |
1984 | Bool_t TFluka::IsTrackAlive() const | |
1985 | { | |
695d8af9 | 1986 | // Means not disappeared or not out |
1987 | FlukaProcessCode_t icode = GetIcode(); | |
1988 | ||
1989 | if (IsTrackOut() || | |
1990 | IsTrackStop() || | |
1991 | icode == kKASKADinelint || // inelastic interaction | |
1992 | icode == kKASKADdecay || // particle decay | |
1993 | icode == kEMFSCOanniflight || // in-flight annihilation | |
1994 | icode == kEMFSCOannirest || // annihilation at rest | |
1995 | icode == kEMFSCOpair || // pair production | |
1996 | icode == kEMFSCOphotoel || // Photoelectric effect | |
1997 | icode == kKASNEUhadronic // hadronic interaction | |
1998 | ) | |
1999 | { | |
2000 | // Exclude the cases for which the particle has disappeared (paused) but will reappear later (= alive). | |
2001 | return 0; | |
2002 | } else { | |
2003 | return 1; | |
2004 | } | |
829fb838 | 2005 | } |
2006 | ||
2007 | // | |
2008 | // secondaries | |
2009 | // | |
2010 | ||
2011 | //______________________________________________________________________________ | |
2012 | Int_t TFluka::NSecondaries() const | |
2013 | ||
2014 | { | |
2015 | // Number of secondary particles generated in the current step | |
81f1d030 | 2016 | // GENSTK.np = number of secondaries except light and heavy ions |
829fb838 | 2017 | // FHEAVY.npheav = number of secondaries for light and heavy secondary ions |
a9ea1616 | 2018 | FlukaCallerCode_t caller = GetCaller(); |
2019 | if (caller == kUSDRAW) // valid only after usdraw | |
4aba9d66 | 2020 | return GENSTK.np + FHEAVY.npheav; |
a9ea1616 | 2021 | else if (caller == kUSTCKV) { |
4aba9d66 | 2022 | // Cerenkov Photon production |
2023 | return fNCerenkov; | |
7b203b6e | 2024 | } |
829fb838 | 2025 | return 0; |
2026 | } // end of NSecondaries | |
2027 | ||
2028 | //______________________________________________________________________________ | |
2029 | void TFluka::GetSecondary(Int_t isec, Int_t& particleId, | |
4aba9d66 | 2030 | TLorentzVector& position, TLorentzVector& momentum) |
829fb838 | 2031 | { |
2032 | // Copy particles from secondary stack to vmc stack | |
2033 | // | |
2034 | ||
a9ea1616 | 2035 | FlukaCallerCode_t caller = GetCaller(); |
2036 | if (caller == kUSDRAW) { // valid only after usdraw | |
4aba9d66 | 2037 | if (GENSTK.np > 0) { |
2038 | // Hadronic interaction | |
2039 | if (isec >= 0 && isec < GENSTK.np) { | |
2040 | particleId = PDGFromId(GENSTK.kpart[isec]); | |
2041 | position.SetX(fXsco); | |
2042 | position.SetY(fYsco); | |
2043 | position.SetZ(fZsco); | |
2044 | position.SetT(TRACKR.atrack); | |
2045 | momentum.SetPx(GENSTK.plr[isec]*GENSTK.cxr[isec]); | |
2046 | momentum.SetPy(GENSTK.plr[isec]*GENSTK.cyr[isec]); | |
2047 | momentum.SetPz(GENSTK.plr[isec]*GENSTK.czr[isec]); | |
2048 | momentum.SetE(GENSTK.tki[isec] + PAPROP.am[GENSTK.kpart[isec]+6]); | |
2049 | } | |
2050 | else if (isec >= GENSTK.np && isec < GENSTK.np + FHEAVY.npheav) { | |
2051 | Int_t jsec = isec - GENSTK.np; | |
2052 | particleId = FHEAVY.kheavy[jsec]; // this is Fluka id !!! | |
2053 | position.SetX(fXsco); | |
2054 | position.SetY(fYsco); | |
2055 | position.SetZ(fZsco); | |
2056 | position.SetT(TRACKR.atrack); | |
2057 | momentum.SetPx(FHEAVY.pheavy[jsec]*FHEAVY.cxheav[jsec]); | |
2058 | momentum.SetPy(FHEAVY.pheavy[jsec]*FHEAVY.cyheav[jsec]); | |
2059 | momentum.SetPz(FHEAVY.pheavy[jsec]*FHEAVY.czheav[jsec]); | |
2060 | if (FHEAVY.tkheav[jsec] >= 3 && FHEAVY.tkheav[jsec] <= 6) | |
2061 | momentum.SetE(FHEAVY.tkheav[jsec] + PAPROP.am[jsec+6]); | |
2062 | else if (FHEAVY.tkheav[jsec] > 6) | |
2063 | momentum.SetE(FHEAVY.tkheav[jsec] + FHEAVY.amnhea[jsec]); // to be checked !!! | |
2064 | } | |
2065 | else | |
2066 | Warning("GetSecondary","isec out of range"); | |
2067 | } | |
a9ea1616 | 2068 | } else if (caller == kUSTCKV) { |
4aba9d66 | 2069 | Int_t index = OPPHST.lstopp - isec; |
2070 | position.SetX(OPPHST.xoptph[index]); | |
2071 | position.SetY(OPPHST.yoptph[index]); | |
2072 | position.SetZ(OPPHST.zoptph[index]); | |
2073 | position.SetT(OPPHST.agopph[index]); | |
2074 | Double_t p = OPPHST.poptph[index]; | |
2075 | ||
2076 | momentum.SetPx(p * OPPHST.txopph[index]); | |
2077 | momentum.SetPy(p * OPPHST.tyopph[index]); | |
2078 | momentum.SetPz(p * OPPHST.tzopph[index]); | |
2079 | momentum.SetE(p); | |
829fb838 | 2080 | } |
2081 | else | |
4aba9d66 | 2082 | Warning("GetSecondary","no secondaries available"); |
7b203b6e | 2083 | |
829fb838 | 2084 | } // end of GetSecondary |
2085 | ||
7b203b6e | 2086 | |
829fb838 | 2087 | //______________________________________________________________________________ |
2088 | TMCProcess TFluka::ProdProcess(Int_t) const | |
2089 | ||
2090 | { | |
2091 | // Name of the process that has produced the secondary particles | |
2092 | // in the current step | |
0dabe425 | 2093 | |
a9ea1616 | 2094 | Int_t mugamma = (TRACKR.jtrack == kFLUKAphoton || |
4aba9d66 | 2095 | TRACKR.jtrack == kFLUKAmuplus || |
2096 | TRACKR.jtrack == kFLUKAmuminus); | |
a9ea1616 | 2097 | FlukaProcessCode_t icode = GetIcode(); |
2098 | ||
2099 | if (icode == kKASKADdecay) return kPDecay; | |
2100 | else if (icode == kKASKADpair || icode == kEMFSCOpair) return kPPair; | |
2101 | else if (icode == kEMFSCOcompton) return kPCompton; | |
2102 | else if (icode == kEMFSCOphotoel) return kPPhotoelectric; | |
2103 | else if (icode == kKASKADbrems || icode == kEMFSCObrems) return kPBrem; | |
2104 | else if (icode == kKASKADdray || icode == kKASHEAdray) return kPDeltaRay; | |
2105 | else if (icode == kEMFSCOmoller || icode == kEMFSCObhabha) return kPDeltaRay; | |
2106 | else if (icode == kEMFSCOanniflight || icode == kEMFSCOannirest) return kPAnnihilation; | |
2107 | else if (icode == kKASKADinelint) { | |
4aba9d66 | 2108 | if (!mugamma) return kPHadronic; |
2109 | else if (TRACKR.jtrack == kFLUKAphoton) return kPPhotoFission; | |
2110 | else return kPMuonNuclear; | |
829fb838 | 2111 | } |
a9ea1616 | 2112 | else if (icode == kEMFSCOrayleigh) return kPRayleigh; |
829fb838 | 2113 | // Fluka codes 100, 300 and 400 still to be investigasted |
a9ea1616 | 2114 | else return kPNoProcess; |
829fb838 | 2115 | } |
2116 | ||
829fb838 | 2117 | |
b496f27c | 2118 | Int_t TFluka::StepProcesses(TArrayI &proc) const |
2119 | { | |
2120 | // | |
2121 | // Return processes active in the current step | |
2122 | // | |
e71bcde8 | 2123 | FlukaProcessCode_t icode = GetIcode(); |
2124 | FlukaCallerCode_t caller = GetCaller(); | |
b496f27c | 2125 | proc.Set(1); |
2126 | TMCProcess iproc; | |
87ad3c3e | 2127 | if (caller == kBXEntering || caller == kBXExiting || caller == kEEDRAW || caller == kSODRAW) { |
e71bcde8 | 2128 | iproc = kPTransportation; |
87ad3c3e | 2129 | } |
2130 | else if (caller == kUSTCKV) { | |
2131 | iproc = kPCerenkov; | |
e71bcde8 | 2132 | } else { |
2133 | switch (icode) { | |
2134 | case kEMFSCO: | |
82a3f706 | 2135 | if (Edep() > 0.) { |
2136 | iproc = kPEnergyLoss; | |
2137 | } else { | |
2138 | iproc = kPTransportation; | |
2139 | } | |
e71bcde8 | 2140 | break; |
6df2c1cc | 2141 | case kKASKAD: |
2142 | if (Edep() > 0.) { | |
2143 | iproc = kPEnergyLoss; | |
2144 | } else { | |
2145 | iproc = kPTransportation; | |
2146 | } | |
2147 | break; | |
87ad3c3e | 2148 | case kKASHEA: |
2149 | case kKASNEU: | |
2150 | case kKASOPH: | |
2151 | case kKASKADescape: | |
2152 | case kEMFSCOescape: | |
2153 | case kKASNEUescape: | |
2154 | case kKASHEAescape: | |
2155 | case kKASOPHescape: | |
2156 | iproc = kPTransportation; | |
2157 | break; | |
e71bcde8 | 2158 | case kKASKADtimekill: |
2159 | case kEMFSCOtimekill: | |
2160 | case kKASNEUtimekill: | |
2161 | case kKASHEAtimekill: | |
2162 | case kKASOPHtimekill: | |
2163 | iproc = kPTOFlimit; | |
2164 | break; | |
2165 | case kKASKADstopping: | |
e71bcde8 | 2166 | case kEMFSCOstopping1: |
2167 | case kEMFSCOstopping2: | |
e71bcde8 | 2168 | case kKASNEUstopping: |
e71bcde8 | 2169 | iproc = kPStop; |
ca01d0af | 2170 | break; |
2171 | case kKASKADinelint: | |
2172 | case kKASNEUhadronic: | |
2173 | iproc = kPHadronic; | |
2174 | break; | |
2175 | case kKASKADinelarecoil: | |
2176 | iproc = kPHadronic; | |
2177 | break; | |
2178 | case kKASKADnelint: | |
2179 | iproc = kPHElastic; | |
e71bcde8 | 2180 | break; |
2181 | case kKASOPHabsorption: | |
2182 | iproc = kPLightAbsorption; | |
2183 | break; | |
2184 | case kKASOPHrefraction: | |
2185 | iproc = kPLightRefraction; | |
87ad3c3e | 2186 | break; |
e71bcde8 | 2187 | case kEMFSCOlocaldep : |
2188 | iproc = kPPhotoelectric; | |
2189 | break; | |
2190 | default: | |
2191 | iproc = ProdProcess(0); | |
2192 | } | |
b496f27c | 2193 | } |
e71bcde8 | 2194 | |
07f5b33e | 2195 | proc[0] = iproc; |
b496f27c | 2196 | return 1; |
2197 | } | |
829fb838 | 2198 | //______________________________________________________________________________ |
2199 | Int_t TFluka::VolId2Mate(Int_t id) const | |
2200 | { | |
2201 | // | |
2202 | // Returns the material number for a given volume ID | |
2203 | // | |
2204 | return fMCGeo->VolId2Mate(id); | |
2205 | } | |
2206 | ||
2207 | //______________________________________________________________________________ | |
2208 | const char* TFluka::VolName(Int_t id) const | |
2209 | { | |
2210 | // | |
2211 | // Returns the volume name for a given volume ID | |
2212 | // | |
2213 | return fMCGeo->VolName(id); | |
2214 | } | |
2215 | ||
a8e4986c | 2216 | Int_t TFluka::MediumId(const Text_t* mediumName) const |
2217 | { | |
2218 | // | |
2219 | // Return the unique medium id for medium with name mediumName | |
2220 | TList *medlist = gGeoManager->GetListOfMedia(); | |
2221 | TGeoMedium* med = (TGeoMedium*) medlist->FindObject(mediumName); | |
2222 | if (med) { | |
2223 | return (med->GetId()); | |
2224 | } else { | |
2225 | return (-1); | |
2226 | } | |
2227 | } | |
2228 | ||
829fb838 | 2229 | //______________________________________________________________________________ |
2230 | Int_t TFluka::VolId(const Text_t* volName) const | |
2231 | { | |
2232 | // | |
2233 | // Converts from volume name to volume ID. | |
2234 | // Time consuming. (Only used during set-up) | |
2235 | // Could be replaced by hash-table | |
2236 | // | |
09cd6497 | 2237 | char sname[20]; |
2238 | Int_t len; | |
2239 | strncpy(sname, volName, len = strlen(volName)); | |
2240 | sname[len] = 0; | |
2241 | while (sname[len - 1] == ' ') sname[--len] = 0; | |
2242 | return fMCGeo->VolId(sname); | |
829fb838 | 2243 | } |
2244 | ||
2245 | //______________________________________________________________________________ | |
2246 | Int_t TFluka::CurrentVolID(Int_t& copyNo) const | |
2247 | { | |
2248 | // | |
2249 | // Return the logical id and copy number corresponding to the current fluka region | |
2250 | // | |
2251 | if (gGeoManager->IsOutside()) return 0; | |
2252 | TGeoNode *node = gGeoManager->GetCurrentNode(); | |
2253 | copyNo = node->GetNumber(); | |
2254 | Int_t id = node->GetVolume()->GetNumber(); | |
2255 | return id; | |
2256 | } | |
2257 | ||
2258 | //______________________________________________________________________________ | |
2259 | Int_t TFluka::CurrentVolOffID(Int_t off, Int_t& copyNo) const | |
2260 | { | |
2261 | // | |
2262 | // Return the logical id and copy number of off'th mother | |
2263 | // corresponding to the current fluka region | |
2264 | // | |
2265 | if (off<0 || off>gGeoManager->GetLevel()) return 0; | |
2266 | if (off==0) return CurrentVolID(copyNo); | |
2267 | TGeoNode *node = gGeoManager->GetMother(off); | |
2268 | if (!node) return 0; | |
2269 | copyNo = node->GetNumber(); | |
2270 | return node->GetVolume()->GetNumber(); | |
2271 | } | |
2272 | ||
2273 | //______________________________________________________________________________ | |
2274 | const char* TFluka::CurrentVolName() const | |
2275 | { | |
2276 | // | |
2277 | // Return the current volume name | |
2278 | // | |
ab2afdda | 2279 | if (gGeoManager->IsOutside()) return "OutOfWorld"; |
829fb838 | 2280 | return gGeoManager->GetCurrentVolume()->GetName(); |
2281 | } | |
2282 | ||
2283 | //______________________________________________________________________________ | |
2284 | const char* TFluka::CurrentVolOffName(Int_t off) const | |
2285 | { | |
2286 | // | |
2287 | // Return the volume name of the off'th mother of the current volume | |
2288 | // | |
2289 | if (off<0 || off>gGeoManager->GetLevel()) return 0; | |
2290 | if (off==0) return CurrentVolName(); | |
2291 | TGeoNode *node = gGeoManager->GetMother(off); | |
2292 | if (!node) return 0; | |
2293 | return node->GetVolume()->GetName(); | |
2294 | } | |
2295 | ||
d59acfe7 | 2296 | const char* TFluka::CurrentVolPath() { |
2297 | // Return the current volume path | |
2298 | return gGeoManager->GetPath(); | |
2299 | } | |
829fb838 | 2300 | //______________________________________________________________________________ |
a60813de | 2301 | Int_t TFluka::CurrentMaterial(Float_t & a, Float_t & z, |
4aba9d66 | 2302 | Float_t & dens, Float_t & radl, Float_t & absl) const |
829fb838 | 2303 | { |
2304 | // | |
a60813de | 2305 | // Return the current medium number and material properties |
829fb838 | 2306 | // |
2307 | Int_t copy; | |
2308 | Int_t id = TFluka::CurrentVolID(copy); | |
2309 | Int_t med = TFluka::VolId2Mate(id); | |
a60813de | 2310 | TGeoVolume* vol = gGeoManager->GetCurrentVolume(); |
2311 | TGeoMaterial* mat = vol->GetMaterial(); | |
2312 | a = mat->GetA(); | |
2313 | z = mat->GetZ(); | |
2314 | dens = mat->GetDensity(); | |
2315 | radl = mat->GetRadLen(); | |
2316 | absl = mat->GetIntLen(); | |
2317 | ||
829fb838 | 2318 | return med; |
2319 | } | |
2320 | ||
2321 | //______________________________________________________________________________ | |
2322 | void TFluka::Gmtod(Float_t* xm, Float_t* xd, Int_t iflag) | |
2323 | { | |
2324 | // Transforms a position from the world reference frame | |
2325 | // to the current volume reference frame. | |
2326 | // | |
2327 | // Geant3 desription: | |
2328 | // ================== | |
2329 | // Computes coordinates XD (in DRS) | |
2330 | // from known coordinates XM in MRS | |
2331 | // The local reference system can be initialized by | |
2332 | // - the tracking routines and GMTOD used in GUSTEP | |
2333 | // - a call to GMEDIA(XM,NUMED) | |
2334 | // - a call to GLVOLU(NLEVEL,NAMES,NUMBER,IER) | |
2335 | // (inverse routine is GDTOM) | |
2336 | // | |
2337 | // If IFLAG=1 convert coordinates | |
2338 | // IFLAG=2 convert direction cosinus | |
2339 | // | |
2340 | // --- | |
2341 | Double_t xmL[3], xdL[3]; | |
2342 | Int_t i; | |
2343 | for (i=0;i<3;i++) xmL[i]=xm[i]; | |
2344 | if (iflag == 1) gGeoManager->MasterToLocal(xmL,xdL); | |
2345 | else gGeoManager->MasterToLocalVect(xmL,xdL); | |
2346 | for (i=0;i<3;i++) xd[i] = xdL[i]; | |
2347 | } | |
2348 | ||
2349 | //______________________________________________________________________________ | |
2350 | void TFluka::Gmtod(Double_t* xm, Double_t* xd, Int_t iflag) | |
2351 | { | |
2047b055 | 2352 | // |
2353 | // See Gmtod(Float_t*, Float_t*, Int_t) | |
2354 | // | |
829fb838 | 2355 | if (iflag == 1) gGeoManager->MasterToLocal(xm,xd); |
2356 | else gGeoManager->MasterToLocalVect(xm,xd); | |
2357 | } | |
2358 | ||
2359 | //______________________________________________________________________________ | |
2360 | void TFluka::Gdtom(Float_t* xd, Float_t* xm, Int_t iflag) | |
2361 | { | |
2362 | // Transforms a position from the current volume reference frame | |
2363 | // to the world reference frame. | |
2364 | // | |
2365 | // Geant3 desription: | |
2366 | // ================== | |
2367 | // Computes coordinates XM (Master Reference System | |
2368 | // knowing the coordinates XD (Detector Ref System) | |
2369 | // The local reference system can be initialized by | |
2370 | // - the tracking routines and GDTOM used in GUSTEP | |
2371 | // - a call to GSCMED(NLEVEL,NAMES,NUMBER) | |
2372 | // (inverse routine is GMTOD) | |
2373 | // | |
2374 | // If IFLAG=1 convert coordinates | |
2375 | // IFLAG=2 convert direction cosinus | |
2376 | // | |
2377 | // --- | |
2378 | Double_t xmL[3], xdL[3]; | |
2379 | Int_t i; | |
2380 | for (i=0;i<3;i++) xdL[i] = xd[i]; | |
2381 | if (iflag == 1) gGeoManager->LocalToMaster(xdL,xmL); | |
2382 | else gGeoManager->LocalToMasterVect(xdL,xmL); | |
2383 | for (i=0;i<3;i++) xm[i]=xmL[i]; | |
2384 | } | |
2385 | ||
2386 | //______________________________________________________________________________ | |
2387 | void TFluka::Gdtom(Double_t* xd, Double_t* xm, Int_t iflag) | |
2388 | { | |
2047b055 | 2389 | // |
2390 | // See Gdtom(Float_t*, Float_t*, Int_t) | |
2391 | // | |
829fb838 | 2392 | if (iflag == 1) gGeoManager->LocalToMaster(xd,xm); |
2393 | else gGeoManager->LocalToMasterVect(xd,xm); | |
2394 | } | |
2395 | ||
2396 | //______________________________________________________________________________ | |
2397 | TObjArray *TFluka::GetFlukaMaterials() | |
2398 | { | |
2047b055 | 2399 | // |
2400 | // Get array of Fluka materials | |
829fb838 | 2401 | return fGeom->GetMatList(); |
2402 | } | |
2403 | ||
2404 | //______________________________________________________________________________ | |
a9ea1616 | 2405 | void TFluka::SetMreg(Int_t l, Int_t lttc) |
829fb838 | 2406 | { |
2407 | // Set current fluka region | |
2408 | fCurrentFlukaRegion = l; | |
a9ea1616 | 2409 | fGeom->SetMreg(l,lttc); |
829fb838 | 2410 | } |
2411 | ||
2412 | ||
b496f27c | 2413 | |
2414 | ||
4aba9d66 | 2415 | //______________________________________________________________________________ |
b496f27c | 2416 | TString TFluka::ParticleName(Int_t pdg) const |
2417 | { | |
2418 | // Return particle name for particle with pdg code pdg. | |
2419 | Int_t ifluka = IdFromPDG(pdg); | |
ece92b30 | 2420 | return TString((CHPPRP.btype[ifluka - kFLUKAcodemin]), 8); |
b496f27c | 2421 | } |
2422 | ||
2423 | ||
4aba9d66 | 2424 | //______________________________________________________________________________ |
b496f27c | 2425 | Double_t TFluka::ParticleMass(Int_t pdg) const |
2426 | { | |
2427 | // Return particle mass for particle with pdg code pdg. | |
2428 | Int_t ifluka = IdFromPDG(pdg); | |
ece92b30 | 2429 | return (PAPROP.am[ifluka - kFLUKAcodemin]); |
2430 | } | |
2431 | ||
4aba9d66 | 2432 | //______________________________________________________________________________ |
ece92b30 | 2433 | Double_t TFluka::ParticleMassFPC(Int_t fpc) const |
2434 | { | |
2435 | // Return particle mass for particle with Fluka particle code fpc | |
2436 | return (PAPROP.am[fpc - kFLUKAcodemin]); | |
b496f27c | 2437 | } |
2438 | ||
4aba9d66 | 2439 | //______________________________________________________________________________ |
b496f27c | 2440 | Double_t TFluka::ParticleCharge(Int_t pdg) const |
2441 | { | |
2442 | // Return particle charge for particle with pdg code pdg. | |
2443 | Int_t ifluka = IdFromPDG(pdg); | |
ece92b30 | 2444 | return Double_t(PAPROP.ichrge[ifluka - kFLUKAcodemin]); |
b496f27c | 2445 | } |
2446 | ||
4aba9d66 | 2447 | //______________________________________________________________________________ |
b496f27c | 2448 | Double_t TFluka::ParticleLifeTime(Int_t pdg) const |
2449 | { | |
2450 | // Return particle lifetime for particle with pdg code pdg. | |
2451 | Int_t ifluka = IdFromPDG(pdg); | |
ece92b30 | 2452 | return (PAPROP.tmnlf[ifluka - kFLUKAcodemin]); |
b496f27c | 2453 | } |
2454 | ||
4aba9d66 | 2455 | //______________________________________________________________________________ |
b496f27c | 2456 | void TFluka::Gfpart(Int_t pdg, char* name, Int_t& type, Float_t& mass, Float_t& charge, Float_t& tlife) |
2457 | { | |
2458 | // Retrieve particle properties for particle with pdg code pdg. | |
2459 | ||
2460 | strcpy(name, ParticleName(pdg).Data()); | |
2461 | type = ParticleMCType(pdg); | |
2462 | mass = ParticleMass(pdg); | |
2463 | charge = ParticleCharge(pdg); | |
2464 | tlife = ParticleLifeTime(pdg); | |
2465 | } | |
2466 | ||
4aba9d66 | 2467 | //______________________________________________________________________________ |
8e5bf079 | 2468 | void TFluka::PrintHeader() |
2469 | { | |
2470 | // | |
2471 | // Print a header | |
2472 | printf("\n"); | |
2473 | printf("\n"); | |
2474 | printf("------------------------------------------------------------------------------\n"); | |
2475 | printf("- You are using the TFluka Virtual Monte Carlo Interface to FLUKA. -\n"); | |
2476 | printf("- Please see the file fluka.out for FLUKA output and licensing information. -\n"); | |
2477 | printf("------------------------------------------------------------------------------\n"); | |
2478 | printf("\n"); | |
2479 | printf("\n"); | |
2480 | } | |
2481 | ||
b496f27c | 2482 | |
81f1d030 | 2483 | #define pshckp pshckp_ |
2484 | #define ustckv ustckv_ | |
3a625972 | 2485 | |
2486 | ||
2487 | extern "C" { | |
81f1d030 | 2488 | void pshckp(Double_t & px, Double_t & py, Double_t & pz, Double_t & e, |
4aba9d66 | 2489 | Double_t & vx, Double_t & vy, Double_t & vz, Double_t & tof, |
2490 | Double_t & polx, Double_t & poly, Double_t & polz, Double_t & wgt, Int_t& ntr) | |
81f1d030 | 2491 | { |
2492 | // | |
2493 | // Pushes one cerenkov photon to the stack | |
2494 | // | |
2495 | ||
2496 | TFluka* fluka = (TFluka*) gMC; | |
2497 | TVirtualMCStack* cppstack = fluka->GetStack(); | |
2498 | Int_t parent = TRACKR.ispusr[mkbmx2-1]; | |
2499 | cppstack->PushTrack(0, parent, 50000050, | |
4aba9d66 | 2500 | px, py, pz, e, |
2501 | vx, vy, vz, tof, | |
2502 | polx, poly, polz, | |
2503 | kPCerenkov, ntr, wgt, 0); | |
2504 | if (fluka->GetVerbosityLevel() >= 3) | |
2505 | printf("pshckp: track=%d parent=%d lattc=%d %s\n", ntr, parent, TRACKR.lt1trk, fluka->CurrentVolName()); | |
81f1d030 | 2506 | } |
2507 | ||
2508 | void ustckv(Int_t & nphot, Int_t & mreg, Double_t & x, Double_t & y, Double_t & z) | |
7b203b6e | 2509 | { |
4aba9d66 | 2510 | // |
2511 | // Calls stepping in order to signal cerenkov production | |
2512 | // | |
2513 | TFluka *fluka = (TFluka*)gMC; | |
2514 | fluka->SetMreg(mreg, TRACKR.lt1trk); //LTCLCM.mlatm1); | |
2515 | fluka->SetXsco(x); | |
2516 | fluka->SetYsco(y); | |
2517 | fluka->SetZsco(z); | |
2518 | fluka->SetNCerenkov(nphot); | |
2519 | fluka->SetCaller(kUSTCKV); | |
2520 | if (fluka->GetVerbosityLevel() >= 3) | |
2521 | printf("ustckv: %10d mreg=%d lattc=%d newlat=%d (%f, %f, %f) edep=%f vol=%s\n", | |
2522 | nphot, mreg, TRACKR.lt1trk, LTCLCM.newlat, x, y, z, fluka->Edep(), fluka->CurrentVolName()); | |
2523 | ||
2524 | // check region lattice consistency (debug Ernesto) | |
2525 | // ***************************************************** | |
2526 | Int_t nodeId; | |
2527 | Int_t volId = fluka->CurrentVolID(nodeId); | |
2528 | Int_t crtlttc = gGeoManager->GetCurrentNodeId()+1; | |
2529 | ||
2530 | if( mreg != volId && !gGeoManager->IsOutside() ) { | |
2531 | cout << " ustckv: track=" << TRACKR.ispusr[mkbmx2-1] << " pdg=" << fluka->PDGFromId(TRACKR.jtrack) | |
2532 | << " icode=" << fluka->GetIcode() << " gNstep=" << fluka->GetNstep() << endl | |
2533 | << " fluka mreg=" << mreg << " mlttc=" << TRACKR.lt1trk << endl | |
2534 | << " TGeo volId=" << volId << " crtlttc=" << crtlttc << endl | |
2535 | << " common TRACKR lt1trk=" << TRACKR.lt1trk << " lt2trk=" << TRACKR.lt2trk << endl | |
2536 | << " common LTCLCM newlat=" << LTCLCM.newlat << " mlatld=" << LTCLCM.mlatld << endl | |
2537 | << " mlatm1=" << LTCLCM.mlatm1 << " mltsen=" << LTCLCM.mltsen << endl | |
2538 | << " mltsm1=" << LTCLCM.mltsm1 << " mlattc=" << LTCLCM.mlattc << endl; | |
2539 | if( TRACKR.lt1trk == crtlttc ) cout << " *************************************************************" << endl; | |
2540 | } | |
2541 | // ***************************************************** | |
2542 | ||
2543 | ||
2544 | ||
2545 | (TVirtualMCApplication::Instance())->Stepping(); | |
7b203b6e | 2546 | } |
3a625972 | 2547 | } |
a9ea1616 | 2548 | |
4aba9d66 | 2549 | //______________________________________________________________________________ |
78df7be0 | 2550 | void TFluka::AddParticlesToPdgDataBase() const |
2551 | { | |
2552 | ||
2553 | // | |
2554 | // Add particles to the PDG data base | |
2555 | ||
2556 | TDatabasePDG *pdgDB = TDatabasePDG::Instance(); | |
2557 | ||
78df7be0 | 2558 | const Double_t kAu2Gev = 0.9314943228; |
2559 | const Double_t khSlash = 1.0545726663e-27; | |
2560 | const Double_t kErg2Gev = 1/1.6021773349e-3; | |
2561 | const Double_t khShGev = khSlash*kErg2Gev; | |
2562 | const Double_t kYear2Sec = 3600*24*365.25; | |
2563 | // | |
2564 | // Ions | |
2565 | // | |
78df7be0 | 2566 | pdgDB->AddParticle("Deuteron","Deuteron",2*kAu2Gev+8.071e-3,kTRUE, |
13858fbd | 2567 | 0,3,"Ion",GetIonPdg(1,2)); |
78df7be0 | 2568 | pdgDB->AddParticle("Triton","Triton",3*kAu2Gev+14.931e-3,kFALSE, |
13858fbd | 2569 | khShGev/(12.33*kYear2Sec),3,"Ion",GetIonPdg(1,3)); |
78df7be0 | 2570 | pdgDB->AddParticle("Alpha","Alpha",4*kAu2Gev+2.424e-3,kTRUE, |
13858fbd | 2571 | khShGev/(12.33*kYear2Sec),6,"Ion",GetIonPdg(2,4)); |
78df7be0 | 2572 | pdgDB->AddParticle("HE3","HE3",3*kAu2Gev+14.931e-3,kFALSE, |
13858fbd | 2573 | 0,6,"Ion",GetIonPdg(2,3)); |
cee6a756 | 2574 | // |
2575 | // | |
2576 | // | |
2577 | // Special particles | |
2578 | // | |
2579 | pdgDB->AddParticle("Cherenkov","Cherenkov",0,kFALSE, | |
2580 | 0,0,"Special",GetSpecialPdg(50)); | |
2581 | pdgDB->AddParticle("FeedbackPhoton","FeedbackPhoton",0,kFALSE, | |
2582 | 0,0,"Special",GetSpecialPdg(51)); | |
78df7be0 | 2583 | } |
2584 | ||
ca01d0af | 2585 | void TFluka::AddIon(Int_t a, Int_t z) const |
2586 | { | |
2587 | ||
2588 | // Add a new ion | |
2589 | TDatabasePDG *pdgDB = TDatabasePDG::Instance(); | |
2590 | const Double_t kAu2Gev = 0.9314943228; | |
2591 | Int_t pdg = GetIonPdg(z, a); | |
2592 | if (pdgDB->GetParticle(pdg)) return; | |
2593 | ||
2594 | pdgDB->AddParticle(Form("Iion A = %5d Z = %5d", a, z),"Ion", Float_t(a) * kAu2Gev + 8.071e-3, kTRUE, | |
2595 | 0, 3 * z, "Ion", pdg); | |
2596 | } | |
2597 | ||
4aba9d66 | 2598 | // |
2599 | // Info about primary ionization electrons | |
2600 | // | |
2601 | ||
2602 | //______________________________________________________________________________ | |
2603 | Int_t TFluka::GetNPrimaryElectrons() | |
f2a98602 | 2604 | { |
2605 | // Get number of primary electrons | |
2606 | return ALLDLT.nalldl; | |
2607 | } | |
2608 | ||
4aba9d66 | 2609 | //______________________________________________________________________________ |
5125d6e5 | 2610 | Double_t TFluka::GetPrimaryElectronKineticEnergy(Int_t i) const |
f2a98602 | 2611 | { |
2612 | // Returns kinetic energy of primary electron i | |
5125d6e5 | 2613 | |
2614 | Double_t ekin = -1.; | |
ea262cc6 | 2615 | |
f2a98602 | 2616 | if (i >= 0 && i < ALLDLT.nalldl) { |
6c854012 | 2617 | ekin = ALLDLT.talldl[i]; |
f2a98602 | 2618 | } else { |
4aba9d66 | 2619 | Warning("GetPrimaryElectronKineticEnergy", |
2620 | "Primary electron index out of range %d %d \n", | |
2621 | i, ALLDLT.nalldl); | |
f2a98602 | 2622 | } |
f0734960 | 2623 | return ekin; |
f2a98602 | 2624 | } |
5125d6e5 | 2625 | |
15a8a899 | 2626 | void TFluka::GetPrimaryElectronPosition(Int_t i, Double_t& x, Double_t& y, Double_t& z, Double_t& t) const |
5125d6e5 | 2627 | { |
2628 | // Returns position of primary electron i | |
2629 | if (i >= 0 && i < ALLDLT.nalldl) { | |
6c854012 | 2630 | x = ALLDLT.xalldl[i]; |
2631 | y = ALLDLT.yalldl[i]; | |
2632 | z = ALLDLT.zalldl[i]; | |
15a8a899 | 2633 | t = ALLDLT.talldl[i]; |
5125d6e5 | 2634 | return; |
2635 | } else { | |
2636 | Warning("GetPrimaryElectronPosition", | |
2637 | "Primary electron index out of range %d %d \n", | |
2638 | i, ALLDLT.nalldl); | |
2639 | return; | |
2640 | } | |
2641 | return; | |
2642 | } | |
2643 | ||
13858fbd | 2644 | Int_t TFluka::GetIonPdg(Int_t z, Int_t a, Int_t i) const |
2645 | { | |
2646 | // Acording to | |
2647 | // http://cepa.fnal.gov/psm/stdhep/pdg/montecarlorpp-2006.pdf | |
5125d6e5 | 2648 | |
13858fbd | 2649 | return 1000000000 + 10*1000*z + 10*a + i; |
2650 | } | |
cee6a756 | 2651 | |
2652 | //__________________________________________________________________ | |
2653 | Int_t TFluka::GetSpecialPdg(Int_t number) const | |
2654 | { | |
2655 | // Numbering for special particles | |
2656 | ||
2657 | return 50000000 + number; | |
2658 | } | |
2659 | ||
13858fbd | 2660 | |
ea262cc6 | 2661 | void TFluka::PrimaryIonisationStepping(Int_t nprim) |
2662 | { | |
2663 | // Call Stepping for primary ionisation electrons | |
2664 | Int_t i; | |
2665 | // Protection against nprim > mxalld | |
2666 | ||
2667 | // Multiple steps for nprim > 0 | |
2668 | if (nprim > 0) { | |
2669 | for (i = 0; i < nprim; i++) { | |
2670 | SetCurrentPrimaryElectronIndex(i); | |
2671 | (TVirtualMCApplication::Instance())->Stepping(); | |
2672 | if (i == 0) SetTrackIsNew(kFALSE); | |
2673 | } | |
2674 | } else { | |
2675 | // No primary electron ionisation | |
2676 | // Call Stepping anyway but flag nprim = 0 as index = -2 | |
2677 | SetCurrentPrimaryElectronIndex(-2); | |
2678 | (TVirtualMCApplication::Instance())->Stepping(); | |
2679 | } | |
2680 | // Reset the index | |
2681 | SetCurrentPrimaryElectronIndex(-1); | |
2682 | } | |
b6a89226 | 2683 | |
2684 | //______________________________________________________________________ | |
2685 | Float_t* TFluka::CreateFloatArray(Double_t* array, Int_t size) const | |
2686 | { | |
2687 | // Converts Double_t* array to Float_t*, | |
2688 | // !! The new array has to be deleted by user. | |
2689 | // --- | |
2690 | ||
2691 | Float_t* floatArray; | |
2692 | if (size>0) { | |
2693 | floatArray = new Float_t[size]; | |
2694 | for (Int_t i=0; i<size; i++) | |
2695 | if (array[i] >= FLT_MAX ) | |
2696 | floatArray[i] = FLT_MAX/100.; | |
2697 | else | |
2698 | floatArray[i] = array[i]; | |
2699 | } | |
2700 | else { | |
2701 | //floatArray = 0; | |
2702 | floatArray = new Float_t[1]; | |
2703 | } | |
2704 | return floatArray; | |
2705 | } |