]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TFluka/endraw.cxx
beam replaced by beamcm
[u/mrichter/AliRoot.git] / TFluka / endraw.cxx
CommitLineData
fa3d1cc7 1#include <Riostream.h>
8fd1d27e 2#include "TVirtualMCApplication.h"
df14e7fb 3#include "TGeoMaterial.h"
4#include "TGeoManager.h"
5#include "TFlukaCerenkov.h"
a7bb59a2 6
fa3d1cc7 7#include "TFluka.h"
a7bb59a2 8
7dac99f1 9#include "Fdimpar.h" //(DIMPAR) fluka include
10#include "Ftrackr.h" //(TRACKR) fluka common
fa3d1cc7 11#ifndef WIN32
12# define endraw endraw_
13#else
14# define endraw ENDRAW
15#endif
16extern "C" {
17void endraw(Int_t& icode, Int_t& mreg, Double_t& rull, Double_t& xsco, Double_t& ysco, Double_t& zsco)
18{
4b81a588 19 TFluka* fluka = (TFluka*) gMC;
2bc4c610 20 Int_t verbosityLevel = fluka->GetVerbosityLevel();
2bc78182 21 Bool_t debug = (verbosityLevel >= 3)? kTRUE : kFALSE;
4b81a588 22 fluka->SetCaller(3);
4b81a588 23 fluka->SetRull(rull);
24 fluka->SetXsco(xsco);
25 fluka->SetYsco(ysco);
26 fluka->SetZsco(zsco);
27 fluka->SetMreg(mreg);
022d4275 28
29 Float_t edep = rull;
30
4b81a588 31 if (icode == 11) {
2bc4c610 32 if (debug) cout << " For icode=" << icode << " Stepping is NOT called" << endl;
4b81a588 33 return;
34 }
df14e7fb 35 if (TRACKR.jtrack == -1) {
36// Handle quantum efficiency the G3 way
2bc4c610 37 if (debug) printf("endraw: Cerenkov photon depositing energy: %d %e\n", mreg, rull);
df14e7fb 38 TGeoMaterial* material = (gGeoManager->GetCurrentVolume())->GetMaterial();
2bc4c610 39 // Int_t nmat = material->GetIndex();
df14e7fb 40 TFlukaCerenkov* cerenkov = dynamic_cast<TFlukaCerenkov*> (material->GetCerenkovProperties());
41 if (cerenkov) {
42 Double_t eff = (cerenkov->GetQuantumEfficiency(rull));
43 if (gRandom->Rndm() > eff) {
022d4275 44 edep = 0.;
df14e7fb 45 }
46 }
47 }
2bc78182 48 if (debug) printf("endraw: Depositing energy for : %d %e icode: %d \n", TRACKR.ispusr[mkbmx2-1], rull, icode);
49
022d4275 50 if (icode != 21 && icode != 22) {
a5b73d69 51 fluka->SetIcode(icode);
022d4275 52 fluka->SetRull(edep);
53 (TVirtualMCApplication::Instance())->Stepping();
54 } else {
2bc78182 55 //
56 // for icode 21,22 the particle has fallen below thresshold
57 // This has to be signalled to the StepManager()
58 //
a5b73d69 59 fluka->SetRull(edep);
60 fluka->SetIcode(20);
022d4275 61 (TVirtualMCApplication::Instance())->Stepping();
62 fluka->SetTrackIsNew(kFALSE);
63 fluka->SetIcode(icode);
a5b73d69 64 fluka->SetRull(0.);
022d4275 65 (TVirtualMCApplication::Instance())->Stepping();
66 }
fa3d1cc7 67} // end of endraw
68} // end of extern "C"
69