9 #include "UtilBeamLine3D.h"
13 UtilBeamLine3D::UtilBeamLine3D() {
25 printf(
"Params of UtilBeamLine3D\n INPUT tracks: maxRxy=%.1fcm, maxZ=%.1fcm, Chi2=[%.1f,%.1f] minP=%.1f GeVC/c \n Minimization: Dmax=%.1fcm, WestOnly=%d \n\n",
26 cut_maxRxy,cut_maxZ,cut_minChi2, cut_maxChi2,cut_minP,cut_Dmax,par_filter);
32 UtilBeamLine3D:: initHisto( TObjArray * HList){
33 TList *L=0; TLine *ln=0;
float yMax=1e6; TH1* h=0;
35 memset(hA,0,
sizeof(hA));
36 printf(
"helper:initHist\n");
38 hA[0]=h=
new TH1F(
"trStat",
"statistics for tracks",20,0.5,20.5);
39 h->GetXaxis()->SetTitleOffset(0.4); h->GetXaxis()->SetLabelSize(0.06); h->GetXaxis()->SetTitleSize(0.05); h->SetMinimum(0.8);
40 h->SetLineColor(kBlue);h->SetLineWidth(2);
43 hA[1]=h=
new TH1F(
"trCh2",
"input track chi2; chi2/dof",100,0,10);
44 ln=
new TLine(cut_minChi2,0,cut_minChi2,yMax);
45 ln->SetLineColor(kRed); ln->SetLineStyle(2);
46 L= h->GetListOfFunctions(); L->Add(ln);
47 ln=
new TLine(cut_maxChi2,0,cut_maxChi2,yMax);
48 ln->SetLineColor(kRed); ln->SetLineStyle(2);
49 L= h->GetListOfFunctions(); L->Add(ln);
51 hA[2]=h=
new TH1F(
"trZ",
"input track Z @DCA; Z(cm)",50,-200,200);
52 ln=
new TLine(cut_maxZ,0,cut_maxZ,yMax);
53 ln->SetLineColor(kRed); ln->SetLineStyle(2);
54 L= h->GetListOfFunctions(); L->Add(ln);
55 ln=
new TLine(-cut_maxZ,0,-cut_maxZ,yMax);
56 ln->SetLineColor(kRed); ln->SetLineStyle(2);
57 L= h->GetListOfFunctions(); L->Add(ln);
59 hA[3]=h=
new TH1F(
"trX",
"input track X @DCA; X(cm)",100,-4,4);
60 ln=
new TLine(cut_maxRxy,0,cut_maxRxy,yMax);
61 ln->SetLineColor(kRed); ln->SetLineStyle(2);
62 L= h->GetListOfFunctions(); L->Add(ln);
63 ln=
new TLine(-cut_maxRxy,0,-cut_maxRxy,yMax);
64 ln->SetLineColor(kRed); ln->SetLineStyle(2);
65 L= h->GetListOfFunctions(); L->Add(ln);
67 hA[4]=h=
new TH1F(
"trY",
"input track Y @DCA; Y(cm)",100,-4,4);
68 ln=
new TLine(cut_maxRxy,0,cut_maxRxy,yMax);
69 ln->SetLineColor(kRed); ln->SetLineStyle(2);
70 L= h->GetListOfFunctions(); L->Add(ln);
71 ln=
new TLine(-cut_maxRxy,0,-cut_maxRxy,yMax);
72 ln->SetLineColor(kRed); ln->SetLineStyle(2);
73 L= h->GetListOfFunctions(); L->Add(ln);
75 hA[5]=h=
new TH1F(
"trP",
"input track momentum P @DCA; P (GeV/c)",100,0,10);
76 ln=
new TLine(cut_minP,0,cut_minP,yMax);
77 ln->SetLineColor(kRed); ln->SetLineStyle(2);
78 L= h->GetListOfFunctions(); L->Add(ln);
80 hA[6]=
new TH1F(
"trPt",
"input track momentum PT @DCA; PT (GeV/c)",100,0,10);
84 hA[13]=h=
new TH2D(
"fcnChiXY",
"ln(3D likelihood), STAR X-Y plane; X-axis (cm); Y-axis(cm)",nB,-.3,.3,nB,-.3,.3);
85 ln=
new TLine(-10,0,10,0); ln->SetLineColor(kMagenta);
86 L= h->GetListOfFunctions(); L->Add(ln);
87 ln=
new TLine(0,-10,0,10); ln->SetLineColor(kMagenta);
88 L= h->GetListOfFunctions(); L->Add(ln);
90 hA[14]=h=
new TH2D(
"fcnChiXnX",
"ln(3D likelihood), STAR X-n_{X} plane; X-axis (cm); slope X ",nB,0,1,nB,-2e-3,2e-3);
91 ln=
new TLine(0,-10,0,10); ln->SetLineColor(kMagenta);
92 L= h->GetListOfFunctions(); L->Add(ln);
93 ln=
new TLine(-10,0,10,0); ln->SetLineColor(kMagenta);
94 L= h->GetListOfFunctions(); L->Add(ln);
96 hA[15]=h=
new TH2D(
"fcnChiYnY",
"ln(3D likelihood), STAR Y-n_{Y} plane; Y-axis (cm); slope Y ",nB,0,1,nB,-2e-3,2e-3);
97 ln=
new TLine(0,-10,0,10); ln->SetLineColor(kMagenta);
98 L= h->GetListOfFunctions(); L->Add(ln);
99 ln=
new TLine(-10,0,10,0); ln->SetLineColor(kMagenta);
100 L= h->GetListOfFunctions(); L->Add(ln);
103 hA[19]=h=
new TH1F(
"bmSol",
"Beam line params (3D fit); value",4,1,1);
104 h->SetMarkerStyle(24);
106 h->SetMaximum(mY); h->SetMinimum(-mY);
107 h->GetXaxis()->SetTitleOffset(0.4); h->GetXaxis()->SetLabelSize(0.06); h->GetXaxis()->SetTitleSize(0.05);
108 h->SetLineColor(kBlue);h->SetLineWidth(2);
111 ln=
new TLine(0,0,6,0); L= h->GetListOfFunctions(); L->Add(ln);
114 hA[20]=
new TH1F(
"fcnDet",
"FCN: determinant from DCA solution",200,0,1.01);
115 hA[21]=h=
new TH1F(
"fcnDca",
"FCN: 3D dca length ...; DCA (cm)",100,0,5.);
116 ln=
new TLine(cut_Dmax,0,cut_Dmax,yMax);
117 ln->SetLineColor(kRed); ln->SetLineStyle(2);
118 L= h->GetListOfFunctions(); L->Add(ln);
120 hA[22]=h=
new TH2F(
"fcnDcaZ",
"FCN: 3D dca length; Z (cm);DCA (cm)",50,-200,200.,50,0,5.);
121 ln=
new TLine(-200,cut_Dmax,200,cut_Dmax);
122 ln->SetLineColor(kRed); ln->SetLineStyle(2);
123 L= h->GetListOfFunctions(); L->Add(ln);
124 hA[23]=h=
new TH1F(
"fcnNtr",
"FCN: # of tracks with 3D.DCA<Dmax ; Z (cm)",50,-200,200.);
125 h->SetLineColor(kBlue); h->SetFillColor(kBlue);
127 for(
int i=0;i<mxH; i++)
if(hA[i]) HList->Add(hA[i]);
128 printf(
"track QA params: maxRxy<%.1f cm, maxZ<%.1f cm, chi2/dof=[%.1f, %.1f], Dmax=%.2f cm track filter=%d\n", cut_maxRxy, cut_maxZ, cut_minChi2,cut_maxChi2,cut_Dmax,par_filter);
136 UtilBeamLine3D::qaTracks(){
137 printf(
"qaTRacks start=%d\n",(
int)
track.size());
139 vector<TrackStump>::iterator it;
140 for (it=
track.begin() ; it <
track.end(); it++ ) {
144 hA[1]->Fill(t->chi2);
145 if( t->chi2<cut_minChi2 || t->chi2>cut_maxChi2)
continue;
148 hA[2]->Fill(t->r.z());
149 if(fabs(t->r.z()) >cut_maxZ)
continue;
152 hA[3]->Fill(t->r.x());
153 if(fabs(t->r.x()) >cut_maxRxy)
continue;
156 hA[4]->Fill(t->r.y());
157 if(fabs(t->r.y()) >cut_maxRxy)
continue;
161 if(t->P<cut_minP)
continue;
165 if(t->r.z()< 0 || t->p.z() <0)
continue;
175 printf(
"qaTRacks end=%d\n",nOK);
183 UtilBeamLine3D::print(
int k) {
184 printf(
"UtilBeamLine3D::print(%d) size=%d\n",k,(
int)
track.size());
185 for(
int i=0;i<(int)
track.size();i++) {
194 UtilBeamLine3D::scanChi2(
double *par,
int mode){
197 printf(
"scan chi2, mode=%d ....\n",mode);
202 double wrkPar[mxPar];
208 if(mode==0) h2=(TH2F*)hA[13];
209 if(mode==1) h2=(TH2F*)hA[14];
210 if(mode==2) h2=(TH2F*)hA[15];
211 TAxis *xax=h2->GetXaxis();
212 TAxis *yax=h2->GetYaxis();
215 if(fabs(par[0])>0.2 ||fabs(par[1])>0.2 ){
216 xax->Set(xax->GetNbins(),par[0]-0.3,par[0]+0.3);
217 yax->Set(yax->GetNbins(),par[1]-0.3,par[1]+0.3);
221 xax->Set(xax->GetNbins(),par[0]-0.3,par[0]+0.3);
222 yax->Set(yax->GetNbins(),par[2]-9e-3,par[2]+9e-3);
226 for(
int bx=1;bx<=xax->GetNbins();bx++){
227 double x=xax->GetBinCenter(bx);
228 for(
int by=1;by<=yax->GetNbins();by++){
229 double y=yax->GetBinCenter(by);
231 wrkPar[0]=x; wrkPar[1]=y;
232 wrkPar[2]=par[2]; wrkPar[3]=par[3];
235 wrkPar[0]=x; wrkPar[1]=par[1];
236 wrkPar[2]=y; wrkPar[3]=par[3];
240 wrkPar[0]=par[0]; wrkPar[1]=x;
241 wrkPar[2]=par[2]; wrkPar[3]=y;
244 beamLineLike3D(npar,grad,fcnval, wrkPar,iflag);
246 h2->Fill(x,y,fcnval);
254 UtilBeamLine3D::evalSolution(
double *par){
261 beamLineLike3D(npar,grad,fcnval, par,iflag);
268 UtilBeamLine3D::readTracks(
const TString fnameT){
269 const char *fname=fnameT.Data();
270 printf(
"Read fname=%s=\n",fname);
271 FILE *fd=fopen(fname,
"r"); assert(fd);
274 float x,y,z,px,py,pz,ery,eryz,erz;
280 char * retc=fgets(buf,3000,fd);
284 int ret=sscanf(buf ,
"%s %f %f %f %f %f %f %f %f %f %d %f %f %d,",text,&x,&y,&z,&px,&py,&pz,&ery,&eryz,&erz,&t.nFitP,&t.chi2,&t.z0,&t.eveId);
287 printf(
"bad ret=%d nSkip=%d size=%d\n",ret,nSkip,(
int)
track.size());
296 t.p.SetXYZ(px,py,pz);
307 printf(
"found %d tracks\n",(
int)
track.size());