BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
CbmStsTrackFinderIdeal.cxx
Go to the documentation of this file.
1
// -------------------------------------------------------------------------
2
// ----- CbmStsTrackFinderIdeal source file -----
3
// ----- Created 01/02/05 by V. Friese -----
4
// -------------------------------------------------------------------------
5
6
#include "
CbmStsTrackFinderIdeal.h
"
7
8
#include "
CbmStsHit.h
"
9
#include "CbmStsTrack.h"
10
11
// CBM includes
12
#include "BmnDetectorList.h"
13
#include "CbmMCTrack.h"
14
#include "FairMCPoint.h"
15
#include "FairRootManager.h"
16
17
// ROOT includes
18
#include "
TClonesArray.h
"
19
20
// C++ includes
21
#include <iomanip>
22
#include <iostream>
23
#include <map>
24
25
using
std::cout;
26
using
std::endl;
27
using
std::left;
28
using
std::map;
29
using
std::setw;
30
31
// ----- Default constructor -------------------------------------------
32
CbmStsTrackFinderIdeal::CbmStsTrackFinderIdeal
()
33
:
CbmStsTrackFinder
()
34
,
fMCTrackArray
(NULL)
35
,
fMCPointArray
(NULL)
36
{
37
fVerbose
= 1;
38
fName
=
"STSTrackFinderIdeal"
;
39
}
40
// -------------------------------------------------------------------------
41
42
// ----- Standard constructor ------------------------------------------
43
CbmStsTrackFinderIdeal::CbmStsTrackFinderIdeal
(
Int_t
verbose)
44
:
CbmStsTrackFinder
()
45
,
fMCTrackArray
(NULL)
46
,
fMCPointArray
(NULL)
47
{
48
fVerbose
= verbose;
49
fName
=
"STSTrackFinderIdeal"
;
50
}
51
// -------------------------------------------------------------------------
52
53
// ----- Destructor ----------------------------------------------------
54
CbmStsTrackFinderIdeal::~CbmStsTrackFinderIdeal
() {}
55
// -------------------------------------------------------------------------
56
57
// ----- Public method Init --------------------------------------------
58
void
CbmStsTrackFinderIdeal::Init
()
59
{
60
61
// Get and check FairRootManager
62
FairRootManager* ioman = FairRootManager::Instance();
63
if
(!ioman) {
64
cout <<
"-E- "
<<
fName
<<
"::Init: "
65
<<
"RootManager not instantised!"
<< endl;
66
return
;
67
}
68
69
// Get MCTrack array
70
fMCTrackArray
= (
TClonesArray
*)ioman->GetObject(
"MCTrack"
);
71
if
(!
fMCTrackArray
) {
72
cout <<
"-E- "
<<
fName
<<
"::Init: No MCTrack array!"
<< endl;
73
return
;
74
}
75
76
// Get MCPoint array
77
fMCPointArray
= (
TClonesArray
*)ioman->GetObject(
"StsPoint"
);
78
if
(!
fMCPointArray
) {
79
cout <<
"-E- "
<<
fName
<<
"::Init: No MCPoint array!"
<< endl;
80
return
;
81
}
82
}
83
// -------------------------------------------------------------------------
84
85
// ----- Public method DoFind ------------------------------------------
86
Int_t
CbmStsTrackFinderIdeal::DoFind
()
87
{
88
89
Bool_t
success =
kTRUE
;
90
91
// Check pointers
92
if
(!
fMCTrackArray
) {
93
cout <<
"-E- "
<<
fName
<<
"::DoFind: "
94
<<
"MCTrack array missing! "
<< endl;
95
return
-1;
96
}
97
if
(!
fMCPointArray
) {
98
cout <<
"-E- "
<<
fName
<<
"::DoFind: "
99
<<
"MCPoint array missing! "
<< endl;
100
return
-1;
101
}
102
103
if
(!
fStsHits
) {
104
cout <<
"-E- "
<<
fName
<<
"::DoFind: "
105
<<
"Hit array missing! "
<< endl;
106
return
-1;
107
}
108
109
if
(!
fTracks
) {
110
cout <<
"-E- "
<<
fName
<<
"::DoFind: "
111
<<
"Track array missing! "
<< endl;
112
return
-1;
113
}
114
115
// Initialise control counters
116
Int_t
nNoMCTrack = 0;
117
Int_t
nNoTrack = 0;
118
Int_t
nNoStsPoint = 0;
119
Int_t
nNoStsHit = 0;
120
121
// Create pointers to StsHit and StsPoint
122
CbmStsHit
* pHit = NULL;
123
FairMCPoint
* pMCpt = NULL;
124
CbmMCTrack
* pMCtr = NULL;
125
CbmStsTrack
* pTrck = NULL;
126
127
// Number of Sts hits
128
Int_t
nHits =
fStsHits
->GetEntriesFast();
129
;
130
131
// Declare some variables outside the loops
132
Int_t
ptIndex = 0;
// MCPoint index
133
Int_t
mcTrackIndex = 0;
// MCTrack index
134
Int_t
trackIndex = 0;
// StsTrack index
135
136
// Create STL map from MCtrack index to number of valid StsHits
137
map<Int_t, Int_t> hitMap;
138
139
// Loop over Sts hits
140
for
(
Int_t
iHit = 0; iHit < nHits; iHit++) {
141
pHit = (
CbmStsHit
*)
fStsHits
->At(iHit);
142
if
(!pHit)
143
continue
;
144
ptIndex = pHit->GetRefIndex();
145
if
(ptIndex < 0)
146
continue
;
// fake or background hit
147
pMCpt = (
FairMCPoint
*)(
fMCPointArray
->At(ptIndex));
148
if
(!pMCpt)
149
continue
;
150
mcTrackIndex = pMCpt->GetTrackID();
151
hitMap[mcTrackIndex]++;
152
}
153
154
// Create STL map from MCTrack index to StsTrack index
155
map<Int_t, Int_t> trackMap;
156
157
// Create StsTracks for reconstructable MCTracks
158
Int_t
nMCacc = 0;
// accepted MCTracks
159
Int_t
nTracks = 0;
// reconstructable MCTracks
160
Int_t
nMCTracks =
fMCTrackArray
->GetEntriesFast();
161
for
(
Int_t
iMCTrack = 0; iMCTrack < nMCTracks; iMCTrack++) {
162
pMCtr = (
CbmMCTrack
*)
fMCTrackArray
->At(iMCTrack);
163
if
(!pMCtr)
164
continue
;
165
if
(pMCtr->
GetNPoints
(
kGEM
) < 3)
166
continue
;
167
nMCacc++;
168
if
(hitMap[iMCTrack] < 3)
169
continue
;
170
new
((*fTracks)[nTracks])
CbmStsTrack
();
171
if
(
fVerbose
> 1)
172
cout <<
"-I- "
<<
fName
<<
": StsTrack "
<< nTracks <<
" created from MCTrack "
<< iMCTrack <<
" ("
173
<< pMCtr->
GetNPoints
(
kGEM
) <<
" StsPoints)"
<< endl;
174
trackMap[iMCTrack] = nTracks++;
175
}
176
177
if
(
fVerbose
> 2)
178
cout <<
"-I- "
<<
GetName
() <<
": "
<< endl;
179
180
// Loop over Sts hits. Get corresponding MCPoint and MCTrack index
181
for
(
Int_t
iHit = 0; iHit < nHits; iHit++) {
182
pHit = (
CbmStsHit
*)
fStsHits
->At(iHit);
183
if
(!pHit) {
184
cout <<
"-E- "
<<
fName
<<
"::DoFind: Empty slot "
185
<<
"in StsHitArray at position "
<< iHit << endl;
186
nNoStsHit++;
187
success =
kFALSE
;
188
continue
;
189
}
190
ptIndex = pHit->GetRefIndex();
191
if
(ptIndex < 0)
192
continue
;
// fake or background hit
193
pMCpt = (
FairMCPoint
*)(
fMCPointArray
->At(ptIndex));
194
if
(!pMCpt) {
195
cout <<
"-E- "
<<
fName
<<
"::DoFind: No reference "
196
<<
"MCPoint "
<< ptIndex <<
" for hit "
<< iHit << endl;
197
nNoStsPoint++;
198
success =
kFALSE
;
199
continue
;
200
}
201
mcTrackIndex = pMCpt->GetTrackID();
202
if
(mcTrackIndex < 0 || mcTrackIndex > nMCTracks) {
203
cout <<
"-E- "
<<
fName
<<
"::DoFind: "
204
<<
"MCTrack index out of range. "
<< mcTrackIndex <<
" "
<< nMCTracks << endl;
205
nNoMCTrack++;
206
success =
kFALSE
;
207
continue
;
208
}
209
if
(trackMap.find(mcTrackIndex) == trackMap.end())
210
continue
;
211
trackIndex = trackMap[mcTrackIndex];
212
pTrck = (
CbmStsTrack
*)
fTracks
->At(trackIndex);
213
if
(!pTrck) {
214
cout <<
"-E- "
<<
fName
<<
"::DoFind: "
215
<<
"No StsTrack pointer. "
<< iHit <<
" "
<< ptIndex <<
" "
<< mcTrackIndex <<
" "
<< trackIndex
216
<< endl;
217
nNoTrack++;
218
success =
kFALSE
;
219
continue
;
220
}
221
pTrck->
AddStsHit
(iHit, pHit);
222
if
(
fVerbose
> 2)
223
cout <<
"Sts Hit "
<< iHit <<
" from StsPoint "
<< ptIndex <<
" (MCTrack "
<< mcTrackIndex
224
<<
") added to StsTrack "
<< trackIndex << endl;
225
}
226
227
if
(
fVerbose
) {
228
cout << endl;
229
cout <<
"-------------------------------------------------------"
<< endl;
230
cout <<
"-I- "
<<
fName
<< endl;
231
cout <<
"Sts hits: "
<< nHits << endl;
232
cout <<
"MCTracks: total "
<< nMCTracks <<
", accepted "
<< nMCacc <<
", reconstructable: "
<< nTracks << endl;
233
if
(nNoStsHit)
234
cout <<
"StsHits not found : "
<< nNoStsHit << endl;
235
if
(nNoStsPoint)
236
cout <<
"StsPoints not found : "
<< nNoStsPoint << endl;
237
if
(nNoMCTrack)
238
cout <<
"MCTracks not found : "
<< nNoMCTrack << endl;
239
if
(nNoTrack)
240
cout <<
"StsTracks not found : "
<< nNoTrack << endl;
241
cout <<
"-------------------------------------------------------"
<< endl;
242
}
else
if
(success)
243
cout <<
"+ "
;
244
else
245
cout <<
"- "
;
246
cout << setw(15) << left <<
fName
<<
": "
<< nMCTracks <<
", acc. "
<< nMCacc <<
", rec. "
<< nTracks << endl;
247
248
return
nTracks;
249
}
250
// -------------------------------------------------------------------------
Bool_t
bool Bool_t
Int_t
int Int_t
kFALSE
constexpr Bool_t kFALSE
kTRUE
constexpr Bool_t kTRUE
TClonesArray.h
kGEM
@ kGEM
Definition
BmnDetectorList.h:15
CbmMCTrack
CbmMCTrack.h.
Definition
CbmMCTrack.h:26
CbmMCTrack::GetNPoints
Long64_t GetNPoints(DetectorId detId) const
Accessors to the number of MCPoints in the detectors.
Definition
CbmMCTrack.cxx:151
CbmStsHit
Definition
CbmStsHit.h:27
CbmStsTrackFinderIdeal::Init
virtual void Init()
Initialisation.
Definition
CbmStsTrackFinderIdeal.cxx:58
CbmStsTrackFinderIdeal::DoFind
virtual Int_t DoFind()
Track finding algorithm This just reads MC truth (MCTracks and MCPoints), creates one StsTrack for ea...
Definition
CbmStsTrackFinderIdeal.cxx:86
CbmStsTrackFinderIdeal::CbmStsTrackFinderIdeal
CbmStsTrackFinderIdeal()
Default constructor.
Definition
CbmStsTrackFinderIdeal.cxx:32
CbmStsTrackFinderIdeal::fMCPointArray
TClonesArray * fMCPointArray
Definition
CbmStsTrackFinderIdeal.h:50
CbmStsTrackFinderIdeal::fMCTrackArray
TClonesArray * fMCTrackArray
Arrays of MC information.
Definition
CbmStsTrackFinderIdeal.h:49
CbmStsTrackFinderIdeal::~CbmStsTrackFinderIdeal
virtual ~CbmStsTrackFinderIdeal()
Destructor.
Definition
CbmStsTrackFinderIdeal.cxx:54
CbmStsTrackFinder::fTracks
TClonesArray * fTracks
Definition
CbmStsTrackFinder.h:66
CbmStsTrackFinder::CbmStsTrackFinder
CbmStsTrackFinder()
Default constructor.
Definition
CbmStsTrackFinder.cxx:16
CbmStsTrackFinder::fStsHits
TClonesArray * fStsHits
Definition
CbmStsTrackFinder.h:65
CbmStsTrackFinder::fVerbose
Int_t fVerbose
Definition
CbmStsTrackFinder.h:67
CbmStsTrack
Definition
CbmStsTrack.h:28
CbmStsTrack::AddStsHit
void AddStsHit(Int_t hitIndex, FairHit *hit)
Add a StsHit to the list.
Definition
CbmStsTrack.cxx:45
FairMCPoint
TNamed::GetName
const char * GetName() const override
TNamed::fName
TString fName
TObject::TClonesArray
friend friend class TClonesArray
CbmStsHit.h
CbmStsTrackFinderIdeal.h
detectors
sts
CbmStsTrackFinderIdeal.cxx
Generated on
for BmnRoot by
1.17.0