3 #include <ktracker/SRecEvent.h>
22 if (do_assert) assert(trk);
64 if (name.substr(0, det_name.size()) != det_name)
continue;
105 std::vector<int>
UtilTrack::FindMatchedRoads(
const TVector3 pos1,
const TLorentzVector mom1,
const TVector3 pos3,
const TLorentzVector mom3,
const double margin)
108 double y_st1 = pos1.Y();
109 double y_st3 = pos3.Y();
110 int top_bot = y_st3>0 ? +1 : -1;
111 if (
verbosity > 0) cout <<
"UtilTrack::FindMatchedRoads(): y_st1=" << y_st1 <<
" y_st3=" << y_st3 <<
" top_bot=" << top_bot << endl;
113 vector<int> list_ele_id[5];
114 for (
int st = 1; st <= 4; st++) {
115 string det_name = (string)
"H" + (
char)(
'0'+st) + (top_bot>0 ?
'T' :
'B');
118 double x_det = det->
xc + det->
deltaX;
120 double z_det = det->
zc + det->
deltaZ;
124 if (
verbosity > 2) cout <<
" st" << st <<
":";
125 if (
verbosity > 3) cout <<
" x_det=" << x_det <<
" n_ele=" << n_ele <<
" space=" << space <<
" width=" << width;
127 const TVector3* pos = (st == 1 ? &pos1 : &pos3);
128 const TLorentzVector* mom = (st == 1 ? &mom1 : &mom3);
129 double x_trk = pos->X() + (z_det - pos->Z()) * mom->X() / mom->Z();
130 double y_trk = pos->Y() + (z_det - pos->Z()) * mom->Y() / mom->Z();
133 int ele_cent = (int)((n_ele+1)/2.0 + (x_trk-x_det)/space + 0.5);
134 if (
verbosity > 2) cout <<
" x_trk=" << x_trk <<
" y_trk=" << y_trk;
137 for (
int i_ele = ele_cent - 1; i_ele <= ele_cent + 1; i_ele++) {
138 if (i_ele <= 0 || i_ele > n_ele)
continue;
139 double x_ele = x_det + space * (i_ele - (n_ele+1)/2.0);
140 if (
verbosity > 2) cout <<
" [ele=" << i_ele <<
" x=" << x_ele;
141 if (
verbosity > 3) cout <<
" edge=" << (width/2-fabs(x_trk-x_ele));
143 if (fabs(x_trk - x_ele) < width/2 + margin) list_ele_id[st].push_back(i_ele);
147 vector<int> list_road_id;
148 for (
auto it1 = list_ele_id[1].begin(); it1 != list_ele_id[1].end(); it1++) {
149 for (
auto it2 = list_ele_id[2].begin(); it2 != list_ele_id[2].end(); it2++) {
150 for (
auto it3 = list_ele_id[3].begin(); it3 != list_ele_id[3].end(); it3++) {
151 for (
auto it4 = list_ele_id[4].begin(); it4 != list_ele_id[4].end(); it4++) {
152 if (
verbosity > 0) cout <<
" road " << *it1 <<
" " << *it2 <<
" " << *it3 <<
" " << *it4;
User interface class about the geometry of detector planes.
int getDetectorID(const std::string &detectorName) const
Get the plane position.
static GeomSvc * instance()
singlton instance
Plane * getPlanePtr(int detectorID)
std::string getDetectorName(const int &detectorID) const
An SQ interface class to hold a list of SQHit objects.
virtual SQHitVector * Clone() const =0
std::vector< SQHit * >::const_iterator ConstIter
virtual ConstIter end() const =0
virtual ConstIter begin() const =0
virtual void push_back(const SQHit *hit)=0
An SQ interface class to hold one detector hit.
virtual short get_detector_id() const
Return the detector ID of this hit.
virtual int get_track_id() const
Return the track ID associated with this hit. Probably the value is not properly set at present.
An SQ interface class to hold a list of SQTrack objects.
virtual ConstIter begin() const =0
virtual ConstIter end() const =0
std::vector< SQTrack * >::const_iterator ConstIter
An SQ interface class to hold one true or reconstructed track.
virtual int get_track_id() const =0
Return the track ID, which is unique per event(?).
virtual TVector3 get_pos_st3() const
Return the track position at Station 3.
virtual TLorentzVector get_mom_st3() const
Return the track momentum at Station 3.
virtual TVector3 get_pos_st1() const
Return the track position at Station 1.
virtual TLorentzVector get_mom_st1() const
Return the track momentum at Station 1.
SQHitVector * FindDetectorHitsOfTrack(const SQHitVector *vec_in, const int id_trk, const std::string det_name)
Find track-associated hits whose detector name starts with 'det_name'.
std::vector< int > FindMatchedRoads(SRecTrack *trk, const double margin=0)
Find all roads that match to the given track within the hodo paddle width plus the given margin.
SQHitVector * FindHodoHitsOfTrack(const SQHitVector *vec_in, const int id_trk)
Find all hodoscope hits hits associated with the given track.
SQHitVector * FindHitsOfTrack(const SQHitVector *vec_in, const int id_trk)
Find all hits associated with the given track.
SQTrack * FindTrackByID(const SQTrackVector *vec, const int id_trk, const bool do_assert=false)
Find a track by track ID in the given track list.
int Hodo2Road(const int h1, const int h2, const int h3, const int h4, const int tb)
Convert a set of hodo IDs to a roadset ID.