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 gemGeometry_ = &iSetup.
getData(geomToken_);
63 muonSimHitMatcher_->match(t, v);
78 if (matchToSimLink_) {
80 matchDigisSLToSimTrack(gemDigisSL);
82 matchDigisToSimTrack(gemDigis);
83 matchPadsToSimTrack(gemPads);
84 matchClustersToSimTrack(gemClusters);
85 matchCoPadsToSimTrack(gemCoPads);
90 edm::LogInfo(
"GEMDigiMatcher") <<
"Matching simtrack to GEM simlinks" << endl;
93 for (
auto itsimlink = digisSL.
begin(); itsimlink != digisSL.
end(); itsimlink++) {
95 for (
auto sl = itsimlink->data.begin(); sl != itsimlink->data.end(); ++sl) {
97 const auto& detids(muonSimHitMatcher_->detIds());
98 if (detids.find(p_id.
rawId()) == detids.end())
102 if (muonSimHitMatcher_->hitsInDetId(p_id.
rawId()).
empty())
106 edm::LogInfo(
"GEMDigiMatcher") <<
"GEMDigiSimLink " << p_id <<
" " << sl->getStrip() <<
" " << sl->getBx()
107 <<
" " << sl->getTrackId() << std::endl;
110 if (simMuOnly_ &&
std::abs(sl->getParticleType()) != 13)
114 if (discardEleHits_ &&
std::abs(sl->getParticleType()) == 11)
118 for (
const auto& simhit : muonSimHitMatcher_->hitsInDetId(p_id.
rawId())) {
120 if (simhit.trackId() == sl->getTrackId() and simhit.particleType() == sl->getParticleType()) {
121 detid_to_simLinks_[p_id.
rawId()].push_back(*sl);
123 edm::LogInfo(
"GEMDigiMatcher") <<
"...was matched!" << endl;
133 edm::LogInfo(
"GEMDigiMatcher") <<
"Matching simtrack to GEM digis" << endl;
134 for (
auto id : muonSimHitMatcher_->detIds()) {
136 const auto& hit_strips = muonSimHitMatcher_->hitStripsInDetId(
id, matchDeltaStrip_);
137 const auto& digis_in_det = digis.get(p_id);
139 for (
auto d = digis_in_det.first;
d != digis_in_det.second; ++
d) {
143 if (
d->bx() < minBXDigi_ ||
d->bx() > maxBXDigi_)
147 edm::LogInfo(
"GEMDigiMatcher") <<
"GEMDigi " << p_id <<
" " << *
d << endl;
150 if (matchToSimLink_) {
152 for (
const auto& sl : detid_to_simLinks_[p_id.
rawId()]) {
153 if (sl.getStrip() ==
d->strip() and sl.getBx() ==
d->bx()) {
162 if (hit_strips.find(
d->strip()) != hit_strips.end()) {
167 detid_to_digis_[p_id.
rawId()].push_back(*
d);
171 edm::LogInfo(
"GEMDigiMatcher") <<
"...was matched!" << endl;
177 for (
auto it = pads.begin(); it != pads.end(); ++it) {
179 const auto& padsvec = (*it).second;
181 for (
auto pad = padsvec.first; pad != padsvec.second; ++pad) {
183 if (pad->bx() < minBXPad_ || pad->bx() > maxBXPad_)
187 edm::LogInfo(
"GEMDigiMatcher") <<
"GEMPad " << p_id <<
" " << *pad << endl;
189 auto digivec = detid_to_digis_[p_id.
rawId()];
207 auto digivec2 = detid_to_digis_[p_id2.rawId()];
210 digivec.insert(digivec.end(), digivec2.begin(), digivec2.end());
212 for (
const auto& digi : digivec) {
214 const bool match8Partition(digi.strip() / 2 == pad->pad());
217 const bool match16Partition(digi.strip() == pad->pad());
220 const bool matchGE0(p_id.
isME0() and match8Partition);
221 const bool matchGE11(p_id.
isGE11() and match8Partition);
227 if (matchGE0
or matchGE11
or matchGE21_8
or matchGE21_16) {
228 detid_to_pads_[p_id.
rawId()].push_back(*pad);
232 edm::LogInfo(
"GEMDigiMatcher") <<
"...was matched!" << endl;
241 for (
auto it = clusters.begin(); it != clusters.end(); ++it) {
243 const auto clvec = (*it).second;
244 for (
auto cluster = clvec.first; cluster != clvec.second; ++cluster) {
248 if (cluster->bx() < minBXCluster_ || cluster->bx() > maxBXCluster_)
252 edm::LogInfo(
"GEMDigiMatcher") <<
"GEMCluster " << p_id <<
" " << *cluster << endl;
255 for (
const auto&
p : cluster->pads()) {
256 for (
const auto& pad : detid_to_pads_[p_id.
rawId()]) {
257 if (pad.pad() ==
p) {
263 detid_to_clusters_[p_id.
rawId()].push_back(*cluster);
264 chamber_to_clusters_[p_id.
chamberId().
rawId()].push_back(*cluster);
267 edm::LogInfo(
"GEMDigiMatcher") <<
"...was matched!" << endl;
275 for (
auto d : superChamberIdsPad()) {
278 const auto& co_pads_in_det = co_pads.get(
id);
279 for (
auto copad = co_pads_in_det.first; copad != co_pads_in_det.second; ++copad) {
281 if (copad->bx(1) < minBXCoPad_ || copad->bx(1) > maxBXCoPad_)
285 edm::LogInfo(
"GEMDigiMatcher") <<
"GEMCoPadDigi: " <<
id <<
" " << *copad << endl;
287 bool isMatchedL1 =
false;
288 bool isMatchedL2 =
false;
293 for (
const auto&
p : padsInDetId(gemL1_id.rawId())) {
294 if (
p == copad->first()) {
300 for (
const auto&
p : padsInChamber(gemL2_id.rawId())) {
301 if (
p == copad->second()) {
305 if (isMatchedL1 and isMatchedL2) {
306 superchamber_to_copads_[
id.rawId()].push_back(*copad);
308 edm::LogInfo(
"GEMDigiMatcher") <<
"...was matched! " << endl;
315 return selectDetIds(detid_to_simLinks_, gem_type);
319 return selectDetIds(detid_to_digis_, gem_type);
325 return selectDetIds(detid_to_clusters_, gem_type);
329 return selectDetIds(chamber_to_digis_, gem_type);
333 return selectDetIds(chamber_to_pads_, gem_type);
337 return selectDetIds(chamber_to_clusters_, gem_type);
341 return selectDetIds(superchamber_to_digis_, gem_type);
345 return selectDetIds(superchamber_to_pads_, gem_type);
349 return selectDetIds(superchamber_to_clusters_, gem_type);
353 return selectDetIds(superchamber_to_copads_, gem_type);
357 if (detid_to_digis_.find(detid) == detid_to_digis_.end())
358 return no_gem_digis_;
359 return detid_to_digis_.at(detid);
363 if (chamber_to_digis_.find(detid) == chamber_to_digis_.end())
364 return no_gem_digis_;
365 return chamber_to_digis_.at(detid);
369 if (superchamber_to_digis_.find(detid) == superchamber_to_digis_.end())
370 return no_gem_digis_;
371 return superchamber_to_digis_.at(detid);
375 if (detid_to_pads_.find(detid) == detid_to_pads_.end())
377 return detid_to_pads_.at(detid);
381 if (chamber_to_pads_.find(detid) == chamber_to_pads_.end())
383 return chamber_to_pads_.at(detid);
387 if (superchamber_to_pads_.find(detid) == superchamber_to_pads_.end())
389 return superchamber_to_pads_.at(detid);
393 if (detid_to_clusters_.find(detid) == detid_to_clusters_.end())
394 return no_gem_clusters_;
395 return detid_to_clusters_.at(detid);
399 if (chamber_to_clusters_.find(detid) == chamber_to_clusters_.end())
400 return no_gem_clusters_;
401 return chamber_to_clusters_.at(detid);
405 if (superchamber_to_clusters_.find(detid) == superchamber_to_clusters_.end())
406 return no_gem_clusters_;
407 return superchamber_to_clusters_.at(detid);
411 if (superchamber_to_copads_.find(detid) == superchamber_to_copads_.end())
412 return no_gem_copads_;
413 return superchamber_to_copads_.at(detid);
419 for (
int iLayer = 1; iLayer <= 2; iLayer++) {
422 const auto& digis = digisInChamber(ch_id.rawId());
424 if (!digis.empty()) {
425 layers.insert(iLayer);
428 return layers.size();
434 for (
int iLayer = 1; iLayer <= 2; iLayer++) {
437 const auto& pads = padsInChamber(ch_id.rawId());
440 layers.insert(iLayer);
443 return layers.size();
449 for (
int iLayer = 1; iLayer <= 2; iLayer++) {
452 const auto&
clusters = clustersInChamber(ch_id.rawId());
454 if (!clusters.empty()) {
455 layers.insert(iLayer);
458 return layers.size();
463 const auto& ids = superChamberIdsPad();
464 for (
const auto&
id : ids) {
465 n += padsInSuperChamber(
id).size();
472 const auto& ids = superChamberIdsCoPad();
473 for (
const auto&
id : ids) {
474 n += coPadsInSuperChamber(
id).size();
481 const auto& digis = digisInDetId(detid);
482 for (
const auto&
d : digis) {
483 result.insert(
d.strip());
490 const auto& digis = padsInDetId(detid);
491 for (
const auto&
d : digis) {
492 result.insert(
d.pad());
500 const auto& detids = detIdsDigi();
501 for (
const auto&
id : detids) {
503 result.insert(idd.
roll());
511 const auto& detids = superChamberIdsCoPad();
512 for (
const auto&
id : detids) {
514 result.insert(idd.
roll());
521 const LocalPoint& gem_lp = gemGeometry_->etaPartition(gem_id)->centreOfStrip(d.
strip());
522 const GlobalPoint& gem_gp = gemGeometry_->idToDet(gem_id)->surface().toGlobal(gem_lp);
528 const LocalPoint& gem_lp = gemGeometry_->etaPartition(gem_id)->centreOfPad(tp.
pad());
529 const GlobalPoint& gem_gp = gemGeometry_->idToDet(gem_id)->surface().toGlobal(gem_lp);
534 detid_to_simLinks_.clear();
536 detid_to_digis_.clear();
537 chamber_to_digis_.clear();
538 superchamber_to_digis_.clear();
540 detid_to_pads_.clear();
541 chamber_to_pads_.clear();
542 superchamber_to_pads_.clear();
544 detid_to_clusters_.clear();
545 chamber_to_clusters_.clear();
546 superchamber_to_clusters_.clear();
548 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
void matchClustersToSimTrack(const GEMPadDigiClusterCollection &)
bool getData(T &iHolder) const
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
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?