CMS 3D CMS Logo

RPCHitAssociator.cc
Go to the documentation of this file.
2 
3 using namespace std;
4 
5 // Constructor
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 }
20 
22  const edm::EventSetup &eventSetup,
23  const edm::ParameterSet &conf)
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 }
31 
33 
34 {
35  if (crossingframe) {
37  LogTrace("RPCHitAssociator") << "getting CrossingFrame<PSimHit> collection - " << RPCsimhitsXFTag;
38  e.getByLabel(RPCsimhitsXFTag, cf);
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 }
66 // end of constructor
67 
68 std::vector<RPCHitAssociator::SimHitIdpr> RPCHitAssociator::associateRecHit(const TrackingRecHit &hit) const {
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 }
100 
101 std::set<RPCDigiSimLink> RPCHitAssociator::findRPCDigiSimLink(uint32_t rpcDetId, int strip, int bx) const {
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 }
muonTagProbeFilters_cff.matched
matched
Definition: muonTagProbeFilters_cff.py:62
MuonAssociatorByHits_cfi.RPCsimhitsTag
RPCsimhitsTag
Definition: MuonAssociatorByHits_cfi.py:59
edm::DetSetVector< RPCDigiSimLink >
electrons_cff.bool
bool
Definition: electrons_cff.py:372
mps_fire.i
i
Definition: mps_fire.py:355
edm::Handle::product
T const * product() const
Definition: Handle.h:70
edm::DetSetVector::end
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:325
RPCHitAssociator::_thelinkDigis
edm::Handle< edm::DetSetVector< RPCDigiSimLink > > _thelinkDigis
Definition: RPCHitAssociator.h:51
RPCHitAssociator::initEvent
void initEvent(const edm::Event &, const edm::EventSetup &)
Definition: RPCHitAssociator.cc:32
edm
HLT enums.
Definition: AlignableModifier.h:19
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
RPCDetId
Definition: RPCDetId.h:16
RPCRecHit::BunchX
int BunchX() const
Definition: RPCRecHit.h:73
RPCHitAssociator::crossingframe
bool crossingframe
Definition: RPCHitAssociator.h:54
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
edm::DetSetVector::begin
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:314
MuonAssociatorByHits_cfi.crossingframe
crossingframe
Definition: MuonAssociatorByHits_cfi.py:38
RPCHitAssociator::RPCsimhitsToken_
edm::EDGetTokenT< edm::PSimHitContainer > RPCsimhitsToken_
Definition: RPCHitAssociator.h:59
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edm::Handle
Definition: AssociativeIterator.h:50
MixCollection::MixItr
Definition: MixCollection.h:62
RPCHitAssociator::RPCHitAssociator
RPCHitAssociator(const edm::ParameterSet &, edm::ConsumesCollector &&ic)
Definition: RPCHitAssociator.cc:6
RPCHitAssociator::RPCdigisimlinkToken_
edm::EDGetTokenT< edm::DetSetVector< RPCDigiSimLink > > RPCdigisimlinkToken_
Definition: RPCHitAssociator.h:60
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
CrossingFrame
Definition: CrossingFrame.h:38
RPCHitAssociator::SimHitIdpr
std::pair< uint32_t, EncodedEventId > SimHitIdpr
Definition: RPCHitAssociator.h:35
RPCHitAssociator::RPCsimhitsXFTag
edm::InputTag RPCsimhitsXFTag
Definition: RPCHitAssociator.h:56
MixCollection
Definition: MixCollection.h:11
RPCRecHit
Definition: RPCRecHit.h:14
str
#define str(s)
Definition: TestProcessor.cc:48
MuonAssociatorByHits_cfi.RPCdigisimlinkTag
RPCdigisimlinkTag
Definition: MuonAssociatorByHits_cfi.py:61
RPCHitAssociator.h
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
edm::DetSetVector::const_iterator
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:102
RPCRecHit::clusterSize
int clusterSize() const
Definition: RPCRecHit.h:77
MuonAssociatorByHits_cfi.RPCsimhitsXFTag
RPCsimhitsXFTag
Definition: MuonAssociatorByHits_cfi.py:60
RPCHitAssociator::associateRecHit
std::vector< SimHitIdpr > associateRecHit(const TrackingRecHit &hit) const
Definition: RPCHitAssociator.cc:68
RPCHitAssociator::findRPCDigiSimLink
std::set< RPCDigiSimLink > findRPCDigiSimLink(uint32_t rpcDetId, int strip, int bx) const
Definition: RPCHitAssociator.cc:101
edm::EventSetup
Definition: EventSetup.h:57
TrackingRecHit
Definition: TrackingRecHit.h:21
std
Definition: JetResolutionObject.h:76
RPCHitAssociator::RPCdigisimlinkTag
edm::InputTag RPCdigisimlinkTag
Definition: RPCHitAssociator.h:52
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
electronStore.links
links
Definition: electronStore.py:149
RPCHitAssociator::_SimHitMap
std::map< unsigned int, edm::PSimHitContainer > _SimHitMap
Definition: RPCHitAssociator.h:62
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
edm::PSimHitContainer
std::vector< PSimHit > PSimHitContainer
Definition: PSimHitContainer.h:11
RPCHitAssociator::RPCsimhitsTag
edm::InputTag RPCsimhitsTag
Definition: RPCHitAssociator.h:55
RPCRecHit::rpcId
RPCDetId rpcId() const
Return the rpcId.
Definition: RPCRecHit.h:71
edm::Event
Definition: Event.h:73
RPCRecHit::firstClusterStrip
int firstClusterStrip() const
Definition: RPCRecHit.h:75
RPCHitAssociator::RPCsimhitsXFToken_
edm::EDGetTokenT< CrossingFrame< PSimHit > > RPCsimhitsXFToken_
Definition: RPCHitAssociator.h:58
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
hit
Definition: SiStripHitEffFromCalibTree.cc:88
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
edm::DetSet::const_iterator
collection_type::const_iterator const_iterator
Definition: DetSet.h:31