Belle II Software development
SegmentHit.cc
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 represent a track segment hit in CDC.
11//-----------------------------------------------------------------------------
12
13#define TRG_SHORT_NAMES
14#define TRGCDC_SHORT_NAMES
15
16#include <stdlib.h>
17#include "trg/cdc/Segment.h"
18#include "trg/cdc/SegmentHit.h"
19#include "trg/cdc/Wire.h"
20#include "trg/cdc/WireHit.h"
21
22using namespace std;
23
24namespace Belle2 {
30 vector<TRGCDCSegmentHit*> TRGCDCSegmentHit::_all;
31
33// : TCCHit((TCCHit &) * w.center().hit()) {
34 : TCCHit(w,
35 //w.center().hit()->iCDCHit(),
36 //w.center().hit()->iCDCSimHit(),
37 //w.center().hit()->iMCParticle(),
38 //w.center().hit()->drift(0),
39 //w.center().hit()->dDrift(0),
40 //w.center().hit()->drift(1),
41 //w.center().hit()->dDrift(1),
42 //w.center().hit()->mcLR()) {
43 w.priority().hit()->iCDCHit(),
44 w.priority().hit()->iCDCSimHit(),
45 w.priority().hit()->iMCParticle(),
46 w.priority().hit()->drift(0),
47 w.priority().hit()->dDrift(0),
48 w.priority().hit()->drift(1),
49 w.priority().hit()->dDrift(1),
50 w.priority().hit()->mcLR())
51 {
52 }
53
55 {
56 }
57
58 int
60 const TRGCDCSegmentHit** b)
61 {
62 if ((* a)->cell().id() > (* b)->cell().id())
63 return 1;
64 else if ((* a)->cell().id() == (* b)->cell().id())
65 return 0;
66 else
67 return -1;
68 }
69
70 void
71 TRGCDCSegmentHit::dump(const std::string& message,
72 const std::string& prefix) const
73 {
74 TCCHit::dump(message, prefix);
75 }
76
77 const TRGCDCSegment&
79 {
80 return dynamic_cast<const TRGCDCSegment&>(cell());
81 }
82
83 void
85 {
86 while (_all.size())
87 delete _all.back();
88 }
89
90 void*
91 TRGCDCSegmentHit::operator new (size_t size)
92 {
93 void* p = malloc(size);
94 _all.push_back(static_cast<TRGCDCSegmentHit*>(p));
95
96// cout << ">---------------------" << endl;
97// for (unsigned i = 0; i < _all.size(); i++)
98// cout << "> " << i << " " << _all[i] << endl;
99
100 return p;
101 }
102
103 void
104 TRGCDCSegmentHit::operator delete (void* t)
105 {
106 for (vector<TRGCDCSegmentHit*>::iterator it = _all.begin();
107 it != _all.end();
108 ++it) {
109 if ((* it) == static_cast<TRGCDCSegmentHit*>(t)) {
110 _all.erase(it);
111 break;
112 }
113 }
114 free(t);
115
116// cout << "<---------------------" << endl;
117// cout << "==> " << t << " erased" << endl;
118// for (unsigned i = 0; i < _all.size(); i++)
119// cout << "< " << i << " " << _all[i] << endl;
120 }
121
123} // namespace Belle2
A class to represent a track segment hit in CDC.
Definition: SegmentHit.h:31
A class to represent a wire in CDC.
Definition: Segment.h:39
virtual const TRGCDCCell & cell(void) const
returns a pointer to a TRGCDCWire.
Definition: CellHit.h:252
TRGCDCSegmentHit(const TRGCDCSegment &)
Constructor.
Definition: SegmentHit.cc:32
static void removeAll(void)
destructs all TRGCDCCellHit objects. (Called by TRGCDC)
Definition: SegmentHit.cc:84
static std::vector< TRGCDCSegmentHit * > _all
Keeps all TRGCDCSegmentHit created by new().
Definition: SegmentHit.h:73
virtual void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const override
dumps debug information.
Definition: SegmentHit.cc:71
virtual ~TRGCDCSegmentHit()
Destructor.
Definition: SegmentHit.cc:54
const TRGCDCSegment & segment(void) const
returns a pointer to a track segment.
Definition: SegmentHit.cc:78
static int sortById(const TRGCDCSegmentHit **a, const TRGCDCSegmentHit **b)
Sorting funnction.
Definition: SegmentHit.cc:59
Abstract base class for different kinds of events.
STL namespace.