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