EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairRadGridManager.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairRadGridManager.cxx
1 // -------------------------------------------------------------------------
2 // ----- FairRadLenManager source file -----
3 // ----- original author D.Bertini -----
4 // ----- adapted april 2010 O.Hartmann -----
5 // -------------------------------------------------------------------------
6 
7 
8 #include <iostream>
9 #include "FairRadGridManager.h"
10 #include "FairRootManager.h"
11 #include "TLorentzVector.h"
12 #include "TParticle.h"
13 #include "TVirtualMC.h"
14 #include "FairMesh.h"
15 
16 using namespace std;
17 
19 
20 FairRadGridManager* FairRadGridManager::fgInstance = NULL;
21 
22 Double_t FairRadGridManager::fLtmp = 0.0 ;
23 
25 {
27  return fgInstance;
28 }
29 
31  : fPointCollection(NULL),
32  fTrackID(0),
33  fVolumeID(0),
34  fPosIn(TLorentzVector(0,0,0,0)),
35  fPosOut(TLorentzVector(0,0,0,0)),
36  fMomIn(TLorentzVector(0,0,0,0)),
37  fMomOut(TLorentzVector(0,0,0,0)),
38  fTime(0),
39  fLength(0),
40  fELoss(0),
41  fA(0),
42  fZmat(0),
43  fDensity(0),
44  fRadl(0),
45  fAbsl(0),
46  fEstimator(0),
47  fMeshList(NULL)
48 {
50  if(NULL == fgInstance) {
51  fgInstance = this;
52  }
53  fLtmp=0;
54 }
55 
57 {
59  fgInstance = NULL;
60 }
61 
63 {
64 // fMeshList = new TObjArray();
65 }
66 
68 {
69  // No free of memory ?
70  // fMesh->Reset();
71 }
72 
74 {
75 
77  TParticle* part = gMC->GetStack()->GetCurrentTrack();
78  fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
79  gMC->TrackPosition(fPosIn);
80  gMC->TrackMomentum(fMomIn);
81  fELoss = 0.;
82 // Int_t MatId= gMC->CurrentMaterial(fA, fZmat, fDensity, fRadl, fAbsl);
83 
85  for (Int_t i=0; i<fMeshList->GetEntriesFast(); i++ ) {
86  FairMesh* aMesh = (FairMesh*) fMeshList->At(i);
87  Double_t fBinVolume = aMesh->GetBinVolume();
88  Double_t fDiag = aMesh->GetDiag();
89 
90  // Geometry bound test
91  if ( IsTrackInside(fPosIn,aMesh) ) {
92  fELoss = gMC->Edep();
93  //cout << "-I- track (" << fTrackID << ") is inside " << endl;
94  //cout << " E deposited is " << fELoss << endl;
95  gMC->TrackPosition(fPosOut);
96  gMC->TrackMomentum(fMomOut);
97 
98  // Now cumulate fEloss (Gev/cm3)
99  // and normalize it to the mesh volume
100 
101  // 1 estimator Edep
102  fELoss = fELoss/fBinVolume;
103  // 2 estimator TrackLengh
104  fLength = gMC->TrackStep();
105  // fill TID
106 
107  aMesh->fillTID(fPosOut.X(),fPosOut.Y(),fELoss);
108  // fill total Fluence
109  if ( fLength < 5*fDiag ) {
110 
111  fLength = fLength/fBinVolume;
112  aMesh->fillFluence(fPosOut.X(),fPosOut.Y(),fLength);
113 
114  // fill SEU
115  if ( part->P() > 0.02 ) {
116  aMesh->fillSEU(fPosOut.X(),fPosOut.Y(),fLength);
117  }
118  }
119 
120  }
121 
122  }
123 }
124 
125 #include <assert.h>
126 
127 Bool_t FairRadGridManager::IsTrackEntering(TLorentzVector& pos ,
128  TLorentzVector& mom )
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 
137  // if ( (( TMath::Abs(pos.Z() - fZmin) ) < 1.0e-06 )
138  // &&
139  // ( mom.Z() > 0 )
140  // ) return kTRUE;
141  // else
142  // return kFALSE;
143 
144  // AYK, 2016/07/13 -> need to make Mac OS X compiler happy (silent); this is indeed
145  // a bug, so prefer to assert(0) here just in case somebody ever wants to use this
146  // code under EicRoot;
147  assert(0);
148 }
149 
150 Bool_t FairRadGridManager::IsTrackInside(TLorentzVector& pos , FairMesh* aMesh)
151 {
152  // check if inside volume
153  if ( (pos.X() >= aMesh->GetXmin()) && (pos.X() <= aMesh->GetXmax())
154  &&
155  (pos.Y() >= aMesh->GetYmin()) && (pos.Y() <= aMesh->GetYmax())
156  &&
157  (pos.Z() >= aMesh->GetZmin()) && (pos.Z() <= aMesh->GetZmax())
158  ) {
159  /* cout << " inside Xpos: " << pos.X() << " Xmin: " << aMesh->GetXmin()
160  << " Xmax: " << aMesh->GetXmax() << endl;
161  cout << " inside Ypos: " << pos.Y() << " Ymin: " << aMesh->GetYmin()
162  << " Ymax: " << aMesh->GetYmax() << endl;
163  cout << " inside Zpos: " << pos.Z() << " Zmin: "
164  << aMesh->GetZmin() << " Zmax: " << aMesh->GetZmax() << endl;
165  */
166  return kTRUE;
167  } else {
168  return kFALSE;
169  }
170 }