Skip to content

Commit

Permalink
Merge pull request #19986 from dildick/from-CMSSW_9_3_X_2017-07-31-23…
Browse files Browse the repository at this point in the history
…00-gem-me0-clustersize-maxclusters

Restrict GEM/ME0 cluster size and max N clusters
  • Loading branch information
cmsbuild committed Sep 1, 2017
2 parents c8e3461 + 8b83ddb commit a9c9ffa
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 22 deletions.
33 changes: 25 additions & 8 deletions SimMuon/GEMDigitizer/src/GEMPadDigiClusterProducer.cc
Expand Up @@ -53,10 +53,15 @@ void GEMPadDigiClusterProducer::produce(edm::Event& e, const edm::EventSetup& ev
}


void GEMPadDigiClusterProducer::buildClusters(const GEMPadDigiCollection &det_pads, GEMPadDigiClusterCollection &out_clusters)
void GEMPadDigiClusterProducer::buildClusters(const GEMPadDigiCollection &det_pads,
GEMPadDigiClusterCollection &out_clusters)
{
// construct clusters
for (const auto& ch: geometry_->chambers()) {
unsigned int nClusters = 0;

// proto collection
std::vector<std::pair<GEMDetId, GEMPadDigiCluster> > proto_clusters;

for (const auto& part: ch->etaPartitions()) {
auto pads = det_pads.get(part->id());
std::vector<uint16_t> cl;
Expand All @@ -66,24 +71,36 @@ void GEMPadDigiClusterProducer::buildClusters(const GEMPadDigiCollection &det_pa
cl.push_back((*d).pad());
}
else {
if ((*d).bx() == startBX and (*d).pad() == cl.back() + 1) {
if ((*d).bx() == startBX and // same bunch crossing
(*d).pad() == cl.back() + 1 // pad difference is 1
and cl.size()<maxClusterSize_) { // max 8 in cluster
cl.push_back((*d).pad());
}
else {
// put the current cluster in the proto collection
GEMPadDigiCluster pad_cluster(cl, startBX);
out_clusters.insertDigi(part->id(), pad_cluster);
proto_clusters.emplace_back(part->id(), pad_cluster);

// start a new cluster
cl.clear();
cl.push_back((*d).pad());
nClusters++;
}
}
startBX = (*d).bx();
}
// put the last cluster in the proto collection
if (pads.first != pads.second){
GEMPadDigiCluster pad_cluster(cl, startBX);
out_clusters.insertDigi(part->id(), pad_cluster);
nClusters++;
proto_clusters.emplace_back(part->id(), pad_cluster);
}
} // end of partition loop

// cluster selection: pick first maxClusters_ for now
unsigned loopMax=std::min(maxClusters_,unsigned(proto_clusters.size()));
for ( unsigned int i=0; i<loopMax; i++) {
const auto& detid(proto_clusters[i].first);
const auto& cluster(proto_clusters[i].second);
out_clusters.insertDigi(detid, cluster);
}
}
} // end of chamber loop
}
11 changes: 5 additions & 6 deletions SimMuon/GEMDigitizer/src/GEMPadDigiProducer.cc
Expand Up @@ -52,24 +52,23 @@ void GEMPadDigiProducer::produce(edm::Event& e, const edm::EventSetup& eventSetu

void GEMPadDigiProducer::buildPads(const GEMDigiCollection &det_digis, GEMPadDigiCollection &out_pads) const
{
auto etaPartitions = geometry_->etaPartitions();
for(const auto& p: etaPartitions)
for(const auto& p: geometry_->etaPartitions())
{
// set of <pad, bx> pairs, sorted first by pad then by bx
std::set<std::pair<int, int> > proto_pads;
// walk over digis in this partition,

// 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)
{
int pad_num = 1 + static_cast<int>( p->padOfStrip(d->strip()) );
proto_pads.emplace(pad_num, d->bx());
}

// in the future, do some dead-time handling
// emulateDeadTime(proto_pads)

// fill the output collections
for (const auto& d: proto_pads)
{
Expand Down
32 changes: 26 additions & 6 deletions SimMuon/GEMDigitizer/src/ME0PadDigiClusterProducer.cc
Expand Up @@ -53,9 +53,15 @@ void ME0PadDigiClusterProducer::produce(edm::Event& e, const edm::EventSetup& ev
}


void ME0PadDigiClusterProducer::buildClusters(const ME0PadDigiCollection &det_pads, ME0PadDigiClusterCollection &out_clusters)
void ME0PadDigiClusterProducer::buildClusters(const ME0PadDigiCollection &det_pads,
ME0PadDigiClusterCollection &out_clusters)
{
for (const auto& ch: geometry_->chambers()) {
// construct clusters
for (const auto& ch: geometry_->layers()) {

// proto collection
std::vector<std::pair<ME0DetId, ME0PadDigiCluster> > proto_clusters;

for (const auto& part: ch->etaPartitions()) {
auto pads = det_pads.get(part->id());
std::vector<uint16_t> cl;
Expand All @@ -65,22 +71,36 @@ void ME0PadDigiClusterProducer::buildClusters(const ME0PadDigiCollection &det_pa
cl.push_back((*d).pad());
}
else {
if ((*d).bx() == startBX and (*d).pad() == cl.back() + 1) {
if ((*d).bx() == startBX and // same bunch crossing
(*d).pad() == cl.back() + 1 // pad difference is 1
and cl.size()<maxClusterSize_) { // max 8 in cluster
cl.push_back((*d).pad());
}
else {
// put the current cluster in the proto collection
ME0PadDigiCluster pad_cluster(cl, startBX);
out_clusters.insertDigi(part->id(), pad_cluster);
proto_clusters.emplace_back(part->id(), pad_cluster);

// start a new cluster
cl.clear();
cl.push_back((*d).pad());
}
}
startBX = (*d).bx();
}
// put the last cluster in the proto collection
if (pads.first != pads.second){
ME0PadDigiCluster pad_cluster(cl, startBX);
out_clusters.insertDigi(part->id(), pad_cluster);
proto_clusters.emplace_back(part->id(), pad_cluster);
}
} // end of partition loop

// cluster selection: pick first maxClusters_ for now
unsigned loopMax=std::min(maxClusters_,unsigned(proto_clusters.size()));
for ( unsigned int i=0; i<loopMax; i++) {
const auto& detid(proto_clusters[i].first);
const auto& cluster(proto_clusters[i].second);
out_clusters.insertDigi(detid, cluster);
}
}
} // end of chamber loop
}
3 changes: 1 addition & 2 deletions SimMuon/GEMDigitizer/src/ME0PadDigiProducer.cc
Expand Up @@ -51,8 +51,7 @@ void ME0PadDigiProducer::produce(edm::Event& e, const edm::EventSetup& eventSetu

void ME0PadDigiProducer::buildPads(const ME0DigiCollection &det_digis, ME0PadDigiCollection &out_pads) const
{
auto etaPartitions = geometry_->etaPartitions();
for(const auto& p: etaPartitions)
for(const auto& p: geometry_->etaPartitions())
{
// set of <pad, bx> pairs, sorted first by pad then by bx
std::set<std::pair<int, int> > proto_pads;
Expand Down

0 comments on commit a9c9ffa

Please sign in to comment.