BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnTOF1.cxx
Go to the documentation of this file.
1
#include "
BmnTOF1.h
"
2
3
using namespace
std
;
4
5
//--------------------------------------------------------------------------------------------------------------------------------------
6
BmnTOF1::BmnTOF1
()
7
:
fPos
()
8
,
fMom
()
9
,
fPosIndex
(0)
10
,
nan
(-10000000)
11
{
12
fTofCollection
=
new
TClonesArray
(
"BmnTOF1Point"
);
13
fVerboseLevel = 1;
14
}
15
16
//--------------------------------------------------------------------------------------------------------------------------------------
17
BmnTOF1::BmnTOF1
(
const
char
* name,
Bool_t
active)
18
:
FairDetector
(name, active)
19
,
fPos
()
20
,
fMom
()
21
,
fPosIndex
(0)
22
,
nan
(-10000000)
23
{
24
fTofCollection
=
new
TClonesArray
(
"BmnTOF1Point"
);
25
fVerboseLevel = 1;
26
}
27
28
//--------------------------------------------------------------------------------------------------------------------------------------
29
BmnTOF1::~BmnTOF1
()
30
{
31
fTofCollection
->Delete();
32
delete
fTofCollection
;
33
}
34
35
//--------------------------------------------------------------------------------------------------------------------------------------
36
void
BmnTOF1::Initialize
()
37
{
38
FairDetector::Initialize();
39
// FairRun* sim = FairRun::Instance();
40
// FairRuntimeDb* rtdb = sim->GetRuntimeDb();
41
}
42
43
//--------------------------------------------------------------------------------------------------------------------------------------
44
void
BmnTOF1::BeginEvent
() {}
45
46
//--------------------------------------------------------------------------------------------------------------------------------------
47
Bool_t
BmnTOF1::ProcessHits
(FairVolume* vol)
48
{
49
// Set parameters at entrance of volume. Reset ELoss.
50
if
(gMC->IsTrackEntering()) {
51
fELoss
= 0.;
52
fTime
= gMC->TrackTime() * 1.0e09;
53
fLength
= gMC->TrackLength();
54
gMC->TrackPosition(
fPos
);
55
gMC->TrackMomentum(
fMom
);
56
}
57
58
// Sum energy loss for all steps in the active volume
59
fELoss
+= gMC->Edep();
60
61
// Create TofPoint at exit of active volume
62
if
(
fELoss
> 0 && (gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared())) {
63
Int_t
fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
64
assert(fTrackID >= 0);
65
66
Int_t
region = 0,
detector
, strip;
67
gMC->CurrentVolOffID(0, strip);
68
gMC->CurrentVolOffID(1,
detector
);
69
70
Int_t
fVolumeID =
BmnTOF1Point::GetVolumeUID
(region,
detector
, strip);
71
72
AddPoint
(fTrackID,
kTOF1
,
TVector3
(
fPos
.X(),
fPos
.Y(),
fPos
.Z()),
TVector3
(
fMom
.Px(),
fMom
.Py(),
fMom
.Pz()),
73
fTime
,
fLength
,
fELoss
, fVolumeID);
74
((
CbmStack
*)gMC->GetStack())->AddPoint(
kTOF1
);
75
76
ResetParameters
();
77
}
78
79
return
kTRUE
;
80
}
81
82
//--------------------------------------------------------------------------------------------------------------------------------------
83
void
BmnTOF1::EndOfEvent
()
84
{
85
if
(fVerboseLevel)
86
Print
(
""
);
87
Reset
();
88
}
89
90
//--------------------------------------------------------------------------------------------------------------------------------------
91
void
BmnTOF1::Register
()
92
{
93
FairRootManager::Instance()->Register(
"TOF400Point"
,
"TOF400"
,
fTofCollection
,
kTRUE
);
94
}
95
96
//--------------------------------------------------------------------------------------------------------------------------------------
97
TClonesArray
*
BmnTOF1::GetCollection
(
Int_t
iColl)
const
98
{
99
if
(iColl == 0)
100
return
fTofCollection
;
101
102
return
nullptr
;
103
}
104
105
//--------------------------------------------------------------------------------------------------------------------------------------
106
void
BmnTOF1::Print
(
Option_t
*)
const
107
{
108
Int_t
nHits =
fTofCollection
->GetEntriesFast();
109
cout <<
"-I- BmnTOF400: "
<< nHits <<
" points registered in this event.\n"
;
110
111
if
(fVerboseLevel > 1)
112
for
(
Int_t
i
= 0;
i
< nHits;
i
++)
113
(*
fTofCollection
)[
i
]->Print();
114
}
115
116
//--------------------------------------------------------------------------------------------------------------------------------------
117
void
BmnTOF1::Reset
()
118
{
119
fTofCollection
->Delete();
120
fPosIndex
= 0;
121
}
122
123
//--------------------------------------------------------------------------------------------------------------------------------------
124
// guarda in FairRootManager::CopyClones
125
void
BmnTOF1::CopyClones
(
TClonesArray
* cl1,
TClonesArray
* cl2,
Int_t
offset)
126
{
127
Int_t
nEntries = cl1->
GetEntriesFast
();
128
// cout << "-I- BmnTOF1: " << nEntries << " entries to add." << endl;
129
TClonesArray
& clref = *cl2;
130
BmnTOF1Point
* oldpoint = NULL;
131
132
for
(
Int_t
i
= 0;
i
< nEntries;
i
++) {
133
oldpoint = (
BmnTOF1Point
*)cl1->
At
(
i
);
134
Int_t
index = oldpoint->GetTrackID() + offset;
135
oldpoint->SetTrackID(index);
136
new
(clref[
fPosIndex
])
BmnTOF1Point
(*oldpoint);
137
fPosIndex
++;
138
}
139
140
cout <<
" -I- BmnTOF400: "
<< cl2->
GetEntriesFast
() <<
" merged entries."
<< endl;
141
}
142
143
//--------------------------------------------------------------------------------------------------------------------------------------
144
void
BmnTOF1::ConstructGeometry
()
145
{
146
TString
fileName = GetGeometryFileName();
147
if
(fileName.
EndsWith
(
".root"
)) {
148
LOG(info) <<
"Constructing TOF400 geometry from ROOT file "
<< fileName.
Data
();
149
ConstructRootGeometry();
150
}
else
if
(fileName.
EndsWith
(
".geo"
)) {
151
LOG(info) <<
"Constructing TOF400 geometry from ASCII file "
<< fileName.
Data
();
152
ConstructAsciiGeometry
();
153
}
else
154
LOG(fatal) <<
"Geometry format of TOF400 file "
<< fileName.
Data
() <<
" not supported."
;
155
}
156
157
//--------------------------------------------------------------------------------------------------------------------------------------
158
void
BmnTOF1::ConstructAsciiGeometry
()
159
{
160
FairGeoLoader* geoLoad = FairGeoLoader::Instance();
161
FairGeoInterface* geoFace = geoLoad->getGeoInterface();
162
BmnTOF1Geo
* TOF1Geo =
new
BmnTOF1Geo
();
163
TOF1Geo->setGeomFile(GetGeometryFileName());
164
geoFace->addGeoModule(TOF1Geo);
165
166
Bool_t
rc = geoFace->readSet(TOF1Geo);
167
if
(rc)
168
TOF1Geo->create(geoLoad->getGeoBuilder());
169
TList
* volList = TOF1Geo->getListOfVolumes();
170
171
// store geo parameter
172
FairRun* fRun = FairRun::Instance();
173
FairRuntimeDb* rtdb = FairRun::Instance()->GetRuntimeDb();
174
BmnTOF1GeoPar
* par = (
BmnTOF1GeoPar
*)(rtdb->getContainer(
"BmnTOF1GeoPar"
));
175
TObjArray
* fSensNodes = par->
GetGeoSensitiveNodes
();
176
TObjArray
* fPassNodes = par->
GetGeoPassiveNodes
();
177
178
TListIter
iter(volList);
179
FairGeoNode* node =
nullptr
;
180
FairGeoVolume* aVol =
nullptr
;
181
182
while
((node = (FairGeoNode*)iter.
Next
())) {
183
aVol =
dynamic_cast<
FairGeoVolume*
>
(node);
184
185
if
(node->isSensitive())
186
fSensNodes->
AddLast
(aVol);
187
else
188
fPassNodes->
AddLast
(aVol);
189
}
190
191
par->setChanged();
192
par->setInputVersion(fRun->GetRunId(), 1);
193
ProcessNodes(volList);
194
}
195
196
//--------------------------------------------------------------------------------------------------------------------------------------
197
Bool_t
BmnTOF1::CheckIfSensitive
(std::string name)
198
{
199
TString
tsname = name;
200
if
(tsname.
Contains
(
"Active"
))
201
return
kTRUE
;
202
203
return
kFALSE
;
204
}
205
206
//--------------------------------------------------------------------------------------------------------------------------------------
207
BmnTOF1Point
*
BmnTOF1::AddPoint
(
Int_t
trackID,
208
Int_t
detID,
209
TVector3
pos,
210
TVector3
mom,
211
Double_t
time,
212
Double_t
length,
213
Double_t
eLoss,
214
Int_t
volUID)
215
{
216
return
new
((*fTofCollection)[
fTofCollection
->GetEntriesFast()])
217
BmnTOF1Point
(trackID, detID, pos, mom, time, length, eLoss, volUID);
218
}
detector
detector
Definition
BmnLambdaEmbeddingQa.h:47
i
int i
Definition
P4_F32vec4.h:22
Bool_t
bool Bool_t
Int_t
int Int_t
kFALSE
constexpr Bool_t kFALSE
Double_t
double Double_t
kTRUE
constexpr Bool_t kTRUE
Option_t
const char Option_t
kTOF1
@ kTOF1
Definition
BmnDetectorList.h:16
BmnTOF1GeoPar
Definition
BmnTOF1GeoPar.h:11
BmnTOF1GeoPar::GetGeoSensitiveNodes
TObjArray * GetGeoSensitiveNodes()
Definition
BmnTOF1GeoPar.h:25
BmnTOF1GeoPar::GetGeoPassiveNodes
TObjArray * GetGeoPassiveNodes()
Definition
BmnTOF1GeoPar.h:26
BmnTOF1Geo
Definition
BmnTOF1Geo.h:9
BmnTOF1Point
Definition
BmnTOF1Point.h:11
BmnTOF1Point::GetVolumeUID
Int_t GetVolumeUID() const
Definition
BmnTOF1Point.h:41
BmnTOF1::Print
virtual void Print(Option_t *) const
Definition
BmnTOF1.cxx:106
BmnTOF1::fTofCollection
TClonesArray * fTofCollection
KG: nan is set to -10 000 000, but i think it should be 0.
Definition
BmnTOF1.h:65
BmnTOF1::Reset
virtual void Reset()
Definition
BmnTOF1.cxx:117
BmnTOF1::fELoss
Double32_t fELoss
length
Definition
BmnTOF1.h:61
BmnTOF1::fTime
Double32_t fTime
momentum
Definition
BmnTOF1.h:59
BmnTOF1::~BmnTOF1
virtual ~BmnTOF1()
Definition
BmnTOF1.cxx:29
BmnTOF1::ConstructAsciiGeometry
virtual void ConstructAsciiGeometry()
Definition
BmnTOF1.cxx:158
BmnTOF1::fLength
Double32_t fLength
time
Definition
BmnTOF1.h:60
BmnTOF1::EndOfEvent
virtual void EndOfEvent()
Definition
BmnTOF1.cxx:83
BmnTOF1::fMom
TLorentzVector fMom
position
Definition
BmnTOF1.h:58
BmnTOF1::ProcessHits
virtual Bool_t ProcessHits(FairVolume *vol=nullptr)
Definition
BmnTOF1.cxx:47
BmnTOF1::GetCollection
virtual TClonesArray * GetCollection(Int_t iColl) const
Definition
BmnTOF1.cxx:97
BmnTOF1::Initialize
virtual void Initialize()
Definition
BmnTOF1.cxx:36
BmnTOF1::nan
const double nan
Definition
BmnTOF1.h:63
BmnTOF1::ConstructGeometry
virtual void ConstructGeometry()
Definition
BmnTOF1.cxx:144
BmnTOF1::BmnTOF1
BmnTOF1()
Definition
BmnTOF1.cxx:6
BmnTOF1::fPos
TLorentzVector fPos
Definition
BmnTOF1.h:57
BmnTOF1::ResetParameters
void ResetParameters()
Hit collection.
Definition
BmnTOF1.h:75
BmnTOF1::CopyClones
virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
Definition
BmnTOF1.cxx:125
BmnTOF1::AddPoint
BmnTOF1Point * AddPoint(Int_t trackID, Int_t detID, TVector3 pos, TVector3 mom, Double_t tof, Double_t length, Double_t eLoss, Int_t volUID)
Definition
BmnTOF1.cxx:207
BmnTOF1::Register
virtual void Register()
Definition
BmnTOF1.cxx:91
BmnTOF1::fPosIndex
Int_t fPosIndex
energy loss
Definition
BmnTOF1.h:62
BmnTOF1::BeginEvent
virtual void BeginEvent()
Definition
BmnTOF1.cxx:44
BmnTOF1::CheckIfSensitive
virtual Bool_t CheckIfSensitive(std::string name)
Definition
BmnTOF1.cxx:197
CbmStack
CbmStack.h.
Definition
CbmStack.h:43
FairDetector
TClonesArray
TListIter
TListIter::Next
TObject * Next() override
TList
TObjArray
TObjArray::GetEntriesFast
Int_t GetEntriesFast() const
TObjArray::At
TObject * At(Int_t idx) const override
TObjArray::AddLast
void AddLast(TObject *obj) override
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
BmnTOF1.h
std
Definition
json.hpp:4446
detectors
tof1
BmnTOF1.cxx
Generated on
for BmnRoot by
1.17.0