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