#include <AlgFitTrackSR.h>
Inheritance diagram for AlgFitTrackSR:

Public Member Functions | |
| AlgFitTrackSR () | |
| virtual | ~AlgFitTrackSR () |
| virtual void | RunAlg (AlgConfig &ac, CandHandle &ch, CandContext &cx) |
| virtual void | Trace (const char *c) const |
Private Member Functions | |
| Int_t | Predict (KalmanPlaneSR *prevkp, KalmanPlaneSR *currentkp, Int_t idir) |
| Int_t | Filter (KalmanPlaneSR *currentkp, Int_t idir) |
| Int_t | FitFrom (KalmanPlaneSR *prevkp, KalmanPlaneSR *currentkp, Int_t idir, Int_t iterate) |
| Int_t | CalculatePropagator (KalmanPlaneSR *prevkp, KalmanPlaneSR *currentkp, Int_t idir) |
| void | CalculateNoise (KalmanPlaneSR *prevkp, KalmanPlaneSR *currentkp, Int_t idir, Int_t befaft=0) |
| void | CalculatePreCovariance (KalmanPlaneSR *prevkp, KalmanPlaneSR *currentkp, Int_t idir) |
| Int_t | CalculatePreState (KalmanPlaneSR *prevkp, KalmanPlaneSR *currentkp, Int_t idir) |
| void | CalculatePreChi2 (KalmanPlaneSR *currentkp, Int_t idir, Double_t=0.0119) |
| void | CalculateGain (KalmanPlaneSR *currentkp, Int_t idir, Double_t=0.0119) |
| void | CalculateFilState (KalmanPlaneSR *currentkp, Int_t idir) |
| void | CalculateFilCovariance (KalmanPlaneSR *currentkp, Int_t idir) |
| void | CalculateFilChi2 (KalmanPlaneSR *currentkp, Int_t idir, Double_t=0.0119) |
| Bool_t | Swim (Double_t *swimstate, Double_t *state, Double_t zPos, Double_t finalZ, Int_t idir, const VldContext *) |
| void | InitKalmanFitParameters (AlgConfig &ac) |
| void | InitializeFit (CandFitTrackSRHandle &cfh, Int_t, Int_t) |
| void | MakeSliceClusterList (TObjArray *trackClusterList, const TObjArray *tclist, CandStripHandleItr &stripItr, CandFitTrackSRHandle &cfh) |
| void | MakeTrackClusterList (TObjArray *trackClusterList, CandStripHandleItr &stripItr, CandFitTrackSRHandle &cfh, Int_t direction) |
| void | SetTrackParameters (const CandTrackHandle *track0, CandFitTrackSRHandle &cfh, Int_t direction) |
| Int_t | FindNumSkippedPlanes (Int_t currentPlane, Int_t prevPlane, KalmanPlaneSR *oldkp, Int_t direction) |
| Int_t | FindTimingDirection (TrackClusterSRItr &clusterItr) |
| Bool_t | MarkTrackClusters (const CandTrackHandle *track0, TObjArray &planeClusterList, CandStripHandleItr &stripItr, CandFitTrackSRHandle &cfh, Int_t &begPlane, Int_t &endPlane) |
| void | SetTrackEndParameters (Int_t begPlane, Int_t endPlane, CandFitTrackSRHandle &cfh, const CandTrackHandle *track0) |
| void | ResetTrackClusterList (TObjArray &planeClusterList) |
| void | ResetTrackClusterList (TObjArray &planeClusterList, CandFitTrackSRHandle &cfh) |
| Int_t | DoKalmanFit (TObjArray &planeClusterList, CandFitTrackSRHandle &cfh, Int_t &istatus, Int_t direction, Int_t dosearch) |
| Int_t | ReverseFit (TObjArray &planeClusterList, CandFitTrackSRHandle &cfh, Int_t, Bool_t=kFALSE) |
| Int_t | AddClustersToFit (TObjArray &planeClusterList, CandFitTrackSRHandle &cfh, Int_t iterate, Int_t &nu, Int_t &nv, Int_t direction) |
| Int_t | RemoveBadPointsFromFit (CandFitTrackSRHandle &cfh, TObjArray &planeClusterList, std::map< Int_t, Int_t > &uFitPlanes, std::map< Int_t, Int_t > &vFitPlanes, Int_t &nfitu, Int_t &nfitv, Int_t direction) |
| Int_t | FindDownstreamPlanes (TObjArray &planeClusterList, CandFitTrackSRHandle &cfh, Int_t direction) |
| Int_t | FindUpstreamPlanes (TObjArray &planeClusterList, CandFitTrackSRHandle &cfh, TObjArray *newkplist, Int_t direction) |
| Int_t | FindNumSkippedPlanesInView (std::map< Int_t, Int_t > &fitPlanes, std::map< Int_t, Int_t >::iterator &fitIter, Int_t currentPlane, Int_t prevPlane, Int_t lastPlane, Int_t direction) |
| Int_t | AddForwardBestKPToFit (KalmanPlaneSR *bestkp, CandFitTrackSRHandle &cfh, Int_t &nswimfail) |
| Int_t | AddToFit (CandFitTrackSRHandle &cfh, TrackClusterSR *, Int_t) |
| Int_t | AddToFit (CandFitTrackSRHandle &cfh, KalmanPlaneSR *, Int_t, Bool_t) |
| Int_t | AddReverseBestKPToFit (KalmanPlaneSR *bestkp, KalmanPlaneSR *oldkp, CandFitTrackSRHandle &cfh, TObjArray *newkplist, Int_t &nswimfail, Int_t direction) |
| void | SetPlaneParameters (CandFitTrackSRHandle &cfh, const KalmanPlaneSR *kpu0, const KalmanPlaneSR *kpu1, const KalmanPlaneSR *kpv0, const KalmanPlaneSR *kpv1) |
| void | MakeDaughterStripList (CandFitTrackSRHandle &cfh) |
| void | SwimVertexAndEndPoints (CandFitTrackSRHandle &cfh, KalmanPlaneSR *kp0, KalmanPlaneSR *kp1, const KalmanPlaneSR *kpu0, const KalmanPlaneSR *kpu1, const KalmanPlaneSR *kpv0, const KalmanPlaneSR *kpv1, Double_t *planepe, Int_t plane0, Int_t plane1, Double_t &vtxqp, Int_t direction) |
| Int_t | IterateKalmanFit (TObjArray &planeClusterList, CandFitTrackSRHandle &cfh, Int_t &nu, Int_t &nv, Int_t direction, Int_t dosearch) |
| Int_t | FindTimingDirection (CandFitTrackSRHandle &cfh, Double_t *fitparm, Double_t &timefitchi2) |
Private Attributes | |
| VldContext | fVldContext |
| DetectorType::Detector_t | fDetectorType |
| Int_t | pRev |
| Int_t | pRev2 |
| Int_t | pFor |
| Int_t | fParmMaxIterate |
| Int_t | fParmMaxIterate2 |
| Double_t | fParmQPDiff |
| Double_t | fParmMinPlanePE |
| Int_t | fParmLastPlane |
| Int_t | fParmIsCosmic |
| Double_t | fParmMaxLocalChi2 |
| Double_t | fParmMaxLocalPreChi2 |
| Double_t | fParmMaxAngleCovariance |
| Double_t | fParmMaxImpactParameter |
| Int_t | fParmNSkipActive |
| Int_t | fParmNSkipView |
| Double_t | fParmPassReducedChi2 |
| Double_t | fParmPassPlaneAsymmetry |
| Int_t | fParmPassMinPlaneAsymmetry |
| Double_t | fParmMinClusterCharge |
| Int_t | fParmMaxClusterNStrip |
| Double_t | fParmDeltaChi2 |
| Double_t | fParmDeltaCovariance |
| Double_t | fParmMisalignmentError |
| Double_t | fParmDState [5] |
| Double_t | fParmdedx |
| Double_t | fParmPlnRadLen |
| Int_t | fParmQPRangeCheck |
| Double_t | fParmMaxQP |
| Double_t | fParmMaxQPFrac |
| Int_t | fSwimmer |
| Double_t | fParmMaxAngle |
| Double_t | fParmTPosError2 |
| Double_t | fParmInitialPositionError2 |
| Double_t | fParmInitialSlopeError2 |
| Double_t | fParmInitialQPError2 |
| Double_t | fParmCovarianceScale |
| Double_t | fCov [5][5] |
|
|
Definition at line 71 of file AlgFitTrackSR.cxx. 00072 {
00073 }
|
|
|
Definition at line 76 of file AlgFitTrackSR.cxx. 00077 {
00078 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 2356 of file AlgFitTrackSR.cxx. References AddToFit(), TrackClusterSR::GetMaxStrip(), TrackClusterSR::GetMinStrip(), TrackClusterSR::GetPlane(), TrackClusterSR::GetPlaneView(), TrackClusterSR::IsValid(), MSG, and tc. Referenced by DoKalmanFit(), and IterateKalmanFit(). 02359 {
02360 MSG("FitTrackSR", Msg::kDebug) << "in AddClustersToFit" << endl;
02361
02362 TrackClusterSR *tc = 0;
02363 Int_t istatus = 0;
02364
02365 Bool_t dir = kIterForward;
02366 if(direction!=1) dir=kIterBackward;
02367 TIter planeItr(&planeClusterList,dir);
02368
02369 TObjArray * plnarray;
02370 while( (plnarray = (TObjArray * )planeItr.Next()) ){
02371 TIter clusterItr(plnarray);
02372 while( (tc = (TrackClusterSR *)clusterItr.Next()) && istatus>=0 ){
02373
02374 MSG("FitTrackSR", Msg::kDebug) << "current cluster on plane "
02375 << tc->GetPlane() << " is valid "
02376 << (Int_t)tc->IsValid() << endl;
02377 if(tc->IsValid()){
02378 MSG("FitTrackSR", Msg::kDebug) << "adding cluster on plane "
02379 << tc->GetPlane() << " "
02380 << tc->GetMinStrip() << "-" << tc->GetMaxStrip()
02381 << " to fit" << endl;
02382
02383 istatus = AddToFit(cfh,tc, iterate);
02384
02385 if(istatus>=0){
02386 if(tc->GetPlaneView()==PlaneView::kU) ++nu;
02387 else if(tc->GetPlaneView()==PlaneView::kV) ++nv;
02388 }
02389 }
02390 }
02391 }//end loop over clusters
02392 return istatus;
02393 }
|
|
||||||||||||||||
|
Definition at line 3398 of file AlgFitTrackSR.cxx. References CandFitTrackSRHandle::AddKalmanPlaneAt(), AddToFit(), fParmMaxAngleCovariance, fParmMaxLocalPreChi2, CandFitTrackSRHandle::GetKalmanLast(), TrackClusterSR::GetMaxStrip(), TrackClusterSR::GetMinStrip(), CandFitTrackSRHandle::GetNSwimFail(), TrackClusterSR::GetPlane(), KalmanPlaneSR::GetPreChi2(), KalmanPlaneSR::GetPreCovarianceMatrixValue(), KalmanPlaneSR::GetTrackCluster(), kdUdZ, kdVdZ, MSG, CandFitTrackSRHandle::RemoveKalmanPlane(), and CandFitTrackSRHandle::SetNSwimFail(). Referenced by FindDownstreamPlanes(). 03401 {
03402
03403 MSG("FitTrackSR", Msg::kDebug) << "in AddForwardBestKPToFit" << endl;
03404 Int_t nadd = 0;
03405
03406 MSG("FitTrackSR",Msg::kDebug) << "considering best tc "
03407 << bestkp->GetTrackCluster()->GetPlane()
03408 << " " << bestkp->GetTrackCluster()->GetMinStrip()
03409 << "-" << bestkp->GetTrackCluster()->GetMaxStrip()
03410 << ", chi2 = " << bestkp->GetPreChi2(0) << "/"
03411 << fParmMaxLocalPreChi2 << " "
03412 << bestkp->GetPreCovarianceMatrixValue(0,kdUdZ,kdUdZ)
03413 << "/"
03414 << fParmMaxAngleCovariance << " "
03415 << bestkp->GetPreCovarianceMatrixValue(0,kdVdZ,kdVdZ)
03416 << "/"
03417 << fParmMaxAngleCovariance << endl;
03418
03419 if(bestkp->GetPreChi2(0)<fParmMaxLocalPreChi2
03420 && bestkp->GetPreCovarianceMatrixValue(0,kdUdZ,kdUdZ)<fParmMaxAngleCovariance
03421 && bestkp->GetPreCovarianceMatrixValue(0,kdVdZ,kdVdZ)<fParmMaxAngleCovariance){
03422
03423 KalmanPlaneSR *kpnewer = cfh.AddKalmanPlaneAt(bestkp,cfh.GetKalmanLast()+1);
03424 Int_t istatus2 = AddToFit(cfh,kpnewer,-1,0);
03425 if (istatus2>=0) {
03426 cfh.SetNSwimFail(cfh.GetNSwimFail()+nswimfail);
03427 ++nadd;
03428 }
03429 else {
03430 MSG("FitTrackSR",Msg::kDebug) << "AddToFit failed, do not add to fit"
03431 << endl;
03432
03433 // need to remove from KalmanPlaneList
03434 cfh.RemoveKalmanPlane(-1,0);
03435 if(bestkp){
03436 delete bestkp;
03437 bestkp = 0;
03438 }
03439 }
03440 }
03441 else if(bestkp){
03442 delete bestkp;
03443 bestkp = 0;
03444 }
03445
03446 nswimfail=0;
03447
03448 return nadd;
03449 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 3454 of file AlgFitTrackSR.cxx. References FitFrom(), fParmMaxAngleCovariance, fParmMaxLocalPreChi2, CandFitTrackSRHandle::GetKalmanLast(), CandFitTrackSRHandle::GetKalmanPlane(), TrackClusterSR::GetMaxStrip(), TrackClusterSR::GetMinStrip(), CandFitTrackSRHandle::GetNSwimFail(), TrackClusterSR::GetPlane(), KalmanPlaneSR::GetPreChi2(), KalmanPlaneSR::GetPreCovarianceMatrixValue(), KalmanPlaneSR::GetTrackCluster(), kdUdZ, kdVdZ, MSG, CandFitTrackSRHandle::SetCurrentKalmanPlane(), and CandFitTrackSRHandle::SetNSwimFail(). Referenced by FindUpstreamPlanes(). 03459 {
03460 MSG("FitTrackSR", Msg::kDebug) << "in AddReverseBestKPToFit" << endl;
03461 Int_t nadd = 0;
03462 MSG("FitTrackSR",Msg::kDebug) << "considering best tc "
03463 << bestkp->GetTrackCluster()->GetPlane()
03464 << " " << bestkp->GetTrackCluster()->GetMinStrip()
03465 << "-" << bestkp->GetTrackCluster()->GetMaxStrip()
03466 << ", chi2 = " << bestkp->GetPreChi2(1) << "/"
03467 << fParmMaxLocalPreChi2 << " planediff = "
03468 << bestkp->GetTrackCluster()->GetPlane()-oldkp->GetTrackCluster()->GetPlane()
03469 << " "
03470 << bestkp->GetPreCovarianceMatrixValue(1,kdUdZ,kdUdZ)
03471 << " "
03472 << bestkp->GetPreCovarianceMatrixValue(1,kdVdZ,kdVdZ)
03473 << endl;
03474 if(bestkp->GetPreChi2(1)<fParmMaxLocalPreChi2
03475 && bestkp->GetPreCovarianceMatrixValue(1,kdUdZ,kdUdZ)<fParmMaxAngleCovariance
03476 && bestkp->GetPreCovarianceMatrixValue(1,kdVdZ,kdVdZ)<fParmMaxAngleCovariance){
03477
03478 // check if forward fit is also good
03479 // first find the plane just before bestkp
03480 KalmanPlaneSR *foundkp = 0;
03481 KalmanPlaneSR *befkp = 0;
03482
03483 //look for the kp before the best kp
03484 for(Int_t i=cfh.GetKalmanLast(); i>=0 && !foundkp; --i){
03485 befkp = cfh.GetKalmanPlane(i);
03486 if(befkp->GetTrackCluster()->GetPlane()*direction
03487 <bestkp->GetTrackCluster()->GetPlane()*direction)
03488 foundkp = befkp;
03489
03490 }
03491
03492 Double_t forwardchi2 = 0.;
03493 Int_t befswimfail = 0;
03494 if(foundkp){
03495 befswimfail = FitFrom(foundkp,bestkp,0,-1);
03496 forwardchi2 = bestkp->GetPreChi2(0);
03497 MSG("FitTrackSR",Msg::kDebug) << "checking forward fit, previous "
03498 << "cluster plane = "
03499 << foundkp->GetTrackCluster()->GetPlane()
03500 << " min/max strip = "
03501 << foundkp->GetTrackCluster()->GetMinStrip()
03502 << "/"
03503 << foundkp->GetTrackCluster()->GetMaxStrip()
03504 << " nswimfail = " << befswimfail
03505 << " prechi2 = " << forwardchi2 << endl;
03506
03507 }
03508 if(!befswimfail && forwardchi2<fParmMaxLocalPreChi2){
03509 MSG("FitTrackSR",Msg::kDebug) << "ADDING TO FIT" << endl;
03510 ++nadd;
03511 oldkp = bestkp;
03512 newkplist->AddLast(oldkp);
03513 cfh.SetCurrentKalmanPlane(oldkp);
03514 cfh.SetNSwimFail(cfh.GetNSwimFail()+nswimfail);
03515 }
03516 else delete bestkp;
03517
03518 }
03519 else delete bestkp;
03520
03521 bestkp = 0;
03522 nswimfail = 0;
03523
03524 return nadd;
03525 }
|
|
||||||||||||||||||||
|
Definition at line 636 of file AlgFitTrackSR.cxx. References fCov, FitFrom(), KalmanPlaneSR::GetFilChi2(), KalmanPlaneSR::GetFilCovarianceMatrixValue(), CandFitTrackSRHandle::GetNSwimFail(), TrackClusterSR::GetPlane(), CandFitTrackSRHandle::GetPlaneList(), KalmanPlaneSR::GetPreChi2(), KalmanPlaneSR::GetTrackCluster(), KalmanPlaneSR::GetZDir(), InitializeFit(), MSG, pFor, CandFitTrackSRHandle::SetCurrentKalmanPlane(), CandFitTrackSRHandle::SetEnd(), and CandFitTrackSRHandle::SetNSwimFail(). 00639 {
00640
00641
00642
00643 // < 0 = failure
00644 // 0 = success
00645
00646 // this method assumes that the plane at thiskp is not already in the kalmanplanelist
00647 // note also that this method takes ownership of thiskp
00648 // if docheck is false, user is responsible for insertion into kalmanplanelist
00649 // before call to AddToFit
00650
00651 TObjArray * KalmanPlaneList=cfh.GetPlaneList();
00652
00653 Bool_t found(0);
00654 Int_t ifound=0;
00655 Int_t ibef=-1;
00656 Int_t ilast;
00657
00658 KalmanPlaneSR *kpnew = 0;
00659 KalmanPlaneSR *kp = 0;
00660 KalmanPlaneSR *kpold = 0;
00661
00662 if(docheck){
00663
00664 for(Int_t i=0; i<=KalmanPlaneList->GetLast(); ++i){
00665
00666 // assume only one track cluster per plane in track
00667 kp = dynamic_cast<KalmanPlaneSR*>(KalmanPlaneList->At(i));
00668
00669 if(kp->GetTrackCluster()->GetPlane() == thiskp->GetTrackCluster()->GetPlane()) {
00670 found = 1;
00671 ifound = i;
00672 kpnew = kp;
00673
00674 // kalmanplane already in list, need to delete thiskp
00675 delete thiskp;
00676 }
00677 else if((kp->GetZDir())*(kp->GetTrackCluster()->GetPlane())<(kp->GetZDir())*(thiskp->GetTrackCluster()->GetPlane())){
00678 ibef = i;
00679 }
00680 }//end loop over kalman planes
00681
00682 //didnt find a plane to bound this one, so add it at the last place in the list
00683 if(!found){
00684 kpnew = thiskp;
00685
00686 ilast = KalmanPlaneList->GetLast();
00687
00688 for(int i=ilast; i>ibef; --i){
00689 kp = dynamic_cast<KalmanPlaneSR*>(KalmanPlaneList->At(i));
00690 KalmanPlaneList->AddAtAndExpand(kp,i+1);
00691 }
00692
00693 KalmanPlaneList->AddAtAndExpand(kpnew,ibef+1);
00694 }//end didnt find a plane
00695 }//end if docheck
00696 else kpnew = thiskp;
00697
00698 cfh.SetCurrentKalmanPlane(kpnew);
00699
00700 //if this is the first kp added to the track, initialize the fit
00701 if(KalmanPlaneList->GetLast()==0
00702 || (docheck && ((found && ifound==0) || ibef<0))) InitializeFit(cfh,0,iterate);
00703 else{
00704
00705 //get the plane of the kp immediately before the one to add to the
00706 //fit
00707 kpold = dynamic_cast<KalmanPlaneSR*>
00708 (KalmanPlaneList->At(KalmanPlaneList->IndexOf(kpnew)-1));
00709
00710 //fit from the previously fit plane to the one to add to the fit
00711 pFor++;
00712 Int_t nswimfail = FitFrom(kpold,kpnew,0,iterate);
00713 if(nswimfail<0){
00714 return nswimfail;
00715 }
00716
00717 cfh.SetNSwimFail(cfh.GetNSwimFail()+nswimfail);
00718 for(int i1=0; i1<5; ++i1){
00719 for(int i2=0; i2<5; ++i2){
00720 fCov[i1][i2] = kpnew->GetFilCovarianceMatrixValue(0,i1,i2);
00721 }
00722 }//end loop to fill fCov covariance matrix
00723 MSG("FitTrackSR",Msg::kDebug) << "fitting forward, prechi2 = "
00724 << kpnew->GetPreChi2(0) << " filchi2 = "
00725 << kpnew->GetFilChi2(0) << endl;
00726
00727
00728 cfh.SetEnd(kpnew);
00729 }//end else
00730
00731 return 0;
00732 }
|
|
||||||||||||||||
|
Definition at line 617 of file AlgFitTrackSR.cxx. References TrackClusterSR::GetPlane(), CandTrackHandle::GetRange(), CandRecoHandle::GetTimeSlope(), KalmanPlaneSR::GetTrackCluster(), KalmanPlaneSR::SetRange(), KalmanPlaneSR::SetZDir(), and tc. Referenced by AddClustersToFit(), and AddForwardBestKPToFit(). 00620 {
00621
00622
00623 // < 0 = failure
00624 // 0 = success
00625
00626 KalmanPlaneSR *kpnew = new KalmanPlaneSR(tc);
00627 kpnew->SetRange(cfh.GetRange(kpnew->GetTrackCluster()->GetPlane()));
00628
00629 if(cfh.GetTimeSlope()>0. || !fParmIsCosmic) kpnew->SetZDir(1);
00630 else kpnew->SetZDir(-1);
00631
00632 return AddToFit(cfh, kpnew, iterate,1);
00633 }
|
|
||||||||||||||||
|
Definition at line 1506 of file AlgFitTrackSR.cxx. References KalmanPlaneSR::GetFilCovarianceMatrixValue(), KalmanPlaneSR::GetFilStateValue(), TrackClusterSR::GetPlaneView(), TrackClusterSR::GetTPos(), KalmanPlaneSR::GetTrackCluster(), MSG, and KalmanPlaneSR::SetFilChi2(). Referenced by Filter(). 01508 {
01509
01510 Int_t index = 0;
01511
01512 //default U view, change if V view
01513 if(currentkp->GetTrackCluster()->GetPlaneView()==PlaneView::kV) index = 1;
01514
01515 Double_t dtpos = 0.;
01516
01517 dtpos = currentkp->GetFilStateValue(index,idir)-currentkp->GetTrackCluster()->GetTPos();
01518
01519 Double_t filChi2 = dtpos*dtpos/(poserr*poserr
01520 + currentkp->GetFilCovarianceMatrixValue(idir,index,index));
01521
01522 currentkp->SetFilChi2(filChi2, idir);
01523 MSG("FitTrackSR",Msg::kDebug) << "filchi2 = " << filChi2 << " dtpos = "
01524 << dtpos << " tposerr2 = " << poserr*poserr
01525 << " cov = "
01526 << currentkp->GetFilCovarianceMatrixValue(idir,index,index)
01527 << endl;
01528
01529 }
|
|
||||||||||||
|
Definition at line 1532 of file AlgFitTrackSR.cxx. References KalmanPlaneSR::GetGainValue(), TrackClusterSR::GetPlaneView(), KalmanPlaneSR::GetPreCovarianceMatrixValue(), KalmanPlaneSR::GetTrackCluster(), kdUdZ, kdVdZ, kQoverP, kU, kV, and KalmanPlaneSR::SetFilCovarianceMatrixValue(). Referenced by Filter(). 01534 {
01535 //do the final step of the Kalman filter
01536 //C_{k} = (I - K_{k}H_{k})C_{k}^{k-1}
01537
01538 Int_t index = 0;
01539
01540 //default U view, change if V view
01541 if(currentkp->GetTrackCluster()->GetPlaneView()==PlaneView::kV) index = 1;
01542
01543 TMatrixD preCov(5,5);
01544 for(Int_t i = 0; i<5; ++i){
01545 for(Int_t j = 0; j<5; ++j){
01546 preCov(i,j) = currentkp->GetPreCovarianceMatrixValue(idir,i,j);
01547 }
01548 }
01549
01550 TMatrixD filCovariance(5,5);
01551
01552 //set the filtered covariance matrix to the identity matrix
01553 filCovariance.UnitMatrix();
01554
01555 //subtract K_{k}H_{k} from the identity
01556 filCovariance(kU,index) -= currentkp->GetGainValue(kU,idir);
01557 filCovariance(kV,index) -= currentkp->GetGainValue(kV,idir);
01558 filCovariance(kdUdZ,index) -= currentkp->GetGainValue(kdUdZ,idir);
01559 filCovariance(kdVdZ,index) -= currentkp->GetGainValue(kdVdZ,idir);
01560 filCovariance(kQoverP,index) -= currentkp->GetGainValue(kQoverP,idir);
01561
01562 //multiply the difference by the pre filtered covariance matrix
01563 filCovariance *= preCov;
01564
01565 // diagonal elements should be positive
01566 Double_t covlim = 5.e-5;
01567
01568 if(filCovariance(kU,kU)<covlim) filCovariance(kU,kU) = covlim;
01569 if(filCovariance(kV,kV)<covlim) filCovariance(kV,kV) = covlim;
01570 if(filCovariance(kdUdZ,kdUdZ)<covlim)
01571 filCovariance(kdUdZ,kdUdZ) = covlim;
01572 if(filCovariance(kdVdZ,kdVdZ)<covlim)
01573 filCovariance(kdVdZ,kdVdZ) = covlim;
01574 if(filCovariance(kQoverP,kQoverP)<1.e-8) filCovariance(kQoverP,kQoverP) = 1.e-8;
01575
01576 for(Int_t i = 0; i<5; ++i){
01577 for(Int_t j = 0; j<5; ++j){
01578 currentkp->SetFilCovarianceMatrixValue(idir,i,j, filCovariance(i,j));
01579 }
01580 }
01581 }
|
|
||||||||||||
|
Definition at line 1441 of file AlgFitTrackSR.cxx. References fParmMaxAngle, fParmMaxQPFrac, KalmanPlaneSR::GetFilStateValue(), KalmanPlaneSR::GetGainValue(), TrackClusterSR::GetPlaneView(), KalmanPlaneSR::GetPreStateValue(), KalmanPlaneSR::GetRange(), TrackClusterSR::GetTPos(), KalmanPlaneSR::GetTrackCluster(), kdUdZ, kdVdZ, kQoverP, kU, kV, and KalmanPlaneSR::SetFilStateValue(). Referenced by Filter(). 01443 {
01444
01445
01446 Int_t index = 0;
01447
01448 //default U view, change if V view
01449 if(currentkp->GetTrackCluster()->GetPlaneView()==PlaneView::kV) index = 1;
01450
01451 //the following is the m_{k} - H_{k}F_{k-1}x_{k-1}
01452 //bit of the Kalman filter equations
01453 //remember that
01454 //m_{k} = measurement,
01455 //H_{k} = [1,0,0,0,0] for U view; [0,1,0,0,0] for V view
01456 //the definition of H_{k} makes the H_{k}F_{k-1}x_{k-1} product
01457 //a scalar and picks out only certain elements of F_{k-1}x_{k-1}
01458 //also, F_{k-1}x_{k-1} is found by the swimmer and put in the
01459 //pre filtered state vector of the plane to add to the fit
01460
01461 Double_t xfac = (currentkp->GetTrackCluster()->GetTPos()
01462 - currentkp->GetPreStateValue(index,idir));
01463
01464 currentkp->SetFilStateValue(kU,idir, currentkp->GetPreStateValue(kU,idir)
01465 +currentkp->GetGainValue(kU,idir)*xfac);
01466 currentkp->SetFilStateValue(kV,idir, currentkp->GetPreStateValue(kV,idir)
01467 +currentkp->GetGainValue(kV,idir)*xfac);
01468 currentkp->SetFilStateValue(kdUdZ,idir, currentkp->GetPreStateValue(kdUdZ,idir)
01469 +currentkp->GetGainValue(kdUdZ,idir)*xfac);
01470 currentkp->SetFilStateValue(kdVdZ,idir, currentkp->GetPreStateValue(kdVdZ,idir)
01471 +currentkp->GetGainValue(kdVdZ,idir)*xfac);
01472 currentkp->SetFilStateValue(kQoverP,idir, currentkp->GetPreStateValue(kQoverP,idir)
01473 +currentkp->GetGainValue(kQoverP,idir)*xfac);
01474
01475 if(TMath::Abs(currentkp->GetFilStateValue(kdUdZ,idir))>fParmMaxAngle){
01476 currentkp->SetFilStateValue(kdUdZ,idir,(currentkp->GetFilStateValue(kdUdZ,idir)>0
01477 ? fParmMaxAngle : -fParmMaxAngle));
01478 }
01479
01480 if(TMath::Abs(currentkp->GetFilStateValue(kdVdZ,idir))>fParmMaxAngle){
01481 currentkp->SetFilStateValue(kdVdZ,idir,(currentkp->GetFilStateValue(kdVdZ,idir)>0
01482 ? fParmMaxAngle : -fParmMaxAngle));
01483 }
01484
01485 Double_t maxqp = fParmMaxQP;
01486
01487 //use a value of about 2 MeV/(g/cm^2) for the energy loss in the material
01488 //you would divide the max qp frac allowed by that value and then by the range to
01489 //get the max qp. but multiplication is a faster operation, so multiply by
01490 //500 instead.
01491 if ( fParmQPRangeCheck ) {
01492 if(currentkp->GetRange()>0. && fParmMaxQPFrac*500./currentkp->GetRange()<maxqp) {
01493 maxqp = fParmMaxQPFrac*500./currentkp->GetRange();
01494 }
01495 }
01496
01497 if(TMath::Abs(currentkp->GetFilStateValue(kQoverP,idir))>maxqp){
01498 currentkp->SetFilStateValue(kQoverP,idir,(currentkp->GetFilStateValue(kQoverP,idir)>0
01499 ? maxqp : -maxqp));
01500 }
01501
01502
01503 }
|
|
||||||||||||||||
|
Definition at line 1397 of file AlgFitTrackSR.cxx. References TrackClusterSR::GetPlaneView(), KalmanPlaneSR::GetPreCovarianceMatrixValue(), KalmanPlaneSR::GetTrackCluster(), kdUdZ, kdVdZ, kQoverP, kU, kV, and KalmanPlaneSR::SetGainValue(). Referenced by Filter(). 01399 {
01400
01401 //the following is the
01402 //K_{k} = C_{k}^{k-1}H_{k}^{T}(V_{k}+H_{k}C_{k}^{k-1}H_{k}^{T})^{-1}
01403 //step of the filtering equations
01404 //remember that
01405 //V_{k} = measurement error,
01406 //H_{k} = [1,0,0,0,0] for U view; [0,1,0,0,0] for V view
01407 //the definition of H_{k} makes the H_{k}C_{k}^{k-1}H_{k}^{T} product
01408 //a scalar and picks out only certain elements of C_{k}^{k-1}
01409
01410
01411 Int_t index = 0;
01412
01413 //default U view, change if V view
01414 if(currentkp->GetTrackCluster()->GetPlaneView()==PlaneView::kV) index = 1;
01415
01416
01417 currentkp->SetGainValue(kU,idir,
01418 (currentkp->GetPreCovarianceMatrixValue(idir,kU,index)/
01419 (currentkp->GetPreCovarianceMatrixValue(idir,index,index)
01420 +poserr*poserr)));
01421 currentkp->SetGainValue(kV,idir,
01422 (currentkp->GetPreCovarianceMatrixValue(idir,kV,index)/
01423 (currentkp->GetPreCovarianceMatrixValue(idir,index,index)
01424 +poserr*poserr)));
01425 currentkp->SetGainValue(kdUdZ,idir,
01426 (currentkp->GetPreCovarianceMatrixValue(idir,kdUdZ,index)/
01427 (currentkp->GetPreCovarianceMatrixValue(idir,index,index)
01428 +poserr*poserr)));
01429 currentkp->SetGainValue(kdVdZ,idir,
01430 (currentkp->GetPreCovarianceMatrixValue(idir,kdVdZ,index)/
01431 (currentkp->GetPreCovarianceMatrixValue(idir,index,index)
01432 +poserr*poserr)));
01433 currentkp->SetGainValue(kQoverP,idir,
01434 (currentkp->GetPreCovarianceMatrixValue(idir,kQoverP,index)/
01435 (currentkp->GetPreCovarianceMatrixValue(idir,index,index)
01436 +poserr*poserr)));
01437
01438 }
|
|
||||||||||||||||||||
|
Definition at line 1068 of file AlgFitTrackSR.cxx. References fParmdedx, fParmPlnRadLen, BField::GetBField(), KalmanPlaneSR::GetFilStateValue(), UgliGeomHandle::GetNearestSteelPlnHandle(), TrackClusterSR::GetPlane(), SwimGeo::GetSteel(), KalmanPlaneSR::GetTrackCluster(), KalmanPlaneSR::GetVldContext(), SwimPlaneInterface::GetZ(), UgliSteelPlnHandle::GetZ0(), TrackClusterSR::GetZPos(), SwimGeo::Instance(), kdUdZ, kdVdZ, kInvSqrt2, kQoverP, kU, kV, MSG, and KalmanPlaneSR::SetNoiseMatrixValue(). Referenced by Predict(). 01071 {
01072
01073
01074 MSG("FitTrackSR", Msg::kDebug) << "In CalculateNoise" << endl;
01075
01076 //find noise from the previous kp to the kp to add to the fit
01077 KalmanPlaneSR *thiskp = prevkp;
01078 KalmanPlaneSR *newkp = currentkp;
01079 Int_t thisdir = idir;
01080
01081 if(befaft){
01082 thiskp = currentkp;
01083 newkp = prevkp;
01084 thisdir = 1-thisdir;
01085 }
01086
01087 Int_t dplane = (currentkp->GetTrackCluster()->GetPlane()
01088 - prevkp->GetTrackCluster()->GetPlane());
01089 Int_t izdir = (dplane>0 ? 0 : 1);
01090
01091 // izdir gives the direction of the swim (0 = forward, 1 = backward)
01092 // relative to z
01093 // this is different from thisdir/idir which gives direction of swim
01094 // relative to time
01095 // idir=0 means forward in time, idir=1 means backward in time
01096 // a particle could be going forward in z and forward in time or
01097 // any of the 4 combinations (for cosmics and atmospherics)
01098 Double_t dudz = thiskp->GetFilStateValue(kdUdZ,idir);
01099 Double_t dvdz = thiskp->GetFilStateValue(kdVdZ,idir);
01100 Double_t dsdz = sqrt(1.+dudz*dudz+dvdz*dvdz);
01101 Double_t qp = thiskp->GetFilStateValue(kQoverP,idir);
01102
01103 // when qp is too small, errors go to zero, so place lower bound
01104 // 0.01 (= 100 GeV/c) is reasonable
01105 if(TMath::Abs(qp)<0.01) qp = (qp>0 ? 0.01 : -0.01);
01106
01107 Double_t locradlen = TMath::Abs(dsdz*(Double_t)(dplane)*fParmPlnRadLen);
01108
01109 // we should really use an average of 1/p in calculating sigmams2
01110 Double_t sigmams2 = (0.0136*TMath::Abs(qp)*TMath::Sqrt(locradlen)
01111 *(1.+0.038*TMath::Log(locradlen)));
01112 sigmams2 *= sigmams2;
01113
01114 Double_t p3p3 = 0.5*sigmams2*(1.+dudz*dudz)*dsdz*dsdz;
01115 Double_t p3p4 = 0.5*sigmams2*dudz*dvdz*dsdz*dsdz;
01116 Double_t p4p4 = 0.5*sigmams2*(1.+dvdz*dvdz)*dsdz*dsdz;
01117
01118 // SwimPlaneInterfaceListSR *spil =
01119 // SwimPlaneInterfaceListSR::Instance(const_cast<VldContext*>(GetVldContext()));
01120
01121 SwimGeo *spil = SwimGeo::Instance(*(const_cast<VldContext*>(currentkp->GetVldContext())));
01122
01123 Double_t z1 = spil->GetSteel(prevkp->GetTrackCluster()->GetZPos(),izdir)->GetZ();
01124 Double_t z2 = spil->GetSteel(z1,izdir)->GetZ();
01125
01126 // treat iron as discrete scatter; in future can make this more rigorous
01127 Double_t dzscatter = TMath::Abs(currentkp->GetTrackCluster()->GetZPos()-0.5*(z1+z2));
01128 Double_t dzscatter2 = dzscatter*dzscatter;
01129 Double_t eloss = fParmdedx*TMath::Abs((Double_t)(dplane));
01130
01131 VldContext vldc = *(prevkp->GetVldContext());
01132 UgliGeomHandle ugh(vldc);
01133 BField bf(vldc);
01134 TVector3 uvz;
01135 uvz(0) = thiskp->GetFilStateValue(kU,idir);
01136 uvz(1) = thiskp->GetFilStateValue(kV,idir);
01137 // rwh: KalmanPlane's TrackCluster z is not necessarily inside the steel
01138 //uvz(2) = thiskp->GetTrackCluster()->GetZPos();
01139 // translate an semi-arbitrary z to z0 of the nearest steel plane
01140 uvz(2) = ugh.GetNearestSteelPlnHandle(thiskp->GetTrackCluster()->GetZPos()).GetZ0();
01141 TVector3 xyz(kInvSqrt2*(uvz[0]-uvz[1]),kInvSqrt2*(uvz[0]+uvz[1]),uvz[2]);
01142 TVector3 bxyz = bf.GetBField(xyz);
01143
01144 // rotate bxyz into buvz
01145 // bxyz in Tesla, convert into GeV/c/m
01146 // warning: numbers are hard coded here
01147 TVector3 buvz(kInvSqrt2*(bxyz[1]+bxyz[0]),kInvSqrt2*(bxyz[1]-bxyz[0]),bxyz[2]);
01148
01149 buvz[0] *= 0.3;
01150 buvz[1] *= 0.3;
01151 buvz[2] *= 0.3;
01152
01153
01154 // we assume the uncertainty in energy loss to follow a Landau distribution,
01155 // and use the FWHM from Ahlen (RMP, Vol. 52, p. 143, 1980)
01156 Double_t sigmaeloss2 = 0.25*eloss*dsdz*qp*qp;
01157 sigmaeloss2 *= sigmaeloss2;
01158
01159 currentkp->SetNoiseMatrixValue(idir,kU,kU,dzscatter2*p3p3);
01160 currentkp->SetNoiseMatrixValue(idir,kU,kV,dzscatter2*p3p4);
01161 currentkp->SetNoiseMatrixValue(idir,kU,kdUdZ,dzscatter*p3p3);
01162 currentkp->SetNoiseMatrixValue(idir,kU,kdVdZ,dzscatter*p3p4);
01163 currentkp->SetNoiseMatrixValue(idir,kU,kQoverP,
01164 (dzscatter*sigmaeloss2*TMath::Abs((Double_t)(dplane))
01165 *buvz(1)*0.0254*Munits::m*dsdz*(1.+dudz*dudz)));
01166 currentkp->SetNoiseMatrixValue(idir,kV,kU,dzscatter2*p3p4);
01167 currentkp->SetNoiseMatrixValue(idir,kV,kV,dzscatter2*p4p4);
01168 currentkp->SetNoiseMatrixValue(idir,kV,kdUdZ,dzscatter*p3p4);
01169 currentkp->SetNoiseMatrixValue(idir,kV,kdVdZ,dzscatter*p4p4);
01170 currentkp->SetNoiseMatrixValue(idir,kV,4,
01171 (dzscatter*sigmaeloss2*TMath::Abs((Double_t)(dplane))
01172 *buvz(0)*0.0254*Munits::m*dsdz*(1.+dvdz*dvdz)));
01173 currentkp->SetNoiseMatrixValue(idir,kdUdZ,kU,dzscatter*p3p3);
01174 currentkp->SetNoiseMatrixValue(idir,kdUdZ,kV,dzscatter*p3p4);
01175 currentkp->SetNoiseMatrixValue(idir,kdUdZ,kdUdZ,p3p3);
01176 currentkp->SetNoiseMatrixValue(idir,kdUdZ,kdVdZ,p3p4);
01177 currentkp->SetNoiseMatrixValue(idir,kdUdZ,kQoverP,
01178 (sigmaeloss2*TMath::Abs((Double_t)(dplane))*buvz(1)
01179 *0.0254*Munits::m*dsdz*(1.+dudz*dudz)));
01180 currentkp->SetNoiseMatrixValue(idir,kdVdZ,kU,dzscatter*p3p4);
01181 currentkp->SetNoiseMatrixValue(idir,kdVdZ,kV,dzscatter*p4p4);
01182 currentkp->SetNoiseMatrixValue(idir,kdVdZ,kdUdZ,p3p4);
01183 currentkp->SetNoiseMatrixValue(idir,kdVdZ,kdVdZ,p4p4);
01184 currentkp->SetNoiseMatrixValue(idir,kdVdZ,kQoverP,
01185 (sigmaeloss2*TMath::Abs((Double_t)(dplane))*buvz(0)
01186 *0.0254*Munits::m*dsdz*(1.+dvdz*dvdz)));
01187 currentkp->SetNoiseMatrixValue(idir,kQoverP,kU,
01188 (dzscatter*sigmaeloss2*TMath::Abs((Double_t)(dplane))
01189 *buvz(1)*0.0254*Munits::m*dsdz*(1.+dudz*dudz)));
01190 currentkp->SetNoiseMatrixValue(idir,kQoverP,kV,
01191 (dzscatter*sigmaeloss2*TMath::Abs((Double_t)(dplane))
01192 *buvz(0)*0.0254*Munits::m*dsdz*(1.+dvdz*dvdz)));
01193 currentkp->SetNoiseMatrixValue(idir,kQoverP,kdUdZ,
01194 (sigmaeloss2*TMath::Abs((Double_t)(dplane))*buvz(1)
01195 *0.0254*Munits::m*dsdz*(1.+dudz*dudz)));
01196 currentkp->SetNoiseMatrixValue(idir,kQoverP,kdVdZ,
01197 (sigmaeloss2*TMath::Abs((Double_t)(dplane))*buvz(0)
01198 *0.0254*Munits::m*dsdz*(1.+dvdz*dvdz)));
01199 currentkp->SetNoiseMatrixValue(idir,kQoverP,kQoverP,sigmaeloss2);
01200
01201 MSG("FitTrackSR",Msg::kDebug) << "du/dz, dv/dz, ds/dz, qp = " << dudz << " "
01202 << dvdz << " " << dsdz << " " << qp << endl
01203 << "dplane, dzscatter, z1, z2, radlen = " << dplane
01204 << " " << dzscatter << " " << z1 << " " << z2 << " "
01205 << locradlen << endl
01206 << "sigmams2 = " << sigmams2 << endl
01207 << "p3p3, p3p4, p4p4 = " << p3p3 << " " << p3p4 << " "
01208 << p4p4 << endl;
01209
01210 }
|
|
||||||||||||||||
|
Definition at line 1371 of file AlgFitTrackSR.cxx. References TrackClusterSR::GetPlaneView(), KalmanPlaneSR::GetPreCovarianceMatrixValue(), KalmanPlaneSR::GetPreStateValue(), TrackClusterSR::GetTPos(), KalmanPlaneSR::GetTrackCluster(), MSG, and KalmanPlaneSR::SetPreChi2(). Referenced by Predict(). 01373 {
01374
01375 Int_t index = 0;
01376
01377 //default view is U, change if this is a V view plane
01378 if(currentkp->GetTrackCluster()->GetPlaneView()==PlaneView::kV) index = 1;
01379
01380 Double_t dtpos = 0.;
01381
01382 dtpos = currentkp->GetPreStateValue(index,idir)-currentkp->GetTrackCluster()->GetTPos();
01383
01384 Double_t preChi2 = dtpos*dtpos/(currentkp->GetPreCovarianceMatrixValue(idir,index,index)
01385 +poserr*poserr);
01386
01387 currentkp->SetPreChi2(preChi2, idir);
01388 MSG("FitTrackSR",Msg::kDebug) << "prechi2 = " << preChi2 << " dtpos = "
01389 << dtpos << " tposerr2 = " << poserr*poserr
01390 << " cov = "
01391 << currentkp->GetPreCovarianceMatrixValue(idir,index,index)
01392 << endl;
01393
01394 }
|
|
||||||||||||||||
|
Definition at line 1213 of file AlgFitTrackSR.cxx. References KalmanPlaneSR::GetFilCovarianceMatrixValue(), KalmanPlaneSR::GetNoiseMatrixValue(), KalmanPlaneSR::GetPreCovarianceMatrixValue(), KalmanPlaneSR::GetPropagatorMatrixValue(), kdUdZ, kdVdZ, kQoverP, kU, kV, MSG, and KalmanPlaneSR::SetPreCovarianceMatrixValue(). Referenced by Predict(). 01216 {
01217 MSG("FitTrackSR", Msg::kDebug) << "In CalculatePreCovariance" << endl;
01218 //get the propagator and filtered covariance matricies from the
01219 //previously fit kp
01220 TMatrixD propagator(5,5);
01221 TMatrixD filCovariance(5,5);
01222
01223 for(Int_t i = 0; i<5; ++i){
01224 for(Int_t j = 0; j<5; ++j){
01225 propagator(i,j) = prevkp->GetPropagatorMatrixValue(idir,i,j);
01226 filCovariance(i,j) = prevkp->GetFilCovarianceMatrixValue(idir,i,j);
01227
01228 //start the calculation of the pre-filtered covariance matrix
01229 //for the kp to add to the fit. set it = noise matrix of previously
01230 //fit plane
01231 currentkp->SetPreCovarianceMatrixValue(idir,i,j,prevkp->GetNoiseMatrixValue(idir,i,j));
01232 }
01233 }
01234
01235 //remember that propagator is really the transpose of the propagator matrix
01236 //so in the following cov0 = F_{k-1}C_{k-1}
01237 TMatrixD cov0(propagator,TMatrixD::kTransposeMult,filCovariance);
01238
01239 //the following makes cov0 = F_{k-1}C_{k-1}F^{T}_{k-1}
01240 cov0 *= propagator;
01241
01242 //finish finding the pre-filtered covariance matrix -
01243 //C_{k}^{k-1} = F_{k-1}C_{k-1}F^{T}_{k-1}+Q_{k-1}
01244 Double_t preCovValue = 0.;
01245 for(Int_t i = 0; i<5; ++i){
01246 for(Int_t j = 0; j<5; ++j){
01247 preCovValue = currentkp->GetPreCovarianceMatrixValue(idir,i,j)+cov0(i,j);
01248 currentkp->SetPreCovarianceMatrixValue(idir,i,j,preCovValue);
01249 }
01250 }
01251
01252 // diagonal elements should be positive
01253 Double_t covlim = 5.e-5;
01254
01255 if(currentkp->GetPreCovarianceMatrixValue(idir,kU,kU)<covlim)
01256 currentkp->SetPreCovarianceMatrixValue(idir,kU,kU,covlim);
01257 if(currentkp->GetPreCovarianceMatrixValue(idir,kV,kV)<covlim)
01258 currentkp->SetPreCovarianceMatrixValue(idir,kV,kV,covlim);
01259 if(currentkp->GetPreCovarianceMatrixValue(idir,kdUdZ,kdUdZ)<covlim)
01260 currentkp->SetPreCovarianceMatrixValue(idir,kdUdZ,kdUdZ,covlim);
01261 if(currentkp->GetPreCovarianceMatrixValue(idir,kdVdZ,kdVdZ)<covlim)
01262 currentkp->SetPreCovarianceMatrixValue(idir,kdVdZ,kdVdZ,covlim);
01263 if(currentkp->GetPreCovarianceMatrixValue(idir,kQoverP,kQoverP)<1.e-8)
01264 currentkp->SetPreCovarianceMatrixValue(idir,kQoverP,kQoverP,1.e-8);
01265
01266 }
|
|
||||||||||||||||
|
Definition at line 1269 of file AlgFitTrackSR.cxx. References fParmMaxAngle, fParmMaxQPFrac, fSwimmer, KalmanPlaneSR::GetFilStateValue(), KalmanPlaneSR::GetPreStateValue(), KalmanPlaneSR::GetRange(), KalmanPlaneSR::GetTrackCluster(), KalmanPlaneSR::GetVldContext(), TrackClusterSR::GetZPos(), kdUdZ, kdVdZ, kQoverP, kU, kV, MSG, KalmanPlaneSR::SetPreStateValue(), and Swim(). Referenced by Predict(). 01272 {
01273
01274 //Swim from the previously fit plane to the plane to add to the fit
01275 //to get the estimate of the state vector at the new plane - this
01276 //takes care of the F_{k-1}x_{k-1} matrix multiplication in the
01277 //Kalman filter equations
01278 Int_t nswimfail=0;
01279
01280 if(fSwimmer!=2) MSG("FitTrackSR",Msg::kError) << "fSwimmer!=2 currently unsupported"
01281 << endl;
01282 MSG("FitTrackSR", Msg::kDebug) << "current Filtered State = ["
01283 << prevkp->GetFilStateValue(kU,idir) << ","
01284 << prevkp->GetFilStateValue(kV,idir) << ","
01285 << prevkp->GetFilStateValue(kdUdZ,idir) << ","
01286 << prevkp->GetFilStateValue(kdVdZ,idir) << ","
01287 << prevkp->GetFilStateValue(kQoverP,idir) << "]"
01288 << endl;
01289
01290 if(fSwimmer==2){
01291
01292 // Using Swimmer package
01293 Double_t swimstate[5];
01294 Double_t state[] = {0.,0.,0.,0.,0.};
01295
01296 swimstate[kU] = prevkp->GetFilStateValue(kU,idir);
01297 swimstate[kV] = prevkp->GetFilStateValue(kV,idir);
01298 swimstate[kdUdZ] = prevkp->GetFilStateValue(kdUdZ,idir);
01299 swimstate[kdVdZ] = prevkp->GetFilStateValue(kdVdZ,idir);
01300 swimstate[kQoverP] = prevkp->GetFilStateValue(kQoverP,idir);
01301
01302 Bool_t swimstatus = false;
01303 Int_t nswim=0;
01304
01305 while(!swimstatus && nswim<100){
01306
01307 swimstatus = Swim(swimstate, state, prevkp->GetTrackCluster()->GetZPos(),
01308 currentkp->GetTrackCluster()->GetZPos(),idir,
01309 currentkp->GetVldContext());
01310
01311 // if outside fiducial detector, return failure flag
01312 if(TMath::Abs(state[kU])>5. || TMath::Abs(state[kV])>5.){
01313 MSG("FitTrackSR",Msg::kDebug) << "outside detector, u,v = " << state[kU] << " "
01314 << state[kV] << " fail" << endl;
01315
01316 return -1;
01317 }
01318
01319 if(!swimstatus){
01320
01321 // swim failed, double momentum
01322 swimstate[kQoverP] *= 0.5;
01323 MSG("FitTrackSR",Msg::kDebug) << "swim failed, doubling momentum to q/p = "
01324 << swimstate[kQoverP] << endl;
01325
01326 ++nswimfail;
01327 }
01328 ++nswim;
01329 }//end loop to swim.
01330
01331 currentkp->SetPreStateValue(kU,idir,state[kU]);
01332 currentkp->SetPreStateValue(kV,idir,state[kV]);
01333 currentkp->SetPreStateValue(kdUdZ,idir,state[kdUdZ]);
01334 currentkp->SetPreStateValue(kdVdZ,idir,state[kdVdZ]);
01335 currentkp->SetPreStateValue(kQoverP,idir,state[kQoverP]);
01336 }//end if using Swim package
01337
01338 if(TMath::Abs(currentkp->GetPreStateValue(kdUdZ,idir))>fParmMaxAngle){
01339 currentkp->SetPreStateValue(kdUdZ,idir,
01340 (currentkp->GetPreStateValue(kdUdZ,idir)>0
01341 ? fParmMaxAngle : -fParmMaxAngle));
01342 }
01343
01344 if(TMath::Abs(currentkp->GetPreStateValue(kdVdZ,idir))>fParmMaxAngle){
01345 currentkp->SetPreStateValue(kdVdZ,idir,
01346 (currentkp->GetPreStateValue(kdVdZ,idir)>0
01347 ? fParmMaxAngle : -fParmMaxAngle));
01348 }
01349
01350 Double_t maxqp = fParmMaxQP;
01351
01352 //use a value of about 2 MeV/(g/cm^2) for the energy loss in the material
01353 //you would divide the max qp frac allowed by that value and then by the range to
01354 //get the max qp. but multiplication is a faster operation, so multiply by
01355 //500 instead.
01356 if ( fParmQPRangeCheck ) {
01357 if(currentkp->GetRange()>0. && fParmMaxQPFrac*500./currentkp->GetRange()<maxqp) {
01358 maxqp = fParmMaxQPFrac*500./currentkp->GetRange();
01359 }
01360 }
01361
01362 if(TMath::Abs(currentkp->GetPreStateValue(kQoverP,idir))>maxqp){
01363 currentkp->SetPreStateValue(kQoverP,idir,
01364 (currentkp->GetPreStateValue(kQoverP,idir)>0 ? maxqp : -maxqp));
01365 }
01366
01367 return nswimfail;
01368 }
|
|
||||||||||||||||
|
Definition at line 942 of file AlgFitTrackSR.cxx. References fParmDState, fSwimmer, KalmanPlaneSR::GetFilStateValue(), KalmanPlaneSR::GetTrackCluster(), KalmanPlaneSR::GetVldContext(), TrackClusterSR::GetZPos(), kQoverP, kU, kV, MSG, KalmanPlaneSR::SetPropagatorMatrixValue(), and Swim(). Referenced by Predict(). 00945 {
00946 // we are actually calculating the tranpose
00947 MSG("FitTrackSR", Msg::kDebug) << "In CalculatePropagator" << endl;
00948 Int_t nswimfail=0;
00949 Double_t dstate[5];
00950 Double_t thisFilState[5];
00951
00952 for(Int_t i=0; i<5; ++i){
00953
00954 //set the filtered state based on the previously fit plane
00955 thisFilState[i] = prevkp->GetFilStateValue(i,idir);
00956 dstate[i] = fParmDState[i];
00957
00958 if(i==4){
00959 dstate[i] = (fParmDState[i]*thisFilState[kQoverP]*thisFilState[kQoverP]
00960 /(1.-fParmDState[i]*TMath::Abs(thisFilState[kQoverP])));
00961 dstate[i] = fParmDState[i]*TMath::Abs(thisFilState[kQoverP]);
00962 if(dstate[i]<.01) dstate[i] = .01;
00963 // corresponds to constant fParmDState[kQoverP] energy interval
00964 }
00965 // MSG("FitTrackSR", Msg::kDebug) << "thisFilState[" << i << "] = "
00966 // << thisFilState[i] << " dstate[" << i
00967 // << "] = " << dstate[i] << endl;
00968 }
00969
00970 Bool_t swimstatus = false;
00971 Int_t nswim=0;
00972 Double_t swimstate[5];
00973 Double_t pstate[] = {0.,0.,0.,0.,0.};
00974 Double_t nstate[] = {0.,0.,0.,0.,0.};
00975
00976 //loop over the vectors and swim the particle until you have a good
00977 //swim or you excede the maximum iterations
00978 while(!swimstatus && nswim<100){
00979
00980 swimstatus = true;
00981
00982 //loop over all the states and change them by +/- dstate and swim from
00983 //that point to the next z pos. this figures out the propagator matrix
00984 for(Int_t i=0; i<5; ++i){
00985 if(i==4){
00986 dstate[i] = (fParmDState[i]*thisFilState[kQoverP]*thisFilState[kQoverP]
00987 /(1.-fParmDState[i]*TMath::Abs(thisFilState[kQoverP])));
00988 dstate[i] = fParmDState[i]*TMath::Abs(thisFilState[kQoverP]);
00989 if(dstate[i]<.01) dstate[i] = .01;
00990 }
00991
00992 swimstate[kU] = thisFilState[kU];
00993 swimstate[kV] = thisFilState[kV];
00994 swimstate[kdUdZ] = thisFilState[kdUdZ];
00995 swimstate[kdVdZ] = thisFilState[kdVdZ];
00996 swimstate[kQoverP] = thisFilState[kQoverP];
00997
00998 swimstate[i] += dstate[i];
00999
01000 if(fSwimmer!=2) MSG("FitTrackSR",Msg::kError) << "fSwimmer!=2 currently unsupported" << endl;
01001 else if(fSwimmer==2){
01002
01003 // Using Swimmer package
01004 if(!(Swim(swimstate, pstate, prevkp->GetTrackCluster()->GetZPos(),
01005 currentkp->GetTrackCluster()->GetZPos(), idir,
01006 prevkp->GetVldContext()))) swimstatus = false;
01007
01008
01009 // if outside fiducial detector, return failure flag
01010 if(TMath::Abs(pstate[kU])>10. || TMath::Abs(pstate[kV])>10.){
01011 return -1;
01012 }
01013
01014 swimstate[kU] = thisFilState[kU];
01015 swimstate[kV] = thisFilState[kV];
01016 swimstate[kdUdZ] = thisFilState[kdUdZ];
01017 swimstate[kdVdZ] = thisFilState[kdVdZ];
01018 swimstate[kQoverP] = thisFilState[kQoverP];
01019
01020 swimstate[i] -= dstate[i];
01021
01022 if(!(Swim(swimstate, nstate, prevkp->GetTrackCluster()->GetZPos(),
01023 currentkp->GetTrackCluster()->GetZPos(), idir,
01024 currentkp->GetVldContext()))) swimstatus = false;
01025
01026
01027 // if outside fiducial detector, return failure flag
01028 if(TMath::Abs(nstate[kU])>10. || TMath::Abs(nstate[kV])>10.){
01029 MSG("FitTrackSR",Msg::kDebug) << "outside detector, pstate u,v = " << pstate[kU]
01030 << " " << pstate[kV] << " fail" << endl;
01031 return -1;
01032 }
01033
01034
01035 //get the value of the propagator matrix terms for the current column of the
01036 //matrix
01037 Double_t propValue = 0.;
01038 for(Int_t j=0; j<5; ++j){
01039
01040 if(dstate[i]!=0.) propValue = (pstate[j]-nstate[j])/(2.*dstate[i]);
01041 else{
01042 if(j==i) propValue = 1.;
01043 else propValue = 0.;
01044 }
01045 prevkp->SetPropagatorMatrixValue(idir, i, j, propValue);
01046 }
01047
01048 }//end if fSwimmer is for the Swim package
01049 }//end loop over matrix rows
01050
01051 if(!swimstatus){
01052
01053 // swim failed, double momentum
01054 thisFilState[kQoverP] *= 0.5;
01055 ++nswimfail;
01056 MSG("FitTrackSR",Msg::kDebug) << "failed swim, doubling momentum to q/p = "
01057 << thisFilState[kQoverP] << " nswim = " << nswim << endl;
01058 }
01059
01060 ++nswim;
01061
01062 }
01063
01064 return nswimfail;
01065 }
|
|
||||||||||||||||||||||||
|
Definition at line 2195 of file AlgFitTrackSR.cxx. References AddClustersToFit(), CandFitTrackSRHandle::AddKalmanPlaneAt(), CandFitTrackSRHandle::ClearKalmanPlaneList(), FindDownstreamPlanes(), FindUpstreamPlanes(), TrackClusterSR::GetMaxStrip(), TrackClusterSR::GetMinStrip(), TrackClusterSR::GetPlane(), TrackClusterSR::GetPlaneView(), KalmanPlaneSR::GetTrackCluster(), KalmanPlaneSR::GetZDir(), InitializeFit(), IterateKalmanFit(), MSG, RemoveBadPointsFromFit(), ResetTrackClusterList(), TrackClusterSR::SetIsValid(), CandFitTrackSRHandle::SetVtx(), and tc. Referenced by RunAlg(). 02198 {
02199 Int_t nadd=1;
02200 Int_t iadd=0;
02201 istatus=0;
02202
02203 Int_t nbadfit = 1;
02204 Int_t ibadfit = 0;
02205
02206 Int_t nu = 0;
02207 Int_t nv = 0;
02208
02209 TrackClusterSR *tc = 0;
02210
02211 //make maps of fit planes in each view. map the plane number
02212 //to an int - 0 for a bad fit and 1 for a good fit
02213 map<Int_t, Int_t> uFitPlanes;
02214 map<Int_t, Int_t> vFitPlanes;
02215
02216 //loop over the clusters in the slice to fill the uFitPlanes and vFitPlanes
02217 //maps. initialize all plane values to zero, and reset them in the for
02218 //loop below if the fit was good. this way you can see how many hit planes
02219 //are being skipped by dropping poorly fit planes - otherwise you might
02220 //just keep removing planes but forgetting that you had the ones you dropped
02221 TIter planeItr(&planeClusterList);
02222 TObjArray * plnarray;
02223 while( (plnarray = (TObjArray * )planeItr.Next()) ){
02224 TIter clusterItr(plnarray);
02225 while( (tc = (TrackClusterSR *)clusterItr.Next()) ){
02226 if(tc->GetPlaneView() == PlaneView::kU) uFitPlanes[tc->GetPlane()] = 0;
02227 else if(tc->GetPlaneView() == PlaneView::kV) vFitPlanes[tc->GetPlane()] = 0;
02228 }
02229 }
02230
02231
02232 //loop as long as the fit flag is 0, you have added some points to the
02233 //track, and you havent gone over the max number of iterations
02234 while(!istatus && nadd && iadd<=fParmMaxIterate2){
02235
02236 nbadfit=1;
02237 ibadfit=0;
02238
02239 //loop as long as the fit flag is 0 and you have points to remove from the
02240 //track
02241 while(!istatus && nbadfit){
02242
02243 //reset the number of bad points in the fit to zero for this loop
02244 nbadfit = 0;
02245
02246 //iterate the Kalman fit forward and backwards until the fit q/p
02247 //converges
02248
02249 istatus = IterateKalmanFit(planeClusterList, cfh, nu, nv, direction, dosearch);
02250
02251 //if all systems are still go, look for and remove any bad points in the
02252 //track
02253
02254 if (!istatus){
02255 MSG("FitTrackSR",Msg::kDebug) << "Removing iteration " << iadd << "/"
02256 << ibadfit << endl;
02257
02258 nbadfit = RemoveBadPointsFromFit(cfh, planeClusterList, uFitPlanes, vFitPlanes,nu, nv, direction);
02259
02260 }//end if tracking worked
02261
02262 ++ibadfit;
02263 }//end loop while there are still bad points or tracking
02264
02265 //now look for planes to add to the fit
02266 //reset the counter for the number of added points to the track
02267 nadd = 0;
02268
02269 //make sure the fit is still ok
02270 if(!istatus && dosearch){
02271
02272 cfh.ClearKalmanPlaneList();
02273
02274 //add the remaining clusters after removal of bad points to the fit.
02275 //use 999 as the value for the third parameter
02276 //to ensure that we just scale the previous covariance matrix
02277 nu = 0;
02278 nv = 0;
02279
02280 AddClustersToFit(planeClusterList, cfh, 999, nu, nv, direction);
02281 //make sure you have enough planes in both view to procede
02282 if(nu>=3 && nv>=3){
02283
02284 // find additional planes downstream
02285 nadd += FindDownstreamPlanes(planeClusterList, cfh, direction);
02286
02287 //reinitialize the fit and use
02288 // 999 to ensure we simply scale previous covariance matrix
02289 InitializeFit(cfh,1,999);
02290
02291 //make an array to hold all the new kp's you find
02292 TObjArray *newkplist = new TObjArray(1,0);
02293
02294 nadd += FindUpstreamPlanes(planeClusterList, cfh, newkplist, direction);
02295
02296 //reset the track clusters in the clusterItr for the next iteration
02297 ResetTrackClusterList(planeClusterList);
02298 MSG("FitTrackSR",Msg::kDebug) << "Last iteration " << iadd << "/" << ibadfit
02299 << endl;
02300 //clear the cfh Kalman Plane list - those objects are all in the
02301 //newkplist and will get deleted once the clusters have all their
02302 //IsValid flags reset
02303
02304 cfh.ClearKalmanPlaneList(0);
02305 const KalmanPlaneSR *currentkp = 0;
02306 Int_t sizeoflist = newkplist->GetLast();
02307
02308 //loop over the newkplist in reverse to mark the clusters used in the fit
02309 KalmanPlaneSR *kp = 0;
02310 for(Int_t i=sizeoflist; i>=0; --i){
02311 kp = dynamic_cast<KalmanPlaneSR*>(newkplist->At(i));
02312 assert(kp);
02313
02314 if(!currentkp) currentkp = cfh.AddKalmanPlaneAt(kp,sizeoflist-i);
02315 else cfh.AddKalmanPlaneAt(kp,sizeoflist-i);
02316
02317 TObjArray * planeClusters=(TObjArray *)planeClusterList.At(kp->GetTrackCluster()->GetPlane());
02318 TIter clusterItr(planeClusters);
02319 while((tc = (TrackClusterSR *)(clusterItr.Next()) )){
02320 if(tc->GetPlane()==kp->GetTrackCluster()->GetPlane()){
02321 if(tc->GetMinStrip() == kp->GetTrackCluster()->GetMinStrip()
02322 && tc->GetMaxStrip() == kp->GetTrackCluster()->GetMaxStrip() )
02323 tc->SetIsValid(true);
02324 }
02325 }
02326 MSG("FitTrackSR",Msg::kDebug) << " TC " << kp->GetTrackCluster()->GetPlane()
02327 << " " << kp->GetTrackCluster()->GetMinStrip()
02328 << " " << kp->GetTrackCluster()->GetMaxStrip()
02329 << " " << kp->GetZDir()
02330 << endl;
02331 delete kp;
02332
02333 }//end loop over new kplist
02334
02335 MSG("FitTrackSR", Msg::kDebug) << "vertex direction = "
02336 << currentkp->GetZDir()
02337 << endl;
02338 //set the vertex to the first kp
02339 cfh.SetVtx(currentkp);
02340
02341 newkplist->Clear();
02342 delete newkplist;
02343
02344 }//end if enough planes hit to start looking for more to add
02345 }//end if fit is still ok after iteration ste
02346 ++iadd;
02347 }//end while !iadd
02348
02349 //the iadd-1 is so that we can just put the returned value right into
02350 //cfh.SetNIterate()
02351 return iadd-1;
02352 }
|
|
||||||||||||
|
Definition at line 829 of file AlgFitTrackSR.cxx. References CalculateFilChi2(), CalculateFilCovariance(), CalculateFilState(), CalculateGain(), fParmMaxAngle, fParmMaxQPFrac, KalmanPlaneSR::GetFilStateValue(), KalmanPlaneSR::GetRange(), TrackClusterSR::GetTPosError(), KalmanPlaneSR::GetTrackCluster(), kdUdZ, kdVdZ, kQoverP, KalmanPlaneSR::SetFilStateValue(), and KalmanPlaneSR::SetPredictPlane(). Referenced by FitFrom(). 00830 {
00831 //
00832 // return value = 0 success
00833 //
00834
00835 //get the K_{k} matrix
00836 CalculateGain(currentkp, idir,currentkp->GetTrackCluster()->GetTPosError());
00837
00838 //do the C_{k} = (I-K_{k}H_{k})C_{k}^{k-1} step
00839 CalculateFilCovariance(currentkp, idir);
00840
00841 //find the filtered state
00842 CalculateFilState(currentkp, idir);
00843
00844 // calculate noise and precovariance matrices onward again, values may have changed
00845
00846 CalculateFilChi2(currentkp, idir,currentkp->GetTrackCluster()->GetTPosError());
00847
00848 //reset the predicted from plane -- filtered state has changed
00849 currentkp->SetPredictPlane(-999, idir);
00850
00851 if(TMath::Abs(currentkp->GetFilStateValue(kdUdZ,idir))>fParmMaxAngle){
00852 if(currentkp->GetFilStateValue(kdUdZ,idir)>0.)
00853 currentkp->SetFilStateValue(kdUdZ, idir, fParmMaxAngle);
00854 if(currentkp->GetFilStateValue(kdUdZ,idir)<0.)
00855 currentkp->SetFilStateValue(kdUdZ, idir, -fParmMaxAngle);;
00856 }
00857 if(TMath::Abs(currentkp->GetFilStateValue(kdVdZ, idir))>fParmMaxAngle){
00858 if(currentkp->GetFilStateValue(kdVdZ, idir)>0.)
00859 currentkp->SetFilStateValue(kdVdZ, idir, fParmMaxAngle);
00860 if(currentkp->GetFilStateValue(kdVdZ, idir)<0.)
00861 currentkp->SetFilStateValue(kdVdZ, idir, -fParmMaxAngle);
00862 }
00863
00864 Double_t maxqp = fParmMaxQP;
00865
00866 //use a value of about 2 MeV/(g/cm^2) for the energy loss in the material
00867 //you would divide the max qp frac allowed by that value and then by the range to
00868 //get the max qp. but multiplication is a faster operation, so multiply by
00869 //500 instead.
00870 if ( fParmQPRangeCheck ) {
00871 if(currentkp->GetRange()>0. && fParmMaxQPFrac*500./currentkp->GetRange()<maxqp) {
00872 maxqp = fParmMaxQPFrac*500./currentkp->GetRange();
00873 }
00874 }
00875
00876 if(idir==0 && TMath::Abs(currentkp->GetFilStateValue(kQoverP,idir))>maxqp){
00877 if(currentkp->GetFilStateValue(kQoverP,idir)>0.)
00878 currentkp->SetFilStateValue(kQoverP, idir, maxqp);
00879 else currentkp->SetFilStateValue(kQoverP, idir, -maxqp);
00880 }
00881
00882 return 0;
00883 }
|
|
||||||||||||||||
|
Definition at line 3030 of file AlgFitTrackSR.cxx. References AddForwardBestKPToFit(), FindNumSkippedPlanes(), FitFrom(), CandFitTrackSRHandle::GetKalmanLast(), CandFitTrackSRHandle::GetKalmanPlane(), TrackClusterSR::GetMaxStrip(), TrackClusterSR::GetMinStrip(), TrackClusterSR::GetPlane(), KalmanPlaneSR::GetPreChi2(), CandTrackHandle::GetRange(), KalmanPlaneSR::GetTrackCluster(), TrackClusterSR::IsValid(), MSG, KalmanPlaneSR::SetRange(), and KalmanPlaneSR::SetZDir(). Referenced by DoKalmanFit(). 03033 {
03034
03035
03036 MSG("FitTrackSR", Msg::kDebug) << "in FindDownstreamPlanes "
03037 << direction << endl;
03038 TrackClusterSR *thistc = 0;
03039 TrackClusterSR *oldtc = 0;
03040 KalmanPlaneSR *thiskp = 0;
03041 KalmanPlaneSR *bestkp = 0;
03042 KalmanPlaneSR *oldkp = cfh.GetKalmanPlane(cfh.GetKalmanLast());
03043 Int_t nswimfail = 0;
03044 Int_t nplaneskip = 0;
03045 Bool_t isvalid = true;
03046 Int_t istatus2 = 0;
03047 Int_t nadd = 0;
03048
03049 Int_t currentPlane = -1;
03050 Int_t oldKPPlane = oldkp->GetTrackCluster()->GetPlane();
03051
03052 //loop over the clusters in the cluster list
03053
03054 //save some time - slice the cluster iterator from the last plane
03055 //in the fit to the last one in the detector in the appropriate direction
03056 //neither detector has more than 500 planes, and both start with plane 0 being
03057 //the front steel (uninstrumented) plane
03058
03059 Bool_t dir = kIterForward;
03060 if(direction!=1) dir=kIterBackward;
03061 TIter planeItr(&planeClusterList,dir);
03062 TObjArray * plnarray;
03063 while( (plnarray = (TObjArray * )planeItr.Next()) ){
03064 TIter clusterItr(plnarray);
03065 while( (thistc = (TrackClusterSR * )clusterItr.Next()) && isvalid ){
03066 //make sure you are looking at a valid track cluster, if not go on to the next one
03067 if( !thistc->IsValid() ) continue;
03068 currentPlane = thistc->GetPlane();
03069
03070 MSG("FitTrackSR", Msg::kDebug) << "looking at plane " << currentPlane << endl;
03071
03072 //make sure you are looking at a downstream plane
03073 if(direction*currentPlane>direction*oldKPPlane){
03074
03075 //see if the current track cluster is on a new plane and that
03076 //you have a potential kp to add to the fit
03077 if(bestkp && oldtc && oldtc->GetPlane() != currentPlane ){
03078 MSG("FitTrackSR", Msg::kDebug ) << "add best kp to fit" << endl;
03079 if(AddForwardBestKPToFit(bestkp, cfh, nswimfail)){
03080 ++nadd;
03081 oldkp = bestkp;
03082 }
03083 bestkp = 0;
03084 }
03085
03086 oldKPPlane = oldkp->GetTrackCluster()->GetPlane();
03087 MSG("FitTrackSR", Msg::kDebug) << " prev plane = " << oldKPPlane
03088 << " direction " << direction << endl;
03089
03090 //on a new cluster, see if it is a good one
03091 MSG("FitTrackSR",Msg::kDebug) << "considering tc " << thistc->GetPlane()
03092 << " " << thistc->GetMinStrip() << "-"
03093 << thistc->GetMaxStrip()
03094 << " for addition to end" << endl;
03095 nplaneskip = 0;
03096
03097 //check if the current plane is far from the last kp - need to
03098 //see how many active planes were skipped if it is
03099 if(TMath::Abs(currentPlane-oldKPPlane)>=2*fParmNSkipActive)
03100 nplaneskip = FindNumSkippedPlanes(currentPlane,oldKPPlane,oldkp, direction);
03101
03102 //make sure you didnt skipp too many active planes
03103 if(nplaneskip<2*fParmNSkipActive){
03104
03105 //make a new kp for this cluster to test it out
03106 thiskp = new KalmanPlaneSR(thistc);
03107 thiskp->SetRange(cfh.GetRange(thiskp->GetTrackCluster()->GetPlane()));
03108 thiskp->SetZDir(direction);
03109 istatus2 = FitFrom(oldkp,thiskp,0,-1);
03110 MSG("FitTrackSR",Msg::kDebug) << " chi2 = " << thiskp->GetPreChi2(0)
03111 << " direction " << direction
03112 << " nswimfail = " << istatus2 << endl;
03113 //look to see if the kp you just made is better than the previous
03114 //best kp
03115 if(!istatus2 && (!bestkp || thiskp->GetPreChi2(0)<bestkp->GetPreChi2(0))){
03116 MSG("FitTrackSR",Msg::kDebug) << "best chi2, keeping" << endl;
03117 if (bestkp) delete bestkp;
03118 bestkp = thiskp;
03119
03120 nswimfail = istatus2;
03121 }
03122 else delete thiskp;
03123
03124 if(istatus2<0) isvalid = 0;
03125 }
03126 else {
03127 // any planes beyond this one will not satisfy NSkipView, stop search
03128 isvalid = 0;
03129 }
03130 MSG("FitTrackSR",Msg::kDebug) << "set oldtc" << endl;
03131 oldtc = thistc;
03132 }//end if current plane is down stream of the last fit plane
03133 }//end loop over cluster list
03134 }
03135
03136 //may still have a best kp, so make sure to add it to the fit
03137 if(bestkp){
03138 MSG("FitTrackSR", Msg::kDebug) << "add bestkp outside of loop over tc" << endl;
03139 nadd += AddForwardBestKPToFit(bestkp, cfh, nswimfail);
03140
03141 //delete bestkp so as to not have a memory leek
03142 bestkp = 0;
03143 }
03144
03145 return nadd;
03146 }
|
|
||||||||||||||||||||
|
Definition at line 1899 of file AlgFitTrackSR.cxx. References fDetectorType, fVldContext, PlexPlaneId::GetAdjoinScint(), KalmanPlaneSR::GetFilStateValue(), PlexPlaneId::GetPlaneCoverage(), UgliGeomHandle::GetScintPlnHandle(), KalmanPlaneSR::GetTrackCluster(), UgliPlnHandle::GetZ0(), TrackClusterSR::GetZPos(), UgliScintPlnHandle::IsValid(), PlexPlaneId::IsValid(), kdUdZ, kdVdZ, kQoverP, kU, kV, and Swim(). Referenced by FindDownstreamPlanes(), and FindUpstreamPlanes(). 01902 {
01903
01904 UgliGeomHandle ugh(fVldContext);
01905
01906 // need to check how many active planes were actually skipped
01907 Int_t nplaneskip=0;
01908
01909 PlexPlaneId plnid(fDetectorType,prevPlane,false);
01910 PlexPlaneId plnidend(fDetectorType,currentPlane,false);
01911 plnid = plnid.GetAdjoinScint(direction);
01912
01913 // setup kalmanplane to do swimming
01914 Double_t currentstate[5] = {oldkp->GetFilStateValue(kU,0),
01915 oldkp->GetFilStateValue(kV,0),
01916 oldkp->GetFilStateValue(kdUdZ,0),
01917 oldkp->GetFilStateValue(kdVdZ,0),
01918 oldkp->GetFilStateValue(kQoverP,0)};
01919 Double_t newstate[] = {0.,0.,0.,0.,0.};
01920
01921 Double_t currentz = oldkp->GetTrackCluster()->GetZPos();
01922
01923 bool isvalid = true;
01924 bool swimflag = true;
01925
01926 while(isvalid && plnid != plnidend && nplaneskip<2*fParmNSkipActive){
01927
01928 if(plnid.IsValid() && plnid.GetPlaneCoverage()!=PlaneCoverage::kNoActive){
01929
01930 UgliScintPlnHandle scintpln = ugh.GetScintPlnHandle(plnid);
01931 if(scintpln.IsValid()){
01932
01933 // plane is active, check if in coil
01934 swimflag = Swim(currentstate,newstate,currentz,scintpln.GetZ0(),0,
01935 &fVldContext);
01936
01937 if(!swimflag || TMath::Abs(newstate[kU])>10. || TMath::Abs(newstate[kV])>10.) {
01938
01939 // if failed swim, set nplaneskip to very large number
01940 nplaneskip = 9999999;
01941 isvalid = 0;
01942 }
01943 else{
01944 currentz = scintpln.GetZ0();
01945 currentstate[kU] = newstate[kU];
01946 currentstate[kV] = newstate[kV];
01947 currentstate[kdUdZ] = newstate[kdUdZ];
01948 currentstate[kdVdZ] = newstate[kdVdZ];
01949 currentstate[kQoverP] = newstate[kQoverP];
01950 }
01951
01952 // check if not in coil (defined to have radius 30 cm)
01953 if(currentstate[kU]*currentstate[kU]+currentstate[kV]*currentstate[kV]>0.09) {
01954 ++nplaneskip;
01955
01956 }
01957
01958
01959 }//end if scintillator plane is valid
01960 }
01961 plnid = plnid.GetAdjoinScint(direction);
01962 }//end loop over planes
01963 return nplaneskip;
01964 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 3326 of file AlgFitTrackSR.cxx. Referenced by RemoveBadPointsFromFit(). 03329 {
03330
03331 //assume you drop the current plane, so start off with numSkipped=1
03332 Int_t numSkipped = 1;
03333 Int_t plane = 0;
03334
03335 fitIter = fitPlanes.find(currentPlane);
03336
03337 //only do the check if there was a plane previous to this one
03338 if(prevPlane>0){
03339 if(direction == 1) --fitIter;
03340 else ++fitIter;
03341
03342 plane = (*fitIter).first;
03343
03344 //loop the iterator in reverse until you find the previously fit plane
03345 while( plane*direction > prevPlane*direction && numSkipped<fParmNSkipView){
03346 if(direction == 1) --fitIter;
03347 else ++fitIter;
03348
03349 plane = (*fitIter).first;
03350
03351 //went through the loop, increment the number of skipped planes
03352 ++numSkipped;
03353
03354 //stop looking once you find a kp with a good fit
03355 if( (*fitIter).second != 0 ) break;
03356
03357 }
03358 }//end if not the first plane in view
03359
03360 //now look downstream
03361 if(numSkipped<fParmNSkipView){
03362
03363 //didnt skip too many before the current plane, what about after it?
03364 fitIter = fitPlanes.find(currentPlane);
03365 if(direction == 1) ++fitIter;
03366 else --fitIter;
03367
03368 plane = (*fitIter).first;
03369
03370 while( plane*direction < lastPlane*direction && numSkipped<fParmNSkipView ){
03371 if(direction == 1) ++fitIter;
03372 else --fitIter;
03373 plane = (*fitIter).first;
03374
03375 //stop looking once you find a kp with a good fit
03376 //the break point is before the count increase in
03377 //the forward loop so that you
03378 //dont double count the current plane as being skipped. you have
03379 //set the iterator such that it should be one
03380 //plane beyond the current plane
03381 //and if that plane is a good fit, you didnt skip 2 planes, just one
03382
03383 if( (*fitIter).second != 0) break;
03384
03385 //went through the loop, increment the number of skipped planes
03386 ++numSkipped;
03387
03388 }
03389
03390 }//end check for second view
03391
03392 return numSkipped;
03393 }
|
|
||||||||||||||||
|
Definition at line 4191 of file AlgFitTrackSR.cxx. References CandDigitHandle::GetCharge(), CandHandle::GetDaughterIterator(), CandTrackHandle::GetdS(), PlexSEIdAltL::GetEnd(), CandHandle::GetNDaughters(), CandStripHandle::GetPlane(), CandDigitHandle::GetPlexSEIdAltL(), CandTrackHandle::GetT(), ArrivalTime::Weight(), and LinearFit::Weighted(). 04194 {
04195
04196
04197
04198 ArrivalTime arrtime;
04199
04200 Int_t plane = 0;
04201 const Double_t min_wgt = 0.4;
04202 StripEnd::StripEnd_t stripEnd = StripEnd::kUnknown;
04203
04204 CandStripHandle *strip = 0;
04205 CandDigitHandle *digit = 0;
04206
04207 CandStripHandleItr stripItr(cfh.GetDaughterIterator());
04208 stripItr.Reset();
04209
04210 //arrays for determining the timing direction - limit to
04211 //1000 entries - really shouldnt need more than that to
04212 //be able to figure out if the event is going north or
04213 //south
04214 Double_t time[1000];
04215 Double_t pathLength[1000];
04216 Double_t weight[1000];
04217 Double_t digitpe = 0.;
04218 Int_t digitCtr = 0;
04219
04220 for(Int_t i = 0; i<1000; ++i){
04221 time[i] = 0.;
04222 pathLength[i] = 0.;
04223 weight[i] = 0.;
04224 }
04225
04226 //loop over all strips in the track
04227 while( (strip = stripItr()) ){
04228
04229 //only look at double ended strips and those that have
04230 //believable transverse positions
04231 if(strip->GetNDaughters() == 2){
04232
04233 plane = strip->GetPlane();
04234 //get the iterator over the digits in the strip
04235 CandDigitHandleItr digitItr(strip->GetDaughterIterator());
04236
04237 while( (digit = digitItr()) ){
04238
04239 stripEnd = digit->GetPlexSEIdAltL().GetEnd();
04240
04241 pathLength[digitCtr] = cfh.GetdS()-cfh.GetdS(plane);
04242
04243 //time is recorded in seconds, but i prefer working in ns.
04244 //time is from the track not the strips
04245 time[digitCtr] = cfh.GetT(plane,stripEnd)*1.e9;
04246
04247 digitpe = digit->GetCharge(CalDigitType::kPE);
04248 weight[digitCtr] = TMath::Min(arrtime.Weight(digitpe),min_wgt);
04249
04250 ++digitCtr;
04251
04252 }//end loop over digits in strip
04253 }//end if double ended strip
04254 }//end loop over strips in track
04255
04256 Double_t efitparm[2];
04257 Double_t maxresid = 11.;
04258 Double_t resid = 0.;
04259 Int_t ctr = digitCtr;
04260 Int_t imaxresid = 0;
04261 Int_t nremove = 0;
04262 while(maxresid>10
04263 && digitCtr-nremove>4
04264 && (1.*nremove)<0.2*digitCtr
04265 ){
04266 LinearFit::Weighted(ctr,pathLength,time,weight,fitparm,efitparm);
04267 maxresid = 0.;
04268 imaxresid = 0;
04269 for(int i=0; i<ctr; ++i){
04270 resid = (fitparm[1]*pathLength[i]+fitparm[0]-time[i]);
04271 if(weight[i]>0. && TMath::Abs(resid)>maxresid){
04272 maxresid = TMath::Abs(resid);
04273 imaxresid = i;
04274 }
04275 }
04276 if(maxresid>10){
04277 weight[imaxresid] = 0.;
04278 nremove++;
04279 }
04280
04281 timefitchi2 = 0.;
04282 for(int i=0; i<ctr; ++i){
04283 resid = (fitparm[1]*pathLength[i]+fitparm[0]-time[i]);
04284 timefitchi2 += weight[i]*resid*resid;
04285 }
04286
04287 }//end loop to find timing fit and remove outliers
04288
04289 timefitchi2 = 0.;
04290 for(int i=0; i<ctr; ++i){
04291 if(weight[i]>0.){
04292
04293 resid = (fitparm[1]*pathLength[i]+fitparm[0]-time[i]);
04294 timefitchi2 += weight[i]*resid*resid;
04295 }
04296 }
04297
04298 //check the chi^2 for the fit - if it is really bad dont change the
04299 //initial guess at the direction for the event, ie just make sure
04300 //that the slope in time vs pathlength is positive;
04301 // if(fitparm[1]<0. && timefitchi2>=10.*(digitCtr-nremove))
04302 // fitparm[1] *= -1.;
04303
04304 return digitCtr-nremove;
04305 }
|
|
|
Definition at line 4091 of file AlgFitTrackSR.cxx. References TrackClusterSR::GetBegTime(), TrackClusterSR::GetCharge(), TrackClusterSR::GetZPos(), min(), ArrivalTime::Weight(), and LinearFit::Weighted(). 04092 {
04093 Int_t idir = 1;
04094
04095 ArrivalTime arrtime;
04096
04097 // determine directionality using timing - this should really
04098 //only be needed for cosmic ray events, as beam events always
04099 //increase in z with increasing time.
04100
04101 //we could try to determine the timing for each side (E, W) of each
04102 //electronics crate. that would be the most accurate way, but it
04103 //would also take a lot of time and iterations. instead, we can
04104 //probably get away with just doing a global fit to all datapoints
04105 //since we do have timing constants that take care of the side to side
04106 //and crate to crate offsets. even if a bit of timing hardware is
04107 //exchanged, this wont really affect our ability to go back and figure
04108 //out the right calibrations later.
04109
04110 //make some arrays to do the fit. allow a maximum of 1000 points
04111 //to be included in the fit. there may be events with more than
04112 //1000 digits, but that should be enough to tell you which way the
04113 //event is going.
04114 Double_t zpos[1000];
04115 Double_t time[1000];
04116 Double_t weight[1000];
04117
04118 for (int i=0; i<1000; i++) {
04119 zpos[i] = 0.;
04120 time[i] = 0.;
04121 weight[i] = 0.;
04122 }
04123
04124 //minimum weight for a signal in the timing fit
04125 // maximum weight corresponds to 10 p.e.; reason for this is to minimize
04126 // weight of showers in which transverse spread can have negative effect
04127 // on timing
04128 const Double_t min_wgt = 0.4;
04129 TrackClusterSR *cluster = 0;
04130
04131 Int_t clusterCtr = 0;
04132
04133 clusterItr.ResetFirst();
04134
04135 while( (cluster = clusterItr()) && clusterCtr<1000){
04136
04137 //get the z position of the plane
04138 zpos[clusterCtr] = (Double_t)cluster->GetZPos();
04139
04140 time[clusterCtr] = cluster->GetBegTime();
04141
04142 weight[clusterCtr] = min(arrtime.Weight(cluster->GetCharge()),min_wgt);
04143 ++clusterCtr;
04144
04145 }//end loop over clusters to fill timing arrays
04146
04147 //reset the iterator over all strips
04148 clusterItr.ResetFirst();
04149
04150 //arrays to hold the slope, intercept, and chi^2 of the
04151 //least squares fit for the timing
04152 Double_t parm[2],eparm[2];
04153
04154 //set the maximum residual to the input parameter+1ns to
04155 //get ready for the while loop below
04156 Double_t fParmMaxTimingResid = 20*Munits::ns;
04157 Double_t maxresid = fParmMaxTimingResid+1.*Munits::ns;
04158 Double_t resid = 0.;
04159 Int_t imaxresid = 0;
04160 Int_t nremove=0;
04161 Int_t fitflag = 0;
04162
04163 while(clusterCtr-nremove>4 && maxresid>fParmMaxTimingResid && !fitflag){
04164
04165 fitflag = LinearFit::Weighted(clusterCtr,zpos,time,weight,parm,eparm);
04166 maxresid = 0.;
04167 imaxresid = 0;
04168 for (int i=0; i<clusterCtr; ++i) {
04169 resid = parm[0]+parm[1]*zpos[i]-time[i];
04170 if (weight[i]>0. && TMath::Abs(resid)>maxresid) {
04171 maxresid = TMath::Abs(resid);
04172 imaxresid = i;
04173 }
04174 }
04175 if (maxresid>fParmMaxTimingResid) {
04176 weight[imaxresid] = 0.;
04177 ++nremove;
04178 }
04179 }//end loop to fit the timing values
04180
04181 if(parm[1]<0.){
04182 idir=-1;
04183 }
04184
04185 return idir;
04186 }
|
|
||||||||||||||||||||
|
Definition at line 3151 of file AlgFitTrackSR.cxx. References AddReverseBestKPToFit(), FindNumSkippedPlanes(), FitFrom(), CandFitTrackSRHandle::GetKalmanLast(), CandFitTrackSRHandle::GetKalmanPlane(), TrackClusterSR::GetMaxStrip(), TrackClusterSR::GetMinStrip(), TrackClusterSR::GetPlane(), KalmanPlaneSR::GetPreChi2(), CandTrackHandle::GetRange(), KalmanPlaneSR::GetTrackCluster(), KalmanPlaneSR::GetZDir(), MSG, CandFitTrackSRHandle::SetCurrentKalmanPlane(), KalmanPlaneSR::SetRange(), and KalmanPlaneSR::SetZDir(). Referenced by DoKalmanFit(). 03155 {
03156 MSG("FitTrackSR", Msg::kDebug) << "in FindUpstreamPlanes "
03157 << direction << endl;
03158 TrackClusterSR *thistc = 0;
03159 KalmanPlaneSR *thiskp = 0;
03160 KalmanPlaneSR *bestkp = 0;
03161 KalmanPlaneSR *oldkp = cfh.GetKalmanPlane(cfh.GetKalmanLast());
03162 Int_t nswimfail = 0;
03163 Int_t nplaneskip = 0;
03164 Bool_t isvalid(1);
03165 Int_t istatus2 = 0;
03166
03167 Int_t nadd = 0;
03168
03169 //loop over the clusters in the cluster list
03170
03171 // identify planes which already are fit
03172 map<Int_t,KalmanPlaneSR *> fitplane;
03173
03174 KalmanPlaneSR *kp = 0;
03175 for(int i=0; i<=cfh.GetKalmanLast(); ++i){
03176 kp = cfh.GetKalmanPlane(i);
03177 MSG("FitTrackSR",Msg::kDebug) << " plane " << kp->GetTrackCluster()->GetPlane()
03178 << " strips " << kp->GetTrackCluster()->GetMinStrip()
03179 << "-" << kp->GetTrackCluster()->GetMaxStrip()
03180 << " " << kp->GetZDir() << endl;
03181
03182
03183 fitplane[kp->GetTrackCluster()->GetPlane()] = kp;
03184 }
03185 MSG("FitTrackSR",Msg::kDebug) << "After finding end hits" << endl;
03186
03187 Int_t currentPlane = oldkp->GetTrackCluster()->GetPlane();
03188 Int_t oldKPPlane = oldkp->GetTrackCluster()->GetPlane();
03189
03190 Int_t prevPlane = -1;
03191 Int_t firstPlane = cfh.GetKalmanPlane(0)->GetTrackCluster()->GetPlane();
03192 MSG("FitTrackSR",Msg::kDebug) << "REVERSING FIT, looking for good track clusters"
03193 << endl;
03194
03195 newkplist->AddLast(oldkp);
03196
03197 nswimfail = 0;
03198 isvalid = 1;
03199 map<Int_t,KalmanPlaneSR *>::iterator planeiter;
03200
03201 Bool_t dir = kIterBackward;
03202 if(direction!=1) dir=kIterForward;
03203 TIter planeItr(&planeClusterList,dir);
03204
03205 TObjArray * plnarray;
03206 while(isvalid && (plnarray = (TObjArray * )planeItr.Next()) ){
03207
03208 TIter clusterItr(plnarray);
03209 thistc = (TrackClusterSR *)clusterItr.Next();
03210 if( (direction==1 && thistc->GetPlane()<oldKPPlane) ||
03211 (direction!=1 && thistc->GetPlane()>oldKPPlane)){
03212 clusterItr.Reset();
03213 while(isvalid && (thistc = (TrackClusterSR *)clusterItr.Next()) ){
03214 //if this isnt a valid track cluster, go on to the next one
03215 if(!thistc->IsValid()) continue;
03216 currentPlane = thistc->GetPlane();
03217 oldKPPlane = oldkp->GetTrackCluster()->GetPlane();
03218
03219 planeiter = fitplane.find(thistc->GetPlane());
03220 MSG("FitTrackSR",Msg::kDebug) << "considering trackcluster, plane="
03221 << thistc->GetPlane() << " strips="
03222 << thistc->GetMinStrip() << "-"
03223 << thistc->GetMaxStrip() << endl;
03224 //if you are on a new plane and have a bestkp , try adding it to the fit
03225 if(bestkp && currentPlane != prevPlane){
03226 nadd += AddReverseBestKPToFit(bestkp, oldkp, cfh, newkplist,
03227 nswimfail, direction);
03228 MSG("FitTrackSR" , Msg::kDebug) << "bestkp has direction "
03229 << bestkp->GetZDir() << endl;
03230 bestkp = 0;
03231 }
03232
03233 //see if this plane contains a fit track cluster
03234 if(planeiter!=fitplane.end() ){
03235
03236 //this plane contains a fit track cluster, so add it to the
03237 //newkplist
03238 if(currentPlane != prevPlane ){
03239 kp = dynamic_cast<KalmanPlaneSR *>(planeiter->second);
03240 MSG("FitTrackSR", Msg::kDebug) << oldkp->GetTrackCluster()->GetPlane() << " "
03241 << kp->GetTrackCluster()->GetPlane() << " "
03242 << kp->GetZDir() << endl;
03243
03244 nswimfail = FitFrom(oldkp,kp,1,-1);
03245 MSG("FitTrackSR", Msg::kDebug) << "adding previously fit plane "
03246 << thistc->GetPlane() << " to list" << " "
03247 << kp->GetZDir() << endl;
03248
03249 newkplist->AddLast(kp);
03250 MSG("FitTrackSR", Msg::kDebug) << "added" << endl;
03251 cfh.SetCurrentKalmanPlane(kp);
03252 oldkp = kp;
03253 }
03254 }//end if plane contains a fit track cluster
03255 else{
03256
03257 MSG("FitTrackSR",Msg::kDebug) << "this plane not fit, considering tc "
03258 << thistc->GetPlane() << " "
03259 << thistc->GetMinStrip() << "-"
03260 << thistc->GetMaxStrip()
03261 << " for addition to end" << endl;
03262 // need to check how many active planes were actually skipped
03263 // only do check if beyond first fit plane
03264 nplaneskip=0;
03265
03266 //only worry about checking how many planes were skipped
03267 //if the currentPlane is upstream of the first plane
03268 // - the gaps are of acceptable size between fit planes already
03269 if(currentPlane*direction<firstPlane*direction
03270 && TMath::Abs(currentPlane-oldKPPlane)>=2*fParmNSkipActive)
03271 nplaneskip = FindNumSkippedPlanes(currentPlane, oldKPPlane, oldkp, -direction);
03272
03273 //not too many planes skipped, give this cluster a whirl
03274 if(nplaneskip<2*fParmNSkipActive){
03275 thiskp = new KalmanPlaneSR(thistc);
03276 thiskp->SetRange(cfh.GetRange(thiskp->GetTrackCluster()->GetPlane()));
03277 thiskp->SetZDir(oldkp->GetZDir());
03278 MSG("FitTrackSR",Msg::kDebug) << "fitting from track cluster, plane "
03279 << oldkp->GetTrackCluster()->GetPlane()
03280 << " strips "
03281 << oldkp->GetTrackCluster()->GetMinStrip()
03282 << "-" << oldkp->GetTrackCluster()->GetMaxStrip()
03283 << " direction " << direction << "/"
03284 << thiskp->GetZDir()
03285 << endl;
03286 istatus2 = FitFrom(oldkp,thiskp,1,-1);
03287 //if the fit was good and this kp has a better chi^2 than the previous
03288 //best one for the plane, make it bestkp
03289 MSG("FitTrackSR",Msg::kDebug) << " chi2 = " << thiskp->GetPreChi2(1)
03290 << " nswimfail = " << istatus2 << endl;
03291
03292 if(!istatus2 && (!bestkp || thiskp->GetPreChi2(1)<bestkp->GetPreChi2(1))){
03293 if (bestkp) delete bestkp;
03294 MSG("FitTrackSR",Msg::kDebug) << "best chi2, keeping" << endl;
03295 bestkp = thiskp;
03296 nswimfail = istatus2;
03297 }
03298 else delete thiskp;
03299
03300 }//end not too many active planes skipped
03301 else{
03302
03303 // any planes beyond this one will not satisfy NSkipView, stop search
03304 isvalid = 0;
03305 }
03306 }//end current plane does not have a fit clustser
03307 prevPlane = currentPlane;
03308 }//end loop in reverse over clusters
03309 }
03310 }
03311 //outside of the loop, but there could still be an extra best kp to add
03312 if(bestkp){
03313 nadd += AddReverseBestKPToFit(bestkp, oldkp, cfh, newkplist,
03314 nswimfail, direction);
03315 MSG("FitTrackSR" , Msg::kDebug) << "bestkp has direction "
03316 << bestkp->GetZDir() << endl;
03317 bestkp = 0;
03318 }
03319
03320 return nadd;
03321 }
|
|
||||||||||||||||||||
|
Definition at line 886 of file AlgFitTrackSR.cxx. References Filter(), fParmMaxQP, fParmMaxQPFrac, KalmanPlaneSR::GetFilCovarianceMatrixValue(), KalmanPlaneSR::GetFilStateValue(), TrackClusterSR::GetMaxStrip(), TrackClusterSR::GetMinStrip(), TrackClusterSR::GetPlane(), KalmanPlaneSR::GetRange(), TrackClusterSR::GetTPos(), KalmanPlaneSR::GetTrackCluster(), KalmanPlaneSR::GetZDir(), kQoverP, MSG, and Predict(). Referenced by AddReverseBestKPToFit(), AddToFit(), FindDownstreamPlanes(), FindUpstreamPlanes(), and ReverseFit(). 00889 {
00890
00891
00892 //
00893 // < 0 = failure
00894 // return value = 0 success
00895 //
00896
00897 Int_t nswimfail = 0;
00898 MSG("FitTrackSR",Msg::kDebug) << "in FitFrom: "
00899 << " Fitting direction " << idir << " "
00900 << currentkp->GetTrackCluster()->GetPlane() << " "
00901 << currentkp->GetTrackCluster()->GetTPos()
00902 << " min/max strip = "
00903 << currentkp->GetTrackCluster()->GetMinStrip() << "/"
00904 << currentkp->GetTrackCluster()->GetMaxStrip()
00905 << currentkp->GetZDir() << endl;
00906
00907
00908 //predict the state of the plane to add to the fit based on the
00909 //previously fit plane
00910 nswimfail = Predict(prevkp, currentkp, idir);
00911
00912 if(nswimfail<0){
00913 return nswimfail;
00914 }
00915
00916 Int_t istatus = 0;
00917 istatus = Filter(currentkp, idir);
00918
00919 MSG("FitTrackSR",Msg::kDebug) << "fit point " << idir << " " << " "
00920 << currentkp->GetTrackCluster()->GetPlane() << " "
00921 << currentkp->GetTrackCluster()->GetTPos() << endl;
00922
00923 MSG("FitTrackSR",Msg::kDebug) << "fit qp = "
00924 << currentkp->GetFilStateValue(kQoverP,idir)
00925 << " sigma q/p= "
00926 << currentkp->GetFilCovarianceMatrixValue(0,
00927 kQoverP,kQoverP)
00928 << "/"
00929 << currentkp->GetFilCovarianceMatrixValue(1,
00930 kQoverP,kQoverP)
00931 << " range (g/cm**2) = " << currentkp->GetRange()
00932 << " maximum qp from range = " << fParmMaxQPFrac
00933 << "/0.002/" << currentkp->GetRange() << " = "
00934 << (currentkp->GetRange()>0.
00935 ? fParmMaxQPFrac/0.002/currentkp->GetRange() : 0.)
00936 << " maxqpparm = " << fParmMaxQP << endl;
00937
00938 return nswimfail;
00939 }
|
|
||||||||||||||||
|
Definition at line 509 of file AlgFitTrackSR.cxx. References fCov, fParmInitialPositionError2, fParmInitialQPError2, fParmInitialSlopeError2, CandFitTrackSRHandle::GetCurrentKalmanPlane(), CandRecoHandle::GetDirCosU(), CandRecoHandle::GetDirCosV(), CandRecoHandle::GetDirCosZ(), CandRecoHandle::GetEndDirCosU(), CandRecoHandle::GetEndDirCosV(), CandRecoHandle::GetEndDirCosZ(), CandFitTrackSRHandle::GetEndQP(), CandRecoHandle::GetEndU(), CandRecoHandle::GetEndV(), KalmanPlaneSR::GetFilCovarianceMatrixValue(), KalmanPlaneSR::GetFilStateValue(), CandFitTrackSRHandle::GetInitialQP(), CandFitTrackSRHandle::GetKalmanLast(), CandFitTrackSRHandle::GetKalmanPlane(), TrackClusterSR::GetPlane(), KalmanPlaneSR::GetTrackCluster(), CandRecoHandle::GetVtxU(), CandRecoHandle::GetVtxV(), KalmanPlaneSR::GetZDir(), TrackClusterSR::GetZPos(), kdUdZ, kdVdZ, kQoverP, kU, kV, min(), MSG, KalmanPlaneSR::SetFilCovarianceMatrix(), KalmanPlaneSR::SetFilCovarianceMatrixValue(), KalmanPlaneSR::SetFilStateValue(), KalmanPlaneSR::SetPredictPlane(), CandRecoHandle::SetVtxPlane(), and CandRecoHandle::SetVtxZ(). Referenced by AddToFit(), DoKalmanFit(), and ReverseFit(). 00510 {
00511
00512 KalmanPlaneSR *kp = 0;
00513 for(Int_t i=0; i<=cfh.GetKalmanLast(); ++i){
00514 kp = cfh.GetKalmanPlane(i);
00515 kp->SetPredictPlane(-999,idir);
00516 }
00517
00518 KalmanPlaneSR *currentkp = cfh.GetCurrentKalmanPlane();
00519 //fill up the covariance matrix for the current kp
00520 for(Int_t i=0; i<5; ++i){
00521 for(Int_t j=0; j<5; ++j){
00522 currentkp->SetFilCovarianceMatrixValue(idir,i,j,0.);
00523 }
00524 }
00525
00526 currentkp->SetFilCovarianceMatrixValue(idir,kU,kU,fParmInitialPositionError2);
00527 currentkp->SetFilCovarianceMatrixValue(idir,kV,kV,fParmInitialPositionError2);
00528 currentkp->SetFilCovarianceMatrixValue(idir,kdUdZ,kdUdZ,fParmInitialSlopeError2);
00529 currentkp->SetFilCovarianceMatrixValue(idir,kdVdZ,kdVdZ,fParmInitialSlopeError2);
00530 currentkp->SetFilCovarianceMatrixValue(idir,kQoverP,kQoverP,fParmInitialQPError2);
00531
00532 Double_t cov_xqp = currentkp->GetFilCovarianceMatrixValue(idir,kQoverP,kQoverP)*0.01*0.3*0.025;
00533 cov_xqp *= (Double_t)(currentkp->GetZDir());
00534
00535 currentkp->SetFilCovarianceMatrixValue(idir,kU,kQoverP,cov_xqp);
00536 currentkp->SetFilCovarianceMatrixValue(idir,kV,kQoverP,cov_xqp);
00537 currentkp->SetFilCovarianceMatrixValue(idir,kQoverP,kU,cov_xqp);
00538 currentkp->SetFilCovarianceMatrixValue(idir,kQoverP,kV,cov_xqp);
00539
00540 //set the filtered state vector with either the vertex or end
00541 //point values depending on whether the fit is in the forward or
00542 //reverse direction
00543 if(idir==0){
00544 // we begin with the vertex position
00545 currentkp->SetFilStateValue(kU,0,cfh.GetVtxU());
00546 currentkp->SetFilStateValue(kV,0,cfh.GetVtxV());
00547 currentkp->SetFilStateValue(kdUdZ,0,cfh.GetDirCosU()/cfh.GetDirCosZ());
00548 currentkp->SetFilStateValue(kdVdZ,0,cfh.GetDirCosV()/cfh.GetDirCosZ());
00549 currentkp->SetFilStateValue(kQoverP,0,cfh.GetInitialQP());
00550 }
00551 else{
00552 currentkp->SetFilStateValue(kU,1,cfh.GetEndU());
00553 currentkp->SetFilStateValue(kV,1,cfh.GetEndV());
00554 currentkp->SetFilStateValue(kdUdZ,1,cfh.GetEndDirCosU()/cfh.GetEndDirCosZ());
00555 currentkp->SetFilStateValue(kdVdZ,1,cfh.GetEndDirCosV()/cfh.GetEndDirCosZ());
00556 currentkp->SetFilStateValue(kQoverP,1,cfh.GetEndQP());
00557 }
00558
00559 MSG("FitTrackSR",Msg::kDebug) << "Initializing fit, direction = " << idir
00560 << " iteration = " << iterate << " plane = "
00561 << currentkp->GetTrackCluster()->GetPlane() << " "
00562 << currentkp->GetFilStateValue(kU,idir) << " "
00563 << currentkp->GetFilStateValue(kV,idir) << " "
00564 << currentkp->GetFilStateValue(kdUdZ,idir) << " "
00565 << currentkp->GetFilStateValue(kdVdZ,idir) << " "
00566 << currentkp->GetFilStateValue(kQoverP,idir) << endl;
00567
00568 if(!(idir==0 && iterate==0) && iterate>=0){
00569 fCov[kU][kU] *= fParmCovarianceScale;
00570 fCov[kV][kV] *= fParmCovarianceScale;
00571 fCov[kdUdZ][kdUdZ] *=fParmCovarianceScale;
00572 fCov[kdVdZ][kdVdZ] *= fParmCovarianceScale;
00573 fCov[kQoverP][kQoverP] *=fParmCovarianceScale;
00574
00575 // make sure none of these are larger than our very first covariance elements
00576 fCov[kU][kU] = min(fCov[kU][kU],fParmInitialPositionError2);
00577 fCov[kV][kV] = min(fCov[kV][kV],fParmInitialPositionError2);
00578 fCov[kdUdZ][kdUdZ] = min(fCov[kdUdZ][kdUdZ],fParmInitialSlopeError2);
00579 fCov[kdVdZ][kdVdZ] = min(fCov[kdVdZ][kdVdZ],fParmInitialSlopeError2);
00580 fCov[kQoverP][kQoverP] = min(fCov[kQoverP][kQoverP],fParmInitialQPError2);
00581
00582 Double_t cov_xqp = fParmInitialQPError2*0.01*0.3*0.025;
00583 for(Int_t i=0; i<2; ++i){
00584 if(TMath::Abs(fCov[i][kQoverP])>cov_xqp) fCov[i][kQoverP] = (fCov[i][kQoverP] > 0 ? cov_xqp : -cov_xqp);
00585 if(TMath::Abs(fCov[kQoverP][i])>cov_xqp) fCov[kQoverP][i] = (fCov[kQoverP][i] > 0 ? cov_xqp : -cov_xqp);
00586 }//end loop over covariance stuff
00587
00588 cov_xqp /= 0.06;
00589 for(Int_t i=2; i<4; ++i){
00590 if(TMath::Abs(fCov[i][kQoverP])>cov_xqp) fCov[i][kQoverP] = (fCov[i][kQoverP] > 0 ? cov_xqp : -cov_xqp);
00591 if(TMath::Abs(fCov[kQoverP][i])>cov_xqp) fCov[kQoverP][i] = (fCov[kQoverP][i] > 0 ? cov_xqp : -cov_xqp);
00592 }//end loop to fill covariance matrix stuff
00593
00594 //set the filtered covariance matrix of the current kp to be the same as fCov
00595 currentkp->SetFilCovarianceMatrix(idir,fCov);
00596
00597 }//end if !(idir==0 && iterate==0) && iterate>=0
00598
00599 MsgFormat ffmt("%10.5f");
00600 MSG("FitTrackSR",Msg::kDebug) << "Covariance Matrix\n";
00601 for (Int_t i=0; i<5; i++) {
00602 MSG("FitTrackSR",Msg::kDebug) << ffmt(currentkp->GetFilCovarianceMatrixValue(idir,i,kU))
00603 << ffmt(currentkp->GetFilCovarianceMatrixValue(idir,i,kV))
00604 << ffmt(currentkp->GetFilCovarianceMatrixValue(idir,i,kdUdZ))
00605 << ffmt(currentkp->GetFilCovarianceMatrixValue(idir,i,kdVdZ))
00606 << ffmt(currentkp->GetFilCovarianceMatrixValue(idir,i,kQoverP))
00607 << endl;
00608 }
00609
00610 if(idir==0){
00611 cfh.SetVtxZ(currentkp->GetTrackCluster()->GetZPos());
00612 cfh.SetVtxPlane(currentkp->GetTrackCluster()->GetPlane());
00613 }
00614 }
|
|
|
Definition at line 486 of file AlgFitTrackSR.cxx. References fParmdedx, fParmDState, fParmMaxAngle, fParmMaxQP, fParmMaxQPFrac, fParmPlnRadLen, fParmQPRangeCheck, fParmTPosError2, fSwimmer, Registry::GetDouble(), Registry::GetInt(), and MSG. Referenced by RunAlg(). 00487 {
00488
00489 fParmDState[kU] = ac.GetDouble("KalmanDState1");
00490 fParmDState[kV] = ac.GetDouble("KalmanDState2");
00491 fParmDState[kdUdZ] = ac.GetDouble("KalmanDState3");
00492 fParmDState[kdVdZ] = ac.GetDouble("KalmanDState4");
00493 fParmDState[kQoverP] = ac.GetDouble("KalmanDState5");
00494 fParmPlnRadLen = ac.GetDouble("KalmanPlnRadLen");
00495 fParmdedx = ac.GetDouble("Kalmandedx");
00496 fParmTPosError2 = ac.GetDouble("TPosError2");
00497 fParmMaxQP = ac.GetDouble("KalmanMaxQP");
00498 fParmQPRangeCheck = ac.GetInt("KalmanQPRangeCheck");
00499 fParmMaxQPFrac = ac.GetDouble("KalmanMaxQPFrac");
00500 fParmMaxAngle = ac.GetDouble("KalmanMaxAngle");
00501 fSwimmer = ac.GetInt("Swimmer");
00502 MSG("FitTrackSR", Msg::kDebug) << "initial state = " << fParmDState[kU] << " "
00503 << fParmDState[kV] << " " << fParmDState[kdUdZ] << " "
00504 << fParmDState[kdVdZ] << " " << fParmDState[kQoverP] << endl;
00505 return;
00506 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 2398 of file AlgFitTrackSR.cxx. References AddClustersToFit(), CandFitTrackSRHandle::ClearKalmanPlaneList(), fParmMaxIterate, fParmQPDiff, KalmanPlaneSR::GetFilStateValue(), CandFitTrackSRHandle::GetKalmanPlane(), CandFitTrackSRHandle::GetNChangedFitPoint(), MSG, ResetTrackClusterList(), and ReverseFit(). Referenced by DoKalmanFit(). 02401 {
02402 Int_t iterate=0;
02403 Double_t qp0=0.;
02404 Double_t qp1=0.;
02405
02406 nu = 0;
02407 nv = 0;
02408
02409 Int_t istatus = 0;
02410
02411 // iterate until stable
02412 MSG("FitTrackSR",Msg::kDebug) << "Before iteration " << iterate << "/"
02413 << fParmMaxIterate << " changed points "
02414 << cfh.GetNChangedFitPoint() << " qp0 "
02415 << qp0 << " qp1 " << qp1
02416 << " istatus " << istatus
02417 << endl;
02418 Double_t qpDiff = fParmQPDiff+.01;
02419 while(iterate<fParmMaxIterate && !istatus
02420 && (iterate<=1
02421 || ((qp1!=0. && TMath::Abs(qpDiff)>fParmQPDiff)
02422 && !(qp0==0. && qp1==0.))
02423 || cfh.GetNChangedFitPoint())
02424 ){
02425
02426 //get the fit q/p for the forward fit
02427 if(iterate) qp0 = cfh.GetKalmanPlane(0)->GetFilStateValue(4,1);
02428
02429 cfh.ClearKalmanPlaneList();
02430 nu=0;
02431 nv=0;
02432
02433 // clock_t dummyt;
02434 // struct tms t1;
02435 // struct tms t2;
02436 // struct tms t3;
02437 //static double ticksPerSecond = sysconf(_SC_CLK_TCK);
02438 // dummyt = times(&t1);
02439
02440 istatus = AddClustersToFit(planeClusterList, cfh, iterate, nu, nv, direction);
02441 // dummyt = times(&t2);
02442 // cout << " forward fitter time " << (Double_t)(t2.tms_utime+t2.tms_stime-t1.tms_utime-t1.tms_stime)/ticksPerSecond << endl;
02443 // cout << " --------------- do reverse fit -------------------" << endl;
02444
02445
02446 //check to see if you have enough planes in both views to reverse the
02447 //fit
02448 if(nu>=3 && nv>=3) istatus = ReverseFit(planeClusterList,cfh,iterate,dosearch);
02449 // dummyt = times(&t3);
02450 // cout << " reverse fitter time " << (Double_t)(t3.tms_utime+t3.tms_stime-t2.tms_utime-t2.tms_stime)/ticksPerSecond << endl;
02451 //since new track clusters may have been chosen in the ReverseFit method,
02452 //reset the cluster list
02453 ResetTrackClusterList(planeClusterList, cfh);
02454
02455 qp1 = cfh.GetKalmanPlane(0)->GetFilStateValue(4,1);
02456 if(qp1==0) qp1 = cfh.GetKalmanPlane(0)->GetFilStateValue(4,0);
02457 if(qp1 != 0.) qpDiff = 1.-qp0/qp1;
02458 else qpDiff = fParmQPDiff;
02459 MSG("FitTrackSR",Msg::kDebug) << "After iteration " << iterate << "/"
02460 << fParmMaxIterate << " changed points "
02461 << cfh.GetNChangedFitPoint() << " qp0 "
02462 << qp0 << " qp1 " << qp1
02463 << " istatus " << istatus
02464 << " qpdiff " << TMath::Abs(qpDiff)
02465 << "/" << fParmQPDiff << endl;
02466
02467
02468 ++iterate;
02469 }//end loop of iterations
02470
02471 return istatus;
02472 }
|
|
|
Definition at line 3529 of file AlgFitTrackSR.cxx. References CandHandle::AddDaughterLink(), CandStripHandle::GetCharge(), CandFitTrackSRHandle::GetdUdZ(), CandFitTrackSRHandle::GetdVdZ(), CandFitTrackSRHandle::GetKalmanLast(), CandFitTrackSRHandle::GetKalmanPlane(), CandStripHandle::GetPlane(), TrackClusterSR::GetPlane(), TrackClusterSR::GetPlaneView(), CandStripHandle::GetStrip(), TrackClusterSR::GetStripList(), CandStripHandle::GetTPos(), KalmanPlaneSR::GetTrackCluster(), CandTrackHandle::GetU(), CandTrackHandle::GetV(), CandStripHandle::GetZPos(), MSG, CandTrackHandle::SetInShower(), and tc. Referenced by RunAlg(). 03530 {
03531
03532 Double_t xz = 0.;
03533 Double_t dxdz = 0.;
03534 Int_t nstripexp = 0;
03535 KalmanPlaneSR *kp = 0;
03536 TrackClusterSR *tc = 0;
03537 CandStripHandle *strip = 0;
03538 const CandStripHandle *constStrip = 0;
03539 Int_t minstripindx = 0;
03540 Double_t mintpos = 0;
03541 Int_t indxbest = 0;
03542 Double_t distbest = 0;
03543 Double_t distsum = 0.;
03544 Int_t strip1=-1,strip2=-1;
03545 Double_t dist = 0.;
03546 Int_t nshower = 0;
03547 Int_t thisplane = 0;
03548
03549 for(Int_t i=0; i<=cfh.GetKalmanLast(); ++i){
03550 kp = cfh.GetKalmanPlane(i);
03551 tc = kp->GetTrackCluster();
03552
03553 xz = 0.;
03554 dxdz = 0.;
03555 thisplane = tc->GetPlane();
03556
03557 if(tc->GetPlaneView()==PlaneView::kU){
03558 xz = cfh.GetU(thisplane);
03559 dxdz = cfh.GetdUdZ(thisplane);
03560 }
03561 else if(tc->GetPlaneView()==PlaneView::kV){
03562 xz = cfh.GetV(thisplane);
03563 dxdz = cfh.GetdVdZ(thisplane);
03564 }
03565
03566 //see how many strips you expect to be hit in this plane
03567 //assume 4:1 aspect ratio for scintillator strips to planes
03568 nstripexp = TMath::Max(1,(Int_t)(TMath::Abs(dxdz)/4.)+1);
03569
03570 //if the number of strips in the cluster is less than the expected number,
03571 //take them all for the daughter list
03572 if(tc->GetStripList()->GetLast()+1<=nstripexp){
03573
03574 for(Int_t istrip=0; istrip<=tc->GetStripList()->GetLast(); ++istrip){
03575
03576 strip = dynamic_cast<CandStripHandle*>(tc->GetStripList()->At(istrip));
03577 cfh.AddDaughterLink(*strip);
03578
03579 MSG("AlgFitTrackSR", Msg::kDebug) << "in track plane = " << strip->GetPlane() << "/" << strip->GetZPos()
03580 << " strip = " << strip->GetStrip() << "/" << strip->GetTPos()
03581 << " charge = " << strip->GetCharge() << " nstripexp " << nstripexp
03582 << " nshower = " << nshower << endl;
03583
03584 //not in a shower because you expected that many strips
03585 cfh.SetInShower(strip,0);
03586 }
03587 }//end if fewer strips than expected in cluster
03588 else{
03589
03590 TObjArray orderedstriplist;
03591 vector<Int_t> orderedstripindx;
03592 // order strips by tpos
03593 minstripindx = 0;
03594
03595 //loop over the strips until there are no more to add
03596 while(minstripindx>=0){
03597 mintpos = 9999999.;
03598 minstripindx = -1;
03599 for (Int_t istrip=0; istrip<=tc->GetStripList()->GetLast(); ++istrip){
03600 constStrip = dynamic_cast<const CandStripHandle*>(tc->GetStripList()->At(istrip));
03601
03602 if(orderedstriplist.IndexOf(constStrip)<0 && constStrip->GetTPos()<mintpos){
03603 mintpos = constStrip->GetTPos();
03604 minstripindx = istrip;
03605 }
03606 }//end loop over strips in cluster
03607 if(minstripindx>=0){
03608 orderedstripindx.push_back(minstripindx);
03609 strip = dynamic_cast<CandStripHandle*>(tc->GetStripList()->At(minstripindx));
03610 orderedstriplist.Add(strip);
03611 }
03612 }//end loop over strips to add to list
03613
03614 indxbest = 0;
03615 distbest = 0;
03616
03617 for(Int_t indx=0; indx<=tc->GetStripList()->GetLast()+1-nstripexp; ++indx){
03618 distsum = 0.;
03619 strip1 = -1;
03620 strip2 = -1;
03621 for(Int_t istrip=indx; istrip<indx+nstripexp; ++istrip){
03622 constStrip = dynamic_cast<const CandStripHandle*>(tc->GetStripList()->At(orderedstripindx[istrip]));
03623 if (strip1<0) strip1 = constStrip->GetStrip();
03624 strip2 = constStrip->GetStrip();
03625 dist = TMath::Abs(constStrip->GetTPos()-xz);
03626 if (fParmIsCosmic) dist *= (0.3+exp(-0.2*constStrip->GetCharge()));
03627
03628 distsum += dist;
03629 }
03630
03631 if (!indx || distsum<distbest) {
03632 distbest = distsum;
03633 indxbest = indx;
03634 }
03635 }//end loop over strips in cluster
03636
03637 // count how many hit strips above 1 pe
03638 nshower=0;
03639 for(int i=0; i<=tc->GetStripList()->GetLast(); ++i){
03640 strip = dynamic_cast<CandStripHandle*>(tc->GetStripList()->At(i));
03641 if (strip->GetCharge()>1.5) ++nshower;
03642 MSG("AlgFitTrackSR", Msg::kDebug) << "in shower plane = " << strip->GetPlane() << "/" << strip->GetZPos()
03643 << " strip = " << strip->GetStrip() << "/" << strip->GetTPos()
03644 << " charge = " << strip->GetCharge() << " nstripexp " << nstripexp
03645 << " nshower = " << nshower << endl;
03646 }
03647 for(Int_t istrip=indxbest; istrip<indxbest+nstripexp; ++istrip){
03648 strip = dynamic_cast<CandStripHandle*>(tc->GetStripList()->At(orderedstripindx[istrip]));
03649 cfh.AddDaughterLink(*strip);
03650 cfh.SetInShower(strip,nshower-nstripexp);
03651 }
03652 }//end too more strips in cluster than expected
03653
03654 }//end loop over kps
03655
03656 return;
03657 }
|
|
||||||||||||||||||||
|
Definition at line 1713 of file AlgFitTrackSR.cxx. References CandFitTrackSRHandle::AddTrackCluster(), CandStripHandle::GetCharge(), TrackClusterSR::GetMaxStrip(), TrackClusterSR::GetMinStrip(), TrackClusterSR::GetPlane(), CandStripHandle::GetPlane(), CandStripHandle::GetStrip(), CandStripHandle::GetTPos(), CandStripHandle::GetZPos(), TrackClusterSR::IsContained(), TrackClusterSR::IsValid(), MSG, TrackClusterSR::SetIsValid(), and tc. Referenced by RunAlg(). 01717 {
01718
01719 stripItr.Reset();
01720
01721 // select track clusters which are in this slice
01722
01723 Int_t oldplane = 0;
01724 Int_t minstrip = 0;
01725 Int_t maxstrip = 0;
01726
01727 CandStripHandle *strip = 0;
01728 TrackClusterSR *tc = 0;
01729
01730 while( (strip = stripItr()) ){
01731 MSG("AlgFitTrackSR", Msg::kDebug) << "plane = " << strip->GetPlane() << "/" << strip->GetZPos()
01732 << " strip = " << strip->GetStrip() << "/" << strip->GetTPos()
01733 << " charge = " << strip->GetCharge() << endl;
01734
01735 if(strip->GetPlane()!=oldplane || strip->GetStrip()<minstrip
01736 || strip->GetStrip()>maxstrip) {
01737
01738 Bool_t found(0);
01739 for(int i=0; !found && i<=tclist->GetLast(); ++i){
01740 tc = dynamic_cast<TrackClusterSR*>(tclist->At(i));
01741 assert(tc);
01742 if((found = tc->IsContained(strip))){
01743 TrackClusterSR *newtc = new TrackClusterSR(*tc);
01744 newtc->SetIsValid(true);
01745 trackClusterList->AddLast(newtc);
01746 MSG("FitTrackSR",Msg::kDebug) << "Adding trackcluster "
01747 << tc->GetPlane() << " "
01748 << tc->GetMinStrip()
01749 << " " << tc->GetMaxStrip()
01750 << " is valid "
01751 << (Int_t)tc->IsValid()
01752 << " to list" << endl;
01753 cfh.AddTrackCluster(newtc);
01754 oldplane = tc->GetPlane();
01755 minstrip = tc->GetMinStrip();
01756 maxstrip = tc->GetMaxStrip();
01757 }//end if this cluster contains the current strip
01758 }//end loop over clusters
01759 }//end if this strip is in a new cluster
01760 }//end loop over strips in slice
01761
01762 return;
01763 }
|
|
||||||||||||||||||||
|
Definition at line 1770 of file AlgFitTrackSR.cxx. References TrackClusterSR::AddStrip(), CandFitTrackSRHandle::AddTrackCluster(), fParmMaxClusterNStrip, fParmMisalignmentError, CandStripHandle::GetBegTime(), TrackClusterSR::GetCharge(), CandStripHandle::GetCharge(), CandStripHandle::GetDemuxVetoFlag(), TrackClusterSR::GetMaxStrip(), TrackClusterSR::GetMinStrip(), TrackClusterSR::GetNStrip(), TrackClusterSR::GetPlane(), CandStripHandle::GetPlane(), CandStripHandle::GetPlaneView(), CandStripHandle::GetStrip(), CandStripHandle::GetTPos(), CandStripHandle::GetZPos(), TrackClusterSR::IsValid(), and MSG. Referenced by RunAlg(). 01774 {
01775
01776 MSG("AlgFitTrackSR", Msg::kDebug) << "in MakeTrackClusterList" << endl;
01777 stripItr.Reset();
01778
01779 // create track clusters
01780 Int_t oldplane=0;
01781 Int_t oldstrip=0;
01782 Double_t oldtime=0.;
01783 TrackClusterSR *tcluster=0;
01784 CandStripHandle *strip = 0;
01785
01786 while( (strip = stripItr()) ){
01787 if(!strip->GetDemuxVetoFlag()
01788 && (strip->GetPlaneView()==PlaneView::kU
01789 || strip->GetPlaneView()==PlaneView::kV)){
01790
01791 MSG("AlgFitTrackSR", Msg::kDebug) << "plane = " << strip->GetPlane() << "/" << strip->GetZPos()
01792 << " strip = " << strip->GetStrip() << "/" << strip->GetTPos()
01793 << " charge = " << strip->GetCharge() << endl;
01794
01795 if(tcluster && strip->GetPlane()==oldplane
01796 && direction*strip->GetStrip()<=direction*oldstrip+3){
01797 tcluster->AddStrip(strip);
01798 oldstrip = strip->GetStrip();
01799 oldtime = strip->GetBegTime();
01800 }
01801 else{
01802 TrackClusterSR *trackcluster = new TrackClusterSR(strip,
01803 fParmMisalignmentError);
01804 trackClusterList->AddLast(trackcluster);
01805 oldplane = strip->GetPlane();
01806 oldstrip = strip->GetStrip();
01807 oldtime = strip->GetBegTime();
01808 tcluster = trackcluster;
01809 }//end if this is a new cluster
01810 }//end if strip is in the detector and not vetoed by DeMux
01811 }//end loop over strips
01812
01813
01814 for(Int_t i=0; i<=trackClusterList->GetLast(); ++i){
01815 tcluster = dynamic_cast<TrackClusterSR*>(trackClusterList->At(i));
01816
01817 //get rid of clusters that are too wide or too little charge
01818 if(tcluster->GetNStrip()>fParmMaxClusterNStrip
01819 || tcluster->GetCharge()<fParmMinClusterCharge){
01820 trackClusterList->RemoveAt(i);
01821 delete tcluster;
01822 }
01823 else{
01824 MSG("AlgFitTrackSR",Msg::kDebug) << "Adding trackcluster "
01825 << tcluster->GetPlane()
01826 << " " << tcluster->GetMinStrip() << " "
01827 << tcluster->GetMaxStrip() << " is valid "
01828 << (Int_t)tcluster->IsValid()
01829 << " to list" << endl;
01830 cfh.AddTrackCluster(tcluster);
01831 }
01832 }//end loop over clusters to remove the bad ones
01833
01834 trackClusterList->Compress();
01835
01836 return;
01837 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 1970 of file AlgFitTrackSR.cxx. References CandStripHandle::GetPlane(), CandStripHandle::GetStrip(), CandTrackHandle::GetU(), CandTrackHandle::GetV(), CandTrackHandle::IsInShower(), MSG, ResetTrackClusterList(), CandTrackHandle::SetInShower(), and tc. Referenced by RunAlg(). 01975 {
01976 ;
01977
01978 bool goodTrack = true;
01979
01980 Int_t oldplane=0;
01981
01982 stripItr.Reset();
01983
01984 // add trackclusters that are part of track
01985 Int_t minstrip = 0;
01986 Int_t maxstrip = 0;
01987 map<TrackClusterSR*,Bool_t> isintrack;
01988
01989 Int_t inTrackPlane[1000];
01990 for(Int_t i = 0; i<1000; ++i){
01991 inTrackPlane[i] = 0;
01992 }
01993
01994 Int_t ntrku = 0;
01995 Int_t ntrkv = 0;
01996
01997 Double_t oldu,oldv;
01998 Int_t prevplane=-1;
01999 begPlane = -1;
02000 endPlane = -1;
02001 Bool_t found = false;
02002 TrackClusterSR *tc = 0;
02003 CandStripHandle *strip = 0;
02004 CandStripHandle *tcstrip = 0;
02005
02006 //set all the track clusters in the iterator to IsValid = false
02007 ResetTrackClusterList(planeClusterList);
02008
02009 //loop over strips to find the clusters in the track and mark them as valid
02010 while( (strip = stripItr()) ){
02011 // check if strip outside detector
02012 if(prevplane!=strip->GetPlane()){
02013 MSG("FitTrackSR", Msg::kDebug) << "prev plane = " << prevplane
02014 << " strip plane = "
02015 << strip->GetPlane() << " strip "
02016 << strip->GetStrip()
02017 << endl;
02018
02019 prevplane = strip->GetPlane();
02020 oldu = track0->GetU(prevplane);
02021 oldv = track0->GetV(prevplane);
02022 MSG("FitTrackSR",Msg::kDebug) << "PLANE " << prevplane
02023 << " u,v = " << oldu << " " << oldv << endl;
02024 }
02025 //if the current track point is out of the detector, ignore it
02026 //B.J.R. 3.24.2005: test the impact parameter for the point to make the call
02027 if(TMath::Sqrt(oldu*oldu + oldv*oldv) > fParmMaxImpactParameter){
02028 MSG("FitTrackSR",Msg::kDebug) << "PLANE " << prevplane
02029 << " out of detector, u,v = "
02030 << oldu << " " << oldv
02031 << " REMOVING from fittrack input" << endl;
02032 continue;
02033 }
02034
02035 //make sure you only take one cluster from each plane
02036 if(inTrackPlane[strip->GetPlane()]==0
02037 && (strip->GetPlane()!=oldplane || strip->GetStrip()<minstrip
02038 || strip->GetStrip()>maxstrip)){
02039 found = false;
02040
02041 //loop over the clusters until you find the one containing the
02042 //current strip
02043
02044 TObjArray * planeClusters=(TObjArray *)planeClusterList.At(strip->GetPlane());
02045 TIter clusterItr(planeClusters);
02046 while(!found && (tc = (TrackClusterSR *)(clusterItr.Next()) )){
02047 if( tc->GetPlane()==strip->GetPlane()){
02048
02049 MSG("AlgFitTrackSR", Msg::kDebug) << "cluster on plane " << tc->GetPlane()
02050 << " min strip " << tc->GetMinStrip()
02051 << " max strip " << tc->GetMaxStrip()
02052 << " is valid " << (Int_t)tc->IsValid()
02053 << endl; //if this strip is in this cluster
02054 if(tc->IsContained(strip)){
02055 found = true;
02056 //the cluster is good so set the plane flag to 1 and the cluster
02057 //valid flag to true
02058 inTrackPlane[strip->GetPlane()] = 1;
02059 tc->SetIsValid(true);
02060 MSG("AlgFitTrackSR",Msg::kDebug) << "Adding trackcluster "
02061 << tc->GetPlane()
02062 << " " << tc->GetMinStrip() << " "
02063 << tc->GetMaxStrip() << " is valid "
02064 << (Int_t)tc->IsValid()
02065 << " to track list"
02066 << endl;
02067 //see what view the cluster is in and if it is a good beg plane
02068 if(tc->GetPlaneView()==PlaneView::kU) ++ntrku;
02069 else if(tc->GetPlaneView()==PlaneView::kV) ++ntrkv;
02070 if(begPlane<0) begPlane = strip->GetPlane();
02071 endPlane = strip->GetPlane();
02072
02073 //loop over all strips in the cluster and add them to the CandFitTrack
02074 for(int j=0; j<=tc->GetStripList()->GetLast(); ++j){
02075 tcstrip = dynamic_cast<CandStripHandle*>(tc->GetStripList()->At(j));
02076 cfh.SetInShower(tcstrip,track0->IsInShower(strip));
02077 }
02078 oldplane = tc->GetPlane();
02079 minstrip = tc->GetMinStrip();
02080 maxstrip = tc->GetMaxStrip();
02081 }//end if this strip is in the current cluster
02082 }//end loop over clusters
02083 }
02084
02085
02086 }//end if strip is from a different plane/cluster
02087 }//end loop over strips
02088
02089 stripItr.Reset();
02090 MSG("FitTrackSR",Msg::kDebug) << "# of u,v planes in track = " << ntrku << " "
02091 << ntrkv << endl;
02092
02093 if(ntrku<3 || ntrkv<3){
02094 goodTrack = false;
02095 return goodTrack;
02096 }
02097
02098 return goodTrack;
02099 }
|
|
||||||||||||||||
|
Definition at line 736 of file AlgFitTrackSR.cxx. References CalculateNoise(), CalculatePreChi2(), CalculatePreCovariance(), CalculatePreState(), CalculatePropagator(), fParmMaxAngle, fParmMaxQPFrac, TrackClusterSR::GetPlane(), KalmanPlaneSR::GetPredictPlane(), KalmanPlaneSR::GetPreStateValue(), KalmanPlaneSR::GetRange(), TrackClusterSR::GetTPosError(), KalmanPlaneSR::GetTrackCluster(), kdUdZ, kdVdZ, kQoverP, MSG, KalmanPlaneSR::SetPredictPlane(), and KalmanPlaneSR::SetPreStateValue(). Referenced by FitFrom(). 00739 {
00740
00741 //
00742 // < 0 indicates failure
00743 // return value = 0 success
00744 // > 0 indicates number of swim failures
00745 //
00746 Int_t nswimfail=0;
00747 MSG("FitTrackSR", Msg::kDebug) << "in Predict" << endl;
00748 //make sure you are looking at different planes
00749 if(prevkp->GetTrackCluster()->GetPlane()!=currentkp->GetPredictPlane(idir)) {
00750
00751 Int_t swimstatus = CalculatePropagator(prevkp,currentkp,idir);
00752
00753 if(swimstatus<0){
00754 MSG("FitTrackSR",Msg::kDebug) << "failed to calculate propagator" << endl;
00755 return swimstatus;
00756 }
00757
00758 nswimfail += swimstatus;
00759
00760 //get the Q_{k-1} matrix
00761 CalculateNoise(prevkp, currentkp, idir);
00762
00763 //get the C_{k}^{k-1} matrix
00764 CalculatePreCovariance(prevkp, currentkp, idir);
00765
00766 //extrapolate from the previously fit plane to the plane to add
00767 //to the fit using the swimmer - this takes the place of the F_{k-1}x_{k-1}
00768 //matrix multiplication in the Kalman Filtering equations.
00769 swimstatus = CalculatePreState(prevkp, currentkp, idir);
00770
00771 if(swimstatus<0){
00772 MSG("FitTrackSR",Msg::kDebug) << "failed to calculate predicted state" << endl;
00773 return swimstatus;
00774 }
00775
00776 nswimfail += swimstatus;
00777 }//end if on a different plane than the predict plane
00778
00779 CalculatePreChi2(currentkp, idir,currentkp->GetTrackCluster()->GetTPosError());
00780
00781 //set the plane you predicted the fit for the current one from
00782 currentkp->SetPredictPlane(prevkp->GetTrackCluster()->GetPlane(), idir);
00783
00784 //i am not sure if the following lines are needed or not - they are done in
00785 //the CalculatePreState method, but that is only called if the plane to add
00786 //to the fit is different plane than the previously fit plane - dunno, guess
00787 //i will leave them in
00788
00789 //---------------------------------------------------------------------------//
00790 if(TMath::Abs(currentkp->GetPreStateValue(kdUdZ, idir))>fParmMaxAngle){
00791 if(currentkp->GetPreStateValue(kdUdZ, idir)>0.)
00792 currentkp->SetPreStateValue(kdUdZ, idir, fParmMaxAngle);
00793 if(currentkp->GetPreStateValue(kdUdZ, idir)<0.)
00794 currentkp->SetPreStateValue(kdUdZ, idir, -fParmMaxAngle);
00795 }
00796
00797 if(TMath::Abs(currentkp->GetPreStateValue(kdVdZ, idir))>fParmMaxAngle){
00798 if(currentkp->GetPreStateValue(kdVdZ, idir)>0.)
00799 currentkp->SetPreStateValue(kdVdZ, idir, fParmMaxAngle);
00800 if(currentkp->GetPreStateValue(kdVdZ, idir)<0.)
00801 currentkp->SetPreStateValue(kdVdZ, idir, -fParmMaxAngle);
00802 }
00803
00804 Double_t maxqp = fParmMaxQP;
00805
00806 //use a value of about 2 MeV/(g/cm^2) for the energy loss in the material
00807 //you would divide the max qp frac allowed by that value and then by the range to
00808 //get the max qp. but multiplication is a faster operation, so multiply by
00809 //500 instead.
00810
00811 if ( fParmQPRangeCheck ) {
00812 if(currentkp->GetRange()>0. && fParmMaxQPFrac*500./currentkp->GetRange()<maxqp) {
00813 maxqp = fParmMaxQPFrac*500./currentkp->GetRange();
00814 }
00815 }
00816
00817 if(idir==0 && TMath::Abs(currentkp->GetPreStateValue(kQoverP, idir))>maxqp){
00818 if(currentkp->GetPreStateValue(kQoverP, idir)>0.)
00819 currentkp->SetPreStateValue(kQoverP, idir, maxqp);
00820 else currentkp->SetPreStateValue(kQoverP, idir, -maxqp);
00821 }
00822 //---------------------------------------------------------------------------//
00823
00824 return nswimfail;
00825 }
|
|
||||||||||||||||||||||||||||||||
|
Definition at line 2713 of file AlgFitTrackSR.cxx. References FindNumSkippedPlanesInView(), fParmDeltaChi2, fParmDeltaCovariance, fParmNSkipView, KalmanPlaneSR::GetFilChi2(), KalmanPlaneSR::GetFilCovarianceMatrixValue(), CandFitTrackSRHandle::GetKalmanLast(), CandFitTrackSRHandle::GetKalmanPlane(), TrackClusterSR::GetMaxStrip(), TrackClusterSR::GetMinStrip(), TrackClusterSR::GetPlane(), TrackClusterSR::GetPlaneView(), KalmanPlaneSR::GetTrackCluster(), TrackClusterSR::IsValid(), kdUdZ, kdVdZ, max(), min(), MSG, ResetTrackClusterList(), TrackClusterSR::SetIsValid(), CandFitTrackSRHandle::SetVtx(), and tc. Referenced by DoKalmanFit(). 02719 {
02720
02721 MSG("FitTrackSR", Msg::kDebug) << "in RemoveBadPointsFromFit" << endl;
02722
02723 TrackClusterSR *tc = 0;
02724 const KalmanPlaneSR *vtxkp = 0;
02725 Int_t nremoveitr = 0;
02726 Int_t nbadfit = 0;
02727 nfitu = 0;
02728 nfitv = 0;
02729
02730 Double_t maxlocalchi2 = fParmMaxLocalChi2;
02731 Double_t maxanglecovariance = fParmMaxAngleCovariance;
02732
02733 // if chi2 has to be increased due to too many points being removed,
02734 //deltachi2 > 0
02735 fParmDeltaChi2 = -1.;
02736
02737 // if angle covariance has to be increased due to too many points
02738 //being removed, deltacovariance > 0
02739 fParmDeltaCovariance = -1.;
02740
02741 Double_t mindchi2=0.;
02742 Double_t mindcovariance=0.;
02743
02744 Int_t nPlanesSkippedU = 0;
02745 Int_t nPlanesSkippedV = 0;
02746 Int_t lastUPlane = -1;
02747 Int_t lastVPlane = -1;
02748 Int_t lastFitPlane = -1;
02749
02750 MSG("FitTrackSR", Msg::kDebug) << "nfit u " << nfitu << " nfitv " << nfitv << endl;
02751 while(nfitu<3 || nfitv<3){
02752
02753 vtxkp = 0;
02754 nfitu = 0;
02755 nfitv = 0;
02756 nbadfit = 0;
02757
02758 //reset the cluster list
02759 ResetTrackClusterList(planeClusterList);
02760
02761 mindchi2=0.;
02762 mindcovariance=0.;
02763
02764 nPlanesSkippedU = 0;
02765 nPlanesSkippedV = 0;
02766
02767 lastUPlane = -1;
02768 lastVPlane = -1;
02769
02770 KalmanPlaneSR *kp = 0;
02771
02772 //loop over the Kalman planes to fill the maps
02773 for(Int_t i=0; i<=cfh.GetKalmanLast(); ++i){
02774 kp = cfh.GetKalmanPlane(i);
02775
02776 //see if the reset of the clusterList also reset the
02777 //clusters in the kp's
02778 MSG("FitTrackSR", Msg::kDebug) << "cluster for kp on plane "
02779 << kp->GetTrackCluster()->GetPlane()
02780 << " is valid "
02781 << (Int_t)kp->GetTrackCluster()->IsValid()
02782 << endl;
02783
02784 MSG("FitTrackSR",Msg::kDebug) << " TC " << kp->GetTrackCluster()->GetPlane()
02785 << " " << kp->GetTrackCluster()->GetMinStrip()
02786 << " " << kp->GetTrackCluster()->GetMaxStrip()
02787 << " " << kp->GetFilChi2(0)
02788 << " " << kp->GetFilChi2(1)
02789 << "/" << maxlocalchi2 << " "
02790 << TMath::Min(kp->GetFilCovarianceMatrixValue(0,kdUdZ, kdUdZ),
02791 kp->GetFilCovarianceMatrixValue(1,kdUdZ, kdUdZ))
02792 << " "
02793 << TMath::Min(kp->GetFilCovarianceMatrixValue(0,kdVdZ, kdVdZ),
02794 kp->GetFilCovarianceMatrixValue(1,kdVdZ, kdVdZ))
02795 << endl;
02796
02797 //see if the fit for this plane was really good
02798 if(TMath::Max(kp->GetFilChi2(0),kp->GetFilChi2(1))<=maxlocalchi2
02799 && TMath::Min(kp->GetFilCovarianceMatrixValue(0,kdUdZ,kdUdZ),
02800 kp->GetFilCovarianceMatrixValue(1,kdUdZ,kdUdZ))<maxanglecovariance
02801 && TMath::Min(kp->GetFilCovarianceMatrixValue(0,kdVdZ,kdVdZ),
02802 kp->GetFilCovarianceMatrixValue(1,kdVdZ,kdVdZ))<maxanglecovariance)
02803 {
02804
02805 MSG("FitTrackSR", Msg::kDebug) << " this fit was good" << endl;
02806
02807 kp->GetTrackCluster()->SetIsValid(true);
02808
02809 MSG("FitTrackSR", Msg::kDebug) << " plane " << kp->GetTrackCluster()->GetPlane()
02810 << " IsValid " << kp->GetTrackCluster()->IsValid()
02811 << endl;
02812 TObjArray * planeClusters=(TObjArray *)planeClusterList.At(kp->GetTrackCluster()->GetPlane());
02813 TIter clusterItr(planeClusters);
02814 while((tc = (TrackClusterSR *)(clusterItr.Next()) )){
02815 if(tc->GetPlane()==kp->GetTrackCluster()->GetPlane()){ // replacing slice
02816 if(tc->GetMinStrip() == kp->GetTrackCluster()->GetMinStrip()
02817 && tc->GetMaxStrip() == kp->GetTrackCluster()->GetMaxStrip() )
02818 tc->SetIsValid(true);
02819 }
02820 }
02821
02822 if(kp->GetTrackCluster()->GetPlaneView() == PlaneView::kU)
02823 uFitPlanes[kp->GetTrackCluster()->GetPlane()] = 1;
02824
02825 else if(kp->GetTrackCluster()->GetPlaneView() == PlaneView::kV)
02826 vFitPlanes[kp->GetTrackCluster()->GetPlane()] = 1;
02827
02828 }//end if good fit for kp
02829 else{
02830
02831 MSG("FitTrackSR", Msg::kDebug) << " plane " << kp->GetTrackCluster()->GetPlane()
02832 << " IsValid "
02833 << (Int_t)kp->GetTrackCluster()->IsValid()
02834 << endl;
02835
02836 //no need to set the fTrackCluster to IsValid=false, as the
02837 //reset call above did that.
02838 if(kp->GetTrackCluster()->GetPlaneView() == PlaneView::kU)
02839 uFitPlanes[kp->GetTrackCluster()->GetPlane()] = 0;
02840 else if(kp->GetTrackCluster()->GetPlaneView() == PlaneView::kV)
02841 vFitPlanes[kp->GetTrackCluster()->GetPlane()] = 0;
02842 }
02843
02844 }//end loop to fill map of fit quality for kp's
02845
02846 lastFitPlane = cfh.GetKalmanPlane(cfh.GetKalmanLast())->GetTrackCluster()->GetPlane();
02847 map<Int_t, Int_t>::iterator vfitIter = vFitPlanes.begin();
02848 map<Int_t, Int_t>::iterator ufitIter = uFitPlanes.begin();
02849 for(Int_t i=0; i<=cfh.GetKalmanLast(); ++i){
02850 kp = cfh.GetKalmanPlane(i);
02851
02852 //look to see which view the kp comes from, and if it has a
02853 //good fit, as found above
02854 if(kp->GetTrackCluster()->GetPlaneView()==PlaneView::kU){
02855 if(uFitPlanes[kp->GetTrackCluster()->GetPlane()]==1){
02856 ++nfitu;
02857 lastUPlane = kp->GetTrackCluster()->GetPlane();
02858 if(!vtxkp) vtxkp = kp;
02859 }
02860 else{
02861 //see how many planes were skipped in this view
02862 nPlanesSkippedU = FindNumSkippedPlanesInView(uFitPlanes,
02863 ufitIter,
02864 kp->GetTrackCluster()->GetPlane(),
02865 lastUPlane,
02866 lastFitPlane, direction);
02867 if(nPlanesSkippedU>=fParmNSkipView){
02868
02869 //dont remove this plane as there would be too many skipped planes
02870 //in the view if we did
02871
02872 TObjArray * planeClusters=(TObjArray *)planeClusterList.At(kp->GetTrackCluster()->GetPlane());
02873 TIter clusterItr(planeClusters);
02874 while((tc = (TrackClusterSR * )(clusterItr.Next()) )){
02875 if(tc->GetPlane()==kp->GetTrackCluster()->GetPlane()){
02876 if(tc->GetMinStrip() == kp->GetTrackCluster()->GetMinStrip()
02877 && tc->GetMaxStrip() == kp->GetTrackCluster()->GetMaxStrip() )
02878 tc->SetIsValid(true);
02879 }
02880 }
02881 MSG("FitTrackSR",Msg::kDebug) << "too many consecutive planes"
02882 << " would be removed, keeping plane"
02883 << endl;
02884
02885 if (!vtxkp) vtxkp = kp;
02886 lastUPlane = kp->GetTrackCluster()->GetPlane();
02887 ++nfitu;
02888 }
02889 else{
02890 MSG("FitTrackSR",Msg::kDebug) << "REMOVING, plane "
02891 << kp->GetTrackCluster()->GetPlane()
02892 << " nskipped = " << nPlanesSkippedU
02893 << "/" << fParmNSkipView << endl;
02894
02895 ++nbadfit;
02896 if(TMath::Max(kp->GetFilChi2(0),kp->GetFilChi2(1))>maxlocalchi2){
02897 if(mindchi2<=0.
02898 || TMath::Max(kp->GetFilChi2(0),kp->GetFilChi2(1))-maxlocalchi2<mindchi2){
02899 mindchi2 = TMath::Max(kp->GetFilChi2(0),kp->GetFilChi2(1))-maxlocalchi2;
02900 mindchi2 += 0.001; // precision
02901 }//end if the max chi^2 is bigger than allowed value
02902 }
02903 else{
02904 Double_t thismaxcov = TMath::Max(TMath::Min(kp->GetFilCovarianceMatrixValue(0,kdUdZ,kdUdZ),
02905 kp->GetFilCovarianceMatrixValue(1,kdUdZ,kdUdZ)),
02906 TMath::Min(kp->GetFilCovarianceMatrixValue(0,kdVdZ,kdVdZ),
02907 kp->GetFilCovarianceMatrixValue(1,kdVdZ,kdVdZ)));
02908 if (mindcovariance<=0.
02909 || thismaxcov-maxanglecovariance<mindcovariance) {
02910 mindcovariance = thismaxcov-maxanglecovariance;
02911 mindcovariance += 0.001; // precision
02912 }//end if mindcovariance is too small
02913 }//end else to check covariance
02914 }//end else remove the current plane
02915
02916 }//end else the current kp is a bad fit
02917 }//end if in U view
02918 //check the other view
02919 else if(kp->GetTrackCluster()->GetPlaneView()==PlaneView::kV){
02920 if(vFitPlanes[kp->GetTrackCluster()->GetPlane()]==1){
02921
02922 ++nfitv;
02923 lastVPlane = kp->GetTrackCluster()->GetPlane();
02924 if(!vtxkp) vtxkp = kp;
02925 }
02926 else{
02927 //see how many planes were skipped in this view
02928 nPlanesSkippedV = FindNumSkippedPlanesInView(vFitPlanes,
02929 vfitIter,
02930 kp->GetTrackCluster()->GetPlane(),
02931 lastVPlane,
02932 lastFitPlane, direction);
02933 if(nPlanesSkippedV>=fParmNSkipView){
02934
02935 //dont remove this plane as there would be too many skipped planes
02936 //in the view if we did
02937 // clusterItr.GetSet()->Slice(kp->GetTrackCluster()->GetPlane());
02938 //in the view if we did
02939 MSG("FitTrackSR",Msg::kDebug) << "too many consecutive planes"
02940 << " would be removed, keeping plane"
02941 << endl;
02942 // clusterItr.GetSet()->Slice(kp->GetTrackCluster()->GetPlane());
02943 TObjArray * planeClusters=(TObjArray *)planeClusterList.At(kp->GetTrackCluster()->GetPlane());
02944 TIter clusterItr(planeClusters);
02945 while((tc = (TrackClusterSR * )(clusterItr.Next()) )){
02946 if(tc->GetPlane()==kp->GetTrackCluster()->GetPlane()){
02947 if(tc->GetMinStrip() == kp->GetTrackCluster()->GetMinStrip()
02948 && tc->GetMaxStrip() == kp->GetTrackCluster()->GetMaxStrip() )
02949 tc->SetIsValid(true);
02950 }
02951 }
02952 // clusterItr.GetSet()->Slice();
02953
02954 if (!vtxkp) vtxkp = kp;
02955 lastVPlane = kp->GetTrackCluster()->GetPlane();
02956 ++nfitv;
02957 }
02958 else{
02959 MSG("FitTrackSR",Msg::kDebug) << "REMOVING, plane "
02960 << kp->GetTrackCluster()->GetPlane()
02961 << " nskipped = " << nPlanesSkippedV
02962 << "/" << fParmNSkipView << endl;
02963 ++nbadfit;
02964 if(max(kp->GetFilChi2(0),kp->GetFilChi2(1))>maxlocalchi2){
02965 if(mindchi2<=0.
02966 || max(kp->GetFilChi2(0),kp->GetFilChi2(1))-maxlocalchi2<mindchi2){
02967 mindchi2 = max(kp->GetFilChi2(0),kp->GetFilChi2(1))-maxlocalchi2;
02968 mindchi2 += 0.001; // precision
02969 }//end if the max chi^2 is bigger than allowed value
02970 }
02971 else{
02972 Double_t thismaxcov = max(min(kp->GetFilCovarianceMatrixValue(0,kdUdZ,kdUdZ),
02973 kp->GetFilCovarianceMatrixValue(1,kdUdZ,kdUdZ)),
02974 min(kp->GetFilCovarianceMatrixValue(0,kdVdZ,kdVdZ),
02975 kp->GetFilCovarianceMatrixValue(1,kdVdZ,kdVdZ)));
02976 if (mindcovariance<=0.
02977 || thismaxcov-maxanglecovariance<mindcovariance) {
02978 mindcovariance = thismaxcov-maxanglecovariance;
02979 mindcovariance += 0.001; // precision
02980 }//end if mindcovariance is too small
02981 }//end else to check covariance
02982 }//end else remove the current plane
02983
02984 }//end else the current kp is a bad fit
02985 }//end if in V view
02986 }//end loop over kp's to remove bad points
02987
02988 if (nfitu<3 || nfitv<3) {
02989 // not enough points, increase maximum chi2
02990
02991 maxlocalchi2 += mindchi2;
02992 maxanglecovariance += mindcovariance;
02993
02994 MSG("FitTrackSR",Msg::kDebug) << "TOO FEW POINTS LEFT, increasing chi2"
02995 << " threshold to " << maxlocalchi2
02996 << " and angle covariance threshold to "
02997 << maxanglecovariance << endl;
02998
02999 }//end if less than 3 planes fit in either view
03000 fParmDeltaChi2 = mindchi2;
03001 fParmDeltaCovariance = mindcovariance;
03002 ++nremoveitr;
03003 assert(nremoveitr<=cfh.GetKalmanLast()+2);
03004 // in principle can never loop through more than # of planes in fit
03005 }//end while less than 3 fit planes in at least one view
03006 //make sure you found a vertex kp and set the vertex to it.
03007 assert(vtxkp);
03008 cfh.SetVtx(vtxkp);
03009
03010 TIter planeItr(&planeClusterList);
03011 TObjArray * plnarray;
03012 while( (plnarray = (TObjArray * )planeItr.Next()) ){
03013 TIter clusterItr(plnarray);
03014 while( (tc = (TrackClusterSR * )clusterItr.Next()) ){
03015
03016 MSG("FitTrackSR", Msg::kDebug) << "current cluster on plane "
03017 << tc->GetPlane() << " is valid "
03018 << (Int_t)tc->IsValid() << " "
03019 << tc->GetMinStrip() << "-" << tc->GetMaxStrip()
03020 << endl;
03021 }
03022 }
03023
03024 return nbadfit;
03025 }
|
|
||||||||||||
|
Definition at line 2165 of file AlgFitTrackSR.cxx. References CandFitTrackSRHandle::GetKalmanLast(), CandFitTrackSRHandle::GetKalmanPlane(), TrackClusterSR::GetMaxStrip(), TrackClusterSR::GetMinStrip(), TrackClusterSR::GetPlane(), KalmanPlaneSR::GetTrackCluster(), TrackClusterSR::SetIsValid(), and tc. 02167 {
02168 // clusterItr.Reset();
02169 TrackClusterSR *tc = 0;
02170 KalmanPlaneSR *kp = 0;
02171
02172 //loop over the KalmanPlaneSR objects in the fit - if the cluster
02173 //for a given KalmanPlaneSR is the same as the current cluster,
02174 //set IsValid = true
02175 for(Int_t i = 0; i<=cfh.GetKalmanLast(); ++i){
02176 kp = cfh.GetKalmanPlane(i);
02177
02178 TObjArray * planeClusters=(TObjArray *)planeClusterList.At(kp->GetTrackCluster()->GetPlane());
02179 TIter clusterItr(planeClusters);
02180 //loop over all the track clusters and set their valid flags to false
02181 while( (tc = (TrackClusterSR * )clusterItr.Next()) ){
02182 if(tc->GetPlane()==kp->GetTrackCluster()->GetPlane()){
02183 tc->SetIsValid(false);
02184 if(tc->GetMinStrip() == kp->GetTrackCluster()->GetMinStrip()
02185 && tc->GetMaxStrip() == kp->GetTrackCluster()->GetMaxStrip() )
02186 tc->SetIsValid(true);
02187 }
02188 }
02189 }//end loop over KalmanPlaneSR's
02190 return;
02191 }
|
|
|
Definition at line 2142 of file AlgFitTrackSR.cxx. References TrackClusterSR::GetPlane(), TrackClusterSR::IsValid(), MSG, TrackClusterSR::SetIsValid(), and tc. Referenced by DoKalmanFit(), IterateKalmanFit(), MarkTrackClusters(), and RemoveBadPointsFromFit(). 02143 {
02144 // clusterItr.Reset();
02145 TrackClusterSR *tc = 0;
02146 //loop over all the track clusters and set their valid flags to false
02147 TIter planeItr(&planeClusterList);
02148 TObjArray * plnarray;
02149 while( (plnarray = (TObjArray * )planeItr.Next()) ){
02150 TIter clusterItr(plnarray);
02151 while( (tc = (TrackClusterSR *)clusterItr.Next()) ){
02152 tc->SetIsValid(false);
02153 MSG("FitTrackSR", Msg::kDebug) << "cluster on plane " << tc->GetPlane()
02154 << " is valid " << (Int_t)tc->IsValid()
02155 << endl;
02156 }
02157 }
02158 // clusterItr.Reset();
02159 return;
02160 }
|
|
||||||||||||||||||||
|
Definition at line 2475 of file AlgFitTrackSR.cxx. References fCov, FitFrom(), CandFitTrackSRHandle::GetBadFit(), KalmanPlaneSR::GetFilChi2(), KalmanPlaneSR::GetFilCovarianceMatrixValue(), KalmanPlaneSR::GetFilStateValue(), TrackClusterSR::GetMaxStrip(), TrackClusterSR::GetMinStrip(), CandFitTrackSRHandle::GetNChangedFitPoint(), CandFitTrackSRHandle::GetNSwimFail(), TrackClusterSR::GetPlane(), CandFitTrackSRHandle::GetPlaneList(), TrackClusterSR::GetPlaneView(), KalmanPlaneSR::GetPreChi2(), CandTrackHandle::GetRange(), TrackClusterSR::GetTPos(), KalmanPlaneSR::GetTrackCluster(), CandFitTrackSRHandle::GetTrackClusterList(), KalmanPlaneSR::GetZDir(), InitializeFit(), max(), MSG, pRev, pRev2, CandFitTrackSRHandle::SetCurrentKalmanPlane(), CandFitTrackSRHandle::SetNChangedFitPoint(), CandFitTrackSRHandle::SetNSwimFail(), CandFitTrackSRHandle::SetPlaneChi2(), CandFitTrackSRHandle::SetPlanePreChi2(), CandFitTrackSRHandle::SetPlaneQP(), KalmanPlaneSR::SetRange(), CandFitTrackSRHandle::SetVtx(), and KalmanPlaneSR::SetZDir(). Referenced by IterateKalmanFit(). 02476 {
02477
02478 InitializeFit(cfh,1,iterate);
02479 TObjArray *KalmanPlaneList =cfh.GetPlaneList();
02480
02481 TObjArray newlist;
02482 newlist.Clear();
02483 newlist.Compress();
02484
02485 cfh.SetNChangedFitPoint(0);
02486
02487 TObjArray *tclist = cfh.GetTrackClusterList();
02488
02489 KalmanPlaneSR *kpold = dynamic_cast<KalmanPlaneSR*>(KalmanPlaneList->At(KalmanPlaneList->GetLast()));
02490 KalmanPlaneSR *lastkp = kpold;
02491
02492 Bool_t *kpswimfail = new Bool_t[KalmanPlaneList->GetLast()+1];
02493
02494 for(Int_t i=0 ;i<=KalmanPlaneList->GetLast(); ++i){
02495 kpswimfail[i] = 0;
02496 }
02497
02498 Int_t nu = 0;
02499 Int_t nv = 0;
02500 Bool_t didswimfail = false;
02501
02502 Int_t nswimfail = 0;
02503 Int_t nswimfailnewer = 0;
02504
02505 KalmanPlaneSR *kpnew = 0;
02506 KalmanPlaneSR *kpnewer = 0;
02507 TrackClusterSR *thistc = 0;
02508
02509 Bool_t ready = true;
02510
02511 for(Int_t i=KalmanPlaneList->GetLast()-1; i>=0; --i){
02512 kpnew = dynamic_cast<KalmanPlaneSR*>(KalmanPlaneList->At(i));
02513 MSG("FitTrackSR",Msg::kDebug) << "new TC, plane = "
02514 << kpnew->GetTrackCluster()->GetPlane()
02515 << " tpos = "
02516 << kpnew->GetTrackCluster()->GetTPos()
02517 << " minstrip = "
02518 << kpnew->GetTrackCluster()->GetMinStrip()
02519 << " maxstrip = "
02520 << kpnew->GetTrackCluster()->GetMaxStrip()
02521 << " q/p = "
02522 << kpnew->GetFilStateValue(4,0)
02523 << endl;
02524
02525 if(TMath::Abs(kpnew->GetFilStateValue(4,0))<=2.0){
02526
02527
02528 MSG("FitTrackSR", Msg::kDebug) << "current kp has sufficient momentum to do "
02529 << "reverse fit" << endl;
02530 pRev++;
02531 nswimfail = FitFrom(kpold,kpnew,1,iterate);
02532
02533 if(nswimfail<0){
02534 MSG("FitTrackSR",Msg::kDebug) << "failed swim" << endl;
02535 return nswimfail;
02536 }
02537
02538 //if(i==KalmanPlaneList->GetLast()-1){
02539 if(ready){
02540 ready = false;
02541 cfh.SetPlaneChi2(kpold->GetTrackCluster()->GetPlane(),kpold->GetFilChi2(0));
02542 cfh.SetPlanePreChi2(kpold->GetTrackCluster()->GetPlane(),kpold->GetPreChi2(0));
02543 cfh.SetPlaneQP(kpold->GetTrackCluster()->GetPlane(),kpold->GetFilStateValue(4,1));
02544 }
02545 MSG("FitTrackSR",Msg::kDebug) << "prechi2 = " << kpnew->GetPreChi2(1)
02546 << " filchi2 = "
02547 << max(kpnew->GetFilChi2(0),kpnew->GetFilChi2(1))
02548 << endl;
02549
02550 if(dosearch && iterate<2){
02551 kpnewer = 0;
02552 nswimfailnewer = 0;
02553
02554 MSG("FitTrackSR",Msg::kDebug) << "Searching for other track clusters in plane "
02555 << kpnew->GetTrackCluster()->GetPlane()
02556 << " original min,max strips = "
02557 << kpnew->GetTrackCluster()->GetMinStrip()
02558 << " "
02559 << kpnew->GetTrackCluster()->GetMaxStrip()
02560 << endl;
02561 //tclist is the list of TrackClusterSR objects for this track
02562 TObjArray * planeClusters=(TObjArray *)planeClusterList.At(kpnew->GetTrackCluster()->GetPlane());
02563 TIter clusterItr(planeClusters);
02564 while((thistc = dynamic_cast<TrackClusterSR *>(clusterItr.Next()) )){
02565 //is this a good tc and from the same plane but a different
02566 //cluster than the one currently used in the plane?
02567 if(!cfh.GetBadFit(thistc)
02568 && thistc->GetMinStrip()!=kpnew->GetTrackCluster()->GetMinStrip()){
02569 //make a new kp based on the alternate track cluster and set
02570 //its range and z direction
02571 KalmanPlaneSR *thiskp = new KalmanPlaneSR(thistc);
02572 thiskp->SetRange(cfh.GetRange(thiskp->GetTrackCluster()->GetPlane()));
02573 thiskp->SetZDir(kpold->GetZDir());
02574
02575 //try fitting from the previous kp to the alternate one in
02576 //the reverse direction
02577 pRev2++;
02578 nswimfailnewer = FitFrom(kpold,thiskp, 1,iterate);
02579 MSG("FitTrackSR",Msg::kDebug) << "considering track cluster: "
02580 << tclist->GetLast() << " tpos = "
02581 << thistc->GetTPos()
02582 << " minstrip = "
02583 << thistc->GetMinStrip() << "/"
02584 << kpnew->GetTrackCluster()->GetMinStrip()
02585 << " prechi2 = "
02586 << thiskp->GetPreChi2(1) << " filchi2 = "
02587 << thiskp->GetFilChi2(1) << endl;
02588 if(nswimfailnewer>=0
02589 && ((kpnewer
02590 && (nswimfail<0 || thiskp->GetPreChi2(1)<kpnewer->GetPreChi2(1)))
02591 || (!kpnewer && thiskp->GetPreChi2(1)<kpnew->GetPreChi2(1)))){
02592 MSG("FitTrackSR",Msg::kDebug) << " better track cluster found\n";
02593
02594 if(kpnewer) delete kpnewer;
02595 kpnewer = thiskp;
02596 nswimfail = nswimfailnewer;
02597 }//end if nswimfailnewer>=0 etc
02598 else delete thiskp;
02599
02600 }//end if !GetBadFit() etc
02601 }//end loop over track clusters
02602
02603 //put the better kp in the list
02604 if(kpnewer){
02605 KalmanPlaneList->AddAt(kpnewer,i);
02606 delete kpnew;
02607 kpnew = kpnewer;
02608 cfh.SetNChangedFitPoint(cfh.GetNChangedFitPoint()+1);
02609 }
02610
02611 }//end if dosearch
02612
02613 if(nswimfail<0){
02614 MSG("FitTrackSR",Msg::kDebug) << "failed swim" << endl;
02615 return nswimfail;
02616 }
02617
02618 if(nswimfail!=0 && nu>=3 && nv>=3){
02619 kpswimfail[i] = 1;
02620 didswimfail = 1;
02621 MSG("FitTrackSR",Msg::kDebug) << "Swim failed, skipping plane" << endl;
02622 }
02623 else{
02624 //swim didnt fail, set the chi^2 and qp values for the plane
02625 cfh.SetPlaneChi2(kpnew->GetTrackCluster()->GetPlane(),
02626 max(kpnew->GetFilChi2(1), kpnew->GetFilChi2(0)));
02627 cfh.SetPlanePreChi2(kpnew->GetTrackCluster()->GetPlane(),
02628 max(kpnew->GetPreChi2(1), kpnew->GetPreChi2(0)));
02629
02630 cfh.SetPlaneQP(kpnew->GetTrackCluster()->GetPlane(),kpnew->GetFilStateValue(4,1));
02631 cfh.SetCurrentKalmanPlane(kpnew);
02632 lastkp = kpnew;
02633
02634 //set the covariance matrix array based on the filtered covariance
02635 //matrix of the current kp
02636 for(int i1=0; i1<5; ++i1){
02637 for(int i2=0; i2<5; ++i2){
02638 fCov[i1][i2]=kpnew->GetFilCovarianceMatrixValue(1,i1,i2);
02639 }
02640 }
02641
02642 if(kpnew->GetTrackCluster()->GetPlaneView()==PlaneView::kU) ++nu;
02643 if(kpnew->GetTrackCluster()->GetPlaneView()==PlaneView::kV) ++nv;
02644
02645 kpold = kpnew;
02646 }//end else for if nswimfail!=0 && nu>=3 && nv>=3
02647
02648 cfh.SetNSwimFail(cfh.GetNSwimFail()+TMath::Abs(nswimfail));
02649
02650 }//end if enough momentum left to do fit
02651 // else kpold = kpnew;
02652 }//end loop over kalman planes in reverse
02653
02654 // remove any planes which failed swim
02655 if(didswimfail){
02656
02657 Int_t nlast = KalmanPlaneList->GetLast();
02658 TObjArray newlist;
02659 newlist.Clear();
02660 newlist.Compress();
02661
02662 KalmanPlaneSR *kp = 0;
02663 for(Int_t i=0; i<=nlast; ++i){
02664 kp = dynamic_cast<KalmanPlaneSR*>(KalmanPlaneList->At(i));
02665 if(kpswimfail[i]) delete kp;
02666 else{
02667 newlist.Add(kp);
02668 MSG("FitTrackSR",Msg::kDebug) << "adding thiskp plane "
02669 << kp->GetTrackCluster()->GetPlane()
02670 << " min/max strip "
02671 << kp->GetTrackCluster()->GetMinStrip()
02672 << "/"
02673 << kp->GetTrackCluster()->GetMaxStrip()
02674 << " q/p "
02675 << kp->GetFilStateValue(4,1) << endl;
02676
02677 }//end else kp didnt fail swim
02678 }//end loop over kalman planes
02679
02680 KalmanPlaneList->Clear();
02681 KalmanPlaneList->Compress();
02682
02683 nlast = newlist.GetLast();
02684 MSG("FitTrackSR",Msg::kDebug) << "new KP list" << endl;
02685
02686 for(Int_t i=0; i<=nlast; ++i){
02687 kp = dynamic_cast<KalmanPlaneSR*>(newlist.At(i));
02688 KalmanPlaneList->Add(kp);
02689 MSG("FitTrackSR",Msg::kDebug) << " plane "
02690 << kp->GetTrackCluster()->GetPlane()
02691 << " min/max strip "
02692 << kp->GetTrackCluster()->GetMinStrip()
02693 << "/" << kp->GetTrackCluster()->GetMaxStrip()
02694 << " q/p "
02695 << kp->GetFilStateValue(4,1) << endl;
02696
02697 }//end loop over kalman planes to add to the list for the track
02698 }//end if didswimfail
02699
02700 delete [] kpswimfail;
02701
02702 if(lastkp) cfh.SetVtx(lastkp);
02703
02704 return 0;
02705 }
|
|
||||||||||||||||
|
Implements AlgBase. Definition at line 81 of file AlgFitTrackSR.cxx. References CandHandle::AddDaughterLink(), AlgReco::Calibrate(), CandFitTrackSRHandle::ClearKalmanPlaneList(), CandFitTrackSRHandle::ClearTrackClusterList(), CandFitTrackSRHandle::ClearUVT(), DoKalmanFit(), fDetectorType, fParmCovarianceScale, fParmDeltaChi2, fParmDeltaCovariance, fParmInitialPositionError2, fParmInitialQPError2, fParmInitialSlopeError2, fParmIsCosmic, fParmLastPlane, fParmMaxAngleCovariance, fParmMaxClusterNStrip, fParmMaxImpactParameter, fParmMaxIterate, fParmMaxIterate2, fParmMaxLocalChi2, fParmMaxLocalPreChi2, fParmMinClusterCharge, fParmMinPlanePE, fParmMisalignmentError, fParmNSkipActive, fParmNSkipView, fParmPassMinPlaneAsymmetry, fParmPassPlaneAsymmetry, fParmPassReducedChi2, fParmQPDiff, fParmTPosError2, fVldContext, CandRecord::GetCandHeader(), CandHandle::GetCandRecord(), CandRecoHandle::GetCandSlice(), CandStripHandle::GetCharge(), CandFitTrackHandle::GetChi2(), CandContext::GetDataIn(), CandHandle::GetDaughterIterator(), VldContext::GetDetector(), Registry::GetDouble(), KalmanPlaneSR::GetFilStateValue(), Registry::GetInt(), CandFitTrackSRHandle::GetKalmanLast(), CandFitTrackSRHandle::GetKalmanPlane(), CandFitTrackHandle::GetNDOF(), CandRecoHandle::GetNPlane(), CandStripHandle::GetPlane(), TrackClusterSR::GetPlane(), PlexPlaneId::GetPlane(), UgliGeomHandle::GetPlaneIdFromZ(), CandTrackHandle::GetRange(), CandHeader::GetSnarl(), CandRecoHandle::GetTimeSlope(), CandHandle::GetVldContext(), InitKalmanFitParameters(), TrackClusterSR::IsValid(), KeyOnClusterPlane(), MakeDaughterStripList(), MakeSliceClusterList(), MakeTrackClusterList(), MarkTrackClusters(), MSG, pFor, pRev, pRev2, CandHandle::RemoveDaughter(), AlgTrack::SetdS(), CandFitTrackHandle::SetEMCharge(), CandFitTrackSRHandle::SetEnd(), CandFitTrackHandle::SetFinderTrack(), CandTrackHandle::SetMomentum(), CandFitTrackHandle::SetMomentumCurve(), CandFitTrackHandle::SetNIterate(), CandFitTrackHandle::SetPass(), SetPlaneParameters(), AlgTrack::SetT(), SetTrackEndParameters(), SetTrackParameters(), AlgTrack::SetUVZ(), CandFitTrackSRHandle::SetVtx(), SwimVertexAndEndPoints(), and tc. 00083 {
00084 // check inputs
00085
00086
00087 pRev=0;
00088 pRev2=0;
00089 pFor=0;
00090 assert(ch.InheritsFrom("CandFitTrackSRHandle"));
00091 CandFitTrackSRHandle &cfh = dynamic_cast<CandFitTrackSRHandle &>(ch);
00092 cfh.SetPass(0);
00093
00094 assert(cx.GetDataIn());
00095 assert(cx.GetDataIn()->InheritsFrom("TObjArray"));
00096
00097 CandTrackHandle *track0 = 0;
00098 const TObjArray *tclist = 0;
00099 const TObjArray *cxin =
00100 dynamic_cast<const TObjArray *>(cx.GetDataIn());
00101 for (Int_t i=0; i<=cxin->GetLast(); i++) {
00102 TObject *tobj = cxin->At(i);
00103 if (tobj->InheritsFrom("CandTrackHandle")) {
00104 track0 = dynamic_cast<CandTrackHandle*>(tobj);
00105 MSG("EventNum", Msg::kDebug) << "event number "
00106 << track0->GetCandRecord()->GetCandHeader()->GetSnarl()
00107 << endl;
00108 }
00109 if (tobj->InheritsFrom("TObjArray")) {
00110 tclist = dynamic_cast<TObjArray*>(tobj);
00111 }
00112 }
00113 assert(track0);
00114
00115 // set finder track
00116 cfh.SetFinderTrack(track0);
00117
00118 // get detector type
00119 const VldContext* vldcptr = track0->GetVldContext();
00120 assert(vldcptr);
00121 fVldContext = *vldcptr;
00122 fDetectorType = fVldContext.GetDetector();
00123 UgliGeomHandle ugh(fVldContext);
00124
00125 // input algorithm parameters
00126
00127 fParmMaxIterate = ac.GetInt("MaxIterate");
00128 fParmMaxIterate2 = ac.GetInt("MaxIterate2");
00129 fParmQPDiff = ac.GetDouble("QPDiff");
00130 fParmMinPlanePE = ac.GetDouble("MinPlanePE");
00131 fParmLastPlane = ac.GetInt("LastPlane");
00132 fParmIsCosmic = ac.GetInt("IsCosmic");
00133 fParmMaxLocalChi2 = ac.GetDouble("MaxLocalChi2");
00134 fParmMaxLocalPreChi2 = ac.GetDouble("MaxLocalPreChi2");
00135 fParmMaxAngleCovariance = ac.GetDouble("MaxAngleCovariance");
00136 fParmNSkipView = ac.GetInt("NSkipView");
00137 fParmNSkipActive = ac.GetInt("NSkipActive");
00138 fParmPassReducedChi2 = ac.GetDouble("PassReducedChi2");
00139 fParmPassPlaneAsymmetry = ac.GetDouble("PassPlaneAsymmetry");
00140 fParmPassMinPlaneAsymmetry = ac.GetInt("PassMinPlaneAsymmetry");
00141 fParmMaxImpactParameter = ac.GetDouble("MaxImpactParameter");
00142 fParmMinClusterCharge = ac.GetDouble("MinClusterCharge");
00143 fParmMaxClusterNStrip = ac.GetInt("MaxClusterNStrip");
00144 fParmDeltaChi2 = ac.GetDouble("DeltaChi2");
00145 fParmDeltaCovariance = ac.GetDouble("DeltaCovariance");
00146 fParmMisalignmentError = ac.GetDouble("MisalignmentError")*Munits::mm;
00147 fParmTPosError2 = ac.GetDouble("TPosError2");
00148 fParmInitialPositionError2 = ac.GetDouble("InitialPositionError2");
00149 fParmInitialSlopeError2 = ac.GetDouble("InitialSlopeError2");
00150 fParmInitialQPError2 = ac.GetDouble("InitialQPError2");
00151 fParmMaxLocalChi2 = ac.GetDouble("MaxLocalChi2");
00152 fParmMaxLocalPreChi2 = ac.GetDouble("MaxLocalPreChi2");
00153 fParmCovarianceScale = ac.GetDouble("CovarianceScale");
00154
00155 //initialize the parameters from registry for the Kalman Plane stuff
00156 InitKalmanFitParameters(ac);
00157
00158 // verify that looping won't ask for planes that don't exist
00159 const float way_downstream = 999999.;
00160 PlexPlaneId lastpln = ugh.GetPlaneIdFromZ(way_downstream);
00161 if (lastpln.GetPlane() < fParmLastPlane ) {
00162 fParmLastPlane = lastpln.GetPlane();
00163 }
00164
00165 Int_t idir = -1;
00166 if(track0->GetTimeSlope()>0. || !fParmIsCosmic) idir = 1;
00167
00168 //get an iterator over the strips in this slice
00169 CandStripHandle *strip = 0;
00170 CandStripHandleItr stripItr(track0->GetCandSlice()->GetDaughterIterator());
00171
00172 //sort by plane and strip then by time using the navigation 2 sort functionality
00173 stripItr.SetSort2Fun(CandStripHandle::StripSRKeyFromPSEId, CandStripHandle::StripSRKeyFromBegTime);
00174
00175 MSG("AlgFitTrackSR", Msg::kDebug) << "sorted the strips by time" << endl;
00176
00177 stripItr.SetDirection(idir);
00178 stripItr.Reset();
00179
00180 //create a TObjArray to hold the cluster objects you are going to make
00181 TObjArray *trackClusterList = new TObjArray(1,0);
00182
00183 //fill the trackClusterList with the objects in tclist, if it is there
00184 if(tclist) MakeSliceClusterList(trackClusterList, tclist, stripItr, cfh);
00185 else MakeTrackClusterList(trackClusterList, stripItr, cfh, idir);
00186
00187 MSG("AlgFitTrackSR", Msg::kDebug) << "made cluster list" << endl;
00188
00189 // clone the trackClusterList so that you can have a master list of
00190 // track clusters and one that keeps track of which clusters are used
00191 // in the fit track
00192
00193 TObjArray *clusterList(trackClusterList);
00194
00195 //make an iterator over clusterList and sort it by plane number
00196 TrackClusterSRItr clusterItr(clusterList);
00197 TrackClusterSRKeyFunc *clusterKf = clusterItr.CreateKeyFunc();
00198 clusterKf->SetFun(KeyOnClusterPlane);
00199 clusterItr.GetSet()->AdoptSortKeyFunc(clusterKf);
00200 clusterKf = 0;
00201 clusterItr.SetDirection(idir);
00202
00203 clusterItr.ResetFirst();
00204 TrackClusterSR *cluster = 0;
00205
00206 TObjArray planeClusterList(1000);
00207 Int_t iplane=0;
00208 Bool_t first=true;
00209 TObjArray * planeClusters;
00210 while( (cluster = clusterItr())) {
00211 if(cluster->GetPlane()!=iplane || first){
00212 iplane=cluster->GetPlane();
00213 MSG("FitTrackSR", Msg::kDebug) << "new cluster on plane " << iplane << endl;
00214 planeClusters = new TObjArray(1,0);
00215 planeClusterList.AddAt(planeClusters,iplane);
00216 planeClusters->Add(cluster);
00217 first=false;
00218 }
00219 else{
00220 MSG("FitTrackSR", Msg::kDebug) << "adding cluster on plane " << iplane << endl;
00221 planeClusters=(TObjArray *)planeClusterList.At(iplane);
00222 if(!planeClusters) MSG("AlgFitTrackSR", Msg::kFatal) << "planeCluster array not defined for plane " << iplane << endl;
00223 planeClusters->Add(cluster);
00224 }
00225 }
00226
00227 Bool_t dir = kIterForward;
00228 if(idir!=1) dir=kIterBackward;
00229 TIter planeItr(&planeClusterList,idir);
00230 TrackClusterSR * tc=0;
00231 TObjArray * plnarray;
00232 while( (plnarray = (TObjArray * )planeItr.Next()) ){
00233 TIter clusterItr(plnarray);
00234 while( (tc = (TrackClusterSR *)clusterItr.Next()) ){
00235
00236 MSG("FitTrackSR", Msg::kDebug) << "current cluster on plane "
00237 << tc->GetPlane() << " is valid "
00238 << (Int_t)tc->IsValid() << endl;
00239 }
00240 }
00241 MSG("AlgFitTrackSR", Msg::kDebug) << "made cluster iterator" << endl;
00242
00243 //get another iterator over the strips in the track this time
00244 CandStripHandleItr trackStripItr(track0->GetDaughterIterator());
00245
00246 //sort by plane and strip then by time using the navigation 2 sort functionality
00247 trackStripItr.SetSort2Fun(CandStripHandle::StripSRKeyFromPSEId, CandStripHandle::StripSRKeyFromBegTime);
00248
00249 /* for now leave in the old code to sort in 2 dimensions just in case
00250 CandStripHandleKeyFunc *trackStripKf = trackStripItr.CreateKeyFunc();
00251 //using a 2d sort - first sort on the PlexStripEndId
00252 trackStripKf->SetFun(CandStripHandle::StripSRKeyFromPSEId);
00253 trackStripItr.GetSet()->AdoptSortKeyFunc(trackStripKf,kTRUE,kFALSE);
00254 //now sort by time
00255 trackStripKf = trackStripItr.CreateKeyFunc();
00256 trackStripKf->SetFun(CandStripHandle::StripSRKeyFromBegTime);
00257 trackStripItr.GetSet()->AdoptSortKeyFunc(trackStripKf,kFALSE);
00258 trackStripKf = 0;
00259 */
00260
00261 MSG("AlgFitTrackSR", Msg::kDebug) << "got iterator sorted over track strips" << endl;
00262
00263 trackStripItr.SetDirection(idir);
00264 trackStripItr.Reset();
00265
00266 Int_t begPlane = -1;
00267 Int_t endPlane = -1;
00268
00269 //now mark the clusters to use in the track by setting the IsValid flag to true
00270 bool goodTrack = MarkTrackClusters(track0, planeClusterList, trackStripItr, cfh,
00271 begPlane, endPlane);
00272
00273 //set the track parameters based on the track passed into the algorithm
00274 SetTrackParameters(track0, cfh, idir);
00275
00276 //set the endpoints and their direction cosines if track0 is a CandTrackSR
00277 SetTrackEndParameters(begPlane, endPlane, cfh, track0);
00278
00279 MSG("AlgFitTrackSR", Msg::kDebug) << "start the fitting" << endl;
00280
00281 //this track has fewer than 3 hits at least one view, so just add the strips
00282 //in the daughter list of track0 to cfh and quit
00283 if(!goodTrack){
00284 // add daughter strips from the current track and bail
00285 CandStripHandleItr trk0stripItr(track0->GetDaughterIterator());
00286 while( (strip = trk0stripItr()) ){
00287 cfh.AddDaughterLink(*strip);
00288 }
00289 return;
00290 }
00291 else{
00292 Int_t istatus = 0;
00293 //now to actually do the track fitting.
00294
00295 Int_t dosearch=1;
00296 Int_t niterate = DoKalmanFit(planeClusterList, cfh, istatus, idir, dosearch);
00297 if(istatus>=0){
00298 //get the first and last planes for the track
00299 KalmanPlaneSR *kp0 = cfh.GetKalmanPlane(0);
00300 KalmanPlaneSR *kp1 = cfh.GetKalmanPlane(cfh.GetKalmanLast());
00301 cfh.SetVtx(kp0);
00302 cfh.SetEnd(kp1);
00303
00304 //set up variables for first and last planes in each view for track
00305 const KalmanPlaneSR *kpu0 = 0;
00306 const KalmanPlaneSR *kpv0 = 0;
00307 const KalmanPlaneSR *kpu1 = 0;
00308 const KalmanPlaneSR *kpv1 = 0;
00309
00310 // clear STL maps--we only want fit planes as keys
00311 cfh.ClearUVT();
00312 SetPlaneParameters(cfh, kpu0, kpu1, kpv0, kpv1);
00313 }
00314 // check to see whether full fit converged. If not, fall back to using
00315 // only track points.
00316 if(istatus<0
00317 || cfh.GetNDOF()==0
00318 || (cfh.GetNDOF()!=0 && cfh.GetChi2()/cfh.GetNDOF()>fParmPassReducedChi2)
00319 ) {
00320 dosearch = 0;
00321 idir = -1;
00322 if(track0->GetTimeSlope()>0. || ! fParmIsCosmic) idir = 1;
00323
00324 //fill the trackClusterList with the objects in tclist, if it is there
00325 cfh.ClearTrackClusterList();
00326 trackClusterList->Clear();
00327 trackClusterList->Compress();
00328 if(tclist) MakeSliceClusterList(trackClusterList, tclist, stripItr,
00329 cfh);
00330 else MakeTrackClusterList(trackClusterList, stripItr, cfh, idir);
00331
00332 //now mark the clusters to use in the track by setting the IsValid flag to true
00333 begPlane = -1;
00334 endPlane = -1;
00335 goodTrack = MarkTrackClusters(track0, planeClusterList, trackStripItr, cfh,
00336 begPlane, endPlane);
00337
00338 //set the track parameters based on the track passed into the algorithm
00339 SetTrackParameters(track0, cfh, idir);
00340
00341 //set the endpoints and their direction cosines if track0 is a CandTrackSR
00342 SetTrackEndParameters(begPlane, endPlane, cfh, track0);
00343 niterate = DoKalmanFit(planeClusterList, cfh, istatus, idir, dosearch);
00344
00345 }
00346
00347 //set the number of iterations for the fit
00348 cfh.SetNIterate(niterate);
00349
00350 if(istatus>=0){
00351 //get the first and last planes for the track
00352 KalmanPlaneSR *kp0 = cfh.GetKalmanPlane(0);
00353 KalmanPlaneSR *kp1 = cfh.GetKalmanPlane(cfh.GetKalmanLast());
00354 cfh.SetVtx(kp0);
00355 cfh.SetEnd(kp1);
00356
00357 //set up variables for first and last planes in each view for track
00358 const KalmanPlaneSR *kpu0 = 0;
00359 const KalmanPlaneSR *kpv0 = 0;
00360 const KalmanPlaneSR *kpu1 = 0;
00361 const KalmanPlaneSR *kpv1 = 0;
00362
00363 // clear STL maps--we only want fit planes as keys
00364 cfh.ClearUVT();
00365 SetPlaneParameters(cfh, kpu0, kpu1, kpv0, kpv1);
00366
00367 //gotta add those strips to the daughter list for this track
00368 MakeDaughterStripList(cfh);
00369
00370 // create array of strips not in fit track
00371 Double_t planepe[1000];
00372 for(int i=0; i<1000; ++i){
00373 planepe[i] = 0.;
00374 }
00375
00376 stripItr.ResetFirst();
00377 CandStripHandle *strip = 0;
00378 while( (strip = stripItr()) ){
00379 if(strip->GetPlane()>=0)
00380 planepe[strip->GetPlane()] += strip->GetCharge(CalDigitType::kPE);
00381 }//end loop over strips to get charge for each plane
00382
00383 // Find planes closest to vertex and end with adjacent planes meeting
00384 // PE cut
00385 Int_t plane0 = -999;
00386 Int_t plane1 = -999;
00387 for(int i=0; i<1000; ++i){
00388 if(planepe[i]>=fParmMinPlanePE && planepe[i+1]>=fParmMinPlanePE){
00389 if(idir>0){
00390 if(plane0<0) plane0 = i;
00391 if(plane1<0 || i+1>plane1) plane1 = i+1;
00392 }
00393 else{
00394 if(plane1<0) plane1 = i;
00395 if(plane0<0 || i+1>plane0) plane0 = i+1;
00396 }
00397 }//end if enough signal on these two planes
00398 }//end loop over planes to find the first and last ones
00399
00400
00401
00402 Double_t vtxqp = kp0->GetFilStateValue(4,1);
00403
00404 // tweak qp to force agreement with truth !!!!
00405 vtxqp *= 1.01-0.1*vtxqp;
00406
00407 //if we are looking at cosmic rays, need to swim the track out of the
00408 //detector
00409 if(fParmIsCosmic) SwimVertexAndEndPoints(cfh, kp0, kp1,
00410 kpu0, kpu1,
00411 kpv0, kpv1,
00412 planepe, plane0, plane1,
00413 vtxqp, idir);
00414
00415 if(vtxqp==0.){
00416 // infinite momentum, choose finite number to prevent floating point exceptions
00417 vtxqp = 0.000001; // 1 PeV
00418 cfh.SetEMCharge(0.);
00419 }
00420
00421 // set momentum and charge sign
00422 cfh.SetMomentumCurve(1./TMath::Abs(vtxqp));
00423 if(vtxqp>0.) cfh.SetEMCharge(1.);
00424 else if(vtxqp<0.) cfh.SetEMCharge(-1.);
00425
00426 // fill time and range maps
00427 SetT(&cfh);
00428 SetdS(&cfh);
00429
00430 // set the momentum from range; taken from PDG R/M vs p/M plot for Fe
00431 Double_t range = cfh.GetRange();
00432 // if(range>0.) cfh.SetMomentumRange(0.105658*exp(1.0363*log(range)-4.383));
00433 if(range>0.) cfh.SetMomentum(0.048 + 1.660e-3*range + 3.057e-8*range*range);
00434 else cfh.SetMomentum(0.);
00435 Calibrate(&cfh);
00436
00437 } // end if istatus>=0
00438
00439 cfh.ClearTrackClusterList();
00440 cfh.ClearKalmanPlaneList();
00441
00442 //check and see if the track passes the cuts for a good track
00443 Float_t nplaneu = (Float_t)(cfh.GetNPlane(PlaneView::kU));
00444 Float_t nplanev = (Float_t)(cfh.GetNPlane(PlaneView::kV));
00445 Int_t nplane = cfh.GetNPlane();
00446 if(istatus>=0 && cfh.GetNDOF()>0
00447 && cfh.GetChi2()/cfh.GetNDOF()<=fParmPassReducedChi2
00448 && fParmDeltaChi2<=0. && fParmDeltaCovariance<=0.
00449 && (nplane<fParmPassMinPlaneAsymmetry
00450 || TMath::Abs((nplaneu-nplanev)/(1.*nplane))<=fParmPassPlaneAsymmetry )
00451 )
00452 cfh.SetPass(1);
00453 else {
00454 cfh.SetPass(0);
00455 SetTrackParameters(track0, cfh, idir);
00456 CandStripHandleItr trkstripItr(cfh.GetDaughterIterator());
00457 while( (strip = trkstripItr()) ){
00458 cfh.RemoveDaughter(strip);
00459 }
00460 CandStripHandleItr trk0stripItr(track0->GetDaughterIterator());
00461 while( (strip = trk0stripItr()) ){
00462 cfh.AddDaughterLink(*strip);
00463 }
00464 // fill time and range maps
00465 SetT(&cfh);
00466 SetdS(&cfh);
00467 SetUVZ(&cfh);
00468 }
00469 }//end if enough planes to try fitting the track
00470
00471 //delete the track clusters you found earlier
00472 trackClusterList->Delete();
00473 delete trackClusterList;
00474
00475 for (Int_t iplane=0;iplane<1000;iplane++){
00476 planeClusters=(TObjArray *)planeClusterList.At(iplane);
00477 if(planeClusters){
00478 delete planeClusters;
00479 }
00480 }
00481 // cout << " # for swim " << pFor << " # rev swim " << pRev << " # rev search swim " << pRev2 << endl;
00482 return;
00483 }
|
|
||||||||||||||||||||||||
|
Definition at line 3961 of file AlgFitTrackSR.cxx. References KalmanPlaneSR::GetFilChi2(), KalmanPlaneSR::GetFilCovarianceMatrixValue(), KalmanPlaneSR::GetFilStateValue(), CandFitTrackSRHandle::GetKalmanLast(), CandFitTrackSRHandle::GetKalmanPlane(), TrackClusterSR::GetPlane(), TrackClusterSR::GetPlaneView(), KalmanPlaneSR::GetPreChi2(), TrackClusterSR::GetTPosError(), KalmanPlaneSR::GetTrackCluster(), kdUdZ, kdVdZ, kQoverP, kU, kV, CandFitTrackHandle::SetChi2(), CandFitTrackSRHandle::SetdUdZ(), CandFitTrackSRHandle::SetdVdZ(), CandFitTrackSRHandle::SetEnddUError(), CandFitTrackSRHandle::SetEnddVError(), CandFitTrackSRHandle::SetEndQPError(), CandFitTrackSRHandle::SetEndUError(), CandFitTrackSRHandle::SetEndVError(), CandFitTrackHandle::SetNDOF(), CandFitTrackSRHandle::SetPlaneChi2(), CandFitTrackSRHandle::SetPlanePreChi2(), CandFitTrackSRHandle::SetPlaneQP(), CandTrackHandle::SetTrackPointError(), CandTrackHandle::SetU(), CandTrackHandle::SetV(), CandFitTrackHandle::SetVtxdUError(), CandFitTrackHandle::SetVtxdVError(), CandFitTrackHandle::SetVtxQPError(), CandFitTrackHandle::SetVtxUError(), CandFitTrackHandle::SetVtxVError(), and tc. Referenced by RunAlg(). 03966 {
03967
03968 //loop over the kalman planes to get the first and last ones in each view,
03969 //as well as setting the u, v, du/dz, and dv/dz values for each plane
03970 const KalmanPlaneSR *kp = 0;
03971 TrackClusterSR *tc = 0;
03972 Int_t thisplane = 0;
03973 Double_t thisu[2];
03974 Double_t thisv[2];
03975 Double_t erru2[2];
03976 Double_t errv2[2];
03977 Double_t avgu = 0.;
03978 Double_t avgv = 0.;
03979 Double_t avgdu = 0.;
03980 Double_t avgdv = 0.;
03981 Double_t thisdu[2];
03982 Double_t thisdv[2];
03983 Double_t errdu2[2];
03984 Double_t errdv2[2];
03985
03986 Double_t chi2=0.;
03987 Double_t dchi2 = 0.;
03988 Double_t dprechi2 = 0.;
03989 Double_t thisqp[2];
03990 Double_t thiseqp2[2];
03991 Double_t avgqp = 0.;
03992
03993 for(Int_t index=0; index<=cfh.GetKalmanLast(); ++index){
03994 kp = cfh.GetKalmanPlane(index);
03995 if(kp->GetTrackCluster()->GetPlaneView()==PlaneView::kU) {
03996 if(!kpu0) kpu0 = kp;
03997 kpu1 = kp;
03998 }
03999 if(kp->GetTrackCluster()->GetPlaneView()==PlaneView::kV){
04000 if(!kpv0) kpv0 = kp;
04001 kpv1 = kp;
04002 }
04003
04004 tc = kp->GetTrackCluster();
04005 thisplane = tc->GetPlane();
04006 //loop over the clusters in the track
04007 cfh.SetTrackPointError(thisplane,tc->GetTPosError());
04008
04009 //get the forward and backward values for u and v and the errors
04010 //on those values. the errors have minimum value of 1.e-12
04011 thisu[0] = kp->GetFilStateValue(kU,0);
04012 thisu[1] = kp->GetFilStateValue(kU,1);
04013 thisv[0] = kp->GetFilStateValue(kV,0);
04014 thisv[1] = kp->GetFilStateValue(kV,1);
04015 erru2[0] = TMath::Max(kp->GetFilCovarianceMatrixValue(0,kU,kU), 1.e-12);
04016 erru2[1] = TMath::Max(kp->GetFilCovarianceMatrixValue(1,kU,kU), 1.e-12);
04017 errv2[0] = TMath::Max(kp->GetFilCovarianceMatrixValue(0,kV,kV), 1.e-12);
04018 errv2[1] = TMath::Max(kp->GetFilCovarianceMatrixValue(1,kV,kV), 1.e-12);
04019
04020 //average forward and backward fit values
04021 avgu = (thisu[0]/erru2[0]+thisu[1]/erru2[1])/(1./erru2[0]+1./erru2[1]);
04022 avgv = (thisv[0]/errv2[0]+thisv[1]/errv2[1])/(1./errv2[0]+1./errv2[1]);
04023 //set the u an v values for this plane
04024 cfh.SetU(thisplane,avgu);
04025 cfh.SetV(thisplane,avgv);
04026
04027 thisdu[0] = kp->GetFilStateValue(kdUdZ,0);
04028 thisdu[1] = kp->GetFilStateValue(kdUdZ,1);
04029 thisdv[0] = kp->GetFilStateValue(kdVdZ,0);
04030 thisdv[1] = kp->GetFilStateValue(kdVdZ,1);
04031 errdu2[0] = TMath::Max(kp->GetFilCovarianceMatrixValue(0,kdUdZ,kdUdZ),1.e-12);
04032 errdu2[1] = TMath::Max(kp->GetFilCovarianceMatrixValue(1,kdUdZ,kdUdZ),1.e-12);
04033 errdv2[0] = TMath::Max(kp->GetFilCovarianceMatrixValue(0,kdVdZ,kdVdZ),1.e-12);
04034 errdv2[1] = TMath::Max(kp->GetFilCovarianceMatrixValue(1,kdVdZ,kdVdZ),1.e-12);
04035
04036 // average forward and backward fit values
04037 avgdu = (thisdu[0]/errdu2[0]+thisdu[1]/errdu2[1])/(1./errdu2[0]+1./errdu2[1]);
04038 avgdv = (thisdv[0]/errdv2[0]+thisdv[1]/errdv2[1])/(1./errdv2[0]+1./errdv2[1]);
04039
04040 //set the du/dz and dv/dz values for this plane
04041 cfh.SetdUdZ(thisplane,avgdu);
04042 cfh.SetdVdZ(thisplane,avgdv);
04043
04044 //now do the q/p values
04045 dchi2 = TMath::Max(kp->GetFilChi2(0),kp->GetFilChi2(1));
04046 dprechi2 = TMath::Max(kp->GetPreChi2(0),kp->GetPreChi2(1));
04047 cfh.SetPlaneChi2(thisplane,dchi2);
04048 cfh.SetPlanePreChi2(thisplane,dprechi2);
04049 thisqp[0] = kp->GetFilStateValue(kQoverP,0);
04050 thisqp[1] = kp->GetFilStateValue(kQoverP,1);
04051 thiseqp2[0] = TMath::Max(kp->GetFilCovarianceMatrixValue(0,kQoverP,kQoverP),1.e-12);
04052 thiseqp2[1] = TMath::Max(kp->GetFilCovarianceMatrixValue(1,kQoverP,kQoverP),1.e-12);
04053
04054 if(thisqp[0]==0){
04055 avgqp=thisqp[1];
04056 }
04057 if(thisqp[1]==0){
04058 avgqp=thisqp[0];
04059 }
04060 else
04061 avgqp = (thisqp[0]/thiseqp2[0]+thisqp[1]/thiseqp2[1])/(1./thiseqp2[0]+1./thiseqp2[1]);
04062
04063 cfh.SetPlaneQP(thisplane,avgqp);
04064 chi2 += dchi2;
04065
04066 }//end loop over kalman planes to set u,v,du/dz,dv/dz and find first and last
04067 //planes in each view
04068
04069 //set the track chi^2 for the q/p fit
04070 cfh.SetChi2(chi2);
04071 Int_t nkalmanlast = cfh.GetKalmanLast();
04072
04073 //set the degrees of freedom and the errors for the vtx and end
04074 cfh.SetNDOF(nkalmanlast-4);
04075 cfh.SetVtxUError(TMath::Sqrt(cfh.GetKalmanPlane(0)->GetFilCovarianceMatrixValue(1, kU, kU)));
04076 cfh.SetVtxVError(TMath::Sqrt(cfh.GetKalmanPlane(0)->GetFilCovarianceMatrixValue(1, kV, kV)));
04077 cfh.SetVtxdUError(TMath::Sqrt(cfh.GetKalmanPlane(0)->GetFilCovarianceMatrixValue(1, kdUdZ, kdUdZ)));
04078 cfh.SetVtxdVError(TMath::Sqrt(cfh.GetKalmanPlane(0)->GetFilCovarianceMatrixValue(1, kdVdZ, kdVdZ)));
04079 cfh.SetVtxQPError(TMath::Sqrt(cfh.GetKalmanPlane(0)->GetFilCovarianceMatrixValue(1,kQoverP,kQoverP)));
04080 cfh.SetEndUError(TMath::Sqrt(cfh.GetKalmanPlane(nkalmanlast)->GetFilCovarianceMatrixValue(0,kU,kU)));
04081 cfh.SetEndVError(TMath::Sqrt(cfh.GetKalmanPlane(nkalmanlast)->GetFilCovarianceMatrixValue(0,kV,kV)));
04082 cfh.SetEnddUError(TMath::Sqrt(cfh.GetKalmanPlane(nkalmanlast)->GetFilCovarianceMatrixValue(0,kdUdZ,kdUdZ)));
04083 cfh.SetEnddVError(TMath::Sqrt(cfh.GetKalmanPlane(nkalmanlast)->GetFilCovarianceMatrixValue(0,kdVdZ,kdVdZ)));
04084 cfh.SetEndQPError(TMath::Sqrt(cfh.GetKalmanPlane(nkalmanlast)->GetFilCovarianceMatrixValue(0,kQoverP,kQoverP)));
04085
04086 return;
04087 }
|
|
||||||||||||||||||||
|
Definition at line 2103 of file AlgFitTrackSR.cxx. References CandRecoHandle::GetEndPlane(), CandTrackHandle::GetT(), CandTrackHandle::GetU(), CandTrackHandle::GetV(), CandRecoHandle::GetVtxPlane(), CandTrackHandle::GetZ(), CandTrackHandle::IsTPosValid(), CandRecoHandle::SetDirCosU(), CandRecoHandle::SetDirCosV(), CandRecoHandle::SetDirCosZ(), CandRecoHandle::SetEndDirCosU(), CandRecoHandle::SetEndDirCosV(), CandRecoHandle::SetEndDirCosZ(), CandRecoHandle::SetEndPlane(), CandRecoHandle::SetEndT(), CandRecoHandle::SetEndU(), CandRecoHandle::SetEndV(), CandRecoHandle::SetEndZ(), CandRecoHandle::SetVtxPlane(), CandRecoHandle::SetVtxT(), CandRecoHandle::SetVtxU(), CandRecoHandle::SetVtxV(), and CandRecoHandle::SetVtxZ(). Referenced by RunAlg(). 02106 {
02107 cfh.SetVtxPlane(begPlane);
02108 cfh.SetVtxZ(track0->GetZ(begPlane));
02109
02110 if(begPlane!=cfh.GetVtxPlane() && track0->IsTPosValid(begPlane)) {
02111 cfh.SetVtxU(track0->GetU(begPlane));
02112 cfh.SetVtxV(track0->GetV(begPlane));
02113
02114 cfh.SetVtxT(track0->GetT(begPlane));
02115 if(track0->InheritsFrom("CandTrackSRHandle")){
02116 // CandTrackSR calculates angles at each plane, use those
02117 cfh.SetDirCosU(dynamic_cast<const CandTrackSRHandle *>(track0)->GetDirCosU(begPlane));
02118 cfh.SetDirCosV(dynamic_cast<const CandTrackSRHandle *>(track0)->GetDirCosV(begPlane));
02119 cfh.SetDirCosZ(dynamic_cast<const CandTrackSRHandle *>(track0)->GetDirCosZ(begPlane));
02120 }
02121 }
02122
02123 cfh.SetEndPlane(endPlane);
02124 cfh.SetEndZ(track0->GetZ(endPlane));
02125 if(endPlane!=cfh.GetEndPlane() && track0->IsTPosValid(endPlane)){
02126 cfh.SetEndU(track0->GetU(endPlane));
02127 cfh.SetEndV(track0->GetV(endPlane));
02128 cfh.SetEndT(track0->GetT(endPlane));
02129 if(track0->InheritsFrom("CandTrackSRHandle")){
02130 // CandTrackSR calculates angles at each plane, use those
02131 cfh.SetEndDirCosU(dynamic_cast<const CandTrackSRHandle *>(track0)->GetDirCosU(endPlane));
02132 cfh.SetEndDirCosV(dynamic_cast<const CandTrackSRHandle *>(track0)->GetDirCosV(endPlane));
02133 cfh.SetEndDirCosZ(dynamic_cast<const CandTrackSRHandle *>(track0)->GetDirCosZ(endPlane));
02134 }
02135 }
02136 return;
02137 }
|
|
||||||||||||||||
|
||||||||||||||||||||||||||||
|
Definition at line 1584 of file AlgFitTrackSR.cxx. References done(), fParmMaxAngle, SwimParticle::GetCharge(), SwimParticle::GetDirection(), SwimParticle::GetMomentumModulus(), SwimParticle::GetPosition(), kdUdZ, kdVdZ, kInvSqrt2, kQoverP, MSG, s(), SwimParticle::SetCharge(), SwimSwimmer::SwimBackward(), and SwimSwimmer::SwimForward(). Referenced by CalculatePreState(), CalculatePropagator(), FindNumSkippedPlanes(), and SwimVertexAndEndPoints(). 01587 {
01588
01589 // return false if angles get too large or momentum is too small
01590
01591 //-------------------------------------------------------------------
01592 // Using Swimmer package
01593 //-------------------------------------------------------------------
01594 SwimSwimmer s(*vldc);
01595
01596 // Add an action to the stepper - in this case a debug printout
01597 // SwimPrintStepAction printStep;
01598 // s.GetStepper()->AddStepAction(&printStep);
01599
01600 // Setup the initial condition for the stepper
01601 //the swimmer works in xyz coordinates, not uvz, so need to rotate
01602 //the coordinates before putting them into a position vector
01603 Double_t x = kInvSqrt2*(swimstate[kU]-swimstate[kV]);
01604 Double_t y = kInvSqrt2*(swimstate[kU]+swimstate[kV]);
01605
01606 TVector3 position(x,y,zPos);
01607 double charge = 0.0;
01608
01609 if(swimstate[kQoverP]>0.0) charge = 1.0;
01610 else if(swimstate[kQoverP]<0.0) charge = -1.0;
01611 else{
01612
01613 // infinite momentum, straight line extrapolation
01614 Double_t delz = finalZ - zPos;
01615 state[kU] = swimstate[kU] + swimstate[kdUdZ]*delz;
01616 state[kV] = swimstate[kV] + swimstate[kdVdZ]*delz;
01617 state[kdUdZ] = swimstate[kdUdZ];
01618 state[kdVdZ] = swimstate[kdVdZ];
01619 state[kQoverP] = swimstate[kQoverP];
01620 return 1;
01621 }
01622
01623 double pz;
01624 // forward in time: idir=0; backward in time: idir = 1
01625 // Momentum is always forward in time
01626 if((finalZ>zPos && idir==0) || (finalZ<zPos && idir==1))
01627 pz = 1.0/(TMath::Sqrt(1+swimstate[kdUdZ]*swimstate[kdUdZ]
01628 +swimstate[kdVdZ]*swimstate[kdVdZ])
01629 *TMath::Abs(swimstate[kQoverP]));
01630
01631 else if((finalZ<zPos && idir==0) || (finalZ>zPos && idir==1))
01632 pz = -1.0/(TMath::Sqrt(1+swimstate[kdUdZ]*swimstate[kdUdZ]
01633 +swimstate[kdVdZ]*swimstate[kdVdZ])
01634 *TMath::Abs(swimstate[kQoverP]));
01635 else{
01636 state[kU] = swimstate[kU];
01637 state[kV] = swimstate[kV];
01638 state[kdUdZ] = swimstate[kdUdZ];
01639 state[kdVdZ] = swimstate[kdVdZ];
01640 state[kQoverP] = swimstate[kQoverP];
01641 return 1;
01642 }
01643
01644 //the swimmer works in xyz coordinates, not uvz, so need to rotate
01645 //the coordinates before putting them into a position vector
01646 Double_t dxdz = kInvSqrt2*(swimstate[kdUdZ]-swimstate[kdVdZ]);
01647 Double_t dydz = kInvSqrt2*(swimstate[kdUdZ]+swimstate[kdVdZ]);
01648
01649 TVector3 momentum(pz*dxdz,pz*dydz,pz);
01650 SwimParticle muon(position,momentum);
01651 muon.SetCharge(charge);
01652 SwimZCondition zc(finalZ);
01653 bool done;
01654
01655 if(idir==0) done = s.SwimForward(muon,zc);
01656 else if(idir==1) done = s.SwimBackward(muon,zc);
01657 else abort();
01658
01659 if(muon.GetDirection().Z()==0.0){
01660 state[kU] = swimstate[kU];
01661 state[kV] = swimstate[kV];
01662 state[kdUdZ] = swimstate[kdUdZ];
01663 state[kdVdZ] = swimstate[kdVdZ];
01664 state[kQoverP] = swimstate[kQoverP];
01665 return 0;
01666 }
01667
01668 if(muon.GetMomentumModulus()==0.0){
01669 state[kU] = swimstate[kU];
01670 state[kV] = swimstate[kV];
01671 state[kdUdZ] = swimstate[kdUdZ];
01672 state[kdVdZ] = swimstate[kdVdZ];
01673 state[kQoverP] = swimstate[kQoverP];
01674 return 0;
01675 }
01676
01677 state[kU] = kInvSqrt2*(muon.GetPosition().X()+muon.GetPosition().Y());
01678 state[kV] = kInvSqrt2*(muon.GetPosition().Y()-muon.GetPosition().X());
01679
01680 dxdz = muon.GetDirection().X()/muon.GetDirection().Z();
01681 dydz = muon.GetDirection().Y()/muon.GetDirection().Z();
01682 state[kdUdZ] = kInvSqrt2*(dxdz+dydz);
01683 state[kdVdZ] = kInvSqrt2*(dydz-dxdz);
01684 state[kQoverP] = muon.GetCharge()/muon.GetMomentumModulus();
01685 // MSG("FitTrackSR", Msg::kDebug) << "state = " << state[kU] << " "
01686 // << state[kV] << " "
01687 // << state[kdUdZ] << " "
01688 // << state[kdVdZ] << " "
01689 // << state[kQoverP] << endl;
01690 if(TMath::Abs(state[kdUdZ])>2.*fParmMaxAngle
01691 || TMath::Abs(state[kdVdZ])>2.*fParmMaxAngle
01692 || TMath::Abs(state[kQoverP])>fParmMaxQP){
01693 MSG("FitTrackSR",Msg::kDebug) << "swimming failed, u,v,du/dz,dv,dz/qp = "
01694 << state[kU] << " "
01695 << state[kV] << " "
01696 << state[kdUdZ] << " "
01697 << state[kdVdZ] << " "
01698 << state[kQoverP] << endl;
01699 return 0;
01700 }
01701
01702 return 1;
01703 }
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Definition at line 3661 of file AlgFitTrackSR.cxx. References fDetectorType, fParmLastPlane, fVldContext, CandRecoHandle::GetEndPlane(), KalmanPlaneSR::GetFilStateValue(), TrackClusterSR::GetPlane(), UgliGeomHandle::GetScintPlnHandle(), KalmanPlaneSR::GetTrackCluster(), CandRecoHandle::GetVtxPlane(), UgliPlnHandle::GetZ0(), TrackClusterSR::GetZPos(), UgliScintPlnHandle::IsValid(), PlexPlaneId::IsValid(), kdUdZ, kdVdZ, kInvSqrt2, kU, kV, min(), CandRecoHandle::SetDirCosU(), CandRecoHandle::SetDirCosV(), CandRecoHandle::SetDirCosZ(), CandRecoHandle::SetEndDirCosU(), CandRecoHandle::SetEndDirCosV(), CandRecoHandle::SetEndDirCosZ(), CandFitTrackSRHandle::SetEndExtrapolate(), CandRecoHandle::SetEndPlane(), CandTrackHandle::SetEndTrace(), CandTrackHandle::SetEndTraceZ(), CandRecoHandle::SetEndU(), CandRecoHandle::SetEndV(), CandRecoHandle::SetEndZ(), CandTrackHandle::SetU(), CandTrackHandle::SetV(), CandFitTrackSRHandle::SetVtxExtrapolate(), CandRecoHandle::SetVtxPlane(), CandTrackHandle::SetVtxTrace(), CandTrackHandle::SetVtxTraceZ(), CandRecoHandle::SetVtxU(), CandRecoHandle::SetVtxV(), CandRecoHandle::SetVtxZ(), and Swim(). Referenced by RunAlg(). 03671 {
03672
03673 Double_t swimstate0[5];
03674 Double_t tmpstate[5]; Double_t swimstatez0 = kp0->GetTrackCluster()->GetZPos();
03675 Double_t swimstate1[5];
03676
03677 UgliGeomHandle ugh(fVldContext);
03678
03679 for(Int_t i = 0; i<5; ++i){
03680 tmpstate[i] = 0.;
03681 swimstate0[i] = kp0->GetFilStateValue(i,1);
03682 swimstate1[i] = kp1->GetFilStateValue(i,0);
03683 }
03684
03685 Double_t swimstatez1 = kp1->GetTrackCluster()->GetZPos();
03686 Int_t thisplane = kp0->GetTrackCluster()->GetPlane()-direction;
03687 Double_t thisx = kInvSqrt2*(swimstate0[kU]-swimstate0[kV]);
03688 Double_t thisy = kInvSqrt2*(swimstate0[kU]+swimstate0[kV]);
03689 Double_t thisu = swimstate0[kU];
03690 Double_t thisv = swimstate0[kV];
03691 Double_t thisz = swimstatez0;
03692 Double_t linx = thisx;
03693 Double_t liny = thisy;
03694 Double_t linu = thisu;
03695 Double_t linv = thisv;
03696 Double_t linz = thisz;
03697 Double_t lindx = kInvSqrt2*(swimstate0[kdUdZ]-swimstate0[kdVdZ]);
03698 Double_t lindy = kInvSqrt2*(swimstate0[kdUdZ]+swimstate0[kdVdZ]);
03699 Double_t lindu = swimstate0[kdUdZ];
03700 Double_t lindv = swimstate0[kdVdZ];
03701 Double_t linds = 0.;
03702 Double_t lindz = 0.;
03703 Double_t oldu = 0.;
03704 Double_t oldv = 0.;
03705 Double_t oldz = 0.;
03706 Double_t thisds = 0.;
03707 Double_t thisdz = 0.;
03708 Int_t nplaneskip = 0;
03709 Int_t swimflag = 1;
03710 Bool_t befvtx = 1;
03711 Double_t du = 0.;
03712 Double_t dv = 0.;
03713 Double_t dz = 0.;
03714 Double_t dsdz = 0.;
03715 Double_t delu = 0.;
03716 Double_t delv = 0.;
03717 Double_t delz = 0.;
03718
03719 while(thisplane>=0 && thisplane<=fParmLastPlane
03720 && ((swimflag && TMath::Abs(thisx)<4. && TMath::Abs(thisy)<4. && TMath::Abs(thisu)<4.
03721 && TMath::Abs(thisv)<4.)
03722 || (TMath::Abs(linx)<4. && TMath::Abs(liny)<4. && TMath::Abs(linu)<4.
03723 && TMath::Abs(linv)<4.)
03724 )
03725 ){
03726
03727 PlexPlaneId plexplane(fDetectorType,thisplane,false);
03728 if(plexplane.IsValid()){
03729
03730 UgliScintPlnHandle planeid = ugh.GetScintPlnHandle(plexplane);
03731
03732 if(planeid.IsValid()){
03733
03734 oldu = swimstate0[kU];
03735 oldv = swimstate0[kV];
03736 oldz = swimstatez0;
03737 dz = (Double_t)planeid.GetZ0()-linz;
03738
03739 if(TMath::Abs(linx)<4. && TMath::Abs(liny)<4.
03740 && TMath::Abs(linu)<4. && TMath::Abs(linv)<4.){
03741
03742 linz = (Double_t)planeid.GetZ0();
03743 linx += dz*lindx;
03744 liny += dz*lindy;
03745 linu += dz*lindu;
03746 linv += dz*lindv;
03747 if(!befvtx){
03748 du = dz*lindu;
03749 dv = dz*lindv;
03750 lindz += TMath::Abs(dz);
03751 linds += TMath::Sqrt(du*du+dv*dv+dz*dz);
03752 }
03753 }//end if inside the detector
03754
03755 if(swimflag && TMath::Abs(thisx)<4. && TMath::Abs(thisy)<4.
03756 && TMath::Abs(thisu)<4. && TMath::Abs(thisv)<4.) {
03757
03758 swimflag = Swim(swimstate0,tmpstate,(Double_t)swimstatez0,
03759 (Double_t)planeid.GetZ0(),1, &fVldContext);
03760 swimstatez0 = (Double_t)planeid.GetZ0();
03761 swimstate0[kU] = tmpstate[kU];
03762 swimstate0[kV] = tmpstate[kV];
03763 swimstate0[kdUdZ] = tmpstate[kdUdZ];
03764 swimstate0[kdVdZ] = tmpstate[kdVdZ];
03765 swimstate0[kQoverP] = tmpstate[kQoverP];
03766
03767 if (TMath::Abs(tmpstate[kU])>4. || TMath::Abs(tmpstate[kV])>4.) swimflag = 0;
03768
03769 thisx = kInvSqrt2*(swimstate0[kU]-swimstate0[kV]);
03770 thisy = kInvSqrt2*(swimstate0[kU]+swimstate0[kV]);
03771 thisu = swimstate0[kU];
03772 thisv = swimstate0[kV];
03773 thisz = swimstatez0;
03774
03775 if(!swimflag && nplaneskip<3 && thisplane*direction>=plane0*direction){
03776 if(!thisu) cfh.SetVtxU(thisu);
03777 if(!thisv) cfh.SetVtxV(thisv);
03778 cfh.SetVtxZ(thisz);
03779 cfh.SetVtxPlane(thisplane);
03780 dsdz = TMath::Sqrt(1.+swimstate0[kdUdZ]*swimstate0[kdUdZ]
03781 +swimstate0[kdVdZ]*swimstate0[kdVdZ]);
03782 cfh.SetDirCosU((Double_t)(direction)*swimstate0[kdUdZ]/dsdz);
03783 cfh.SetDirCosV((Double_t)(direction)*swimstate0[kdVdZ]/dsdz);
03784 cfh.SetDirCosZ((Double_t)(direction)/dsdz);
03785 cfh.SetU(thisplane,thisu);
03786 cfh.SetV(thisplane,thisv);
03787
03788 vtxqp = swimstate0[kQoverP];
03789 }//end if swimflag and not too many planes skipped and this plane is beyond the
03790 //vertex
03791 else{
03792 befvtx = 0;
03793 delu = thisu-oldu;
03794 delv = thisv-oldv;
03795 delz = thisz-oldz;
03796 thisds += TMath::Sqrt(delu*delu+delv*delv+delz*delz);
03797 thisdz += TMath::Abs(delz);
03798 }
03799
03800 //look to see if this plane was hit in the slice, if
03801 //not increment the number of skipped planes
03802 if(planepe[thisplane] > 0.) nplaneskip = 0;
03803 else ++nplaneskip;
03804
03805 }//end if in the detector
03806 }//end if planeid is valid
03807 }//end if plexplane is valid
03808
03809 thisplane -= direction;
03810 }//end loop over planes
03811
03812 cfh.SetVtxTrace(min(thisds,linds));
03813 cfh.SetVtxTraceZ(min(thisdz,lindz));
03814
03815 if(kpu0) cfh.SetVtxExtrapolate(TMath::Abs(kpu0->GetTrackCluster()->GetPlane()-cfh.GetVtxPlane()),
03816 PlaneView::kU);
03817 else cfh.SetVtxExtrapolate(-1,PlaneView::kU);
03818
03819 if(kpv0) cfh.SetVtxExtrapolate(TMath::Abs(kpv0->GetTrackCluster()->GetPlane()-cfh.GetVtxPlane()),
03820 PlaneView::kV);
03821 else cfh.SetVtxExtrapolate(-1,PlaneView::kV);
03822
03823 thisplane = kp1->GetTrackCluster()->GetPlane()+direction;
03824 thisx = kInvSqrt2*(swimstate1[kU]-swimstate1[kV]);
03825 thisy = kInvSqrt2*(swimstate1[kU]+swimstate1[kV]);
03826 thisu = swimstate1[kU];
03827 thisv = swimstate1[kV];
03828 thisz = swimstatez1;
03829 linx = thisx;
03830 liny = thisy;
03831 linu = thisu;
03832 linv = thisv;
03833 linz = thisz;
03834 lindx = kInvSqrt2*(swimstate1[kdUdZ]-swimstate1[kdVdZ]);
03835 lindy = kInvSqrt2*(swimstate1[kdUdZ]+swimstate1[kdVdZ]);
03836 lindu = swimstate1[kdUdZ];
03837 lindv = swimstate1[kdVdZ];
03838 linds = 0.;
03839 lindz = 0.;
03840 oldu = 0.;
03841 oldv = 0.;
03842 oldz = 0.;
03843 thisds = 0.;
03844 thisdz = 0.;
03845 nplaneskip = 0;
03846 swimflag = 1;
03847 befvtx = 1;
03848
03849
03850
03851 while(thisplane>=0 && thisplane<=fParmLastPlane
03852 && ((swimflag && TMath::Abs(thisx)<4. && TMath::Abs(thisy)<4.
03853 && TMath::Abs(thisu)<4. && TMath::Abs(thisv)<4.)
03854 || (TMath::Abs(linx)<4. && TMath::Abs(liny)<4. && TMath::Abs(linu)<4.
03855 && TMath::Abs(linv)<4.)
03856 )
03857 ){
03858
03859
03860
03861 PlexPlaneId plexplane(fDetectorType,thisplane,false);
03862 if(plexplane.IsValid()){
03863
03864 UgliScintPlnHandle planeid = ugh.GetScintPlnHandle(plexplane);
03865
03866 if(planeid.IsValid()){
03867 oldu = swimstate1[kU];
03868 oldv = swimstate1[kV];
03869 oldz = swimstatez1;
03870 dz = (Double_t)planeid.GetZ0()-linz;
03871
03872
03873
03874 if(TMath::Abs(linx)<4. && TMath::Abs(liny)<4. && TMath::Abs(linu)<4.
03875 && TMath::Abs(linv)<4.){
03876
03877 linz = (Double_t)planeid.GetZ0();
03878 linx += dz*lindx;
03879 liny += dz*lindy;
03880 linu += dz*lindu;
03881 linv += dz*lindv;
03882 if (!befvtx) {
03883 du = dz*lindu;
03884 dv = dz*lindv;
03885 lindz += TMath::Abs(dz);
03886 linds += TMath::Sqrt(du*du+dv*dv+dz*dz);
03887 }
03888 }//end if in the detector
03889
03890 if(swimflag && TMath::Abs(thisx)<4. && TMath::Abs(thisy)<4.
03891 && TMath::Abs(thisu)<4. && TMath::Abs(thisv)<4.){
03892
03893 swimflag = Swim(swimstate1,tmpstate,(Double_t)swimstatez1,
03894 (Double_t)planeid.GetZ0(),0, &fVldContext);
03895 swimstatez1 = (Double_t)planeid.GetZ0();
03896 swimstate1[kU] = tmpstate[kU];
03897 swimstate1[kV] = tmpstate[kV];
03898 swimstate1[kdUdZ] = tmpstate[kdUdZ];
03899 swimstate1[kdVdZ] = tmpstate[kdVdZ];
03900 swimstate1[kQoverP] = tmpstate[kQoverP];
03901
03902 if (TMath::Abs(tmpstate[kU])>4. || TMath::Abs(tmpstate[kV])>4.) swimflag = 0;
03903
03904 thisx = kInvSqrt2*(swimstate1[kU]-swimstate1[kV]);
03905 thisy = kInvSqrt2*(swimstate1[kU]+swimstate1[kV]);
03906 thisu = swimstate1[kU];
03907 thisv = swimstate1[kV];
03908 thisz = swimstatez1;
03909
03910
03911
03912 if(!swimflag && nplaneskip<3 && thisplane*direction<=plane1*direction){
03913 cfh.SetEndU(thisu);
03914 cfh.SetEndV(thisv);
03915 cfh.SetEndZ(thisz);
03916 cfh.SetEndPlane(thisplane);
03917 dsdz = TMath::Sqrt(1.+swimstate1[kdUdZ]*swimstate1[kdUdZ]
03918 +swimstate1[kdVdZ]*swimstate1[kdVdZ]);
03919 cfh.SetEndDirCosU((Double_t)(direction)*swimstate1[kdUdZ]/dsdz);
03920 cfh.SetEndDirCosV((Double_t)(direction)*swimstate1[kdVdZ]/dsdz);
03921 cfh.SetEndDirCosZ((Double_t)(direction)/dsdz);
03922 cfh.SetU(thisplane,thisu);
03923 cfh.SetV(thisplane,thisv);
03924
03925 }
03926 else {
03927 befvtx = 0;
03928 delu = thisu-oldu;
03929 delv = thisv-oldv;
03930 delz = thisz-oldz;
03931 thisds += TMath::Sqrt(delu*delu+delv*delv+delz*delz);
03932 thisdz += TMath::Abs(delz);
03933 }
03934 if(planepe[thisplane] > 0.) nplaneskip = 0;
03935 else ++nplaneskip;
03936
03937 }//end if in the detector and swimflag
03938 }//end if planeid is valid
03939 }//end if plexplane is valid
03940
03941 thisplane += direction;
03942 }//end loop over planes to find the end
03943
03944 cfh.SetEndTrace(min(thisds,linds));
03945 cfh.SetEndTraceZ(min(thisdz,lindz));
03946 if(kpu1) cfh.SetEndExtrapolate(TMath::Abs(kpu1->GetTrackCluster()->GetPlane()-cfh.GetEndPlane()),
03947 PlaneView::kU);
03948
03949 else cfh.SetEndExtrapolate(-1,PlaneView::kU);
03950
03951 if(kpv1) cfh.SetEndExtrapolate(TMath::Abs(kpv1->GetTrackCluster()->GetPlane()-cfh.GetEndPlane()),
03952 PlaneView::kV);
03953 else cfh.SetEndExtrapolate(-1,PlaneView::kV);
03954
03955 return;
03956 }
|
|
|
Reimplemented from AlgBase. Definition at line 1707 of file AlgFitTrackSR.cxx. 01708 {
01709 }
|
|
|
Definition at line 84 of file AlgFitTrackSR.h. Referenced by AddToFit(), InitializeFit(), and ReverseFit(). |
|
|
Definition at line 42 of file AlgFitTrackSR.h. Referenced by FindNumSkippedPlanes(), RunAlg(), and SwimVertexAndEndPoints(). |
|
|
Definition at line 81 of file AlgFitTrackSR.h. Referenced by RunAlg(). |
|
|
Definition at line 69 of file AlgFitTrackSR.h. Referenced by CalculateNoise(), and InitKalmanFitParameters(). |
|
|
Definition at line 64 of file AlgFitTrackSR.h. Referenced by RemoveBadPointsFromFit(), and RunAlg(). |
|
|
Definition at line 65 of file AlgFitTrackSR.h. Referenced by RemoveBadPointsFromFit(), and RunAlg(). |
|
|
Definition at line 68 of file AlgFitTrackSR.h. Referenced by CalculatePropagator(), and InitKalmanFitParameters(). |
|
|
Definition at line 78 of file AlgFitTrackSR.h. Referenced by InitializeFit(), and RunAlg(). |
|
|