Belle II Software development
Link.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9//-----------------------------------------------------------------------------
10// Description : A class to relate TRGCDCCellHit and TRGCDCTrack objects.
11//-----------------------------------------------------------------------------
12
13#ifndef TRGCDCLink_FLAG_
14#define TRGCDCLink_FLAG_
15
16#include <cstring>
17#include <vector>
18#include "CLHEP/Geometry/Point3D.h"
19#include "trg/cdc/Cell.h"
20#include "trg/cdc/CellHit.h"
21
22#ifdef TRGCDC_SHORT_NAMES
23#define TCLink TRGCDCLink
24#endif
25
26namespace Belle2 {
32 class TRGCDC;
33 class TRGCDCTrack;
34 class TRGCDCTrackMC;
35 class TRGCDCWire;
36 class TRGCDCSegment;
37
39 class TRGCDCLink {
40
41 public:
42
45 const TRGCDCCellHit* hit = 0,
47
49 TRGCDCLink(const TRGCDCLink&);
50
52 virtual ~TRGCDCLink();
53
55 static void removeAll(void);
56
58 static void* operator new (size_t);
59
61 static void operator delete (void*);
62
63 public:// Selectors
64
66 TRGCDCTrack* track(void) const;
67
69 const TRGCDCCellHit* hit(void) const;
70
72 const TRGCDCCell* cell(void) const;
73
75 const TRGCDCWire* wire(void) const;
76
78 const TRGCDCSegment* segment(void) const;
79
81 double pull(void) const;
82
84 const HepGeom::Point3D<double>& xyPosition(void) const;
85
88
91
93 double dPhi(void) const;
94
96 unsigned leftRight(void) const;
97
99 const HepGeom::Point3D<double>& position(void) const;
100
102 double distance(void) const;
103
105 TRGCDCLink* neighbor(unsigned n) const;
106
108 TRGCDCLink* link(void) const;
109
110 public:// tmp
111// const HepGeom::Point3D<double> & conf(void) const;
114
115 public:// Modifiers
117 void update(const HepGeom::Point3D<double>& onTrack,
118 const HepGeom::Point3D<double>& onWire,
119 unsigned leftRight,
120 double pull);
121
123 const TRGCDCCellHit* hit(const TRGCDCCellHit*);
124
127
131 const HepGeom::Point3D<double>& positionOnWire(double p[3]);
132
136 const HepGeom::Point3D<double>& positionOnTrack(double p[3]);
137
139 double dPhi(double);
140
143
145 void neighbor(unsigned n, TRGCDCLink* neighbor);
146
149
151 unsigned leftRight(unsigned);
152
154 double pull(double);
155
156// const unsigned fit2D(const unsigned &);
157
158// unsigned fit2D(void);
159
160 public:// Drift distance
161
163 float drift(void) const;
164
166 float drift(unsigned) const;
167
169 float drift(float, unsigned);
170
172 float dDrift(void) const;
173
175 float dDrift(unsigned) const;
176
178 float dDrift(float, unsigned);
179
180 public:// Utility functions
181
183 void dump(const std::string& message = std::string(""),
184 const std::string& prefix = std::string("")) const;
185
186 public:// Static utility functions (for Belle2)
187
189 static void separate(const std::vector<TRGCDCLink*>& links,
190 unsigned nLayers,
191 std::vector<TRGCDCLink*>* layers);
192
193 public:// Static utility functions
194
196 static const TRGCDCTrackMC& links2HEP(
197 const std::vector<TRGCDCLink*>& links);
198
200 static unsigned nSuperLayers(const std::vector<TRGCDCLink*>& links);
201
203 static unsigned nSuperLayers(const std::vector<TRGCDCLink*>& links,
204 unsigned minNHits);
205
208 static unsigned nMissingAxialSuperLayers(
209 const std::vector<TRGCDCLink*>& links);
210
213 const std::vector<TRGCDCLink*>& links);
214
216 static unsigned nLayers(const std::vector<TRGCDCLink*>& links);
217
219 static void nHits(const std::vector<TRGCDCLink*>& links,
220 unsigned* nHits);
221
223 static void nHitsSuperLayer(const std::vector<TRGCDCLink*>& links,
224 unsigned* nHits);
225
227 static void nHitsSuperLayer(const std::vector<TRGCDCLink*>& links,
228 std::vector<TRGCDCLink*>* list);
229
231 static std::vector<TRGCDCLink*> axialHits(
232 const std::vector<TRGCDCLink*>& links);
233
235 static std::vector<TRGCDCLink*> stereoHits(
236 const std::vector<TRGCDCLink*>& links);
237
239 static unsigned nAxialHits(const std::vector<TRGCDCLink*>& links);
240
242 static unsigned nStereoHits(const std::vector<TRGCDCLink*>& links);
243
247 static unsigned width(const std::vector<TRGCDCLink*>&);
248
251 static std::vector<TRGCDCLink*> edges(const std::vector<TRGCDCLink*>&);
252
254 static std::vector<TRGCDCLink*> sameLayer(
255 const std::vector<TRGCDCLink*>& list,
256 const TRGCDCLink& a);
257
259 static std::vector<TRGCDCLink*> sameLayer(
260 const std::vector<TRGCDCLink*>& list,
261 unsigned id);
262
264 static std::vector<TRGCDCLink*> sameSuperLayer(
265 const std::vector<TRGCDCLink*>& list,
266 const TRGCDCLink& a);
267
269 static std::vector<TRGCDCLink*> sameSuperLayer(
270 const std::vector<TRGCDCLink*>& list,
271 unsigned id);
272
274 static unsigned superLayer(const std::vector<TRGCDCLink*>& list);
275
277 static unsigned superLayer(const std::vector<TRGCDCLink*>& list,
278 unsigned minNHits);
279
281 static TRGCDCLink* innerMost(const std::vector<TRGCDCLink*>& links);
282
284 static TRGCDCLink* outerMost(const std::vector<TRGCDCLink*>& links);
285
289 static std::vector<TRGCDCLink*> inOut(const std::vector<TRGCDCLink*>&);
290
292 static void separateCores(const std::vector<TRGCDCLink*>& input,
293 std::vector<TRGCDCLink*>& cores,
294 std::vector<TRGCDCLink*>& nonCores);
295
297 static std::vector<TRGCDCLink*> cores(
298 const std::vector<TRGCDCLink*>& input);
299
301 static void remove(std::vector<TRGCDCLink*>& list,
302 const std::vector<TRGCDCLink*>& links);
303
305 static void dump(const std::vector<const TRGCDCLink*>& links,
306 const std::string& message = std::string(""),
307 const std::string& prefix = std::string(""));
308
310 static void dump(const std::vector<TRGCDCLink*>& links,
311 const std::string& message = std::string(""),
312 const std::string& prefix = std::string(""));
313
315 static void dump(const TRGCDCLink& link,
316 const std::string& message = std::string(""),
317 const std::string& prefix = std::string(""));
318
320 static std::string layerUsage(const std::vector<TRGCDCLink*>& links);
321
322 public:// Sorters
323
325 static bool sortById(const TRGCDCLink* a, const TRGCDCLink* b);
326
328 static int sortByX(const TRGCDCLink* a, const TRGCDCLink* b);
329
330 private:
331 friend class TRGCDC;
332
333 public:
335 static void initializeBuffers(void);
336
337 private:
339 static void clearBufferSL(void);
340
342 void dump_base(const std::string& message = std::string(""),
343 const std::string& prefix = std::string("")) const;
344
345 private:
346
348 static std::vector<TRGCDCLink*> _all;
349
352
355
363 double _dPhi;
365 unsigned _leftRight;
367 float _drift[2];
369 float _dDrift[2];
370
376 double _pull;
381
384
388 unsigned _fit2D;
389 //
390 // for quick dicision
391 //
393 static bool ms_smallcell;
395 static bool ms_superb;
396
398 static unsigned _nL;
400 static unsigned _nSL;
402 static unsigned _nSLA;
404 static unsigned* _nHitsSL;
405
406#ifdef TRASAN_DEBUG
407 public:
408 static unsigned nTRGCDCLinks(void);
409 static unsigned nTRGCDCLinksMax(void);
410 private:
411 static unsigned _nTRGCDCLinks;
412 static unsigned _nTRGCDCLinksMax;
413#endif
414 };
415
416//-----------------------------------------------------------------------------
417
418 inline
419 const TRGCDCCellHit*
420 TRGCDCLink::hit(void) const
421 {
422 return _hit;
423 }
424
425 inline
428 {
429 return _track;
430 }
431
432 inline
433 const TRGCDCCellHit*
435 {
436 return _hit = a;
437 }
438
439 inline
442 {
443 return _track = a;
444 }
445
446 inline
447 void
449 const HepGeom::Point3D<double>& onWire,
450 unsigned leftRight,
451 double pull)
452 {
453 _onTrack = onTrack;
454 _onWire = onWire;
456 _pull = pull;
457 }
458
459 inline
460 double
462 {
463 return _pull;
464 }
465
466 inline
467 double
469 {
470 return _pull = a;
471 }
472
473 inline
476 {
477 return _onWire;
478 }
479
480 inline
483 {
484 return _onTrack;
485 }
486
487 inline
490 {
491 return _onWire = a;
492 }
493
494 inline
497 {
498 _onWire.setX(p[0]);
499 _onWire.setY(p[1]);
500 _onWire.setZ(p[2]);
501 return _onWire;
502 }
503
504 inline
507 {
508 return _onTrack = a;
509 }
510
511 inline
514 {
515 _onTrack.setX(p[0]);
516 _onTrack.setY(p[1]);
517 _onTrack.setZ(p[2]);
518 return _onTrack;
519 }
520
521 inline
522 unsigned
524 {
525 return _leftRight;
526 }
527
528 inline
529 unsigned
531 {
532 return _leftRight = a;
533 }
534
535 inline
536 double
538 {
539 return _dPhi;
540 }
541
542 inline
543 double
545 {
546 return _dPhi = a;
547 }
548
549 inline
552 {
553 return _position;
554 }
555
556 inline
559 {
560 return _position = a;
561 }
562
563// inline
564// const HepGeom::Point3D<double> &
565// TRGCDCLink::conf(void) const {
566// return _conf;
567// }
568
569 inline
572 {
573 return _conf = a;
574 }
575
576 inline
577 void
578 TRGCDCLink::neighbor(unsigned n, TRGCDCLink* neighbor)
579 {
580 if (n < 7)
581 _neighbor[n] = neighbor;
582 }
583
584 inline
586 TRGCDCLink::neighbor(unsigned n) const
587 {
588 if (n < 7)
589 return _neighbor[n];
590 return NULL;
591 }
592
593 inline
596 {
597 return _link;
598 }
599
600 inline
603 {
604 return _link = a;
605 }
606
607 inline
608 double
610 {
611 return (_onTrack - _onWire).mag();
612 }
613
614 inline
617 {
618 return _hit->cell().xyPosition();
619 }
620
621// inline
622// const unsigned
623// TRGCDCLink::fit2D(const unsigned &f) {
624// return _fit2D = f;
625// }
626
627// inline
628// unsigned
629// TRGCDCLink::fit2D(void) {
630// return _fit2D;
631// }
632
633 inline
634 float
635 TRGCDCLink::drift(unsigned a) const
636 {
637 return _drift[a];
638 }
639
640 inline
641 float
642 TRGCDCLink::drift(float b, unsigned a)
643 {
644 return _drift[a] = b;
645 }
646
647 inline
648 float
649 TRGCDCLink::dDrift(unsigned a) const
650 {
651 return _dDrift[a];
652 }
653
654 inline
655 float
656 TRGCDCLink::dDrift(float b, unsigned a)
657 {
658 return _dDrift[a] = b;
659 }
660
661 inline
662 float
664 {
665 return (_drift[0] + _drift[1]) / 2.;
666 }
667
668 inline
669 float
671 {
672 return (_dDrift[0] + _dDrift[1]) / 2.;
673 }
674
675 inline
676 void
678 {
679 bzero(_nHitsSL, sizeof(unsigned) * _nSL);
680 }
681
682 inline
683 const TRGCDCCell*
685 {
686 if (_hit)
687 return & _hit->cell();
688 return 0;
689 }
690
692} // namespace Belle2
693
694#endif /* TRGCDCLink_FLAG_ */
A class to represent a wire hit in CDC.
Definition: CellHit.h:74
A class to represent a wire in CDC.
Definition: Cell.h:40
A class to represent a wire in CDC.
Definition: Segment.h:39
A class to represent a GEN_HEPEVT particle in tracking.
Definition: TrackMC.h:32
A class to represent a reconstructed charged track in TRGCDC.
Definition: TRGCDCTrack.h:38
A class to represent a wire in CDC.
Definition: Wire.h:56
The instance of TRGCDC is a singleton.
Definition: TRGCDC.h:69
const TRGCDCWire * wire(void) const
returns a pointer to a wire.
Definition: Link.cc:833
float drift(void) const
returns drift distance.
Definition: Link.h:663
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
static const TRGCDCTrackMC & links2HEP(const std::vector< TRGCDCLink * > &links)
returns TRGCDCTrackMC
Definition: Link.cc:723
HepGeom::Point3D< double > Point3D
3D point
Definition: Cell.h:32
virtual const TRGCDCCell & cell(void) const
returns a pointer to a TRGCDCWire.
Definition: CellHit.h:252
virtual ~TRGCDCLink()
Destructor.
Definition: Link.cc:100
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
Definition: Link.cc:207
const TRGCDCCell * cell(void) const
returns a pointer to a cell.
Definition: Link.h:684
float dDrift(void) const
returns drift distance error.
Definition: Link.h:670
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
static std::vector< TRGCDCLink * > edges(const std::vector< TRGCDCLink * > &)
returns links which are edges.
Definition: Link.cc:527
static TRGCDCLink * outerMost(const std::vector< TRGCDCLink * > &links)
returns the outer-most link.
Definition: Link.cc:425
const HepGeom::Point3D< double > & position(void) const
returns position.
Definition: Link.h:551
static unsigned width(const std::vector< TRGCDCLink * > &)
returns width(wire cell unit) of given std::vector<TRGCDCLink *>.
Definition: Link.cc:483
TRGCDCTrack * track(void) const
returns a pointer to a track.
Definition: Link.h:427
static TRGCDCLink * innerMost(const std::vector< TRGCDCLink * > &links)
returns the inner-most link.
Definition: Link.cc:409
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
const HepGeom::Point3D< double > & positionOnTrack(void) const
returns the closest point on track to wire.
Definition: Link.h:482
static unsigned superLayer(const std::vector< TRGCDCLink * > &list)
returns super layer pattern.
Definition: Link.cc:644
double distance(void) const
returns distance between point on wire and on track.
Definition: Link.h:609
static void clearBufferSL(void)
clear buffers
Definition: Link.h:677
const TRGCDCCellHit * hit(void) const
returns a pointer to a hit.
Definition: Link.h:420
static int sortByX(const TRGCDCLink *a, const TRGCDCLink *b)
sorts by X position.
Definition: Link.cc:477
static unsigned _nSL
...Buffers...
Definition: Link.h:400
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
static bool sortById(const TRGCDCLink *a, const TRGCDCLink *b)
sorts by ID.
Definition: Link.cc:471
const HepGeom::Point3D< double > & positionOnWire(void) const
returns the closest point on wire to a track.
Definition: Link.h:475
static unsigned nMissingAxialSuperLayers(const std::vector< TRGCDCLink * > &links)
returns # of missing axial super layers.
Definition: Link.cc:699
static void removeAll(void)
destructs all TRGCDCLink objects. (Called by TRGCDC)
Definition: Link.cc:849
static std::vector< TRGCDCLink * > _all
Keeps all TRGCDCLinks created by new().
Definition: Link.h:348
TRGCDCLink * link(void) const
returns a pointer to a TRGCDCLink.
Definition: Link.h:595
TRGCDCLink * neighbor(unsigned n) const
returns neighbor TRGCDCLink.
Definition: Link.h:586
static void remove(std::vector< TRGCDCLink * > &list, const std::vector< TRGCDCLink * > &links)
removes links from list if wire is same
Definition: Link.cc:784
static bool ms_superb
ms_superb
Definition: Link.h:395
double dPhi(void) const
returns dPhi to the closest point.
Definition: Link.h:537
static unsigned nSuperLayers(const std::vector< TRGCDCLink * > &links)
returns # of layers.
Definition: Link.cc:668
void update(const HepGeom::Point3D< double > &onTrack, const HepGeom::Point3D< double > &onWire, unsigned leftRight, double pull)
sets results of fitting.
Definition: Link.h:448
static void nHits(const std::vector< TRGCDCLink * > &links, unsigned *nHits)
returns # of hits per layer.
Definition: Link.cc:125
static std::vector< TRGCDCLink * > stereoHits(const std::vector< TRGCDCLink * > &links)
returns stereo hits.
Definition: Link.cc:397
double pull(void) const
returns pull.
Definition: Link.h:461
const HepGeom::Point3D< double > & xyPosition(void) const
returns middle position of a wire. z componet is 0.
Definition: Link.h:616
static std::vector< TRGCDCLink * > axialHits(const std::vector< TRGCDCLink * > &links)
returns axial hits.
Definition: Link.cc:385
void dump_base(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
Definition: Link.cc:145
static std::string layerUsage(const std::vector< TRGCDCLink * > &links)
usage of each layer
Definition: Link.cc:769
static unsigned nLayers(const std::vector< TRGCDCLink * > &links)
returns # of layers.
Definition: Link.cc:105
static bool ms_smallcell
ms_smallcell
Definition: Link.h:393
static std::vector< TRGCDCLink * > cores(const std::vector< TRGCDCLink * > &input)
separate cores and non-cores.
Definition: Link.cc:457
static void initializeBuffers(void)
initialize the Buffers
Definition: Link.cc:804
const HepGeom::Point3D< double > & conf(const HepGeom::Point3D< double > &conf)
conf 3D point
Definition: Link.h:571
static unsigned nAxialHits(const std::vector< TRGCDCLink * > &links)
returns # of axial hits.
Definition: Link.cc:374
unsigned leftRight(void) const
returns left-right. 0:left, 1:right, 2:wire
Definition: Link.h:523
static unsigned _nL
...Buffers...
Definition: Link.h:398
static unsigned * _nHitsSL
...Buffers...
Definition: Link.h:404
static unsigned nStereoHits(const std::vector< TRGCDCLink * > &links)
returns # of stereo hits.
Definition: Link.cc:363
static void nHitsSuperLayer(const std::vector< TRGCDCLink * > &links, unsigned *nHits)
returns # of hits per super layer.
Definition: Link.cc:135
static void separate(const std::vector< TRGCDCLink * > &links, unsigned nLayers, std::vector< TRGCDCLink * > *layers)
separates into layers.
Definition: Link.cc:818
static unsigned _nSLA
...Buffers...
Definition: Link.h:402
Abstract base class for different kinds of events.