EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairRadLenManager.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairRadLenManager.cxx
1 // -------------------------------------------------------------------------
2 // ----- FairRadLenManager source file -----
3 // ----- Created 14/01/08 by M. Al-Turany -----
4 // -------------------------------------------------------------------------
5 
6 
7 #include <iostream>
8 #include "FairRadLenPoint.h"
9 #include "FairRadLenManager.h"
10 #include "FairRootManager.h"
11 #include "TLorentzVector.h"
12 #include "TParticle.h"
13 #include "TVirtualMC.h"
14 
15 using namespace std;
16 
18 
19 FairRadLenManager* FairRadLenManager::fgInstance = NULL;
20 
22 {
24  return fgInstance;
25 }
26 
28  : fPointCollection(new TClonesArray("FairRadLenPoint")),
29  fTrackID(0),
30  fVolumeID(0),
31  fPosIn(TLorentzVector(0,0,0,0)),
32  fPosOut(TLorentzVector(0,0,0,0)),
33  fMomIn(TLorentzVector(0,0,0,0)),
34  fMomOut(TLorentzVector(0,0,0,0)),
35  fTime(0),
36  fLength(0),
37  fELoss(0),
38  fA(0),
39  fZmat(0),
40  fDensity(0),
41  fRadl(0),
42  fAbsl(0)
43 {
45  if(NULL == fgInstance) {
46  fgInstance = this;
47  // fPointCollection=new TClonesArray("FairRadLenPoint");
48  }
49 }
50 
52 {
54  fgInstance = NULL;
55  fPointCollection->Delete();
56  delete fPointCollection;
57 }
58 
60 {
62  FairRootManager::Instance()->Register("RadLen","RadLenPoint", fPointCollection, kTRUE);
63 }
64 
66 {
68  fPointCollection->Delete();
69 }
70 
71 void FairRadLenManager::AddPoint(Int_t& ModuleId)
72 {
74  if ( gMC->IsTrackEntering() ) {
75  fELoss = 0.;
76  Int_t copyNo;
77  fVolumeID = gMC->CurrentVolID(copyNo);
78  fTime = gMC->TrackTime() * 1.0e09;
79  fLength = gMC->TrackLength();
80  gMC->TrackPosition(fPosIn);
81  gMC->TrackMomentum(fMomIn);
82  // Int_t MatId= gMC->CurrentMaterial(fA, fZmat, fDensity, fRadl, fAbsl);
83  gMC->CurrentMaterial(fA, fZmat, fDensity, fRadl, fAbsl);
84  }
86  fELoss += gMC->Edep();
88  if ( gMC->IsTrackExiting() ||
89  gMC->IsTrackStop() ||
90  gMC->IsTrackDisappeared() ) {
91  FairRadLenPoint* p=0;
92  fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
93  gMC->TrackPosition(fPosOut);
94  gMC->TrackMomentum(fMomOut);
95  TClonesArray& clref = *fPointCollection;
96  Int_t tsize = clref.GetEntriesFast();
97  p=new(clref[tsize]) FairRadLenPoint(fTrackID, ModuleId,
98  TVector3(fPosIn.X(),fPosIn.Y(),fPosIn.Z()),
99  TVector3(fMomIn.X(),fMomIn.Y(),fMomIn.Z()),
100  fTime, fLength, fELoss,
101  TVector3(fPosOut.X(),fPosOut.Y(),fPosOut.Z()),
102  TVector3(fMomOut.X(),fMomOut.Y(),fMomOut.Z()),
103  fA, fZmat, fDensity, fRadl);
104  }
105 
106 }
107 
108