CMS 3D CMS Logo

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, GEMRecHitContainerchamber_to_recHits_
 
std::map< unsigned int, GEMRecHitContainerdetid_to_recHits_
 
edm::ESHandle< GEMGeometrygem_geom_
 
std::shared_ptr< GEMDigiMatchergemDigiMatcher_
 
const GEMGeometrygemGeometry_
 
edm::Handle< GEMRecHitCollectiongemRecHitH_
 
edm::EDGetTokenT< GEMRecHitCollectiongemRecHitToken_
 
int maxBX_
 
int minBX_
 
const GEMRecHitContainer no_recHits_
 
GEMRecHitContainer recHits_
 
std::map< unsigned int, GEMRecHitContainersuperchamber_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 31 of file GEMRecHitMatcher.h.

Constructor & Destructor Documentation

◆ GEMRecHitMatcher()

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

Definition at line 7 of file GEMRecHitMatcher.cc.

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"));
17 }

References muonGEMRecHitPSet::gemRecHit, eostools::move(), and muonDTDigis_cfi::pset.

◆ ~GEMRecHitMatcher()

GEMRecHitMatcher::~GEMRecHitMatcher ( )
inline

Definition at line 37 of file GEMRecHitMatcher.h.

37 {}

Member Function Documentation

◆ areGEMRecHitSame()

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

Definition at line 202 of file GEMRecHitMatcher.cc.

202  {
203  return l.localPosition() == r.localPosition() and l.BunchX() == r.BunchX();
204 }

References cmsLHEtoEOSManager::l, and alignCSCRings::r.

◆ chamberIds()

std::set< unsigned int > GEMRecHitMatcher::chamberIds ( ) const

Definition at line 100 of file GEMRecHitMatcher.cc.

100  {
101  std::set<unsigned int> result;
102  for (const auto& p : chamber_to_recHits_)
103  result.insert(p.first);
104  return result;
105 }

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

◆ detIds()

std::set< unsigned int > GEMRecHitMatcher::detIds ( void  ) const

Definition at line 93 of file GEMRecHitMatcher.cc.

93  {
94  std::set<unsigned int> result;
95  for (const auto& p : detid_to_recHits_)
96  result.insert(p.first);
97  return result;
98 }

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

◆ gemDigiMatcher()

std::shared_ptr<GEMDigiMatcher> GEMRecHitMatcher::gemDigiMatcher ( ) const
inline

Definition at line 80 of file GEMRecHitMatcher.h.

80 { return gemDigiMatcher_; }

References gemDigiMatcher_.

◆ init()

void GEMRecHitMatcher::init ( const edm::Event e,
const edm::EventSetup eventSetup 
)

Definition at line 19 of file GEMRecHitMatcher.cc.

19  {
20  gemDigiMatcher_->init(iEvent, iSetup);
21 
22  iEvent.getByToken(gemRecHitToken_, gemRecHitH_);
23 
24  iSetup.get<MuonGeometryRecord>().get(gem_geom_);
25  if (gem_geom_.isValid()) {
27  } else {
28  std::cout << "+++ Info: GEM geometry is unavailable. +++\n";
29  }
30 }

References gather_cfg::cout, edm::EventSetup::get(), get, and iEvent.

◆ isGEMRecHitMatched()

bool GEMRecHitMatcher::isGEMRecHitMatched ( const GEMRecHit thisRh) const

Definition at line 198 of file GEMRecHitMatcher.cc.

198  {
199  return recHitInContainer(thisRh, recHits());
200 }

References FastTrackerRecHitMaskProducer_cfi::recHits.

◆ match()

void GEMRecHitMatcher::match ( const SimTrack t,
const SimVertex v 
)

do the matching

Definition at line 33 of file GEMRecHitMatcher.cc.

33  {
34  // match digis first
35  gemDigiMatcher_->match(t, v);
36 
37  // get the rechit collection
39 
40  // now match the rechits
42 }

References gemRecHits_cfi::gemRecHits, OrderedSet::t, and findQualityFiles::v.

◆ matchRecHitsToSimTrack()

void GEMRecHitMatcher::matchRecHitsToSimTrack ( const GEMRecHitCollection recHits)
private

Definition at line 44 of file GEMRecHitMatcher.cc.

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

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

◆ nGEMRecHits()

int GEMRecHitMatcher::nGEMRecHits ( ) const

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

◆ nLayersWithRecHitsInSuperChamber()

int GEMRecHitMatcher::nLayersWithRecHitsInSuperChamber ( unsigned int  detid) const

Definition at line 132 of file GEMRecHitMatcher.cc.

132  {
133  set<int> layers;
134  for (const auto& d : recHitsInSuperChamber(detid)) {
135  layers.insert(d.gemId().layer());
136  }
137  return layers.size();
138 }

References ztail::d, and hgcalTopologyTester_cfi::layers.

◆ partitionNumbers()

std::set< int > GEMRecHitMatcher::partitionNumbers ( ) const

Definition at line 151 of file GEMRecHitMatcher.cc.

151  {
152  std::set<int> result;
153 
154  for (auto id : detIds()) {
155  GEMDetId idd(id);
156  result.insert(idd.roll());
157  }
158  return result;
159 }

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

◆ recHitInContainer()

bool GEMRecHitMatcher::recHitInContainer ( const GEMRecHit rh,
const GEMRecHitContainer c 
) const

Definition at line 190 of file GEMRecHitMatcher.cc.

190  {
191  bool isSame = false;
192  for (const auto& thisRH : c)
193  if (areGEMRecHitSame(thisRH, rh))
194  isSame = true;
195  return isSame;
196 }

References HltBtagPostValidation_cff::c.

◆ recHitMeanPosition()

GlobalPoint GEMRecHitMatcher::recHitMeanPosition ( const GEMRecHitContainer rechits) const

Definition at line 167 of file GEMRecHitMatcher.cc.

167  {
168  GlobalPoint point_zero;
169  if (rechit.empty())
170  return point_zero; // point "zero"
171 
172  float sumx, sumy, sumz;
173  sumx = sumy = sumz = 0.f;
174  size_t n = 0;
175  for (const auto& d : rechit) {
177  if (gp == point_zero)
178  continue;
179 
180  sumx += gp.x();
181  sumy += gp.y();
182  sumz += gp.z();
183  ++n;
184  }
185  if (n == 0)
186  return GlobalPoint();
187  return GlobalPoint(sumx / n, sumy / n, sumz / n);
188 }

References ztail::d, runTauDisplay::gp, and dqmiodumpmetadata::n.

◆ recHitPosition()

GlobalPoint GEMRecHitMatcher::recHitPosition ( const GEMRecHit rechit) const

Definition at line 161 of file GEMRecHitMatcher.cc.

161  {
162  const GEMDetId& idd = rechit.gemId();
163  const LocalPoint& lp = rechit.localPosition();
164  return gemGeometry_->idToDet(idd)->surface().toGlobal(lp);
165 }

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

◆ recHits()

const GEMRecHitContainer& GEMRecHitMatcher::recHits ( void  ) const
inline

Definition at line 55 of file GEMRecHitMatcher.h.

55 { return recHits_; }

References recHits_.

◆ recHitsInChamber()

const GEMRecHitContainer & GEMRecHitMatcher::recHitsInChamber ( unsigned int  detid) const

Definition at line 120 of file GEMRecHitMatcher.cc.

120  {
121  if (chamber_to_recHits_.find(detid) == chamber_to_recHits_.end())
122  return no_recHits_;
123  return chamber_to_recHits_.at(detid);
124 }

◆ recHitsInDetId()

const GEMRecHitContainer & GEMRecHitMatcher::recHitsInDetId ( unsigned int  detid) const

Definition at line 114 of file GEMRecHitMatcher.cc.

114  {
115  if (detid_to_recHits_.find(detid) == detid_to_recHits_.end())
116  return no_recHits_;
117  return detid_to_recHits_.at(detid);
118 }

◆ recHitsInSuperChamber()

const GEMRecHitContainer & GEMRecHitMatcher::recHitsInSuperChamber ( unsigned int  detid) const

Definition at line 126 of file GEMRecHitMatcher.cc.

126  {
127  if (superchamber_to_recHits_.find(detid) == superchamber_to_recHits_.end())
128  return no_recHits_;
129  return superchamber_to_recHits_.at(detid);
130 }

◆ stripNumbersInDetId()

std::set< int > GEMRecHitMatcher::stripNumbersInDetId ( unsigned int  detid) const

Definition at line 140 of file GEMRecHitMatcher.cc.

140  {
141  set<int> result;
142  for (const auto& d : recHitsInDetId(detid)) {
143  // loop on all strips hit in this rechit
144  for (int iStrip = d.firstClusterStrip(); iStrip < d.firstClusterStrip() + d.clusterSize(); ++iStrip) {
145  result.insert(iStrip);
146  }
147  }
148  return result;
149 }

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

◆ superChamberIds()

std::set< unsigned int > GEMRecHitMatcher::superChamberIds ( ) const

Definition at line 107 of file GEMRecHitMatcher.cc.

107  {
108  std::set<unsigned int> result;
109  for (const auto& p : superchamber_to_recHits_)
110  result.insert(p.first);
111  return result;
112 }

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

◆ verbose()

bool GEMRecHitMatcher::verbose ( ) const
inline

Definition at line 72 of file GEMRecHitMatcher.h.

72 { return verbose_; }

References verbose_.

Member Data Documentation

◆ chamber_to_recHits_

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

Definition at line 101 of file GEMRecHitMatcher.h.

◆ detid_to_recHits_

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

Definition at line 100 of file GEMRecHitMatcher.h.

◆ gem_geom_

edm::ESHandle<GEMGeometry> GEMRecHitMatcher::gem_geom_
private

Definition at line 94 of file GEMRecHitMatcher.h.

◆ gemDigiMatcher_

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

Definition at line 107 of file GEMRecHitMatcher.h.

Referenced by gemDigiMatcher().

◆ gemGeometry_

const GEMGeometry* GEMRecHitMatcher::gemGeometry_
private

Definition at line 95 of file GEMRecHitMatcher.h.

◆ gemRecHitH_

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

Definition at line 92 of file GEMRecHitMatcher.h.

◆ gemRecHitToken_

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

Definition at line 91 of file GEMRecHitMatcher.h.

◆ maxBX_

int GEMRecHitMatcher::maxBX_
private

Definition at line 97 of file GEMRecHitMatcher.h.

◆ minBX_

int GEMRecHitMatcher::minBX_
private

Definition at line 97 of file GEMRecHitMatcher.h.

◆ no_recHits_

const GEMRecHitContainer GEMRecHitMatcher::no_recHits_
private

Definition at line 104 of file GEMRecHitMatcher.h.

◆ recHits_

GEMRecHitContainer GEMRecHitMatcher::recHits_
private

Definition at line 105 of file GEMRecHitMatcher.h.

Referenced by recHits().

◆ superchamber_to_recHits_

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

Definition at line 102 of file GEMRecHitMatcher.h.

◆ verbose_

bool GEMRecHitMatcher::verbose_
private

Definition at line 98 of file GEMRecHitMatcher.h.

Referenced by verbose().

GEMRecHitCollection
GEMRecHitMatcher::recHits_
GEMRecHitContainer recHits_
Definition: GEMRecHitMatcher.h:105
mps_fire.i
i
Definition: mps_fire.py:355
muonGEMRecHitPSet.gemRecHit
gemRecHit
Definition: muonGEMRecHitPSet.py:3
GEMRecHitMatcher::verbose_
bool verbose_
Definition: GEMRecHitMatcher.h:98
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
edm::Handle::product
T const * product() const
Definition: Handle.h:70
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
GEMRecHitMatcher::gemDigiMatcher_
std::shared_ptr< GEMDigiMatcher > gemDigiMatcher_
Definition: GEMRecHitMatcher.h:107
GEMGeometry::idToDet
const GeomDet * idToDet(DetId) const override
Definition: GEMGeometry.cc:25
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
gather_cfg.cout
cout
Definition: gather_cfg.py:144
GEMDigiMatcher
Definition: GEMDigiMatcher.h:28
GEMRecHitMatcher::recHits
const GEMRecHitContainer & recHits() const
Definition: GEMRecHitMatcher.h:55
findQualityFiles.v
v
Definition: findQualityFiles.py:179
GEMRecHitMatcher::recHitInContainer
bool recHitInContainer(const GEMRecHit &rh, const GEMRecHitContainer &c) const
Definition: GEMRecHitMatcher.cc:190
GEMRecHitMatcher::gemRecHitToken_
edm::EDGetTokenT< GEMRecHitCollection > gemRecHitToken_
Definition: GEMRecHitMatcher.h:91
GEMRecHitMatcher::recHitPosition
GlobalPoint recHitPosition(const GEMRecHit &rechit) const
Definition: GEMRecHitMatcher.cc:161
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
GEMRecHitMatcher::chamber_to_recHits_
std::map< unsigned int, GEMRecHitContainer > chamber_to_recHits_
Definition: GEMRecHitMatcher.h:101
GEMRecHitMatcher::gemGeometry_
const GEMGeometry * gemGeometry_
Definition: GEMRecHitMatcher.h:95
GEMRecHitMatcher::areGEMRecHitSame
bool areGEMRecHitSame(const GEMRecHit &l, const GEMRecHit &r) const
Definition: GEMRecHitMatcher.cc:202
GEMRecHitMatcher::superchamber_to_recHits_
std::map< unsigned int, GEMRecHitContainer > superchamber_to_recHits_
Definition: GEMRecHitMatcher.h:102
Surface::toGlobal
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:49
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, GlobalTag >
OrderedSet.t
t
Definition: OrderedSet.py:90
GEMRecHitMatcher::gem_geom_
edm::ESHandle< GEMGeometry > gem_geom_
Definition: GEMRecHitMatcher.h:94
runTauDisplay.gp
gp
Definition: runTauDisplay.py:431
GEMRecHitMatcher::recHitsInSuperChamber
const GEMRecHitContainer & recHitsInSuperChamber(unsigned int) const
Definition: GEMRecHitMatcher.cc:126
GEMRecHitMatcher::detIds
std::set< unsigned int > detIds() const
Definition: GEMRecHitMatcher.cc:93
GEMDetId
Definition: GEMDetId.h:17
TrackInfoProducer_cfi.rechits
rechits
Definition: TrackInfoProducer_cfi.py:9
iEvent
int iEvent
Definition: GenABIO.cc:224
GEMRecHitMatcher::matchRecHitsToSimTrack
void matchRecHitsToSimTrack(const GEMRecHitCollection &recHits)
Definition: GEMRecHitMatcher.cc:44
GEMRecHitMatcher::minBX_
int minBX_
Definition: GEMRecHitMatcher.h:97
GEMRecHit::gemId
GEMDetId gemId() const
Return the gemId.
Definition: GEMRecHit.h:65
GEMRecHitMatcher::no_recHits_
const GEMRecHitContainer no_recHits_
Definition: GEMRecHitMatcher.h:104
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
get
#define get
edm::ESHandleBase::isValid
bool isValid() const
Definition: ESHandle.h:44
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:193
alignCSCRings.r
r
Definition: alignCSCRings.py:93
GEMRecHitMatcher::recHitsInDetId
const GEMRecHitContainer & recHitsInDetId(unsigned int) const
Definition: GEMRecHitMatcher.cc:114
eostools.move
def move(src, dest)
Definition: eostools.py:511
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
GEMRecHitMatcher::gemRecHitH_
edm::Handle< GEMRecHitCollection > gemRecHitH_
Definition: GEMRecHitMatcher.h:92
GEMRecHitMatcher::detid_to_recHits_
std::map< unsigned int, GEMRecHitContainer > detid_to_recHits_
Definition: GEMRecHitMatcher.h:100
GEMRecHitMatcher::maxBX_
int maxBX_
Definition: GEMRecHitMatcher.h:97
ztail.d
d
Definition: ztail.py:151
mps_fire.result
result
Definition: mps_fire.py:303
gemRecHits_cfi.gemRecHits
gemRecHits
Definition: gemRecHits_cfi.py:7
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
edm::InputTag
Definition: InputTag.h:15
hgcalTopologyTester_cfi.layers
layers
Definition: hgcalTopologyTester_cfi.py:8
GEMRecHitMatcher::verbose
bool verbose() const
Definition: GEMRecHitMatcher.h:72
GEMRecHit::localPosition
LocalPoint localPosition() const override
Return the 3-dimensional local position.
Definition: GEMRecHit.h:37
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27