CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

DetIdSelector Class Reference

#include <DetIdSelector.h>

List of all members.

Public Member Functions

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

Definition at line 7 of file DetIdSelector.cc.

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

Definition at line 11 of file DetIdSelector.cc.

References addSelection().

                                                      :
  m_selections(),m_masks()
{
  addSelection(selstring);
}
DetIdSelector::DetIdSelector ( const std::vector< std::string > &  selstrings)

Definition at line 17 of file DetIdSelector.cc.

References addSelection().

                                                                  :
  m_selections(),m_masks()
{
  addSelection(selstrings);
}
DetIdSelector::DetIdSelector ( const edm::ParameterSet selconfig)

Definition at line 23 of file DetIdSelector.cc.

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

                                                            :
  m_selections(),m_masks()
{

  const std::vector<std::string> selstrings = selconfig.getUntrackedParameter<std::vector<std::string> >("selection");
  addSelection(selstrings);

}

Member Function Documentation

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

Definition at line 32 of file DetIdSelector.cc.

References LogDebug, m_masks, m_selections, and corrVsCorr::selection.

Referenced by addSelection(), and DetIdSelector().

                                                           {

  unsigned int selection;
  unsigned int mask;

  if(selstring.substr(0,2) == "0x") {
    sscanf(selstring.c_str(),"%x-%x",&mask,&selection);
  }
  else {
    sscanf(selstring.c_str(),"%u-%u",&mask,&selection);
  }

  m_selections.push_back(selection);
  m_masks.push_back(mask);

  LogDebug("Selection added") << "Selection " << selection << " with mask " << mask << " added";

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

Definition at line 51 of file DetIdSelector.cc.

References addSelection().

                                                                       {

  for(std::vector<std::string>::const_iterator selstring=selstrings.begin();selstring!=selstrings.end();++selstring) {
    addSelection(*selstring);
  }

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

Definition at line 59 of file DetIdSelector.cc.

References i, m_masks, and m_selections.

                                                              {

  for(unsigned int i=0; i<m_selections.size() ; ++i) {
    if((m_masks[i] & rawid) == m_selections[i]) return true;
  }

  return false;
}
bool DetIdSelector::isSelected ( const DetId detid) const

Definition at line 68 of file DetIdSelector.cc.

References DetId::rawId().

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

                                                       {

  return isSelected(detid.rawId());

}
bool DetIdSelector::isValid ( void  ) const [inline]

Definition at line 23 of file DetIdSelector.h.

References m_selections.

Referenced by FEDBadModuleFilter::filter().

{ return m_selections.size()!=0;}
bool DetIdSelector::operator() ( const DetId detid) const

Definition at line 74 of file DetIdSelector.cc.

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

                                                       {

  return isSelected(detid.rawId());

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

Definition at line 80 of file DetIdSelector.cc.

References isSelected().

                                                              {

  return isSelected(rawid);

}

Member Data Documentation

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

Definition at line 31 of file DetIdSelector.h.

Referenced by addSelection(), and isSelected().

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

Definition at line 30 of file DetIdSelector.h.

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