]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TFluka/endraw.cxx
Adding Set/Get methods for trigger pattern
[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 #include "TFlukaCodes.h"
9
10 #include "Fdimpar.h"  //(DIMPAR) fluka include
11 #include "Ftrackr.h"  //(TRACKR) fluka common
12 #include "Fltclcm.h"  //(LTCLCM) fluka common
13 #include "Fpaprop.h"  //(PAPROP) fluka common
14 #ifndef WIN32
15 # define endraw endraw_
16 #else
17 # define endraw ENDRAW
18 #endif
19 extern "C" {
20 void endraw(Int_t& icode, Int_t& mreg, Double_t& rull, Double_t& xsco, Double_t& ysco, Double_t& zsco)
21 {
22   TFluka* fluka = (TFluka*) gMC;
23   // nothing to do if particle in dummy region
24   if (mreg == fluka->GetDummyRegion()) return;
25   Int_t verbosityLevel = fluka->GetVerbosityLevel();
26   Bool_t debug = (verbosityLevel >= 3)? kTRUE : kFALSE;
27   Int_t mlttc = LTCLCM.mlatm1;
28   fluka->SetCaller(kENDRAW);
29   fluka->SetRull(rull);
30   fluka->SetXsco(xsco);
31   fluka->SetYsco(ysco);
32   fluka->SetZsco(zsco);
33   fluka->SetMreg(mreg, mlttc);
34   
35   Float_t edep = rull;
36   
37   if (icode == kKASKADinelarecoil) {
38     if (debug) cout << " For icode=" << icode << " Stepping is NOT called" << endl;
39     return;
40   }
41
42   if (TRACKR.jtrack == -1) {
43 // Handle quantum efficiency the G3 way
44       if (debug) printf("endraw: Cerenkov photon depositing energy: %d %e\n", mreg, rull);
45       TGeoMaterial* material = (gGeoManager->GetCurrentVolume())->GetMaterial();
46       TFlukaCerenkov*  cerenkov = dynamic_cast<TFlukaCerenkov*> (material->GetCerenkovProperties());
47       if (cerenkov) {
48           Double_t eff = (cerenkov->GetQuantumEfficiency(rull));
49           if (gRandom->Rndm() > eff) {
50               edep = 0.;
51           }
52       }
53   }
54
55   if (icode != kEMFSCOstopping1 && icode != kEMFSCOstopping2) {
56       fluka->SetIcode((FlukaProcessCode_t)icode);
57       fluka->SetRull(edep);
58       (TVirtualMCApplication::Instance())->Stepping();
59   } else {
60   //
61   // For icode 21,22 the particle has fallen below thresshold.
62   // This has to be signalled to the StepManager() 
63   //
64       fluka->SetRull(edep);
65       fluka->SetIcode((FlukaProcessCode_t) icode);
66       (TVirtualMCApplication::Instance())->Stepping();
67       fluka->SetTrackIsNew(kFALSE);
68       fluka->SetIcode((FlukaProcessCode_t)icode);
69       fluka->SetRull(0.);
70       (TVirtualMCApplication::Instance())->Stepping();
71   }
72 } // end of endraw
73 } // end of extern "C"
74