BmnRoot
Loading...
Searching...
No Matches
BmnUpstreamTracking.h
Go to the documentation of this file.
1// Author: Vasilisa Lenivenko (VBLHEP) <vasilisa@jinr.ru> 2019-07-18
2
4// //
5// BmnUpstreamTracking //
6// //
7// Implementation of an algorithm developed by //
8// V.Lenivenko and V.Paltchik //
9// to the BmnRoot software //
10// //
11// The algorithm serves for searching for tracks //
12// in the Silicon detectors & MWPCs //
13// of the configuration SRC of BM@N experiment //
14// //
16
17#ifndef BMNUPSTREAMTRACKING_H
18#define BMNUPSTREAMTRACKING_H 1
19
20#include "BmnTrack.h"
21#include "BmnSiliconHit.h"
22#include "BmnSiliconTrackFinder.h"
23#include "BmnMwpcTrack.h"
24#include "BmnMwpcHit.h"
25#include "BmnMwpcSegment.h"
26
27#include "FairTask.h"
28#include "FairTrackParam.h"
29#include "FairMCPoint.h"
30
31#include <TMath.h>
32#include "TList.h"
33#include "TH1D.h"
34#include "TH2D.h"
35#include <TString.h>
36#include <TClonesArray.h>
37#include <TVector2.h>
38
39#include <fstream>
40#include <vector>
41using namespace std;
42using namespace TMath;
43
44
45struct Smatch {
46 Int_t Ind1 = -1;//Si
47 Int_t Ind2 = -1;//Pctr
48 Int_t Inds2 = -1;//seg2
49 Int_t Inds3 = -1;//seg3
50 Int_t Nhits1 = -1;
51 Int_t Nhits2 = -1;
52 Double_t Z1 = -999.;
53 Double_t Z2 = -999.;
54 Double_t Zs2 = -999.;
55 Double_t Zs3 = -999.;
56 Double_t distX = -1.;
57 Double_t distY = -1.;
58 Double_t Chi2m = 999.;
59 Double_t param1[4] = { 999., 999., 999., 999.};
60 Double_t param2[4] = { 999., 999., 999., 999.};
61 Double_t params2[4] = { 999., 999., 999., 999.};
62 Double_t params3[4] = { 999., 999., 999., 999.};
63 //Silicon
64 Double_t SiCoordX[4] = {-999., -999., -999., -999.};
65 Double_t SiCoordY[4] = {-999., -999., -999., -999.};
66 Double_t SiCoordZ[4] = {-999., -999., -999., -999.};
67 Double_t SiSigmaX[4] = {-999., -999., -999., -999.};
68 Double_t SiSigmaY[4] = {-999., -999., -999., -999.};
69 Double_t SiMod[4] = {-999., -999., -999., -999.};
70};
71
72struct UpTracks {
73 Double_t param[4] = { 999., 999., 999., 999.};
74 Double_t CoordX[5] = {-999., -999., -999., -999., -999.};
75 Double_t CoordY[5] = {-999., -999., -999., -999., -999.};
76 Double_t CoordZ[5] = {-999., -999., -999., -999., -999.};
77 Double_t Chi2 = 999.;
78 Int_t Nhits = -1;
79 Int_t Pdg = -1;
80};
81
82
83
84class BmnUpstreamTracking : public FairTask
85{
86 public:
88 BmnUpstreamTracking(Bool_t, Int_t);
89 virtual ~BmnUpstreamTracking();
90
91 virtual InitStatus Init();
92 virtual void Exec(Option_t* opt);
93 virtual void Finish();
94
95 static bool compareSegments(const Smatch &a, const Smatch &b) {
96 return a.Chi2m < b.Chi2m;
97 }
98
99 struct MC_points{
100 Int_t Id = -1;//
101 Int_t Pdg = -1;//
102 Int_t Np_P = 0;
103 Int_t Np_Si = 0;
104 Int_t Np_ch2 = 0;
105 Int_t Np_ch3 = 0;
106 Int_t Np = 0;
107
108 Bool_t xWas2=0;
109 Bool_t uWas2=0;
110 Bool_t vWas2=0;
111 Bool_t xWas3=0;
112 Bool_t uWas3=0;
113 Bool_t vWas3=0;
114 Bool_t np_3si=0;
115
116 Double_t param[4]= {999., 999., 999., 999.};
117 Double_t x_si[4] = {-999., -999.,-999.,-999.};
118 Double_t y_si[4] = {-999., -999.,-999.,-999.};
119 Double_t z_si[4] = {-999., -999.,-999.,-999.};
120 };
121 struct twotracks{
122 Double_t track1[5] = {-999.,-999.,-999.,-999.,-999.};//Ax, x, Ay, Y
123 Int_t track1_pdg = -999;
124 Double_t track2[5] = {-999.,-999.,-999.,-999.,-999.};//Ax, x, Ay, Y
125 Int_t track2_pdg = -999;
126 };
127
128 private:
129 Bool_t fDebug = 0;
130 UInt_t fEventNo = 0; // event counter
131 Int_t fRunNumber;
132 Bool_t expData;
133 TList fList;
134 TClonesArray* fSiTracks;
135 TClonesArray* fSilHits;
136 TClonesArray* fMWPCTracks;
137 TClonesArray* fMWPCSegments;
138 TString fInputBranchName1;
139 TString fInputBranchName2;
140 TString fInputBranchName3;
141 TString fInputBranchHits;
142 //--mc--
143 TClonesArray* fSiTracksSim;
144 TString fInputBranchNameSimTrue;
145 TClonesArray* fBmnHitsArray;
146 TString fInputBranchName;
147
149 TClonesArray* fBmnUpstreamTracksArray;
150 TString fOutputTracksBranchName;
151 TString fOutputFileName;
152 //--------
153 Double_t*** par_ab_Ch;
154 Double_t*** par_ab_tr;
155 Double_t*** SiXYhits;
156 Double_t*** Points;
157 Double_t** par_ab_SiTr;
158 Double_t** par_Seg_z;
159 Double_t** par_ab_trz;
160 Double_t** Xforglfit;
161 Double_t** Amatr;
162 Double_t* par_SiTr_z;
163 Double_t* X_shift_seg;
164 Double_t* X_shiftUp;
165 Double_t* Y_shiftUp;
166 Double_t* Z_pair;
167 Double_t* Z_Chamber;
168 Double_t* AmatrInverted ;
169 Double_t* rhs;
170 Double_t* AmatrArray;
171 Double_t* line;
172 Int_t* Nseg_Ch;
173 Int_t* NPCTracks;
174 Int_t* NSiXYhits;
175 Int_t NSiTracks;
176 Int_t NumPoints;
177 Double_t Shift_toCenterOfMagnetX;// = 0.039;
178 Double_t Shift_toCenterOfMagnetY;// = 0.13;
179 Double_t Shift_toCenterOfMagnetAX;// = 0.;
180 Double_t Shift_toCenterOfMagnetAY;// = 0.0019;
181 Double_t X_shift;
182 Double_t Y_shift;
183
184 vector<Smatch> vtmpSeg;
185 vector<Smatch> OutVector;
186 vector<UpTracks> vecUpTracks;
187 vector<MC_points> vec_points;
188 vector<twotracks> vec_twotracks;
189 //--------
190 void PrepareArraysToProcessEvent();
191 void ReadSiliconTracks(Double_t**, Double_t*, Int_t &, vector<MC_points> &);
192 void ReadSiliconHits(Double_t***, Int_t*);
193 void ReadMWPCSegments(Double_t***, Double_t**, Int_t*, vector<MC_points> &);
194 void ReadMWPCTracks(Double_t***, Double_t**, Int_t*);
195 void PCTracksSiTracksMatching(Double_t**, Double_t*, Int_t &, Double_t***, Double_t**, Int_t*, vector<Smatch> &,vector<Smatch> &);
196 void PCSegmentsSiTracksMatching(Double_t**, Double_t*, Int_t &,Double_t***, Double_t**, Int_t*, vector<Smatch> &, vector<Smatch> &);
197 void RecordingBest(Int_t & , vector<Smatch> & , vector<Smatch> & );
198 void RecordCandidateSeg(Int_t &, Int_t &, Int_t &, Double_t**, Double_t***, Double_t*, Double_t**, Double_t &, Double_t &, vector<Smatch>& );
199 void GetAddSiHits(vector<Smatch> &, Double_t***, Int_t* );
200 void GetHitsToPoints(vector<Smatch> &,Double_t***, Int_t*, Double_t***, Int_t*, Double_t***, Int_t &);
201 void GlobalFit(Double_t**, Double_t**, Double_t*);
202 bool InvertMatrix(Double_t*, Double_t*);
203 void CalculationOfChi2(Double_t***, Int_t &, vector<UpTracks> &);
204 void PrintAllTracks(vector<UpTracks> & );
205 void TrackRecording(vector<UpTracks> & );
206 void MCefficiencyCalculation(vector<MC_points> &, vector<UpTracks> &);
207
208 //--------
209 const Int_t kBig = 200;
210 const Int_t kPoints = 5;//kNumDets
211 const Int_t kPoin_Par = 5;//parameters
212 const Int_t kNumPars = 10;//parameters
213 const Int_t kNumPairs = 2;//number of MWPC pairs
214 const Int_t kNumChambers = 4;//number of MWPC stat
215 const Int_t kNumStSi = 4;//number of Si stat
216 const Int_t kMaxMC = 100;
217 const Int_t fNstations = 4;
218 const Int_t kNPlanes = 6;
219 const Double_t kChi2_Max = 50.;
220 const Double_t dw = 0.25; // [cm]//MWPC wire step
221 const Double_t SigmXmwpc = sqrt(2)*dw / 6.;//dw/6.;//dw / sq12;
222 const Double_t SigmYmwpc = sqrt(2)*dw / 3.;//dw/3.
223 //matching consts
224 const Double_t cutAx = 0.02;//0.012;
225 const Double_t cutAy = 0.02;//0.015;
226 const Double_t cutX = 1.5;//cm
227 const Double_t cutY = 2.0;//cm
228 //important Z
229 const Double_t Zcentr = -350.;//cm
230 const Double_t kZ_target = -645.191;//cm
231 const Double_t kZSi_cent = -392.5;
232 //MC
233 const Int_t PDG_Be7 = 1000040070;//Be7
234 const Int_t PDG_Li6 = 1000030060;//Li6
235 const Int_t PDG_Li7 = 1000030070;//Li7
236 const Int_t PDG_He3 = 1000020030;//He3
237 const Int_t PDG_He4 = 1000020040;//He4
238 const Int_t PDG_H2 = 1000010020;//H2
239 const Int_t PDG_p = 2212;//proton
240
241 //some hists
242 TH1D *hAx_fitUp,*hAy_fitUp,* hx_fitUp,* hy_fitUp,* hchi2_fitUp,* hNhitsUp,
243 *hdAx_tr_mc_comb, *hdX_tr_mc_comb, *hdAy_tr_mc_comb, *hdY_tr_mc_comb,
244 *hdAx_uptr_mc, *hdX_uptr_mc, *hdAy_uptr_mc, *hdY_uptr_mc,
245 *hDen_mcuptr, *hNum_mcuptr, *hEff_mcuptr,
246 *hAx_upmc, *hAy_upmc, *hX_upmc, *hY_upmc,
247 *hNtr_reco, *hNtr_mc, *hNrecoTrif2mc, *hAngle_reco, *hAngle_recoifNmc2, *hAngle_recoifNmc2Cases;
248 TH2D *hNtr_mc_vs_reco, *hy_vs_x_Up, *hY_vs_Xmctrue, *hvertexXYUp, *hTyTx_Up;
249 vector<TH1D*> hResXst, hResYst;
250
251 ClassDef(BmnUpstreamTracking, 1)
252};
253
254#endif
friend F32vec4 sqrt(const F32vec4 &a)
Definition P4_F32vec4.h:34
static bool compareSegments(const Smatch &a, const Smatch &b)
virtual void Exec(Option_t *opt)
virtual InitStatus Init()
STL namespace.
Double_t SiMod[4]
Double_t params3[4]
Double_t SiSigmaX[4]
Double_t params2[4]
Double_t param1[4]
Double_t SiCoordZ[4]
Double_t param2[4]
Double_t SiCoordX[4]
Double_t SiCoordY[4]
Double_t Chi2m
Double_t SiSigmaY[4]
Double_t distX
Double_t distY
Double_t CoordX[5]
Double_t CoordY[5]
Double_t CoordZ[5]
Double_t param[4]