BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnDedx.cxx
Go to the documentation of this file.
1#include "BmnDedx.h"
2
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
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
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) {
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
76{
77 printf("Work time of BmnDedx: %4.2f sec.\n", fTime);
78}
79
80InitStatus 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
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
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
224{
225 fDedx = tr->GetDedx();
226 return fDedx;
227}
228
233
235{
237 return 2;
238 else
239 return 1;
240}
241
int i
Definition P4_F32vec4.h:22
int Int_t
float Float_t
short Short_t
constexpr Bool_t kFALSE
const char Option_t
void Fatal(const char *location, const char *msgfmt,...)
char * Form(const char *fmt,...)
@ kSILICON
@ kGEM
Float_t *** a
Definition BmnDedx.h:62
TClonesArray * fGlobTracks
Definition BmnDedx.h:69
virtual InitStatus Init()
Inherited from FairTask.
Definition BmnDedx.cxx:80
TClonesArray * fLowFsdClusters
Definition BmnDedx.h:68
TClonesArray * fLowGemClusters
Definition BmnDedx.h:67
vector< Int_t > fNSect
Definition BmnDedx.h:58
Float_t fMinMom
Definition BmnDedx.h:54
void CalcDedx(BmnGlobalTrack *tr)
Definition BmnDedx.cxx:159
Float_t fNormDedxThresh
Definition BmnDedx.h:56
Int_t fNMomSlices
Definition BmnDedx.h:59
TClonesArray * fStsHits
Definition BmnDedx.h:66
Float_t *** b
Definition BmnDedx.h:63
virtual ~BmnDedx()
Destructor.
Definition BmnDedx.cxx:242
Int_t fRunId
Definition BmnDedx.h:64
Short_t GetQ(BmnGlobalTrack *tr)
Definition BmnDedx.cxx:234
vector< Float_t > fMaxMomBound
Definition BmnDedx.h:61
Float_t CalcNormalizedDedx(BmnGlobalTrack *tr)
Definition BmnDedx.cxx:229
Float_t fMaxMom
Definition BmnDedx.h:55
Float_t fDedx
Definition BmnDedx.h:70
virtual void Exec(Option_t *opt)
Inherited from FairTask.
Definition BmnDedx.cxx:51
Int_t fNSt
Definition BmnDedx.h:57
Float_t GetDedx(BmnGlobalTrack *tr)
Definition BmnDedx.cxx:223
BmnDedx()
Constructor.
Definition BmnDedx.cxx:3
Double_t fTime
Definition BmnDedx.h:72
virtual void Finish()
Inherited from FairTask.
Definition BmnDedx.cxx:75
TClonesArray * fStsTracks
Definition BmnDedx.h:65
vector< Float_t > fMinMomBound
Definition BmnDedx.h:60
TF1 * fAlephFit_He4
Definition BmnDedx.h:53
BmnGlobalTrack.h.
void SetDedx(Float_t dedx)
void SetQ(Int_t q)
Float_t GetDedx() const
Int_t GetGemTrackIndex() const
Accessors.
Double_t GetP()
Definition BmnTrack.h:67
virtual Int_t GetStationNr() const
Definition CbmStsHit.h:67
Int_t GetSectorNr() const
Definition CbmStsHit.h:68
Int_t GetSystemId() const
Accessors.
Definition CbmStsHit.h:66
Int_t fDigiF
Definition CbmStsHit.h:101
Int_t GetNStsHits() const
Accessors.
Definition CbmStsTrack.h:60
Int_t GetStsHitIndex(Int_t iHit) const
Definition CbmStsTrack.h:62
Double_t TotalSignal
T * Get(const char *namecycle)
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
void Close(Option_t *option="") override
virtual Double_t GetBinContent(Int_t bin) const
virtual Int_t FindBin(Double_t x, Double_t y=0, Double_t z=0)
Double_t RealTime()
void Start(Bool_t reset=kTRUE)
void Stop()