8 discardEleHits_ = gemSimLink.getParameter<
bool>(
"discardEleHits");
9 verboseSimLink_ = gemSimLink.getParameter<
int>(
"verbose");
13 maxBXDigi_ = gemDigi.getParameter<
int>(
"maxBX");
14 matchDeltaStrip_ = gemDigi.getParameter<
int>(
"matchDeltaStrip");
15 verboseDigi_ = gemDigi.getParameter<
int>(
"verbose");
16 matchToSimLink_ = gemDigi.getParameter<
bool>(
"matchToSimLink");
20 maxBXPad_ = gemPad.getParameter<
int>(
"maxBX");
21 verbosePad_ = gemPad.getParameter<
int>(
"verbose");
25 maxBXCluster_ = gemCluster.getParameter<
int>(
"maxBX");
26 verboseCluster_ = gemCluster.getParameter<
int>(
"verbose");
30 maxBXCoPad_ = gemCoPad.getParameter<
int>(
"maxBX");
31 verboseCoPad_ = gemCoPad.getParameter<
int>(
"verbose");
48 muonSimHitMatcher_->init(iEvent, iSetup);
51 iEvent.
getByToken(gemSimLinkToken_, gemDigisSLH_);
54 iEvent.
getByToken(gemClusterToken_, gemClustersH_);
55 iEvent.
getByToken(gemCoPadToken_, gemCoPadsH_);
57 const auto gemH = iSetup.
getHandle(geomToken_);
58 if (!gemH.isValid()) {
59 gemGeometry_ =
nullptr;
60 edm::LogError(
"GEMDigiMatcher") <<
"Failed to initialize GEM geometry.";
62 gemGeometry_ = gemH.product();
68 muonSimHitMatcher_->match(t, v);
83 if (matchToSimLink_) {
85 matchDigisSLToSimTrack(gemDigisSL);
87 matchDigisToSimTrack(gemDigis);
88 matchPadsToSimTrack(gemPads);
89 matchClustersToSimTrack(gemClusters);
90 matchCoPadsToSimTrack(gemCoPads);
95 edm::LogInfo(
"GEMDigiMatcher") <<
"Matching simtrack to GEM simlinks" << endl;
98 for (
auto itsimlink = digisSL.
begin(); itsimlink != digisSL.
end(); itsimlink++) {
100 for (
auto sl = itsimlink->data.begin(); sl != itsimlink->data.end(); ++sl) {
102 const auto& detids(muonSimHitMatcher_->detIds());
103 if (detids.find(p_id.
rawId()) == detids.end())
107 if (muonSimHitMatcher_->hitsInDetId(p_id.
rawId()).
empty())
111 edm::LogInfo(
"GEMDigiMatcher") <<
"GEMDigiSimLink " << p_id <<
" " << sl->getStrip() <<
" " << sl->getBx()
112 <<
" " << sl->getTrackId() << std::endl;
115 if (simMuOnly_ &&
std::abs(sl->getParticleType()) != 13)
119 if (discardEleHits_ &&
std::abs(sl->getParticleType()) == 11)
123 for (
const auto& simhit : muonSimHitMatcher_->hitsInDetId(p_id.
rawId())) {
125 if (simhit.trackId() == sl->getTrackId() and simhit.particleType() == sl->getParticleType()) {
126 detid_to_simLinks_[p_id.
rawId()].push_back(*sl);
128 edm::LogInfo(
"GEMDigiMatcher") <<
"...was matched!" << endl;
138 edm::LogInfo(
"GEMDigiMatcher") <<
"Matching simtrack to GEM digis" << endl;
139 for (
auto id : muonSimHitMatcher_->detIds()) {
141 const auto& hit_strips = muonSimHitMatcher_->hitStripsInDetId(
id, matchDeltaStrip_);
142 const auto& digis_in_det = digis.get(p_id);
144 for (
auto d = digis_in_det.first;
d != digis_in_det.second; ++
d) {
148 if (
d->bx() < minBXDigi_ ||
d->bx() > maxBXDigi_)
152 edm::LogInfo(
"GEMDigiMatcher") <<
"GEMDigi " << p_id <<
" " << *
d << endl;
155 if (matchToSimLink_) {
157 for (
const auto& sl : detid_to_simLinks_[p_id.
rawId()]) {
158 if (sl.getStrip() ==
d->strip() and sl.getBx() ==
d->bx()) {
167 if (hit_strips.find(
d->strip()) != hit_strips.end()) {
172 detid_to_digis_[p_id.
rawId()].push_back(*
d);
176 edm::LogInfo(
"GEMDigiMatcher") <<
"...was matched!" << endl;
182 for (
auto it = pads.begin(); it != pads.end(); ++it) {
184 const auto& padsvec = (*it).second;
186 for (
auto pad = padsvec.first; pad != padsvec.second; ++pad) {
188 if (pad->bx() < minBXPad_ || pad->bx() > maxBXPad_)
192 edm::LogInfo(
"GEMDigiMatcher") <<
"GEMPad " << p_id <<
" " << *pad << endl;
194 auto digivec = detid_to_digis_[p_id.
rawId()];
212 auto digivec2 = detid_to_digis_[p_id2.rawId()];
215 digivec.insert(digivec.end(), digivec2.begin(), digivec2.end());
217 for (
const auto& digi : digivec) {
219 const bool match8Partition(digi.strip() / 2 == pad->pad());
222 const bool match16Partition(digi.strip() == pad->pad());
225 const bool matchGE0(p_id.
isME0() and match8Partition);
226 const bool matchGE11(p_id.
isGE11() and match8Partition);
232 if (matchGE0
or matchGE11
or matchGE21_8
or matchGE21_16) {
233 detid_to_pads_[p_id.
rawId()].push_back(*pad);
237 edm::LogInfo(
"GEMDigiMatcher") <<
"...was matched!" << endl;
246 for (
auto it = clusters.begin(); it != clusters.end(); ++it) {
248 const auto clvec = (*it).second;
249 for (
auto cluster = clvec.first; cluster != clvec.second; ++cluster) {
253 if (cluster->bx() < minBXCluster_ || cluster->bx() > maxBXCluster_)
257 edm::LogInfo(
"GEMDigiMatcher") <<
"GEMCluster " << p_id <<
" " << *cluster << endl;
260 for (
const auto&
p : cluster->pads()) {
261 for (
const auto& pad : detid_to_pads_[p_id.
rawId()]) {
262 if (pad.pad() ==
p) {
268 detid_to_clusters_[p_id.
rawId()].push_back(*cluster);
269 chamber_to_clusters_[p_id.
chamberId().
rawId()].push_back(*cluster);
272 edm::LogInfo(
"GEMDigiMatcher") <<
"...was matched!" << endl;
280 for (
auto d : superChamberIdsPad()) {
283 const auto& co_pads_in_det = co_pads.get(
id);
284 for (
auto copad = co_pads_in_det.first; copad != co_pads_in_det.second; ++copad) {
286 if (copad->bx(1) < minBXCoPad_ || copad->bx(1) > maxBXCoPad_)
290 edm::LogInfo(
"GEMDigiMatcher") <<
"GEMCoPadDigi: " <<
id <<
" " << *copad << endl;
292 bool isMatchedL1 =
false;
293 bool isMatchedL2 =
false;
298 for (
const auto&
p : padsInDetId(gemL1_id.rawId())) {
299 if (
p == copad->first()) {
305 for (
const auto&
p : padsInChamber(gemL2_id.rawId())) {
306 if (
p == copad->second()) {
310 if (isMatchedL1 and isMatchedL2) {
311 superchamber_to_copads_[
id.rawId()].push_back(*copad);
313 edm::LogInfo(
"GEMDigiMatcher") <<
"...was matched! " << endl;
320 return selectDetIds(detid_to_simLinks_, gem_type);
324 return selectDetIds(detid_to_digis_, gem_type);
330 return selectDetIds(detid_to_clusters_, gem_type);
334 return selectDetIds(chamber_to_digis_, gem_type);
338 return selectDetIds(chamber_to_pads_, gem_type);
342 return selectDetIds(chamber_to_clusters_, gem_type);
346 return selectDetIds(superchamber_to_digis_, gem_type);
350 return selectDetIds(superchamber_to_pads_, gem_type);
354 return selectDetIds(superchamber_to_clusters_, gem_type);
358 return selectDetIds(superchamber_to_copads_, gem_type);
362 if (detid_to_digis_.find(detid) == detid_to_digis_.end())
363 return no_gem_digis_;
364 return detid_to_digis_.at(detid);
368 if (chamber_to_digis_.find(detid) == chamber_to_digis_.end())
369 return no_gem_digis_;
370 return chamber_to_digis_.at(detid);
374 if (superchamber_to_digis_.find(detid) == superchamber_to_digis_.end())
375 return no_gem_digis_;
376 return superchamber_to_digis_.at(detid);
380 if (detid_to_pads_.find(detid) == detid_to_pads_.end())
382 return detid_to_pads_.at(detid);
386 if (chamber_to_pads_.find(detid) == chamber_to_pads_.end())
388 return chamber_to_pads_.at(detid);
392 if (superchamber_to_pads_.find(detid) == superchamber_to_pads_.end())
394 return superchamber_to_pads_.at(detid);
398 if (detid_to_clusters_.find(detid) == detid_to_clusters_.end())
399 return no_gem_clusters_;
400 return detid_to_clusters_.at(detid);
404 if (chamber_to_clusters_.find(detid) == chamber_to_clusters_.end())
405 return no_gem_clusters_;
406 return chamber_to_clusters_.at(detid);
410 if (superchamber_to_clusters_.find(detid) == superchamber_to_clusters_.end())
411 return no_gem_clusters_;
412 return superchamber_to_clusters_.at(detid);
416 if (superchamber_to_copads_.find(detid) == superchamber_to_copads_.end())
417 return no_gem_copads_;
418 return superchamber_to_copads_.at(detid);
424 for (
int iLayer = 1; iLayer <= 2; iLayer++) {
427 const auto& digis = digisInChamber(ch_id.rawId());
429 if (!digis.empty()) {
430 layers.insert(iLayer);
433 return layers.size();
439 for (
int iLayer = 1; iLayer <= 2; iLayer++) {
442 const auto& pads = padsInChamber(ch_id.rawId());
445 layers.insert(iLayer);
448 return layers.size();
454 for (
int iLayer = 1; iLayer <= 2; iLayer++) {
457 const auto&
clusters = clustersInChamber(ch_id.rawId());
459 if (!clusters.empty()) {
460 layers.insert(iLayer);
463 return layers.size();
468 const auto& ids = superChamberIdsPad();
469 for (
const auto&
id : ids) {
470 n += padsInSuperChamber(
id).size();
477 const auto& ids = superChamberIdsCoPad();
478 for (
const auto&
id : ids) {
479 n += coPadsInSuperChamber(
id).size();
486 const auto& digis = digisInDetId(detid);
487 for (
const auto&
d : digis) {
488 result.insert(
d.strip());
495 const auto& digis = padsInDetId(detid);
496 for (
const auto&
d : digis) {
497 result.insert(
d.pad());
505 const auto& detids = detIdsDigi();
506 for (
const auto&
id : detids) {
508 result.insert(idd.
roll());
516 const auto& detids = superChamberIdsCoPad();
517 for (
const auto&
id : detids) {
519 result.insert(idd.
roll());
526 const LocalPoint& gem_lp = gemGeometry_->etaPartition(gem_id)->centreOfStrip(d.
strip());
527 const GlobalPoint& gem_gp = gemGeometry_->idToDet(gem_id)->surface().toGlobal(gem_lp);
533 const LocalPoint& gem_lp = gemGeometry_->etaPartition(gem_id)->centreOfPad(tp.
pad());
534 const GlobalPoint& gem_gp = gemGeometry_->idToDet(gem_id)->surface().toGlobal(gem_lp);
539 detid_to_simLinks_.clear();
541 detid_to_digis_.clear();
542 chamber_to_digis_.clear();
543 superchamber_to_digis_.clear();
545 detid_to_pads_.clear();
546 chamber_to_pads_.clear();
547 superchamber_to_pads_.clear();
549 detid_to_clusters_.clear();
550 chamber_to_clusters_.clear();
551 superchamber_to_clusters_.clear();
553 superchamber_to_copads_.clear();
void matchCoPadsToSimTrack(const GEMCoPadDigiCollection &)
std::vector< GEMCoPadDigi > GEMCoPadDigiContainer
std::set< unsigned int > superChamberIdsCluster(int gem_type=MuonHitHelper::GEM_ALL) const
const GEMPadDigiClusterContainer & clustersInChamber(unsigned int) const
std::set< int > padNumbersInDetId(unsigned int) const
std::set< unsigned int > detIdsCluster(int gem_type=MuonHitHelper::GEM_ALL) const
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
void match(const SimTrack &t, const SimVertex &v)
do the matching
GlobalPoint getGlobalPointPad(unsigned int rawId, const GEMPadDigi &tp) const
std::set< unsigned int > detIdsDigi(int gem_type=MuonHitHelper::GEM_ALL) const
uint16_t *__restrict__ id
GlobalPoint getGlobalPointDigi(unsigned int rawId, const GEMDigi &d) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::set< int > stripNumbersInDetId(unsigned int) const
std::set< int > partitionNumbers() const
constexpr int roll() const
void matchPadsToSimTrack(const GEMPadDigiCollection &)
const GEMPadDigiContainer & padsInDetId(unsigned int) const
constexpr uint32_t rawId() const
get the raw id
GEMDigiMatcher(edm::ParameterSet const &iPS, edm::ConsumesCollector &&iC)
const GEMPadDigiContainer & padsInChamber(unsigned int) const
std::set< unsigned int > detIdsPad(int gem_type=MuonHitHelper::GEM_ALL) const
Log< level::Error, false > LogError
void matchClustersToSimTrack(const GEMPadDigiClusterCollection &)
std::vector< GEMDigi > GEMDigiContainer
const GEMPadDigiClusterContainer & clustersInDetId(unsigned int) const
std::vector< GEMPadDigiCluster > GEMPadDigiClusterContainer
const GEMPadDigiClusterContainer & clustersInSuperChamber(unsigned int) const
void matchDigisToSimTrack(const GEMDigiCollection &)
const GEMDigiContainer & digisInChamber(unsigned int) const
std::set< int > partitionNumbersWithCoPads() const
constexpr int region() const
std::set< unsigned int > detIdsSimLink(int gem_type=MuonHitHelper::GEM_ALL) const
Abs< T >::type abs(const T &t)
const GEMDigiContainer & digisInDetId(unsigned int) const
constexpr GEMDetId chamberId() const
bool isMatched(TrackingRecHit const &hit)
std::set< unsigned int > superChamberIdsDigi(int gem_type=MuonHitHelper::GEM_ALL) const
int nLayersWithDigisInSuperChamber(unsigned int) const
iterator end()
Return the off-the-end iterator.
Log< level::Info, false > LogInfo
const GEMCoPadDigiContainer & coPadsInSuperChamber(unsigned int) const
std::set< unsigned int > chamberIdsDigi(int gem_type=MuonHitHelper::GEM_ALL) const
std::set< unsigned int > superChamberIdsCoPad(int gem_type=MuonHitHelper::GEM_ALL) const
std::vector< GEMPadDigi > GEMPadDigiContainer
std::set< unsigned int > superChamberIdsPad(int gem_type=MuonHitHelper::GEM_ALL) const
std::set< unsigned int > chamberIdsCluster(int gem_type=MuonHitHelper::GEM_ALL) const
ParameterSet const & getParameterSet(std::string const &) const
constexpr int chamber() const
constexpr int ring() const
constexpr int layer() const
T getParameter(std::string const &) const
constexpr int station() const
void matchDigisSLToSimTrack(const edm::DetSetVector< GEMDigiSimLink > &)
const math::XYZTLorentzVectorD & momentum() const
int nLayersWithPadsInSuperChamber(unsigned int) const
iterator begin()
Return an iterator to the first DetSet.
int nLayersWithClustersInSuperChamber(unsigned int) const
constexpr GEMDetId superChamberId() const
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
int nPads() const
How many pads in GEM did this simtrack get in total?
const GEMPadDigiContainer & padsInSuperChamber(unsigned int) const
std::set< unsigned int > chamberIdsPad(int gem_type=MuonHitHelper::GEM_ALL) const
const GEMDigiContainer & digisInSuperChamber(unsigned int) const
void init(const edm::Event &e, const edm::EventSetup &eventSetup)
int nCoPads() const
How many coincidence pads in GEM did this simtrack get in total?