CMS 3D CMS Logo

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

#include <GEMRecHitMatcher.h>

Public Member Functions

bool areGEMRecHitSame (const GEMRecHit &l, const GEMRecHit &r) const
 
std::set< unsigned int > chamberIds () const
 
std::set< unsigned int > detIds () const
 
std::shared_ptr< GEMDigiMatchergemDigiMatcher () const
 
 GEMRecHitMatcher (edm::ParameterSet const &iPS, edm::ConsumesCollector &&iC)
 
void init (const edm::Event &e, const edm::EventSetup &eventSetup)
 
bool isGEMRecHitMatched (const GEMRecHit &thisRh) const
 
void match (const SimTrack &t, const SimVertex &v)
 do the matching More...
 
int nGEMRecHits () const
 How many recHits in GEM did this simtrack get in total? More...
 
int nLayersWithRecHitsInSuperChamber (unsigned int) const
 
std::set< int > partitionNumbers () const
 
bool recHitInContainer (const GEMRecHit &rh, const GEMRecHitContainer &c) const
 
GlobalPoint recHitMeanPosition (const GEMRecHitContainer &rechits) const
 
GlobalPoint recHitPosition (const GEMRecHit &rechit) const
 
const GEMRecHitContainerrecHits () const
 
const GEMRecHitContainerrecHitsInChamber (unsigned int) const
 
const GEMRecHitContainerrecHitsInDetId (unsigned int) const
 
const GEMRecHitContainerrecHitsInSuperChamber (unsigned int) const
 
std::set< int > stripNumbersInDetId (unsigned int) const
 
std::set< unsigned int > superChamberIds () const
 
bool verbose () const
 
 ~GEMRecHitMatcher ()
 

Private Member Functions

void matchRecHitsToSimTrack (const GEMRecHitCollection &recHits)
 

Private Attributes

std::map< unsigned int,
GEMRecHitContainer
chamber_to_recHits_
 
std::map< unsigned int,
GEMRecHitContainer
detid_to_recHits_
 
std::shared_ptr< GEMDigiMatchergemDigiMatcher_
 
const GEMGeometrygemGeometry_
 
edm::Handle< GEMRecHitCollectiongemRecHitH_
 
edm::EDGetTokenT
< GEMRecHitCollection
gemRecHitToken_
 
edm::ESGetToken< GEMGeometry,
MuonGeometryRecord
geomToken_
 
int maxBX_
 
int minBX_
 
const GEMRecHitContainer no_recHits_
 
GEMRecHitContainer recHits_
 
std::map< unsigned int,
GEMRecHitContainer
superchamber_to_recHits_
 
bool verbose_
 

Detailed Description

Description: Matching of RecHits for SimTrack in GEM

Original Author : "Vadim Khotilovich" Contibuting Author : "Claudio Caputo"

Definition at line 30 of file GEMRecHitMatcher.h.

Constructor & Destructor Documentation

GEMRecHitMatcher::GEMRecHitMatcher ( edm::ParameterSet const &  iPS,
edm::ConsumesCollector &&  iC 
)

Definition at line 7 of file GEMRecHitMatcher.cc.

References muonGEMRecHitPSet::gemRecHit, edm::ParameterSet::getParameterSet(), and eostools::move().

7  {
8  const auto& gemRecHit = pset.getParameterSet("gemRecHit");
9  minBX_ = gemRecHit.getParameter<int>("minBX");
10  maxBX_ = gemRecHit.getParameter<int>("maxBX");
11  verbose_ = gemRecHit.getParameter<int>("verbose");
12 
13  // make a new digi matcher
15 
16  gemRecHitToken_ = iC.consumes<GEMRecHitCollection>(gemRecHit.getParameter<edm::InputTag>("inputTag"));
18 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::shared_ptr< GEMDigiMatcher > gemDigiMatcher_
edm::EDGetTokenT< GEMRecHitCollection > gemRecHitToken_
def move
Definition: eostools.py:511
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > geomToken_
GEMRecHitMatcher::~GEMRecHitMatcher ( )
inline

Definition at line 36 of file GEMRecHitMatcher.h.

36 {}

Member Function Documentation

bool GEMRecHitMatcher::areGEMRecHitSame ( const GEMRecHit l,
const GEMRecHit r 
) const

Definition at line 198 of file GEMRecHitMatcher.cc.

References GEMRecHit::BunchX(), and GEMRecHit::localPosition().

198  {
199  return l.localPosition() == r.localPosition() and l.BunchX() == r.BunchX();
200 }
LocalPoint localPosition() const override
Return the 3-dimensional local position.
Definition: GEMRecHit.h:37
int BunchX() const
Definition: GEMRecHit.h:67
std::set< unsigned int > GEMRecHitMatcher::chamberIds ( ) const

Definition at line 96 of file GEMRecHitMatcher.cc.

References AlCaHLTBitMon_ParallelJobs::p, and mps_fire::result.

96  {
97  std::set<unsigned int> result;
98  for (const auto& p : chamber_to_recHits_)
99  result.insert(p.first);
100  return result;
101 }
std::map< unsigned int, GEMRecHitContainer > chamber_to_recHits_
tuple result
Definition: mps_fire.py:311
std::set< unsigned int > GEMRecHitMatcher::detIds ( void  ) const

Definition at line 89 of file GEMRecHitMatcher.cc.

References AlCaHLTBitMon_ParallelJobs::p, and mps_fire::result.

89  {
90  std::set<unsigned int> result;
91  for (const auto& p : detid_to_recHits_)
92  result.insert(p.first);
93  return result;
94 }
tuple result
Definition: mps_fire.py:311
std::map< unsigned int, GEMRecHitContainer > detid_to_recHits_
std::shared_ptr<GEMDigiMatcher> GEMRecHitMatcher::gemDigiMatcher ( ) const
inline

Definition at line 79 of file GEMRecHitMatcher.h.

References gemDigiMatcher_.

79 { return gemDigiMatcher_; }
std::shared_ptr< GEMDigiMatcher > gemDigiMatcher_
void GEMRecHitMatcher::init ( const edm::Event e,
const edm::EventSetup eventSetup 
)

Definition at line 20 of file GEMRecHitMatcher.cc.

References edm::Event::getByToken(), and edm::EventSetup::getData().

20  {
21  gemDigiMatcher_->init(iEvent, iSetup);
22 
23  iEvent.getByToken(gemRecHitToken_, gemRecHitH_);
24 
25  gemGeometry_ = &iSetup.getData(geomToken_);
26 }
std::shared_ptr< GEMDigiMatcher > gemDigiMatcher_
edm::EDGetTokenT< GEMRecHitCollection > gemRecHitToken_
int iEvent
Definition: GenABIO.cc:224
const GEMGeometry * gemGeometry_
edm::Handle< GEMRecHitCollection > gemRecHitH_
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > geomToken_
bool GEMRecHitMatcher::isGEMRecHitMatched ( const GEMRecHit thisRh) const

Definition at line 194 of file GEMRecHitMatcher.cc.

References HLT_FULL_cff::recHits.

194  {
195  return recHitInContainer(thisRh, recHits());
196 }
const GEMRecHitContainer & recHits() const
bool recHitInContainer(const GEMRecHit &rh, const GEMRecHitContainer &c) const
void GEMRecHitMatcher::match ( const SimTrack t,
const SimVertex v 
)

do the matching

Definition at line 29 of file GEMRecHitMatcher.cc.

References gemRecHits_cfi::gemRecHits.

29  {
30  // match digis first
31  gemDigiMatcher_->match(t, v);
32 
33  // get the rechit collection
35 
36  // now match the rechits
37  matchRecHitsToSimTrack(gemRecHits);
38 }
std::shared_ptr< GEMDigiMatcher > gemDigiMatcher_
void matchRecHitsToSimTrack(const GEMRecHitCollection &recHits)
edm::Handle< GEMRecHitCollection > gemRecHitH_
T const * product() const
Definition: Handle.h:70
void GEMRecHitMatcher::matchRecHitsToSimTrack ( const GEMRecHitCollection recHits)
private

Definition at line 40 of file GEMRecHitMatcher.cc.

References GEMDetId::chamberId(), filterCSVwithJSON::copy, gather_cfg::cout, ztail::d, mps_fire::i, gpuClustering::id, DetId::rawId(), GEMDetId::superChamberId(), and verbose.

40  {
41  // get the matched ids with digis
42  const auto& det_ids = gemDigiMatcher_->detIdsDigi();
43 
44  // loop on those ids
45  for (auto id : det_ids) {
46  // now check the digis in this detid
47  const auto& hit_digis = gemDigiMatcher_->stripNumbersInDetId(id);
48  if (verbose()) {
49  cout << "hit_digis_fat ";
50  copy(hit_digis.begin(), hit_digis.end(), ostream_iterator<int>(cout, " "));
51  cout << endl;
52  }
53 
54  GEMDetId p_id(id);
55  const auto& rechits_in_det = rechits.get(p_id);
56 
57  for (auto d = rechits_in_det.first; d != rechits_in_det.second; ++d) {
58  if (verbose())
59  edm::LogInfo("GEMDigiMatcher") << "recHit " << p_id << " " << *d << endl;
60 
61  // check that the rechit is within BX range
62  if (d->BunchX() < minBX_ || d->BunchX() > maxBX_)
63  continue;
64 
65  int firstStrip = d->firstClusterStrip();
66  int cls = d->clusterSize();
67  bool stripFound = false;
68 
69  // check that it matches a strip that was hit by digis from our track
70  for (int i = firstStrip; i < (firstStrip + cls); i++) {
71  if (hit_digis.find(i) != hit_digis.end())
72  stripFound = true;
73  }
74 
75  // this rechit did not correspond with any previously matched digi
76  if (!stripFound)
77  continue;
78  if (verbose())
79  edm::LogInfo("GEMDigiMatcher") << "oki" << endl;
80 
81  recHits_.push_back(*d);
82  detid_to_recHits_[id].push_back(*d);
83  chamber_to_recHits_[p_id.chamberId().rawId()].push_back(*d);
84  superchamber_to_recHits_[p_id.superChamberId().rawId()].push_back(*d);
85  }
86  }
87 }
GEMRecHitContainer recHits_
uint16_t *__restrict__ id
std::shared_ptr< GEMDigiMatcher > gemDigiMatcher_
std::map< unsigned int, GEMRecHitContainer > chamber_to_recHits_
tuple d
Definition: ztail.py:151
std::map< unsigned int, GEMRecHitContainer > superchamber_to_recHits_
Log< level::Info, false > LogInfo
bool verbose() const
tuple cout
Definition: gather_cfg.py:144
std::map< unsigned int, GEMRecHitContainer > detid_to_recHits_
int GEMRecHitMatcher::nGEMRecHits ( ) const

How many recHits in GEM did this simtrack get in total?

int GEMRecHitMatcher::nLayersWithRecHitsInSuperChamber ( unsigned int  detid) const

Definition at line 128 of file GEMRecHitMatcher.cc.

References ztail::d, and LayerTriplets::layers().

128  {
129  set<int> layers;
130  for (const auto& d : recHitsInSuperChamber(detid)) {
131  layers.insert(d.gemId().layer());
132  }
133  return layers.size();
134 }
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
Definition: LayerTriplets.cc:4
tuple d
Definition: ztail.py:151
const GEMRecHitContainer & recHitsInSuperChamber(unsigned int) const
std::set< int > GEMRecHitMatcher::partitionNumbers ( ) const

Definition at line 147 of file GEMRecHitMatcher.cc.

References mps_fire::result, and GEMDetId::roll().

147  {
148  std::set<int> result;
149 
150  for (auto id : detIds()) {
151  GEMDetId idd(id);
152  result.insert(idd.roll());
153  }
154  return result;
155 }
std::set< unsigned int > detIds() const
tuple result
Definition: mps_fire.py:311
bool GEMRecHitMatcher::recHitInContainer ( const GEMRecHit rh,
const GEMRecHitContainer c 
) const

Definition at line 186 of file GEMRecHitMatcher.cc.

186  {
187  bool isSame = false;
188  for (const auto& thisRH : c)
189  if (areGEMRecHitSame(thisRH, rh))
190  isSame = true;
191  return isSame;
192 }
bool areGEMRecHitSame(const GEMRecHit &l, const GEMRecHit &r) const
const edm::EventSetup & c
GlobalPoint GEMRecHitMatcher::recHitMeanPosition ( const GEMRecHitContainer rechits) const

Definition at line 163 of file GEMRecHitMatcher.cc.

References ztail::d, runTauDisplay::gp, dqmiodumpmetadata::n, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

163  {
164  GlobalPoint point_zero;
165  if (rechit.empty())
166  return point_zero; // point "zero"
167 
168  float sumx, sumy, sumz;
169  sumx = sumy = sumz = 0.f;
170  size_t n = 0;
171  for (const auto& d : rechit) {
173  if (gp == point_zero)
174  continue;
175 
176  sumx += gp.x();
177  sumy += gp.y();
178  sumz += gp.z();
179  ++n;
180  }
181  if (n == 0)
182  return GlobalPoint();
183  return GlobalPoint(sumx / n, sumy / n, sumz / n);
184 }
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:60
tuple d
Definition: ztail.py:151
T z() const
Definition: PV3DBase.h:61
GlobalPoint recHitPosition(const GEMRecHit &rechit) const
T x() const
Definition: PV3DBase.h:59
GlobalPoint GEMRecHitMatcher::recHitPosition ( const GEMRecHit rechit) const

Definition at line 157 of file GEMRecHitMatcher.cc.

References GEMRecHit::gemId(), and GEMRecHit::localPosition().

157  {
158  const GEMDetId& idd = rechit.gemId();
159  const LocalPoint& lp = rechit.localPosition();
160  return gemGeometry_->idToDet(idd)->surface().toGlobal(lp);
161 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
LocalPoint localPosition() const override
Return the 3-dimensional local position.
Definition: GEMRecHit.h:37
const GeomDet * idToDet(DetId) const override
Definition: GEMGeometry.cc:25
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
const GEMGeometry * gemGeometry_
GEMDetId gemId() const
Return the gemId.
Definition: GEMRecHit.h:65
const GEMRecHitContainer& GEMRecHitMatcher::recHits ( void  ) const
inline

Definition at line 54 of file GEMRecHitMatcher.h.

References recHits_.

54 { return recHits_; }
GEMRecHitContainer recHits_
const GEMRecHitContainer & GEMRecHitMatcher::recHitsInChamber ( unsigned int  detid) const

Definition at line 116 of file GEMRecHitMatcher.cc.

116  {
117  if (chamber_to_recHits_.find(detid) == chamber_to_recHits_.end())
118  return no_recHits_;
119  return chamber_to_recHits_.at(detid);
120 }
std::map< unsigned int, GEMRecHitContainer > chamber_to_recHits_
const GEMRecHitContainer no_recHits_
const GEMRecHitContainer & GEMRecHitMatcher::recHitsInDetId ( unsigned int  detid) const

Definition at line 110 of file GEMRecHitMatcher.cc.

110  {
111  if (detid_to_recHits_.find(detid) == detid_to_recHits_.end())
112  return no_recHits_;
113  return detid_to_recHits_.at(detid);
114 }
const GEMRecHitContainer no_recHits_
std::map< unsigned int, GEMRecHitContainer > detid_to_recHits_
const GEMRecHitContainer & GEMRecHitMatcher::recHitsInSuperChamber ( unsigned int  detid) const

Definition at line 122 of file GEMRecHitMatcher.cc.

122  {
123  if (superchamber_to_recHits_.find(detid) == superchamber_to_recHits_.end())
124  return no_recHits_;
125  return superchamber_to_recHits_.at(detid);
126 }
std::map< unsigned int, GEMRecHitContainer > superchamber_to_recHits_
const GEMRecHitContainer no_recHits_
std::set< int > GEMRecHitMatcher::stripNumbersInDetId ( unsigned int  detid) const

Definition at line 136 of file GEMRecHitMatcher.cc.

References ztail::d, and mps_fire::result.

136  {
137  set<int> result;
138  for (const auto& d : recHitsInDetId(detid)) {
139  // loop on all strips hit in this rechit
140  for (int iStrip = d.firstClusterStrip(); iStrip < d.firstClusterStrip() + d.clusterSize(); ++iStrip) {
141  result.insert(iStrip);
142  }
143  }
144  return result;
145 }
const GEMRecHitContainer & recHitsInDetId(unsigned int) const
tuple result
Definition: mps_fire.py:311
tuple d
Definition: ztail.py:151
std::set< unsigned int > GEMRecHitMatcher::superChamberIds ( ) const

Definition at line 103 of file GEMRecHitMatcher.cc.

References AlCaHLTBitMon_ParallelJobs::p, and mps_fire::result.

103  {
104  std::set<unsigned int> result;
105  for (const auto& p : superchamber_to_recHits_)
106  result.insert(p.first);
107  return result;
108 }
tuple result
Definition: mps_fire.py:311
std::map< unsigned int, GEMRecHitContainer > superchamber_to_recHits_
bool GEMRecHitMatcher::verbose ( ) const
inline

Definition at line 71 of file GEMRecHitMatcher.h.

References verbose_.

71 { return verbose_; }

Member Data Documentation

std::map<unsigned int, GEMRecHitContainer> GEMRecHitMatcher::chamber_to_recHits_
private

Definition at line 100 of file GEMRecHitMatcher.h.

std::map<unsigned int, GEMRecHitContainer> GEMRecHitMatcher::detid_to_recHits_
private

Definition at line 99 of file GEMRecHitMatcher.h.

std::shared_ptr<GEMDigiMatcher> GEMRecHitMatcher::gemDigiMatcher_
private

Definition at line 106 of file GEMRecHitMatcher.h.

Referenced by gemDigiMatcher().

const GEMGeometry* GEMRecHitMatcher::gemGeometry_
private

Definition at line 94 of file GEMRecHitMatcher.h.

edm::Handle<GEMRecHitCollection> GEMRecHitMatcher::gemRecHitH_
private

Definition at line 91 of file GEMRecHitMatcher.h.

edm::EDGetTokenT<GEMRecHitCollection> GEMRecHitMatcher::gemRecHitToken_
private

Definition at line 90 of file GEMRecHitMatcher.h.

edm::ESGetToken<GEMGeometry, MuonGeometryRecord> GEMRecHitMatcher::geomToken_
private

Definition at line 93 of file GEMRecHitMatcher.h.

int GEMRecHitMatcher::maxBX_
private

Definition at line 96 of file GEMRecHitMatcher.h.

int GEMRecHitMatcher::minBX_
private

Definition at line 96 of file GEMRecHitMatcher.h.

const GEMRecHitContainer GEMRecHitMatcher::no_recHits_
private

Definition at line 103 of file GEMRecHitMatcher.h.

GEMRecHitContainer GEMRecHitMatcher::recHits_
private

Definition at line 104 of file GEMRecHitMatcher.h.

Referenced by recHits().

std::map<unsigned int, GEMRecHitContainer> GEMRecHitMatcher::superchamber_to_recHits_
private

Definition at line 101 of file GEMRecHitMatcher.h.

bool GEMRecHitMatcher::verbose_
private

Definition at line 97 of file GEMRecHitMatcher.h.

Referenced by verbose().