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