CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes
RPCHitAssociator Class Reference

#include <RPCHitAssociator.h>

Public Types

typedef edm::DetSetVector
< RPCDigiSimLink
RPCDigiSimLinks
 
typedef std::pair< uint32_t,
EncodedEventId
SimHitIdpr
 

Public Member Functions

std::vector< SimHitIdprassociateRecHit (const TrackingRecHit &hit)
 
std::set< RPCDigiSimLinkfindRPCDigiSimLink (uint32_t rpcDetId, int strip, int bx)
 
 RPCHitAssociator (const edm::Event &, const edm::EventSetup &, const edm::ParameterSet &)
 
 ~RPCHitAssociator ()
 

Private Attributes

std::map< unsigned int,
edm::PSimHitContainer
_SimHitMap
 
edm::Handle< edm::DetSetVector
< RPCDigiSimLink > > 
_thelinkDigis
 
bool crossingframe
 
edm::InputTag RPCdigisimlinkTag
 
edm::InputTag RPCsimhitsTag
 
edm::InputTag RPCsimhitsXFTag
 

Detailed Description

Definition at line 31 of file RPCHitAssociator.h.

Member Typedef Documentation

Definition at line 34 of file RPCHitAssociator.h.

typedef std::pair<uint32_t, EncodedEventId> RPCHitAssociator::SimHitIdpr

Definition at line 35 of file RPCHitAssociator.h.

Constructor & Destructor Documentation

RPCHitAssociator::RPCHitAssociator ( const edm::Event e,
const edm::EventSetup eventSetup,
const edm::ParameterSet conf 
)

Definition at line 6 of file RPCHitAssociator.cc.

References _SimHitMap, _thelinkDigis, MixCollection< T >::begin(), crossingframe, edm::Event::getByLabel(), edm::InputTag::label(), LogTrace, edm::Handle< T >::product(), RPCdigisimlinkTag, RPCsimhitsTag, and RPCsimhitsXFTag.

6  :
7 
8  RPCdigisimlinkTag(conf.getParameter<edm::InputTag>("RPCdigisimlinkTag")),
9  // CrossingFrame used or not ?
10  crossingframe(conf.getParameter<bool>("crossingframe")),
11  RPCsimhitsTag(conf.getParameter<edm::InputTag>("RPCsimhitsTag")),
12  RPCsimhitsXFTag(conf.getParameter<edm::InputTag>("RPCsimhitsXFTag"))
13 
14 {
15  if (crossingframe) {
16 
18  LogTrace("RPCHitAssociator") <<"getting CrossingFrame<PSimHit> collection - "<<RPCsimhitsXFTag;
20 
21  std::auto_ptr<MixCollection<PSimHit> >
22  RPCsimhits( new MixCollection<PSimHit>(cf.product()) );
23  LogTrace("RPCHitAssociator") <<"... size = "<<RPCsimhits->size();
24 
25  // MixCollection<PSimHit> & simHits = *hits;
26 
27  for(MixCollection<PSimHit>::MixItr hitItr = RPCsimhits->begin();
28  hitItr != RPCsimhits->end(); ++hitItr)
29  {
30  _SimHitMap[hitItr->detUnitId()].push_back(*hitItr);
31  }
32 
33  } else if (!RPCsimhitsTag.label().empty()) {
35  LogTrace("RPCHitAssociator") <<"getting PSimHit collection - "<<RPCsimhitsTag;
36  e.getByLabel(RPCsimhitsTag, RPCsimhits);
37  LogTrace("RPCHitAssociator") <<"... size = "<<RPCsimhits->size();
38 
39  // arrange the hits by detUnit
40  for(edm::PSimHitContainer::const_iterator hitItr = RPCsimhits->begin();
41  hitItr != RPCsimhits->end(); ++hitItr)
42  {
43  _SimHitMap[hitItr->detUnitId()].push_back(*hitItr);
44  }
45  }
46 
48  LogTrace("RPCHitAssociator") <<"getting RPCDigiSimLink collection - "<<RPCdigisimlinkTag;
49  e.getByLabel(RPCdigisimlinkTag, thelinkDigis);
50  _thelinkDigis = thelinkDigis;
51 }
T getParameter(std::string const &) const
edm::InputTag RPCdigisimlinkTag
std::map< unsigned int, edm::PSimHitContainer > _SimHitMap
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
#define LogTrace(id)
edm::InputTag RPCsimhitsTag
iterator begin()
edm::InputTag RPCsimhitsXFTag
T const * product() const
Definition: Handle.h:74
std::string const & label() const
Definition: InputTag.h:42
edm::Handle< edm::DetSetVector< RPCDigiSimLink > > _thelinkDigis
RPCHitAssociator::~RPCHitAssociator ( )
inline

Definition at line 41 of file RPCHitAssociator.h.

41 {}

Member Function Documentation

std::vector< RPCHitAssociator::SimHitIdpr > RPCHitAssociator::associateRecHit ( const TrackingRecHit hit)

Definition at line 54 of file RPCHitAssociator.cc.

References RPCRecHit::BunchX(), RPCRecHit::clusterSize(), spr::find(), findRPCDigiSimLink(), RPCRecHit::firstClusterStrip(), i, electronStore::links, DetId::rawId(), and RPCRecHit::rpcId().

Referenced by MuonAssociatorByHits::getMatchedIds().

54  {
55 
56  std::vector<SimHitIdpr> matched;
57 
58  const TrackingRecHit * hitp = &hit;
59  const RPCRecHit * rpcrechit = dynamic_cast<const RPCRecHit *>(hitp);
60 
61  if (rpcrechit) {
62 
63  RPCDetId rpcDetId = rpcrechit->rpcId();
64  int fstrip = rpcrechit->firstClusterStrip();
65  int cls = rpcrechit->clusterSize();
66  int bx = rpcrechit->BunchX();
67 
68  for(int i = fstrip; i < fstrip+cls; ++i) {
69  std::set<RPCDigiSimLink> links = findRPCDigiSimLink(rpcDetId.rawId(),i,bx);
70 
71  if (links.empty()) edm::LogWarning("RPCHitAssociator")
72  <<"*** WARNING in RPCHitAssociator::associateRecHit, RPCRecHit "<<*rpcrechit<<", strip "<<i<<" has no associated RPCDigiSimLink !"<<endl;
73 
74  for(std::set<RPCDigiSimLink>::iterator itlink = links.begin(); itlink != links.end(); ++itlink) {
75  SimHitIdpr currentId(itlink->getTrackId(),itlink->getEventId());
76  if(find(matched.begin(),matched.end(),currentId ) == matched.end())
77  matched.push_back(currentId);
78  }
79  }
80 
81  } else edm::LogWarning("RPCHitAssociator")<<"*** WARNING in RPCHitAssociator::associateRecHit, null dynamic_cast !";
82 
83  return matched;
84 }
int firstClusterStrip() const
Definition: RPCRecHit.h:107
int i
Definition: DBlmapReader.cc:9
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
std::set< RPCDigiSimLink > findRPCDigiSimLink(uint32_t rpcDetId, int strip, int bx)
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
int clusterSize() const
Definition: RPCRecHit.h:111
RPCDetId rpcId() const
Return the rpcId.
Definition: RPCRecHit.h:99
std::pair< uint32_t, EncodedEventId > SimHitIdpr
int BunchX() const
Definition: RPCRecHit.h:103
std::set< RPCDigiSimLink > RPCHitAssociator::findRPCDigiSimLink ( uint32_t  rpcDetId,
int  strip,
int  bx 
)

Definition at line 86 of file RPCHitAssociator.cc.

References _thelinkDigis, edm::DetSetVector< T >::begin(), cond::rpcobgas::detid, edm::DetSetVector< T >::end(), and electronStore::links.

Referenced by associateRecHit().

86  {
87 
88  std::set<RPCDigiSimLink> links;
89 
91  for(edm::DetSet<RPCDigiSimLink>::const_iterator digi_iter=itlink->data.begin();digi_iter != itlink->data.end();++digi_iter){
92 
93  uint32_t detid = digi_iter->getDetUnitId();
94  int str = digi_iter->getStrip();
95  int bunchx = digi_iter->getBx();
96 
97  if(detid == rpcDetId && str == strip && bunchx == bx){
98  links.insert(*digi_iter);
99  }
100 
101  }
102  }
103 
104  return links;
105 }
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:356
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:341
collection_type::const_iterator const_iterator
Definition: DetSet.h:34
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:106
edm::Handle< edm::DetSetVector< RPCDigiSimLink > > _thelinkDigis

Member Data Documentation

std::map<unsigned int, edm::PSimHitContainer> RPCHitAssociator::_SimHitMap
private

Definition at line 56 of file RPCHitAssociator.h.

Referenced by RPCHitAssociator().

edm::Handle< edm::DetSetVector<RPCDigiSimLink> > RPCHitAssociator::_thelinkDigis
private

Definition at line 49 of file RPCHitAssociator.h.

Referenced by findRPCDigiSimLink(), and RPCHitAssociator().

bool RPCHitAssociator::crossingframe
private

Definition at line 52 of file RPCHitAssociator.h.

Referenced by RPCHitAssociator().

edm::InputTag RPCHitAssociator::RPCdigisimlinkTag
private

Definition at line 50 of file RPCHitAssociator.h.

Referenced by RPCHitAssociator().

edm::InputTag RPCHitAssociator::RPCsimhitsTag
private

Definition at line 53 of file RPCHitAssociator.h.

Referenced by RPCHitAssociator().

edm::InputTag RPCHitAssociator::RPCsimhitsXFTag
private

Definition at line 54 of file RPCHitAssociator.h.

Referenced by RPCHitAssociator().