1 |
#include "TCPhysObject.h"
|
2 |
|
3 |
TCPhysObject::TCPhysObject() {
|
4 |
_isPF = _isReco = false;
|
5 |
}
|
6 |
|
7 |
TCPhysObject::TCPhysObject(TLorentzVector p4, int charge) {
|
8 |
this->SetP4(p4);
|
9 |
this->SetCharge(charge);
|
10 |
|
11 |
_isPF = _isReco = false;
|
12 |
}
|
13 |
|
14 |
TCPhysObject::TCPhysObject(TLorentzVector p4, int charge, string type) {
|
15 |
this->SetP4(p4);
|
16 |
this->SetCharge(charge);
|
17 |
this->SetType(type);
|
18 |
|
19 |
_isPF = _isReco = false;
|
20 |
}
|
21 |
|
22 |
TCPhysObject::~TCPhysObject() {
|
23 |
}
|
24 |
|
25 |
// "get" methods -------------------------------------
|
26 |
|
27 |
using namespace std;
|
28 |
|
29 |
float TCPhysObject::IdMap(string key) {
|
30 |
|
31 |
//Check that key is present in the id map
|
32 |
try {
|
33 |
string exception = "Can't find " + key + " in id map";
|
34 |
if (_IdMap.count(key) == 0)
|
35 |
throw exception;
|
36 |
} catch (string ex) {
|
37 |
cout << ex << endl;
|
38 |
}
|
39 |
|
40 |
return _IdMap[key];
|
41 |
}
|
42 |
|
43 |
float TCPhysObject::IsoMap(string key) {
|
44 |
|
45 |
//Check that key is present in the iso map
|
46 |
try {
|
47 |
string exception = "Can't find " + key + " in isolation map";
|
48 |
if (_IsoMap.count(key) == 0)
|
49 |
throw exception;
|
50 |
} catch (string ex) {
|
51 |
cout << ex << endl;
|
52 |
}
|
53 |
|
54 |
return _IsoMap[key];
|
55 |
}
|
56 |
|
57 |
TVector2 TCPhysObject::P2() const {
|
58 |
TVector2 v2(this->Px(), this->Py());
|
59 |
return v2;
|
60 |
}
|
61 |
|
62 |
TVector3 TCPhysObject::Vtx() const { return _vtx; }
|
63 |
string TCPhysObject::Type() const { return _type; }
|
64 |
int TCPhysObject::Charge() const { return _charge; }
|
65 |
bool TCPhysObject::IsPF() const { return _isPF; }
|
66 |
bool TCPhysObject::IsReco() const { return _isReco; }
|
67 |
|
68 |
// "set" methods ---------------------------------------------
|
69 |
|
70 |
void TCPhysObject::SetP4(TLorentzVector p4) { this->SetPxPyPzE(p4.Px(), p4.Py(), p4.Pz(), p4.E()); }
|
71 |
void TCPhysObject::SetIdMap(string s, float v){ _IdMap[s] = v; }
|
72 |
void TCPhysObject::SetIsoMap(string s, float v){ _IsoMap[s] = v; }
|
73 |
|
74 |
void TCPhysObject::SetVtx(float vx, float vy, float vz) {
|
75 |
TVector3 v3(vx, vy, vz);
|
76 |
_vtx = v3;
|
77 |
}
|
78 |
|
79 |
void TCPhysObject::SetCharge(int c){ _charge = c; }
|
80 |
void TCPhysObject::SetType(string s){ _type = s; }
|
81 |
void TCPhysObject::SetPF(bool p){ _isPF = p;}
|
82 |
void TCPhysObject::SetReco(bool r){ _isReco = r;}
|
83 |
|
84 |
// generally useful methods -----------------------------------
|
85 |
|
86 |
float TCPhysObject::Dxy(TVector3 *primVtx) const {
|
87 |
//Calculating track dxy parameter
|
88 |
//wrt primary vertex d0 = - dxy
|
89 |
float vx = _vtx.X(), vy = _vtx.Y();
|
90 |
float px = this->Px(), py = this->Py(), pt = this->Pt();
|
91 |
float pvx = primVtx->X(), pvy = primVtx->Y();
|
92 |
float ret = (-(vx-pvx)*py + (vy-pvy)*px)/pt;
|
93 |
return ret;
|
94 |
}
|
95 |
|
96 |
float TCPhysObject::Dz(TVector3 *primVtx) const {
|
97 |
//Calculating track dz parameter wrt primary vertex
|
98 |
float vx = _vtx.X(), vy = _vtx.Y(), vz = _vtx.Z();
|
99 |
float px = this->Px(), py = this->Py();
|
100 |
float pz = this->Pz(), pt = this->Pt();
|
101 |
float pvx = primVtx->X(), pvy = primVtx->Y(), pvz = primVtx->Z();
|
102 |
float ret = (vz-pvz)-((vx-pvx)*px +(vy-pvy)*py)/pt*(pz/pt);
|
103 |
return ret;
|
104 |
}
|