BmnRoot
Loading...
Searching...
No Matches
BmnStsVectorFinderV9.h
Go to the documentation of this file.
1// -------------------------------------------------------------------------
2// ----- BmnStsVectorFinder header file -----
3// ----- Created 3/12/21 by A.Zinchenko, D.Zinchenko, R.Zinchenko -----
4// -------------------------------------------------------------------------
5
6/*** BmnStsVectorFinder.h
7 *@author A.Zinchenko <Alexander.Zinchenko@jinr.ru>
8 **
9 ** Vector Finder in BM@N tracker
10 **/
11
12#ifndef BMNSTSVECTORFINDERV9_H
13#define BMNSTSVECTORFINDERV9_H 1
14
15#include "BmnGemStripStationSet.h"
16#include "BmnSiliconStationSet.h"
17#include "BmnStsKFTrackFitter.h"
18#include "CbmStsKFTrackFitter.h"
19#include "CbmStsTrack.h"
20#include "FairTask.h"
21
22#include <TClonesArray.h>
23#include <TMVA/Reader.h> //AZ-300922
24#include <TProfile2D.h>
25#include <TVector3.h>
26#include <fstream>
27#include <set>
28#include <string>
29#include <unordered_map>
30
31// typedef std::pair<Double_t,std::map<Int_t,Int_t> > candvec;
32
33class BmnStsVectorFinderV9 : public FairTask
34{
35
36 public:
37 struct hitinfo
38 {
40 hitinfo(TVector3 v3, Double_t phxi, Double_t txi, Double_t tyi)
41 : xyz(v3)
42 , phx(phxi)
43 , tx(txi)
44 , ty(tyi)
45 , used(0)
46 {
47 ;
48 }
49 TVector3 xyz;
50 Double_t phx;
51 Double_t tx;
52 Double_t ty;
53 int used;
54 };
55
56 struct candvec
57 {
58 Int_t nskips;
59 Int_t idmaxP;
60 Double_t momxz;
61 Double_t ty;
62 Double_t lengxz;
63 // Double_t varx;
64 Double_t tx;
65 std::map<Int_t, Int_t> stahit;
66 std::string code;
67 FairTrackParam param;
68 Double_t chi2;
70 candvec(Double_t momi, std::map<Int_t, Int_t> stahi)
71 : nskips(0)
72 , momxz(momi)
73 , stahit(stahi)
74 {
75 ;
76 }
77 };
78
81
84
86 virtual InitStatus Init();
87
89 virtual void Exec(Option_t* opt);
90
92 virtual void FinishEvent();
93
95 virtual void Finish();
96
97 void SetMatBudgetFileName(TString s) { fMatBudgetFileName = s; }
98 void SetNofSiStations(int nsi) { fNSi = nsi; } // AZ-051022
99 int GetNofSiStations() const { return fNSi; } // AZ-280725
100
101 private:
102 // void ReadMatBudget();
103 void ReadTxInfo(TString fileName);
104 Int_t ExcludeHits(Int_t minHits, TClonesArray* trArray);
105 std::set<Int_t> GetHitId(CbmStsHit* hit, Int_t& idmaxP);
106 std::set<Int_t> GetHitIdBmn(CbmStsHit* hit, Int_t& idmaxP);
107 std::set<Int_t> GetHitId(Int_t hitInd, Int_t& idmaxP)
108 {
109 return GetHitId((CbmStsHit*)fHitArray->UncheckedAt(hitInd), idmaxP);
110 }
111 // AZ-080623 void BuildTrackCand();
112 void FillHitInfo(); // AZ-080623
113 void BuildDoublets();
114 int FindBin(int ista, Float_t binw, Float_t tx);
115 Float_t BinCenterTx(int ista, int ibin, Float_t binw);
116 void DTxWindow(int ista2, Float_t tx, int idu, Float_t curvCut, Float_t* dtx);
117 Bool_t CheckVarx(Double_t dx, Double_t dz, Double_t tx, Double_t distxz, Double_t& varx); // AZ-310722
118 void BuildTriplets();
119 void BuildTracks();
120 void ExtendTrack(candvec cand);
121 Double_t FitTrack(candvec& cand);
122 Double_t FilterHit(candvec& cand, CbmStsTrack& track);
123 void MakeStsTrack(candvec& cand, std::string& hitcode, CbmStsTrack& track);
124 void ExtendTracks(Int_t ista);
125 TVector3 Parabola(TVector3& pos0, TVector3& pos1, TVector3& pos2, int ix = 0);
126 void FitTracks();
127 void RemoveDoubles();
128 Bool_t AreTracksDoubles(CbmStsTrack& tr1, CbmStsTrack& tr2);
129 void RemoveFakes();
130 void ExcludeFakes();
131 Double_t DxVsMom(Int_t ista, candvec& aaa);
132 Double_t Proxim(Double_t ang1, Double_t ang2);
133 // AZ-280722 Double_t LinearFit(CbmStsTrack *tr, Int_t newtr, Double_t &ty);
134 Double_t LinearFit(candvec& cand, candvec& cand2, CbmStsTrack* tr, Int_t newtr, Double_t& ty); // AZ-280722
135 Double_t Curv3(candvec& cand1, candvec& cand2, candvec& cand3, int newtr3);
136 std::set<int> KalmanWindow(candvec& cand, int hitIndx);
137 std::string MakeCode(candvec& cand);
138 void PrintHits(candvec& cand);
139 void InitTMVA3(); // AZ-300922
140 Float_t TMVAOutput3(candvec& aaa1, candvec& aaa2, int mult2); // AZ-300922
141 void InitTMVA2(); // AZ-221022
142 Float_t TMVAOutput2(candvec& aaa1); // AZ-241022
143 void InitTMVAtracks(); // AZ-040525
144 void TMVAOutputTra(); // AZ-040525
145 void GoToTarget(); // AZ-240625
146
148 TClonesArray *fClusArray[4], *fHitArray, *fTrackArray, *fDigiMatches, *fStsPoints, *fSilPoints, *fVspPoints;
149 TClonesArray* fVectorArray; // output tracks
150 int fEvent;
151 Int_t fPass; // pass number
152 Int_t fNsta; // number of stations
153 Int_t fNbranches; // max number of branches in a triplet from one doublet
154 Int_t fExact; // exact match - for debug
155 Int_t fExactSel; // exact match for selected ID - for debug
156 Int_t discarded; // number of discarded 3-hit candidates with bad chi2, debug
157 int fOut; // AZ-210922 - flag for writing out
158 TVector3 fXyzv; // mean vertex position
159 Double_t fBy; // max. field in Tesla
160 // AZ-080623 std::multimap<Double_t,Int_t> fmapPhx[19], fmapTy[19], fmapX[19], fmapY[19];
161 std::multimap<Double_t, Int_t> fmapTx[19], fmapTy[19], fmapX[19], fmapY[19];
162 std::vector<candvec> fSeedVec[19]; //
163 std::vector<candvec> fCandVec[19]; //
164 std::set<string> fCandCodes[19];
165 // std::multimap<Int_t,candvec> fCandMap2[19]; //
166 // std::multimap<Int_t,candvec> fCandMap3[19]; //
167
168 std::vector<candvec> fCandVec2[19]; // doublets
169 std::unordered_map<std::string, int> fMap2Out; // AZ-210922 - doublets for writing out
170 // AZ-240623 std::map<std::string,int> *fMap2OutPtr; //AZ-210922 - doublets for writing out
171 std::unordered_map<std::string, int> fMap3Out; // AZ-260922 - triplets for writing out
172 // AZ-240623 std::map<std::string,int> *fMap3OutPtr; //AZ-260922 - triplets for writing out
173 std::ofstream fStream2out; // 240623
174 std::ofstream fStream3out; // 240623
175 // AZ-130722 std::multimap<int,int> fMap2[19]; // hit index -> index in fCandVec2
176 std::unordered_multimap<int, int> fMap2[19]; // AZ-130722 hit index -> index in fCandVec2
177
178 std::vector<candvec> fCandVec3[19]; // triplets
179 // AZ-130722 std::multimap<int,int> fMap3[19]; // hit index -> index in fCandVec3
180 std::unordered_multimap<int, int> fMap3[19]; // AZ-130722 hit index -> index in fCandVec3
181 // AZ-130722 std::map<std::string,int> fMapCode3[19]; // triplet code -> index in fCandVec3
182 std::unordered_map<std::string, int> fMapCode3[19]; // AZ-130722 triplet code -> index in fCandVec3
183
184 std::multimap<Double_t, CbmStsTrack> fTracks; //
185 // AZ-130722 std::map<Int_t,hitinfo> fmapHits;
186 std::unordered_map<Int_t, hitinfo> fmapHits; // AZ-130722
187 // AZ-130722 std::multimap<Int_t,Int_t> fHit2id, fClusMaps[2];
188 std::unordered_multimap<Int_t, Int_t> fHit2id, fClusMaps[2]; // AZ-130722
189 Int_t *fNhitsMin, fNskips[20];
190 Double_t *fdTanX, *fdTanY, *fdTanY3, *fdTanXB0, *fPhiXZ, *fTanXmax, *fZmean, *fPTcut, *fCurvSta;
191 // CbmStsKFTrackFitter fitter;
192 BmnStsKFTrackFitter fitter;
193 std::set<string> fCandSet[19];
194
195 // AZ-070623 - binned hits in Tx
196 std::unordered_multimap<int, int> fTxBins[19];
197 std::unordered_map<int, std::unordered_map<int, std::vector<Float_t>>> fStatData;
198 Float_t fTxStep;
199 Float_t fTxBinw;
200
201 TString fMatBudgetFileName;
202 // std::map<Double_t,TProfile2D*> fMatHistos;
203 int fUseTMVA; // AZ-300922
204 int fTMVAtracks; // AZ-040525
205 int fNSi; // AZ-051022
206 Float_t fVarTMVA[20]; // AZ-300922
207 // TMVA::Reader* fReaderTMVA3; // AZ-300922
208 std::map<int, TMVA::Reader*> fReadersTMVA3; // AZ-080525 - for triplets
209 TMVA::Reader* fReaderTMVA2; // AZ-221022
210 std::map<int, TMVA::Reader*> fTmvaReaders; // AZ-040525 - for tracks
211 // std::ofstream *fOutf; // AZ-290525
212
213 TString fGemConfigFile;
214 TString fSilConfigFile;
215 BmnGemStripStationSet* fGemStationSet;
216 BmnSiliconStationSet* fSilStationSet;
217
220
221 ClassDef(BmnStsVectorFinderV9, 0);
222};
223
224#endif
virtual void FinishEvent()
virtual void Exec(Option_t *opt)
virtual InitStatus Init()
virtual void Finish()
void SetMatBudgetFileName(TString s)
std::map< Int_t, Int_t > stahit
candvec(Double_t momi, std::map< Int_t, Int_t > stahi)
hitinfo(TVector3 v3, Double_t phxi, Double_t txi, Double_t tyi)