CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
DetIdSelector Class Reference

#include <DetIdSelector.h>

Public Member Functions

 DetIdSelector ()
 
 DetIdSelector (const std::string &selstring)
 
 DetIdSelector (const std::vector< std::string > &selstrings)
 
 DetIdSelector (const edm::ParameterSet &selconfig)
 
bool isSelected (const DetId &detid) const
 
bool isSelected (const unsigned int &rawid) const
 
bool isValid () const
 
bool operator() (const DetId &detid) const
 
bool operator() (const unsigned int &rawid) const
 

Private Member Functions

void addSelection (const std::string &selstring)
 
void addSelection (const std::vector< std::string > &selstrings)
 

Private Attributes

std::vector< unsigned int > m_masks
 
std::vector< unsigned int > m_selections
 

Detailed Description

Definition at line 12 of file DetIdSelector.h.

Constructor & Destructor Documentation

◆ DetIdSelector() [1/4]

DetIdSelector::DetIdSelector ( )

Definition at line 6 of file DetIdSelector.cc.

6 : m_selections(), m_masks() {}
std::vector< unsigned int > m_masks
Definition: DetIdSelector.h:30
std::vector< unsigned int > m_selections
Definition: DetIdSelector.h:29

◆ DetIdSelector() [2/4]

DetIdSelector::DetIdSelector ( const std::string &  selstring)

Definition at line 8 of file DetIdSelector.cc.

References addSelection().

8 : m_selections(), m_masks() { addSelection(selstring); }
std::vector< unsigned int > m_masks
Definition: DetIdSelector.h:30
std::vector< unsigned int > m_selections
Definition: DetIdSelector.h:29
void addSelection(const std::string &selstring)

◆ DetIdSelector() [3/4]

DetIdSelector::DetIdSelector ( const std::vector< std::string > &  selstrings)

Definition at line 10 of file DetIdSelector.cc.

References addSelection().

10  : m_selections(), m_masks() {
11  addSelection(selstrings);
12 }
std::vector< unsigned int > m_masks
Definition: DetIdSelector.h:30
std::vector< unsigned int > m_selections
Definition: DetIdSelector.h:29
void addSelection(const std::string &selstring)

◆ DetIdSelector() [4/4]

DetIdSelector::DetIdSelector ( const edm::ParameterSet selconfig)

Definition at line 14 of file DetIdSelector.cc.

References addSelection(), and edm::ParameterSet::getUntrackedParameter().

14  : m_selections(), m_masks() {
15  const std::vector<std::string> selstrings = selconfig.getUntrackedParameter<std::vector<std::string> >("selection");
16  addSelection(selstrings);
17 }
std::vector< unsigned int > m_masks
Definition: DetIdSelector.h:30
T getUntrackedParameter(std::string const &, T const &) const
std::vector< unsigned int > m_selections
Definition: DetIdSelector.h:29
void addSelection(const std::string &selstring)

Member Function Documentation

◆ addSelection() [1/2]

void DetIdSelector::addSelection ( const std::string &  selstring)
private

Definition at line 19 of file DetIdSelector.cc.

References LogDebug, m_masks, m_selections, ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering::pixelStatus::mask, and corrVsCorr::selection.

Referenced by addSelection(), and DetIdSelector().

19  {
20  unsigned int selection;
21  unsigned int mask;
22 
23  if (selstring.substr(0, 2) == "0x") {
24  sscanf(selstring.c_str(), "%x-%x", &mask, &selection);
25  } else {
26  sscanf(selstring.c_str(), "%u-%u", &mask, &selection);
27  }
28 
29  m_selections.push_back(selection);
30  m_masks.push_back(mask);
31 
32  LogDebug("Selection added") << "Selection " << selection << " with mask " << mask << " added";
33 }
selection
main part
Definition: corrVsCorr.py:100
std::vector< unsigned int > m_masks
Definition: DetIdSelector.h:30
std::vector< unsigned int > m_selections
Definition: DetIdSelector.h:29
#define LogDebug(id)

◆ addSelection() [2/2]

void DetIdSelector::addSelection ( const std::vector< std::string > &  selstrings)
private

Definition at line 35 of file DetIdSelector.cc.

References addSelection().

35  {
36  for (std::vector<std::string>::const_iterator selstring = selstrings.begin(); selstring != selstrings.end();
37  ++selstring) {
38  addSelection(*selstring);
39  }
40 }
void addSelection(const std::string &selstring)

◆ isSelected() [1/2]

bool DetIdSelector::isSelected ( const DetId detid) const

Definition at line 51 of file DetIdSelector.cc.

References DetId::rawId().

Referenced by FEDBadModuleFilter::filter(), and operator()().

51 { return isSelected(detid.rawId()); }
bool isSelected(const DetId &detid) const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57

◆ isSelected() [2/2]

bool DetIdSelector::isSelected ( const unsigned int &  rawid) const

Definition at line 42 of file DetIdSelector.cc.

References mps_fire::i, m_masks, and m_selections.

42  {
43  for (unsigned int i = 0; i < m_selections.size(); ++i) {
44  if ((m_masks[i] & rawid) == m_selections[i])
45  return true;
46  }
47 
48  return false;
49 }
std::vector< unsigned int > m_masks
Definition: DetIdSelector.h:30
std::vector< unsigned int > m_selections
Definition: DetIdSelector.h:29

◆ isValid()

bool DetIdSelector::isValid ( void  ) const
inline

Definition at line 23 of file DetIdSelector.h.

References m_selections.

Referenced by ntupleDataFormat._Object::_checkIsValid(), FEDBadModuleFilter::filter(), and core.AutoHandle.AutoHandle::ReallyLoad().

23 { return !m_selections.empty(); }
std::vector< unsigned int > m_selections
Definition: DetIdSelector.h:29

◆ operator()() [1/2]

bool DetIdSelector::operator() ( const DetId detid) const

Definition at line 53 of file DetIdSelector.cc.

References isSelected(), and DetId::rawId().

53 { return isSelected(detid.rawId()); }
bool isSelected(const DetId &detid) const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57

◆ operator()() [2/2]

bool DetIdSelector::operator() ( const unsigned int &  rawid) const

Definition at line 55 of file DetIdSelector.cc.

References isSelected().

55 { return isSelected(rawid); }
bool isSelected(const DetId &detid) const

Member Data Documentation

◆ m_masks

std::vector<unsigned int> DetIdSelector::m_masks
private

Definition at line 30 of file DetIdSelector.h.

Referenced by addSelection(), and isSelected().

◆ m_selections

std::vector<unsigned int> DetIdSelector::m_selections
private

Definition at line 29 of file DetIdSelector.h.

Referenced by addSelection(), isSelected(), and isValid().