FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairRutherford.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 #include "FairRutherford.h"
9 
10 #include "FairDetectorList.h" // for DetectorId::kFairRutherford
11 #include "FairRootManager.h" // for FairRootManager
12 #include "FairRutherfordGeo.h" // for FairRutherfordGeo
13 #include "FairRutherfordGeoPar.h" // for FairRutherfordGeoPar
14 #include "FairRutherfordPoint.h" // for FairRutherfordPoint
15 #include "FairStack.h" // for FairStack
16 #include "FairVolume.h" // for FairVolume
17 
18 #include <TClonesArray.h> // for TClonesArray
19 #include <TVirtualMC.h> // for TVirtualMC
20 #include <TVirtualMCStack.h> // for TVirtualMCStack
21 
22 FairRutherfordGeo* FairRutherford::fgGeo = nullptr;
23 
25  : FairDetector("FairRutherford", kTRUE, kFairRutherford)
26  , fTrackID(-1)
27  , fVolumeID(-1)
28  , fPos()
29  , fMom()
30  , fTime(-1.)
31  , fLength(-1.)
32  , fELoss(-1)
33  , fFairRutherfordPointCollection(new TClonesArray("FairRutherfordPoint"))
34 {}
35 
36 FairRutherford::FairRutherford(const char* name, Bool_t active)
37  : FairDetector(name, active, kFairRutherford)
38  , fTrackID(-1)
39  , fVolumeID(-1)
40  , fPos()
41  , fMom()
42  , fTime(-1.)
43  , fLength(-1.)
44  , fELoss(-1)
45  , fFairRutherfordPointCollection(new TClonesArray("FairRutherfordPoint"))
46 {}
47 
49  : FairDetector(rhs)
50  , fTrackID(-1)
51  , fVolumeID(-1)
52  , fPos()
53  , fMom()
54  , fTime(-1.)
55  , fLength(-1.)
56  , fELoss(-1)
57  , fFairRutherfordPointCollection(new TClonesArray("FairRutherfordPoint"))
58 {}
59 
61 {
62  if (fFairRutherfordPointCollection) {
63  fFairRutherfordPointCollection->Delete();
64  delete fFairRutherfordPointCollection;
65  }
66 }
67 
69 {
71  /*
72  FairRuntimeDb* rtdb= FairRun::Instance()->GetRuntimeDb();
73  FairRutherfordGeoPar* par=(FairRutherfordGeoPar*)(rtdb->getContainer("FairRutherfordGeoPar"));
74 */
75 }
76 
78 {
81  // Set parameters at entrance of volume. Reset ELoss.
82  if (TVirtualMC::GetMC()->IsTrackEntering()) {
83  fELoss = 0.;
84  fTime = TVirtualMC::GetMC()->TrackTime() * 1.0e09;
85  fLength = TVirtualMC::GetMC()->TrackLength();
86  TVirtualMC::GetMC()->TrackPosition(fPos);
87  TVirtualMC::GetMC()->TrackMomentum(fMom);
88  }
89 
90  // Sum energy loss for all steps in the active volume
91  fELoss += TVirtualMC::GetMC()->Edep();
92 
93  // Create FairRutherfordPoint at exit of active volume
94  if (TVirtualMC::GetMC()->IsTrackExiting() || TVirtualMC::GetMC()->IsTrackStop()
95  || TVirtualMC::GetMC()->IsTrackDisappeared()) {
96  fTrackID = TVirtualMC::GetMC()->GetStack()->GetCurrentTrackNumber();
97  fVolumeID = vol->getMCid();
98  if (fELoss == 0.) {
99  return kFALSE;
100  }
101  AddHit(fTrackID,
102  fVolumeID,
103  TVector3(fPos.X(), fPos.Y(), fPos.Z()),
104  TVector3(fMom.Px(), fMom.Py(), fMom.Pz()),
105  fTime,
106  fLength,
107  fELoss);
108 
109  // Increment number of FairRutherford points in TParticle
110  FairStack* stack = static_cast<FairStack*>(TVirtualMC::GetMC()->GetStack());
111  stack->AddPoint(kFairRutherford);
112  }
113 
114  return kTRUE;
115 }
116 
117 void FairRutherford::EndOfEvent() { fFairRutherfordPointCollection->Clear(); }
118 
120 {
128  "FairRutherfordPoint", "FairRutherford", fFairRutherfordPointCollection, kTRUE);
129 }
130 
131 TClonesArray* FairRutherford::GetCollection(Int_t iColl) const
132 {
133  if (iColl == 0) {
134  return fFairRutherfordPointCollection;
135  } else {
136  return nullptr;
137  }
138 }
139 
140 void FairRutherford::Reset() { fFairRutherfordPointCollection->Clear(); }
141 
143 {
148  ConstructASCIIGeometry<FairRutherfordGeo, FairRutherfordGeoPar>(fgGeo, "FairRutherfordGeoPar");
149 }
150 
152  Int_t detID,
153  TVector3 pos,
154  TVector3 mom,
155  Double_t time,
156  Double_t length,
157  Double_t eLoss)
158 {
159  TClonesArray& clref = *fFairRutherfordPointCollection;
160  Int_t size = clref.GetEntriesFast();
161  return new (clref[size])
162  FairRutherfordPoint(trackID, detID, pos, mom, time, length, eLoss, pos.Mag(), pos.Phi(), pos.Theta());
163 }
164 
166 
virtual void Reset()
virtual void EndOfEvent()
FairRutherfordPoint * AddHit(Int_t trackID, Int_t detID, TVector3 pos, TVector3 mom, Double_t time, Double_t length, Double_t eLoss)
static FairRootManager * Instance()
ClassImp(FairEventBuilder)
virtual TClonesArray * GetCollection(Int_t iColl) const
virtual void Initialize()
virtual Bool_t ProcessHits(FairVolume *v=0)
Int_t getMCid()
Definition: FairVolume.h:57
void Register(const char *name, const char *Foldername, TNamed *obj, Bool_t toFile)
virtual void Register()
void AddPoint(DetectorId iDet)
Definition: FairStack.cxx:344
virtual FairModule * CloneModule() const
virtual void Initialize()
virtual ~FairRutherford()