Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check valid pads and clusters in GEM trigger primitive producers #30624

Merged
merged 6 commits into from Aug 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions DataFormats/GEMDigi/src/GEMPadDigiCluster.cc
Expand Up @@ -37,10 +37,10 @@ bool GEMPadDigiCluster::isValid() const {
}

std::ostream& operator<<(std::ostream& o, const GEMPadDigiCluster& digi) {
o << " bx: " << digi.bx() << " pads: ";
o << " bx: " << digi.bx() << " pads: [";
for (auto p : digi.pads())
o << " " << p;
o << std::endl;
o << "]";
return o;
}

Expand Down
6 changes: 6 additions & 0 deletions DataFormats/MuonDetId/interface/GEMDetId.h
Expand Up @@ -227,6 +227,12 @@ class GEMDetId : public DetId {
return rawid;
}

// subsystem
GEMSubDetId::Station subsystem() const;
bool isGE11() const;
bool isGE21() const;
bool isME0() const;

private:
constexpr void v12FromV11(const uint32_t& rawid) { id_ = v12Form(rawid); }

Expand Down
8 changes: 8 additions & 0 deletions DataFormats/MuonDetId/src/GEMDetId.cc
Expand Up @@ -4,6 +4,14 @@

#include "DataFormats/MuonDetId/interface/GEMDetId.h"

GEMSubDetId::Station GEMDetId::subsystem() const { return GEMSubDetId::station(station()); }

bool GEMDetId::isGE11() const { return subsystem() == GEMSubDetId::Station::GE11; }

bool GEMDetId::isGE21() const { return subsystem() == GEMSubDetId::Station::GE21; }

bool GEMDetId::isME0() const { return subsystem() == GEMSubDetId::Station::ME0; }

std::ostream& operator<<(std::ostream& os, const GEMDetId& id) {
os << " Re " << id.region() << " Ri " << id.ring() << " St " << id.station() << " La " << id.layer() << " Ch "
<< id.chamber() << " Ro " << id.roll() << " ";
Expand Down
6 changes: 6 additions & 0 deletions Geometry/GEMGeometry/interface/GEMEtaPartition.h
Expand Up @@ -78,6 +78,12 @@ class GEMEtaPartition : public GeomDet {
/// returns last strip (INT number [0,nstrip-1]) for pad (an integer [0,npads-1])
int lastStripInPad(int pad) const;

// subsystem
GEMSubDetId::Station subsystem() const;
bool isME0() const;
bool isGE11() const;
bool isGE21() const;

private:
GEMDetId id_;
GEMEtaPartitionSpecs* specs_;
Expand Down
8 changes: 8 additions & 0 deletions Geometry/GEMGeometry/src/GEMEtaPartition.cc
Expand Up @@ -71,3 +71,11 @@ int GEMEtaPartition::lastStripInPad(int pad) const {
LocalPoint lp = specificPadTopology().localPosition(p);
return static_cast<int>(strip(lp));
}

GEMSubDetId::Station GEMEtaPartition::subsystem() const { return id_.subsystem(); }

bool GEMEtaPartition::isGE11() const { return id_.isGE11(); }

bool GEMEtaPartition::isGE21() const { return id_.isGE21(); }

bool GEMEtaPartition::isME0() const { return id_.isME0(); }
12 changes: 12 additions & 0 deletions L1Trigger/CSCTriggerPrimitives/src/GEMCoPadProcessor.cc
Expand Up @@ -59,7 +59,15 @@ std::vector<GEMCoPadDigi> GEMCoPadProcessor::run(const GEMPadDigiCollection* in_
// now let's correlate the pads in two layers of this partition
const auto& pads_range = (*det_range).second;
for (auto p = pads_range.first; p != pads_range.second; ++p) {
// only consider valid pads
if (!p->isValid())
continue;

for (auto co_p = co_pads_range.first; co_p != co_pads_range.second; ++co_p) {
// only consider valid pads
if (!co_p->isValid())
continue;

// check the match in pad
if ((unsigned)std::abs(p->pad() - co_p->pad()) > maxDeltaPad_)
continue;
Expand Down Expand Up @@ -91,6 +99,10 @@ void GEMCoPadProcessor::declusterize(const GEMPadDigiClusterCollection* in_clust
const GEMDetId& id = (*detUnitIt).first;
const auto& range = (*detUnitIt).second;
for (auto digiIt = range.first; digiIt != range.second; ++digiIt) {
// only consider valid clusters
if (!digiIt->isValid())
continue;

for (const auto& p : digiIt->pads()) {
out_pads.insertDigi(id, GEMPadDigi(p, digiIt->bx()));
}
Expand Down
38 changes: 29 additions & 9 deletions L1Trigger/L1TGEM/plugins/GEMPadDigiClusterProducer.cc
Expand Up @@ -99,6 +99,8 @@ class GEMPadDigiClusterProducer : public edm::stream::EDProducer<> {
void sortClusters(const GEMPadDigiClusterContainer& in_clusters,
GEMPadDigiClusterSortedContainer& out_clusters) const;
void selectClusters(const GEMPadDigiClusterSortedContainer& in, GEMPadDigiClusterCollection& out) const;
template <class T>
void checkValid(const T& cluster, const GEMDetId& id) const;

/// Name of input digi Collection
edm::EDGetTokenT<GEMPadDigiCollection> pad_token_;
Expand Down Expand Up @@ -187,7 +189,7 @@ void GEMPadDigiClusterProducer::buildClusters(const GEMPadDigiCollection& det_pa
for (const auto& part : geometry_->etaPartitions()) {
// clusters are not build for ME0
// -> ignore hits from station 0
if (part->id().station() == 0)
if (part->isME0())
continue;

GEMPadDigiClusters all_pad_clusters;
Expand All @@ -197,6 +199,9 @@ void GEMPadDigiClusterProducer::buildClusters(const GEMPadDigiCollection& det_pa
int startBX = 99;

for (auto d = pads.first; d != pads.second; ++d) {
// check if the input pad is valid
checkValid(*d, part->id());

if (cl.empty()) {
cl.push_back((*d).pad());
} else {
Expand All @@ -206,7 +211,10 @@ void GEMPadDigiClusterProducer::buildClusters(const GEMPadDigiCollection& det_pa
cl.push_back((*d).pad());
} else {
// put the current cluster in the proto collection
GEMPadDigiCluster pad_cluster(cl, startBX, GEMSubDetId::station(part->id().station()));
GEMPadDigiCluster pad_cluster(cl, startBX, part->subsystem());

// check if the output cluster is valid
checkValid(pad_cluster, part->id());

all_pad_clusters.emplace_back(pad_cluster);

Expand All @@ -220,7 +228,11 @@ void GEMPadDigiClusterProducer::buildClusters(const GEMPadDigiCollection& det_pa

// put the last cluster in the proto collection
if (pads.first != pads.second) {
GEMPadDigiCluster pad_cluster(cl, startBX, GEMSubDetId::station(part->id().station()));
GEMPadDigiCluster pad_cluster(cl, startBX, part->subsystem());

// check if the output cluster is valid
checkValid(pad_cluster, part->id());

all_pad_clusters.emplace_back(pad_cluster);
}
proto_clusters.emplace(part->id(), all_pad_clusters);
Expand All @@ -237,9 +249,7 @@ void GEMPadDigiClusterProducer::sortClusters(const GEMPadDigiClusterContainer& p

for (const auto& ch : geometry_->chambers()) {
// check the station number
const int station = ch->id().station();
const bool isGE11 = (station == 1);
const unsigned nOH = isGE11 ? nOHGE11_ : nOHGE21_;
const unsigned nOH = ch->id().isGE11() ? nOHGE11_ : nOHGE21_;
const unsigned nPartOH = ch->nEtaPartitions() / nOH;

std::vector<std::vector<std::pair<GEMDetId, GEMPadDigiClusters> > > temp_clustersCH;
Expand Down Expand Up @@ -268,9 +278,7 @@ void GEMPadDigiClusterProducer::selectClusters(const GEMPadDigiClusterSortedCont
GEMPadDigiClusterCollection& out_clusters) const {
// loop over chambers
for (const auto& ch : geometry_->chambers()) {
const int station = ch->id().station();
const bool isGE11 = (station == 1);
const unsigned maxClustersOH = isGE11 ? maxClustersOHGE11_ : maxClustersOHGE21_;
const unsigned maxClustersOH = ch->id().isGE11() ? maxClustersOHGE11_ : maxClustersOHGE21_;

// loop over the optohybrids
for (const auto& optohybrid : sorted_clusters.at(ch->id())) {
Expand All @@ -285,6 +293,9 @@ void GEMPadDigiClusterProducer::selectClusters(const GEMPadDigiClusterSortedCont
// pick the clusters with lowest pad number
for (const auto& clus : clusters) {
if (nClusters < maxClustersOH) {
// check if the output cluster is valid
checkValid(clus, detid);

out_clusters.insertDigi(detid, clus);
nClusters++;
}
Expand All @@ -294,4 +305,13 @@ void GEMPadDigiClusterProducer::selectClusters(const GEMPadDigiClusterSortedCont
} // end of chamber loop
}

template <class T>
void GEMPadDigiClusterProducer::checkValid(const T& tp, const GEMDetId& id) const {
// check if the pad/cluster is valid
// in principle, invalid pads/clusters can appear in the CMS raw data
if (!tp.isValid()) {
edm::LogWarning("GEMPadDigiClusterProducer") << "Invalid " << tp << " in " << id;
}
}

DEFINE_FWK_MODULE(GEMPadDigiClusterProducer);
27 changes: 22 additions & 5 deletions L1Trigger/L1TGEM/plugins/GEMPadDigiProducer.cc
Expand Up @@ -37,6 +37,7 @@ class GEMPadDigiProducer : public edm::stream::EDProducer<> {
private:
void buildPads(const GEMDigiCollection& digis, GEMPadDigiCollection& out_pads) const;
void buildPads16GE21(const GEMDigiCollection& digis, GEMPadDigiCollection& out_pads) const;
void checkValid(const GEMPadDigi& pad, const GEMDetId& id) const;

/// Name of input digi Collection
edm::EDGetTokenT<GEMDigiCollection> digi_token_;
Expand Down Expand Up @@ -94,7 +95,7 @@ void GEMPadDigiProducer::buildPads(const GEMDigiCollection& det_digis, GEMPadDig
for (const auto& p : geometry_->etaPartitions()) {
// when using the GE2/1 geometry with 16 eta partitions
// ->ignore GE2/1
if (use16GE21_ and p->id().station() == 2)
if (use16GE21_ and p->isGE21())
continue;

// set of <pad, bx> pairs, sorted first by pad then by bx
Expand All @@ -104,13 +105,20 @@ void GEMPadDigiProducer::buildPads(const GEMDigiCollection& det_digis, GEMPadDig
// and stuff them into a set of unique pads (equivalent of OR operation)
auto digis = det_digis.get(p->id());
for (auto d = digis.first; d != digis.second; ++d) {
int pad_num = static_cast<int>(p->padOfStrip(d->strip()));
unsigned pad_num = static_cast<int>(p->padOfStrip(d->strip()));

// check that the input digi is valid
if ((p->isGE11() and pad_num == GEMPadDigi::GE11InValid) or
(p->isGE21() and pad_num == GEMPadDigi::GE21InValid) or (p->isME0() and pad_num == GEMPadDigi::ME0InValid)) {
edm::LogWarning("GEMPadDigiProducer") << "Invalid " << pad_num << " from " << *d << " in " << p->id();
}
proto_pads.emplace(pad_num, d->bx());
}

// fill the output collections
for (const auto& d : proto_pads) {
GEMPadDigi pad_digi(d.first, d.second, GEMSubDetId::station(p->id().station()));
GEMPadDigi pad_digi(d.first, d.second, p->subsystem());
checkValid(pad_digi, p->id());
out_pads.insertDigi(p->id(), pad_digi);
}
}
Expand All @@ -120,7 +128,7 @@ void GEMPadDigiProducer::buildPads16GE21(const GEMDigiCollection& det_digis, GEM
for (const auto& p : geometry_->etaPartitions()) {
// when using the GE2/1 geometry with 16 eta partitions
// ->ignore GE1/1
if (p->id().station() == 1)
if (!p->isGE21())
continue;

// ignore eta partition with even numbers
Expand Down Expand Up @@ -150,10 +158,19 @@ void GEMPadDigiProducer::buildPads16GE21(const GEMDigiCollection& det_digis, GEM

// fill the output collections
for (const auto& d : proto_pads) {
GEMPadDigi pad_digi(d.first, d.second);
GEMPadDigi pad_digi(d.first, d.second, p->subsystem());
checkValid(pad_digi, p->id());
out_pads.insertDigi(p->id(), pad_digi);
}
}
}

void GEMPadDigiProducer::checkValid(const GEMPadDigi& pad, const GEMDetId& id) const {
// check if the pad is valid
// in principle, invalid pads can appear in the CMS raw data
if (!pad.isValid()) {
edm::LogWarning("GEMPadDigiProducer") << "Invalid " << pad << " in " << id;
}
}

DEFINE_FWK_MODULE(GEMPadDigiProducer);