~maus-detector-integration/maus/ckov_merge

« back to all changes in this revision

Viewing changes to src/common_cpp/DataStructure/Hit.cc

  • Committer: Chris Rogers
  • Date: 2012-03-05 16:24:30 UTC
  • mfrom: (340.32.8 release)
  • Revision ID: chris.rogers@stfc.ac.uk-20120305162430-5v76jvrfqmrw4z4u
MergeĀ releaseĀ 0.1.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of MAUS: http://micewww.pp.rl.ac.uk/projects/maus
 
2
 *
 
3
 * MAUS is free software: you can redistribute it and/or modify
 
4
 * it under the terms of the GNU General Public License as published by
 
5
 * the Free Software Foundation, either version 3 of the License, or
 
6
 * (at your option) any later version.
 
7
 *
 
8
 * MAUS is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with MAUS.  If not, see <http://www.gnu.org/licenses/>.
 
15
 */
 
16
 
 
17
#include "src/common_cpp/DataStructure/Hit.hh"
 
18
 
 
19
namespace MAUS {
 
20
 
 
21
Hit::Hit() : _track_id(0), _particle_id(0), _energy(0), _charge(0), _time(0),
 
22
             _energy_deposited(0), _position(0, 0, 0), _momentum(0, 0, 0),
 
23
             _channel_id(NULL) {
 
24
}
 
25
 
 
26
Hit::Hit(const Hit& md)
 
27
           : _track_id(0), _particle_id(0), _energy(0), _charge(0), _time(0),
 
28
             _energy_deposited(0), _position(0, 0, 0), _momentum(0, 0, 0),
 
29
             _channel_id(NULL) {
 
30
    *this = md;
 
31
}
 
32
 
 
33
Hit& Hit::operator=(const Hit& md) {
 
34
    if (this == &md) {
 
35
        return *this;
 
36
    }
 
37
    _track_id = md._track_id;
 
38
    _particle_id = md._particle_id;
 
39
    _energy = md._energy;
 
40
    _charge = md._charge;
 
41
    _time = md._time;
 
42
    _energy_deposited = md._energy_deposited;
 
43
    _position = md._position;
 
44
    _momentum = md._momentum;
 
45
    if (_channel_id != NULL) {
 
46
        delete _channel_id;
 
47
    }
 
48
    if (md._channel_id == NULL) {
 
49
        _channel_id = NULL;
 
50
    } else {
 
51
        _channel_id = md._channel_id->Clone();
 
52
    }
 
53
    return *this;
 
54
}
 
55
 
 
56
Hit::~Hit() {
 
57
    if (_channel_id != NULL) {
 
58
        delete _channel_id;
 
59
        _channel_id = NULL;
 
60
    }
 
61
}
 
62
 
 
63
 
 
64
int Hit::GetTrackId() const {
 
65
    return _track_id;
 
66
}
 
67
 
 
68
void Hit::SetTrackId(int id) {
 
69
    _track_id = id;
 
70
}
 
71
 
 
72
int Hit::GetParticleId() const {
 
73
    return _particle_id;
 
74
}
 
75
 
 
76
void Hit::SetParticleId(int pid) {
 
77
    _particle_id = pid;
 
78
}
 
79
 
 
80
double Hit::GetEnergy() const {
 
81
    return _energy;
 
82
}
 
83
 
 
84
void Hit::SetEnergy(double energy) {
 
85
    _energy = energy;
 
86
}
 
87
 
 
88
double Hit::GetCharge() const {
 
89
    return _charge;
 
90
}
 
91
 
 
92
void Hit::SetCharge(double charge) {
 
93
    _charge = charge;
 
94
}
 
95
 
 
96
double Hit::GetTime() const {
 
97
    return _time;
 
98
}
 
99
 
 
100
void Hit::SetTime(double time) {
 
101
    _time = time;
 
102
}
 
103
 
 
104
double Hit::GetEnergyDeposited() const {
 
105
    return _energy_deposited;
 
106
}
 
107
 
 
108
void Hit::SetEnergyDeposited(double edep) {
 
109
    _energy_deposited = edep;
 
110
}
 
111
 
 
112
ThreeVector Hit::GetPosition() const {
 
113
    return _position;
 
114
}
 
115
 
 
116
void Hit::SetPosition(ThreeVector pos) {
 
117
    _position = pos;
 
118
}
 
119
 
 
120
ThreeVector Hit::GetMomentum() const {
 
121
    return _momentum;
 
122
}
 
123
 
 
124
void Hit::SetMomentum(ThreeVector mom) {
 
125
    _momentum = mom;
 
126
}
 
127
 
 
128
ChannelId* Hit::GetChannelId() const {
 
129
    return _channel_id;
 
130
}
 
131
 
 
132
void Hit::SetChannelId(ChannelId* id) {
 
133
    if (_channel_id != NULL) {
 
134
        delete _channel_id;
 
135
    }
 
136
    _channel_id = id;
 
137
}
 
138
}