Belle II Software  release-05-01-25
WireHit.cc
1 //-----------------------------------------------------------------------------
2 // $Id$
3 //-----------------------------------------------------------------------------
4 // Filename : WireHit.cc
5 // Section : TRG CDC
6 // Owner : Yoshihito Iwasaki
7 // Email : yoshihito.iwasaki@kek.jp
8 //-----------------------------------------------------------------------------
9 // Description : A class to represent a wire hit in CDC.
10 //-----------------------------------------------------------------------------
11 // $Log$
12 //-----------------------------------------------------------------------------
13 
14 #define TRG_SHORT_NAMES
15 #define TRGCDC_SHORT_NAMES
16 
17 #include <stdlib.h>
18 #include "trg/cdc/Wire.h"
19 #include "trg/cdc/WireHit.h"
20 
21 using namespace std;
22 
23 namespace Belle2 {
29  vector<TRGCDCWireHit*> TRGCDCWireHit::_all;
30 
31  TRGCDCWireHit::TRGCDCWireHit(const TRGCDCWire& w,
32  unsigned indexCDCHit,
33  unsigned indexCDCSimHit,
34  unsigned indexMCParticle,
35  float driftLeft,
36  float driftLeftError,
37  float driftRight,
38  float driftRightError,
39  int mcLRflag,
40  float fudgeFactor)
41  : TCCHit((TRGCDCCell&) w,
42  indexCDCHit,
43  indexCDCSimHit,
44  indexMCParticle,
45  driftLeft,
46  driftLeftError,
47  driftRight,
48  driftRightError,
49  mcLRflag,
50  fudgeFactor),
51  _mc(), //2019/07/31 by ytlai
52  _iCDCSimHit(indexCDCSimHit)
53  {
54  }
55 
57  {
58  }
59 
60  const TRGCDCWire&
61  TRGCDCWireHit::wire(void) const
62  {
63  return dynamic_cast<const TRGCDCWire&>(cell());
64  }
65 
66  int
68  const TRGCDCWireHit** b)
69  {
70  if ((* a)->cell().id() > (* b)->cell().id())
71  return 1;
72  else if ((* a)->cell().id() == (* b)->cell().id())
73  return 0;
74  else
75  return -1;
76  }
77 
78  void
80  {
81  while (_all.size())
82  delete _all.back();
83  }
84 
85  void*
86  TRGCDCWireHit::operator new(size_t size)
87  {
88  void* p = malloc(size);
89  _all.push_back((TRGCDCWireHit*) p);
90 
91 // cout << ">---------------------" << endl;
92 // for (unsigned i = 0; i < _all.size(); i++)
93 // cout << "> " << i << " " << _all[i] << endl;
94 
95  return p;
96  }
97 
98  void
99  TRGCDCWireHit::operator delete(void* t)
100  {
101  for (vector<TRGCDCWireHit*>::iterator it = _all.begin();
102  it != _all.end();
103  ++it) {
104  if ((* it) == (TRGCDCWireHit*) t) {
105  _all.erase(it);
106  break;
107  }
108  }
109  free(t);
110 
111 // cout << "<---------------------" << endl;
112 // cout << "==> " << t << " erased" << endl;
113 // for (unsigned i = 0; i < _all.size(); i++)
114 // cout << "< " << i << " " << _all[i] << endl;
115  }
116 
118 } // namespace Belle2
Belle2::TRGCDCWireHit::_all
static std::vector< TRGCDCWireHit * > _all
Keeps all TRGCDCWireHit created by new().
Definition: WireHit.h:84
Belle2::TRGCDCWireHit::sortByWireId
static int sortByWireId(const TRGCDCWireHit **a, const TRGCDCWireHit **b)
Sort function. This will be removed.
Definition: WireHit.cc:67
Belle2::TRGCDCWireHit::wire
const TRGCDCWire & wire(void) const
returns a pointer to a TRGCDCWire.
Definition: WireHit.cc:61
Belle2::TRGCDCWire
A class to represent a wire in CDC.
Definition: Wire.h:57
Belle2::TRGCDCCell
A class to represent a wire in CDC.
Definition: Cell.h:41
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TRGCDCWireHit
A class to represent a wire hit in CDC.
Definition: WireHit.h:34
Belle2::TRGCDCWireHit::~TRGCDCWireHit
virtual ~TRGCDCWireHit()
Destructor.
Definition: WireHit.cc:56
Belle2::TRGCDCCellHit::cell
virtual const TRGCDCCell & cell(void) const
returns a pointer to a TRGCDCWire.
Definition: CellHit.h:253
Belle2::TRGCDCWireHit::removeAll
static void removeAll(void)
destructs all TRGCDCCellHit objects. (Called by TRGCDC)
Definition: WireHit.cc:79