1 |
/*
|
2 |
* Particle.cpp
|
3 |
*
|
4 |
* Created on: 2 Jul 2010
|
5 |
* Author: kreczko
|
6 |
*/
|
7 |
|
8 |
#include "../../interface/RecoObjects/Particle.h"
|
9 |
|
10 |
namespace BAT {
|
11 |
|
12 |
Particle::Particle() :
|
13 |
particleMass(0), particleCharge(0), distanceFromInteractionPointInMicron(999999),
|
14 |
distanceFromInteractionPointInMicron_wrt_to_BeamSpot(999999), fourvector(0., 0., 0., 0.) {
|
15 |
|
16 |
}
|
17 |
|
18 |
Particle::Particle(const Particle& particle) :
|
19 |
particleMass(particle.mass()), particleCharge(particle.charge()), distanceFromInteractionPointInMicron(
|
20 |
particle.d0()), distanceFromInteractionPointInMicron_wrt_to_BeamSpot(particle.d0_wrtBeamSpot()), fourvector(
|
21 |
particle.getFourVector()) {
|
22 |
|
23 |
}
|
24 |
|
25 |
Particle::Particle(float energy, float px, float py, float pz) :
|
26 |
particleMass(0),
|
27 |
particleCharge(0),
|
28 |
distanceFromInteractionPointInMicron(99999),
|
29 |
distanceFromInteractionPointInMicron_wrt_to_BeamSpot(999999),
|
30 |
fourvector(px, py, pz, energy) {
|
31 |
}
|
32 |
|
33 |
Particle::~Particle() {
|
34 |
}
|
35 |
|
36 |
float Particle::mass() const {
|
37 |
if (particleMass == 0)
|
38 |
return massFromEnergyAndMomentum();
|
39 |
else
|
40 |
return particleMass;
|
41 |
}
|
42 |
|
43 |
float Particle::d0() const {
|
44 |
return distanceFromInteractionPointInMicron;
|
45 |
}
|
46 |
|
47 |
float Particle::d0_wrtBeamSpot() const {
|
48 |
return distanceFromInteractionPointInMicron_wrt_to_BeamSpot;
|
49 |
}
|
50 |
|
51 |
float Particle::energy() const {
|
52 |
return fourvector.Energy();
|
53 |
}
|
54 |
|
55 |
float Particle::et() const {
|
56 |
return fourvector.Et();
|
57 |
}
|
58 |
|
59 |
float Particle::px() const {
|
60 |
return fourvector.Px();
|
61 |
}
|
62 |
|
63 |
float Particle::py() const {
|
64 |
return fourvector.Py();
|
65 |
}
|
66 |
|
67 |
float Particle::pz() const {
|
68 |
return fourvector.Pz();
|
69 |
}
|
70 |
|
71 |
float Particle::pt() const {
|
72 |
return fourvector.Pt();
|
73 |
}
|
74 |
|
75 |
float Particle::eta() const {
|
76 |
return fourvector.Eta();
|
77 |
}
|
78 |
|
79 |
float Particle::phi() const {
|
80 |
return fourvector.Phi();
|
81 |
}
|
82 |
|
83 |
float Particle::theta() const {
|
84 |
return fourvector.Theta();
|
85 |
}
|
86 |
|
87 |
float Particle::massFromEnergyAndMomentum() const {
|
88 |
return fourvector.M();
|
89 |
}
|
90 |
|
91 |
float Particle::charge() const {
|
92 |
return particleCharge;
|
93 |
}
|
94 |
|
95 |
void Particle::setMass(float mass) {
|
96 |
particleMass = mass;
|
97 |
}
|
98 |
|
99 |
void Particle::setD0(float d0) {
|
100 |
distanceFromInteractionPointInMicron = d0;
|
101 |
}
|
102 |
|
103 |
void Particle::setD0_wrtBeamSpot(float d0) {
|
104 |
distanceFromInteractionPointInMicron_wrt_to_BeamSpot = d0;
|
105 |
}
|
106 |
|
107 |
const FourVector& Particle::getFourVector() const {
|
108 |
return fourvector;
|
109 |
}
|
110 |
|
111 |
void Particle::setFourVector(FourVector vector) {
|
112 |
fourvector = vector;
|
113 |
}
|
114 |
|
115 |
void Particle::setCharge(float charge) {
|
116 |
particleCharge = charge;
|
117 |
}
|
118 |
|
119 |
Particle & Particle::operator =(const Particle &rightHandSide) {
|
120 |
if (this == &rightHandSide)
|
121 |
return *this;
|
122 |
fourvector = rightHandSide.getFourVector();
|
123 |
// particleMass = rightHandSide.mass();
|
124 |
return *this;
|
125 |
}
|
126 |
|
127 |
Particle & Particle::operator+=(const Particle &rightHandSide) {
|
128 |
fourvector += rightHandSide.getFourVector();
|
129 |
setMass(0.);
|
130 |
setCharge(charge() + rightHandSide.charge());
|
131 |
return *this;
|
132 |
}
|
133 |
|
134 |
const Particle Particle::operator +(const Particle &other) const {
|
135 |
Particle result = *this;
|
136 |
FourVector vector = result.getFourVector() + other.getFourVector();
|
137 |
result.setFourVector(vector);
|
138 |
result.setMass(0);
|
139 |
result.setCharge(result.charge() + other.charge());
|
140 |
return result;
|
141 |
}
|
142 |
|
143 |
bool Particle::isInBarrelRegion() const {
|
144 |
return fabs(eta()) < 1.4442;
|
145 |
}
|
146 |
|
147 |
bool Particle::isInCrack() const {
|
148 |
return !isInBarrelRegion() && !isInEndCapRegion();
|
149 |
}
|
150 |
|
151 |
bool Particle::isInEndCapRegion() const {
|
152 |
return fabs(eta()) > 1.5660;
|
153 |
}
|
154 |
|
155 |
const char* Particle::getEtaRegion() const {
|
156 |
if (isInBarrelRegion())
|
157 |
return "barrel";
|
158 |
else if (isInCrack())
|
159 |
return "crack";
|
160 |
else if (isInEndCapRegion())
|
161 |
return "endcap";
|
162 |
else
|
163 |
return "unknown";
|
164 |
}
|
165 |
|
166 |
float Particle::deltaEta(const ParticlePointer other) const {
|
167 |
return eta() - other->eta();
|
168 |
}
|
169 |
|
170 |
float Particle::deltaPhi(const ParticlePointer other) const {
|
171 |
return fourvector.DeltaPhi(other->getFourVector());
|
172 |
}
|
173 |
|
174 |
float Particle::deltaR(const ParticlePointer other) const {
|
175 |
return fourvector.DeltaR(other->getFourVector());
|
176 |
}
|
177 |
|
178 |
bool Particle::isWithinDeltaR(float delta_R, const ParticlePointer particle) const {
|
179 |
return deltaR(particle) < delta_R;
|
180 |
}
|
181 |
|
182 |
float Particle::invariantMass(const ParticlePointer otherParticle) const {
|
183 |
TLorentzVector combinedParticle(fourvector + otherParticle->getFourVector());
|
184 |
return combinedParticle.M();
|
185 |
}
|
186 |
|
187 |
float Particle::relativePtTo(const ParticlePointer otherParticle) const {
|
188 |
float relativePt = fourvector.Perp(otherParticle->getFourVector().Vect());
|
189 |
return fabs(relativePt);
|
190 |
}
|
191 |
|
192 |
unsigned short Particle::getClosest(const ParticleCollection& particles) const {
|
193 |
unsigned short idOfClosest = 999;
|
194 |
float closestDR = 999.;
|
195 |
for (unsigned short index = 0; index < particles.size(); ++index) {
|
196 |
float DR = deltaR(particles.at(index));
|
197 |
if (DR < closestDR) {
|
198 |
closestDR = DR;
|
199 |
idOfClosest = index;
|
200 |
}
|
201 |
}
|
202 |
return idOfClosest;
|
203 |
}
|
204 |
|
205 |
float Particle::angle(const ParticlePointer otherParticle) const {
|
206 |
return fourvector.Angle(otherParticle->getFourVector().Vect());
|
207 |
}
|
208 |
}
|