CbmRoot
Loading...
Searching...
No Matches
CbmStsWkn.cxx
Go to the documentation of this file.
1/* Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Olga Derenovskaya, Volker Friese [committer] */
4
11#include "CbmStsWkn.h"
12
13#include "CbmGlobalTrack.h"
14#include "CbmStsCluster.h"
15#include "CbmStsDigi.h"
16#include "CbmStsHit.h"
17#include "CbmStsTrack.h"
18
19#include "FairRootManager.h"
20
21#include "TClonesArray.h"
22#include "TMath.h"
23#include "TString.h"
24#include "TSystem.h"
25
26#include <iostream>
27
28#include <cmath>
29using std::cout;
30using std::endl;
31using std::fabs;
32using std::map;
33using std::vector;
34
35CbmStsWkn::CbmStsWkn() : fdegWkn(4), fEmp(2.4), fXi(0.5), fk1(fdegWkn + 1), fnSet(8), fwkn(-1) { Init(); }
36
38
40{
41 FairRootManager* ioman = FairRootManager::Instance();
42 if (ioman != nullptr) {
43 fGlobalTracks = (TClonesArray*) ioman->GetObject("GlobalTrack");
44 fStsTracks = (TClonesArray*) ioman->GetObject("StsTrack");
45 fStsHits = (TClonesArray*) ioman->GetObject("StsHit");
46 fStsClusterArray = (TClonesArray*) ioman->GetObject("StsCluster");
47 fStsDigiArray = (TClonesArray*) ioman->GetObject("StsDigi");
48 }
49}
50
51Double_t CbmStsWkn::GetStsWkn(Int_t StsTrackIndex)
52{
53 double dr = 1.;
54 std::vector<float> eLossVector;
55 std::vector<float> dEdxAllveto;
56
57 CbmStsTrack* StsTrack = (CbmStsTrack*) fStsTracks->At(StsTrackIndex);
58 if (StsTrack == NULL) return fwkn;
59
60 int nClustersWveto = StsTrack->GetNofStsHits() + StsTrack->GetNofStsHits(); //assume all clusters with veto
61 if (nClustersWveto < 8) return fwkn;
62
63 //cout<<fnSet<<endl;
64 for (int iHit = 0; iHit < StsTrack->GetNofStsHits(); ++iHit) {
65 Int_t StsHitIndex = StsTrack->GetStsHitIndex(iHit);
66 CbmStsHit* stsHit = (CbmStsHit*) fStsHits->At(StsHitIndex);
67
68 // ***********dx=dr is calculated from the track inclination
69 double x, y, z, xNext, yNext, zNext;
70 x = stsHit->GetX();
71 y = stsHit->GetY();
72 z = stsHit->GetZ();
73
74 if (iHit != StsTrack->GetNofStsHits() - 1) {
75 CbmStsHit* stsHitNext = (CbmStsHit*) fStsHits->At(StsTrack->GetStsHitIndex(iHit + 1));
76 xNext = stsHitNext->GetX();
77 yNext = stsHitNext->GetY();
78 zNext = stsHitNext->GetZ();
79 dr = sqrt((xNext - x) * (xNext - x) + (yNext - y) * (yNext - y) + (zNext - z) * (zNext - z))
80 / (zNext - z); // if *300um, you get real reconstructed dr
81 } // else dr stay previous
82 // ***********End of dr calculation
83
84 //************dE is defined as a total cluster charge
85 Int_t FrontClusterId = stsHit->GetFrontClusterId();
86 CbmStsCluster* frontCluster = (CbmStsCluster*) fStsClusterArray->At(FrontClusterId);
87 Int_t BackClusterId = stsHit->GetBackClusterId();
88 CbmStsCluster* backCluster = (CbmStsCluster*) fStsClusterArray->At(BackClusterId);
89
90 if (!frontCluster || !backCluster) return fwkn;
91
92 dEdxAllveto.push_back((frontCluster->GetCharge()) / dr);
93 dEdxAllveto.push_back((backCluster->GetCharge()) / dr);
94 }
95
96 if (dEdxAllveto.size() != 0) {
97 unsigned int NSample = dEdxAllveto.size();
98
99 for (unsigned int jVec = 0; jVec < NSample; jVec++)
100 dEdxAllveto[jVec] = dEdxAllveto[jVec] / 10000;
101
102 for (unsigned int jVec = 0; jVec < NSample; jVec++)
103 dEdxAllveto[jVec] = (dEdxAllveto[jVec] - fEmp) / fXi - 0.225;
104
105 sort(dEdxAllveto.begin(), dEdxAllveto.end());
106
107 for (unsigned int jVec = 0; jVec < NSample; jVec++)
108 dEdxAllveto[jVec] = TMath::LandauI(dEdxAllveto[jVec]);
109
110
111 for (int iHit = 0; iHit < fnSet; iHit++)
112 eLossVector.push_back(dEdxAllveto[NSample - fnSet + iHit]);
113 }
114
115 Double_t S = 0, ty = 0, ti = 0;
116
117 for (Int_t i = 0; i < fnSet; i++) {
118 ty = eLossVector[i];
119 ti = i;
120 S += pow((ti - 1) / fnSet - ty, fk1) - pow(ti / fnSet - ty, fk1);
121 }
122 float fwkn0 = pow(fnSet, 0.5 * fdegWkn) / fk1;
123 Double_t result_wkn = -fwkn0 * S;
124
125 return result_wkn;
126}
127
128Double_t CbmStsWkn::GetStsWkn(const CbmStsTrack* StsTrack)
129{
130 double dr = 1.;
131 std::vector<float> eLossVector;
132 std::vector<float> dEdxAllveto;
133
134 int nClustersWveto = StsTrack->GetNofStsHits() + StsTrack->GetNofStsHits(); //assume all clusters with veto
135 if (nClustersWveto < 8) return fwkn;
136
137 //cout<<fnSet<<endl;
138 for (int iHit = 0; iHit < StsTrack->GetNofStsHits(); ++iHit) {
139 Int_t StsHitIndex = StsTrack->GetStsHitIndex(iHit);
140 CbmStsHit* stsHit = (CbmStsHit*) fStsHits->At(StsHitIndex);
141
142 // ***********dx=dr is calculated from the track inclination
143 double x, y, z, xNext, yNext, zNext;
144 x = stsHit->GetX();
145 y = stsHit->GetY();
146 z = stsHit->GetZ();
147
148 if (iHit != StsTrack->GetNofStsHits() - 1) {
149 CbmStsHit* stsHitNext = (CbmStsHit*) fStsHits->At(StsTrack->GetStsHitIndex(iHit + 1));
150 xNext = stsHitNext->GetX();
151 yNext = stsHitNext->GetY();
152 zNext = stsHitNext->GetZ();
153 dr = sqrt((xNext - x) * (xNext - x) + (yNext - y) * (yNext - y) + (zNext - z) * (zNext - z))
154 / (zNext - z); // if *300um, you get real reconstructed dr
155 } // else dr stay previous
156 // ***********End of dr calculation
157
158 //************dE is defined as a total cluster charge
159 Int_t FrontClusterId = stsHit->GetFrontClusterId();
160 CbmStsCluster* frontCluster = (CbmStsCluster*) fStsClusterArray->At(FrontClusterId);
161 Int_t BackClusterId = stsHit->GetBackClusterId();
162 CbmStsCluster* backCluster = (CbmStsCluster*) fStsClusterArray->At(BackClusterId);
163
164 if (!frontCluster || !backCluster) return fwkn;
165
166 dEdxAllveto.push_back((frontCluster->GetCharge()) / dr);
167 dEdxAllveto.push_back((backCluster->GetCharge()) / dr);
168 }
169
170 if (dEdxAllveto.size() != 0) {
171 unsigned int NSample = dEdxAllveto.size();
172
173 for (unsigned int jVec = 0; jVec < NSample; jVec++)
174 dEdxAllveto[jVec] = dEdxAllveto[jVec] / 10000;
175
176 for (unsigned int jVec = 0; jVec < NSample; jVec++)
177 dEdxAllveto[jVec] = (dEdxAllveto[jVec] - fEmp) / fXi - 0.225;
178
179 sort(dEdxAllveto.begin(), dEdxAllveto.end());
180
181 for (unsigned int jVec = 0; jVec < NSample; jVec++)
182 dEdxAllveto[jVec] = TMath::LandauI(dEdxAllveto[jVec]);
183
184
185 for (int iHit = 0; iHit < fnSet; iHit++)
186 eLossVector.push_back(dEdxAllveto[NSample - fnSet + iHit]);
187 }
188
189 Double_t S = 0, ty = 0, ti = 0;
190
191 for (Int_t i = 0; i < fnSet; i++) {
192 ty = eLossVector[i];
193 ti = i;
194 S += pow((ti - 1) / fnSet - ty, fk1) - pow(ti / fnSet - ty, fk1);
195 }
196 float fwkn0 = pow(fnSet, 0.5 * fdegWkn) / fk1;
197 Double_t result_wkn = -fwkn0 * S;
198
199 return result_wkn;
200}
201
Data class for STS clusters.
Data class for a reconstructed hit in the STS.
Data class for STS tracks.
ClassImp(CbmStsWkn)
friend fvec sqrt(const fvec &a)
double GetZ() const
Definition CbmHit.h:71
double GetY() const
Definition CbmPixelHit.h:74
double GetX() const
Definition CbmPixelHit.h:73
Data class for STS clusters.
double GetCharge() const
Get cluster charge @value Total cluster charge [e].
data class for a reconstructed 3-d hit in the STS
Definition CbmStsHit.h:35
int32_t GetFrontClusterId() const
Definition CbmStsHit.h:105
int32_t GetBackClusterId() const
Definition CbmStsHit.h:65
int32_t GetStsHitIndex(int32_t iHit) const
int32_t GetNofStsHits() const
Definition CbmStsTrack.h:93
TClonesArray * fStsTracks
Definition CbmStsWkn.h:58
float fXi
Definition CbmStsWkn.h:52
Int_t fdegWkn
Definition CbmStsWkn.h:50
virtual ~CbmStsWkn()
Definition CbmStsWkn.cxx:37
Double_t GetStsWkn(Int_t StsTrackIndex)
Return Wkn value.
Definition CbmStsWkn.cxx:51
Double_t fwkn
Definition CbmStsWkn.h:55
TClonesArray * fStsClusterArray
Definition CbmStsWkn.h:60
TClonesArray * fStsDigiArray
Definition CbmStsWkn.h:61
Int_t fnSet
Definition CbmStsWkn.h:54
float fk1
Definition CbmStsWkn.h:53
void Init()
Definition CbmStsWkn.cxx:39
float fEmp
Definition CbmStsWkn.h:51
TClonesArray * fGlobalTracks
Definition CbmStsWkn.h:57
TClonesArray * fStsHits
Definition CbmStsWkn.h:59