ATLAS Offline Software
Loading...
Searching...
No Matches
TracksInCone.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5// ======================================================================
6// TracksInCone
7// James.Catmore@cern.ch
8// Given an xAOD::IParticle and an IDTrackParticle container, checks
9// which tracks are in a cone of a given size around the IParticle. Sets
10// a mask accordingly. Intended for thinning use.
11// ======================================================================
12#pragma once
13
14#include "xAODBase/IParticle.h"
17
18namespace DerivationFramework {
20
21 void select(const xAOD::IParticle* particle, float coneSize, const xAOD::TrackParticleContainer* tracks, std::vector<bool> &mask) {
22 float particleEta = particle->eta();
23 float particlePhi = particle->phi();
24 unsigned int i(0);
25 for (xAOD::TrackParticleContainer::const_iterator trIt = tracks->begin(); trIt!=tracks->end(); ++trIt, ++i) {
26 float deltaEta = (*trIt)->eta() - particleEta;
27 float deltaPhi = fabs((*trIt)->phi() - particlePhi);
28 if (deltaPhi > TMath::Pi()) deltaPhi = 2.0*TMath::Pi() - deltaPhi;
29 float deltaR = sqrt(deltaEta*deltaEta + deltaPhi*deltaPhi);
30 if (deltaR < coneSize) mask[i] = true;
31 }
32 return;
33 }
34
35 // Extend the functionality to tau tracks for consistency (TauTrackParticleThinning),
36 // although it's not recommended to select tau tracks based on dR;
37 // the selection should only rely on the tau track classification
38 void select(const xAOD::IParticle* particle, float coneSize, const xAOD::TauTrackContainer* tracks, std::vector<bool> &mask) {
39 float particleEta = particle->eta();
40 float particlePhi = particle->phi();
41 unsigned int i(0);
42 for (xAOD::TauTrackContainer::const_iterator trIt = tracks->begin(); trIt!=tracks->end(); ++trIt, ++i) {
43 float deltaEta = (*trIt)->eta() - particleEta;
44 float deltaPhi = fabs((*trIt)->phi() - particlePhi);
45 if (deltaPhi > TMath::Pi()) deltaPhi = 2.0*TMath::Pi() - deltaPhi;
46 float deltaR = sqrt(deltaEta*deltaEta + deltaPhi*deltaPhi);
47 if (deltaR < coneSize) mask[i] = true;
48 }
49 return;
50 }
51 };
52}
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
Class providing the definition of the 4-vector interface.
THE reconstruction tool.
double deltaR(double eta1, double eta2, double phi1, double phi2)
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
TauTrackContainer_v1 TauTrackContainer
Definition of the current TauTrack container version.
void select(const xAOD::IParticle *particle, float coneSize, const xAOD::TrackParticleContainer *tracks, std::vector< bool > &mask)
void select(const xAOD::IParticle *particle, float coneSize, const xAOD::TauTrackContainer *tracks, std::vector< bool > &mask)