test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PSimHitMap.cc
Go to the documentation of this file.
3 
5 {
6  theMap.clear();
8  LogTrace("PSimHitMap") << "getting CrossingFrame<PSimHit> collection ";
9  e.getByToken(sh_token, cf);
10 
12  LogTrace("PSimHitMap") <<"... size = "<<simHits.size();
13 
14  // arrange the hits by detUnit
15  for(MixCollection<PSimHit>::MixItr hitItr = simHits.begin();
16  hitItr != simHits.end(); ++hitItr)
17  {
18  theMap[hitItr->detUnitId()].push_back(*hitItr);
19  }
20 }
21 
22 const edm::PSimHitContainer & PSimHitMap::hits(int detId) const
23 {
24  std::map<int, edm::PSimHitContainer>::const_iterator mapItr
25  = theMap.find(detId);
26  if(mapItr != theMap.end())
27  {
28  return mapItr->second;
29  }
30  else
31  {
32  return theEmptyContainer;
33  }
34 }
35 
36 
37 std::vector<int> PSimHitMap::detsWithHits() const
38 {
39  std::vector<int> result;
40  result.reserve(theMap.size());
41  for(std::map<int, edm::PSimHitContainer>::const_iterator mapItr = theMap.begin(),
42  mapEnd = theMap.end();
43  mapItr != mapEnd;
44  ++mapItr)
45  {
46  result.push_back(mapItr->first);
47  }
48  return result;
49 }
edm::PSimHitContainer theEmptyContainer
Definition: PSimHitMap.h:28
void fill(const edm::Event &e)
Definition: PSimHitMap.cc:4
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
tuple result
Definition: mps_fire.py:83
const edm::PSimHitContainer & hits(int detId) const
Definition: PSimHitMap.cc:22
edm::EDGetTokenT< CrossingFrame< PSimHit > > sh_token
Definition: PSimHitMap.h:30
#define LogTrace(id)
std::vector< int > detsWithHits() const
Definition: PSimHitMap.cc:37
std::map< int, edm::PSimHitContainer > theMap
Definition: PSimHitMap.h:27
T const * product() const
Definition: Handle.h:81
tuple simHits
Definition: trackerHits.py:16
std::vector< PSimHit > PSimHitContainer