]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TFluka/endraw.cxx
Quantum efficiency implemented by setting energy deposition to zero to flag inefficiency.
[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 #ifndef WITH_ROOT
8 #include "TFluka.h"
9 #else
10 #include "TFlukaGeo.h"
11 #endif
12
13 #include "Fdimpar.h"  //(DIMPAR) fluka include
14 #include "Ftrackr.h"  //(TRACKR) fluka common
15 #ifndef WIN32
16 # define endraw endraw_
17 #else
18 # define endraw ENDRAW
19 #endif
20 extern "C" {
21 void endraw(Int_t& icode, Int_t& mreg, Double_t& rull, Double_t& xsco, Double_t& ysco, Double_t& zsco)
22 {
23   TFluka* fluka = (TFluka*) gMC;
24   fluka->SetCaller(3);
25   fluka->SetIcode(icode);
26   fluka->SetRull(rull);
27   fluka->SetXsco(xsco);
28   fluka->SetYsco(ysco);
29   fluka->SetZsco(zsco);
30   fluka->SetMreg(mreg);
31   if (icode == 11) {
32     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       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               rull = 0.;
45               fluka->SetRull(rull);
46           }
47       }
48   }
49   (TVirtualMCApplication::Instance())->Stepping();
50   fluka->SetTrackIsNew(kFALSE);
51 } // end of endraw
52 } // end of extern "C"
53