109{
110
111 bool is_muons = false;
112 bool is_egamma = false;
113 bool is_tau = false;
114 bool is_track = false;
115
116
117 SG::ReadHandle<xAOD::CaloClusterContainer> importedCaloCluster;
119 importedCaloCluster =
120 SG::ReadHandle<xAOD::CaloClusterContainer>(
m_CaloClSGKey, ctx);
121 }
122
123
124 SG::ReadHandle<xAOD::CaloClusterContainer> importedTopoCaloCluster;
126 importedTopoCaloCluster =
127 SG::ReadHandle<xAOD::CaloClusterContainer>(
m_TopoClSGKey, ctx);
128 }
129
130 unsigned int nClusters = 0;
132 nClusters = importedCaloCluster->size();
133 }
134 unsigned int nTopoClusters = 0;
136 nTopoClusters = importedTopoCaloCluster->size();
137 }
138 if (nClusters == 0 && nTopoClusters == 0) {
139 return StatusCode::SUCCESS;
140 }
141
142
143 std::vector<bool>
mask(nClusters,
false), topomask(nTopoClusters,
false);
146
147
148 SG::ReadHandle<xAOD::IParticleContainer> importedParticlesHandle{
m_sgKey,
149 ctx };
151 importedParticlesHandle.
ptr();
152
153
154 unsigned int nParticles(importedParticles->
size());
155 if (nParticles == 0) {
157 SG::ThinningHandle<xAOD::CaloClusterContainer> thin(
m_CaloClSGKey, ctx);
158 thin.keep(mask);
159 }
161 SG::ThinningHandle<xAOD::CaloClusterContainer> thin(
m_TopoClSGKey, ctx);
162 thin.keep(topomask);
163 }
164 return StatusCode::SUCCESS;
165 }
166
167 is_egamma = false;
168 is_muons = false;
169 is_track = false;
170
171
177 is_egamma = true;
178 }
181 if (testMuons) {
182 is_muons = true;
183 }
186 if (testTaus) {
187 is_tau = true;
188 }
191 if (testTracks) {
192 is_track = true;
193 }
194
195 if (!(is_egamma || is_muons || is_tau || is_track)) {
196 ATH_MSG_ERROR(
"This tool only works with Egamma, Muons, Taus and Tracks "
197 <<
m_sgKey.key() <<
" is not a compatible collection");
198 return StatusCode::FAILURE;
199 }
200
201
202
204 std::vector<int>
entries = m_parser->evaluateAsVector();
206
207 if (nParticles != nEntries) {
208 ATH_MSG_ERROR(
"Sizes incompatible! Are you sure your selection string "
209 "used e-gamma objects??");
210 return StatusCode::FAILURE;
211 }
212 std::vector<const xAOD::IParticle*> particlesToCheck = {};
213
214 for (
unsigned int i = 0;
i < nParticles; ++
i) {
215 if (
static_cast<bool>(
entries[i])) {
216 particlesToCheck.push_back((*importedParticles)[i]);
217 }
218 }
220 for (const auto* particle : particlesToCheck) {
222
224 particle,
225 importedCaloCluster.
cptr(),
226 is_muons,
227 is_egamma,
228 is_tau) != StatusCode::SUCCESS) {
229 return StatusCode::FAILURE;
230 }
232 particle,
233 importedCaloCluster.
cptr(),
234 is_muons,
235 is_egamma,
236 is_track) != StatusCode::SUCCESS) {
237 return StatusCode::FAILURE;
238 }
239 }
242 particle,
243 importedTopoCaloCluster.
cptr(),
244 is_muons,
245 is_egamma,
246 is_tau) != StatusCode::SUCCESS) {
247 return StatusCode::FAILURE;
248 }
250 particle,
251 importedTopoCaloCluster.
cptr(),
252 is_muons,
253 is_egamma,
254 is_track) != StatusCode::SUCCESS) {
255 return StatusCode::FAILURE;
256 }
257 }
258 }
259 } else {
260 for (const auto* particle : *importedParticles) {
263 particle,
264 importedCaloCluster.
cptr(),
265 is_muons,
266 is_egamma,
267 is_tau) != StatusCode::SUCCESS) {
268 return StatusCode::FAILURE;
269 }
271 particle,
272 importedCaloCluster.
cptr(),
273 is_muons,
274 is_egamma,
275 is_track) != StatusCode::SUCCESS) {
276 return StatusCode::FAILURE;
277 }
278 }
281 particle,
282 importedTopoCaloCluster.
cptr(),
283 is_muons,
284 is_egamma,
285 is_tau) != StatusCode::SUCCESS) {
286 return StatusCode::FAILURE;
287 }
289 particle,
290 importedTopoCaloCluster.
cptr(),
291 is_muons,
292 is_egamma,
293 is_track) != StatusCode::SUCCESS) {
294 return StatusCode::FAILURE;
295 }
296 }
297 }
298 }
299
300
301 for (
unsigned int i = 0;
i < nClusters; ++
i) {
302 if (mask[i])
304 }
305 for (
unsigned int i = 0;
i < nTopoClusters; ++
i) {
306 if (topomask[i])
308 }
309
310
312 SG::ThinningHandle<xAOD::CaloClusterContainer> thin(
m_CaloClSGKey, ctx);
313 thin.keep(mask);
314 }
316 SG::ThinningHandle<xAOD::CaloClusterContainer> thin(
m_TopoClSGKey, ctx);
317 thin.keep(topomask);
318 }
319 return StatusCode::SUCCESS;
320}
StatusCode testPhotons(const char *APP_NAME, bool quiet)
StatusCode testElectrons(const char *APP_NAME, bool quiet)
size_type size() const noexcept
Returns the number of elements in the collection.
StatusCode particleCluster(std::vector< bool > &mask, const xAOD::IParticle *particle, const xAOD::CaloClusterContainer *cps, bool is_muons, bool is_egamma, bool is_tau) const
SG::ThinningHandleKey< xAOD::CaloClusterContainer > m_TopoClSGKey
SG::ReadHandleKey< xAOD::IParticleContainer > m_sgKey
SG::ThinningHandleKey< xAOD::CaloClusterContainer > m_CaloClSGKey
StatusCode setClustersMask(std::vector< bool > &mask, const xAOD::IParticle *particle, const xAOD::CaloClusterContainer *cps, bool is_muons, bool is_egamma, bool is_track) const
const_pointer_type ptr()
Dereference the pointer.
const_pointer_type cptr()
Dereference the pointer.
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
TauJetContainer_v3 TauJetContainer
Definition of the current "taujet container version".
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.