18 "originalTrackParticle");
42 <<
" as the source collection for GSF track particles");
44 <<
"GSF track particles associated with objects in "
46 <<
" will be marked as kept true in the ThinningHandle "
47 <<
"otherwise as kept false");
54 <<
" as the source collection for inner detector track particles");
56 ATH_MSG_INFO(
"Inner detector track particles refitted to produce"
58 <<
" will be retained when the corresponding "
59 <<
m_gsfSGKey.key() <<
" track particle will be retained");
62 "Inner detector track particles in a cone dr "
64 <<
" obects will be marked as kept true in the ThinningHandle "
65 <<
"otherwise as kept false");
72 <<
" as the source collection for GSF conversion vertices");
74 <<
" GSF conversion vertices will be kept");
83 return StatusCode::SUCCESS;
103 return StatusCode::SUCCESS;
114 std::unique_ptr<SG::ThinningHandle<xAOD::TrackParticleContainer>>
115 importedTrackParticles =
nullptr;
117 importedTrackParticles =
118 std::make_unique<SG::ThinningHandle<xAOD::TrackParticleContainer>>(
124 ? importedTrackParticles->cptr()
127 unsigned int nTracks = tps ? tps->
size() : 0;
128 unsigned int nGSF = gsfs->
size();
130 ATH_MSG_DEBUG(
"nTracks : " << nTracks <<
" , nGSF : " << nGSF);
131 if (nTracks == 0 && nGSF == 0) {
133 return StatusCode::SUCCESS;
137 std::vector<bool> mask, gsfMask;
138 mask.assign(nTracks,
false);
139 gsfMask.assign(nGSF,
false);
145 if (!importedEgamma.
isValid()) {
147 <<
" found in StoreGate!");
148 return StatusCode::FAILURE;
151 size_t nEgammas(importedEgamma->size());
159 std::vector<int>
entries = m_parser->evaluateAsVector();
160 unsigned int nEntries =
entries.size();
162 if (nEgammas != nEntries) {
163 ATH_MSG_ERROR(
"Sizes incompatible! Are you sure your selection string "
164 "used e-gamma objects??");
165 return StatusCode::FAILURE;
168 for (
unsigned int i = 0; i < nEgammas; ++i)
184 "nor for Photons ??");
191 unsigned int n_pass = 0;
192 for (
unsigned int i = 0; i < nTracks; ++i) {
198 unsigned int n_gsf_pass = 0;
199 for (
unsigned int i = 0; i < nGSF; ++i) {
207 importedGSFTrackParticles.
keep(gsfMask);
209 importedTrackParticles->keep(mask);
212 return StatusCode::SUCCESS;
216 const EventContext& ctx)
const
221 unsigned int nGSFVtx = gsfVtxs->
size();
226 std::vector<bool> gsfVtxMask(nGSFVtx,
false);
229 importedGSFConversionVtx.
keep(gsfVtxMask);
234 const EventContext& ctx,
235 std::vector<bool>& mask,
236 std::vector<bool>& gsfMask,
242 ATH_MSG_ERROR(
"Thinning track particles/vertices associated to photons"
243 "but no conversion vertex key provided");
250 unsigned int nGSFVtx = gsfVtxs->
size(), n_gsfVtx_pass = 0;
251 std::vector<bool> gsfVtxMask(nGSFVtx,
false);
256 for (
const auto*
egamma : *egammas) {
262 "EgammaTrackParticleThinning::setPhotonMasks");
269 std::vector<ElementLink<xAOD::VertexContainer>> vertexLinks =
270 photon->vertexLinks();
271 unsigned int nLinks = vertexLinks.size();
276 for (
unsigned int i = 0; i < nLinks; ++i) {
277 if (!(vertexLinks[i])) {
280 if (!(vertexLinks[i]).
isValid()) {
283 gsfVtxMask[vertexLinks[i].index()] =
true;
289 for (
unsigned int i = 0; i < nLinks; ++i) {
290 if (!(vertexLinks[i]).
isValid()) {
293 gsfVtxMask[vertexLinks[i].index()] =
true;
299 for (
const auto& link : trackParticleLinks) {
300 if (!link.isValid()) {
303 gsfMask[link.index()] =
true;
306 orig(*((*gsfs)[link.index()]));
308 int inDetIndex = origTrackLink.
index();
309 if (inDetIndex>=0 ) [[
likely]] mask[inDetIndex] =
true;
315 importedGSFConversionVtx.
keep(gsfVtxMask);
316 for (
bool b : gsfVtxMask) {
325 std::vector<bool>& mask,
326 std::vector<bool>& gsfMask,
332 for (
const auto *
egamma : *egammas) {
340 "EgammaTrackParticleThinning::setElectronMasks");
349 unsigned int nGSFLinks =
m_bestMatchOnly ? 1 : electron->nTrackParticles();
350 for (
unsigned int i = 0; i < nGSFLinks; ++i) {
351 if (!(electron->trackParticleLink(i).isValid())) {
354 int gsfIndex = electron->trackParticleLink(i).index();
355 if (gsfIndex < 0)[[
unlikely]]
continue;
356 gsfMask[gsfIndex] =
true;
359 orig(*((*gsfs)[gsfIndex]));
361 int inDetIndex = origTrackLink.
index();
362 if (inDetIndex>=0 ) [[
likely]] mask[inDetIndex] =
true;
#define ATH_CHECK
Evaluate an expression and check for errors.
bool isValid() const
Test to see if the link can be dereferenced.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_INFO(x,...)
DataVector adapter that acts like it holds const pointers.
Handle for requesting thinning for a data object.
DataVector adapter that acts like it holds const pointers.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const DV * asDataVector() const
Return a pointer to this object, as a const DataVector.
size_type size() const noexcept
Returns the number of elements in the collection.
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_inDetSGKey
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_gsfSGKey
virtual ~EgammaTrackParticleThinning()
EgammaTrackParticleThinning(const std::string &t, const std::string &n, const IInterface *p)
BooleanProperty m_bestVtxMatchOnly
std::atomic< unsigned long int > m_ntotGSFVtx
std::atomic< unsigned long int > m_nGSFVtxPass
SG::ThinningHandleKey< xAOD::VertexContainer > m_gsfVtxSGKey
virtual StatusCode finalize() override
virtual StatusCode doThinning(const EventContext &ctx) const override
std::atomic< unsigned long int > m_nGSFPass
StringProperty m_streamName
BooleanProperty m_bestMatchOnly
std::atomic< unsigned long int > m_ntot
std::atomic< unsigned long int > m_nEgammas
std::atomic< unsigned long int > m_ntotGSF
void clearGSFVtx(const EventContext &ctx) const
void setPhotonMasks(const EventContext &ctx, std::vector< bool > &, std::vector< bool > &, const xAOD::EgammaContainer *, const xAOD::TrackParticleContainer *, const xAOD::TrackParticleContainer *) const
virtual StatusCode initialize() override
StringProperty m_selectionString
void setElectronMasks(std::vector< bool > &, std::vector< bool > &, const xAOD::EgammaContainer *, const xAOD::TrackParticleContainer *, const xAOD::TrackParticleContainer *) const
std::atomic< unsigned long int > m_nSelEgammas
std::atomic< unsigned long int > m_npass
SG::ReadHandleKey< xAOD::EgammaContainer > m_egammaKey
ElementLink implementation for ROOT usage.
index_type index() const
Get the index of the element inside of its container.
bool isValid() const
Check if the element can be found.
Helper class to provide type-safe access to aux data.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
void keep(size_t ndx)
Mark that index ndx in the container should be kept (not thinned away).
Handle for requesting thinning for a data object.
const TrackParticleLinks_t & trackParticleLinks() const
Get all the particles associated with the vertex.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
@ Photon
The object is a photon.
@ Electron
The object is an electron.
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
Photon_v1 Photon
Definition of the current "egamma version".
EgammaContainer_v1 EgammaContainer
Definition of the current "egamma container version".
Electron_v1 Electron
Definition of the current "egamma version".
void select(const xAOD::IParticle *particle, float coneSize, const xAOD::TrackParticleContainer *tracks, std::vector< bool > &mask)