1 #ifndef ANALYSISFUNCTIONS
2 #define ANALYSISFUNCTIONS
5 #include "TLorentzVector.h"
7 #include "TClonesArray.h"
16 #include "classes/DelphesClasses.h"
20 template<
class T>std::vector<T *>
SelectorFcn(std::vector<T *>particles,
23 std::vector<T *> output_list;
37 inline std::map<std::string, float>
DISVariables(TClonesArray *branchParticle)
40 auto pProton =
static_cast<GenParticle *
>(branchParticle->At(0))->P4();
50 auto pleptonIn =
static_cast<GenParticle *
>(branchParticle->At(3))->P4();
51 auto pleptonOut =
static_cast<GenParticle *
>(branchParticle->At(5))->P4();
52 auto pPhoton = pleptonIn - pleptonOut;
55 float Q2 = -pPhoton.M2();
56 float W2 = (pProton + pPhoton).M2();
57 float x = Q2 / (2. * pProton.Dot(pPhoton));
58 float y = (pProton.Dot(pPhoton)) / (pProton.Dot(pleptonIn));
61 std::map<std::string, float> dis_variables;
62 dis_variables[
"Q2"] = Q2;
63 dis_variables[
"W2"] = W2;
64 dis_variables[
"x"] =
x;
65 dis_variables[
"y"] =
y;
71 TClonesArray *electrons,
72 TClonesArray *photons,
73 TClonesArray *neutral_hadrons)
76 float delta_track = 0.0;
77 auto temp_p = TVector3();
79 for (
int i = 0; i < tracks->GetEntries(); i++) {
80 auto track_mom =
static_cast<Track *
>(tracks->At(i))->P4();
82 if (isnan(track_mom.E()))
84 delta_track += (track_mom.E() - track_mom.Pz());
85 temp_p = temp_p + track_mom.Vect();
88 float delta_track_noel = 0.0;
90 if (electrons->GetEntries() > 0) {
91 auto e =
static_cast<Track *
>(electrons->At(0))->P4();
94 delta_track_noel = delta_track - (
e.E() -
e.Pz());
98 float delta_photon = 0.0;
100 for (
int i = 0; i < photons->GetEntries(); i++) {
101 auto pf_mom =
static_cast<Photon *
>(photons->At(i))->P4();
103 if (isnan(pf_mom.E()))
105 delta_photon += (pf_mom.E() - pf_mom.Pz());
106 temp_p = temp_p + pf_mom.Vect();
109 float delta_neutral = 0;
110 float delta_neutral_noBarrel = 0;
111 auto ptmiss_noBarrel = TVector3();
113 for (
int i = 0; i < neutral_hadrons->GetEntries(); i++) {
114 auto pf_mom =
static_cast<Tower *
>(neutral_hadrons->At(i))->P4();
116 if (isnan(pf_mom.E()))
118 delta_neutral += (pf_mom.E() - pf_mom.Pz());
119 temp_p = temp_p + pf_mom.Vect();
121 if (TMath::Abs(pf_mom.Eta()) > 1.0) {
122 delta_neutral_noBarrel += (pf_mom.E() - pf_mom.Pz());
123 ptmiss_noBarrel = ptmiss_noBarrel + pf_mom.Vect();
127 float delta = delta_track + delta_photon + delta_neutral;
132 float delta_noBarrel = delta_track + delta_photon + delta_neutral_noBarrel;
134 float y_JB = delta / (2.0 * 10.0);
135 auto ptmiss = temp_p.Perp();
136 float Q2_JB = (ptmiss * ptmiss) / (1.0 - y_JB);
137 float s = 4.0 * 10.0 * 275.0;
138 float x_JB = Q2_JB / (s * y_JB);
140 std::map<std::string, float> dis_variables;
141 dis_variables[
"x_JB"] = x_JB;
142 dis_variables[
"Q2_JB"] = Q2_JB;
143 dis_variables[
"y_JB"] = y_JB;
145 return dis_variables;
154 bool good_track =
true;
158 float d0 = TMath::Abs(track->D0);
159 float z0 = TMath::Abs(track->DZ);
167 float r0 = TMath::Sqrt(d0 * d0 + z0 * z0);
177 const TLorentzVector& jetMomentum = jet->P4();
178 float jpx = jetMomentum.Px();
179 float jpy = jetMomentum.Py();
180 float jpz = jetMomentum.Pz();
182 float d0 = TMath::Abs(track->D0);
184 float xd = track->Xd;
185 float yd = track->Yd;
186 float zd = track->Zd;
187 float dd0 = TMath::Abs(track->ErrorD0);
188 float dz = TMath::Abs(track->DZ);
189 float ddz = TMath::Abs(track->ErrorDZ);
191 int sign = (jpx * xd + jpy * yd + jpz * zd > 0.0) ? 1 : -1;
194 float sip = sign * TMath::Sqrt(TMath::Power(d0 / dd0, 2) + TMath::Power(dz / ddz, 2));
197 if (!
IsTaggingTrack(track) || TMath::IsNaN(sip) || !TMath::Finite(sip)) {
206 inline bool Tagged_Kaon(
Jet *jet, std::vector<Track *>kaons,
float minSignif,
float minPT,
int minKaons)
211 for (
auto kaon : kaons) {
212 if (kaon->P4().DeltaR(jet->P4()) > 0.5)
215 if (kaon->PT < minPT)
222 if (
sIP3D(jet, kaon) < minSignif)
227 if (kaon_count >= minKaons)
231 tagged = (kaon_count >= minKaons);
236 inline bool Tagged_Electron(
Jet *jet, std::vector<Track *>electrons,
float minSignif,
float minPT,
int minElectrons)
239 int electron_count = 0;
241 for (
auto electron : electrons) {
242 if (electron->P4().DeltaR(jet->P4()) > 0.5)
245 if (electron->PT < minPT)
251 if (
sIP3D(jet, electron) < minSignif)
256 if (electron_count >= minElectrons)
260 tagged = (electron_count >= minElectrons);
265 inline bool Tagged_Muon(
Jet *jet, std::vector<Track *>muons,
float minSignif,
float minPT,
int minMuons)
270 for (
auto muon : muons) {
271 if (muon->P4().DeltaR(jet->P4()) > 0.5)
274 if (muon->PT < minPT)
280 if (
sIP3D(jet, muon) < minSignif)
286 if (muon_count >= minMuons)
290 tagged = (muon_count >= minMuons);
296 float minSignif,
float minPT,
int minTracks)
300 const TLorentzVector& jetMomentum = jet->P4();
301 float jpx = jetMomentum.Px();
302 float jpy = jetMomentum.Py();
303 float jpz = jetMomentum.Pz();
305 auto jet_constituents = tracks;
312 for (
int iconst = 0; iconst < jet_constituents.GetEntries(); iconst++) {
313 if (N_sIPtrack >= minTracks)
316 auto constituent = jet_constituents.At(iconst);
318 if (constituent == 0)
continue;
320 if (constituent->IsA() == Track::Class()) {
321 auto track =
static_cast<Track *
>(constituent);
323 const TLorentzVector& trkMomentum = track->P4();
324 float tpt = trkMomentum.Pt();
326 if (tpt < minPT)
continue;
328 if (trkMomentum.DeltaR(jetMomentum) > 0.5)
337 float sip =
sIP3D(jet, track);
340 if (sip > minSignif) N_sIPtrack++;
344 tagged = (N_sIPtrack >= minTracks);
351 #endif // ifndef ANALYSISFUNCTIONS