CbmRoot
Loading...
Searching...
No Matches
CbmTrdSetTracksPidModWkn.cxx
Go to the documentation of this file.
1/* Copyright (C) 2014-2016 Laboratory of Information Technologies, Joint Institute for Nuclear Research, Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Olga Derenovskaya [committer], Florian Uhlig */
4
5// -------------------------------------------------------------------------
6// ----- CbmTrdSetTracksPidModWkn source file -----
7// ----- -----
8// -------------------------------------------------------------------------
10
11#include "CbmMCTrack.h"
12#include "CbmTrackMatch.h"
13#include "CbmTrdHit.h"
14#include "CbmTrdPoint.h"
15#include "CbmTrdTrack.h"
16#include "FairRootManager.h"
17#include "TClonesArray.h"
18#include "TMath.h"
19#include "TStopwatch.h"
20#include "Vc/Vc"
21
22#include <cmath>
23#include <iomanip>
24#include <iostream>
25#include <vector>
26
27using std::cout;
28using std::endl;
29
30// ----- Default constructor -------------------------------------------
32// -------------------------------------------------------------------------
33
34// ----- Standard constructor ------------------------------------------
36 : FairTask(name)
37 , fTrackArray(NULL)
38 , fTrdHitArray(NULL)
39 , fnSet(0)
40 , fdegWkn(0)
41 , fk1(0)
42 , fwkn0(0)
43 , fEmp(0)
44 , fXi(0)
45 , fWmin(0)
46 , fWmax(0)
47 , fDiff(0)
48 , fSISType("sis300")
49{
50}
51// -------------------------------------------------------------------------
52
53
54// ----- Destructor ----------------------------------------------------
56// -------------------------------------------------------------------------
57
58
59// ----- Public method Init (abstract in base class) --------------------
61{
62
63 // Get and check FairRootManager
64 FairRootManager* ioman = FairRootManager::Instance();
65 if (!ioman) {
66 cout << "-E- CbmTrdSetTracksPidModWkn::Init: "
67 << "RootManager not instantised!" << endl;
68 return kFATAL;
69 }
70
71 // Get TrdTrack array
72 fTrackArray = (TClonesArray*) ioman->GetObject("TrdTrack");
73 if (!fTrackArray) {
74 cout << "-E- CbmTrdSetTracksPidModWkn::Init: No TrdTrack array!" << endl;
75 return kERROR;
76 }
77
78 // Get TrdHit array
79 fTrdHitArray = (TClonesArray*) ioman->GetObject("TrdHit");
80 if (!fTrdHitArray) {
81 cout << "-E- CbmTrdSetTracksPidModWkn::Init: No TrdHit array!" << endl;
82 return kERROR;
83 }
84
86 // fmom = new TH1D("(p_{rec}-p_{mc})/p_{mc}","",400, -1, 1);
87 return kSUCCESS;
88}
89// -------------------------------------------------------------------------
90
91
92// ----- Public method Exec --------------------------------------------
94{
95
96 TStopwatch timer;
97 timer.Start();
98
99 if (!fTrackArray) return;
100
101 float ti = 0, mom = 0;
102
103 std::vector<float> eLossVector; // vector for energy losses
104
105 Vc::float_v* mWkn = new Vc::float_v[fnSet];
106 Vc::float_v resWkn = 0;
107 Vc::float_v numTr = 0;
108
109 // int nTracks_SIMD = Vc::float_v::Size;
110 int NHits = 0;
111 int iV = 0;
112
113 unsigned short nTracks = fTrackArray->GetEntriesFast();
114 unsigned short nTrue = 0;
115
116 for (unsigned short itr = 0; itr < nTracks; itr++) {
117 CbmTrdTrack* pTr = (CbmTrdTrack*) fTrackArray->At(itr);
118 if ((pTr->GetNofHits()) > fnSet - 1)
119 nTrue++;
120 else
121 pTr->SetPidWkn(-2.);
122 }
123
124 for (unsigned short itrack = 0; itrack < nTrue; itrack++) {
125 eLossVector.clear();
126
127 CbmTrdTrack* pTrack = (CbmTrdTrack*) fTrackArray->At(itrack);
128 NHits = pTrack->GetNofHits();
129 numTr[iV] = itrack;
130 mom = fabs(1.f / pTrack->GetParamFirst()->GetQp());
131
132 fEmp = 0.0002598 * mom * mom * mom - 0.008862 * mom * mom + 0.1176 * mom + 0.9129;
133 fXi = 0.00008938 * mom * mom * mom - 0.003022 * mom * mom + 0.03999 * mom + 0.5292;
134
135 for (Int_t iHit = 0; iHit < NHits; iHit++) {
136 Int_t TRDindex = pTrack->GetHitIndex(iHit);
137 CbmTrdHit* trdHit = (CbmTrdHit*) fTrdHitArray->At(TRDindex);
138 eLossVector.push_back((trdHit->GetELoss()) * 1000000);
139 }
140
141 for (unsigned int jVec = 0; jVec < eLossVector.size(); jVec++)
142 eLossVector[jVec] = (eLossVector[jVec] - fEmp) / fXi - 0.225;
143
144 sort(eLossVector.begin(), eLossVector.end());
145
146 for (unsigned int jVec = 0; jVec < eLossVector.size(); jVec++)
147 eLossVector[jVec] = TMath::LandauI(eLossVector[jVec]);
148
149 for (Int_t iHit = 0; iHit < fnSet; iHit++)
150 mWkn[iHit][iV] = eLossVector[NHits - fnSet + iHit];
151
152 iV++;
153
154 if (!((iV == Vc::float_v::Size) || ((itrack == (nTrue - 1)) && (iV != 0)))) continue;
155
156 Vc::float_v sumWkn = 0;
157 for (Int_t iHit = 0; iHit < fnSet; iHit++) {
158 ti = iHit + 1;
159 Vc::float_v g1 = (ti - 1) / fnSet - mWkn[iHit];
160 Vc::float_v g2 = ti / fnSet - mWkn[iHit];
161 Vc::float_v s1 = 1, s2 = 1;
162 for (int iPow = 0; iPow < 5; iPow++) {
163 s1 *= g1;
164 s2 *= g2;
165 }
166 sumWkn += s1 - s2;
167 }
168
169 // resWkn = -fwkn0*sumWkn;
170 // resWkn = 2*(-fwkn0*sumWkn-fWmin)/fDiff-1; //[-1;1]
171 resWkn = (-fwkn0 * sumWkn - fWmin) / fDiff; //[0;1]
172
173
174 for (Int_t iHit = 0; iHit < iV; iHit++) {
175 CbmTrdTrack* pTrack2 = (CbmTrdTrack*) fTrackArray->At(numTr[iHit]);
176 pTrack2->SetPidWkn(resWkn[iHit]);
177 }
178
179 iV = 0;
180 }
181
182 delete[] mWkn;
183
184 timer.Stop();
185 static int nEv = 0;
186 nEv++;
187 static Double_t rtime = 0;
188 rtime += timer.RealTime();
189 static Double_t ctime = 0;
190 ctime += timer.CpuTime();
191 cout << endl << endl;
192 cout << "--CbmTrdSetTracksPidModWkn--" << endl;
193 cout << "Real time " << (rtime / Double_t(nEv)) << " s, CPU time " << (ctime / Double_t(nEv)) << "s" << endl << endl;
194}
195
196
198{
199 if (fSISType == "sis300") {
200 fnSet = 5; // number of the layers with TR
201 fdegWkn = 4; // statistics degree
202 }
203
204 if (fSISType == "sis100") {
205 fnSet = 2; // number of the layers with TR
206 fdegWkn = 2; // statistics degree
207 }
208
209 fk1 = fdegWkn + 1;
210 fwkn0 = pow(fnSet, 0.5 * fdegWkn) / fk1;
211 fWmin = 1 / (pow(2, fdegWkn) * pow(fnSet, fdegWkn / 2) * (fdegWkn + 1)),
212 fWmax = pow(fnSet, fdegWkn / 2) / (fdegWkn + 1), fDiff = fWmax - fWmin;
213}
214
215
216// ----- Public method Finish ------------------------------------------
218{
219 //fmom->Write();
220}
221// -------------------------------------------------------------------------
222
ClassImp(CbmConverterManager)
Class for hits in TRD detector.
virtual int32_t GetNofHits() const
Definition CbmTrack.h:58
const FairTrackParam * GetParamFirst() const
Definition CbmTrack.h:68
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)
void SetPidWkn(double pid)
Definition CbmTrdTrack.h:50