ATLAS Offline Software
Loading...
Searching...
No Matches
SelectedParticles.h
Go to the documentation of this file.
1// dear emacs, this is -*- C++ -*-
2
3/*
4 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
5*/
6
7#ifndef PARTICLEEVENT_SELECTEDPARTICLES_H
8#define PARTICLEEVENT_SELECTEDPARTICLES_H 1
9
11// //
12// SelectedParticles //
13// //
14// Store on/off bits for selected particles
15// S. Protopopescu 9 Sep. 2008
16// //
18
20//
21// SelectedBranches is a container mirroring a parent branch with particles
22// there should be only one instance in a branch, one can have multiple branches per parent branch
23//
24// For each particle i a bit is stored indicating whether selected or rejected)
25// User can supply own vector of unsigned integers with bits set (1=selected, 0=rejected)
26// or create an empty instance with default constructor and set bits with
27// SetBit(i, true or false)
28//
29// If less than 32 particles then it is sufficient to call SetBit(i) for selected particles only
30//
31// If more than 32 particles one should either call SetBit(i, true or false) for every particle
32// or call SetMaxBits(num of particles) and SetBit(i) for selected particles only
33//
34// Note that once a bit is set to true there is no mechanism for resetting it to false.
35//
36//
38//
39// isGood(i) will return true if ith particle was selected
40//
41// goodParticles(std::vector<unsigned>& goodparts ) will return list of selected particle numbers
42//
43// displayBits() will print out the stored bits
44// Note that because SelectedParticles stores a vector of unsigned integers it does not know the
45// number of particles in parent branch
46// Selected Particles is useless if parent branch is discarded or trimmed
47//
49#include <vector>
50#include<string>
53
55
56 public:
57
59 SelectedParticles(const std::vector<unsigned>& indices);
60 void Set(const std::vector<unsigned>& onoffBits){ m_bits=onoffBits;}
61 // supply max number of bits
62 void SetMaxBits(unsigned maxbits);
63 // set specific bit
64 void SetBit(unsigned i, bool good=true);
66
67 // display the bits
68 std::string displayBits() const;
69 // find if ith particle was selected
70 bool isGood(unsigned i) const;
71 // how many good particles
72 unsigned numGood() const;
73 // list of good particles
74 void goodParticles(std::vector<unsigned>& goodparts ) const;
75 // return all bits
76 const std::vector<unsigned>& AllBits() const {return m_bits;}
77 private:
78 std::vector<unsigned> m_bits;
79
80};
81 CLASS_DEF(SelectedParticles, 162859305, 1 )
82
83
84#endif // !PARTICLEEVENT_SELECTEDPARTICLES_H
85
macros to associate a CLID to a type
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
void SetMaxBits(unsigned maxbits)
void Set(const std::vector< unsigned > &onoffBits)
void SetBit(unsigned i, bool good=true)
const std::vector< unsigned > & AllBits() const
std::vector< unsigned > m_bits
std::string displayBits() const
bool isGood(unsigned i) const
void goodParticles(std::vector< unsigned > &goodparts) const
unsigned numGood() const