CbmRoot
Loading...
Searching...
No Matches
CbmTrdSetTracksPidWkn.cxx
Go to the documentation of this file.
1/* Copyright (C) 2007-2019 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Florian Uhlig [committer], Philipp Kähler */
4
5// -------------------------------------------------------------------------
6// ----- CbmTrdSetTracksPidWkn source file -----
7// ----- Created 13/02/07 by F.Uhlig -----
8//------ Last modification 01/07/18 by O.Derenovskaya
9// -------------------------------------------------------------------------
11
12#include "CbmTrdHit.h"
13#include "CbmTrdTrack.h"
14#include "FairRootManager.h"
15#include "TClonesArray.h"
16#include "TMath.h"
17
18#include <iostream>
19#include <vector>
20
21using std::cout;
22using std::endl;
23
24
25// ----- Default constructor -------------------------------------------
27// -------------------------------------------------------------------------
28
29
30// ----- Standard constructor ------------------------------------------
32 : FairTask(name)
33 , fnSet(0)
34 , fdegWkn(0)
35 , fNofTracks(0)
36 , fk1(0)
37 , fwkn0(0)
38 , fEmp(0)
39 , fXi(0)
40 , fWmin(0)
41 , fWmax(0)
42 , fDiff(0)
43 , fSISType("sis100")
44 , fTrackArray(NULL)
45 , fTrdHitArray(NULL)
46
47
48{
49}
50// -------------------------------------------------------------------------
51
52
53// ----- Destructor ----------------------------------------------------
55// -------------------------------------------------------------------------
56
57
58// ----- SetParContainers -------------------------------------------------
60// -------------------------------------------------------------------------
61
62
63// ----- Public method Init (abstract in base class) --------------------
65{
66
67 // Get and check FairRootManager
68 FairRootManager* ioman = FairRootManager::Instance();
69 if (!ioman) {
70 cout << "-E- CbmTrdSetTracksPidWkn::Init: "
71 << "RootManager not instantised!" << endl;
72 return kFATAL;
73 }
74
75 // Get TrdTrack array
76 fTrackArray = (TClonesArray*) ioman->GetObject("TrdTrack");
77 if (!fTrackArray) {
78 cout << "-E- CbmTrdSetTracksPidWkn::Init: No TrdTrack array!" << endl;
79 return kERROR;
80 }
81
82 // Get TrdHit array
83 fTrdHitArray = (TClonesArray*) ioman->GetObject("TrdHit");
84 if (!fTrdHitArray) {
85 cout << "-E- CbmTrdSetTracksPidWkn::Init: No TrdHit array!" << endl;
86 return kERROR;
87 }
88
90
91 return kSUCCESS;
92}
93// -------------------------------------------------------------------------
94
95
96// ----- Public method Exec --------------------------------------------
98{
99
100 if (!fTrackArray) return;
101
102 Int_t nTracks = fTrackArray->GetEntriesFast();
103
104 Double_t result_wkn;
105 Int_t NHits;
106
107 fNofTracks = 0;
108
109
110 std::vector<float> eLossVectorTmp;
111 std::vector<float> eLossVector;
112
113 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
114 eLossVectorTmp.clear();
115 eLossVector.clear();
116 CbmTrdTrack* pTrack = (CbmTrdTrack*) fTrackArray->At(iTrack);
117 NHits = pTrack->GetNofHits();
118
119 // Set total energy loss member in CbmTrdTack object if not already done
120 assert(pTrack);
121 if (pTrack->GetELoss() < 0.) {
122 double_t sumEloss = 0.;
123 for (Int_t iHit = 0; iHit < NHits; iHit++) {
124 CbmTrdHit* hit = (CbmTrdHit*) fTrdHitArray->At(pTrack->GetHitIndex(iHit));
125 assert(hit);
126 sumEloss += hit->GetELoss();
127 }
128 pTrack->SetELoss(sumEloss);
129 } //? Track energy loss not set
130
131 // Up to now only for tracks with twelve hits the Wkn can be calculated
132 // This should be changed in the future.
133 if (NHits < fnSet) {
134 fNofTracks++;
135 pTrack->SetPidWkn(-2.);
136 continue;
137 }
138
139 for (Int_t iTRD = 0; iTRD < NHits; iTRD++) {
140 Int_t TRDindex = pTrack->GetHitIndex(iTRD);
141 CbmTrdHit* trdHit = (CbmTrdHit*) fTrdHitArray->At(TRDindex);
142 eLossVectorTmp.push_back((trdHit->GetELoss()) * 1000000);
143 }
144
145 // calculate the lambda parameter for each TRD layer
146 for (unsigned int jVec = 0; jVec < eLossVectorTmp.size(); jVec++)
147 eLossVectorTmp[jVec] = (eLossVectorTmp[jVec] - fEmp) / fXi - 0.225;
148
149 sort(eLossVectorTmp.begin(), eLossVectorTmp.end());
150
151 for (unsigned int jVec = 0; jVec < eLossVectorTmp.size(); jVec++) {
152 eLossVectorTmp[jVec] = TMath::LandauI(eLossVectorTmp[jVec]);
153 }
154
155 for (int iHit = 0; iHit < fnSet; iHit++)
156 eLossVector.push_back(eLossVectorTmp[NHits - fnSet + iHit]);
157
158 // calculate the Wkn and add the information to the TrdTrack
159
160 Double_t S = 0, ty = 0, ti = 0;
161
162 for (Int_t i = 0; i < fnSet; i++) {
163 ty = eLossVector[i];
164 ti = i;
165 S += pow((ti - 1) / fnSet - ty, fk1) - pow(ti / fnSet - ty, fk1);
166 }
167 result_wkn = -fwkn0 * S;
168 // cout<<result_wkn<<endl;
169 pTrack->SetPidWkn(result_wkn);
170 }
171}
172// -------------------------------------------------------------------------
173
174// ----- Public method Finish ------------------------------------------
176// -------------------------------------------------------------------------
177
179{
180 if (fSISType == "sis300") {
181 fnSet = 5; // number of the layers with TR
182 fdegWkn = 4; // statistics degree
183 fEmp = 1.06;
184 fXi = 0.57;
185 }
186
187 if (fSISType == "sis100") {
188 fnSet = 3; // number of the layers with TR
189 fdegWkn = 2; // statistics degree
190 fEmp = 3.5;
191 fXi = 5.0;
192 }
193
194
195 fk1 = fdegWkn + 1;
196 fwkn0 = pow(fnSet, 0.5 * fdegWkn) / fk1;
197 fWmin = 1 / (pow(2, fdegWkn) * pow(fnSet, fdegWkn / 2) * (fdegWkn + 1));
198 fWmax = pow(fnSet, fdegWkn / 2) / (fdegWkn + 1);
199 fDiff = fWmax - fWmin;
200}
201
ClassImp(CbmConverterManager)
Class for hits in TRD detector.
virtual int32_t GetNofHits() const
Definition CbmTrack.h:58
int32_t GetHitIndex(int32_t iHit) const
Definition CbmTrack.h:59
data class for a reconstructed Energy-4D measurement in the TRD
Definition CbmTrdHit.h:40
double GetELoss() const
Definition CbmTrdHit.h:79
virtual void Exec(Option_t *opt)
double GetELoss() const
Definition CbmTrdTrack.h:42
void SetELoss(double eLoss)
Definition CbmTrdTrack.h:52
void SetPidWkn(double pid)
Definition CbmTrdTrack.h:50