Mechanism for interruption and resuming of transport after secondary tracking.
[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);
28 if (icode == 11) {
2bc4c610 29 if (debug) cout << " For icode=" << icode << " Stepping is NOT called" << endl;
4b81a588 30 return;
31 }
df14e7fb 32 if (TRACKR.jtrack == -1) {
33// Handle quantum efficiency the G3 way
2bc4c610 34 if (debug) printf("endraw: Cerenkov photon depositing energy: %d %e\n", mreg, rull);
df14e7fb 35 TGeoMaterial* material = (gGeoManager->GetCurrentVolume())->GetMaterial();
2bc4c610 36 // Int_t nmat = material->GetIndex();
df14e7fb 37 TFlukaCerenkov* cerenkov = dynamic_cast<TFlukaCerenkov*> (material->GetCerenkovProperties());
38 if (cerenkov) {
39 Double_t eff = (cerenkov->GetQuantumEfficiency(rull));
40 if (gRandom->Rndm() > eff) {
41 rull = 0.;
42 fluka->SetRull(rull);
43 }
44 }
45 }
2bc78182 46 if (debug) printf("endraw: Depositing energy for : %d %e icode: %d \n", TRACKR.ispusr[mkbmx2-1], rull, icode);
47
7dac99f1 48 (TVirtualMCApplication::Instance())->Stepping();
2bc78182 49 //
50 // for icode 21,22 the particle has fallen below thresshold
51 // This has to be signalled to the StepManager()
52 //
fbf08100 53 fluka->SetTrackIsNew(kFALSE);
2bc78182 54 fluka->SetIcode(icode);
55 (TVirtualMCApplication::Instance())->Stepping();
56
fa3d1cc7 57} // end of endraw
58} // end of extern "C"
59