BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
HoughPeak.cxx
Go to the documentation of this file.
1#include "HoughPeak.h"
2#include <fstream>
3#include <sstream>
4
7 // cout<<" HoughPeak destruct" <<endl;
8 for ( int i = 0; i < _houghPeakHitList.size(); i++ )
9 {
10 // delete _houghPeakHitList[i];
11 _houghPeakHitList[i] = NULL;
12 }
13 _houghPeakHitList.clear();
14}
16 if ( this == &other ) return *this;
17 _height = other._height;
18 _theta = other._theta;
19 _rho = other._rho;
20 _thetaBin = other._thetaBin;
21 _rhoBin = other._rhoBin;
22 _isCandiTrack = other._isCandiTrack;
23 _peakNum = other._peakNum;
24 _charge = other._charge;
25 if ( _houghPeakHitList.size() != 0 )
26 {
27 for ( int i = 0; i < _houghPeakHitList.size(); i++ ) { _houghPeakHitList[i] = NULL; }
28 _houghPeakHitList.clear();
29 }
30 _houghPeakHitList = other._houghPeakHitList;
31 // for(int i =0;i<other._houghPeakHitList.size();i++){
32 // const HoughHit* p_hit= new HoughHit( *(other._houghPeakHitList[i]));
33 // _houghPeakHitList.push_back(p_hit);
34 // }
35 return *this;
36}
37
39 if ( _houghPeakHitList.size() != 0 )
40 {
41 for ( int i = 0; i < _houghPeakHitList.size(); i++ ) { _houghPeakHitList[i] = NULL; }
42 _houghPeakHitList.clear();
43 }
44 _height = other._height;
45 _theta = other._theta;
46 _rho = other._rho;
47 _thetaBin = other._thetaBin;
48 _rhoBin = other._rhoBin;
49 _houghPeakHitList = other._houghPeakHitList;
50 _isCandiTrack = other._isCandiTrack;
51 _peakNum = other._peakNum;
52 _charge = other._charge;
53 // for(int i =0;i<other._houghPeakHitList.size();i++){
54 // const HoughHit* p_hit= new HoughHit( *(other._houghPeakHitList[i]));
55 // _houghPeakHitList.push_back(p_hit);
56 // }
57}
58
59HoughPeak::HoughPeak( int itheta, int irho, double theta, double rho,
60 vector<const HoughHit*>** mapHitList, bool isCandiTrack, int peakNum ) {
61 _thetaBin = itheta;
62 _rhoBin = irho;
63 _theta = theta;
64 _rho = rho;
65 _houghPeakHitList = mapHitList[itheta][irho];
66 _isCandiTrack = isCandiTrack;
67 _peakNum = peakNum;
68 // int t_size=mapHitList[itheta][irho].size();
69 // for(int i =0;i<t_size;i++){
70 // const HoughHit* p_hit= new HoughHit( *(mapHitList[itheta][irho][i]));
71 // _houghPeakHitList.push_back(p_hit);
72 // }
73}
74
75HoughPeak::HoughPeak( int height, int itheta, int irho, double theta, double rho,
76 bool isCandiTrack, int peakNum, int charge ) {
77 _height = height;
78 _thetaBin = itheta;
79 _rhoBin = irho;
80 _theta = theta;
81 _rho = rho;
82 // _houghPeakHitList = mapHitList[itheta][irho];
83 _isCandiTrack = isCandiTrack;
84 _peakNum = peakNum;
85 _charge = charge;
86 // collectHits(hitlist);
87}
88
90 int size = _houghPeakHitList.size();
91 if ( size == 0 ) return;
92 cout << "Print hitlist in HoughPeak " << endl;
93 cout << "at center (" << _theta << " ," << _rho << "): " << size << endl;
94 for ( int i = 0; i < size; i++ )
95 {
96 int layer = _houghPeakHitList[i]->getLayerId();
97 int wire = _houghPeakHitList[i]->getWireId();
98 std::cout << "Peak (" << layer << "," << wire << ") " << _houghPeakHitList[i]
99 << std::endl;
100 }
101}
102
103int HoughPeak::getHitNum( int select ) const {
104 int size = _houghPeakHitList.size();
105 int n0, n1, n2, n3, n4, n5, n6;
106 n0 = n1 = n2 = n3 = n4 = n5 = n6 = 0;
107 for ( int i = 0; i < size; i++ )
108 {
109 int cir = _houghPeakHitList[i]->getCirList();
110 int index = _houghPeakHitList[i]->digi()->getTrackIndex();
111 int style = _houghPeakHitList[i]->getStyle();
112 // cout<<"peak compare ("<<_houghPeakHitList[i]->getLayerId()<<" ,"
113 //<<_houghPeakHitList[i]->getWireId()<<"
114 //)"<<endl;
115 n0++;
116 if ( style == 1 ) n1++;
117 if ( style == 2 ) n2++;
118 if ( index < 0 ) n3++;
119 if ( index >= 0 && cir <= 1 && style == 0 ) n4++;
120 if ( index < 0 || cir > 1 ) n5++;
121 if ( index >= 0 && cir == 0 && style == 0 ) n6++;
122 }
123 if ( select == 0 ) return n0;
124 if ( select == 1 ) return n1;
125 if ( select == 2 ) return n2;
126 if ( select == 3 ) return n3;
127 if ( select == 4 ) return n4;
128 if ( select == 5 ) return n5;
129 if ( select == 6 ) return n6;
130 std::cout << "HoughTrack::getHitNum: select " << select << " is out of range, exiting"
131 << std::endl;
132 exit( 1 );
133}
134int HoughPeak::getHitNumA( int select ) const {
135 int size = _houghPeakHitList.size();
136 int n0, n1, n2, n3, n4, n5, n6;
137 n0 = n1 = n2 = n3 = n4 = n5 = n6 = 0;
138 for ( int i = 0; i < size; i++ )
139 {
140 int cir = _houghPeakHitList[i]->getCirList();
141 int index = _houghPeakHitList[i]->digi()->getTrackIndex();
142 int type = _houghPeakHitList[i]->getSlayerType();
143 int style = _houghPeakHitList[i]->getStyle();
144 if ( type == 0 ) n0++;
145 if ( type == 0 && style == 1 ) n1++;
146 if ( type == 0 && style == 2 ) n2++;
147 if ( type == 0 && index < 0 ) n3++;
148 if ( type == 0 && index >= 0 && cir <= 1 && style == 0 ) n4++;
149 if ( type == 0 && ( index < 0 || cir > 1 ) ) n5++;
150 if ( type == 0 && index >= 0 && cir == 0 && style == 0 ) n6++;
151 }
152 if ( select == 0 ) return n0;
153 if ( select == 1 ) return n1;
154 if ( select == 2 ) return n2;
155 if ( select == 3 ) return n3;
156 if ( select == 4 ) return n4;
157 if ( select == 5 ) return n5;
158 if ( select == 6 ) return n6;
159 std::cout << "HoughTrack::getHitNum: select " << select << " is out of range, exiting"
160 << std::endl;
161 exit( 1 );
162}
163int HoughPeak::getHitNumS( int select ) const {
164 int size = _houghPeakHitList.size();
165 int n0, n1, n2, n3, n4, n5, n6;
166 n0 = n1 = n2 = n3 = n4 = n5 = n6 = 0;
167 for ( int i = 0; i < size; i++ )
168 {
169 int cir = _houghPeakHitList[i]->getCirList();
170 int index = _houghPeakHitList[i]->digi()->getTrackIndex();
171 int type = _houghPeakHitList[i]->getSlayerType();
172 int style = _houghPeakHitList[i]->getStyle();
173 if ( type != 0 ) n0++;
174 if ( type != 0 && style == 1 ) n1++;
175 if ( type != 0 && style == 2 ) n2++;
176 if ( type != 0 && index < 0 ) n3++;
177 if ( type != 0 && index >= 0 && cir <= 1 && style == 0 ) n4++;
178 if ( type != 0 && ( index < 0 || cir > 1 ) ) n5++;
179 if ( type != 0 && index >= 0 && cir == 0 && style == 0 ) n6++;
180 }
181 if ( select == 0 ) return n0;
182 if ( select == 1 ) return n1;
183 if ( select == 2 ) return n2;
184 if ( select == 3 ) return n3;
185 if ( select == 4 ) return n4;
186 if ( select == 5 ) return n5;
187 if ( select == 6 ) return n6;
188 std::cout << "HoughTrack::getHitNum: select " << select << " is out of range, exiting"
189 << std::endl;
190 exit( 1 );
191}
192
194
195 double cirr_track = fabs( 1. / ( _rho ) );
196 double cirx_track = ( 1. / _rho ) * cos( _theta );
197 double ciry_track = ( 1. / _rho ) * sin( _theta );
198 std::vector<HoughHit>::const_iterator iter = hitlist.getList().begin();
199 for ( ; iter != hitlist.getList().end(); iter++ )
200 {
201 const HoughHit* hit = &( *iter );
202 int layer = hit->getLayerId();
203 if ( hit->getSlayerType() != 0 ) continue;
204 double cirx_hit = hit->getMidX();
205 double ciry_hit = hit->getMidY();
206 double cirr_hit = hit->getDriftDist();
207 if ( _charge == 1 && ( cirx_track * ciry_hit - ciry_track * cirx_hit >= 0 ) )
208 continue; // suppose charge -1 FIXME
209 if ( _charge == -1 && ( cirx_track * ciry_hit - ciry_track * cirx_hit <= 0 ) )
210 continue; // suppose charge -1 FIXME
211 double l1l2 = sqrt( ( cirx_hit - cirx_track ) * ( cirx_hit - cirx_track ) +
212 ( ciry_hit - ciry_track ) * ( ciry_hit - ciry_track ) );
213 double deltaD = 1.e9; // add initialize 25-05-15
214 if ( l1l2 > cirr_track ) deltaD = l1l2 - cirr_track - cirr_hit;
215 if ( l1l2 <= cirr_track ) deltaD = l1l2 - cirr_track + cirr_hit;
216
217 // cal flight length
218
219 double theta_temp;
220 double l_temp = 1.e9; // add initialize 25-05-15
221 if ( cirx_track == 0 || cirx_hit - cirx_track == 0 ) { theta_temp = 0; }
222 else
223 {
224 theta_temp = M_PI - atan2( ciry_hit - ciry_track, cirx_hit - cirx_track ) +
225 atan2( ciry_track, cirx_track );
226 if ( theta_temp > 2 * M_PI ) { theta_temp = theta_temp - 2 * M_PI; }
227 if ( theta_temp < 0 ) { theta_temp = theta_temp + 2 * M_PI; }
228 }
229 // cout<<" charge "<<_charge <<" "<<theta_temp<<endl;
230 if ( _charge == -1 ) { l_temp = cirr_track * theta_temp; }
231 if ( _charge == 1 )
232 {
233 theta_temp = 2 * M_PI - theta_temp;
234 l_temp = cirr_track * ( theta_temp );
235 }
236 double pt = fabs( ( 1. / _rho ) / 333.567 );
237 // if( fabs(deltaD)<0.2 && l_temp<=35 ) _houghPeakHitList.push_back(hit); //suppose 60MeV
238 // FIXME if( fabs(deltaD)<0.2 && l_temp>35 && l_temp<=45) _houghPeakHitList.push_back(hit);
239
240 if ( pt < 0.06 && fabs( deltaD ) < 0.1 && l_temp <= 35 )
241 _houghPeakHitList.push_back( hit );
242 if ( 0.06 < pt && pt < 0.07 && fabs( deltaD ) < 0.1 && l_temp <= 35 )
243 _houghPeakHitList.push_back( hit );
244 if ( 0.07 < pt && pt < 0.08 && fabs( deltaD ) < 0.1 && l_temp <= 43 )
245 _houghPeakHitList.push_back( hit );
246 if ( 0.08 < pt && pt < 0.09 && fabs( deltaD ) < 0.1 && l_temp <= 43 )
247 _houghPeakHitList.push_back( hit );
248 if ( 0.09 < pt && pt < 0.10 && fabs( deltaD ) < 0.1 && l_temp <= 41 )
249 _houghPeakHitList.push_back( hit );
250 if ( 0.10 < pt && pt < 0.11 && fabs( deltaD ) < 0.1 && l_temp <= 41 )
251 _houghPeakHitList.push_back( hit );
252 if ( 0.11 < pt && pt < 0.12 && fabs( deltaD ) < 0.1 && l_temp <= 41 )
253 _houghPeakHitList.push_back( hit );
254
255 if ( pt < 0.06 && fabs( deltaD ) < 0.1 && l_temp > 35 && l_temp < 45 )
256 _houghPeakHitList.push_back( hit );
257 if ( 0.06 < pt && pt < 0.07 && fabs( deltaD ) < 0.1 && l_temp > 35 && l_temp <= 45 )
258 _houghPeakHitList.push_back( hit );
259 if ( 0.07 < pt && pt < 0.08 && fabs( deltaD ) < 0.1 && l_temp > 43 && l_temp <= 50 )
260 _houghPeakHitList.push_back( hit );
261 if ( 0.08 < pt && pt < 0.09 && fabs( deltaD ) < 0.1 && l_temp > 43 && l_temp <= 50 )
262 _houghPeakHitList.push_back( hit );
263 // if( 0.09<pt&&pt<0.10 && fabs(deltaD)<0. && l_temp>41&& l_temp<=50)
264 //_houghPeakHitList.push_back(hit); if( 0.10<pt&&pt<0.11 && fabs(deltaD)<0. &&
265 // l_temp>80&& l_temp<=105) _houghPeakHitList.push_back(hit); if( 0.11<pt&&pt<0.12 &&
266 // fabs(deltaD)<0. && l_temp>80&& l_temp<=105) _houghPeakHitList.push_back(hit);
267 if ( pt > 0.12 && fabs( deltaD ) < 0.1 ) _houghPeakHitList.push_back( hit );
268 }
269 return _houghPeakHitList.size();
270}
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
int n2
Definition SD0Tag.cxx:59
int n1
Definition SD0Tag.cxx:58
#define M_PI
Definition TConstant.h:4
const std::vector< HoughHit > & getList() const
int getSlayerType() const
Definition HoughHit.h:62
double getDriftDist() const
Definition HoughHit.h:67
double getMidY() const
Definition HoughHit.h:59
double getMidX() const
Definition HoughHit.h:58
int getLayerId() const
Definition HoughHit.h:60
int getHitNumS(int) const
int getHitNum(int) const
HoughPeak & operator=(const HoughPeak &other)
Definition HoughPeak.cxx:15
void printAllHit() const
Definition HoughPeak.cxx:89
int collectHits(const HoughHitList &)
int getHitNumA(int) const