CGEM BOSS 6.6.5.h
BESIII Offline Software System
Loading...
Searching...
No Matches
CgemLineFit.h
Go to the documentation of this file.
1#ifndef CGEMLINEFIT_H
2#define CGEMLINEFIT_H
3
4#include "GaudiKernel/Algorithm.h"
5#include "GaudiKernel/NTuple.h"
6#include "GaudiKernel/INTupleSvc.h"
7#include "MdcGeomSvc/IMdcGeomSvc.h"
8#include "MdcGeomSvc/MdcGeoWire.h"
9#include "MdcGeomSvc/MdcGeoLayer.h"
13#include <string>
14#include <vector>
15#include <map>
16#include "TH2D.h"
17#include "TF1.h"
18#include "TGraph.h"
19#include <fstream>
20
21#include "CLHEP/Alist/AList.h"
22#include "MdcGeom/MdcDetector.h"
23#include "BField/BField.h"
27//#include "CLHEP/Matrix/Vector.h"
28
29
30
33#include "HepPDT/ParticleDataTable.hh"
37#include "TrkBase/TrkRecoTrk.h"
41#include "TrackUtil/Helix.h"
42#include "TMinuit.h"
43class IBesTimerSvc;
44class BesTimer;
45
46
47class CgemLineFit:public Algorithm {
48 public:
49 CgemLineFit(const std::string& name, ISvcLocator* pSvcLocator);
50 StatusCode initialize();
51 StatusCode execute();
52 StatusCode finalize();
53
54
55 bool Data_Max();
56 bool Data_Closest();
57 bool Loop_All();
58 bool Loop_MaxQ();
59 bool ToyMC();
60 bool debug;
61 bool MC;
63 int TEST_N;
64 int Nmax;// the number of max cluster No. on eacy sheet
66 void OrderClusters ();
67 void FilterClusters ();
68 bool Erase_outer();
69 void erase (int i);
70 int GetVirLay(int geolay, double phi);
71 void Discard (int layer);
72 StraightLine* IniPar(double phi1,double z1,int i,double phi2,double z2,int j);
73 void Filter (int layerid,StraightLine* l1);
74 static void fcn( Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag);
75 static void fcn2( Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag);
76 static void fcn3( Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag);
77 void Store_Trk(TMinuit* fit,int trkid);
78 TMinuit* Fit(StraightLine* l_outer,int sheetflag,int typ );
79
80 static double dx(double layerid, double R,double dr,double phi0,double z0,double tanl,double x );
81 static double dV(int layer,double R ,double dr,double phi0,double z0,double tglam,double x,double V);
82
83 bool Get_MCInf();
84 void IncidentAngle(StraightLine* cosmic_ray,HepPoint3D cluster,double theta,double ang[] );
85 void GetIntersection();
86 vector<double>MC_truth();
87 vector<double>Get4Par(HepLorentzVector p4,Hep3Vector bp);
88 bool HitPos(HepLorentzVector p4,Hep3Vector bp);
89 void Get_OtherIniPar(int clst_0,int clst_1,int clst_2);
90 vector<double>Get_Clusters(vector<double>Vec_truth);
91 void Rec_Clusters();
92 void Rec_Clusters_mTPC();
93 void Fit_Clusters(double par[]);
95 double RealPhi(double SimuPhi);
96
97 static vector<double> Trans(double par0,double par1,double par2,double par3);
98 static vector<int> GetNMaxQ(vector<double> Q_11,vector<int> L_11,int Nmax);
99 static double func(double layer,double R,double dr,double phi0,double z0,double tglam,double V,double x);
100
101 StatusCode registerTrack(RecMdcTrackCol*& recMdcTrackCol ,RecMdcHitCol*& recMdcHitCol);
102 void Erase(int _layerid);
103 static void to_0_2pi(double &arg);
104 static double Min_diff(double arg1,double arg2);
105 //static double Min_diff2(double arg1,double arg2);
106
107
111
112 double Min_dis(int R_id,double x,double z,StraightLine* l1 );
113 double Min_dis_up(int R_id,double x,double z,StraightLine* l1 );
114 double Min_dis_down(int R_id,double x,double z,StraightLine* l1 );
115 bool Layer_cross(int R_id,StraightLine* l1 );
116 void Swap(int i,int j);
117 private:
118
119 ClusterRefVec vecclusters;
120 double length;
121 double sigma;
122 double Chisq_cut;
123 double MAX_Clusters;
124 bool Align_Flag;
125 bool MC_Flag;
126 bool Run10_Flag;
127
128 bool ThreeClsts_Flag;
129 int Method;
130 RecMdcHitCol* m_hitList_tds;
131
132 NTuple::Tuple* m_tuple_track;
133 NTuple::Item<long> tr_run;
134 NTuple::Item<long> tr_event;
135 // track parameters
136 NTuple::Item<double> tr_drho;
137 NTuple::Item<double> tr_phi0;
138 NTuple::Item<double> tr_dz0;
139 NTuple::Item<double> tr_tanLam;
140 NTuple::Item<double> tr_chisq;
141 // whether is the track fitted successfully
142 NTuple::Item<bool> tr_Is_fitted;
143 // number of clusters in an event
144 NTuple::Item<long> tr_ncluster;
145
146 // cluster id
147 NTuple::Array<int> tr_id_cluster;
148 // cluster position
149 NTuple::Array<double> tr_x_cluster;
150 NTuple::Array<double> tr_y_cluster;
151 NTuple::Array<double> tr_z_cluster;
152 NTuple::Array<double> tr_phi_cluster;
153 // cluster deposit energy, layer id, sheet id and whether is it one selected by track on each sheet
154 NTuple::Array<double> tr_Q_cluster;
155 NTuple::Array<long> tr_layer_cluster;
156 NTuple::Array<long> tr_sheet_cluster;
157 NTuple::Array<bool> tr_Is_selected_cluster;
158
159 NTuple::Tuple* m_tuple;
160 NTuple::Item<double> run;
161
162 NTuple::Item<double> R0;
163 NTuple::Item<double> R1;
164 NTuple::Item<double> R2;
165
166 NTuple::Item<double> status1;
167 NTuple::Item<double> status2;
168 NTuple::Item<double> status3;
169
170 NTuple::Item<double> clst_2;
171 NTuple::Item<double> clst_0;
172 NTuple::Item<double> clst_1;
173
174 NTuple::Item<double> clst_00;
175 NTuple::Item<double> clst_01;
176
177 NTuple::Item<double> clst_10;
178 NTuple::Item<double> clst_11;
179
180 NTuple::Item<double> event;
181 NTuple::Item<double> phi_o1;
182 NTuple::Item<double> phi_o2;
183 NTuple::Item<double> ini_1;
184 NTuple::Item<double> ini_0;
185 NTuple::Item<double> ini_2;
186 NTuple::Item<double> ini_3;
187
188
189 NTuple::Item<double> inim_1;
190 NTuple::Item<double> inim_0;
191 NTuple::Item<double> inim_2;
192 NTuple::Item<double> inim_3;
193 NTuple::Item<double> inii_1;
194 NTuple::Item<double> inii_0;
195 NTuple::Item<double> inii_2;
196 NTuple::Item<double> inii_3;
197 NTuple::Item<double> par0;
198 NTuple::Item<double> par1;
199 NTuple::Item<double> par2;
200 NTuple::Item<double> par3;
201 NTuple::Item<double> Err_par0;
202 NTuple::Item<double> Err_par1;
203 NTuple::Item<double> Err_par2;
204 NTuple::Item<double> Err_par3;
205 NTuple::Item<double> newpar0;
206 NTuple::Item<double> newpar1;
207 NTuple::Item<double> newpar2;
208 NTuple::Item<double> newpar3;
209 NTuple::Item<double> newErr_par0;
210 NTuple::Item<double> newErr_par1;
211 NTuple::Item<double> newErr_par2;
212 NTuple::Item<double> newErr_par3;
213 NTuple::Item<double> MC_par0;
214 NTuple::Item<double> MC_par1;
215 NTuple::Item<double> MC_par2;
216 NTuple::Item<double> MC_par3;
217 NTuple::Item<double> MC_px;
218 NTuple::Item<double> MC_py;
219 NTuple::Item<double> MC_pz;
220
221 NTuple::Item<double> x_0_up;
222 NTuple::Item<double> x_1_up;
223 NTuple::Item<double> x_2_up;
224 NTuple::Item<double> x_0_down;
225 NTuple::Item<double> x_1_down;
226 NTuple::Item<double> x_2_down;
227 NTuple::Item<double> v_0_up;
228 NTuple::Item<double> v_1_up;
229 NTuple::Item<double> v_2_up;
230 NTuple::Item<double> v_0_down;
231 NTuple::Item<double> v_1_down;
232 NTuple::Item<double> v_2_down;
233 NTuple::Item<double> z_1_up;
234 NTuple::Item<double> z_2_up;
235 NTuple::Item<double> z_0_up;
236 NTuple::Item<double> z_1_down;
237 NTuple::Item<double> z_2_down;
238 NTuple::Item<double> z_0_down;
239
240
241 NTuple::Item<double> x_0_up_m;
242 NTuple::Item<double> x_1_up_m;
243 NTuple::Item<double> x_2_up_m;
244 NTuple::Item<double> x_0_down_m;
245 NTuple::Item<double> x_1_down_m;
246 NTuple::Item<double> x_2_down_m;
247 NTuple::Item<double> v_0_up_m;
248 NTuple::Item<double> v_1_up_m;
249 NTuple::Item<double> v_2_up_m;
250 NTuple::Item<double> v_0_down_m;
251 NTuple::Item<double> v_1_down_m;
252 NTuple::Item<double> v_2_down_m;
253 NTuple::Item<double> z_1_up_m;
254 NTuple::Item<double> z_2_up_m;
255 NTuple::Item<double> z_0_up_m;
256 NTuple::Item<double> z_1_down_m;
257 NTuple::Item<double> z_2_down_m;
258 NTuple::Item<double> z_0_down_m;
259
260
261
262
263
264
265
266
267
268 NTuple::Item<double> x_0_up_f;
269 NTuple::Item<double> x_1_up_f;
270 NTuple::Item<double> x_2_up_f;
271 NTuple::Item<double> x_0_down_f;
272 NTuple::Item<double> x_1_down_f;
273 NTuple::Item<double> x_2_down_f;
274 NTuple::Item<double> v_0_up_f;
275 NTuple::Item<double> v_1_up_f;
276 NTuple::Item<double> v_2_up_f;
277 NTuple::Item<double> v_0_down_f;
278 NTuple::Item<double> v_1_down_f;
279 NTuple::Item<double> v_2_down_f;
280
281 NTuple::Item<double> x_0_up_mc;
282 NTuple::Item<double> x_1_up_mc;
283 NTuple::Item<double> x_2_up_mc;
284 NTuple::Item<double> x_0_down_mc;
285 NTuple::Item<double> x_1_down_mc;
286 NTuple::Item<double> x_2_down_mc;
287 NTuple::Item<double> v_0_up_mc;
288 NTuple::Item<double> v_1_up_mc;
289 NTuple::Item<double> v_2_up_mc;
290 NTuple::Item<double> v_0_down_mc;
291 NTuple::Item<double> v_1_down_mc;
292 NTuple::Item<double> v_2_down_mc;
293
294
295 NTuple::Item<double> inner_phi1;
296 NTuple::Item<double> inner_phi2;
297 NTuple::Item<double> inner_V1;
298 NTuple::Item<double> inner_V2;
299 NTuple::Item<double> inner_z1;
300 NTuple::Item<double> inner_z2;
301 NTuple::Item<double> chisq_1;
302 NTuple::Item<double> chisq_2;
303 NTuple::Item<double> chisq_3;
304
305
306 NTuple::Item<double> pos_x;
307 NTuple::Item<double> pos_y;
308 NTuple::Item<double> pos_z;
309
310 NTuple::Item<double> hit_x;
311 NTuple::Item<double> hit_y;
312 NTuple::Item<double> hit_z;
313
314 NTuple::Item<double> ang_1;
315 NTuple::Item<double> ang_1_x;
316 NTuple::Item<double> ang_1_v;
317
318 NTuple::Item<double> ang_2;
319 NTuple::Item<double> ang_2_x;
320 NTuple::Item<double> ang_2_v;
321
322 NTuple::Item<double> ang_3;
323 NTuple::Item<double> ang_3_x;
324 NTuple::Item<double> ang_3_v;
325
326 NTuple::Item<double> ang_4;
327 NTuple::Item<double> ang_4_x;
328 NTuple::Item<double> ang_4_v;
329
330
331 NTuple::Item<double> inter_1_x;
332 NTuple::Item<double> inter_1_V;
333 NTuple::Item<double> inter_1_flag;
334 NTuple::Item<double> inter_1_z;
335
336
337 NTuple::Item<double> inter_2_x;
338 NTuple::Item<double> inter_2_V;
339 NTuple::Item<double> inter_2_flag;
340 NTuple::Item<double> inter_2_z;
341
342
343 NTuple::Item<double> inter_3_x;
344 NTuple::Item<double> inter_3_V;
345 NTuple::Item<double> inter_3_flag;
346 NTuple::Item<double> inter_3_z;
347
348 NTuple::Item<double> inter_4_x;
349 NTuple::Item<double> inter_4_V;
350 NTuple::Item<double> inter_4_flag;
351 NTuple::Item<double> inter_4_z;
352 NTuple::Item<double> Res_phi;
353 NTuple::Item<double> Res_V;
354 NTuple::Item<double> Test_phi;
355 NTuple::Item<double> Test_V;
356 void GetRes( StraightLine* l1,int i_inter);
357 //data member
358 int m_event;
359 int m_run;
360 RawDataProviderSvc* m_rawDataProviderSvc;
361 CgemGeomSvc* m_cgemGeomSvc;
362 // CgemGeomSvc* myCgemGeomSvc;
363 CgemCalibFunSvc* m_cgemCalibFunSvc;
364
365 // ReadoutPlane* readoutPlane;
366 RecMdcTrackCol* m_trackList_tds;
367 // CgemGeoReadoutPlane* readoutPlane;
368
369};
370#endif
StraightLine * l_outer
Double_t phi2
Double_t phi1
double arg(const EvtComplex &c)
ObjectVector< RecMdcHit > RecMdcHitCol
Definition RecMdcHit.h:99
SmartRefVector< RecCgemCluster > ClusterRefVec
Definition RecMdcTrack.h:28
ObjectVector< RecMdcTrack > RecMdcTrackCol
void Rec_Clusters_mTPC()
static vector< int > GetNMaxQ(vector< double > Q_11, vector< int > L_11, int Nmax)
StatusCode finalize()
void OrderClusters()
void Filter(int layerid, StraightLine *l1)
void InAngle(StraightLine sl)
void erase(int i)
void Swap(int i, int j)
StraightLine * IniPar(double phi1, double z1, int i, double phi2, double z2, int j)
vector< double > Get4Par(HepLorentzVector p4, Hep3Vector bp)
double Min_dis_up(int R_id, double x, double z, StraightLine *l1)
StatusCode execute()
CgemLineFit(const std::string &name, ISvcLocator *pSvcLocator)
int GetVirLay(int geolay, double phi)
void Fit_Clusters(double par[])
static void fcn2(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
bool Layer_cross(int R_id, StraightLine *l1)
static vector< double > Trans(double par0, double par1, double par2, double par3)
double Min_dis_down(int R_id, double x, double z, StraightLine *l1)
static void fcn3(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
static void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
void IncidentAngle(StraightLine *cosmic_ray, HepPoint3D cluster, double theta, double ang[])
static double dV(int layer, double R, double dr, double phi0, double z0, double tglam, double x, double V)
double Min_dis(int R_id, double x, double z, StraightLine *l1)
vector< double > MC_truth()
bool HitPos(HepLorentzVector p4, Hep3Vector bp)
int Switch_CCmTPC
Definition CgemLineFit.h:65
static double func(double layer, double R, double dr, double phi0, double z0, double tglam, double V, double x)
static void to_0_2pi(double &arg)
bool Data_Closest()
TMinuit * Fit(StraightLine *l_outer, int sheetflag, int typ)
static double dx(double layerid, double R, double dr, double phi0, double z0, double tanl, double x)
void Get_OtherIniPar(int clst_0, int clst_1, int clst_2)
void GetIntersection()
void FilterClusters()
static double Min_diff(double arg1, double arg2)
StatusCode initialize()
void Erase(int _layerid)
void Store_Trk(TMinuit *fit, int trkid)
void Discard(int layer)
double MinQ_Clus2D
double RealPhi(double SimuPhi)
vector< double > Get_Clusters(vector< double >Vec_truth)
void Rec_Clusters()
StatusCode registerTrack(RecMdcTrackCol *&recMdcTrackCol, RecMdcHitCol *&recMdcHitCol)