CMS 3D CMS Logo

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

#include <RPCHitAssociator.h>

Classes

class  Config
 

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
 
 RPCHitAssociator (const edm::Event &e, const Config &conf)
 

Private Member Functions

void initEvent (const edm::Event &)
 

Private Attributes

std::map< unsigned int, edm::PSimHitContainer_SimHitMap
 
edm::Handle< edm::DetSetVector< RPCDigiSimLink > > _thelinkDigis
 
Config const & theConfig
 

Detailed Description

Definition at line 32 of file RPCHitAssociator.h.

Member Typedef Documentation

◆ RPCDigiSimLinks

Definition at line 34 of file RPCHitAssociator.h.

◆ SimHitIdpr

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

Definition at line 35 of file RPCHitAssociator.h.

Constructor & Destructor Documentation

◆ RPCHitAssociator()

RPCHitAssociator::RPCHitAssociator ( const edm::Event e,
const Config conf 
)

Definition at line 22 of file RPCHitAssociator.cc.

References MillePedeFileConverter_cfg::e, and initEvent().

22 : theConfig(conf) { initEvent(e); }
void initEvent(const edm::Event &)
Config const & theConfig

Member Function Documentation

◆ associateRecHit()

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

Definition at line 56 of file RPCHitAssociator.cc.

References RPCRecHit::BunchX(), nano_mu_digi_cff::bx, RPCRecHit::clusterSize(), spr::find(), findRPCDigiSimLink(), RPCRecHit::firstClusterStrip(), mps_fire::i, electronStore::links, LogTrace, muonTagProbeFilters_cff::matched, DetId::rawId(), and RPCRecHit::rpcId().

Referenced by MuonAssociatorByHitsHelper::getMatchedIds().

56  {
57  std::vector<SimHitIdpr> matched;
58 
59  const TrackingRecHit *hitp = &hit;
60  const RPCRecHit *rpcrechit = dynamic_cast<const RPCRecHit *>(hitp);
61 
62  if (rpcrechit) {
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())
72  LogTrace("RPCHitAssociator") << "*** WARNING in RPCHitAssociator::associateRecHit, RPCRecHit " << *rpcrechit
73  << ", strip " << i << " has no associated RPCDigiSimLink !" << endl;
74 
75  for (std::set<RPCDigiSimLink>::iterator itlink = links.begin(); itlink != links.end(); ++itlink) {
76  SimHitIdpr currentId(itlink->getTrackId(), itlink->getEventId());
77  if (find(matched.begin(), matched.end(), currentId) == matched.end())
78  matched.push_back(currentId);
79  }
80  }
81 
82  } else
83  LogTrace("RPCHitAssociator") << "*** WARNING in RPCHitAssociator::associateRecHit, null "
84  "dynamic_cast !";
85 
86  return matched;
87 }
std::set< RPCDigiSimLink > findRPCDigiSimLink(uint32_t rpcDetId, int strip, int bx) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
#define LogTrace(id)
RPCDetId rpcId() const
Return the rpcId.
Definition: RPCRecHit.h:71
int BunchX() const
Definition: RPCRecHit.h:73
std::pair< uint32_t, EncodedEventId > SimHitIdpr
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
int clusterSize() const
Definition: RPCRecHit.h:77
int firstClusterStrip() const
Definition: RPCRecHit.h:75

◆ findRPCDigiSimLink()

std::set< RPCDigiSimLink > RPCHitAssociator::findRPCDigiSimLink ( uint32_t  rpcDetId,
int  strip,
int  bx 
) const

Definition at line 89 of file RPCHitAssociator.cc.

References _thelinkDigis, edm::DetSetVector< T >::begin(), nano_mu_digi_cff::bx, edm::DetSetVector< T >::end(), electronStore::links, str, and nano_mu_digi_cff::strip.

Referenced by associateRecHit().

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

◆ initEvent()

void RPCHitAssociator::initEvent ( const edm::Event e)
private

Definition at line 24 of file RPCHitAssociator.cc.

References _SimHitMap, _thelinkDigis, RPCHitAssociator::Config::crossingframe, MillePedeFileConverter_cfg::e, edm::InputTag::label(), LogTrace, RPCHitAssociator::Config::RPCdigisimlinkTag, RPCHitAssociator::Config::RPCdigisimlinkToken_, RPCHitAssociator::Config::RPCsimhitsTag, RPCHitAssociator::Config::RPCsimhitsToken_, RPCHitAssociator::Config::RPCsimhitsXFTag, RPCHitAssociator::Config::RPCsimhitsXFToken_, and theConfig.

Referenced by RPCHitAssociator().

26 {
28  LogTrace("RPCHitAssociator") << "getting CrossingFrame<PSimHit> collection - " << theConfig.RPCsimhitsXFTag;
30 
31  std::unique_ptr<MixCollection<PSimHit>> RPCsimhits(new MixCollection<PSimHit>(&cf));
32  LogTrace("RPCHitAssociator") << "... size = " << RPCsimhits->size();
33 
34  // MixCollection<PSimHit> & simHits = *hits;
35 
36  for (MixCollection<PSimHit>::MixItr hitItr = RPCsimhits->begin(); hitItr != RPCsimhits->end(); ++hitItr) {
37  _SimHitMap[hitItr->detUnitId()].push_back(*hitItr);
38  }
39 
40  } else if (!theConfig.RPCsimhitsTag.label().empty()) {
41  LogTrace("RPCHitAssociator") << "getting PSimHit collection - " << theConfig.RPCsimhitsTag;
42  edm::PSimHitContainer const &RPCsimhits = e.get(theConfig.RPCsimhitsToken_);
43  LogTrace("RPCHitAssociator") << "... size = " << RPCsimhits.size();
44 
45  // arrange the hits by detUnit
46  for (edm::PSimHitContainer::const_iterator hitItr = RPCsimhits.begin(); hitItr != RPCsimhits.end(); ++hitItr) {
47  _SimHitMap[hitItr->detUnitId()].push_back(*hitItr);
48  }
49  }
50 
51  LogTrace("RPCHitAssociator") << "getting RPCDigiSimLink collection - " << theConfig.RPCdigisimlinkTag;
53 }
edm::EDGetTokenT< CrossingFrame< PSimHit > > RPCsimhitsXFToken_
std::string const & label() const
Definition: InputTag.h:36
edm::Handle< edm::DetSetVector< RPCDigiSimLink > > _thelinkDigis
#define LogTrace(id)
std::map< unsigned int, edm::PSimHitContainer > _SimHitMap
Config const & theConfig
edm::EDGetTokenT< edm::PSimHitContainer > RPCsimhitsToken_
edm::EDGetTokenT< edm::DetSetVector< RPCDigiSimLink > > RPCdigisimlinkToken_
edm::InputTag RPCdigisimlinkTag
std::vector< PSimHit > PSimHitContainer

Member Data Documentation

◆ _SimHitMap

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

Definition at line 68 of file RPCHitAssociator.h.

Referenced by initEvent().

◆ _thelinkDigis

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

Definition at line 67 of file RPCHitAssociator.h.

Referenced by findRPCDigiSimLink(), and initEvent().

◆ theConfig

Config const& RPCHitAssociator::theConfig
private

Definition at line 66 of file RPCHitAssociator.h.

Referenced by initEvent().