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;
110 const EventContext& ctx = Gaudi::Hive::currentContext();
115 std::unique_ptr<SG::ThinningHandle<xAOD::TrackParticleContainer>>
116 importedTrackParticles =
nullptr;
118 importedTrackParticles =
119 std::make_unique<SG::ThinningHandle<xAOD::TrackParticleContainer>>(
125 ? importedTrackParticles->cptr()
128 unsigned int nTracks = tps ? tps->
size() : 0;
129 unsigned int nGSF = gsfs->
size();
131 ATH_MSG_DEBUG(
"nTracks : " << nTracks <<
" , nGSF : " << nGSF);
132 if (nTracks == 0 && nGSF == 0) {
134 return StatusCode::SUCCESS;
138 std::vector<bool> mask, gsfMask;
139 mask.assign(nTracks,
false);
140 gsfMask.assign(nGSF,
false);
146 if (!importedEgamma.
isValid()) {
148 <<
" found in StoreGate!");
149 return StatusCode::FAILURE;
152 size_t nEgammas(importedEgamma->size());
160 std::vector<int>
entries = m_parser->evaluateAsVector();
161 unsigned int nEntries =
entries.size();
163 if (nEgammas != nEntries) {
164 ATH_MSG_ERROR(
"Sizes incompatible! Are you sure your selection string "
165 "used e-gamma objects??");
166 return StatusCode::FAILURE;
169 for (
unsigned int i = 0; i < nEgammas; ++i)
185 "nor for Photons ??");
192 unsigned int n_pass = 0;
193 for (
unsigned int i = 0; i < nTracks; ++i) {
199 unsigned int n_gsf_pass = 0;
200 for (
unsigned int i = 0; i < nGSF; ++i) {
208 importedGSFTrackParticles.
keep(gsfMask);
210 importedTrackParticles->keep(mask);
213 return StatusCode::SUCCESS;
217 const EventContext& ctx)
const
222 unsigned int nGSFVtx = gsfVtxs->
size();
227 std::vector<bool> gsfVtxMask(nGSFVtx,
false);
230 importedGSFConversionVtx.
keep(gsfVtxMask);
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 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 gsfMask[gsfIndex] =
true;
358 orig(*((*gsfs)[gsfIndex]));
360 int inDetIndex = origTrackLink.
index();
361 mask[inDetIndex] =
true;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
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 StatusCode doThinning() const override
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
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(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
Test to see if the link can be dereferenced.
SG::Accessor< T, ALLOC > Accessor
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)