do the old version ....
478 vector<const TrackingRecHit*> Hits = _Hits;
483 cout <<
"CRackTrajectoryBuilder::AddHit" << endl;
487 vector<TrackingRecHitRange> hitRangeByDet;
490 prevDet = Hits.begin();
492 if ((*prevDet)->geographicalId() == (*iHit)->geographicalId())
495 hitRangeByDet.push_back(make_pair(prevDet, iHit));
498 hitRangeByDet.push_back(make_pair(prevDet, Hits.end()));
519 double chi2min =
theEstimator->estimate(prSt, *bestHit).second;
522 cout <<
"Size " << iHitRange->first - (*iHitRange).second << endl;
526 <<
" " << Hits.end() - iHit << endl;
529 double currChi2 =
theEstimator->estimate(prSt, *tmpHit).second;
530 if (currChi2 < chi2min) {
537 cout << chi2min << endl;
540 cout <<
"chi2 fine : " << chi2min << endl;
543 hits.push_back(bestHit);
544 traj.
push(
TM(prSt, UpdatedState, bestHit, chi2min));
546 edm::LogInfo(
"CosmicTrackFinder") <<
"STATE UPDATED WITH HIT AT POSITION " 548 << bestHit->globalPosition() << UpdatedState <<
" " << traj.
chiSquared();
550 cout <<
"STATE UPDATED WITH HIT AT POSITION " 552 << bestHit->globalPosition() << UpdatedState <<
" " << traj.
chiSquared();
554 cout <<
"State is valid ..." << endl;
557 edm::LogWarning(
"CosmicTrackFinder") <<
" State can not be updated with hit at position " << endl;
560 cout <<
"NOT! UPDATED WITH HIT AT POSITION " 562 << bestHit->globalPosition() << UpdatedState <<
" " << traj.
chiSquared();
575 std::vector<std::pair<TrackingRecHitRangeIterator, TSOS> > trackHitCandidates;
576 std::vector<std::pair<TrackingRecHitRangeIterator, TSOS> >::iterator iHitRange;
577 std::vector<uint32_t> processedDets;
580 trackHitCandidates.clear();
586 if (
find(processedDets.begin(), processedDets.end(), currDet.
rawId()) != processedDets.end())
596 trackHitCandidates.push_back(make_pair(iHit, prSt));
599 if (trackHitCandidates.empty())
603 cout << Hits.size() <<
" (int) trackHitCandidates.begin() " << trackHitCandidates.size() << endl;
605 cout <<
"Before sorting ... " << endl;
608 for (iHitRange = trackHitCandidates.begin(); iHitRange != trackHitCandidates.end(); iHitRange++) {
610 cout << (
tracker->
idToDet((*(iHitRange->first->first))->geographicalId()))->position();
615 stable_sort(trackHitCandidates.begin(),
616 trackHitCandidates.end(),
620 cout <<
"After sorting ... " << endl;
622 for (iHitRange = trackHitCandidates.begin(); iHitRange != trackHitCandidates.end(); iHitRange++) {
624 cout << (
tracker->
idToDet((*(iHitRange->first->first))->geographicalId()))->position();
629 for (iHitRange = trackHitCandidates.begin(); iHitRange != trackHitCandidates.end(); iHitRange++)
633 cout <<
"loop2 " << trackHitCandidates.size() <<
" " << trackHitCandidates.end() - iHitRange << endl;
637 TSOS currPrSt = (*iHitRange).second;
640 cout <<
"curr position" << bestHit->globalPosition();
641 for (
TrackingRecHitIterator iHit = (*iHitRange).first->first + 1; iHit != iHitRange->first->second; iHit++) {
644 cout <<
"curr position" << tmpHit->globalPosition();
648 cout <<
"Cross check end ..." << endl;
655 for (iHitRange = trackHitCandidates.begin(); iHitRange != trackHitCandidates.end();
660 cout <<
"loop2 " << trackHitCandidates.size() <<
" " << trackHitCandidates.end() - iHitRange << endl;
669 cout <<
"curr position A" << bestHit->globalPosition() << endl;
670 TSOS currPrSt = (*iHitRange).second;
671 double chi2min =
theEstimator->estimate(currPrSt, *bestHit).second;
674 cout <<
"Size " << iHitRange->first->second - (*iHitRange).first->first << endl;
675 for (
TrackingRecHitIterator iHit = (*iHitRange).first->first + 1; iHit != iHitRange->first->second; iHit++) {
678 <<
" " << Hits.end() - iHit << endl;
682 cout <<
"curr position B" << tmpHit->globalPosition() << endl;
683 double currChi2 =
theEstimator->estimate(currPrSt, *tmpHit).second;
684 if (currChi2 < chi2min) {
686 cout <<
"Is best hit" << endl;
699 cout << chi2min << endl;
703 cout <<
"chi2 fine : " << chi2min << endl;
708 hits.push_back(bestHit);
709 traj.
push(
TM(currPrSt, UpdatedState, bestHit, chi2min));
711 edm::LogInfo(
"CosmicTrackFinder") <<
"STATE UPDATED WITH HIT AT POSITION " 715 cout <<
"Added Hit" << bestHit->globalPosition() << endl;
717 cout <<
"State is valid ..." << UpdatedState << endl;
733 <<
" State can not be updated with hit at position " << bestHit->globalPosition();
741 cout <<
" continue 1 " << endl;
747 cout <<
" continue 2 " << endl;
750 while (iHitRange != trackHitCandidates.end());
std::vector< TrackingRecHitRange >::iterator TrackingRecHitRangeIterator
friend class CompareDetByTraj
Chi2MeasurementEstimator * theEstimator
constexpr uint32_t rawId() const
get the raw id
GlobalPoint globalPosition() const
const TransientTrackingRecHitBuilder * RHBuilder
TransientTrackingRecHit::RecHitContainer hits
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const Plane & surface() const
The nominal surface of the GeomDet.
std::vector< const TrackingRecHit * >::iterator TrackingRecHitIterator
TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const override
edm::ESHandle< TrackerGeometry > tracker
TrajectoryMeasurement const & lastMeasurement() const
std::shared_ptr< TrackingRecHit const > RecHitPointer
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
const TrackerGeomDet * idToDet(DetId) const override
TrajectoryStateOnSurface const & updatedState() const
DetId geographicalId() const
void push(const TrajectoryMeasurement &tm)