CMS 3D CMS Logo

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

#include <RPCHitAssociator.h>

Public Types

typedef edm::DetSetVector< RPCDigiSimLinkRPCDigiSimLinks
 
typedef std::pair< uint32_t, EncodedEventIdSimHitIdpr
 

Public Member Functions

std::vector< SimHitIdprassociateRecHit (const TrackingRecHit &hit) const
 
std::set< RPCDigiSimLinkfindRPCDigiSimLink (uint32_t rpcDetId, int strip, int bx) const
 
void initEvent (const edm::Event &, const edm::EventSetup &)
 
 RPCHitAssociator (const edm::ParameterSet &, edm::ConsumesCollector &&ic)
 
 RPCHitAssociator (const edm::Event &e, const edm::EventSetup &eventSetup, const edm::ParameterSet &conf)
 
 ~RPCHitAssociator ()
 

Private Attributes

std::map< unsigned int, edm::PSimHitContainer_SimHitMap
 
edm::Handle< edm::DetSetVector< RPCDigiSimLink > > _thelinkDigis
 
bool crossingframe
 
edm::InputTag RPCdigisimlinkTag
 
edm::EDGetTokenT< edm::DetSetVector< RPCDigiSimLink > > RPCdigisimlinkToken_
 
edm::InputTag RPCsimhitsTag
 
edm::EDGetTokenT< edm::PSimHitContainerRPCsimhitsToken_
 
edm::InputTag RPCsimhitsXFTag
 
edm::EDGetTokenT< CrossingFrame< PSimHit > > RPCsimhitsXFToken_
 

Detailed Description

Definition at line 32 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::ParameterSet conf,
edm::ConsumesCollector &&  ic 
)

Definition at line 6 of file RPCHitAssociator.cc.

References crossingframe, edm::InputTag::label(), RPCdigisimlinkTag, RPCdigisimlinkToken_, RPCsimhitsTag, RPCsimhitsToken_, RPCsimhitsXFTag, and RPCsimhitsXFToken_.

7  : RPCdigisimlinkTag(conf.getParameter<edm::InputTag>("RPCdigisimlinkTag")),
8  // CrossingFrame used or not ?
9  crossingframe(conf.getParameter<bool>("crossingframe")),
10  RPCsimhitsTag(conf.getParameter<edm::InputTag>("RPCsimhitsTag")),
11  RPCsimhitsXFTag(conf.getParameter<edm::InputTag>("RPCsimhitsXFTag")) {
12  if (crossingframe) {
14  } else if (!RPCsimhitsTag.label().empty()) {
16  }
17 
19 }
T getParameter(std::string const &) const
edm::InputTag RPCdigisimlinkTag
edm::EDGetTokenT< CrossingFrame< PSimHit > > RPCsimhitsXFToken_
edm::InputTag RPCsimhitsTag
edm::EDGetTokenT< edm::PSimHitContainer > RPCsimhitsToken_
edm::InputTag RPCsimhitsXFTag
std::string const & label() const
Definition: InputTag.h:36
std::vector< PSimHit > PSimHitContainer
edm::EDGetTokenT< edm::DetSetVector< RPCDigiSimLink > > RPCdigisimlinkToken_
RPCHitAssociator::RPCHitAssociator ( const edm::Event e,
const edm::EventSetup eventSetup,
const edm::ParameterSet conf 
)

Definition at line 21 of file RPCHitAssociator.cc.

References initEvent().

24  : RPCdigisimlinkTag(conf.getParameter<edm::InputTag>("RPCdigisimlinkTag")),
25  // CrossingFrame used or not ?
26  crossingframe(conf.getParameter<bool>("crossingframe")),
27  RPCsimhitsTag(conf.getParameter<edm::InputTag>("RPCsimhitsTag")),
28  RPCsimhitsXFTag(conf.getParameter<edm::InputTag>("RPCsimhitsXFTag")) {
29  initEvent(e, eventSetup);
30 }
T getParameter(std::string const &) const
edm::InputTag RPCdigisimlinkTag
void initEvent(const edm::Event &, const edm::EventSetup &)
edm::InputTag RPCsimhitsTag
edm::InputTag RPCsimhitsXFTag
RPCHitAssociator::~RPCHitAssociator ( )
inline

Definition at line 44 of file RPCHitAssociator.h.

References associateRecHit(), findRPCDigiSimLink(), and digitizers_cfi::strip.

44 {}

Member Function Documentation

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

Definition at line 68 of file RPCHitAssociator.cc.

References RPCRecHit::BunchX(), RPCRecHit::clusterSize(), spr::find(), findRPCDigiSimLink(), RPCRecHit::firstClusterStrip(), mps_fire::i, LogTrace, electrons_cff::matched, DetId::rawId(), and RPCRecHit::rpcId().

Referenced by MuonAssociatorByHitsHelper::getMatchedIds(), and ~RPCHitAssociator().

68  {
69  std::vector<SimHitIdpr> matched;
70 
71  const TrackingRecHit *hitp = &hit;
72  const RPCRecHit *rpcrechit = dynamic_cast<const RPCRecHit *>(hitp);
73 
74  if (rpcrechit) {
75  RPCDetId rpcDetId = rpcrechit->rpcId();
76  int fstrip = rpcrechit->firstClusterStrip();
77  int cls = rpcrechit->clusterSize();
78  int bx = rpcrechit->BunchX();
79 
80  for (int i = fstrip; i < fstrip + cls; ++i) {
81  std::set<RPCDigiSimLink> links = findRPCDigiSimLink(rpcDetId.rawId(), i, bx);
82 
83  if (links.empty())
84  LogTrace("RPCHitAssociator") << "*** WARNING in RPCHitAssociator::associateRecHit, RPCRecHit " << *rpcrechit
85  << ", strip " << i << " has no associated RPCDigiSimLink !" << endl;
86 
87  for (std::set<RPCDigiSimLink>::iterator itlink = links.begin(); itlink != links.end(); ++itlink) {
88  SimHitIdpr currentId(itlink->getTrackId(), itlink->getEventId());
89  if (find(matched.begin(), matched.end(), currentId) == matched.end())
90  matched.push_back(currentId);
91  }
92  }
93 
94  } else
95  LogTrace("RPCHitAssociator") << "*** WARNING in RPCHitAssociator::associateRecHit, null "
96  "dynamic_cast !";
97 
98  return matched;
99 }
int firstClusterStrip() const
Definition: RPCRecHit.h:111
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
int clusterSize() const
Definition: RPCRecHit.h:115
RPCDetId rpcId() const
Return the rpcId.
Definition: RPCRecHit.h:103
#define LogTrace(id)
std::pair< uint32_t, EncodedEventId > SimHitIdpr
std::set< RPCDigiSimLink > findRPCDigiSimLink(uint32_t rpcDetId, int strip, int bx) const
int BunchX() const
Definition: RPCRecHit.h:107
std::set< RPCDigiSimLink > RPCHitAssociator::findRPCDigiSimLink ( uint32_t  rpcDetId,
int  strip,
int  bx 
) const

Definition at line 101 of file RPCHitAssociator.cc.

References _thelinkDigis, edm::DetSetVector< T >::begin(), edm::DetSetVector< T >::end(), and str.

Referenced by associateRecHit(), and ~RPCHitAssociator().

101  {
102  std::set<RPCDigiSimLink> links;
103 
105  itlink != _thelinkDigis->end();
106  itlink++) {
107  for (edm::DetSet<RPCDigiSimLink>::const_iterator digi_iter = itlink->data.begin(); digi_iter != itlink->data.end();
108  ++digi_iter) {
109  uint32_t detid = digi_iter->getDetUnitId();
110  int str = digi_iter->getStrip();
111  int bunchx = digi_iter->getBx();
112 
113  if (detid == rpcDetId && str == strip && bunchx == bx) {
114  links.insert(*digi_iter);
115  }
116  }
117  }
118 
119  return links;
120 }
edm::Handle< edm::DetSetVector< RPCDigiSimLink > > _thelinkDigis
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:361
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:346
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:104
#define str(s)
void RPCHitAssociator::initEvent ( const edm::Event e,
const edm::EventSetup eventSetup 
)

Definition at line 32 of file RPCHitAssociator.cc.

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

Referenced by RPCHitAssociator().

34 {
35  if (crossingframe) {
37  LogTrace("RPCHitAssociator") << "getting CrossingFrame<PSimHit> collection - " << RPCsimhitsXFTag;
39 
40  std::unique_ptr<MixCollection<PSimHit>> RPCsimhits(new MixCollection<PSimHit>(cf.product()));
41  LogTrace("RPCHitAssociator") << "... size = " << RPCsimhits->size();
42 
43  // MixCollection<PSimHit> & simHits = *hits;
44 
45  for (MixCollection<PSimHit>::MixItr hitItr = RPCsimhits->begin(); hitItr != RPCsimhits->end(); ++hitItr) {
46  _SimHitMap[hitItr->detUnitId()].push_back(*hitItr);
47  }
48 
49  } else if (!RPCsimhitsTag.label().empty()) {
51  LogTrace("RPCHitAssociator") << "getting PSimHit collection - " << RPCsimhitsTag;
52  e.getByLabel(RPCsimhitsTag, RPCsimhits);
53  LogTrace("RPCHitAssociator") << "... size = " << RPCsimhits->size();
54 
55  // arrange the hits by detUnit
56  for (edm::PSimHitContainer::const_iterator hitItr = RPCsimhits->begin(); hitItr != RPCsimhits->end(); ++hitItr) {
57  _SimHitMap[hitItr->detUnitId()].push_back(*hitItr);
58  }
59  }
60 
62  LogTrace("RPCHitAssociator") << "getting RPCDigiSimLink collection - " << RPCdigisimlinkTag;
63  e.getByLabel(RPCdigisimlinkTag, thelinkDigis);
64  _thelinkDigis = thelinkDigis;
65 }
edm::InputTag RPCdigisimlinkTag
edm::Handle< edm::DetSetVector< RPCDigiSimLink > > _thelinkDigis
std::map< unsigned int, edm::PSimHitContainer > _SimHitMap
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:480
#define LogTrace(id)
edm::InputTag RPCsimhitsTag
T const * product() const
Definition: Handle.h:74
edm::InputTag RPCsimhitsXFTag
std::string const & label() const
Definition: InputTag.h:36

Member Data Documentation

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

Definition at line 62 of file RPCHitAssociator.h.

Referenced by initEvent().

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

Definition at line 51 of file RPCHitAssociator.h.

Referenced by findRPCDigiSimLink(), and initEvent().

bool RPCHitAssociator::crossingframe
private

Definition at line 54 of file RPCHitAssociator.h.

Referenced by initEvent(), and RPCHitAssociator().

edm::InputTag RPCHitAssociator::RPCdigisimlinkTag
private

Definition at line 52 of file RPCHitAssociator.h.

Referenced by initEvent(), and RPCHitAssociator().

edm::EDGetTokenT<edm::DetSetVector<RPCDigiSimLink> > RPCHitAssociator::RPCdigisimlinkToken_
private

Definition at line 60 of file RPCHitAssociator.h.

Referenced by RPCHitAssociator().

edm::InputTag RPCHitAssociator::RPCsimhitsTag
private

Definition at line 55 of file RPCHitAssociator.h.

Referenced by initEvent(), and RPCHitAssociator().

edm::EDGetTokenT<edm::PSimHitContainer> RPCHitAssociator::RPCsimhitsToken_
private

Definition at line 59 of file RPCHitAssociator.h.

Referenced by RPCHitAssociator().

edm::InputTag RPCHitAssociator::RPCsimhitsXFTag
private

Definition at line 56 of file RPCHitAssociator.h.

Referenced by initEvent(), and RPCHitAssociator().

edm::EDGetTokenT<CrossingFrame<PSimHit> > RPCHitAssociator::RPCsimhitsXFToken_
private

Definition at line 58 of file RPCHitAssociator.h.

Referenced by RPCHitAssociator().