Belle II Software  release-05-02-19
Link.h
1 //-----------------------------------------------------------------------------
2 // $Id$
3 //-----------------------------------------------------------------------------
4 // Filename : Link.h
5 // Section : TRG CDC
6 // Owner : Yoshihito Iwasaki
7 // Email : yoshihito.iwasaki@kek.jp
8 //-----------------------------------------------------------------------------
9 // Description : A class to relate TRGCDCCellHit and TRGCDCTrack objects.
10 //-----------------------------------------------------------------------------
11 // $Log$
12 //-----------------------------------------------------------------------------
13 
14 #ifndef TRGCDCLink_FLAG_
15 #define TRGCDCLink_FLAG_
16 
17 #include <cstring>
18 #include <vector>
19 #include "CLHEP/Geometry/Point3D.h"
20 #include "trg/cdc/Cell.h"
21 #include "trg/cdc/CellHit.h"
22 
23 #ifdef TRGCDC_SHORT_NAMES
24 #define TCLink TRGCDCLink
25 #endif
26 
27 namespace Belle2 {
33  class TRGCDC;
34  class TRGCDCTrack;
35  class TRGCDCTrackMC;
36  class TRGCDCWire;
37  class TRGCDCSegment;
38 
40  class TRGCDCLink {
41 
42  public:
43 
46  const TRGCDCCellHit* hit = 0,
48 
50  TRGCDCLink(const TRGCDCLink&);
51 
53  virtual ~TRGCDCLink();
54 
56  static void removeAll(void);
57 
59  static void* operator new(size_t);
60 
62  static void operator delete(void*);
63 
64  public:// Selectors
65 
67  TRGCDCTrack* track(void) const;
68 
70  const TRGCDCCellHit* hit(void) const;
71 
73  const TRGCDCCell* cell(void) const;
74 
76  const TRGCDCWire* wire(void) const;
77 
79  const TRGCDCSegment* segment(void) const;
80 
82  double pull(void) const;
83 
85  const HepGeom::Point3D<double>& xyPosition(void) const;
86 
88  const HepGeom::Point3D<double>& positionOnWire(void) const;
89 
91  const HepGeom::Point3D<double>& positionOnTrack(void) const;
92 
94  double dPhi(void) const;
95 
97  unsigned leftRight(void) const;
98 
100  const HepGeom::Point3D<double>& position(void) const;
101 
103  double distance(void) const;
104 
106  TRGCDCLink* neighbor(unsigned int) const;
107 
109  TRGCDCLink* link(void) const;
110 
111  public:// tmp
112 // const HepGeom::Point3D<double> & conf(void) const;
115 
116  public:// Modifiers
118  void update(const HepGeom::Point3D<double>& onTrack,
119  const HepGeom::Point3D<double>& onWire,
120  unsigned leftRight,
121  double pull);
122 
124  const TRGCDCCellHit* hit(const TRGCDCCellHit*);
125 
128 
132  const HepGeom::Point3D<double>& positionOnWire(double p[3]);
133 
137  const HepGeom::Point3D<double>& positionOnTrack(double p[3]);
138 
140  double dPhi(double);
141 
144 
146  void neighbor(unsigned int, TRGCDCLink*);
147 
150 
152  unsigned leftRight(unsigned);
153 
155  double pull(double);
156 
157 // const unsigned fit2D(const unsigned &);
158 
159 // unsigned fit2D(void);
160 
161  public:// Drift distance
162 
164  float drift(void) const;
165 
167  float drift(unsigned) const;
168 
170  float drift(float, unsigned);
171 
173  float dDrift(void) const;
174 
176  float dDrift(unsigned) const;
177 
179  float dDrift(float, unsigned);
180 
181  public:// Utility functions
182 
184  void dump(const std::string& message = std::string(""),
185  const std::string& prefix = std::string("")) const;
186 
187  public:// Static utility functions (for Belle2)
188 
190  static void separate(const std::vector<TRGCDCLink*>& links,
191  unsigned nLayers,
192  std::vector<TRGCDCLink*>* layers);
193 
194  public:// Static utility functions
195 
197  static const TRGCDCTrackMC& links2HEP(
198  const std::vector<TRGCDCLink*>& links);
199 
201  static unsigned nSuperLayers(const std::vector<TRGCDCLink*>& links);
202 
204  static unsigned nSuperLayers(const std::vector<TRGCDCLink*>& links,
205  unsigned minNHits);
206 
209  static unsigned nMissingAxialSuperLayers(
210  const std::vector<TRGCDCLink*>& links);
211 
213  static unsigned nMissingStereoSuperLayers(
214  const std::vector<TRGCDCLink*>& links);
215 
217  static unsigned nLayers(const std::vector<TRGCDCLink*>& links);
218 
220  static void nHits(const std::vector<TRGCDCLink*>& links,
221  unsigned* nHits);
222 
224  static void nHitsSuperLayer(const std::vector<TRGCDCLink*>& links,
225  unsigned* nHits);
226 
228  static void nHitsSuperLayer(const std::vector<TRGCDCLink*>& links,
229  std::vector<TRGCDCLink*>* list);
230 
232  static std::vector<TRGCDCLink*> axialHits(
233  const std::vector<TRGCDCLink*>& links);
234 
236  static std::vector<TRGCDCLink*> stereoHits(
237  const std::vector<TRGCDCLink*>& links);
238 
240  static unsigned nAxialHits(const std::vector<TRGCDCLink*>& links);
241 
243  static unsigned nStereoHits(const std::vector<TRGCDCLink*>& links);
244 
248  static unsigned width(const std::vector<TRGCDCLink*>&);
249 
252  static std::vector<TRGCDCLink*> edges(const std::vector<TRGCDCLink*>&);
253 
255  static std::vector<TRGCDCLink*> sameLayer(
256  const std::vector<TRGCDCLink*>& list,
257  const TRGCDCLink& a);
258 
260  static std::vector<TRGCDCLink*> sameLayer(
261  const std::vector<TRGCDCLink*>& list,
262  unsigned id);
263 
265  static std::vector<TRGCDCLink*> sameSuperLayer(
266  const std::vector<TRGCDCLink*>& list,
267  const TRGCDCLink& a);
268 
270  static std::vector<TRGCDCLink*> sameSuperLayer(
271  const std::vector<TRGCDCLink*>& list,
272  unsigned id);
273 
275  static unsigned superLayer(const std::vector<TRGCDCLink*>& list);
276 
278  static unsigned superLayer(const std::vector<TRGCDCLink*>& list,
279  unsigned minNHits);
280 
282  static TRGCDCLink* innerMost(const std::vector<TRGCDCLink*>& links);
283 
285  static TRGCDCLink* outerMost(const std::vector<TRGCDCLink*>& links);
286 
290  static std::vector<TRGCDCLink*> inOut(const std::vector<TRGCDCLink*>&);
291 
293  static void separateCores(const std::vector<TRGCDCLink*>& input,
294  std::vector<TRGCDCLink*>& cores,
295  std::vector<TRGCDCLink*>& nonCores);
296 
298  static std::vector<TRGCDCLink*> cores(
299  const std::vector<TRGCDCLink*>& input);
300 
302  static void remove(std::vector<TRGCDCLink*>& list,
303  const std::vector<TRGCDCLink*>& links);
304 
306  static void dump(const std::vector<const TRGCDCLink*>& links,
307  const std::string& message = std::string(""),
308  const std::string& prefix = std::string(""));
309 
311  static void dump(const std::vector<TRGCDCLink*>& links,
312  const std::string& message = std::string(""),
313  const std::string& prefix = std::string(""));
314 
316  static void dump(const TRGCDCLink& link,
317  const std::string& message = std::string(""),
318  const std::string& prefix = std::string(""));
319 
321  static std::string layerUsage(const std::vector<TRGCDCLink*>& links);
322 
323  public:// Sorters
324 
326  static bool sortById(const TRGCDCLink* a, const TRGCDCLink* b);
327 
329  static int sortByX(const TRGCDCLink* a, const TRGCDCLink* b);
330 
331  private:
332  friend class TRGCDC;
333 
334  public:
336  static void initializeBuffers(void);
337 
338  private:
340  static void clearBufferSL(void);
341 
343  void dump_base(const std::string& message = std::string(""),
344  const std::string& prefix = std::string("")) const;
345 
346  private:
347 
349  static std::vector<TRGCDCLink*> _all;
350 
353 
356 
364  double _dPhi;
366  unsigned _leftRight;
368  float _drift[2];
370  float _dDrift[2];
371 
373  int _zStatus;
375  int _zPair;
377  double _pull;
382 
385 
389  unsigned _fit2D;
390  //
391  // for quick dicision
392  //
394  static bool ms_smallcell;
396  static bool ms_superb;
397 
399  static unsigned _nL;
401  static unsigned _nSL;
403  static unsigned _nSLA;
405  static unsigned* _nHitsSL;
406 
407 #ifdef TRASAN_DEBUG
408  public:
409  static unsigned nTRGCDCLinks(void);
410  static unsigned nTRGCDCLinksMax(void);
411  private:
412  static unsigned _nTRGCDCLinks;
413  static unsigned _nTRGCDCLinksMax;
414 #endif
415  };
416 
417 //-----------------------------------------------------------------------------
418 
419  inline
420  const TRGCDCCellHit*
421  TRGCDCLink::hit(void) const
422  {
423  return _hit;
424  }
425 
426  inline
427  TRGCDCTrack*
428  TRGCDCLink::track(void) const
429  {
430  return _track;
431  }
432 
433  inline
434  const TRGCDCCellHit*
436  {
437  return _hit = a;
438  }
439 
440  inline
441  TRGCDCTrack*
443  {
444  return _track = a;
445  }
446 
447  inline
448  void
450  const HepGeom::Point3D<double>& onWire,
451  unsigned leftRight,
452  double pull)
453  {
454  _onTrack = onTrack;
455  _onWire = onWire;
457  _pull = pull;
458  }
459 
460  inline
461  double
462  TRGCDCLink::pull(void) const
463  {
464  return _pull;
465  }
466 
467  inline
468  double
470  {
471  return _pull = a;
472  }
473 
474  inline
477  {
478  return _onWire;
479  }
480 
481  inline
484  {
485  return _onTrack;
486  }
487 
488  inline
491  {
492  return _onWire = a;
493  }
494 
495  inline
498  {
499  _onWire.setX(p[0]);
500  _onWire.setY(p[1]);
501  _onWire.setZ(p[2]);
502  return _onWire;
503  }
504 
505  inline
508  {
509  return _onTrack = a;
510  }
511 
512  inline
515  {
516  _onTrack.setX(p[0]);
517  _onTrack.setY(p[1]);
518  _onTrack.setZ(p[2]);
519  return _onTrack;
520  }
521 
522  inline
523  unsigned
525  {
526  return _leftRight;
527  }
528 
529  inline
530  unsigned
532  {
533  return _leftRight = a;
534  }
535 
536  inline
537  double
538  TRGCDCLink::dPhi(void) const
539  {
540  return _dPhi;
541  }
542 
543  inline
544  double
546  {
547  return _dPhi = a;
548  }
549 
550  inline
553  {
554  return _position;
555  }
556 
557  inline
560  {
561  return _position = a;
562  }
563 
564 // inline
565 // const HepGeom::Point3D<double> &
566 // TRGCDCLink::conf(void) const {
567 // return _conf;
568 // }
569 
570  inline
573  {
574  return _conf = a;
575  }
576 
577  inline
578  void
579  TRGCDCLink::neighbor(unsigned n, TRGCDCLink* neighbor)
580  {
581  if (n < 7)
582  _neighbor[n] = neighbor;
583  }
584 
585  inline
586  TRGCDCLink*
587  TRGCDCLink::neighbor(unsigned n) const
588  {
589  if (n < 7)
590  return _neighbor[n];
591  return NULL;
592  }
593 
594  inline
595  TRGCDCLink*
596  TRGCDCLink::link(void) const
597  {
598  return _link;
599  }
600 
601  inline
602  TRGCDCLink*
604  {
605  return _link = a;
606  }
607 
608  inline
609  double
611  {
612  return (_onTrack - _onWire).mag();
613  }
614 
615  inline
618  {
619  return _hit->cell().xyPosition();
620  }
621 
622 // inline
623 // const unsigned
624 // TRGCDCLink::fit2D(const unsigned &f) {
625 // return _fit2D = f;
626 // }
627 
628 // inline
629 // unsigned
630 // TRGCDCLink::fit2D(void) {
631 // return _fit2D;
632 // }
633 
634  inline
635  float
636  TRGCDCLink::drift(unsigned a) const
637  {
638  return _drift[a];
639  }
640 
641  inline
642  float
643  TRGCDCLink::drift(float b, unsigned a)
644  {
645  return _drift[a] = b;
646  }
647 
648  inline
649  float
650  TRGCDCLink::dDrift(unsigned a) const
651  {
652  return _dDrift[a];
653  }
654 
655  inline
656  float
657  TRGCDCLink::dDrift(float b, unsigned a)
658  {
659  return _dDrift[a] = b;
660  }
661 
662  inline
663  float
664  TRGCDCLink::drift(void) const
665  {
666  return (_drift[0] + _drift[1]) / 2.;
667  }
668 
669  inline
670  float
671  TRGCDCLink::dDrift(void) const
672  {
673  return (_dDrift[0] + _dDrift[1]) / 2.;
674  }
675 
676  inline
677  void
679  {
680  bzero(_nHitsSL, sizeof(unsigned) * _nSL);
681  }
682 
683  inline
684  const TRGCDCCell*
685  TRGCDCLink::cell(void) const
686  {
687  if (_hit)
688  return & _hit->cell();
689  return 0;
690  }
691 
693 } // namespace Belle2
694 
695 #endif /* TRGCDCLink_FLAG_ */
Belle2::TRGCDCLink::_nL
static unsigned _nL
...Buffers...
Definition: Link.h:399
Belle2::TRGCDCLink::axialHits
static std::vector< TRGCDCLink * > axialHits(const std::vector< TRGCDCLink * > &links)
returns axial hits.
Definition: Link.cc:385
Belle2::TRGCDCLink::initializeBuffers
static void initializeBuffers(void)
initialize the Buffers
Definition: Link.cc:804
Belle2::TRGCDCLink::dump
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
Definition: Link.cc:208
Belle2::TRGCDCLink::nHits
static void nHits(const std::vector< TRGCDCLink * > &links, unsigned *nHits)
returns # of hits per layer.
Definition: Link.cc:126
Belle2::TRGCDCLink::_nSL
static unsigned _nSL
...Buffers...
Definition: Link.h:401
Belle2::TRGCDCLink::separate
static void separate(const std::vector< TRGCDCLink * > &links, unsigned nLayers, std::vector< TRGCDCLink * > *layers)
separates into layers.
Definition: Link.cc:818
Belle2::TRGCDCLink::hit
const TRGCDCCellHit * hit(void) const
returns a pointer to a hit.
Definition: Link.h:421
Belle2::TRGCDCTrackMC
A class to represent a GEN_HEPEVT particle in tracking.
Definition: TrackMC.h:33
Belle2::TRGCDCLink::width
static unsigned width(const std::vector< TRGCDCLink * > &)
returns width(wire cell unit) of given std::vector<TRGCDCLink *>.
Definition: Link.cc:483
Belle2::TRGCDCLink::dPhi
double dPhi(void) const
returns dPhi to the closest point.
Definition: Link.h:538
Belle2::TRGCDCLink::sortById
static bool sortById(const TRGCDCLink *a, const TRGCDCLink *b)
sorts by ID.
Definition: Link.cc:471
Belle2::TRGCDCLink::_all
static std::vector< TRGCDCLink * > _all
Keeps all TRGCDCLinks created by new().
Definition: Link.h:349
Belle2::TRGCDCWire
A class to represent a wire in CDC.
Definition: Wire.h:57
Belle2::TRGCDCLink::pull
double pull(void) const
returns pull.
Definition: Link.h:462
Belle2::TRGCDCLink::superLayer
static unsigned superLayer(const std::vector< TRGCDCLink * > &list)
returns super layer pattern.
Definition: Link.cc:644
Belle2::TRGCDCLink::nMissingAxialSuperLayers
static unsigned nMissingAxialSuperLayers(const std::vector< TRGCDCLink * > &links)
returns # of missing axial super layers.
Definition: Link.cc:699
Belle2::TRGCDCLink::positionOnTrack
const HepGeom::Point3D< double > & positionOnTrack(void) const
returns the closest point on track to wire.
Definition: Link.h:483
Belle2::TRGCDCLink::link
TRGCDCLink * link(void) const
returns a pointer to a TRGCDCLink.
Definition: Link.h:596
Belle2::TRGCDCLink::edges
static std::vector< TRGCDCLink * > edges(const std::vector< TRGCDCLink * > &)
returns links which are edges.
Definition: Link.cc:527
Belle2::TRGCDCLink::sameLayer
static std::vector< TRGCDCLink * > sameLayer(const std::vector< TRGCDCLink * > &list, const TRGCDCLink &a)
returns links which are in the same layer as 'a' or 'id'.
Definition: Link.cc:575
Belle2::TRGCDCLink::nHitsSuperLayer
static void nHitsSuperLayer(const std::vector< TRGCDCLink * > &links, unsigned *nHits)
returns # of hits per super layer.
Definition: Link.cc:136
Belle2::TRGCDCLink::track
TRGCDCTrack * track(void) const
returns a pointer to a track.
Definition: Link.h:428
Belle2::TRGCDCLink::nSuperLayers
static unsigned nSuperLayers(const std::vector< TRGCDCLink * > &links)
returns # of layers.
Definition: Link.cc:668
Belle2::TRGCDCLink::ms_smallcell
static bool ms_smallcell
ms_smallcell
Definition: Link.h:394
Belle2::TRGCDCCell
A class to represent a wire in CDC.
Definition: Cell.h:41
Belle2::TRGCDCLink::cores
static std::vector< TRGCDCLink * > cores(const std::vector< TRGCDCLink * > &input)
separate cores and non-cores.
Definition: Link.cc:457
Belle2::TRGCDCCellHit
A class to represent a wire hit in CDC.
Definition: CellHit.h:75
Belle2::TRGCDCLink::update
void update(const HepGeom::Point3D< double > &onTrack, const HepGeom::Point3D< double > &onWire, unsigned leftRight, double pull)
sets results of fitting.
Definition: Link.h:449
Belle2::TRGCDCLink::conf
const HepGeom::Point3D< double > & conf(const HepGeom::Point3D< double > &conf)
conf 3D point
Definition: Link.h:572
Belle2::TRGCDCLink::distance
double distance(void) const
returns distance between point on wire and on track.
Definition: Link.h:610
Belle2::TRGCDCLink::nLayers
static unsigned nLayers(const std::vector< TRGCDCLink * > &links)
returns # of layers.
Definition: Link.cc:106
Belle2::TRGCDCLink::innerMost
static TRGCDCLink * innerMost(const std::vector< TRGCDCLink * > &links)
returns the inner-most link.
Definition: Link.cc:409
Belle2::TRGCDCLink::stereoHits
static std::vector< TRGCDCLink * > stereoHits(const std::vector< TRGCDCLink * > &links)
returns stereo hits.
Definition: Link.cc:397
Belle2::TRGCDCLink::positionOnWire
const HepGeom::Point3D< double > & positionOnWire(void) const
returns the closest point on wire to a track.
Definition: Link.h:476
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TRGCDCLink::nAxialHits
static unsigned nAxialHits(const std::vector< TRGCDCLink * > &links)
returns # of axial hits.
Definition: Link.cc:374
Belle2::TRGCDCLink::nStereoHits
static unsigned nStereoHits(const std::vector< TRGCDCLink * > &links)
returns # of stereo hits.
Definition: Link.cc:363
Belle2::TRGCDCLink::sameSuperLayer
static std::vector< TRGCDCLink * > sameSuperLayer(const std::vector< TRGCDCLink * > &list, const TRGCDCLink &a)
returns links which are in the same super layer as 'a' or 'id'.
Definition: Link.cc:587
Belle2::TRGCDCLink::remove
static void remove(std::vector< TRGCDCLink * > &list, const std::vector< TRGCDCLink * > &links)
removes links from list if wire is same
Definition: Link.cc:784
Belle2::TRGCDCLink::links2HEP
static const TRGCDCTrackMC & links2HEP(const std::vector< TRGCDCLink * > &links)
returns TRGCDCTrackMC
Definition: Link.cc:723
Belle2::TRGCDC
The instance of TRGCDC is a singleton.
Definition: TRGCDC.h:70
Belle2::TRGCDCLink::cell
const TRGCDCCell * cell(void) const
returns a pointer to a cell.
Definition: Link.h:685
Belle2::TRGCDCSegment
A class to represent a wire in CDC.
Definition: Segment.h:40
Belle2::TRGCDCLink::layerUsage
static std::string layerUsage(const std::vector< TRGCDCLink * > &links)
usage of each layer
Definition: Link.cc:769
Belle2::TRGCDCLink::_nHitsSL
static unsigned * _nHitsSL
...Buffers...
Definition: Link.h:405
Belle2::TRGCDCLink::_nSLA
static unsigned _nSLA
...Buffers...
Definition: Link.h:403
Belle2::TRGCDCLink::position
const HepGeom::Point3D< double > & position(void) const
returns position.
Definition: Link.h:552
Belle2::TRGCDCLink::inOut
static std::vector< TRGCDCLink * > inOut(const std::vector< TRGCDCLink * > &)
returns links which are in the inner most and outer most layer.
Definition: Link.cc:621
Belle2::TRGCDCLink::xyPosition
const HepGeom::Point3D< double > & xyPosition(void) const
returns middle position of a wire. z componet is 0.
Definition: Link.h:617
Belle2::TRGCDCTrack
A class to represent a reconstructed charged track in TRGCDC.
Definition: Track.h:39
Belle2::TRGCDCLink::leftRight
unsigned leftRight(void) const
returns left-right. 0:left, 1:right, 2:wire
Definition: Link.h:524
Belle2::TRGCDCLink::dump_base
void dump_base(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
Definition: Link.cc:146
Belle2::TRGCDCCellHit::cell
virtual const TRGCDCCell & cell(void) const
returns a pointer to a TRGCDCWire.
Definition: CellHit.h:253
HepGeom::Point3D< double >
Belle2::TRGCDCLink::drift
float drift(void) const
returns drift distance.
Definition: Link.h:664
Belle2::TRGCDCLink::clearBufferSL
static void clearBufferSL(void)
clear buffers
Definition: Link.h:678
Belle2::TRGCDCLink::~TRGCDCLink
virtual ~TRGCDCLink()
Destructor.
Definition: Link.cc:101
Belle2::TRGCDCLink::ms_superb
static bool ms_superb
ms_superb
Definition: Link.h:396
Belle2::TRGCDCLink::separateCores
static void separateCores(const std::vector< TRGCDCLink * > &input, std::vector< TRGCDCLink * > &cores, std::vector< TRGCDCLink * > &nonCores)
separate cores and non-cores.
Definition: Link.cc:441
Belle2::Point3D
HepGeom::Point3D< double > Point3D
3D point
Definition: Cell.h:33
Belle2::TRGCDCLink::sortByX
static int sortByX(const TRGCDCLink *a, const TRGCDCLink *b)
sorts by X position.
Definition: Link.cc:477
Belle2::TRGCDCLink::removeAll
static void removeAll(void)
destructs all TRGCDCLink objects. (Called by TRGCDC)
Definition: Link.cc:849
Belle2::TRGCDCLink::wire
const TRGCDCWire * wire(void) const
returns a pointer to a wire.
Definition: Link.cc:833
Belle2::TRGCDCLink::outerMost
static TRGCDCLink * outerMost(const std::vector< TRGCDCLink * > &links)
returns the outer-most link.
Definition: Link.cc:425
Belle2::TRGCDCLink::dDrift
float dDrift(void) const
returns drift distance error.
Definition: Link.h:671