BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnVacWall.cxx
Go to the documentation of this file.
1
#include "
BmnVacWall.h
"
2
3
#include "CbmStack.h"
4
#include "FairRootManager.h"
5
#include "FairRun.h"
6
#include "FairRuntimeDb.h"
7
#include "FairVolume.h"
8
#include "
TGeoManager.h
"
9
#include "
TLorentzVector.h
"
10
#include "
TParticle.h
"
11
#include "TVirtualMC.h"
12
13
#include <iostream>
14
15
BmnVacWall::BmnVacWall
()
16
:
FairDetector
(
"BmnVacWall"
, true)
17
,
fGeoHandler
(new
BmnZdcGeo
())
18
,
fCollection
(new
TClonesArray
(
"FairMCPoint"
))
19
{
20
LOG(debug4) <<
"BmnVacWall default constructor called"
;
21
}
22
23
BmnVacWall::BmnVacWall
(
const
char
* name,
Bool_t
active)
24
:
FairDetector
(name, active)
25
,
fGeoHandler
(new
BmnZdcGeo
())
26
,
fCollection
(new
TClonesArray
(
"FairMCPoint"
))
27
{
28
LOG(debug4) <<
"BmnVacWall constructor called with name: "
<< name <<
" and active: "
<< active;
29
}
30
31
BmnVacWall::~BmnVacWall
()
32
{
33
LOG(debug4) <<
"BmnVacWall destructor called"
;
34
if
(
fCollection
) {
35
fCollection
->Delete();
36
delete
fCollection
;
37
}
38
delete
fGeoHandler
;
39
}
40
41
void
BmnVacWall::Initialize
()
42
{
43
LOG(debug4) <<
"BmnVacWall Initialize method called"
;
44
FairDetector::Initialize();
45
// FairRun* sim = FairRun::Instance();
46
// FairRuntimeDb* rtdb = sim->GetRuntimeDb();
47
}
48
49
void
BmnVacWall::BeginEvent
()
50
{
51
LOG(debug4) <<
"BmnVacWall BeginEvent method called"
;
52
}
53
54
Bool_t
BmnVacWall::ProcessHits
(FairVolume* vol)
55
{
56
LOG(debug2) <<
"BmnVacWall ProcessHits method called for event "
<< gMC->CurrentEvent();
57
if
(!
CheckIfSensitive
(gMC->CurrentVolName())) {
58
return
kFALSE
;
59
}
60
61
Int_t
trackID = gMC->GetStack()->GetCurrentTrackNumber();
62
int
plane_id;
63
gMC->CurrentVolOffID(0, plane_id);
// planeNb 1-6
64
if
(gMC->IsTrackEntering()) {
65
// Initializing new hit
66
FairMCPoint
* newPoint =
new
FairMCPoint
();
67
newPoint->SetEventID(gMC->CurrentEvent());
68
newPoint->SetTrackID(trackID);
69
newPoint->SetDetectorID(plane_id);
70
TLorentzVector
tPos, tMom;
71
gMC->TrackPosition(tPos);
// Position at entrance
72
gMC->TrackMomentum(tMom);
// Momentum at entrance
73
newPoint->SetPosition(
TVector3
(tPos.
X
(), tPos.
Y
(), tPos.
Z
()));
74
newPoint->SetMomentum(
TVector3
(tMom.
X
(), tMom.
Y
(), tMom.
Z
()));
75
newPoint->SetTime(gMC->TrackTime() * 1.0e09);
// Time of flight
76
newPoint->SetLength(gMC->TrackLength());
// Length of the current track from its origin (in cm)
77
78
// Inserting new hit
79
AddHit
(newPoint);
80
((
CbmStack
*)gMC->GetStack())->AddPoint(
kVACWALL
);
81
}
82
return
kTRUE
;
83
}
84
85
void
BmnVacWall::EndOfEvent
()
86
{
87
LOG(debug4) <<
"BmnVacWall EndOfEvent method called"
;
88
Print
(
""
);
89
Reset
();
90
}
91
92
void
BmnVacWall::Register
()
93
{
94
LOG(debug4) <<
"BmnVacWall Register method called"
;
95
if
(!FairRootManager::Instance()->GetObject(
"VacWallPoint"
))
96
FairRootManager::Instance()->Register(
"VacWallPoint"
,
"VacWall"
,
fCollection
,
kTRUE
);
97
else
98
LOG(debug4) <<
"VacWallPoint Already registered"
;
99
}
100
101
TClonesArray
*
BmnVacWall::GetCollection
(
Int_t
iColl)
const
102
{
103
LOG(debug4) <<
"BmnVacWall GetCollection method called with iColl: "
<< iColl;
104
return
(iColl == 0) ?
fCollection
:
nullptr
;
105
}
106
107
void
BmnVacWall::Print
(
Option_t
*)
const
108
{
109
LOG(debug4) <<
"BmnVacWall Print method called"
;
110
Int_t
nHits =
fCollection
->GetEntriesFast();
111
std::cout <<
"-I- BmnVacWall: "
<< nHits <<
" points registered in event "
<< gMC->CurrentEvent() << std::endl;
112
113
if
(FairLogger::GetLogger()->IsLogNeeded(fair::Severity::debug2)) {
114
for
(
Int_t
i
= 0;
i
< nHits;
i
++) {
115
(*fCollection)[
i
]->Print();
116
}
117
}
118
}
119
120
void
BmnVacWall::Reset
()
121
{
122
LOG(debug4) <<
"BmnVacWall Reset method called"
;
123
fCollection
->Delete();
124
}
125
126
void
BmnVacWall::ConstructGeometry
()
127
{
128
LOG(debug4) <<
"BmnVacWall ConstructGeometry method called"
;
129
TString
fileName = GetGeometryFileName();
130
if
(fileName.
EndsWith
(
".root"
)) {
131
LOG(info) <<
Form
(
"Constructing VacWall geometry from ROOT file %s"
, fileName.
Data
());
132
ConstructRootGeometry();
133
}
134
135
FairGeoLoader* geoLoad = FairGeoLoader::Instance();
136
FairGeoInterface* geoFace = geoLoad->getGeoInterface();
137
fGeoHandler
->setGeomFile(GetGeometryFileName());
138
geoFace->addGeoModule(
fGeoHandler
);
139
140
Bool_t
rc = geoFace->readSet(
fGeoHandler
);
141
if
(rc)
142
fGeoHandler
->create(geoLoad->getGeoBuilder());
143
TList
* volList =
fGeoHandler
->getListOfVolumes();
144
145
ProcessNodes(volList);
146
}
147
148
Bool_t
BmnVacWall::CheckIfSensitive
(std::string name)
149
{
150
LOG(debug4) <<
"BmnVacWall CheckIfSensitive method called with name: "
<< name;
151
TString
tsname = name.c_str();
152
// zdc legacy
153
return
tsname.
Contains
(
"zdc01s"
) || tsname.
Contains
(
"zdc01s_after"
) || tsname.
Contains
(
"ScH"
);
154
}
155
156
FairMCPoint
*
BmnVacWall::AddHit
(
FairMCPoint
* point)
157
{
158
TClonesArray
& clref = *
fCollection
;
159
Int_t
size = clref.
GetEntriesFast
();
160
return
new
(clref[size])
FairMCPoint
(*point);
161
}
162
163
void
BmnVacWall::RemoveHit
(
Int_t
index)
164
{
165
if
(index < 0 || index >=
fCollection
->GetEntriesFast()) {
166
LOG(debug4) <<
"BmnVacWall RemoveHit method index: "
<< index <<
" out of range."
;
167
return
;
168
}
169
fCollection
->RemoveAt(index);
170
fCollection
->Compress();
// This method will remove NULL pointers from the array
171
}
i
int i
Definition
P4_F32vec4.h:22
Bool_t
bool Bool_t
Int_t
int Int_t
kFALSE
constexpr Bool_t kFALSE
kTRUE
constexpr Bool_t kTRUE
Option_t
const char Option_t
TGeoManager.h
TLorentzVector.h
TParticle.h
Form
char * Form(const char *fmt,...)
kVACWALL
@ kVACWALL
Definition
BmnDetectorList.h:38
BmnVacWall::BeginEvent
virtual void BeginEvent()
Called at the beginning of each event.
Definition
BmnVacWall.cxx:49
BmnVacWall::fCollection
TClonesArray * fCollection
Definition
BmnVacWall.h:78
BmnVacWall::~BmnVacWall
virtual ~BmnVacWall()
Destructor.
Definition
BmnVacWall.cxx:31
BmnVacWall::ProcessHits
virtual Bool_t ProcessHits(FairVolume *vol=nullptr)
Processes hits and creates FairMCPoints.
Definition
BmnVacWall.cxx:54
BmnVacWall::Reset
virtual void Reset()
Clears the hit collection.
Definition
BmnVacWall.cxx:120
BmnVacWall::ConstructGeometry
virtual void ConstructGeometry()
Constructs geometry from files.
Definition
BmnVacWall.cxx:126
BmnVacWall::fGeoHandler
BmnZdcGeo * fGeoHandler
Definition
BmnVacWall.h:77
BmnVacWall::CheckIfSensitive
virtual Bool_t CheckIfSensitive(std::string name)
Checks whether a volume is sensitive based on its name.
Definition
BmnVacWall.cxx:148
BmnVacWall::RemoveHit
void RemoveHit(Int_t index)
Remove hit from hits collection by index.
Definition
BmnVacWall.cxx:163
BmnVacWall::AddHit
FairMCPoint * AddHit(FairMCPoint *point)
Adds the hit to hits collection.
Definition
BmnVacWall.cxx:156
BmnVacWall::Initialize
virtual void Initialize()
Initialises detector and FairRun.
Definition
BmnVacWall.cxx:41
BmnVacWall::BmnVacWall
BmnVacWall()
Default constructor.
Definition
BmnVacWall.cxx:15
BmnVacWall::GetCollection
virtual TClonesArray * GetCollection(Int_t iColl) const
Accessor to the hit collection.
Definition
BmnVacWall.cxx:101
BmnVacWall::EndOfEvent
virtual void EndOfEvent()
Called at the end of each event.
Definition
BmnVacWall.cxx:85
BmnVacWall::Register
virtual void Register()
Registers the hit collection in the ROOT manager.
Definition
BmnVacWall.cxx:92
BmnVacWall::Print
virtual void Print(Option_t *) const
Screen output of hit collection.
Definition
BmnVacWall.cxx:107
BmnZdcGeo
Definition
BmnZdcGeo.h:17
CbmStack
CbmStack.h.
Definition
CbmStack.h:43
FairDetector
FairMCPoint
TClonesArray
TList
TLorentzVector
TLorentzVector::Y
Double_t Y() const
TLorentzVector::X
Double_t X() const
TLorentzVector::Z
Double_t Z() const
TObjArray::GetEntriesFast
Int_t GetEntriesFast() const
TString
TString::EndsWith
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
TString::Data
const char * Data() const
TString::Contains
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TVector3
BmnVacWall.h
detectors
vacwall
BmnVacWall.cxx
Generated on
for BmnRoot by
1.17.0