Project
Loading...
Searching...
No Matches
FairRadLenManager.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// ----- Created 14/01/08 by M. Al-Turany -----
11// -------------------------------------------------------------------------
12
13#include "FairRadLenManager.h"
14
15#include "FairRadLenPoint.h" // for FairRadLenPoint
16#include "FairRootManager.h" // for FairRootManager
17
18#include <TClonesArray.h> // for TClonesArray
19#include <TVector3.h> // for TVector3
20#include <TVirtualMC.h> // for TVirtualMC
21#include <TVirtualMCStack.h> // for TVirtualMCStack
22
23using namespace std;
24
26
27FairRadLenManager* FairRadLenManager::fgInstance = nullptr;
28
30{
32 return fgInstance;
33}
34
36 : fPointCollection(new TClonesArray("FairRadLenPoint"))
37 , fTrackID(0)
38 , fVolumeID(0)
39 , fPosIn(TLorentzVector(0, 0, 0, 0))
40 , fPosOut(TLorentzVector(0, 0, 0, 0))
41 , fMomIn(TLorentzVector(0, 0, 0, 0))
42 , fMomOut(TLorentzVector(0, 0, 0, 0))
43 , fTime(0)
44 , fLength(0)
45 , fELoss(0)
46 , fA(0)
47 , fZmat(0)
48 , fDensity(0)
49 , fRadl(0)
50 , fAbsl(0)
51{
53 if (nullptr == fgInstance) {
54 fgInstance = this;
55 // fPointCollection=new TClonesArray("FairRadLenPoint");
56 }
57}
58
60{
62 fgInstance = nullptr;
63 fPointCollection->Delete();
64 delete fPointCollection;
65}
66
68{
70 FairRootManager::Instance()->Register("RadLen", "RadLenPoint", fPointCollection, kTRUE);
71}
72
74{
76 fPointCollection->Delete();
77}
78
79void FairRadLenManager::AddPoint(Int_t& ModuleId)
80{
82 if (TVirtualMC::GetMC()->IsTrackEntering()) {
83 fELoss = 0.;
84 Int_t copyNo;
85 fVolumeID = TVirtualMC::GetMC()->CurrentVolID(copyNo);
86 fTime = TVirtualMC::GetMC()->TrackTime() * 1.0e09;
87 fLength = TVirtualMC::GetMC()->TrackLength();
88 TVirtualMC::GetMC()->TrackPosition(fPosIn);
89 TVirtualMC::GetMC()->TrackMomentum(fMomIn);
90 // Int_t MatId= TVirtualMC::GetMC()->CurrentMaterial(fA, fZmat, fDensity, fRadl, fAbsl);
91 TVirtualMC::GetMC()->CurrentMaterial(fA, fZmat, fDensity, fRadl, fAbsl);
92 }
94 fELoss += TVirtualMC::GetMC()->Edep();
96 if (TVirtualMC::GetMC()->IsTrackExiting() || TVirtualMC::GetMC()->IsTrackStop()
97 || TVirtualMC::GetMC()->IsTrackDisappeared()) {
98 // FairRadLenPoint* p=0;
99 fTrackID = TVirtualMC::GetMC()->GetStack()->GetCurrentTrackNumber();
100 TVirtualMC::GetMC()->TrackPosition(fPosOut);
101 TVirtualMC::GetMC()->TrackMomentum(fMomOut);
102 TClonesArray& clref = *fPointCollection;
103 Int_t tsize = clref.GetEntriesFast();
104 // p=new(clref[tsize]) FairRadLenPoint(fTrackID, ModuleId,
105 new (clref[tsize]) FairRadLenPoint(fTrackID,
106 ModuleId,
107 TVector3(fPosIn.X(), fPosIn.Y(), fPosIn.Z()),
108 TVector3(fMomIn.X(), fMomIn.Y(), fMomIn.Z()),
109 fTime,
110 fLength,
111 fELoss,
112 TVector3(fPosOut.X(), fPosOut.Y(), fPosOut.Z()),
113 TVector3(fMomOut.X(), fMomOut.Y(), fMomOut.Z()),
114 fA,
115 fZmat,
116 fDensity,
117 fRadl);
118 }
119}
ClassImp(FairRadLenManager)
void AddPoint(Int_t &ModuleId)
static FairRadLenManager * Instance()
void Register(const char *name, const char *Foldername, TNamed *obj, Bool_t toFile)
static FairRootManager * Instance()