FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairRadGridManager.cxx
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 // -------------------------------------------------------------------------
9 // ----- FairRadLenManager source file -----
10 // ----- original author D.Bertini -----
11 // ----- adapted april 2010 O.Hartmann -----
12 // -------------------------------------------------------------------------
13 
14 #include "FairRadGridManager.h"
15 
16 #include "FairMesh.h"
17 #include "FairRootManager.h"
18 
19 #include <TParticle.h>
20 #include <TVirtualMC.h>
21 
23 
24 FairRadGridManager* FairRadGridManager::fgInstance = nullptr;
25 
26 Double_t FairRadGridManager::fLtmp = 0.0;
27 
29 {
31  return fgInstance;
32 }
33 
35  : fPointCollection(nullptr)
36  , fTrackID(0)
37  , fVolumeID(0)
38  , fPosIn(TLorentzVector(0, 0, 0, 0))
39  , fPosOut(TLorentzVector(0, 0, 0, 0))
40  , fMomIn(TLorentzVector(0, 0, 0, 0))
41  , fMomOut(TLorentzVector(0, 0, 0, 0))
42  , fTime(0)
43  , fLength(0)
44  , fELoss(0)
45  , fA(0)
46  , fZmat(0)
47  , fDensity(0)
48  , fRadl(0)
49  , fAbsl(0)
50  , fEstimator(0)
51  , fMeshList(nullptr)
52  , fOutputFileName("radGridManager.root")
53 {
55  if (nullptr == fgInstance) {
56  fgInstance = this;
57  }
58  fLtmp = 0;
59 }
60 
62 {
64  fgInstance = nullptr;
65 }
66 
68 {
69  // fMeshList = new TObjArray();
70 }
71 
73 {
74  // No free of memory ?
75  // fMesh->Reset();
76 }
77 
79 {
80 
82  TParticle* part = TVirtualMC::GetMC()->GetStack()->GetCurrentTrack();
83  fTrackID = TVirtualMC::GetMC()->GetStack()->GetCurrentTrackNumber();
84  TVirtualMC::GetMC()->TrackPosition(fPosIn);
85  TVirtualMC::GetMC()->TrackMomentum(fMomIn);
86  fELoss = 0.;
87  // Int_t MatId= TVirtualMC::GetMC()->CurrentMaterial(fA, fZmat, fDensity, fRadl, fAbsl);
88 
90  for (Int_t i = 0; i < fMeshList->GetEntriesFast(); i++) {
91  FairMesh* aMesh = static_cast<FairMesh*>(fMeshList->At(i));
92  Double_t fBinVolume = aMesh->GetBinVolume();
93  Double_t fDiag = aMesh->GetDiag();
94 
95  // Geometry bound test
96  if (IsTrackInside(fPosIn, aMesh)) {
97  fELoss = TVirtualMC::GetMC()->Edep();
98  // cout << "-I- track (" << fTrackID << ") is inside " << endl;
99  // cout << " E deposited is " << fELoss << endl;
100  TVirtualMC::GetMC()->TrackPosition(fPosOut);
101  TVirtualMC::GetMC()->TrackMomentum(fMomOut);
102 
103  // Now cumulate fEloss (Gev/cm3)
104  // and normalize it to the mesh volume
105 
106  // 1 estimator Edep
107  fELoss = fELoss / fBinVolume;
108  // 2 estimator TrackLengh
109  fLength = TVirtualMC::GetMC()->TrackStep();
110  // fill TID
111 
112  aMesh->fillTID(fPosOut.X(), fPosOut.Y(), fELoss);
113  // fill total Fluence
114  if (fLength < 5 * fDiag) {
115 
116  fLength = fLength / fBinVolume;
117  aMesh->fillFluence(fPosOut.X(), fPosOut.Y(), fLength);
118 
119  // fill SEU
120  if (part->P() > 0.02) {
121  aMesh->fillSEU(fPosOut.X(), fPosOut.Y(), fLength);
122  }
123  }
124  }
125  }
126 }
127 
128 Bool_t FairRadGridManager::IsTrackEntering(TLorentzVector&, TLorentzVector&)
129 {
130  // assume for the moment vertical scoring planes
131  // cout << " is entering diagnosis " << endl;
132  // cout << " Z pos " << pos.Z() << endl;
133  // cout << " Zmin " << fZmin << endl;
134  // cout << " diff " << pos.Z()-fZmin << endl;
135 
136  // if ( (( TMath::Abs(pos.Z() - fZmin) ) < 1.0e-06 )
137  // &&
138  // ( mom.Z() > 0 )
139  // ) return kTRUE;
140  // else
141  // return kFALSE;
142 
143  return kFALSE;
144 }
145 
146 Bool_t FairRadGridManager::IsTrackInside(TLorentzVector& pos, FairMesh* aMesh)
147 {
148  // check if inside volume
149  if ((pos.X() >= aMesh->GetXmin()) && (pos.X() <= aMesh->GetXmax()) && (pos.Y() >= aMesh->GetYmin())
150  && (pos.Y() <= aMesh->GetYmax()) && (pos.Z() >= aMesh->GetZmin()) && (pos.Z() <= aMesh->GetZmax())) {
151  /* cout << " inside Xpos: " << pos.X() << " Xmin: " << aMesh->GetXmin()
152  << " Xmax: " << aMesh->GetXmax() << endl;
153  cout << " inside Ypos: " << pos.Y() << " Ymin: " << aMesh->GetYmin()
154  << " Ymax: " << aMesh->GetYmax() << endl;
155  cout << " inside Zpos: " << pos.Z() << " Zmin: "
156  << aMesh->GetZmin() << " Zmax: " << aMesh->GetZmax() << endl;
157  */
158  return kTRUE;
159  } else {
160  return kFALSE;
161  }
162 }
Double_t GetYmin() const
Definition: FairMesh.h:38
static FairRadGridManager * Instance()
Double_t GetYmax() const
Definition: FairMesh.h:42
Bool_t IsTrackInside(TLorentzVector &vec, FairMesh *aMesh)
void fillTID(Double_t x, Double_t y, Double_t we)
Definition: FairMesh.h:74
ClassImp(FairEventBuilder)
Double_t GetXmin() const
Definition: FairMesh.h:37
Double_t GetZmin() const
Definition: FairMesh.h:39
Double_t GetBinVolume()
Definition: FairMesh.h:72
Double_t GetZmax() const
Definition: FairMesh.h:43
void fillSEU(Double_t x, Double_t y, Double_t we)
Definition: FairMesh.h:76
Double_t GetXmax() const
Definition: FairMesh.h:41
void fillFluence(Double_t x, Double_t y, Double_t we)
Definition: FairMesh.h:75
Bool_t IsTrackEntering(TLorentzVector &vec1, TLorentzVector &vec2)
Double_t GetDiag()
Definition: FairMesh.h:71