]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TFluka/endraw.cxx
Update of the class ESDMuonFilter. New marcros for creating AOD with muon information...
[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 <TParticle.h>
6 #include "TFlukaCerenkov.h"
7
8 #include "TFluka.h"
9 #include "TFlukaCodes.h"
10
11 #include "Fdimpar.h"  //(DIMPAR) fluka include
12 #include "Ftrackr.h"  //(TRACKR) fluka common
13 #include "Fltclcm.h"  //(LTCLCM) fluka common
14 #include "Fpaprop.h"  //(PAPROP) fluka common
15 #include "Fopphst.h"  //(OPPHST) fluka common
16
17 #ifndef WIN32
18 # define endraw endraw_
19 #else
20 # define endraw ENDRAW
21 #endif
22 extern "C" {
23 void endraw(Int_t& icode, Int_t& mreg, Double_t& rull, Double_t& xsco, Double_t& ysco, Double_t& zsco)
24 {
25   TFluka* fluka = (TFluka*) gMC;
26   // nothing to do if particle in dummy region
27   if (mreg == fluka->GetDummyRegion()) return;
28   Int_t verbosityLevel = fluka->GetVerbosityLevel();
29   Bool_t debug = (verbosityLevel >= 3)? kTRUE : kFALSE;
30   Int_t mlttc = (icode==kKASKADinelarecoil) ? TRACKR.lt2trk : TRACKR.lt1trk; //LTCLCM.mlatm1;
31   fluka->SetCaller(kENDRAW);
32   fluka->SetRull(rull);
33   fluka->SetXsco(xsco);
34   fluka->SetYsco(ysco);
35   fluka->SetZsco(zsco);
36   fluka->SetMreg(mreg, mlttc);
37
38   Float_t edep = rull;
39   Int_t ipt = fluka->PDGFromId(TRACKR.jtrack);
40   if (ipt == -1) {
41       if (debug) printf("Unknown particle %5d %5d \n", TRACKR.jtrack, icode);
42       return;
43   }
44   
45   if (TRACKR.jtrack == -1) {
46   // Handle quantum efficiency the G3 way
47       if (debug) printf("endraw: Cerenkov photon depositing energy: %d %e\n", mreg, rull);
48       TGeoMaterial* material = (gGeoManager->GetCurrentVolume())->GetMaterial();
49       TFlukaCerenkov*  cerenkov = dynamic_cast<TFlukaCerenkov*> (material->GetCerenkovProperties());
50       if (cerenkov) {
51           Double_t eff = (cerenkov->GetQuantumEfficiency(rull));
52           if (gRandom->Rndm() > eff) {
53               edep = 0.;
54           }
55       }
56   }
57
58   TVirtualMCStack* cppstack = fluka->GetStack();
59
60   if (debug) {
61      cout << "ENDRAW For icode=" << icode 
62           << " track=" << TRACKR.ispusr[mkbmx2-1] << " pdg=" << fluka->PDGFromId(TRACKR.jtrack)
63           << " edep="<< edep << " mreg=" << mreg << endl;
64   }
65
66     // check region lattice consistency (debug Ernesto)
67     // *****************************************************
68     Int_t nodeId;
69     Int_t volId = fluka->CurrentVolID(nodeId);
70     Int_t crtlttc = gGeoManager->GetCurrentNodeId()+1;
71     if(debug && mreg != volId  && !gGeoManager->IsOutside() ) {
72        cout << "  endraw:   track=" << TRACKR.ispusr[mkbmx2-1] << " pdg=" << fluka->PDGFromId(TRACKR.jtrack)
73             << " icode=" << icode << " gNstep=" << fluka->GetNstep() << endl
74             << "               fluka   mreg=" << mreg << " mlttc=" << mlttc << endl
75             << "               TGeo   volId=" << volId << " crtlttc=" << crtlttc << endl
76             << "     common TRACKR   lt1trk=" << TRACKR.lt1trk << " lt2trk=" << TRACKR.lt2trk << endl
77             << "     common LTCLCM   newlat=" << LTCLCM.newlat << " mlatld=" <<  LTCLCM.mlatld << endl
78             << "                     mlatm1=" << LTCLCM.mlatm1 << " mltsen=" <<  LTCLCM.mltsen << endl
79             << "                     mltsm1=" << LTCLCM.mltsm1 << " mlattc=" << LTCLCM.mlattc << endl;
80         if( mlttc == crtlttc ) cout << "   *************************************************************" << endl;
81     }
82     // *****************************************************
83   if (icode != kEMFSCOstopping1 && icode != kEMFSCOstopping2) {
84       fluka->SetIcode((FlukaProcessCode_t)icode);
85       fluka->SetRull(edep);
86       if (icode == kKASKADelarecoil && TRACKR.ispusr[mkbmx2-5]) {
87           //  Elastic recoil and in stuprf npprmr > 0,
88           //  the secondary being loaded is actually still the interacting particle
89           cppstack->SetCurrentTrack( TRACKR.ispusr[mkbmx2-4] );
90       } else if (TRACKR.jtrack == -1) {
91           cppstack->SetCurrentTrack(OPPHST.louopp[OPPHST.lstopp]);
92       } else {
93           cppstack->SetCurrentTrack(TRACKR.ispusr[mkbmx2-1] );
94       }
95
96       (TVirtualMCApplication::Instance())->Stepping();
97       
98   } else {
99   //
100   // For icode 21,22 the particle has fallen below thresshold.
101   // This has to be signalled to the StepManager() 
102   //
103       cppstack->SetCurrentTrack( TRACKR.ispusr[mkbmx2-1] );
104       
105       fluka->SetRull(edep);
106       fluka->SetIcode((FlukaProcessCode_t) icode);
107       (TVirtualMCApplication::Instance())->Stepping();
108       fluka->SetTrackIsNew(kFALSE);
109 //      fluka->SetIcode((FlukaProcessCode_t)icode);
110 //      fluka->SetRull(0.);
111 //      (TVirtualMCApplication::Instance())->Stepping();
112   }
113 } // end of endraw
114 } // end of extern "C"
115