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

Add partition number in GEM trigger primitives #31268

Merged
merged 15 commits into from Sep 11, 2020
13 changes: 11 additions & 2 deletions DataFormats/GEMDigi/interface/GEMPadDigi.h
Expand Up @@ -17,8 +17,14 @@
class GEMPadDigi {
public:
enum InValid { ME0InValid = 255, GE11InValid = 255, GE21InValid = 511 };

explicit GEMPadDigi(uint16_t pad, int16_t bx, enum GEMSubDetId::Station station = GEMSubDetId::Station::GE11);
// Newer GE2/1 geometries will have 16 eta partitions
// instead of the usual 8.
enum NumberPartitions { ME0 = 8, GE11 = 8, GE21 = 8, GE21SplitStrip = 16 };

explicit GEMPadDigi(uint16_t pad,
int16_t bx,
enum GEMSubDetId::Station station = GEMSubDetId::Station::GE11,
unsigned nPart = NumberPartitions::GE11);
GEMPadDigi();

bool operator==(const GEMPadDigi& digi) const;
Expand All @@ -33,12 +39,15 @@ class GEMPadDigi {
int16_t bx() const { return bx_; }
GEMSubDetId::Station station() const { return station_; }

unsigned nPartitions() const { return part_; }
void print() const;

private:
uint16_t pad_;
int16_t bx_;
GEMSubDetId::Station station_;
// number of eta partitions
unsigned part_;
};

std::ostream& operator<<(std::ostream& o, const GEMPadDigi& digi);
Expand Down
9 changes: 8 additions & 1 deletion DataFormats/GEMDigi/interface/GEMPadDigiCluster.h
Expand Up @@ -19,10 +19,14 @@
class GEMPadDigiCluster {
public:
enum InValid { GE11InValid = 255, GE21InValid = 511 };
// Newer GE2/1 geometries will have 16 eta partitions
// instead of the usual 8.
enum NumberPartitions { ME0 = 8, GE11 = 8, GE21 = 8, GE21SplitStrip = 16 };

explicit GEMPadDigiCluster(std::vector<uint16_t> pads,
int16_t bx,
enum GEMSubDetId::Station station = GEMSubDetId::Station::GE11);
enum GEMSubDetId::Station station = GEMSubDetId::Station::GE11,
unsigned nPart = NumberPartitions::GE11);
GEMPadDigiCluster();

bool operator==(const GEMPadDigiCluster& digi) const;
Expand All @@ -36,12 +40,15 @@ class GEMPadDigiCluster {
int bx() const { return bx_; }
GEMSubDetId::Station station() const { return station_; }

unsigned nPartitions() const { return part_; }
void print() const;

private:
std::vector<uint16_t> v_;
int32_t bx_;
GEMSubDetId::Station station_;
// number of eta partitions
unsigned part_;
};

std::ostream& operator<<(std::ostream& o, const GEMPadDigiCluster& digi);
Expand Down
7 changes: 4 additions & 3 deletions DataFormats/GEMDigi/src/GEMPadDigi.cc
@@ -1,10 +1,11 @@
#include "DataFormats/GEMDigi/interface/GEMPadDigi.h"
#include <iostream>

GEMPadDigi::GEMPadDigi(uint16_t pad, int16_t bx, enum GEMSubDetId::Station station)
: pad_(pad), bx_(bx), station_(station) {}
GEMPadDigi::GEMPadDigi(uint16_t pad, int16_t bx, enum GEMSubDetId::Station station, unsigned nPart)
: pad_(pad), bx_(bx), station_(station), part_(nPart) {}

GEMPadDigi::GEMPadDigi() : pad_(GE11InValid), bx_(-99), station_(GEMSubDetId::Station::GE11) {}
GEMPadDigi::GEMPadDigi()
: pad_(GE11InValid), bx_(-99), station_(GEMSubDetId::Station::GE11), part_(NumberPartitions::GE11) {}

// Comparison
bool GEMPadDigi::operator==(const GEMPadDigi& digi) const {
Expand Down
12 changes: 8 additions & 4 deletions DataFormats/GEMDigi/src/GEMPadDigiCluster.cc
@@ -1,10 +1,14 @@
#include "DataFormats/GEMDigi/interface/GEMPadDigiCluster.h"
#include <iostream>

GEMPadDigiCluster::GEMPadDigiCluster(std::vector<uint16_t> pads, int16_t bx, enum GEMSubDetId::Station station)
: v_(pads), bx_(bx), station_(station) {}

GEMPadDigiCluster::GEMPadDigiCluster() : v_(std::vector<uint16_t>()), bx_(-99), station_(GEMSubDetId::Station::GE11) {}
GEMPadDigiCluster::GEMPadDigiCluster(std::vector<uint16_t> pads,
int16_t bx,
enum GEMSubDetId::Station station,
unsigned nPart)
: v_(pads), bx_(bx), station_(station), part_(nPart) {}

GEMPadDigiCluster::GEMPadDigiCluster()
: v_(std::vector<uint16_t>()), bx_(-99), station_(GEMSubDetId::Station::GE11), part_(NumberPartitions::GE11) {}

// Comparison
bool GEMPadDigiCluster::operator==(const GEMPadDigiCluster& digi) const {
Expand Down
10 changes: 6 additions & 4 deletions DataFormats/GEMDigi/src/classes_def.xml
Expand Up @@ -10,20 +10,22 @@
<class name="MuonDigiCollection<GEMDetId,GEMDigi>"/>
<class name="edm::Wrapper<MuonDigiCollection<GEMDetId,GEMDigi> >" splitLevel="0"/>

<class name="GEMPadDigi" ClassVersion="13">
<class name="GEMPadDigi" ClassVersion="14">
<version ClassVersion="11" checksum="426510066"/>
<version ClassVersion="12" checksum="3838591655"/>
<version ClassVersion="13" checksum="2944221332"/>
<version ClassVersion="14" checksum="1418399352"/>
</class>
<class name="std::vector<GEMPadDigi>"/>
<class name="std::map<GEMDetId,std::vector<GEMPadDigi> >"/>
<class name="std::pair<GEMDetId,std::vector<GEMPadDigi> >"/>
<class name="MuonDigiCollection<GEMDetId,GEMPadDigi>"/>
<class name="edm::Wrapper<MuonDigiCollection<GEMDetId,GEMPadDigi> >" splitLevel="0"/>

<class name="GEMPadDigiCluster" ClassVersion="11">
<class name="GEMPadDigiCluster" ClassVersion="12">
<version ClassVersion="10" checksum="2569340006"/>
<version ClassVersion="11" checksum="3372991553"/>
<version ClassVersion="12" checksum="533478463"/>
</class>
<class name="std::vector<GEMPadDigiCluster>"/>
<class name="std::map<GEMDetId,std::vector<GEMPadDigiCluster> >"/>
Expand All @@ -47,8 +49,8 @@
<class name="std::vector<GEMVfatStatusDigi>"/>
<class name="std::map<GEMDetId,std::vector<GEMVfatStatusDigi> >"/>
<class name="std::pair<GEMDetId,std::vector<GEMVfatStatusDigi> >"/>
<class name="MuonDigiCollection<GEMDetId,GEMVfatStatusDigi>"/>
<class name="edm::Wrapper<MuonDigiCollection<GEMDetId,GEMVfatStatusDigi> >" splitLevel="0"/>
<class name="MuonDigiCollection<GEMDetId,GEMVfatStatusDigi>"/>
<class name="edm::Wrapper<MuonDigiCollection<GEMDetId,GEMVfatStatusDigi> >" splitLevel="0"/>

<class name="gem::GEBdata" ClassVersion="3">
<version ClassVersion="3" checksum="3127786112"/>
Expand Down
4 changes: 4 additions & 0 deletions Geometry/GEMGeometry/interface/GEMGeometry.h
Expand Up @@ -109,6 +109,10 @@ class GEMGeometry : public TrackingGeometry {
/// Add a GEMEtaPartition to the Geometry
void add(const GEMEtaPartition* etaPartition);

bool hasME0() const;
bool hasGE11() const;
bool hasGE21() const;

private:
DetContainer theEtaPartitions;
DetContainer theDets;
Expand Down
6 changes: 6 additions & 0 deletions Geometry/GEMGeometry/src/GEMGeometry.cc
Expand Up @@ -107,3 +107,9 @@ void GEMGeometry::add(const GEMChamber* chamber) {
theDetIds.emplace_back(chamber->geographicalId());
theMap.insert(std::make_pair((chamber->geographicalId()).rawId(), chamber));
}

bool GEMGeometry::hasME0() const { return station(1, 0) != nullptr and station(-1, 0) != nullptr; }

bool GEMGeometry::hasGE11() const { return station(1, 1) != nullptr and station(-1, 1) != nullptr; }

bool GEMGeometry::hasGE21() const { return station(1, 2) != nullptr and station(-1, 2) != nullptr; }
9 changes: 9 additions & 0 deletions L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboard.cc
Expand Up @@ -45,6 +45,10 @@ void CSCGEMMotherboard::retrieveGEMPads(const GEMPadDigiCollection* gemPads, uns
GEMDetId roll_id(roll->id());
auto pads_in_det = gemPads->get(roll_id);
for (auto pad = pads_in_det.first; pad != pads_in_det.second; ++pad) {
// ignore 16-partition GE2/1 pads
if (roll->isGE21() and pad->nPartitions() == GEMPadDigi::GE21SplitStrip)
continue;

// ignore invalid pads
if (!pad->isValid())
continue;
Expand All @@ -63,6 +67,11 @@ void CSCGEMMotherboard::retrieveGEMCoPads() {
coPads_.clear();
for (const auto& copad : gemCoPadV) {
GEMDetId detId(theRegion, 1, theStation, 0, theChamber, 0);

// ignore 16-partition GE2/1 pads
if (detId.isGE21() and copad.first().nPartitions() == GEMPadDigi::GE21SplitStrip)
continue;

// only consider matches with same BX
coPads_[CSCConstants::LCT_CENTRAL_BX + copad.bx(1)].emplace_back(detId.rawId(), copad);
}
Expand Down
8 changes: 8 additions & 0 deletions L1Trigger/CSCTriggerPrimitives/src/GEMCoPadProcessor.cc
Expand Up @@ -59,6 +59,10 @@ 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) {
// ignore 16-partition GE2/1 pads
if (id.isGE21() and p->nPartitions() == GEMPadDigi::GE21SplitStrip)
continue;

// only consider valid pads
if (!p->isValid())
continue;
Expand Down Expand Up @@ -99,6 +103,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) {
// ignore 16-partition GE2/1 pads
if (id.isGE21() and digiIt->nPartitions() == GEMPadDigiCluster::GE21SplitStrip)
continue;

// only consider valid clusters
if (!digiIt->isValid())
continue;
Expand Down
10 changes: 8 additions & 2 deletions L1Trigger/L1TGEM/plugins/GEMPadDigiClusterProducer.cc
Expand Up @@ -202,6 +202,9 @@ void GEMPadDigiClusterProducer::buildClusters(const GEMPadDigiCollection& det_pa
// check if the input pad is valid
checkValid(*d, part->id());

// number of eta partitions
unsigned nPart = d->nPartitions();

if (cl.empty()) {
cl.push_back((*d).pad());
} else {
Expand All @@ -211,7 +214,7 @@ 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, part->subsystem());
GEMPadDigiCluster pad_cluster(cl, startBX, part->subsystem(), nPart);

// check if the output cluster is valid
checkValid(pad_cluster, part->id());
Expand All @@ -228,7 +231,10 @@ 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, part->subsystem());
// number of eta partitions
unsigned nPart = (pads.first)->nPartitions();

GEMPadDigiCluster pad_cluster(cl, startBX, part->subsystem(), nPart);

// check if the output cluster is valid
checkValid(pad_cluster, part->id());
Expand Down
55 changes: 46 additions & 9 deletions L1Trigger/L1TGEM/plugins/GEMPadDigiProducer.cc
Expand Up @@ -50,7 +50,6 @@ class GEMPadDigiProducer : public edm::stream::EDProducer<> {

GEMPadDigiProducer::GEMPadDigiProducer(const edm::ParameterSet& ps) : geometry_(nullptr) {
digis_ = ps.getParameter<edm::InputTag>("InputCollection");
use16GE21_ = ps.getParameter<bool>("use16GE21");

digi_token_ = consumes<GEMDigiCollection>(digis_);
geom_token_ = esConsumes<GEMGeometry, MuonGeometryRecord, edm::Transition::BeginRun>();
Expand All @@ -64,15 +63,18 @@ GEMPadDigiProducer::~GEMPadDigiProducer() {}
void GEMPadDigiProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("InputCollection", edm::InputTag("simMuonGEMDigis"));
// GE2/1 geometry with 16 eta partitions
desc.add<bool>("use16GE21", false);

descriptions.add("simMuonGEMPadDigisDef", desc);
}

void GEMPadDigiProducer::beginRun(const edm::Run& run, const edm::EventSetup& eventSetup) {
edm::ESHandle<GEMGeometry> hGeom = eventSetup.getHandle(geom_token_);
geometry_ = &*hGeom;
// check the number of parititions
if (geometry_->hasGE21()) {
use16GE21_ = (geometry_->chamber(GEMDetId(1, 1, 2, 1, 1, 0))->nEtaPartitions() ==
GEMPadDigi::NumberPartitions::GE21SplitStrip);
}
}

void GEMPadDigiProducer::produce(edm::Event& e, const edm::EventSetup& eventSetup) {
Expand All @@ -92,39 +94,74 @@ void GEMPadDigiProducer::produce(edm::Event& e, const edm::EventSetup& eventSetu
}

void GEMPadDigiProducer::buildPads(const GEMDigiCollection& det_digis, GEMPadDigiCollection& out_pads) const {
// check that ME0 has 8-eta partitions
if (geometry_->hasME0()) {
if (geometry_->chamber(GEMDetId(1, 1, 0, 1, 1, 0))->nEtaPartitions() != GEMPadDigi::NumberPartitions::ME0) {
edm::LogError("GEMPadDigiProducer") << "ME0 geometry appears corrupted";
}
}

// check that GE1/1 has 8-eta partitions
if (geometry_->hasGE11()) {
if (geometry_->chamber(GEMDetId(1, 1, 1, 1, 1, 0))->nEtaPartitions() != GEMPadDigi::NumberPartitions::GE11) {
edm::LogError("GEMPadDigiProducer") << "GE1/1 geometry appears corrupted";
}
}

// check that GE2/1 has 8-eta partitions
if (geometry_->hasGE21()) {
if (geometry_->chamber(GEMDetId(1, 1, 2, 1, 1, 0))->nEtaPartitions() != GEMPadDigi::NumberPartitions::GE21) {
edm::LogError("GEMPadDigiProducer") << "GE2/1 geometry (8 partition) appears corrupted";
}
}

for (const auto& p : geometry_->etaPartitions()) {
// when using the GE2/1 geometry with 16 eta partitions
// ->ignore GE2/1
if (use16GE21_ and p->isGE21())
continue;

// set of <pad, bx> pairs, sorted first by pad then by bx
std::set<std::pair<int, int> > proto_pads;
// set of <pad, bx, part> pairs, sorted first by pad then by bx
std::set<std::tuple<int, int, unsigned> > proto_pads;

// walk over digis in this partition,
// 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) {
unsigned pad_num = static_cast<int>(p->padOfStrip(d->strip()));
unsigned pad_num = static_cast<unsigned>(p->padOfStrip(d->strip()));

auto nPart = GEMPadDigi::NumberPartitions::GE11;
if (p->isME0()) {
nPart = GEMPadDigi::NumberPartitions::ME0;
} else if (p->isGE21()) {
nPart = GEMPadDigi::NumberPartitions::GE21;
}
// 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());
proto_pads.emplace(pad_num, d->bx(), nPart);
}

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

void GEMPadDigiProducer::buildPads16GE21(const GEMDigiCollection& det_digis, GEMPadDigiCollection& out_pads) const {
// check that GE2/1 has 16-eta partitions
if (geometry_->hasGE21()) {
if (geometry_->chamber(GEMDetId(1, 1, 2, 1, 1, 0))->nEtaPartitions() !=
GEMPadDigi::NumberPartitions::GE21SplitStrip) {
edm::LogError("GEMPadDigiProducer") << "GE2/1 geometry (16 partition) appears corrupted";
}
}

for (const auto& p : geometry_->etaPartitions()) {
// when using the GE2/1 geometry with 16 eta partitions
// ->ignore GE1/1
Expand Down Expand Up @@ -158,7 +195,7 @@ 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, p->subsystem());
GEMPadDigi pad_digi(d.first, d.second, p->subsystem(), GEMPadDigi::NumberPartitions::GE21SplitStrip);
checkValid(pad_digi, p->id());
out_pads.insertDigi(p->id(), pad_digi);
}
Expand Down
Expand Up @@ -143,6 +143,10 @@ void GEMPadDigiClusterValidation::analyze(const edm::Event& event, const edm::Ev
ME3IdsKey key3(region_id, station_id, layer_id);

for (auto digi = range.first; digi != range.second; ++digi) {
// ignore 16-partition GE2/1 pads
if (gemid.isGE21() and digi->nPartitions() == GEMPadDigiCluster::GE21SplitStrip)
continue;

const auto& padsVec = digi->pads();
if (padsVec.empty()) {
edm::LogError(kLogCategory_) << "Pads missing for digi from GEM ID = " << gemid;
Expand Down
4 changes: 4 additions & 0 deletions Validation/MuonGEMDigis/plugins/GEMPadDigiValidation.cc
Expand Up @@ -144,6 +144,10 @@ void GEMPadDigiValidation::analyze(const edm::Event& event, const edm::EventSetu
ME3IdsKey key3(region_id, station_id, layer_id);

for (auto digi = range.first; digi != range.second; ++digi) {
// ignore 16-partition GE2/1 pads
if (gemid.isGE21() and digi->nPartitions() == GEMPadDigi::GE21SplitStrip)
continue;

Int_t pad = digi->pad();
Int_t bx = digi->bx();

Expand Down
8 changes: 8 additions & 0 deletions Validation/MuonGEMDigis/src/GEMDigiMatcher.cc
Expand Up @@ -165,6 +165,10 @@ void GEMDigiMatcher::matchPadsToSimTrack(const GEMPadDigiCollection& pads) {
const auto& pads_in_det = pads.get(p_id);

for (auto pad = pads_in_det.first; pad != pads_in_det.second; ++pad) {
// ignore 16-partition GE2/1 pads
if (p_id.isGE21() and pad->nPartitions() == GEMPadDigi::GE21SplitStrip)
continue;

// check that the pad BX is within the range
if (pad->bx() < minBXPad_ || pad->bx() > maxBXPad_)
continue;
Expand Down Expand Up @@ -197,6 +201,10 @@ void GEMDigiMatcher::matchClustersToSimTrack(const GEMPadDigiClusterCollection&
for (auto cluster = clusters_in_det.first; cluster != clusters_in_det.second; ++cluster) {
bool isMatched;

// ignore 16-partition GE2/1 pads
if (p_id.isGE21() and cluster->nPartitions() == GEMPadDigiCluster::GE21SplitStrip)
continue;

// check that the cluster BX is within the range
if (cluster->bx() < minBXCluster_ || cluster->bx() > maxBXCluster_)
continue;
Expand Down