BOSS 7.0.2
BESIII Offline Software System
Loading...
Searching...
No Matches
THistogram Class Reference

A class for a histogram used in tracking. More...

#include <THistogram.h>

Public Member Functions

 THistogram (unsigned nBins)
 Constructor.
 
virtual ~THistogram ()
 Destructor.
 
void dump (const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
 dumps debug information.
 
const AList< TMLink > *const bin (unsigned i) const
 returns a pointer to i'th AList<TMLink>.
 
const AList< TMLink > *const bin (int i) const
 returns a pointer to i'th AList<TMLink>.
 
unsigned nBin (unsigned i) const
 returns number in i'th bin.
 
unsigned nBins (void) const
 returns # of bins.
 
AList< TMLinkcontents (unsigned center, unsigned width) const
 returns an AList of TMLinks within 'center' bin +- 'width' bin region.
 
AList< TMLinkcontents (int start, int end) const
 returns an AList of TMLinks from 'start' bin to 'end' bin region.
 
const AList< TMLink > & contents (void) const
 returns an AList<TMLink> of all contents.
 
AList< TSegment0clusters0 (void) const
 returns an AList<TSegment0> of clusters.
 
AList< TSegmentclusters (void) const
 returns an AList<TSegment0> of clusters.
 
AList< TSegment0segments0 (void) const
 returns an AList<TSegment0> using clusters() function.
 
AList< TSegmentsegments (void) const
 returns an AList<TSegment0> using clusters() function.
 
void fillX (const AList< TMLink > &links)
 fills with hits.
 
void fillY (const AList< TMLink > &links)
 fills with hits.
 
void fillPhi (const AList< TMLink > &links)
 fills with hits.
 
void remove (const AList< TMLink > &links)
 removes links.
 
void mask (unsigned binN)
 masks a bin. Masked bin will not be returned by ::findPeak.
 
void unmask (void)
 remove masks.
 
 THistogram (unsigned nBins)
 Constructor.
 
virtual ~THistogram ()
 Destructor.
 
void dump (const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
 dumps debug information.
 
const AList< TMLink > *const bin (unsigned i) const
 returns a pointer to i'th AList<TMLink>.
 
const AList< TMLink > *const bin (int i) const
 returns a pointer to i'th AList<TMLink>.
 
unsigned nBin (unsigned i) const
 returns number in i'th bin.
 
unsigned nBins (void) const
 returns # of bins.
 
AList< TMLinkcontents (unsigned center, unsigned width) const
 returns an AList of TMLinks within 'center' bin +- 'width' bin region.
 
AList< TMLinkcontents (int start, int end) const
 returns an AList of TMLinks from 'start' bin to 'end' bin region.
 
const AList< TMLink > & contents (void) const
 returns an AList<TMLink> of all contents.
 
AList< TSegment0clusters0 (void) const
 returns an AList<TSegment0> of clusters.
 
AList< TSegmentclusters (void) const
 returns an AList<TSegment0> of clusters.
 
AList< TSegment0segments0 (void) const
 returns an AList<TSegment0> using clusters() function.
 
AList< TSegmentsegments (void) const
 returns an AList<TSegment0> using clusters() function.
 
void fillX (const AList< TMLink > &links)
 fills with hits.
 
void fillY (const AList< TMLink > &links)
 fills with hits.
 
void fillPhi (const AList< TMLink > &links)
 fills with hits.
 
void remove (const AList< TMLink > &links)
 removes links.
 
void mask (unsigned binN)
 masks a bin. Masked bin will not be returned by ::findPeak.
 
void unmask (void)
 remove masks.
 

Detailed Description

A class for a histogram used in tracking.

Definition at line 34 of file InstallArea/include/TrkReco/TrkReco/THistogram.h.

Constructor & Destructor Documentation

◆ THistogram() [1/2]

THistogram::THistogram ( unsigned  nBins)

Constructor.

Definition at line 19 of file THistogram.cxx.

19 : _nBins(nBins) {
20 _binSize = 2. * M_PI / (float) _nBins;
21 _bins = (unsigned *) malloc(_nBins * sizeof(unsigned));
22 _masks = (bool *) malloc(_nBins * sizeof(bool));
23 _links = (AList<TMLink> **) malloc(_nBins * sizeof(AList<TMLink> *));
24 for (unsigned i = 0; i < _nBins; i++) {
25 _bins[i] = 0;
26 _masks[i] = false;
27 _links[i] = new AList<TMLink>;
28 }
29}
#define M_PI
Definition: TConstant.h:4
unsigned nBins(void) const
returns # of bins.

◆ ~THistogram() [1/2]

THistogram::~THistogram ( )
virtual

Destructor.

Definition at line 31 of file THistogram.cxx.

31 {
32 free(_bins);
33 free(_masks);
34 for (unsigned i = 0; i < _nBins; i++)
35 delete _links[i];
36 free(_links);
37}

◆ THistogram() [2/2]

THistogram::THistogram ( unsigned  nBins)

Constructor.

◆ ~THistogram() [2/2]

virtual THistogram::~THistogram ( )
virtual

Destructor.

Member Function Documentation

◆ bin() [1/4]

const AList< TMLink > *const THistogram::bin ( int  i) const
inline

returns a pointer to i'th AList<TMLink>.

Definition at line 129 of file InstallArea/include/TrkReco/TrkReco/THistogram.h.

129 {
130 while (i < 0) i += _nBins;
131 return _links[i % _nBins];
132}

◆ bin() [2/4]

const AList< TMLink > *const THistogram::bin ( int  i) const

returns a pointer to i'th AList<TMLink>.

◆ bin() [3/4]

const AList< TMLink > *const THistogram::bin ( unsigned  i) const
inline

returns a pointer to i'th AList<TMLink>.

Definition at line 122 of file InstallArea/include/TrkReco/TrkReco/THistogram.h.

122 {
123 if (i < _nBins) return _links[i];
124 return 0;
125}

◆ bin() [4/4]

const AList< TMLink > *const THistogram::bin ( unsigned  i) const

returns a pointer to i'th AList<TMLink>.

◆ clusters() [1/2]

AList< TSegment > THistogram::clusters ( void  ) const

returns an AList<TSegment0> of clusters.

Definition at line 229 of file THistogram.cxx.

229 {
230 AList<TSegment> list;
231// std::cout<<"enter clusters"<<std::endl;
232 //...Serach for empty bin...
233 unsigned begin = 0;
234 while (_bins[begin] > 0)begin++;
235 if (begin == _nBins) return list;
236
237 //...Start searching...
238 unsigned loop = 0;
239 while (loop < _nBins) {
240 ++loop;
241 unsigned id = (begin + loop) % _nBins;
242 if (_bins[id]) {
243 unsigned size = 0;
244 TSegment * c = new TSegment();
245 while (_bins[id]) {
246 if (_bins[id]) ++size;
247 c->append(* _links[id]);
248 ++loop;
249 id = (begin + loop) % _nBins;
250 if (loop == _nBins) break;
251 }
252 list.append(c);
253 }
254 }
255 return list;
256}
A class to relate TMDCWireHit and TTrack objects.
void append(TMLink &)
appends a TMLink.
Definition: TTrackBase.cxx:362

Referenced by segments().

◆ clusters() [2/2]

AList< TSegment > THistogram::clusters ( void  ) const

returns an AList<TSegment0> of clusters.

◆ clusters0() [1/2]

AList< TSegment0 > THistogram::clusters0 ( void  ) const

returns an AList<TSegment0> of clusters.

Definition at line 162 of file THistogram.cxx.

162 {
163 AList<TSegment0> list;
164
165 //...Serach for empty bin...
166 unsigned begin = 0;
167 while (_bins[begin] > 0) begin++;
168 if (begin == _nBins) return list;
169
170 //...Start searching...
171 unsigned loop = 0;
172 while (loop < _nBins) {
173 ++loop;
174 unsigned id = (begin + loop) % _nBins;
175 if (_bins[id]) {
176 unsigned size = 0;
177 TSegment0 * c = new TSegment0();
178 while (_bins[id]) {
179 if (_bins[id]) ++size;
180 c->append(* _links[id]);
181 ++loop;
182 id = (begin + loop) % _nBins;
183 if (loop == _nBins) break;
184 }
185 list.append(c);
186 }
187 }
188 return list;
189}
A class to relate TMDCWireHit and TTrack objects.

Referenced by TFastFinder::doit(), TConformalFinder0::findClusters(), TConformalFinder0::findClusters2(), and segments0().

◆ clusters0() [2/2]

AList< TSegment0 > THistogram::clusters0 ( void  ) const

returns an AList<TSegment0> of clusters.

◆ contents() [1/6]

AList< TMLink > THistogram::contents ( int  start,
int  end 
) const

returns an AList of TMLinks from 'start' bin to 'end' bin region.

Definition at line 154 of file THistogram.cxx.

154 {
155 AList<TMLink> links;
156 for (int i = start; i <= end; i++)
157 links.append(* bin(i));
158 return links;
159}
*******INTEGER m_nBinMax INTEGER m_NdiMax !No of bins in histogram for cell exploration division $ !Last vertex $ !Last active cell $ !Last cell in buffer $ !No of sampling when dividing cell $ !No of function total $ !Flag for random ceel for $ !Flag for type of for WtMax $ !Flag which decides whether vertices are included in the sampling $ entire domain is hyp !Maximum effective eevents per bin
Definition: FoamA.h:85

◆ contents() [2/6]

AList< TMLink > THistogram::contents ( int  start,
int  end 
) const

returns an AList of TMLinks from 'start' bin to 'end' bin region.

◆ contents() [3/6]

AList< TMLink > THistogram::contents ( unsigned  center,
unsigned  width 
) const

returns an AList of TMLinks within 'center' bin +- 'width' bin region.

Definition at line 143 of file THistogram.cxx.

143 {
144 AList<TMLink> links;
145 for (int i = - (int) width;
146 i <= (int) width;
147 i++) {
148 links.append(* bin((int) center + i));
149 }
150 return links;
151}

◆ contents() [4/6]

AList< TMLink > THistogram::contents ( unsigned  center,
unsigned  width 
) const

returns an AList of TMLinks within 'center' bin +- 'width' bin region.

◆ contents() [5/6]

const AList< TMLink > & THistogram::contents ( void  ) const
inline

returns an AList<TMLink> of all contents.

Definition at line 154 of file InstallArea/include/TrkReco/TrkReco/THistogram.h.

154 {
155 return _all;
156}

◆ contents() [6/6]

const AList< TMLink > & THistogram::contents ( void  ) const

returns an AList<TMLink> of all contents.

◆ dump() [1/2]

void THistogram::dump ( const std::string &  message = std::string(""),
const std::string &  prefix = std::string("") 
) const

dumps debug information.

Definition at line 40 of file THistogram.cxx.

40 {
41 std::cout << pre;
42 std::cout << "THistogram dump:#bins=" << _nBins << std::endl;
43 unsigned nLoops = _nBins / 15 + 1;
44 unsigned n0 = 0;
45 unsigned n1 = 0;
46 for (unsigned i = 0; i < nLoops; i++) {
47 for (unsigned j = 0; j < 15; j++) {
48 if (n0 == _nBins) break;
49 printf("%4d", n0);
50 ++n0;
51 }
52 std::cout << std::endl;
53 for (unsigned j = 0; j < 15; j++) {
54 if (n1 == _nBins) break;
55 if (! _masks[n1]) printf("%4d", _bins[n1]);
56 else printf("-%3d", _bins[n1]);
57 ++n1;
58 }
59 std::cout << std::endl;
60 }
61
62 if (msg.find("detail") != std::string::npos) {
63 for (unsigned i = 0; i < _nBins; i++) {
64 std::cout << "bin " << i << " : ";
65 for (unsigned j = 0; j < _links[i]->length(); j++) {
66 std::cout << (* _links[i])[j]->wire()->name() << ",";
67 }
68 std::cout << std::endl;
69 }
70 }
71
72 return;
73}
int n1
Definition: SD0Tag.cxx:54

◆ dump() [2/2]

void THistogram::dump ( const std::string &  message = std::string(""),
const std::string &  prefix = std::string("") 
) const

dumps debug information.

◆ fillPhi() [1/2]

void THistogram::fillPhi ( const AList< TMLink > &  links)

fills with hits.

Definition at line 111 of file THistogram.cxx.

111 {
112 _all = (AList<TMLink> &) links;
113 unsigned nLinks = links.length();
114 double offset = _binSize / 4.;
115 for (unsigned i = 0; i < nLinks; i++) {
116 TMLink * l = links[i];
117 const HepPoint3D & p = l->position();
118 float phi = atan2(p.y(), p.x()) + M_PI;
119// std::cout<<"atan "<<atan2(-1., -1.)<<std::endl;
120 unsigned pos = (unsigned) floor((phi + offset) / _binSize);
121
122// std::cout <<"layer "<<l->wire()->layerId()<<" cell "<<l->wire()->localId()
123// <<" x "<<p.x()<<" y "<<p.y()<<" pos "<<pos<<" xypos hit "<<l->hit()->xyPosition()<<" xypos wire "<<l->wire()->xyPosition()<<" drift "<<l->hit()->drift(0)<< "+-" <<l->hit()->dDrift(0)<<std::endl;
124// std::cout<<"binsize "<<_binSize<<" offset "<<offset<<" phi "<<phi<<std::endl;
125 //...Why is this needed?...
126 pos %= _nBins;
127
128 ++_bins[pos];
129 _links[pos]->append(l);
130 }
131}

◆ fillPhi() [2/2]

void THistogram::fillPhi ( const AList< TMLink > &  links)

fills with hits.

◆ fillX() [1/2]

void THistogram::fillX ( const AList< TMLink > &  links)

fills with hits.

Definition at line 76 of file THistogram.cxx.

76 {
77 _all = (AList<TMLink> &) links;
78 unsigned nLinks = links.length();
79 double offset = _binSize / 4.;
80 for (unsigned i = 0; i < nLinks; i++) {
81 TMLink * l = links[i];
82 const HepPoint3D & p = l->position();
83 unsigned pos = (unsigned) floor((p.x() + offset) / _binSize);
84
85 //...Why is this needed?...
86 pos %= _nBins;
87
88 ++_bins[pos];
89 _links[pos]->append(l);
90 }
91}

Referenced by TFastFinder::doit(), and TConformalFinder0::findSegments().

◆ fillX() [2/2]

void THistogram::fillX ( const AList< TMLink > &  links)

fills with hits.

◆ fillY() [1/2]

void THistogram::fillY ( const AList< TMLink > &  links)

fills with hits.

Definition at line 94 of file THistogram.cxx.

94 {
95 _all = (AList<TMLink> &) links;
96 unsigned nLinks = links.length();
97 for (unsigned i = 0; i < nLinks; i++) {
98 TMLink * l = links[i];
99 const HepPoint3D & p = l->position();
100 unsigned pos = (unsigned) floor(p.y() / _binSize);
101
102 //...Why is this needed?...
103 pos %= _nBins;
104
105 ++_bins[pos];
106 _links[pos]->append(l);
107 }
108}

◆ fillY() [2/2]

void THistogram::fillY ( const AList< TMLink > &  links)

fills with hits.

◆ mask() [1/2]

void THistogram::mask ( unsigned  binN)
inline

masks a bin. Masked bin will not be returned by ::findPeak.

Definition at line 142 of file InstallArea/include/TrkReco/TrkReco/THistogram.h.

142 {
143 _masks[a] = true;
144}

◆ mask() [2/2]

void THistogram::mask ( unsigned  binN)

masks a bin. Masked bin will not be returned by ::findPeak.

◆ nBin() [1/2]

unsigned THistogram::nBin ( unsigned  i) const
inline

returns number in i'th bin.

Definition at line 160 of file InstallArea/include/TrkReco/TrkReco/THistogram.h.

160 {
161 if (i < _nBins) return _bins[i];
162 return 0;
163}

◆ nBin() [2/2]

unsigned THistogram::nBin ( unsigned  i) const

returns number in i'th bin.

◆ nBins() [1/2]

unsigned THistogram::nBins ( void  ) const
inline

returns # of bins.

Definition at line 136 of file InstallArea/include/TrkReco/TrkReco/THistogram.h.

136 {
137 return _nBins;
138}

◆ nBins() [2/2]

unsigned THistogram::nBins ( void  ) const

returns # of bins.

◆ remove() [1/2]

void THistogram::remove ( const AList< TMLink > &  links)

removes links.

Definition at line 134 of file THistogram.cxx.

134 {
135 for (unsigned i = 0; i < _nBins; i++) {
136 _links[i]->remove(links);
137 _bins[i] = _links[i]->length();
138 }
139 _all.remove(links);
140}

◆ remove() [2/2]

void THistogram::remove ( const AList< TMLink > &  links)

removes links.

◆ segments() [1/2]

AList< TSegment > THistogram::segments ( void  ) const

returns an AList<TSegment0> using clusters() function.

Definition at line 259 of file THistogram.cxx.

259 {
260 //yuany
261 /*
262 for (unsigned i = 0; i < _nBins; i++) {
263 std::cout<<"i "<<i<<" bins[i] "<<_bins[i]<<std::endl;
264 }
265 */
266 //...Obtain raw clusters...
267 AList<TSegment> list = clusters();
268 unsigned n = list.length();
269 if (n == 0) return list;
270
271 //...Examine each cluster...
272 AList<TSegment> splitted;
273 for (unsigned i = 0; i < n; i++) {
274 TSegment * c = list[i];
275
276#ifdef TRKRECO_DEBUG_DETAIL
277 std::cout << " base segment : ";
278 c->dump("hits");
279#endif
280
281 AList<TSegment> newClusters = c->split();
282 if (newClusters.length() == 0) {
283#ifdef TRKRECO_DEBUG_DETAIL
284 std::cout << " ... Solving dual hits" << std::endl;
285#endif
286 c->solveDualHits();
287 continue;
288 }
289
290 list.append(newClusters);
291 splitted.append(c);
292#ifdef TRKRECO_DEBUG_DETAIL
293 c->dump("hits", " ");
294 std::cout << " ... splitted as" << std::endl;
295 for (unsigned j = 0; j < newClusters.length(); j++) {
296 std::cout << " " << j << " : ";
297 newClusters[j]->dump("hits");
298 }
299#endif
300 }
301 list.remove(splitted);
302 HepAListDeleteAll(splitted);
303
304 //yuany
305// n = list.length();
306// for (unsigned i = 0; i < n; i++) {
307// TSegment * c = list[i];
308// std::cout << " base segment : ";
309// c->dump("hits");
310// }
311
312 return list;
313}
const Int_t n
AList< TSegment > clusters(void) const
returns an AList<TSegment0> of clusters.
Definition: THistogram.cxx:229
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
Definition: TSegment.cxx:116
AList< TSegment > split(void) const
returns a list of sub TSegments in this cluster. If cluster type is 1, 2, or 7, no cluster is returne...
Definition: TSegment.cxx:388
int solveDualHits(void)
Definition: TSegment.cxx:736

◆ segments() [2/2]

AList< TSegment > THistogram::segments ( void  ) const

returns an AList<TSegment0> using clusters() function.

◆ segments0() [1/2]

AList< TSegment0 > THistogram::segments0 ( void  ) const

returns an AList<TSegment0> using clusters() function.

Definition at line 192 of file THistogram.cxx.

192 {
193
194 //...Obtain raw clusters...
196 unsigned n = list.length();
197 if (n == 0) return list;
198
199 //...Examine each cluster...
200 AList<TSegment0> splitted;
201 for (unsigned i = 0; i < n; i++) {
202 TSegment0 * c = list[i];
203
204 AList<TSegment0> newClusters = c->split();
205 if (newClusters.length() == 0) {
206 c->solveDualHits();
207 continue;
208 }
209
210 list.append(newClusters);
211 splitted.append(c);
212#ifdef TRKRECO_DEBUG_DETAIL
213 c->dump("hits", " ");
214 std::cout << " ... splitted as" << std::endl;
215 for (unsigned j = 0; j < newClusters.length(); j++) {
216 std::cout << " " << j << " : ";
217 newClusters[j]->dump("hits");
218 }
219#endif
220 }
221 list.remove(splitted);
222 HepAListDeleteAll(splitted);
223
224 return list;
225
226}
AList< TSegment0 > clusters0(void) const
returns an AList<TSegment0> of clusters.
Definition: THistogram.cxx:162
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
Definition: TSegment0.cxx:51
int solveDualHits(void)
Definition: TSegment0.cxx:624
AList< TSegment0 > split(void) const
returns a list of sub TSegments in this cluster. If cluster type is 1, 2, or 7, no cluster is returne...
Definition: TSegment0.cxx:281

◆ segments0() [2/2]

AList< TSegment0 > THistogram::segments0 ( void  ) const

returns an AList<TSegment0> using clusters() function.

◆ unmask() [1/2]

void THistogram::unmask ( void  )
inline

remove masks.

Definition at line 148 of file InstallArea/include/TrkReco/TrkReco/THistogram.h.

148 {
149 for (unsigned i = 0; i < _nBins; i++) _masks[i] = false;
150}

◆ unmask() [2/2]

void THistogram::unmask ( void  )

remove masks.


The documentation for this class was generated from the following files: