44 #include <JANA/JCalibration.h>
52 #define RADIUS_CUT 50.0
53 #define BEAM_VAR 1. // cm^2
63 if (p_cdc <p ) p=p_cdc;
64 if (dist<10. && dist <4.+1.75/p
78 if(segment1->
hits.size()>0)layer1=segment1->
hits[0]->wire->layer;
79 if(segment2->
hits.size()>0)layer2=segment2->
hits[0]->wire->layer;
81 return layer1 < layer2;
94 return (hit1->
dE > hit2->
dE);
110 return (hit1->
dE > hit2->
dE);
122 MAX_NUM_TRACK_CANDIDATES = 20;
134 FactorForSenseOfRotation=(bfield->GetBz(0.,0.,65.)>0.)?-1.:1.;
144 SetFactoryFlag(NOT_OBJECT_OWNER);
147 ClearFactoryFlag(NOT_OBJECT_OWNER);
150 double endplate_z,endplate_dz,endplate_rmin;
151 dgeom->
GetCDCEndplate(endplate_z,endplate_dz,endplate_rmin,endplate_rmax);
152 cdc_endplate.SetZ(endplate_z+endplate_dz);
155 eventLoop->GetSingle(dParticleID);
157 JCalibration *jcalib = dapp->GetJCalibration(runnumber);
158 map<string, double> targetparms;
159 if (jcalib->Get(
"TARGET/target_parms",targetparms)==
false){
160 TARGET_Z = targetparms[
"TARGET_Z_POSITION"];
168 stepper->SetStepSize(1.0);
171 gPARMS->SetDefaultParameter(
"TRKFIND:DEBUG_HISTS",DEBUG_HISTS);
183 match_dist=(TH2F*)gROOT->FindObject(
"match_dist");
185 match_dist=
new TH2F(
"match_dist",
"Matching distance",
186 120,0.,60.,500,0,25.);
187 match_dist->SetXTitle(
"r (cm)");
188 match_dist->SetYTitle(
"#Deltar (cm)");
190 match_dist_vs_p=(TH2F*)gROOT->FindObject(
"match_dist_vs_p");
191 if (!match_dist_vs_p) {
192 match_dist_vs_p=
new TH2F(
"match_dist_vs_p",
"Matching distance vs p",
194 match_dist_vs_p->SetYTitle(
"#Deltar (cm)");
195 match_dist_vs_p->SetXTitle(
"p (GeV/c)");
200 gPARMS->SetDefaultParameter(
"TRKFIND:MAX_NUM_TRACK_CANDIDATES", MAX_NUM_TRACK_CANDIDATES);
206 gPARMS->SetDefaultParameter(
"TRKFIND:DEBUG_LEVEL", DEBUG_LEVEL);
250 vector<const DTrackCandidate*> locStraightLineCandidates;
251 loop->Get(locStraightLineCandidates,
"StraightLine");
252 for(
size_t loc_i = 0; loc_i < locStraightLineCandidates.size(); ++loc_i)
253 _data.push_back(const_cast<DTrackCandidate*>(locStraightLineCandidates[loc_i]));
258 vector<const DSCHit *>schits;
263 cdctrackcandidates.clear();
264 fdctrackcandidates.clear();
265 trackcandidates.clear();
269 loop->Get(cdctrackcandidates,
"CDC");
270 loop->Get(fdctrackcandidates,
"FDCCathodes");
273 loop->Get(mycdchits);
276 vector<unsigned int> cdc_forward_ids;
277 vector<unsigned int> cdc_backward_ids;
278 vector<DVector3> cdc_endplate_projections;
281 vector<unsigned int>used_cdc_hits(mycdchits.size());
284 vector<int>forward_matches(fdctrackcandidates.size());
290 for(
unsigned int i=0; i<cdctrackcandidates.size(); i++){
296 unsigned int num_unmatched_cdcs=0;
297 for (
unsigned int i=0;i<used_cdc_hits.size();i++){
298 if (used_cdc_hits[i]==0) num_unmatched_cdcs++;
303 for(
unsigned int i=0; i<cdctrackcandidates.size(); i++){
309 bool isForward=
false;
310 if (fdctrackcandidates.size()>0){
311 if (mom.Theta()<M_PI_2){
315 ProjectHelixToZ(cdc_endplate.z(),srccan->
charge(),mom,pos);
321 stepper->SetCharge(srccan->
charge());
322 stepper->SwimToPlane(pos,mom,cdc_endplate,norm,NULL);
324 cdc_endplate_projections.push_back(pos);
325 cdc_forward_ids.push_back(i);
331 if (isForward==
false){
332 cdc_backward_ids.push_back(i);
337 int num_forward_cdc_cands_remaining=cdc_forward_ids.size();
338 int num_fdc_cands_remaining=fdctrackcandidates.size();
339 vector<int>cdc_forward_matches(cdc_forward_ids.size());
340 vector<int>cdc_backward_matches(cdc_backward_ids.size());
344 if (num_forward_cdc_cands_remaining>0){
345 for(
unsigned int i=0; i<fdctrackcandidates.size(); i++){
348 if (num_forward_cdc_cands_remaining==0)
break;
352 vector<const DFDCSegment *>segments;
353 fdccan->GetT(segments);
355 if (segments[0]->package!=0)
continue;
358 bool got_match=
false;
360 if (DEBUG_LEVEL>0)
_DBG_ <<
"Attempting FDC/CDC matching method #1..." <<endl;
366 if (CheckZPosition(fdccan)==
false){
369 forward_matches[i]=-1;
375 if (MatchMethod1(fdccan,cdc_forward_ids,cdc_endplate_projections,
376 cdc_forward_matches)){
377 if (DEBUG_LEVEL>0)
_DBG_ <<
"... matched to FDC candidate #" << i <<endl;
382 if (DEBUG_LEVEL>0)
_DBG_ <<
"Attempting FDC/CDC matching method #2..." <<endl;
384 for (
unsigned int j=0;j<cdc_forward_ids.size();j++){
385 if (cdc_forward_matches[j])
continue;
391 if (MatchMethod2(fdccan,cdccan)){
392 if (DEBUG_LEVEL>0)
_DBG_ <<
"... matched to FDC candidate #" << i <<endl;
394 cdc_forward_matches[j]=1;
397 _DBG_ <<
".. matched to CDC candidate #" <<cdc_forward_ids[j] <<endl;
406 forward_matches[i]=1;
407 num_fdc_cands_remaining--;
410 num_forward_cdc_cands_remaining--;
418 if (num_forward_cdc_cands_remaining>0){
419 for (
unsigned int i=0;i<cdc_forward_ids.size();i++){
420 if (cdc_forward_matches[i])
continue;
421 if (num_forward_cdc_cands_remaining==0)
break;
423 if (DEBUG_LEVEL>0)
_DBG_ <<
"Attempting FDC/CDC matching method #3..." <<endl;
427 if (MatchMethod3(cdccan,forward_matches)){
428 num_fdc_cands_remaining--;
429 num_forward_cdc_cands_remaining--;
432 cdc_forward_matches[i]=1;
434 if (DEBUG_LEVEL>0)
_DBG_ <<
"... matched to CDC candidate #" << i <<endl;
445 if (num_fdc_cands_remaining>0 && num_forward_cdc_cands_remaining>0){
446 for (
unsigned int j=0;j<cdc_forward_ids.size();j++){
447 if (num_fdc_cands_remaining==0)
break;
448 if (num_forward_cdc_cands_remaining==0)
break;
449 if (cdc_forward_matches[j]==0){
450 const DTrackCandidate *cdccan = cdctrackcandidates[cdc_forward_ids[j]];
452 if (MatchMethod8(cdccan,forward_matches)==
true){
453 cdc_forward_matches[j]=1;
454 num_fdc_cands_remaining--;
455 num_forward_cdc_cands_remaining--;
463 if (num_forward_cdc_cands_remaining>0){
464 for (
unsigned int j=0;j<cdc_forward_ids.size();j++){
465 if (cdc_forward_matches[j]==0){
468 const DTrackCandidate *cdccan = cdctrackcandidates[cdc_forward_ids[j]];
469 vector<const DCDCTrackHit *>cdchits;
470 cdccan->GetT(cdchits);
484 for (
unsigned int n=0;n<cdchits.size();n++){
486 can->AddAssociatedObject(cdchits[n]);
490 trackcandidates.push_back(can);
495 for (
unsigned int j=0;j<cdc_backward_ids.size();j++){
496 const DTrackCandidate *cdccan = cdctrackcandidates[cdc_backward_ids[j]];
502 if (num_fdc_cands_remaining>0
503 && MatchMethod8(cdccan,forward_matches)==
true){
504 num_fdc_cands_remaining--;
505 cdc_backward_matches[j]=1;
513 if (num_fdc_cands_remaining>0 && mom.Theta()>M_PI_2 && !sc_pos.empty()){
514 if (TryToFlipDirection(schits,mom,pos)){
516 _DBG_<<
"Flipped direction of track (backward to forward) to look for FDC match..." << endl;
519 double p_cdc=mom.Mag();
520 stepper->SetCharge(cdccan->
charge());
521 stepper->SwimToPlane(pos,mom,cdc_endplate,norm,NULL);
523 for (
unsigned int i=0;i<fdctrackcandidates.size();i++){
524 if (num_fdc_cands_remaining==0)
break;
525 if (forward_matches[i]==0){
527 if (MatchMethod2(fdccan,cdccan)){
529 _DBG_ <<
"... matched to FDC candidate #" << i <<endl;
531 forward_matches[i]=1;
532 cdc_backward_matches[j]=1;
533 num_fdc_cands_remaining--;
540 double p_fdc=fdcmom.Mag();
541 ProjectHelixToZ(cdc_endplate.z(),fdccan->
charge(),fdcmom,fdcpos);
542 double diff=(pos-fdcpos).Mag();
545 vector<const DFDCSegment *>segments;
546 fdccan->GetT(segments);
550 double theta=fdcmom.Theta();
551 if (segments.size()>1 && p_fdc<0.3 && theta< 5.*M_PI/180.){
555 if (MakeCandidateFromMethod1(theta,segments,cdccan)){
556 forward_matches[i]=1;
557 num_fdc_cands_remaining--;
558 cdc_backward_matches[j]=1;
560 _DBG_ <<
".. matched to CDC candidate #" << cdc_backward_ids[j] <<endl;
572 for (
unsigned int j=0;j<cdc_backward_ids.size();j++){
573 if (cdc_backward_matches[j]==0){
574 const DTrackCandidate *cdccan = cdctrackcandidates[cdc_backward_ids[j]];
577 vector<const DCDCTrackHit *>cdchits;
578 cdccan->GetT(cdchits);
583 can->setPosition(cdccan->
position());
584 can->setPID(cdccan->
PID());
591 for (
unsigned int n=0;n<cdchits.size();n++){
592 can->AddAssociatedObject(cdchits[n]);
594 can->chisq=cdccan->
chisq;
595 can->Ndof=cdccan->
Ndof;
597 trackcandidates.push_back(can);
604 if (num_fdc_cands_remaining>1){
605 for (
unsigned int j=0;j<fdctrackcandidates.size();j++){
606 if (num_fdc_cands_remaining<1)
break;
607 if (forward_matches[j]<=0){
610 if (MatchMethod4(fdctrackcandidates[j],forward_matches,num_fdc_cands_remaining)==
true){
611 forward_matches[j]=1;
612 num_fdc_cands_remaining--;
620 if (num_fdc_cands_remaining>0){
621 for (
unsigned int j=0;j<fdctrackcandidates.size();j++){
622 if (forward_matches[j]<=0){
626 vector<const DFDCSegment *>segments;
627 fdccan->GetT(segments);
629 if (segments.size()>1){
642 for (
unsigned int m=0;m<segments.size();m++){
643 for (
unsigned int n=0;n<segments[m]->hits.size();n++){
644 const DFDCPseudo *fdchit=segments[m]->hits[n];
645 can->AddAssociatedObject(fdchit);
648 trackcandidates.push_back(can);
650 num_fdc_cands_remaining--;
651 forward_matches[j]=1;
659 if (num_fdc_cands_remaining>0){
660 vector<int>candidate_updated(trackcandidates.size());
661 for (
unsigned int i=0;i<trackcandidates.size();i++){
662 if (num_fdc_cands_remaining<=0)
break;
665 if (MatchMethod7(can,forward_matches,num_fdc_cands_remaining)==
false){
667 if (MatchMethod12(can,forward_matches,num_fdc_cands_remaining)){
668 candidate_updated[i]=1;
673 if (num_fdc_cands_remaining>0){
675 for (
unsigned int i=0;i<trackcandidates.size();i++){
676 if (num_fdc_cands_remaining==0)
break;
677 if (candidate_updated[i]==1){
679 if (MatchMethod7(can,forward_matches,num_fdc_cands_remaining)==
false){
681 MatchMethod12(can,forward_matches,num_fdc_cands_remaining);
693 if (num_fdc_cands_remaining){
694 bool matched_stray_segments=MatchStraySegments(forward_matches,
695 num_fdc_cands_remaining);
696 if (num_fdc_cands_remaining && matched_stray_segments){
697 for (
unsigned int i=0;i<trackcandidates.size();i++){
698 if (num_fdc_cands_remaining==0)
break;
701 if (MatchMethod7(can,forward_matches,num_fdc_cands_remaining)==
false){
703 MatchMethod12(can,forward_matches,num_fdc_cands_remaining);
708 if (num_fdc_cands_remaining){
710 for (
unsigned int j=0;j<forward_matches.size();j++){
711 if (num_fdc_cands_remaining==0)
break;
712 if (forward_matches[j]<=0){
715 vector<const DFDCSegment *>segments;
716 srccan->GetT(segments);
730 for (
unsigned int n=0;n<segment->
hits.size();n++){
732 can->AddAssociatedObject(fdchit);
735 trackcandidates.push_back(can);
744 if (num_unmatched_cdcs>0){
746 _DBG_ <<
"Trying to use stray CDC hits in match to FDC..." << endl;
749 for (
unsigned int i=0;i<trackcandidates.size();i++){
750 if (num_unmatched_cdcs>0){
753 vector<const DCDCTrackHit *>usedcdchits;
754 candidate->GetT(usedcdchits);
755 if (usedcdchits.size()==0){
756 vector<const DFDCPseudo*>usedfdchits;
757 candidate->GetT(usedfdchits);
760 if ((usedfdchits[0]->wire->layer-1)/6==0){
761 MatchMethod6(candidate,usedfdchits,used_cdc_hits,num_unmatched_cdcs);
769 for (
unsigned int i=0;i<trackcandidates.size();i++){
772 vector<const DFDCPseudo*>myfdchits;
773 candidate->GetT(myfdchits);
774 vector<const DCDCTrackHit *>mycdchits;
775 candidate->GetT(mycdchits);
777 if (mycdchits.size()>=3 || myfdchits.size()>=3){
778 _data.push_back(candidate);
780 else delete candidate;
783 if((
int(_data.size()) > MAX_NUM_TRACK_CANDIDATES) && (MAX_NUM_TRACK_CANDIDATES >= 0))
785 if (DEBUG_LEVEL>0)
_DBG_ <<
"Number of candidates = " << _data.size()
786 <<
" > " << MAX_NUM_TRACK_CANDIDATES
787 <<
" --- skipping track fitting! " << endl;
788 for(
size_t loc_i = 0; loc_i < _data.size(); ++loc_i)
795 for(
size_t loc_i = 0; loc_i < _data.size(); ++loc_i)
797 vector<const DCDCTrackHit*> locCDCTrackHits;
798 _data[loc_i]->Get(locCDCTrackHits);
800 vector<const DFDCPseudo*> locFDCPseudos;
801 _data[loc_i]->Get(locFDCPseudos);
803 _data[loc_i]->dCDCRings = dParticleID->Get_CDCRingBitPattern(locCDCTrackHits);
804 _data[loc_i]->dFDCPlanes = dParticleID->Get_FDCPlaneBitPattern(locFDCPseudos);
817 double x=segment->
xc+segment->
rc*cos(segment->
Phi1);
819 double z=segment->
hits[0]->wire->origin.z();
823 double phi0=segment->
phi0;
824 double tanl=segment->
tanl;
828 double cosp=cos(phi0);
829 double sinp=
sin(phi0);
830 double sperp=(z-z0)/tanl;
832 double twoks=FactorForSenseOfRotation*segment->
q*sperp/segment->
rc;
833 double sin2ks=
sin(twoks);
834 double cos2ks=cos(twoks);
837 double B=fabs(bfield->GetBz(x,y,z));
840 double pt=0.003*B*segment->
rc;
841 double px=pt*(cosp*cos2ks-sinp*sin2ks);
842 double py=pt*(sinp*cos2ks+cosp*sin2ks);
846 mom.SetXYZ(px,py,pz);
855 double phi0=atan2(-fit.
x0,fit.
y0);
856 if (fit.
h<0) phi0+=M_PI;
857 double sinphi0=
sin(phi0);
858 double sign=(sinphi0>0)?1.:-1.;
859 if (fabs(sinphi0)<1
e-8) sinphi0=sign*1
e-8;
860 double cosphi0=cos(phi0);
861 double D=FactorForSenseOfRotation*fit.
h*fit.
r0-fit.
x0/sinphi0;
866 double ratio=
sqrt(dx*dx+dy*dy)/(2.*fit.
r0);
867 double phi_s=(ratio<1.)?2.*asin(ratio):M_PI;
868 double newz=pos.z()-phi_s*fit.
tanl*fit.
r0;
869 pos.SetXYZ(x,y,newz);
872 double pt=0.003*Bz*fit.
r0;
873 mom.SetXYZ(pt*cosphi0,pt*sinphi0,pt*fit.
tanl);
890 double xc2_plus_yc2=xc2+yc2;
891 double a=(r2-xc2_plus_yc2-rc2)/tworc;
892 double b=xc2_plus_yc2-a*a;
896 return VALUE_OUT_OF_RANGE;
899 double temp1=yc*
sqrt(b);
901 double cosphi_plus=(temp2+temp1)/xc2_plus_yc2;
902 double cosphi_minus=(temp2-temp1)/xc2_plus_yc2;
905 double tanl=fit.
tanl;
906 double pt=0.003*Bz*rc;
908 double phi_plus=acos(cosphi_plus);
909 double phi_minus=acos(cosphi_minus);
910 double x_plus=xc+rc*cosphi_plus;
911 double x_minus=xc+rc*cosphi_minus;
912 double y_plus=yc+rc*
sin(phi_plus);
913 double y_minus=yc+rc*
sin(phi_minus);
918 double r2_plus=x_plus*x_plus+y_plus*y_plus;
919 double r2_minus=x_minus*x_minus+y_minus*y_minus;
920 if (fabs(r2-r2_plus)>
EPS){
922 y_plus=yc+rc*
sin(phi_plus);
924 if (fabs(r2-r2_minus)>
EPS){
926 y_minus=yc+rc*
sin(phi_minus);
930 double xwire=origin.x();
931 double ywire=origin.y();
932 double dx=x_minus-xwire;
933 double dy=y_minus-ywire;
934 double d2_minus=dx*dx+dy*dy;
937 double d2_plus=dx*dx+dy*dy;
940 if (d2_plus>d2_minus){
942 phi_minus=M_PI-phi_minus;
943 pos.SetXYZ(x_minus,y_minus,0.);
944 mom.SetXYZ(pt*
sin(phi_minus),pt*cos(phi_minus),pt*tanl);
949 pos.SetXYZ(x_plus,y_plus,0.);
950 mom.SetXYZ(pt*
sin(phi_plus),pt*cos(phi_plus),pt*tanl);
953 double ratio=(pos0-pos).Perp()/tworc;
954 double sperp=(ratio<1.)?tworc*asin(ratio):tworc*M_PI_2;
955 pos.SetZ(pos0.z()-sperp*tanl);
964 double pt=mom.Perp();
965 double phi=mom.Phi();
966 double sinphi=
sin(phi);
967 double cosphi=cos(phi);
968 double tanl=tan(M_PI_2-mom.Theta());
972 double B=fabs(bfield->GetBz(x0,y0,z0));
973 double twokappa=FactorForSenseOfRotation*0.003*B*q/pt;
974 double one_over_twokappa=1./twokappa;
975 double sperp=(z-z0)/tanl;
976 double twoks=twokappa*sperp;
977 double sin2ks=
sin(twoks);
978 double one_minus_cos2ks=1.-cos(twoks);
979 double x=x0+(cosphi*sin2ks-sinphi*one_minus_cos2ks)*one_over_twokappa;
980 double y=y0+(sinphi*sin2ks+cosphi*one_minus_cos2ks)*one_over_twokappa;
992 double pt=mom.Perp();
993 double phi=mom.Phi();
994 double sinphi=
sin(phi);
995 double cosphi=cos(phi);
996 double tanl=tan(M_PI_2-mom.Theta());
1001 double B=fabs(bfield->GetBz(x0,y0,z0));
1002 double twokappa=FactorForSenseOfRotation*0.003*B*q/pt;
1003 double one_over_twokappa=1./twokappa;
1007 double z0w=origin.z();
1011 double old_doca2=1e8;
1012 double doca2=old_doca2;
1015 while (z>50. && z<180. &&
x<60. &&
y<60.){
1018 double twoks=twokappa*sperp;
1019 double sin2ks=
sin(twoks);
1020 double one_minus_cos2ks=1.-cos(twoks);
1021 x=x0+(cosphi*sin2ks-sinphi*one_minus_cos2ks)*one_over_twokappa;
1022 y=y0+(sinphi*sin2ks+cosphi*one_minus_cos2ks)*one_over_twokappa;
1025 wirepos=origin+(z-z0w)*dir;
1026 double dxw=
x-wirepos.x();
1027 double dyw=y-wirepos.y();
1029 doca2=dxw*dxw+dyw*dyw;
1030 if (doca2>old_doca2){
1051 double Phi1=atan2(pos.Y()-yc,pos.X()-xc);
1054 double phiplus=Phi1+dphi;
1055 double phiminus=Phi1-dphi;
1056 DVector2 plus(xc+rc*cos(phiplus),yc+rc*
sin(phiplus));
1057 DVector2 minus(xc+rc*cos(phiminus),yc+rc*
sin(phiminus));
1060 double d2plus=(plus-fdchit->
xy).Mod2();
1061 double d2minus=(minus-fdchit->
xy).Mod2();
1074 vector<const DFDCSegment *>segments,
1075 vector<const DCDCTrackHit *>cdchits,
1077 unsigned int num_hits=0;
1082 for (
unsigned int k=0;k<cdchits.size();k++){
1083 if (cdchits[k]->is_stereo==
false){
1085 const DVector3 origin=cdchits[k]->wire->origin;
1086 double x=origin.x(),
y=origin.y(),z=origin.z();
1088 Bz+=bfield->GetBz(x,
y,z);
1093 for (
unsigned int k=0;k<segments.size();k++){
1094 for (
unsigned int n=0;n<segments[k]->hits.size();n++){
1095 const DFDCPseudo *fdchit=segments[k]->hits[n];
1099 Bz+=bfield->GetBz(fdchit->
xy.X(),fdchit->
xy.Y(),fdchit->
wire->
origin.z());
1101 num_hits+=segments[k]->hits.size();
1103 Bz=fabs(Bz)/double(num_hits);
1107 double p=0.003*Bz*fit.
r0/cos(atan(fit.
tanl));
1116 return RESOURCE_UNAVAILABLE;
1122 vector<unsigned int> &cdc_forward_ids,
1123 vector<DVector3>&cdc_endplate_projections,
1124 vector<int>&cdc_forward_matches
1129 double p_fdc=mom.Mag();
1130 ProjectHelixToZ(cdc_endplate.z(),fdccan->
charge(),mom,pos);
1134 double diff_min=1000.;
1135 unsigned int jmin=0;
1136 for (
unsigned int j=0;j<cdc_forward_ids.size();j++){
1137 if (cdc_forward_matches[j])
continue;
1138 double diff=(cdc_endplate_projections[j]-pos).Mag();
1146 match_dist->Fill(pos.Perp(),diff_min);
1147 match_dist_vs_p->Fill(p_fdc,diff_min);
1151 double p_cdc=cdctrackcandidates[cdc_forward_ids[jmin]]->momentum().Mag();
1154 vector<const DFDCSegment *>segments;
1155 fdccan->GetT(segments);
1159 if (segments.size()>1){
1160 double theta=180./M_PI*mom.Theta();
1161 if (p_fdc<0.3 && theta<5.)
return false;
1164 unsigned int cdc_index=cdc_forward_ids[jmin];
1165 if (MakeCandidateFromMethod1(mom.Theta(),segments,
1166 cdctrackcandidates[cdc_index])){
1169 _DBG_ <<
".. matched to CDC candidate #" << cdc_index <<endl;
1172 cdc_forward_matches[jmin]=1;
1191 vector<const DCDCTrackHit *>cdchits;
1192 cdccan->GetT(cdchits);
1200 const DVector2 fdc_hit_pos=segments[0]->hits[0]->xy;
1201 const DVector3 cdc_wire_origin=cdchits[0]->wire->origin;
1202 if (cdc_wire_origin.x()*fdc_hit_pos.X()<0.
1203 || cdc_wire_origin.y()*fdc_hit_pos.Y()<0.){
1204 if (DEBUG_LEVEL>0)
_DBG_ <<
"Skipping match of potential back-to-back tracks." <<endl;
1213 if (DoRefit(fit,segments,cdchits,Bz_avg)==NOERROR){
1215 double theta_cdc=cdccan->
momentum().Theta();
1216 if (segments.size()==1 && theta_cdc<M_PI_4){
1217 double numcdc=double(cdchits.size());
1218 double numfdc=segments[0]->hits.size();
1219 theta=(theta*numfdc+theta_cdc*numcdc)/(numfdc+numcdc);
1221 fit.
tanl=tan(M_PI_2-theta);
1224 const DFDCPseudo *fdchit=segments[0]->hits[0];
1228 UpdatePositionAndMomentum(fit,Bz_avg,cdchits[0]->wire->origin,pos,mom);
1239 for (
unsigned int m=0;m<segments.size();m++){
1240 for (
unsigned int n=0;n<segments[m]->hits.size();n++){
1241 can->AddAssociatedObject(segments[m]->hits[n]);
1244 for (
unsigned int n=0;n<cdchits.size();n++){
1245 can->AddAssociatedObject(cdchits[n]);
1255 trackcandidates.push_back(can);
1270 vector<const DCDCTrackHit *>cdchits;
1271 cdccan->GetT(cdchits);
1275 unsigned int num_match=0;
1276 unsigned int num_cdc=0;
1281 double q=fdccan->
charge();
1285 unsigned int outer_index=cdchits.size()-1;
1286 DVector3 origin=cdchits[outer_index]->wire->origin;
1287 DVector3 dir=(1./cdchits[outer_index]->wire->udir.z())*cdchits[outer_index]->wire->udir;
1288 DVector3 cdc_outer_wire_pos=origin+(167.-origin.z())*dir;
1289 if (cdc_outer_wire_pos.Perp()>pos.Perp()) {
1294 if ((cdc_outer_wire_pos-pos).Mag()>5.){
1300 for (
unsigned int m=0;m<cdchits.size();m++){
1301 double variance=1.6;
1304 double dr2=DocaToHelix(cdchits[m],q,pos,mom);
1305 double prob=isfinite(dr2) ? TMath::Prob(dr2/variance,1):0.0;
1307 if (prob>0.01) num_match++;
1308 if (DEBUG_LEVEL>1)
_DBG_ <<
"CDC s: " << cdchits[m]->wire->straw
1309 <<
" r: " << cdchits[m]->wire->ring
1310 <<
" prob: " << prob << endl;
1315 if (num_match>=3 &&
double(num_match)/
double(num_cdc)>0.33){
1317 vector<const DFDCSegment *>segments;
1318 fdccan->GetT(segments);
1328 const DVector2 fdc_hit_pos=segments[0]->hits[0]->xy;
1329 const DVector3 cdc_wire_origin=cdchits[0]->wire->origin;
1330 if (cdc_wire_origin.x()*fdc_hit_pos.X()<0.
1331 && cdc_wire_origin.y()*fdc_hit_pos.Y()<0.){
1332 if (DEBUG_LEVEL>0)
_DBG_ <<
"Skipping match of potential back-to-back tracks." <<endl;
1344 unsigned int num_fdc_hits=0;
1345 for (
unsigned int m=0;m<segments.size();m++){
1346 for (
unsigned int n=0;n<segments[m]->hits.size();n++){
1347 can->AddAssociatedObject(segments[m]->hits[n]);
1352 for (
unsigned int m=0;m<cdchits.size();m++){
1353 can->AddAssociatedObject(cdchits[m]);
1362 double theta=fdccan->
momentum().Theta();
1363 double theta_cdc=cdccan->
momentum().Theta();
1364 if (segments.size()==1&& theta_cdc<M_PI_4){
1365 double numcdc=double(cdchits.size());
1366 double numfdc=segments[0]->hits.size();
1367 theta=(theta*numfdc+theta_cdc*numcdc)/(numfdc+numcdc);
1369 fit.
tanl=tan(M_PI_2-theta);
1370 if (DoRefit(fit,segments,cdchits,Bz_avg)==NOERROR){
1376 const DFDCPseudo *fdchit=segments[0]->hits[0];
1378 pos.SetXYZ(fdchit->
xy.X(),fdchit->
xy.Y(),zhit);
1379 UpdatePositionAndMomentum(fit,Bz_avg,cdchits[0]->wire->origin,pos,mom);
1403 trackcandidates.push_back(can);
1414 vector<int> &forward_matches
1417 vector<const DCDCTrackHit *>cdchits;
1418 cdccan->GetT(cdchits);
1422 for (
unsigned int k=0;k<fdctrackcandidates.size();k++){
1423 if (forward_matches[k]==0){
1426 double p_fdc=fdccan->
momentum().Mag();
1427 double p_cdc=cdccan->
momentum().Mag();
1428 if (p_fdc/p_cdc>0.5){
1430 vector<const DFDCSegment *>segments;
1431 fdccan->GetT(segments);
1436 if (segments[0]->package>0)
continue;
1442 const DVector2 fdc_hit_pos=segments[0]->hits[0]->xy;
1443 const DVector3 cdc_wire_origin=cdchits[0]->wire->origin;
1444 if (cdc_wire_origin.x()*fdc_hit_pos.X()<0.
1445 && cdc_wire_origin.y()*fdc_hit_pos.Y()<0.){
1446 if (DEBUG_LEVEL>0)
_DBG_ <<
"Skipping match of potential back-to-back tracks." <<endl;
1453 double q=cdccan->
charge();
1458 for (
unsigned int m=0;m<segments.size();m++){
1459 for (
unsigned int n=0;n<segments[m]->hits.size();n++){
1460 unsigned int ind=segments[m]->hits.size()-1-n;
1461 const DFDCPseudo *hit=segments[m]->hits[ind];
1463 if (pos.Perp()<48.5){
1464 ProjectHelixToZ(hit->
wire->
origin.z(),q,mom,pos);
1468 double dx=XY.X()-pos.x();
1469 double dy=XY.Y()-pos.y();
1470 double dr2=dx*dx+dy*dy;
1472 double variance=1.0;
1473 double prob = isfinite(dr2) ? TMath::Prob(dr2/variance,1):0.0;
1474 if (prob>0.01) num_match++;
1480 || (num_match>0 &&
double(num_match)/
double(num_hits)>0.33)){
1487 forward_matches[k]=1;
1490 for (
unsigned int m=0;m<cdchits.size();m++){
1491 can->AddAssociatedObject(cdchits[m]);
1495 for (
unsigned int m=0;m<segments.size();m++){
1496 for (
unsigned int n=0;n<segments[m]->hits.size();n++){
1497 can->AddAssociatedObject(segments[m]->hits[n]);
1506 if (DoRefit(fit,segments,cdchits,Bz_avg)==NOERROR){
1508 double theta=fdccan->
momentum().Theta();
1509 double theta_cdc=cdccan->
momentum().Theta();
1510 if (segments.size()==1 && theta_cdc<M_PI_4){
1511 double numcdc=double(cdchits.size());
1512 double numfdc=segments[0]->hits.size();
1513 theta=(theta*numfdc+theta_cdc*numcdc)/(numfdc+numcdc);
1515 fit.
tanl=tan(M_PI_2-theta);
1525 const DFDCPseudo *fdchit=segments[0]->hits[0];
1527 pos.SetXYZ(fdchit->
xy.X(),fdchit->
xy.Y(),zhit);
1528 UpdatePositionAndMomentum(fit,Bz_avg,cdchits[0]->wire->origin,
1553 trackcandidates.push_back(can);
1555 if (DEBUG_LEVEL>0)
_DBG_ <<
".. matched to FDC candidate #" << k <<endl;
1569 vector<int> &forward_matches,
1570 int &num_fdc_cands_remaining){
1572 vector<const DFDCSegment *>src_segments;
1573 srccan->GetT(src_segments);
1575 if (src_segments.size()==1)
return false;
1578 if (DEBUG_LEVEL>0)
_DBG_ <<
"Attempting matching method #4..." <<endl;
1580 unsigned int pack1_last=src_segments[src_segments.size()-1]->package;
1581 unsigned int pack1_first=src_segments[0]->package;
1583 for (
unsigned int k=0;k<fdctrackcandidates.size();k++){
1584 if (num_fdc_cands_remaining==0)
break;
1585 if (forward_matches[k]==0){
1589 vector<const DFDCSegment *>segments;
1590 fdccan->GetT(segments);
1593 const DFDCPseudo *firsthit=segments[0]->hits[0];
1594 unsigned int pack2_first=segments[0]->package;
1595 unsigned int pack2_last=segments[segments.size()-1]->package;
1598 if (pack2_first-pack1_last==1 || pack1_first-pack2_last==1){
1602 double q=srccan->
charge();
1605 if (pack2_last<pack1_first){
1611 stepper->SetCharge(q);
1612 stepper->SwimToPlane(pos,mom,firsthit->wire->origin,norm,NULL);
1614 double dx=pos.x()-firsthit->xy.X();
1615 double dy=pos.y()-firsthit->xy.Y();
1616 double d2=dx*dx+dy*dy;
1618 double prob=TMath::Prob(d2/variance,1);
1620 unsigned int num_match=(prob>0.01)?1:0;
1623 for (
unsigned int i=1;i<segments[0]->hits.size();i++){
1626 if (pos.Perp()<48.5){
1627 ProjectHelixToZ(hit->
wire->
origin.z(),q,mom,pos);
1630 double dx=XY.X()-pos.x();
1631 double dy=XY.Y()-pos.y();
1632 double dr2=dx*dx+dy*dy;
1634 double variance=1.0;
1635 double prob = isfinite(dr2) ? TMath::Prob(dr2/variance,1):0.0;
1636 if (prob>0.01) num_match++;
1640 forward_matches[k]=1;
1647 unsigned int num_hits=0;
1655 for (
unsigned int m=0;m<src_segments.size();m++){
1656 for (
unsigned int n=0;n<src_segments[m]->hits.size();n++){
1657 const DFDCPseudo *fdchit=src_segments[m]->hits[n];
1659 can->AddAssociatedObject(fdchit);
1663 Bz_avg+=bfield->GetBz(fdchit->
xy.X(),fdchit->
xy.Y(),
1666 num_hits+=src_segments[m]->hits.size();
1668 for (
unsigned int m=0;m<segments.size();m++){
1669 for (
unsigned int n=0;n<segments[m]->hits.size();n++){
1670 const DFDCPseudo *fdchit=segments[m]->hits[n];
1672 can->AddAssociatedObject(fdchit);
1676 Bz_avg+=bfield->GetBz(fdchit->
xy.X(),fdchit->
xy.Y(),
1679 num_hits+=segments[m]->hits.size();
1685 Bz_avg=fabs(Bz_avg)/double(num_hits);
1688 double theta=fdccan->
momentum().Theta();
1689 fit.
tanl=tan(M_PI_2-theta);
1695 double p=0.003*fit.
r0*Bz_avg/cos(atan(fit.
tanl));
1701 fit.
h=GetSenseOfRotation(fit,firsthit,srccan->
position());
1707 pos.SetXYZ(myhit->
x,myhit->
y,myhit->
z);
1708 GetPositionAndMomentum(myhit->
z-1.,fit,Bz_avg,pos,mom);
1719 trackcandidates.push_back(can);
1721 num_fdc_cands_remaining--;
1724 _DBG_ <<
"Found a match using method #4" <<endl;
1739 vector<const DCDCTrackHit *>&cdchits,
1740 vector<int> &forward_matches
1743 for (
unsigned int k=0;k<fdctrackcandidates.size();k++){
1744 if (forward_matches[k]==0){
1747 unsigned int num_match=0;
1748 unsigned int num_cdc=0;
1752 double q=fdccan->
charge();
1754 for (
unsigned int m=0;m<cdchits.size();m++){
1755 double variance=1.0;
1758 double dr2=DocaToHelix(cdchits[m],q,pos,mom);
1759 double prob=isfinite(dr2) ? TMath::Prob(dr2/variance,1):0.0;
1761 if (prob>0.01) num_match++;
1762 if (DEBUG_LEVEL>1)
_DBG_ <<
"CDC s: " << cdchits[m]->wire->straw
1763 <<
" r: " << cdchits[m]->wire->ring
1764 <<
" prob: " << prob << endl;
1769 if (num_match>=3 &&
double(num_match)/
double(num_cdc)>0.33){
1771 vector<const DFDCSegment *>segments;
1772 fdccan->GetT(segments);
1782 const DVector2 fdc_hit_pos=segments[0]->hits[0]->xy;
1783 const DVector3 cdc_wire_origin=cdchits[0]->wire->origin;
1784 if (cdc_wire_origin.x()*fdc_hit_pos.X()<0.
1785 && cdc_wire_origin.y()*fdc_hit_pos.Y()<0.){
1786 if (DEBUG_LEVEL>0)
_DBG_ <<
"Skipping match of potential back-to-back tracks." <<endl;
1791 forward_matches[k]=1;
1793 if (DEBUG_LEVEL>0)
_DBG_ <<
"... matched to FDC candidate #" << k <<endl;
1796 for (
unsigned int m=0;m<segments.size();m++){
1797 for (
unsigned int n=0;n<segments[m]->hits.size();n++){
1798 can->AddAssociatedObject(segments[m]->hits[n]);
1807 if (DoRefit(fit,segments,cdchits,Bz_avg)==NOERROR){
1814 double theta=fdccan->
momentum().Theta();
1815 fit.
tanl=tan(M_PI_2-theta);
1821 const DFDCPseudo *fdchit=segments[0]->hits[0];
1823 pos.SetXYZ(fdchit->
xy.X(),fdchit->
xy.Y(),zhit);
1824 UpdatePositionAndMomentum(fit,Bz_avg,cdchits[0]->wire->origin,
1843 vector<const DFDCPseudo*>&fdchits,
1844 vector<unsigned int>&used_cdc_hits,
1845 unsigned int &num_unmatched_cdcs
1853 bool got_inner_index=
false;
1854 unsigned int inner_index=0;
1855 int id_for_smallest_dr=-1;
1859 for (
unsigned int k=0;k<used_cdc_hits.size();k++){
1862 if (mycdchits[k]->wire->ring!=old_ring){
1863 if (id_for_smallest_dr>=0){
1864 if (!used_cdc_hits[id_for_smallest_dr]){
1865 num_unmatched_cdcs--;
1866 used_cdc_hits[id_for_smallest_dr]=1;
1869 can->AddAssociatedObject(mycdchits[id_for_smallest_dr]);
1871 if (got_inner_index==
false){
1872 inner_index=id_for_smallest_dr;
1873 got_inner_index=
true;
1879 id_for_smallest_dr=-1;
1882 if (!used_cdc_hits[k]){
1883 double variance=1.0;
1886 double dr2=DocaToHelix(mycdchits[k],q,pos,mom);
1887 double prob=isfinite(dr2) ? TMath::Prob(dr2/variance,1):0.0;
1893 id_for_smallest_dr=k;
1897 old_ring=mycdchits[k]->wire->ring;
1900 if (id_for_smallest_dr>=0){
1901 if (!used_cdc_hits[id_for_smallest_dr]){
1902 num_unmatched_cdcs--;
1903 used_cdc_hits[id_for_smallest_dr]=1;
1906 can->AddAssociatedObject(mycdchits[id_for_smallest_dr]);
1911 if (got_inner_index){
1915 double Bz_avg=0.,denom=0.;
1916 for (
unsigned int m=0;m<fdchits.size();m++){
1918 double x=fdchit->
xy.X();
1919 double y=fdchit->
xy.Y();
1922 Bz_avg+=bfield->GetBz(x,y,z);
1925 Bz_avg=fabs(Bz_avg)/denom;
1931 fit.
h=q*FactorForSenseOfRotation;
1933 fit.
y0=pos.y()+fit.
h*fit.
r0*cos(fit.
phi);
1934 fit.
tanl=tan(M_PI_2-mom.Theta());
1939 pos.SetXYZ(firsthit->
xy.X(),firsthit->
xy.Y(),zhit);
1940 UpdatePositionAndMomentum(fit,Bz_avg,mycdchits[inner_index]->wire->origin,
1947 if (DEBUG_LEVEL>0)
_DBG_ <<
"... matched stray CDC hits ..." << endl;
1954 vector<int> &forward_matches,
1955 int &num_fdc_cands_remaining){
1956 if (DEBUG_LEVEL>0)
_DBG_ <<
"Attempting matching method #7..." <<endl;
1959 vector<const DFDCPseudo *>fdchits;
1960 srccan->GetT(fdchits);
1961 if (fdchits.size()==0)
return false;
1964 unsigned int pack1_last=(fdchits[fdchits.size()-1]->wire->layer-1)/6;
1966 for (
unsigned int k=0;k<fdctrackcandidates.size();k++){
1967 if (num_fdc_cands_remaining==0)
break;
1968 if (forward_matches[k]==0){
1972 vector<const DFDCSegment *>segments;
1973 fdccan->GetT(segments);
1976 const DFDCPseudo *firsthit=segments[0]->hits[0];
1977 unsigned int pack2_first=segments[0]->package;
1979 if (pack2_first-pack1_last==1){
1983 double q=srccan->
charge();
1988 stepper->SetCharge(q);
1989 stepper->SwimToPlane(pos,mom,firsthit->wire->origin,norm,NULL);
1991 double dx=pos.x()-firsthit->xy.X();
1992 double dy=pos.y()-firsthit->xy.Y();
1993 double d2=dx*dx+dy*dy;
1995 double prob=TMath::Prob(d2/variance,1);
1997 unsigned int num_match=(prob>0.01)?1:0;
2000 for (
unsigned int i=1;i<segments[0]->hits.size();i++){
2003 if (pos.Perp()<48.5){
2004 ProjectHelixToZ(hit->
wire->
origin.z(),q,mom,pos);
2007 double dx=XY.X()-pos.x();
2008 double dy=XY.Y()-pos.y();
2009 double dr2=dx*dx+dy*dy;
2011 double variance=1.0;
2012 double prob = isfinite(dr2) ? TMath::Prob(dr2/variance,1):0.0;
2013 if (prob>0.01) num_match++;
2017 forward_matches[k]=1;
2018 num_fdc_cands_remaining--;
2022 unsigned int num_hits=0;
2029 vector<const DCDCTrackHit *>cdchits;
2030 srccan->GetT(cdchits);
2032 for (
unsigned int i=0;i<cdchits.size();i++){
2033 if (cdchits[i]->is_stereo==
false){
2035 const DVector3 origin=cdchits[i]->wire->origin;
2036 double x=origin.x(),
y=origin.y(),z=origin.z();
2038 Bz+=bfield->GetBz(x,
y,z);
2043 for (
unsigned int i=0;i<fdchits.size();i++){
2045 double zhit=fdchits[i]->wire->origin.z();
2047 Bz+=bfield->GetBz(fdchits[i]->xy.X(),fdchits[i]->xy.Y(),zhit);
2050 if (zhit<firsthit->wire->origin.z()){
2051 firsthit=fdchits[i];
2056 for (
unsigned int m=0;m<segments.size();m++){
2057 for (
unsigned int n=0;n<segments[m]->hits.size();n++){
2058 const DFDCPseudo *fdchit=segments[m]->hits[n];
2062 Bz+=bfield->GetBz(fdchit->
xy.X(),fdchit->
xy.Y(),zhit);
2063 srccan->AddAssociatedObject(fdchit);
2065 num_hits+=segments[m]->hits.size();
2067 Bz=fabs(Bz)/double(num_hits);
2072 double theta=srccan->
momentum().Theta();
2073 fit.
tanl=tan(M_PI_2-theta);
2075 double p=0.003*fit.
r0*Bz/cos(atan(fit.
tanl));
2076 if ((cdchits.size())>0?(p>3.):(p>10.)){
2081 if (cdchits.size()>0){
2083 double zhit=firsthit->wire->origin.z();
2084 pos.SetXYZ(firsthit->xy.X(),firsthit->xy.Y(),zhit);
2085 UpdatePositionAndMomentum(fit,Bz,cdchits[0]->wire->origin,
2091 pos.SetXYZ(myhit->
x,myhit->
y,myhit->
z);
2092 GetPositionAndMomentum(myhit->
z-1.,fit,Bz,pos,mom);
2104 if (DEBUG_LEVEL>0)
_DBG_ <<
"Found a match using method #7" <<endl;
2123 vector<int> &forward_matches
2126 vector<const DCDCTrackHit *>cdchits;
2127 cdccan->GetT(cdchits);
2130 unsigned int last_index=cdchits.size()-1;
2131 if (cdchits[last_index]->is_stereo==
true
2132 && cdchits[last_index]->wire->ring<13){
2136 DVector3 origin=cdchits[last_index]->wire->origin;
2138 DVector3 wirepos=origin+(75./dir.z())*dir;
2140 double x=wirepos.x(),
y=wirepos.y(),z=wirepos.z();
2142 double Bz=bfield->GetBz(x,
y,z);
2146 for (
unsigned int k=0;k<cdchits.size();k++){
2147 if (cdchits[k]->is_stereo==
false){
2149 origin=cdchits[k]->wire->origin;
2150 double x=origin.x(),
y=origin.y(),z=origin.z();
2152 Bz+=bfield->GetBz(x,
y,z);
2156 Bz=fabs(Bz)/num_hits;
2160 if (fit.
FitCircle()!=NOERROR)
return false;
2163 double tworc=2.*fit.
r0;
2164 double ratio=wirepos.Perp()/tworc;
2165 double sperp=tworc*((ratio<1.)?asin(ratio):M_PI_2);
2166 fit.
tanl=(wirepos.z()-TARGET_Z)/sperp;
2170 double q=fit.
h*FactorForSenseOfRotation;
2175 UpdatePositionAndMomentum(fit,Bz,cdchits[0]->wire->origin,pos,mom);
2178 stepper->SetCharge(q);
2183 for (
unsigned int k=0;k<fdctrackcandidates.size();k++){
2184 if (forward_matches[k]==0){
2188 vector<const DFDCSegment *>segments;
2189 fdccan->GetT(segments);
2193 if (segments[0]->package>0)
continue;
2195 const DFDCPseudo *firsthit=segments[0]->hits[0];
2204 stepper->SwimToPlane(my_pos,my_mom,firsthit->
wire->
origin,norm,NULL);
2207 double dx=my_pos.x()-firsthit->
xy.X();
2208 double dy=my_pos.y()-firsthit->
xy.Y();
2209 double d2=dx*dx+dy*dy;
2211 double prob=TMath::Prob(d2/variance,1);
2213 unsigned int num_match=(prob>0.01)?1:0;
2216 for (
unsigned int i=1;i<segments[0]->hits.size();i++){
2219 if (my_pos.Perp()<48.5){
2220 ProjectHelixToZ(hit->
wire->
origin.z(),q,my_mom,my_pos);
2223 double dx=XY.X()-my_pos.x();
2224 double dy=XY.Y()-my_pos.y();
2225 double dr2=dx*dx+dy*dy;
2227 double variance=1.0;
2228 double prob = isfinite(dr2) ? TMath::Prob(dr2/variance,1):0.0;
2229 if (prob>0.01) num_match++;
2233 forward_matches[k]=1;
2237 unsigned int num_hits_fdc=0;
2245 for (
unsigned int m=0;m<segments.size();m++){
2246 for (
unsigned int n=0;n<segments[m]->hits.size();n++){
2247 const DFDCPseudo *fdchit=segments[m]->hits[n];
2250 Bz_fdc+=bfield->GetBz(fdchit->
xy.X(),fdchit->
xy.Y(),
2253 num_hits_fdc+=segments[m]->hits.size();
2261 double theta=fdccan->
momentum().Theta();
2262 double theta_cdc=cdccan->
momentum().Theta();
2263 if (segments.size()==1 && theta_cdc<M_PI_4){
2264 double numcdc=double(cdchits.size());
2265 double numfdc=segments[0]->hits.size();
2266 theta=(theta*numfdc+theta_cdc*numcdc)/(numfdc+numcdc);
2268 fit.
tanl=tan(M_PI_2-theta);
2270 Bz=0.5*(Bz+fabs(Bz_fdc)/num_hits_fdc);
2272 double p=0.003*fit.
r0*Bz/cos(atan(fit.
tanl));
2279 const DFDCPseudo *fdchit=segments[0]->hits[0];
2281 pos.SetXYZ(fdchit->
xy.X(),fdchit->
xy.Y(),zhit);
2282 UpdatePositionAndMomentum(fit,Bz,cdchits[0]->wire->origin,pos,mom);
2297 for (
unsigned int m=0;m<segments.size();m++){
2298 for (
unsigned int n=0;n<segments[m]->hits.size();n++){
2299 const DFDCPseudo *fdchit=segments[m]->hits[n];
2300 can->AddAssociatedObject(fdchit);
2303 for (
unsigned int n=0;n<cdchits.size();n++){
2304 can->AddAssociatedObject(cdchits[n]);
2307 trackcandidates.push_back(can);
2309 if (DEBUG_LEVEL>0)
_DBG_ <<
"Matched using Method #8" <<endl;
2327 vector<const DTrackCandidate*>&cands,
2328 vector<int> &forward_matches){
2330 _DBG_ <<
"Attempting Match method #9..." << endl;
2332 double q=srccan->
charge();
2337 for (
unsigned int n=0;n<segment->
hits.size();n++){
2341 if (fit1.
FitCircle()!=NOERROR)
return false;
2344 fit1.
h=q*FactorForSenseOfRotation;
2347 double theta=srccan->
momentum().Theta();
2348 fit1.
tanl=tan(M_PI_2-theta);
2351 double x=segment->
hits[0]->xy.X();
2352 double y=segment->
hits[0]->xy.Y();
2353 double z=segment->
hits[0]->wire->origin.z();
2354 double Bz=fabs(bfield->GetBz(x,y,z));
2358 GetPositionAndMomentum(z,fit1,Bz,mypos,mymom);
2362 for (
unsigned int k=src_index+1;k<forward_matches.size();k++){
2363 if (forward_matches[k]==0){
2366 vector<const DFDCSegment *>segments2;
2367 can2->GetT(segments2);
2369 int pack2=segments2[0]->package;
2370 if (abs(pack1-pack2)>0){
2374 for (
unsigned int n=0;n<segments2[0]->hits.size();n++){
2378 if (fit2.
FitCircle()!=NOERROR)
continue;
2381 double dx=fit1.
x0-fit2.
x0;
2382 double dy=fit1.
y0-fit2.
y0;
2383 double circle_center_diff2=dx*dx+dy*dy;
2384 double got_match=
false;
2385 if (circle_center_diff2<9.0) got_match=
true;
2389 double q2=can2->
charge();
2390 fit2.
h=q2*FactorForSenseOfRotation;
2394 fit2.
tanl=tan(M_PI_2-theta);
2397 got_match=MatchMethod11(q,mypos,mymom,fit2,segment,segments2[0]);
2401 forward_matches[k]=1;
2402 forward_matches[src_index]=1;
2412 for (
unsigned int n=0;n<segment->
hits.size();n++){
2414 can->AddAssociatedObject(fdchit);
2416 Bz+=bfield->GetBz(fdchit->
xy.X(),fdchit->
xy.Y(),
2424 for (
unsigned int n=0;n<segments2[0]->hits.size();n++){
2427 can->AddAssociatedObject(hit);
2429 Bz+=bfield->GetBz(hit->
xy.X(),hit->
xy.Y(),
2433 Bz=fabs(Bz)/double(num_hits);
2449 double p=0.003*fit1.
r0*Bz/cos(atan(fit1.
tanl));
2456 fit1.
h=GetSenseOfRotation(fit1,segments2[0]->hits[0],
2458 q=FactorForSenseOfRotation*fit1.
h;
2462 pos.SetXYZ(myhit->
x,myhit->
y,myhit->
z);
2463 GetPositionAndMomentum(myhit->
z-1.,fit1,Bz,pos,mom);
2474 trackcandidates.push_back(can);
2477 _DBG_ <<
"Match method #9 succeeded..." << endl;
2495 vector<const DTrackCandidate*>&cands,
2496 vector<int> &forward_matches){
2498 _DBG_ <<
"Attempting Match method #10..." << endl;
2500 double q=srccan->
charge();
2505 for (
unsigned int n=0;n<segment->
hits.size();n++){
2512 fit1.
h=q*FactorForSenseOfRotation;
2515 double theta=srccan->
momentum().Theta();
2516 fit1.
tanl=tan(M_PI_2-theta);
2519 double x=segment->
hits[0]->xy.X();
2520 double y=segment->
hits[0]->xy.Y();
2521 double z=segment->
hits[0]->wire->origin.z();
2522 double Bz=fabs(bfield->GetBz(x,y,z));
2526 GetPositionAndMomentum(z,fit1,Bz,mypos,mymom);
2530 for (
unsigned int k=src_index+1;k<forward_matches.size();k++){
2531 if (forward_matches[k]==0){
2534 vector<const DFDCSegment *>segments2;
2535 can2->GetT(segments2);
2537 int pack2=segments2[0]->package;
2538 if (abs(pack1-pack2)>0){
2541 for (
unsigned int n=0;n<segments2[0]->hits.size();n++){
2548 double q2=can2->
charge();
2549 fit2.
h=q2*FactorForSenseOfRotation;
2553 fit2.
tanl=tan(M_PI_2-theta);
2556 if (MatchMethod11(q,mypos,mymom,fit2,segment,segments2[0])){
2557 forward_matches[k]=1;
2558 forward_matches[src_index]=1;
2568 for (
unsigned int n=0;n<segment->
hits.size();n++){
2570 can->AddAssociatedObject(fdchit);
2572 Bz+=bfield->GetBz(fdchit->
xy.X(),fdchit->
xy.Y(),
2580 for (
unsigned int n=0;n<segments2[0]->hits.size();n++){
2583 can->AddAssociatedObject(hit);
2585 Bz+=bfield->GetBz(hit->
xy.X(),hit->
xy.Y(),
2589 Bz=fabs(Bz)/double(num_hits);
2594 double q=srccan->
charge();
2605 double p=0.003*fit1.
r0*Bz/cos(atan(fit1.
tanl));
2612 fit1.
h=GetSenseOfRotation(fit1,segments2[0]->hits[0],
2614 q=FactorForSenseOfRotation*fit1.
h;
2618 pos.SetXYZ(myhit->
x,myhit->
y,myhit->
z);
2619 GetPositionAndMomentum(myhit->
z-1.,fit1,Bz,pos,mom);
2630 trackcandidates.push_back(can);
2633 _DBG_ <<
"Match method #10 succeeded..." << endl;
2653 _DBG_ <<
"Attempting Match method #11..." << endl;
2661 if ((pack2<pack1 && mymom.z()>0.) || (pack1>pack2 && mymom.z()<0.)) mymom=(-1.)*mymom;
2664 double x=segment2->
hits[0]->xy.X();
2665 double y=segment2->
hits[0]->xy.Y();
2666 double z=segment2->
hits[0]->wire->origin.z();
2668 double Bz=fabs(bfield->GetBz(x,y,z));
2676 GetPositionAndMomentum(z,fit2,Bz,mypos2,mymom2);
2678 if (pack2>pack1) mymom2=(-1.)*mymom2;
2683 stepper->SetCharge(q);
2684 stepper->SwimToPlane(mypos1,mymom1,secondhit->
wire->
origin,norm,NULL);
2688 if (mypos1.Perp()<48.5){
2690 double dx=mypos1.x()-secondhit->
xy.X();
2691 double dy=mypos1.y()-secondhit->
xy.Y();
2692 double d2=dx*dx+dy*dy;
2693 double prob=TMath::Prob(d2/variance,1);
2695 unsigned int num_match=(prob>0.01)?1:0;
2698 for (
unsigned int i=1;i<segment2->
hits.size();i++){
2701 if (mypos1.Perp()<48.5){
2702 ProjectHelixToZ(hit->
wire->
origin.z(),q,mymom1,mypos1);
2705 double dx=XY.X()-mypos1.x();
2706 double dy=XY.Y()-mypos1.y();
2707 double dr2=dx*dx+dy*dy;
2709 double variance=1.0;
2710 double prob = isfinite(dr2) ? TMath::Prob(dr2/variance,1):0.0;
2711 if (prob>0.01) num_match++;
2716 _DBG_ <<
"Method 11: found match!" << endl;
2723 secondhit=segment1->
hits[0];
2725 double q2=fit2.
h*FactorForSenseOfRotation;
2726 stepper->SetCharge(q2);
2727 stepper->SwimToPlane(mypos2,mymom2,secondhit->
wire->
origin,norm,NULL);
2729 if (mypos2.Perp()<48.5){
2731 double dx=mypos2.x()-secondhit->
xy.X();
2732 double dy=mypos2.y()-secondhit->
xy.Y();
2733 double d2=dx*dx+dy*dy;
2735 double prob=TMath::Prob(d2/variance,1);
2737 unsigned int num_match=(prob>0.01)?1:0;
2740 for (
unsigned int i=1;i<segment1->
hits.size();i++){
2743 if (mypos2.Perp()<48.5){
2744 ProjectHelixToZ(hit->
wire->
origin.z(),q2,mymom2,mypos2);
2747 double dx=XY.X()-mypos2.x();
2748 double dy=XY.Y()-mypos2.y();
2749 double dr2=dx*dx+dy*dy;
2751 double variance=1.0;
2752 double prob = isfinite(dr2) ? TMath::Prob(dr2/variance,1):0.0;
2753 if (prob>0.01) num_match++;
2758 _DBG_ <<
"Method 11: found match!" << endl;
2771 vector<int> &forward_matches,
2772 int &num_fdc_cands_remaining){
2774 _DBG_ <<
"Attempting matching method #12..." <<endl;
2776 for (
unsigned int i=0;i<fdctrackcandidates.size();i++){
2777 if (num_fdc_cands_remaining==0)
return false;
2778 if (forward_matches[i])
continue;
2781 if (fdccan->
momentum().Mag()>0.5)
continue;
2784 double dx=can->
xc-fdccan->
xc;
2785 double dy=can->
yc-fdccan->
yc;
2786 double dr2=dx*dx+dy*dy;
2788 if (dr2<4.0 && fabs((can->
rc-fdccan->
rc)/can->
rc)<0.5
2792 vector<const DFDCSegment *>segments;
2793 fdccan->GetT(segments);
2797 vector<const DFDCPseudo*>myfdchits;
2798 can->GetT(myfdchits);
2799 if (myfdchits.size()>0){
2801 unsigned int last_package
2802 =(myfdchits[myfdchits.size()-1]->wire->layer-1)/6;
2804 if (segments[0]->package-last_package==1){
2805 vector<const DCDCTrackHit *>cdchits;
2810 unsigned int num_hits=0;
2815 for (
unsigned int k=0;k<cdchits.size();k++){
2816 if (cdchits[k]->is_stereo==
false){
2818 const DVector3 origin=cdchits[k]->wire->origin;
2819 double x=origin.x(),
y=origin.y(),z=origin.z();
2824 for (
unsigned int k=0;k<segments.size();k++){
2825 for (
unsigned int n=0;n<segments[k]->hits.size();n++){
2826 const DFDCPseudo *fdchit=segments[k]->hits[n];
2830 Bz+=bfield->GetBz(fdchit->
xy.X(),fdchit->
xy.Y(),fdchit->
wire->
origin.z());
2832 num_hits+=segments[k]->hits.size();
2834 for (
unsigned int k=0;k<myfdchits.size();k++){
2839 Bz+=bfield->GetBz(fdchit->
xy.X(),fdchit->
xy.Y(),fdchit->
wire->
origin.z());
2841 num_hits+=myfdchits.size();
2842 Bz=fabs(Bz)/double(num_hits);
2847 double theta=fdccan->
momentum().Theta();
2848 double theta_cdc=can->
momentum().Theta();
2849 if (segments.size()==1 && theta_cdc<M_PI_4){
2850 double numcdc=double(cdchits.size());
2851 double numfdc=segments[0]->hits.size();
2852 theta=(theta*numfdc+theta_cdc*numcdc)/(numfdc+numcdc);
2854 fit.
tanl=tan(M_PI_2-theta);
2859 if (myfdchits.size()) myorigin.SetXYZ(myfdchits[0]->xy.X(),
2860 myfdchits[0]->xy.Y(),
2861 myfdchits[0]->wire->origin.z());
2862 if (cdchits.size()) myorigin=cdchits[0]->wire->origin;
2864 UpdatePositionAndMomentum(fit,Bz,myorigin,pos,mom);
2872 for (
unsigned int m=0;m<segments.size();m++){
2873 for (
unsigned int n=0;n<segments[m]->hits.size();n++){
2874 can->AddAssociatedObject(segments[m]->hits[n]);
2884 forward_matches[i]=1;
2885 num_fdc_cands_remaining--;
2888 _DBG_ <<
"... Found match!" << endl;
2896 vector<const DCDCTrackHit *>cdchits;
2902 unsigned int num_hits=0;
2907 for (
unsigned int k=0;k<cdchits.size();k++){
2908 if (cdchits[k]->is_stereo==
false){
2910 const DVector3 origin=cdchits[k]->wire->origin;
2911 double x=origin.x(),
y=origin.y(),z=origin.z();
2916 for (
unsigned int k=0;k<segments.size();k++){
2917 for (
unsigned int n=0;n<segments[k]->hits.size();n++){
2918 const DFDCPseudo *fdchit=segments[k]->hits[n];
2922 Bz+=bfield->GetBz(fdchit->
xy.X(),fdchit->
xy.Y(),fdchit->
wire->
origin.z());
2924 num_hits+=segments[k]->hits.size();
2926 Bz=fabs(Bz)/double(num_hits);
2931 double theta=fdccan->
momentum().Theta();
2932 double theta_cdc=can->
momentum().Theta();
2933 if (segments.size()==1 && theta_cdc<M_PI_4){
2934 double numcdc=double(cdchits.size());
2935 double numfdc=segments[0]->hits.size();
2936 theta=(theta*numfdc+theta_cdc*numcdc)/(numfdc+numcdc);
2939 fit.
tanl=tan(M_PI_2-theta);
2940 DVector3 myorigin=cdchits[0]->wire->origin;
2942 UpdatePositionAndMomentum(fit,Bz,cdchits[0]->wire->origin,pos,mom);
2950 for (
unsigned int m=0;m<segments.size();m++){
2951 for (
unsigned int n=0;n<segments[m]->hits.size();n++){
2952 can->AddAssociatedObject(segments[m]->hits[n]);
2963 forward_matches[i]=1;
2964 num_fdc_cands_remaining--;
2967 _DBG_ <<
"... Found match!" << endl;
2985 vector<const DTrackCandidate*>&cands,
2986 vector<int> &forward_matches){
2988 _DBG_ <<
"Attempting Match method #13..." << endl;
2990 double q=srccan->
charge();
2995 for (
unsigned int n=0;n<segment->
hits.size();n++){
3003 double theta=srccan->
momentum().Theta();
3004 fit1.
tanl=tan(M_PI_2-theta);
3011 double x=segment->
hits[0]->xy.X();
3012 double y=segment->
hits[0]->xy.Y();
3013 double z=segment->
hits[0]->wire->origin.z();
3014 double Bz=fabs(bfield->GetBz(x,y,z));
3018 GetPositionAndMomentum(z,fit1,Bz,mypos,mymom);
3022 for (
unsigned int k=src_index+1;k<forward_matches.size();k++){
3023 if (forward_matches[k]==0){
3026 vector<const DFDCSegment *>segments2;
3027 can2->GetT(segments2);
3029 int pack2=segments2[0]->package;
3030 if (abs(pack1-pack2)>0){
3033 for (
unsigned int n=0;n<segments2[0]->hits.size();n++){
3042 fit2.
tanl=tan(M_PI_2-theta);
3049 if (MatchMethod11(q,mypos,mymom,fit2,segment,segments2[0])){
3050 forward_matches[k]=1;
3051 forward_matches[src_index]=1;
3061 for (
unsigned int n=0;n<segment->
hits.size();n++){
3063 can->AddAssociatedObject(fdchit);
3065 Bz+=bfield->GetBz(fdchit->
xy.X(),fdchit->
xy.Y(),
3073 for (
unsigned int n=0;n<segments2[0]->hits.size();n++){
3076 can->AddAssociatedObject(hit);
3078 Bz+=bfield->GetBz(hit->
xy.X(),hit->
xy.Y(),
3082 Bz=fabs(Bz)/double(num_hits);
3087 double q=srccan->
charge();
3099 fit1.
h=GetSenseOfRotation(fit1,segments2[0]->hits[0],
3101 q=FactorForSenseOfRotation*fit1.
h;
3105 pos.SetXYZ(myhit->
x,myhit->
y,myhit->
z);
3106 GetPositionAndMomentum(myhit->
z-1.,fit1,Bz,pos,mom);
3117 trackcandidates.push_back(can);
3120 _DBG_ <<
"Match method #13 succeeded..." << endl;
3141 double phi1=atan2(pos.y()-yc,pos.x()-xc);
3142 double q_over_rc_tanl=FactorForSenseOfRotation*fit.
h/(rc*fit.
tanl);
3143 double dphi_s=(pos.z()-z)*q_over_rc_tanl;
3144 double dphi1=phi1-dphi_s;
3145 double x=xc+rc*cos(dphi1);
3146 double y=yc+rc*
sin(dphi1);
3150 if (fit.
h<0) dphi1+=M_PI;
3153 double pt=0.003*fabs(Bz)*rc;
3154 double px=pt*
sin(dphi1);
3155 double py=pt*cos(dphi1);
3156 double pz=pt*fit.
tanl;
3157 mom.SetXYZ(px,py,pz);
3168 if (schits.size()==0)
return false;
3170 _DBG_ <<
"Attempting to flip direction of track..." << endl;
3173 double zsc=sc_pos[0][1].z();
3175 unsigned int best_sc_sector_id=0;
3176 double dphi_min=1000.;
3177 double cand_phi=pos.Phi();
3178 for (
unsigned int k=0;k<schits.size();k++){
3179 unsigned int sector_id=schits[k]->sector-1;
3180 double dphi=cand_phi-sc_pos[sector_id][0].Phi();
3181 if (dphi<-M_PI) dphi+=2.*M_PI;
3182 if (dphi>M_PI) dphi-=2.*M_PI;
3184 if (fabs(dphi)<dphi_min){
3185 best_sc_sector_id=sector_id;
3186 dphi_min=fabs(dphi);
3189 if (dphi_min<0.105){
3191 mom.SetMagThetaPhi(mom.Mag(),M_PI-mom.Theta(),mom.Phi());
3192 pos=sc_pos[best_sc_sector_id][1];
3195 _DBG_ <<
"Changing direction of CDC candidate..." << endl;
3208 int &num_fdc_cands_remaining){
3210 _DBG_ <<
"Attempting to match stray FDC segments..." << endl;
3213 bool got_new_match=
false;
3214 for (
unsigned int j=0;j<forward_matches.size();j++){
3215 if (num_fdc_cands_remaining==0)
break;
3216 if (forward_matches[j]==0){
3220 vector<const DFDCSegment *>segments;
3221 srccan->GetT(segments);
3225 if (MatchMethod9(j,srccan,segment,fdctrackcandidates,forward_matches)){
3226 if (DEBUG_LEVEL>0)
_DBG_ <<
"Matched FDC segments using method #9" << endl;
3227 num_fdc_cands_remaining-=2;
3231 else if (MatchMethod10(j,srccan,segment,fdctrackcandidates,
3233 if (DEBUG_LEVEL>0)
_DBG_ <<
"Matched FDC segments using method #10" << endl;
3234 num_fdc_cands_remaining-=2;
3239 else if (MatchMethod13(j,srccan,segment,fdctrackcandidates,
3241 if (DEBUG_LEVEL>0)
_DBG_ <<
"Matched FDC segments using method #13" << endl;
3242 num_fdc_cands_remaining-=2;
3247 return got_new_match;
3262 if (GetPositionAndMomentum(fit,Bz,origin,pos,mom)!=NOERROR){
3264 GetPositionAndMomentum(fit,Bz,pos,mom);
3269 GetPositionAndMomentum(0.,fit,Bz,pos,mom);
3276 double phi0=atan2(-fdccan->
xc,fdccan->
yc);
3277 double q=fdccan->
charge();
3278 if (FactorForSenseOfRotation*q<0) phi0+=M_PI;
3279 double sinphi0=
sin(phi0);
3280 double sign=(sinphi0>0)?1.:-1.;
3281 if (fabs(sinphi0)<1
e-8) sinphi0=sign*1
e-8;
3282 double D=q*fdccan->
rc-fdccan->
xc/sinphi0;
3283 double x=-D*sinphi0;
3284 double y=D*cos(phi0);
3286 double dx=pos.x()-
x;
3287 double dy=pos.y()-
y;
3288 double ratio=
sqrt(dx*dx+dy*dy)/(2.*fdccan->
rc);
3289 double phi_s=(ratio<1.)?2.*asin(ratio):M_PI;
3290 double newz=pos.z()-phi_s*tan(M_PI_2-fdccan->
momentum().Theta())*fdccan->
rc;
void setMomentum(const DVector3 &aMomentum)
DVector2 xy
rough x,y coordinates in lab coordinate system
bool SegmentSortByLayerincreasing(const DFDCSegment *const &segment1, const DFDCSegment *const &segment2)
virtual jerror_t brun(JEventLoop *eventLoop, int32_t runnumber)
DMagneticFieldMap * GetBfield(unsigned int run_number=1)
bool MatchMethod8(const DTrackCandidate *cdccan, vector< int > &forward_matches)
const DVector3 & position(void) const
const DFDCWire * wire
DFDCWire for this wire.
void UpdatePositionAndMomentum(DHelicalFit &fit, double Bz, const DVector3 &origin, DVector3 &pos, DVector3 &mom) const
bool cdc_fdc_match(double p_fdc, double p_cdc, double dist)
bool MatchMethod3(const DTrackCandidate *cdccan, vector< int > &forward_matches)
jerror_t FitCircleRiemann(float rc=0.)
class DFDCPseudo: definition for a reconstructed point in the FDC
void MatchMethod6(DTrackCandidate *can, vector< const DFDCPseudo * > &fdchits, vector< unsigned int > &used_cdc_hits, unsigned int &num_unmatched_cdcs)
virtual jerror_t evnt(JEventLoop *loop, uint64_t eventnumber)
Invoked via JEventProcessor virtual method.
bool MakeCandidateFromMethod1(double theta, vector< const DFDCSegment * > &segments, const DTrackCandidate *cdccan)
bool MatchMethod2(const DTrackCandidate *fdccan, const DTrackCandidate *cdccan)
DMagneticFieldStepper class.
bool TryToFlipDirection(vector< const DSCHit * > &scihits, DVector3 &mom, DVector3 &pos) const
jerror_t AddHitXYZ(float x, float y, float z)
jerror_t AddHit(float r, float phi, float z)
vector< int > used_cdc_indexes
bool MatchMethod7(DTrackCandidate *srccan, vector< int > &forward_matches, int &num_fdc_cands_remaining)
vector< const DFDCPseudo * > hits
bool MatchMethod10(unsigned int src_index, const DTrackCandidate *srccan, const DFDCSegment *segment, vector< const DTrackCandidate * > &cands, vector< int > &forward_matches)
jerror_t GuessChargeFromCircleFit(void)
bool MatchMethod13(unsigned int src_index, const DTrackCandidate *srccan, const DFDCSegment *segment, vector< const DTrackCandidate * > &cands, vector< int > &forward_matches)
bool MatchStraySegments(vector< int > &forward_matches, int &num_fdc_cands_remaining)
double dE
energy deposition, from integral
DGeometry * GetDGeometry(unsigned int run_number)
double DocaToHelix(const DCDCTrackHit *hit, double q, const DVector3 &pos, const DVector3 &mom)
jerror_t DoRefit(DHelicalFit &fit, vector< const DFDCSegment * >segments, vector< const DCDCTrackHit * >cdchits, double &Bz)
void ProjectHelixToZ(const double z, const double q, const DVector3 &mom, DVector3 &pos)
bool MatchMethod12(DTrackCandidate *srccan, vector< int > &forward_matches, int &num_fdc_cands_remaining)
const vector< DHFHit_t * > GetHits() const
bool MatchMethod1(const DTrackCandidate *fdccan, vector< unsigned int > &cdc_forward_ids, vector< DVector3 > &cdc_endplate_projections, vector< int > &cdc_forward_matches)
bool CDCHitSortByLayerincreasing(const DCDCTrackHit *const &hit1, const DCDCTrackHit *const &hit2)
bool MatchMethod5(DTrackCandidate *can, vector< const DCDCTrackHit * > &cdchits, vector< int > &forward_matches)
double charge(void) const
<A href="index.html#legend"> <IMG src="CORE.png" width="100"> </A>
void setPID(Particle_t locPID)
jerror_t FitLineRiemann(void)
float chisq
Chi-squared for the track (not chisq/dof!)
bool MatchMethod9(unsigned int src_index, const DTrackCandidate *srccan, const DFDCSegment *segment, vector< const DTrackCandidate * > &cands, vector< int > &forward_matches)
bool CheckZPosition(const DTrackCandidate *fdccan) const
void FindSenseOfRotation(void)
jerror_t FitCircleStraightTrack()
const DVector3 & momentum(void) const
double GetSenseOfRotation(DHelicalFit &fit, const DFDCPseudo *fdchit, const DVector3 &pos)
bool FDCHitSortByLayerincreasing(const DFDCPseudo *const &hit1, const DFDCPseudo *const &hit2)
jerror_t PruneHit(int idx)
void GetPositionAndMomentum(const DFDCSegment *segment, DVector3 &pos, DVector3 &mom) const
int Ndof
Number of degrees of freedom in the fit.
virtual jerror_t erun(void)
bool GetCDCEndplate(double &z, double &dz, double &rmin, double &rmax) const
void setPosition(const DVector3 &aPosition)
virtual jerror_t init(void)
bool MatchMethod11(double q, DVector3 &mypos, DVector3 &mymom, DHelicalFit &fit2, const DFDCSegment *segment1, const DFDCSegment *segment2)
bool MatchMethod4(const DTrackCandidate *srccan, vector< int > &forward_matches, int &num_fdc_cands_remaining)
class DFDCSegment: definition for a track segment in the FDC
bool GetTargetZ(double &z_target) const
z-location of center of target
float z
point in lab coordinates
Particle_t PID(void) const
bool GetStartCounterGeom(vector< vector< DVector3 > > &pos, vector< vector< DVector3 > > &norm) const
virtual jerror_t fini(void)