ATLAS Offline Software
Loading...
Searching...
No Matches
AnalysisSelection.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef ANALYSISUTILS_ANALYSISSELECTION_H
6#define ANALYSISUTILS_ANALYSISSELECTION_H
7
15
16#include <vector>
17
18namespace AnalysisUtils {
19
20 template <class CRITERIA> struct Selection : public CRITERIA
21 {
22
28 template <class COLL> void getObjects(const COLL *coll, std::vector<typename COLL::value_type> &out)
29 {
30 out.clear();
31
32 // loop over all elements
33 typename COLL::const_iterator it = coll->begin();
34 typename COLL::const_iterator itE = coll->end();
35 for (; it != itE; ++it)
36 // selection
37 if (CRITERIA::isAccepted(*it))
38 out.push_back(*it);
39 }
40
46 template <class COLL> void getIndices(const COLL *coll, std::vector<int> &out)
47 {
48 out.clear();
49
50 // loop over all elements
51 int index = 0;
52 typename COLL::const_iterator it = coll->begin();
53 typename COLL::const_iterator itE = coll->end();
54 for (; it != itE; ++it)
55 {
56 // selection
57 if (CRITERIA::isAccepted(*it))
58 out.push_back(index);
59
60 ++index;
61 }
62 }
63 };
64
65} // end of AnalysisUtils namespace
66
67#endif
utility class to select combination of elements in a collection
Definition index.py:1
void getIndices(const COLL *coll, std::vector< int > &out)
get indices of the objects which pass the selection criteria
void getObjects(const COLL *coll, std::vector< typename COLL::value_type > &out)
get objects which pass the selection criteria