CMS 3D CMS Logo

GEMRecHitMatcher.cc
Go to the documentation of this file.
4 
5 using namespace std;
6 
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
14  gemDigiMatcher_.reset(new GEMDigiMatcher(pset, std::move(iC)));
15 
16  gemRecHitToken_ = iC.consumes<GEMRecHitCollection>(gemRecHit.getParameter<edm::InputTag>("inputTag"));
17  geomToken_ = iC.esConsumes<GEMGeometry, MuonGeometryRecord>();
18 }
19 
21  gemDigiMatcher_->init(iEvent, iSetup);
22 
23  iEvent.getByToken(gemRecHitToken_, gemRecHitH_);
24 
25  gemGeometry_ = &iSetup.getData(geomToken_);
26 }
27 
30  // match digis first
31  gemDigiMatcher_->match(t, v);
32 
33  // get the rechit collection
34  const GEMRecHitCollection& gemRecHits = *gemRecHitH_.product();
35 
36  // now match the rechits
37  matchRecHitsToSimTrack(gemRecHits);
38 }
39 
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 }
88 
89 std::set<unsigned int> GEMRecHitMatcher::detIds() const {
90  std::set<unsigned int> result;
91  for (const auto& p : detid_to_recHits_)
92  result.insert(p.first);
93  return result;
94 }
95 
96 std::set<unsigned int> GEMRecHitMatcher::chamberIds() const {
97  std::set<unsigned int> result;
98  for (const auto& p : chamber_to_recHits_)
99  result.insert(p.first);
100  return result;
101 }
102 
103 std::set<unsigned int> GEMRecHitMatcher::superChamberIds() const {
104  std::set<unsigned int> result;
105  for (const auto& p : superchamber_to_recHits_)
106  result.insert(p.first);
107  return result;
108 }
109 
110 const GEMRecHitContainer& GEMRecHitMatcher::recHitsInDetId(unsigned int detid) const {
111  if (detid_to_recHits_.find(detid) == detid_to_recHits_.end())
112  return no_recHits_;
113  return detid_to_recHits_.at(detid);
114 }
115 
116 const GEMRecHitContainer& GEMRecHitMatcher::recHitsInChamber(unsigned int detid) const {
117  if (chamber_to_recHits_.find(detid) == chamber_to_recHits_.end())
118  return no_recHits_;
119  return chamber_to_recHits_.at(detid);
120 }
121 
123  if (superchamber_to_recHits_.find(detid) == superchamber_to_recHits_.end())
124  return no_recHits_;
125  return superchamber_to_recHits_.at(detid);
126 }
127 
129  set<int> layers;
130  for (const auto& d : recHitsInSuperChamber(detid)) {
131  layers.insert(d.gemId().layer());
132  }
133  return layers.size();
134 }
135 
136 std::set<int> GEMRecHitMatcher::stripNumbersInDetId(unsigned int detid) const {
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 }
146 
147 std::set<int> GEMRecHitMatcher::partitionNumbers() const {
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 }
156 
158  const GEMDetId& idd = rechit.gemId();
159  const LocalPoint& lp = rechit.localPosition();
160  return gemGeometry_->idToDet(idd)->surface().toGlobal(lp);
161 }
162 
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) {
172  GlobalPoint gp = recHitPosition(d);
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 }
185 
187  bool isSame = false;
188  for (const auto& thisRH : c)
189  if (areGEMRecHitSame(thisRH, rh))
190  isSame = true;
191  return isSame;
192 }
193 
195  return recHitInContainer(thisRh, recHits());
196 }
197 
199  return l.localPosition() == r.localPosition() and l.BunchX() == r.BunchX();
200 }
GEMRecHitCollection
mps_fire.i
i
Definition: mps_fire.py:428
muonGEMRecHitPSet.gemRecHit
gemRecHit
Definition: muonGEMRecHitPSet.py:3
SimVertex
Definition: SimVertex.h:5
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
gather_cfg.cout
cout
Definition: gather_cfg.py:144
GEMDigiMatcher
Definition: GEMDigiMatcher.h:31
GEMDetId::superChamberId
constexpr GEMDetId superChamberId() const
Definition: GEMDetId.h:207
GEMRecHitMatcher::chamberIds
std::set< unsigned int > chamberIds() const
Definition: GEMRecHitMatcher.cc:96
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
findQualityFiles.v
v
Definition: findQualityFiles.py:179
GEMRecHitMatcher::recHitInContainer
bool recHitInContainer(const GEMRecHit &rh, const GEMRecHitContainer &c) const
Definition: GEMRecHitMatcher.cc:186
GEMRecHitMatcher::recHitPosition
GlobalPoint recHitPosition(const GEMRecHit &rechit) const
Definition: GEMRecHitMatcher.cc:157
GEMRecHitMatcher::areGEMRecHitSame
bool areGEMRecHitSame(const GEMRecHit &l, const GEMRecHit &r) const
Definition: GEMRecHitMatcher.cc:198
GEMRecHitMatcher::recHitsInChamber
const GEMRecHitContainer & recHitsInChamber(unsigned int) const
Definition: GEMRecHitMatcher.cc:116
GEMRecHitMatcher::stripNumbersInDetId
std::set< int > stripNumbersInDetId(unsigned int) const
Definition: GEMRecHitMatcher.cc:136
GEMRecHitContainer
std::vector< GEMRecHit > GEMRecHitContainer
Definition: GEMRecHitMatcher.h:27
verbose
static constexpr int verbose
Definition: HLTExoticaSubAnalysis.cc:25
HI_PhotonSkim_cff.rechits
rechits
Definition: HI_PhotonSkim_cff.py:76
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, GlobalTag >
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
runTauDisplay.gp
gp
Definition: runTauDisplay.py:431
GEMRecHitMatcher::recHitsInSuperChamber
const GEMRecHitContainer & recHitsInSuperChamber(unsigned int) const
Definition: GEMRecHitMatcher.cc:122
GEMRecHitMatcher::detIds
std::set< unsigned int > detIds() const
Definition: GEMRecHitMatcher.cc:89
edm::ParameterSet
Definition: ParameterSet.h:47
GEMRecHitMatcher::GEMRecHitMatcher
GEMRecHitMatcher(edm::ParameterSet const &iPS, edm::ConsumesCollector &&iC)
Definition: GEMRecHitMatcher.cc:7
GEMRecHitMatcher::isGEMRecHitMatched
bool isGEMRecHitMatched(const GEMRecHit &thisRh) const
Definition: GEMRecHitMatcher.cc:194
GEMRecHitMatcher::nLayersWithRecHitsInSuperChamber
int nLayersWithRecHitsInSuperChamber(unsigned int) const
Definition: GEMRecHitMatcher.cc:128
GEMDetId::roll
constexpr int roll() const
Definition: GEMDetId.h:194
GEMDetId
Definition: GEMDetId.h:18
GEMRecHitMatcher::partitionNumbers
std::set< int > partitionNumbers() const
Definition: GEMRecHitMatcher.cc:147
iEvent
int iEvent
Definition: GenABIO.cc:224
GEMRecHitMatcher::matchRecHitsToSimTrack
void matchRecHitsToSimTrack(const GEMRecHitCollection &recHits)
Definition: GEMRecHitMatcher.cc:40
GEMRecHit::gemId
GEMDetId gemId() const
Return the gemId.
Definition: GEMRecHit.h:65
edm::EventSetup
Definition: EventSetup.h:58
GEMRecHitMatcher.h
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
alignCSCRings.r
r
Definition: alignCSCRings.py:93
GEMRecHitMatcher::recHitsInDetId
const GEMRecHitContainer & recHitsInDetId(unsigned int) const
Definition: GEMRecHitMatcher.cc:110
GEMRecHitMatcher::init
void init(const edm::Event &e, const edm::EventSetup &eventSetup)
Definition: GEMRecHitMatcher.cc:20
GEMRecHitMatcher::recHitMeanPosition
GlobalPoint recHitMeanPosition(const GEMRecHitContainer &rechits) const
Definition: GEMRecHitMatcher.cc:163
GEMGeometry.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
SimTrack
Definition: SimTrack.h:9
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
GEMDetId::chamberId
constexpr GEMDetId chamberId() const
Definition: GEMDetId.h:204
GEMRecHitMatcher::superChamberIds
std::set< unsigned int > superChamberIds() const
Definition: GEMRecHitMatcher.cc:103
GEMRecHit
Definition: GEMRecHit.h:14
GEMGeometry
Definition: GEMGeometry.h:24
ztail.d
d
Definition: ztail.py:151
mps_fire.result
result
Definition: mps_fire.py:311
gemRecHits_cfi.gemRecHits
gemRecHits
Definition: gemRecHits_cfi.py:7
MuonGeometryRecord.h
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
edm::Event
Definition: Event.h:73
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
GEMRecHitMatcher::match
void match(const SimTrack &t, const SimVertex &v)
do the matching
Definition: GEMRecHitMatcher.cc:29
edm::Log
Definition: MessageLogger.h:70
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
hgcalTopologyTester_cfi.layers
layers
Definition: hgcalTopologyTester_cfi.py:8
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