er  dev
ERTarget.cxx
1 #include <iostream>
2 #include <stdlib.h>
3 
4 #include "TVirtualMC.h"
5 
6 #include "FairGeoLoader.h"
7 #include "FairGeoInterface.h"
8 #include "FairGeoRootBuilder.h"
9 #include "FairRuntimeDb.h"
10 #include "TObjArray.h"
11 #include "FairRun.h"
12 #include "FairRunSim.h"
13 #include "FairGeoVolume.h"
14 #include "FairGeoNode.h"
15 
16 #include "ERTarget.h"
17 #include "ERMCEventHeader.h"
18 #include "ERGeoPassivePar.h"
19 
20 using namespace std;
21 
22 // ----- Initialsisation of static variables --------------------------
23 Double_t ERTarget::fThickness = 2.; //cm
24 // ------------------------------------------------------------------------
25 
26 ERTarget::ERTarget(): ERDetector("ERNeuRad", kTRUE)
27 {
28  fTargetPoints = new TClonesArray("ERmuSiPoint");
29 }
30 
31 ERTarget::ERTarget(const char* name, Bool_t active, Int_t verbose):ERDetector(name, active)
32 {
33  fTargetPoints = new TClonesArray("ERmuSiPoint");
34 }
35 
37 {
38 
39 }
40 
41 Bool_t ERTarget::ProcessHits(FairVolume* vol){
42  /*
43  FairRunSim* run = FairRunSim::Instance();
44 
45  ERMCEventHeader* header = (ERMCEventHeader*)run->GetMCEventHeader();
46 
47  Double_t targetReactionPos = header->TargetReactionPos();
48 
49  TLorentzVector curPos;
50  gMC->TrackPosition(curPos);
51  if (gMC->ParticleName(gMC->TrackPid()).Contains("F27") ||
52  gMC->ParticleName(gMC->TrackPid()).Contains("ExpertPrimaryIon"))
53  {
54  if (curPos.Z() >= targetReactionPos){
55  cerr << "TargetReactionPos = " << targetReactionPos << " " << curPos.Z() << endl;
56  gMC->StopTrack();
57  }
58  }
59 */
60  return kTRUE;
61 }
62 
64 
65 }
66 
68 
69 }
70 
72 
73 }
74 
75 TClonesArray* ERTarget::GetCollection(Int_t iColl) const {
76  if (iColl == 0)
77  return fTargetPoints;
78  else
79  return NULL;
80 }
81 
82 void ERTarget::Print(Option_t *option) const{
83 
84 }
85 
87 
88 }
89 
90 void ERTarget::CopyClones(TClonesArray* cl1, TClonesArray* cl2,
91  Int_t offset){
92 }
93 
95 {
96  TString fileName = GetGeometryFileName();
97  if(fileName.EndsWith(".root")) {
98  std::cout << "Constructing Target geometry from ROOT file " << fileName.Data() << std::endl;
99  ConstructRootGeometry();
100  } else {
101  LOG(FATAL) << "Target geometry file name is not set" << std::endl;
102  exit(1);
103  }
104 }
105 
107  FairDetector::Initialize();
108 }
109 
110 
111 Bool_t ERTarget::CheckIfSensitive(std::string name)
112 {
113  TString volName = name;
114  if(volName.Contains("target_vol")) {
115  return kTRUE;
116  }
117  return kFALSE;
118 }
119 
120 ClassImp(ERTarget)
121 
virtual void Initialize()
Definition: ERTarget.cxx:106
virtual void EndOfEvent()
Definition: ERTarget.cxx:67
virtual void Print(Option_t *option="") const
Definition: ERTarget.cxx:82
virtual TClonesArray * GetCollection(Int_t iColl) const
Definition: ERTarget.cxx:75
ERTarget()
The point collection //fix.
Definition: ERTarget.cxx:26
virtual void BeginEvent()
Definition: ERTarget.cxx:63
virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
Definition: ERTarget.cxx:90
virtual void Register()
Definition: ERTarget.cxx:71
virtual ~ERTarget()
Definition: ERTarget.cxx:36
virtual void ConstructGeometry()
Definition: ERTarget.cxx:94
virtual Bool_t CheckIfSensitive(std::string name)
Definition: ERTarget.cxx:111
virtual Bool_t ProcessHits(FairVolume *vol=0)
Definition: ERTarget.cxx:41
virtual void Reset()
Definition: ERTarget.cxx:86
The base class for detector simulation in er sim.
Definition: ERDetector.h:32