ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
SelectedParticles Class Reference

#include <SelectedParticles.h>

Collaboration diagram for SelectedParticles:

Public Member Functions

 SelectedParticles ()
 
 SelectedParticles (const std::vector< unsigned > &indices)
 
void Set (const std::vector< unsigned > &onoffBits)
 
void SetMaxBits (unsigned maxbits)
 
void SetBit (unsigned i, bool good=true)
 
 ~SelectedParticles ()
 
std::string displayBits () const
 
bool isGood (unsigned i) const
 
unsigned numGood () const
 
void goodParticles (std::vector< unsigned > &goodparts) const
 
const std::vector< unsigned > & AllBits () const
 

Private Attributes

std::vector< unsigned > m_bits
 

Detailed Description

Definition at line 54 of file SelectedParticles.h.

Constructor & Destructor Documentation

◆ SelectedParticles() [1/2]

SelectedParticles::SelectedParticles ( )
inline

Definition at line 58 of file SelectedParticles.h.

58 :m_bits(){;}

◆ SelectedParticles() [2/2]

SelectedParticles::SelectedParticles ( const std::vector< unsigned > &  indices)

Definition at line 11 of file SelectedParticles.cxx.

11  :m_bits(){
12  int nind=indices.size();
13  this->SetMaxBits(nind);
14  for(int i=0;i<nind;++i){
15  this->SetBit(indices[i],true);
16  }
17 }

◆ ~SelectedParticles()

SelectedParticles::~SelectedParticles ( )
inline

Definition at line 65 of file SelectedParticles.h.

65 {;}

Member Function Documentation

◆ AllBits()

const std::vector<unsigned>& SelectedParticles::AllBits ( ) const
inline

Definition at line 76 of file SelectedParticles.h.

76 {return m_bits;}

◆ displayBits()

string SelectedParticles::displayBits ( ) const

Definition at line 49 of file SelectedParticles.cxx.

50 {
51  stringstream os;
52  unsigned c;
53  // Invariant: displayed j 32-bit ints so far
54  unsigned nwords=m_bits.size();
55  vector<unsigned>::const_iterator itb=m_bits.begin();
56  int j=0;
57  for (; itb != m_bits.end(); ++itb){
58  // display mask will be a single 1 at the most significant bit
59  unsigned displayMask = 1u << 31;
60  // need to display the words in reverse order
61  int temp = nwords - j - 1;
62  ++j;
63  // Invariant: displayed c bits in the unsigned int
64  // displayMask has shifted its bits c places
65  for (c = 0; c != 32; c++ ) {
66  //if the current most significant bit in value temp is a 1
67  // display it if not display zero
68  os << (m_bits[temp] & displayMask ? '1' : '0');
69  // shift the displayMask one bit, so there is a new
70  // bit to check with value
71  displayMask >>= 1;
72 
73  // group display by bytes
74  if (c % 8 == 7 )
75  os << ' ';
76  }
77  // a new line for each 32-bit line
78  os << std::endl;
79  }
80  os << std::endl;
81  return os.str();
82 }

◆ goodParticles()

void SelectedParticles::goodParticles ( std::vector< unsigned > &  goodparts) const

Definition at line 121 of file SelectedParticles.cxx.

122 {
123  unsigned nbits=m_bits.size()*32;
124  for(unsigned ibit=0; ibit<nbits; ++ibit) {
125  if(isGood(ibit)) goodparts.push_back(ibit);
126  }
127  return;
128 }

◆ isGood()

bool SelectedParticles::isGood ( unsigned  i) const

Definition at line 84 of file SelectedParticles.cxx.

85 {
86 
87  unsigned c;
88  unsigned nwords=m_bits.size();
89  vector<unsigned>::const_iterator itb=m_bits.begin();
90  unsigned j=ipart/32;
91  if(j>nwords-1) return false; // this should probably be an abort
92  for (; itb != m_bits.end(); ++itb){
93  // display mask will be a single 1 at the most significant bit
94  unsigned displayMask = 1;
95 
96  // Invariant: displayed c bits in the unsigned int
97  // displayMask has shifted its bits c places
98  for (c = 0; c != 32; c++ ) {
99  //if the current most significant bit in value temp is a 1
100  // display it if not display zero
101  if (m_bits[j] & displayMask) {
102  if(c==ipart) return true;
103  }
104  // shift the displayMask one bit, so there is a new
105  // bit to check with value
106  displayMask <<= 1;
107  }
108  }
109  return false;
110 }

◆ numGood()

unsigned SelectedParticles::numGood ( ) const

Definition at line 112 of file SelectedParticles.cxx.

113 {
114  unsigned nwords=m_bits.size();
115  if(nwords==0) return 0;
116  vector<unsigned> goodparts;
117  goodParticles(goodparts);
118  return goodparts.size();
119 }

◆ Set()

void SelectedParticles::Set ( const std::vector< unsigned > &  onoffBits)
inline

Definition at line 60 of file SelectedParticles.h.

60 { m_bits=onoffBits;}

◆ SetBit()

void SelectedParticles::SetBit ( unsigned  i,
bool  good = true 
)

Definition at line 19 of file SelectedParticles.cxx.

19  {
20  unsigned nwords=m_bits.size();
21  unsigned iword=i/32;
22 
23  if(iword+1>nwords){
24  for(unsigned iw=nwords; iw<iword+1; ++iw){
25  unsigned temp=0;
26  m_bits.push_back(temp);
27  }
28  }
29 
30  if(good==false) return;
31 
32  unsigned bitnum = i % 32 ;
33  unsigned temp = 1 << bitnum;
34  m_bits[iword] |= temp;
35 
36  return;
37 }

◆ SetMaxBits()

void SelectedParticles::SetMaxBits ( unsigned  maxbits)

Definition at line 39 of file SelectedParticles.cxx.

40 {
41  unsigned nwords=maxbits/32;
42  for(unsigned iw=0; iw<nwords+1; ++iw){
43  unsigned temp=0;
44  m_bits.push_back(temp);
45  }
46 }

Member Data Documentation

◆ m_bits

std::vector<unsigned> SelectedParticles::m_bits
private

Definition at line 78 of file SelectedParticles.h.


The documentation for this class was generated from the following files:
temp
Definition: JetEventDict.h:21
SelectedParticles::SetBit
void SetBit(unsigned i, bool good=true)
Definition: SelectedParticles.cxx:19
SelectedParticles::SetMaxBits
void SetMaxBits(unsigned maxbits)
Definition: SelectedParticles.cxx:39
Trk::indices
std::pair< long int, long int > indices
Definition: AlSymMatBase.h:24
SelectedParticles::isGood
bool isGood(unsigned i) const
Definition: SelectedParticles.cxx:84
SelectedParticles::goodParticles
void goodParticles(std::vector< unsigned > &goodparts) const
Definition: SelectedParticles.cxx:121
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
lumiFormat.i
int i
Definition: lumiFormat.py:85
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
SelectedParticles::m_bits
std::vector< unsigned > m_bits
Definition: SelectedParticles.h:78
ReadBchFromCool.good
good
Definition: ReadBchFromCool.py:433
python.compressB64.c
def c
Definition: compressB64.py:93