Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

THistogram Class Reference

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

#include <THistogram.h>

List of all members.

Public Member Functions

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

Private Attributes

AList< TMLink_all
AList< TMLink_all
unsigned * _bins
unsigned * _bins
float _binSize
AList< TMLink > ** _links
AList< TMLink > ** _links
bool_masks
bool_masks
unsigned _nBins


Detailed Description

A class for a histogram used in tracking.


Constructor & Destructor Documentation

THistogram::THistogram unsigned  nBins  ) 
 

Constructor.

00019                                      : _nBins(nBins) {
00020     _binSize = 2. * M_PI / (float) _nBins;
00021     _bins = (unsigned *) malloc(_nBins * sizeof(unsigned));
00022     _masks = (bool *) malloc(_nBins * sizeof(bool));
00023     _links = (AList<TMLink> **) malloc(_nBins * sizeof(AList<TMLink> *));
00024     for (unsigned i = 0; i < _nBins; i++) {
00025         _bins[i] = 0;
00026         _masks[i] = false;
00027         _links[i] = new AList<TMLink>;
00028     }
00029 }

THistogram::~THistogram  )  [virtual]
 

Destructor.

00031                         {
00032     free(_bins);
00033     free(_masks);
00034     for (unsigned i = 0; i < _nBins; i++)
00035         delete _links[i];
00036     free(_links);
00037 }

THistogram::THistogram unsigned  nBins  ) 
 

Constructor.

virtual THistogram::~THistogram  )  [virtual]
 

Destructor.


Member Function Documentation

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

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

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

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

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

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

00129                            {
00130     while (i < 0) i += _nBins;
00131     return _links[i % _nBins];
00132 }

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

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

00122                                 {
00123     if (i < _nBins) return _links[i];
00124     return 0;
00125 }

AList<TSegment> THistogram::clusters void   )  const
 

returns an AList<TSegment0> of clusters.

AList< TSegment > THistogram::clusters void   )  const
 

returns an AList<TSegment0> of clusters.

00229                                {
00230     AList<TSegment> list;
00231 //    std::cout<<"enter clusters"<<std::endl;
00232     //...Serach for empty bin...
00233     unsigned begin = 0;
00234     while (_bins[begin] > 0)begin++;
00235     if (begin == _nBins) return list;
00236 
00237     //...Start searching...
00238     unsigned loop = 0;
00239     while (loop < _nBins) {
00240         ++loop;
00241         unsigned id = (begin + loop) % _nBins;
00242         if (_bins[id]) {
00243             unsigned size = 0;
00244             TSegment * c = new TSegment();
00245             while (_bins[id]) {
00246                 if (_bins[id]) ++size;
00247                 c->append(* _links[id]);
00248                 ++loop;
00249                 id = (begin + loop) % _nBins;
00250                 if (loop == _nBins) break;
00251             }
00252             list.append(c);
00253         }
00254     }
00255     return list;
00256 }

AList<TSegment0> THistogram::clusters0 void   )  const
 

returns an AList<TSegment0> of clusters.

AList< TSegment0 > THistogram::clusters0 void   )  const
 

returns an AList<TSegment0> of clusters.

00162                                 {
00163     AList<TSegment0> list;
00164 
00165     //...Serach for empty bin...
00166     unsigned begin = 0;
00167     while (_bins[begin] > 0) begin++;
00168     if (begin == _nBins) return list;
00169 
00170     //...Start searching...
00171     unsigned loop = 0;
00172     while (loop < _nBins) {
00173         ++loop;
00174         unsigned id = (begin + loop) % _nBins;
00175         if (_bins[id]) {
00176             unsigned size = 0;
00177             TSegment0 * c = new TSegment0();
00178             while (_bins[id]) {
00179                 if (_bins[id]) ++size;
00180                 c->append(* _links[id]);
00181                 ++loop;
00182                 id = (begin + loop) % _nBins;
00183                 if (loop == _nBins) break;
00184             }
00185             list.append(c);
00186         }
00187     }
00188     return list;
00189 }

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

returns an AList<TMLink> of all contents.

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

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

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

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

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

returns an AList<TMLink> of all contents.

00154                                {
00155     return _all;
00156 }

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

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

00154                                              {
00155     AList<TMLink> links;
00156     for (int i = start; i <= end; i++)
00157         links.append(* bin(i));
00158     return links;
00159 }

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

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

00143                                                           {
00144     AList<TMLink> links;
00145     for (int i = - (int) width;
00146          i <= (int) width;
00147          i++) {
00148         links.append(* bin((int) center + i));
00149     }
00150     return links;
00151 }

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

dumps debug information.

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

dumps debug information.

00040                                                                    {
00041     std::cout << pre;
00042     std::cout << "THistogram dump:#bins=" << _nBins << std::endl;
00043     unsigned nLoops = _nBins / 15 + 1;
00044     unsigned n0 = 0;
00045     unsigned n1 = 0;
00046     for (unsigned i = 0; i < nLoops; i++) {
00047         for (unsigned j = 0; j < 15; j++) {
00048             if (n0 == _nBins) break;
00049             printf("%4d", n0);
00050             ++n0;
00051         }
00052         std::cout << std::endl;
00053         for (unsigned j = 0; j < 15; j++) {
00054             if (n1 == _nBins) break;
00055             if (! _masks[n1]) printf("%4d", _bins[n1]);
00056             else              printf("-%3d", _bins[n1]);
00057             ++n1;
00058         }       
00059         std::cout << std::endl;
00060     }
00061 
00062     if (msg.find("detail") != std::string::npos) {
00063         for (unsigned i = 0; i < _nBins; i++) {
00064             std::cout << "bin " << i << " : ";
00065             for (unsigned j = 0; j < _links[i]->length(); j++) {
00066                 std::cout << (* _links[i])[j]->wire()->name() << ",";
00067             }
00068             std::cout << std::endl;
00069         }
00070     }
00071 
00072     return;
00073 }

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

fills with hits.

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

fills with hits.

00111                                                {
00112     _all = (AList<TMLink> &) links;
00113     unsigned nLinks = links.length();
00114     double offset = _binSize / 4.;
00115     for (unsigned i = 0; i < nLinks; i++) {
00116         TMLink * l = links[i];
00117         const HepPoint3D & p = l->position();
00118         float phi = atan2(p.y(), p.x()) + M_PI;
00119 //      std::cout<<"atan "<<atan2(-1., -1.)<<std::endl;
00120         unsigned pos = (unsigned) floor((phi + offset) / _binSize);
00121 
00122 //      std::cout <<"layer "<<l->wire()->layerId()<<" cell "<<l->wire()->localId()
00123 //                <<" 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;
00124 //      std::cout<<"binsize "<<_binSize<<" offset "<<offset<<" phi "<<phi<<std::endl;
00125         //...Why is this needed?...
00126         pos %= _nBins;
00127 
00128         ++_bins[pos];
00129         _links[pos]->append(l);
00130     }
00131 }

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

fills with hits.

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

fills with hits.

00076                                              {
00077     _all = (AList<TMLink> &) links;
00078     unsigned nLinks = links.length();
00079     double offset = _binSize / 4.;
00080     for (unsigned i = 0; i < nLinks; i++) {
00081         TMLink * l = links[i];
00082         const HepPoint3D & p = l->position();
00083         unsigned pos = (unsigned) floor((p.x() + offset) / _binSize);
00084 
00085         //...Why is this needed?...
00086         pos %= _nBins;
00087 
00088         ++_bins[pos];
00089         _links[pos]->append(l);
00090     }
00091 }

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

fills with hits.

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

fills with hits.

00094                                              {
00095     _all = (AList<TMLink> &) links;
00096     unsigned nLinks = links.length();
00097     for (unsigned i = 0; i < nLinks; i++) {
00098         TMLink * l = links[i];
00099         const HepPoint3D & p = l->position();
00100         unsigned pos = (unsigned) floor(p.y() / _binSize);
00101 
00102         //...Why is this needed?...
00103         pos %= _nBins;
00104 
00105         ++_bins[pos];
00106         _links[pos]->append(l);
00107     }
00108 }

void THistogram::mask unsigned  binN  ) 
 

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

void THistogram::mask unsigned  binN  )  [inline]
 

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

00142                            {
00143     _masks[a] = true;
00144 }

unsigned THistogram::nBin unsigned  i  )  const
 

returns number in i'th bin.

unsigned THistogram::nBin unsigned  i  )  const [inline]
 

returns number in i'th bin.

00160                                  {
00161     if (i < _nBins) return _bins[i];
00162     return 0;
00163 }

unsigned THistogram::nBins void   )  const
 

returns # of bins.

unsigned THistogram::nBins void   )  const [inline]
 

returns # of bins.

00136                             {
00137     return _nBins;
00138 }

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

removes links.

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

removes links.

00134                                               {
00135     for (unsigned i = 0; i < _nBins; i++) {
00136         _links[i]->remove(links);
00137         _bins[i] = _links[i]->length();
00138     }
00139     _all.remove(links);
00140 }

AList<TSegment> THistogram::segments void   )  const
 

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

AList< TSegment > THistogram::segments void   )  const
 

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

00259                                {
00260   //yuany
00261   /*
00262   for (unsigned i = 0; i < _nBins; i++) {
00263       std::cout<<"i "<<i<<" bins[i] "<<_bins[i]<<std::endl;
00264     }
00265   */
00266     //...Obtain raw clusters...
00267     AList<TSegment> list = clusters();
00268     unsigned n = list.length();
00269     if (n == 0) return list;
00270 
00271     //...Examine each cluster...
00272     AList<TSegment> splitted;
00273     for (unsigned i = 0; i < n; i++) {
00274         TSegment * c = list[i];
00275 
00276 #ifdef TRKRECO_DEBUG_DETAIL
00277         std::cout << "    base segment : ";
00278         c->dump("hits");
00279 #endif
00280 
00281         AList<TSegment> newClusters = c->split();
00282         if (newClusters.length() == 0) {
00283 #ifdef TRKRECO_DEBUG_DETAIL
00284             std::cout << "    ... Solving dual hits" << std::endl;
00285 #endif
00286             c->solveDualHits();
00287             continue;
00288         }
00289 
00290         list.append(newClusters);
00291         splitted.append(c);
00292 #ifdef TRKRECO_DEBUG_DETAIL
00293         c->dump("hits", "    ");
00294         std::cout << "    ... splitted as" << std::endl;
00295         for (unsigned j = 0; j < newClusters.length(); j++) {
00296             std::cout << "    " << j << " : ";
00297             newClusters[j]->dump("hits");
00298         }
00299 #endif
00300     }
00301     list.remove(splitted);
00302     HepAListDeleteAll(splitted);
00303     
00304     //yuany
00305 //    n = list.length();
00306 //    for (unsigned i = 0; i < n; i++) {
00307 //      TSegment * c = list[i];
00308 //      std::cout << "    base segment : ";
00309 //      c->dump("hits");
00310 //    }
00311 
00312     return list;
00313 }

AList<TSegment0> THistogram::segments0 void   )  const
 

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

AList< TSegment0 > THistogram::segments0 void   )  const
 

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

00192                                 {
00193 
00194     //...Obtain raw clusters...
00195     AList<TSegment0> list = clusters0();
00196     unsigned n = list.length();
00197     if (n == 0) return list;
00198 
00199     //...Examine each cluster...
00200     AList<TSegment0> splitted;
00201     for (unsigned i = 0; i < n; i++) {
00202         TSegment0 * c = list[i];
00203 
00204         AList<TSegment0> newClusters = c->split();
00205         if (newClusters.length() == 0) {
00206             c->solveDualHits();
00207             continue;
00208         }
00209 
00210         list.append(newClusters);
00211         splitted.append(c);
00212 #ifdef TRKRECO_DEBUG_DETAIL
00213         c->dump("hits", "    ");
00214         std::cout << "    ... splitted as" << std::endl;
00215         for (unsigned j = 0; j < newClusters.length(); j++) {
00216             std::cout << "    " << j << " : ";
00217             newClusters[j]->dump("hits");
00218         }
00219 #endif
00220     }
00221     list.remove(splitted);
00222     HepAListDeleteAll(splitted);
00223 
00224     return list;
00225 
00226 }

void THistogram::unmask void   ) 
 

remove masks.

void THistogram::unmask void   )  [inline]
 

remove masks.

00148                        {
00149     for (unsigned i = 0; i < _nBins; i++) _masks[i] = false;
00150 }


Member Data Documentation

AList<TMLink> THistogram::_all [private]
 

AList<TMLink> THistogram::_all [private]
 

unsigned* THistogram::_bins [private]
 

unsigned* THistogram::_bins [private]
 

float THistogram::_binSize [private]
 

AList<TMLink>** THistogram::_links [private]
 

AList<TMLink>** THistogram::_links [private]
 

bool* THistogram::_masks [private]
 

bool* THistogram::_masks [private]
 

unsigned THistogram::_nBins [private]
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 18:53:27 2011 for BOSS6.5.5 by  doxygen 1.3.9.1