CMS 3D CMS Logo

Public Member Functions | Private Attributes

PSimHitMap Class Reference

#include <PSimHitMap.h>

List of all members.

Public Member Functions

std::vector< int > detsWithHits () const
void fill (const edm::Event &e)
const edm::PSimHitContainerhits (int detId) const
 PSimHitMap (const edm::InputTag &)

Private Attributes

edm::InputTag simHitsTag
edm::PSimHitContainer theEmptyContainer
std::map< int,
edm::PSimHitContainer
theMap

Detailed Description

Definition at line 9 of file PSimHitMap.h.


Constructor & Destructor Documentation

PSimHitMap::PSimHitMap ( const edm::InputTag collectionTag)

Definition at line 5 of file PSimHitMap.cc.

:  theMap(),
   theEmptyContainer(),  
   simHitsTag(collectionTag)
{
}

Member Function Documentation

std::vector< int > PSimHitMap::detsWithHits ( ) const

Definition at line 47 of file PSimHitMap.cc.

References query::result, and theMap.

Referenced by CSCRecHit2DValidation::analyze(), and CSCSegmentValidation::fillLayerHitsPerChamber().

{
  std::vector<int> result;
  result.reserve(theMap.size());
  for(std::map<int, edm::PSimHitContainer>::const_iterator mapItr = theMap.begin(),
      mapEnd = theMap.end();
      mapItr != mapEnd;
      ++mapItr)
  {
    result.push_back(mapItr->first);
  }
  return result;
} 
void PSimHitMap::fill ( const edm::Event e)

Definition at line 13 of file PSimHitMap.cc.

References edm::Event::getByLabel(), LogTrace, edm::Handle< T >::product(), trackerHits::simHits, simHitsTag, and theMap.

Referenced by CSCDigiValidation::analyze(), and CSCRecHitValidation::analyze().

{
  theMap.clear();
  edm::Handle<CrossingFrame<PSimHit> > cf;
  LogTrace("PSimHitMap") <<"getting CrossingFrame<PSimHit> collection - "<<simHitsTag;
  e.getByLabel(simHitsTag, cf);

  MixCollection<PSimHit> simHits(cf.product());
  LogTrace("PSimHitMap") <<"... size = "<<simHits.size();

  // arrange the hits by detUnit
  for(MixCollection<PSimHit>::MixItr hitItr = simHits.begin();
      hitItr != simHits.end(); ++hitItr)
  {
    theMap[hitItr->detUnitId()].push_back(*hitItr);
  }
}
const edm::PSimHitContainer & PSimHitMap::hits ( int  detId) const

Definition at line 32 of file PSimHitMap.cc.

References theEmptyContainer, and theMap.

Referenced by CSCWireDigiValidation::analyze(), CSCRecHit2DValidation::analyze(), CSCSegmentValidation::fillLayerHitsPerChamber(), and CSCSegmentValidation::keyHit().

{
  std::map<int, edm::PSimHitContainer>::const_iterator mapItr
    = theMap.find(detId);
  if(mapItr != theMap.end())
  {
    return mapItr->second;
  }
  else
  {
    return theEmptyContainer;
  }
}

Member Data Documentation

Definition at line 23 of file PSimHitMap.h.

Referenced by fill().

Definition at line 22 of file PSimHitMap.h.

Referenced by hits().

std::map<int, edm::PSimHitContainer> PSimHitMap::theMap [private]

Definition at line 21 of file PSimHitMap.h.

Referenced by detsWithHits(), fill(), and hits().