BOSS 7.0.2
BESIII Offline Software System
Loading...
Searching...
No Matches
TrkFundHit.cxx
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: TrkFundHit.cxx,v 1.4 2011/02/17 11:53:41 zhangy Exp $
4//
5// Description:
6//
7// Environment:
8// Software developed for the BaBar Detector at the SLAC B-Factory.
9//
10// Author(s): Steve Schaffner
11//
12// We may want to inline some of these functions some day.
13//
14// Revision History:
15// 20000523 M. Kelsey -- Add concrete printAll() implementation which
16// calls through to subclass print(), then dumps HOT list.
17//------------------------------------------------------------------------
18#include "TrkBase/TrkFundHit.h"
19#include "TrkBase/TrkHitOnTrk.h"
20#include "TrkBase/TrkHitOnTrkIter.h"
21#include "TrkBase/TrkPredicates.h"
22#include <assert.h>
23#include <algorithm>
24#include <iostream>
25// Remove!:
26// MHK Restore, for use in printAll()
27#include "TrkBase/TrkRecoTrk.h"
28using std::endl;
29using std::ostream;
30
31int debug_nHit = 0;
32
34 //std::cout << " @ TrkFundHit constructor: " << ++debug_nHit << " addr: " << this << std::endl;
35}
36
38{
39 //std::cout << " @ ~TrkFundHit() : " << --debug_nHit << " addr: " << this << std::endl;
40 // hitlist cleanup done in derived classes
41}
42
44{
45 assert(_hitList.empty());
46 //std::cout << " @ TrkFundHit copy constructor : " << ++debug_nHit << " addr: " << this << std::endl;
47}
48
51{
52 //std::cout << " @ TrkFundHit operator= : " << debug_nHit << " addr: " << this << std::endl;
53 assert(_hitList.empty());
54 return *this;
55}
56
57const TrkHitOnTrk*
59{
60 // if (hitList->contains(hit)) {
61 // return;
62 // }
63 //FIXME: check hot corresponds to this hit??
64// std::cout << "TrkFundHit setUsedHit "<<((MdcHit*)(hit->hit()))->layernumber()<<" "<<((MdcHit*)(hit->hit()))->wirenumber()<<endl;
65// this->printAll(std::cout);//yzhang debug
66 _hitList.push_back(hit);
67// std::cout << "after push_bak " << std::endl;//yzhang debug
68// printAll(std::cout);//yzhang debug
69
70 return hit;
71}
72
73// return hit if on list, return 0 if not on list...
74const TrkHitOnTrk *
76{
77 //std::cout << " @ setUnusedHit() : " << debug_nHit << " addr: " << this << std::endl;
78 if (_hitList.empty()) return 0;
79 std::vector<const TrkHitOnTrk*>::iterator i=std::find(_hitList.begin(),_hitList.end(),hit);
80 if (i==_hitList.end()) return 0;
81 assert(*i==hit);
82// std::cout << "TrkFundHit setUnusedHit "<<((MdcHit*)(hit->hit()))->layernumber()<<" "<<((MdcHit*)(hit->hit()))->wirenumber()<<endl;
83//this->printAll(std::cout);//yzhang debug
84 _hitList.erase(i);
85 return hit;
86}
87
88int
90{
91 return _hitList.size();
92}
93
94const TrkHitOnTrk*
96{
97 hot_iterator i = std::find_if(begin(), end(),
98 std::bind2nd(TrkBase::Predicates::isHotOnTrack(),trk));
99 return (i==end()?0:i.get());
100}
101
102void
103TrkFundHit::printAll(ostream& os) const
104{
105// print(os); // Call through to get subclass info
106 os << " used by " << nUsedHits() << " HOTs" << endl;
107 if (usedHit()) {
108 for (hot_iterator i=begin(); i != end(); ++i) {
109 i->printAll(os);//yzhang debug
110// os << "\ttrack " << i->parentTrack()->id() << ": ";
111// i->print(os); // NOTE: includes endl!
112 //yzhang debug
113 std::cout << " parentTrack" << std::endl;//yzhang debug
114 i->parentTrack()->printAll(std::cout);
115 //zhangy debug
116 }
117 os << endl;
118 }
119}
int debug_nHit
Definition: TrkFundHit.cxx:31
const TrkHitOnTrk * getHitOnTrack(const TrkRecoTrk *trk) const
Definition: TrkFundHit.cxx:95
const TrkHitOnTrk * setUnusedHit(const TrkHitOnTrk *hit)
Definition: TrkFundHit.cxx:75
virtual void printAll(std::ostream &os) const
std::vector< const TrkHitOnTrk * > _hitList
TrkFundHit::hot_iterator begin() const
TrkHitOnTrkIter< TrkFundHit > hot_iterator
virtual ~TrkFundHit()
Definition: TrkFundHit.cxx:37
int nUsedHits() const
Definition: TrkFundHit.cxx:89
TrkFundHit & operator=(const TrkFundHit &)
Definition: TrkFundHit.cxx:50
const TrkHitOnTrk * setUsedHit(const TrkHitOnTrk *hit)
Definition: TrkFundHit.cxx:58
TrkFundHit::hot_iterator end() const