BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnDedx.cxx
Go to the documentation of this file.
1
#include "
BmnDedx.h
"
2
3
BmnDedx::BmnDedx
()
4
:
fMinMom
(0.0)
5
,
fMaxMom
(20.0)
6
,
fNormDedxThresh
(2.8)
7
,
fNSt
(11)
8
,
fNSect
({6, 10, 14, 18, 8, 8, 8, 8, 8, 8, 8})
9
, fNMomSlices(6)
10
, fMinMomBound({0.0, 0.5, 1.0, 1.5, 2.0, 3.0})
11
, fMaxMomBound({0.5, 1.0, 2.0, 3.0, 5.0, 20.0})
12
, fRunId(-1)
13
, fStsTracks(
nullptr
)
14
, fStsHits(
nullptr
)
15
, fLowGemClusters(
nullptr
)
16
, fLowFsdClusters(
nullptr
)
17
, fGlobTracks(
nullptr
)
18
, fDedx(0.0)
19
, fTime(0.0)
20
{
21
const
Float_t
fpar[5] = {-295.415, -2.71164, -0.0606733, 1.93517, 3.99467e-6};
22
fAlephFit_He4 =
23
new
TF1
(
"alephFit_He4"
,
"[0]/(x^([3]))*([1]-x^([3])-TMath::Log([2]+1/(x^([4]))))"
, fMinMom, fMaxMom);
24
fAlephFit_He4->SetParameters(fpar[0], fpar[1], fpar[2], fpar[3], fpar[4]);
25
}
26
27
BmnDedx::BmnDedx
(
Int_t
runid)
28
:
fMinMom
(0.0)
29
,
fMaxMom
(20.0)
30
,
fNormDedxThresh
(2.8)
31
,
fNSt
(11)
32
,
fNSect
({6, 10, 14, 18, 8, 8, 8, 8, 8, 8, 8})
33
, fNMomSlices(6)
34
, fMinMomBound({0.0, 0.5, 1.0, 1.5, 2.0, 3.0})
35
, fMaxMomBound({0.5, 1.0, 2.0, 3.0, 5.0, 20.0})
36
, fRunId(runid)
37
, fStsTracks(
nullptr
)
38
, fStsHits(
nullptr
)
39
, fLowGemClusters(
nullptr
)
40
, fLowFsdClusters(
nullptr
)
41
, fGlobTracks(
nullptr
)
42
, fDedx(0.0)
43
, fTime(0.0)
44
{
45
const
Float_t
fpar[5] = {-295.415, -2.71164, -0.0606733, 1.93517, 3.99467e-6};
46
fAlephFit_He4 =
47
new
TF1
(
"alephFit_He4"
,
"[0]/(x^([3]))*([1]-x^([3])-TMath::Log([2]+1/(x^([4]))))"
, fMinMom, fMaxMom);
48
fAlephFit_He4->SetParameters(fpar[0], fpar[1], fpar[2], fpar[3], fpar[4]);
49
}
50
51
void
BmnDedx::Exec
(
Option_t
* opt)
52
{
53
54
TStopwatch
sw;
55
sw.
Start
();
56
57
if
(!IsActive())
58
return
;
59
60
if
(fVerbose > 1)
61
cout <<
"\n======================== BmnDedx::Exec started =====================\n"
<< endl;
62
63
for
(
Int_t
iTr = 0; iTr <
fGlobTracks
->GetEntriesFast(); ++iTr) {
64
BmnGlobalTrack
* tr = (
BmnGlobalTrack
*)
fGlobTracks
->At(iTr);
65
CalcDedx
(tr);
66
}
67
68
sw.
Stop
();
69
fTime
+= sw.
RealTime
();
70
71
if
(fVerbose > 1)
72
cout <<
"\n======================== BmnDedx::Exec started ====================\n"
<< endl;
73
}
74
75
void
BmnDedx::Finish
()
76
{
77
printf(
"Work time of BmnDedx: %4.2f sec.\n"
,
fTime
);
78
}
79
80
InitStatus
BmnDedx::Init
()
81
{
82
if
(fVerbose > 1)
83
cout <<
"\n======================== BmnDedx::Init finished ====================\n"
<< endl;
84
85
FairRootManager* ioman = FairRootManager::Instance();
86
if
(!ioman)
87
Fatal
(
"Init"
,
"FairRootManager is not instantiated"
);
88
89
fStsTracks
= (
TClonesArray
*)ioman->GetObject(
"StsVector"
);
90
if
(!
fStsTracks
) {
91
cout <<
"BmnDedx::Init(): branch StsVector not found! Task will be deactivated"
<< endl;
92
SetActive(
kFALSE
);
93
return
kERROR;
94
}
95
fStsHits
= (
TClonesArray
*)ioman->GetObject(
"StsHit"
);
96
if
(!
fStsHits
) {
97
cout <<
"BmnDedx::Init(): branch StsHit not found! Task will be deactivated"
<< endl;
98
SetActive(
kFALSE
);
99
return
kERROR;
100
}
101
fGlobTracks
= (
TClonesArray
*)ioman->GetObject(
"BmnGlobalTrack"
);
102
if
(!
fGlobTracks
) {
103
cout <<
"BmnDedx::Init(): branch BmnGlobalTrack not found! Task will be deactivated"
<< endl;
104
SetActive(
kFALSE
);
105
return
kERROR;
106
}
107
fLowGemClusters
= (
TClonesArray
*)ioman->GetObject(
"BmnGemLowerCluster"
);
108
if
(!
fLowGemClusters
) {
109
cout <<
"BmnDedx::Init(): branch BmnGemLowerCluster not found! Task will be deactivated"
<< endl;
110
SetActive(
kFALSE
);
111
return
kERROR;
112
}
113
fLowFsdClusters
= (
TClonesArray
*)ioman->GetObject(
"BmnSiliconLowerCluster"
);
114
if
(!
fLowFsdClusters
) {
115
cout <<
"BmnDedx::Init(): branch BmnSiliconLowerCluster not found! Task will be deactivated"
<< endl;
116
SetActive(
kFALSE
);
117
return
kERROR;
118
}
119
120
if
(
fRunId
== -1) {
121
cout <<
"BmnDedx::Init(): run ID not defined! Task will be deactivated"
<< endl;
122
SetActive(
kFALSE
);
123
return
kERROR;
124
}
125
126
a
=
new
Float_t
**[
fNSt
];
127
b
=
new
Float_t
**[
fNSt
];
128
129
TString
dir = getenv(
"VMCWORKDIR"
);
130
TString
calibFileName = dir +
"/input/calibration.root"
;
131
TFile
* calibFile =
TFile::Open
(calibFileName);
132
133
if
(fVerbose > 1)
134
cout <<
"Calibration file reading: "
<< calibFileName << endl;
135
136
for
(
Int_t
i
= 0;
i
<
fNSt
; ++
i
) {
137
a
[
i
] =
new
Float_t
*[
fNSect
[
i
]];
138
b
[
i
] =
new
Float_t
*[
fNSect
[
i
]];
139
for
(
Int_t
j = 0; j <
fNSect
[
i
]; ++j) {
140
a
[
i
][j] =
new
Float_t
[
fNMomSlices
];
141
b
[
i
][j] =
new
Float_t
[
fNMomSlices
];
142
for
(
Int_t
k = 0; k <
fNMomSlices
; ++k) {
143
TH1F
* hA = (
TH1F
*)calibFile->
Get
(
Form
(
"hA_run_%d_%d_%d"
,
i
, j, k));
144
TH1F
* hB = (
TH1F
*)calibFile->
Get
(
Form
(
"hB_run_%d_%d_%d"
,
i
, j, k));
145
146
a
[
i
][j][k] = hA->
GetBinContent
(hA->
FindBin
(
fRunId
));
147
b
[
i
][j][k] = hB->
GetBinContent
(hB->
FindBin
(
fRunId
));
148
}
149
}
150
}
151
calibFile->
Close
();
152
153
if
(fVerbose > 1)
154
cout <<
"\n======================== BmnDedx::Init finished ====================\n"
<< endl;
155
156
return
kSUCCESS;
157
}
158
159
void
BmnDedx::CalcDedx
(
BmnGlobalTrack
* tr)
160
{
161
Float_t
p = tr->
GetP
();
162
if
(p < 0) {
163
tr->
SetDedx
(0.0);
164
tr->
SetQ
(-1);
165
}
166
Int_t
momIdx = -1;
167
for
(
Int_t
iP = 0; iP <
fNMomSlices
; ++iP) {
168
if
(p >
fMinMomBound
[iP] && p <
fMaxMomBound
[iP]) {
169
momIdx = iP;
170
break
;
171
}
172
}
173
if
(momIdx == -1)
174
return
;
175
176
CbmStsTrack
* ststr = (
CbmStsTrack
*)
fStsTracks
->At(tr->
GetGemTrackIndex
());
177
set<Float_t> signalsLow;
178
Int_t
nHits = ststr->
GetNStsHits
();
179
180
Int_t
nGemHits = 0;
181
Int_t
nFsdHits = 0;
182
for
(
Int_t
hitIdx = 0; hitIdx < nHits; ++hitIdx) {
183
CbmStsHit
* hit = (
CbmStsHit
*)
fStsHits
->At(ststr->
GetStsHitIndex
(hitIdx));
184
Int_t
sect = hit->
GetSectorNr
() - 1;
185
Int_t
st = hit->
GetStationNr
() - 1;
186
StripCluster
* low;
187
if
(hit->
GetSystemId
() ==
kGEM
) {
188
low = (
StripCluster
*)
fLowGemClusters
->At(hit->
fDigiF
% 1000000);
189
nGemHits++;
190
}
else
if
(hit->
GetSystemId
() ==
kSILICON
) {
191
low = (
StripCluster
*)
fLowFsdClusters
->At(hit->
fDigiF
% 1000000);
192
nFsdHits++;
193
}
194
195
signalsLow.insert(low->
TotalSignal
*
a
[st][sect][momIdx] +
b
[st][sect][momIdx]);
196
}
197
198
Int_t
usedHits = (nHits == 3) ? 2
199
: (nHits == 4) ? 2
200
: (nHits == 5) ? 3
201
: (nHits == 6) ? 4
202
: (nHits == 7) ? 4
203
: (nHits == 8) ? 5
204
: (nHits == 9) ? 6
205
: (nHits == 10) ? 6
206
: (nHits > 10) ? 7
207
: 0;
208
auto
it = signalsLow.begin();
209
Float_t
totSigLow = 0.0;
210
for
(
Int_t
i
= 0;
i
< usedHits; ++
i
) {
211
totSigLow += (*it);
212
it++;
213
}
214
215
fDedx
= (usedHits > 0) ? totSigLow / usedHits : 0.0;
216
217
tr->
SetDedx
(
fDedx
);
218
tr->
SetQ
(
GetQ
(tr));
219
220
return
;
221
}
222
223
Float_t
BmnDedx::GetDedx
(
BmnGlobalTrack
* tr)
224
{
225
fDedx
= tr->
GetDedx
();
226
return
fDedx
;
227
}
228
229
Float_t
BmnDedx::CalcNormalizedDedx
(
BmnGlobalTrack
* tr)
230
{
231
return
fDedx
/
fAlephFit_He4
->Eval(tr->
GetP
());
232
}
233
234
Short_t
BmnDedx::GetQ
(
BmnGlobalTrack
* tr)
235
{
236
if
(
CalcNormalizedDedx
(tr) >
fNormDedxThresh
)
237
return
2;
238
else
239
return
1;
240
}
241
242
BmnDedx::~BmnDedx
() {}
i
int i
Definition
P4_F32vec4.h:22
Int_t
int Int_t
Float_t
float Float_t
Short_t
short Short_t
kFALSE
constexpr Bool_t kFALSE
Option_t
const char Option_t
Fatal
void Fatal(const char *location, const char *msgfmt,...)
Form
char * Form(const char *fmt,...)
kSILICON
@ kSILICON
Definition
BmnDetectorList.h:25
kGEM
@ kGEM
Definition
BmnDetectorList.h:15
BmnDedx::a
Float_t *** a
Definition
BmnDedx.h:62
BmnDedx::fGlobTracks
TClonesArray * fGlobTracks
Definition
BmnDedx.h:69
BmnDedx::Init
virtual InitStatus Init()
Inherited from FairTask.
Definition
BmnDedx.cxx:80
BmnDedx::fLowFsdClusters
TClonesArray * fLowFsdClusters
Definition
BmnDedx.h:68
BmnDedx::fLowGemClusters
TClonesArray * fLowGemClusters
Definition
BmnDedx.h:67
BmnDedx::fNSect
vector< Int_t > fNSect
Definition
BmnDedx.h:58
BmnDedx::fMinMom
Float_t fMinMom
Definition
BmnDedx.h:54
BmnDedx::CalcDedx
void CalcDedx(BmnGlobalTrack *tr)
Definition
BmnDedx.cxx:159
BmnDedx::fNormDedxThresh
Float_t fNormDedxThresh
Definition
BmnDedx.h:56
BmnDedx::fNMomSlices
Int_t fNMomSlices
Definition
BmnDedx.h:59
BmnDedx::fStsHits
TClonesArray * fStsHits
Definition
BmnDedx.h:66
BmnDedx::b
Float_t *** b
Definition
BmnDedx.h:63
BmnDedx::~BmnDedx
virtual ~BmnDedx()
Destructor.
Definition
BmnDedx.cxx:242
BmnDedx::fRunId
Int_t fRunId
Definition
BmnDedx.h:64
BmnDedx::GetQ
Short_t GetQ(BmnGlobalTrack *tr)
Definition
BmnDedx.cxx:234
BmnDedx::fMaxMomBound
vector< Float_t > fMaxMomBound
Definition
BmnDedx.h:61
BmnDedx::CalcNormalizedDedx
Float_t CalcNormalizedDedx(BmnGlobalTrack *tr)
Definition
BmnDedx.cxx:229
BmnDedx::fMaxMom
Float_t fMaxMom
Definition
BmnDedx.h:55
BmnDedx::fDedx
Float_t fDedx
Definition
BmnDedx.h:70
BmnDedx::Exec
virtual void Exec(Option_t *opt)
Inherited from FairTask.
Definition
BmnDedx.cxx:51
BmnDedx::fNSt
Int_t fNSt
Definition
BmnDedx.h:57
BmnDedx::GetDedx
Float_t GetDedx(BmnGlobalTrack *tr)
Definition
BmnDedx.cxx:223
BmnDedx::BmnDedx
BmnDedx()
Constructor.
Definition
BmnDedx.cxx:3
BmnDedx::fTime
Double_t fTime
Definition
BmnDedx.h:72
BmnDedx::Finish
virtual void Finish()
Inherited from FairTask.
Definition
BmnDedx.cxx:75
BmnDedx::fStsTracks
TClonesArray * fStsTracks
Definition
BmnDedx.h:65
BmnDedx::fMinMomBound
vector< Float_t > fMinMomBound
Definition
BmnDedx.h:60
BmnDedx::fAlephFit_He4
TF1 * fAlephFit_He4
Definition
BmnDedx.h:53
BmnGlobalTrack
BmnGlobalTrack.h.
Definition
BmnGlobalTrack.h:14
BmnGlobalTrack::SetDedx
void SetDedx(Float_t dedx)
Definition
BmnGlobalTrack.h:93
BmnGlobalTrack::SetQ
void SetQ(Int_t q)
Definition
BmnGlobalTrack.h:92
BmnGlobalTrack::GetDedx
Float_t GetDedx() const
Definition
BmnGlobalTrack.h:68
BmnGlobalTrack::GetGemTrackIndex
Int_t GetGemTrackIndex() const
Accessors.
Definition
BmnGlobalTrack.h:34
BmnTrack::GetP
Double_t GetP()
Definition
BmnTrack.h:67
CbmStsHit
Definition
CbmStsHit.h:27
CbmStsHit::GetStationNr
virtual Int_t GetStationNr() const
Definition
CbmStsHit.h:67
CbmStsHit::GetSectorNr
Int_t GetSectorNr() const
Definition
CbmStsHit.h:68
CbmStsHit::GetSystemId
Int_t GetSystemId() const
Accessors.
Definition
CbmStsHit.h:66
CbmStsHit::fDigiF
Int_t fDigiF
Definition
CbmStsHit.h:101
CbmStsTrack
Definition
CbmStsTrack.h:28
CbmStsTrack::GetNStsHits
Int_t GetNStsHits() const
Accessors.
Definition
CbmStsTrack.h:60
CbmStsTrack::GetStsHitIndex
Int_t GetStsHitIndex(Int_t iHit) const
Definition
CbmStsTrack.h:62
StripCluster
Definition
BmnStripData.h:177
StripCluster::TotalSignal
Double_t TotalSignal
Definition
BmnStripData.h:181
TClonesArray
TDirectoryFile::Get
T * Get(const char *namecycle)
TF1
TFile
TFile::Open
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
TFile::Close
void Close(Option_t *option="") override
TH1F
TH1::GetBinContent
virtual Double_t GetBinContent(Int_t bin) const
TH1::FindBin
virtual Int_t FindBin(Double_t x, Double_t y=0, Double_t z=0)
TStopwatch
TStopwatch::RealTime
Double_t RealTime()
TStopwatch::Start
void Start(Bool_t reset=kTRUE)
TStopwatch::Stop
void Stop()
TString
BmnDedx.h
reconstruction
identification
BmnDedx.cxx
Generated on
for BmnRoot by
1.17.0