CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
GEMPadDigiClusterProducer Class Reference
Inheritance diagram for GEMPadDigiClusterProducer:
edm::stream::EDProducer<>

Public Types

typedef std::map< GEMDetId,
GEMPadDigiClusters
GEMPadDigiClusterContainer
 
typedef std::vector
< GEMPadDigiCluster
GEMPadDigiClusters
 
typedef std::map< GEMDetId,
std::vector< std::vector
< std::pair< GEMDetId,
GEMPadDigiClusters > > > > 
GEMPadDigiClusterSortedContainer
 
- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Public Member Functions

void beginRun (const edm::Run &, const edm::EventSetup &) override
 
 GEMPadDigiClusterProducer (const edm::ParameterSet &ps)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~GEMPadDigiClusterProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void buildClusters (const GEMPadDigiCollection &pads, GEMPadDigiClusterContainer &out_clusters) const
 
template<class T >
void checkValid (const T &cluster, const GEMDetId &id) const
 
void selectClusters (const GEMPadDigiClusterSortedContainer &in, GEMPadDigiClusterCollection &out) const
 
void sortClusters (const GEMPadDigiClusterContainer &in_clusters, GEMPadDigiClusterSortedContainer &out_clusters) const
 

Private Attributes

edm::ESGetToken< GEMGeometry,
MuonGeometryRecord
geom_token_
 
const GEMGeometrygeometry_
 
unsigned int maxClusterSize_
 
unsigned int maxClustersOHGE11_
 
unsigned int maxClustersOHGE21_
 
unsigned int nOHGE11_
 
unsigned int nOHGE21_
 
edm::EDGetTokenT
< GEMPadDigiCollection
pad_token_
 Name of input digi Collection. More...
 
edm::InputTag pads_
 
bool sendOverflowClusters_
 

Detailed Description

Produces GEM pad clusters from at most 8 adjacent GEM pads. Clusters are used downstream in the CSC local trigger to build GEM-CSC triggers and in the muon trigger to build EMTF tracks

Based on documentation provided by the GEM firmware architects

Author
Sven Dildick (TAMU)

Definition at line 39 of file GEMPadDigiClusterProducer.cc.

Member Typedef Documentation

Definition at line 43 of file GEMPadDigiClusterProducer.cc.

Definition at line 42 of file GEMPadDigiClusterProducer.cc.

typedef std::map<GEMDetId, std::vector<std::vector<std::pair<GEMDetId, GEMPadDigiClusters> > > > GEMPadDigiClusterProducer::GEMPadDigiClusterSortedContainer

Definition at line 47 of file GEMPadDigiClusterProducer.cc.

Constructor & Destructor Documentation

GEMPadDigiClusterProducer::GEMPadDigiClusterProducer ( const edm::ParameterSet ps)
explicit

Definition at line 120 of file GEMPadDigiClusterProducer.cc.

References geom_token_, edm::ParameterSet::getParameter(), maxClusterSize_, maxClustersOHGE11_, maxClustersOHGE21_, nOHGE11_, nOHGE21_, pad_token_, pads_, and sendOverflowClusters_.

120  : geometry_(nullptr) {
121  pads_ = ps.getParameter<edm::InputTag>("InputCollection");
122  maxClustersOHGE11_ = ps.getParameter<unsigned int>("maxClustersOHGE11");
123  maxClustersOHGE21_ = ps.getParameter<unsigned int>("maxClustersOHGE21");
124  nOHGE11_ = ps.getParameter<unsigned int>("nOHGE11");
125  nOHGE21_ = ps.getParameter<unsigned int>("nOHGE21");
126  maxClusterSize_ = ps.getParameter<unsigned int>("maxClusterSize");
127  sendOverflowClusters_ = ps.getParameter<bool>("sendOverflowClusters");
128 
129  if (sendOverflowClusters_) {
130  maxClustersOHGE11_ *= 2;
131  maxClustersOHGE21_ *= 2;
132  }
133 
134  pad_token_ = consumes<GEMPadDigiCollection>(pads_);
135  geom_token_ = esConsumes<GEMGeometry, MuonGeometryRecord, edm::Transition::BeginRun>();
136 
137  produces<GEMPadDigiClusterCollection>();
138  consumes<GEMPadDigiCollection>(pads_);
139 }
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > geom_token_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< GEMPadDigiCollection > pad_token_
Name of input digi Collection.
GEMPadDigiClusterProducer::~GEMPadDigiClusterProducer ( )
override

Definition at line 141 of file GEMPadDigiClusterProducer.cc.

141 {}

Member Function Documentation

void GEMPadDigiClusterProducer::beginRun ( const edm::Run run,
const edm::EventSetup eventSetup 
)
override

Definition at line 156 of file GEMPadDigiClusterProducer.cc.

References geom_token_, geometry_, and edm::EventSetup::getHandle().

156  {
158  geometry_ = &*hGeom;
159 }
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > geom_token_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:157
void GEMPadDigiClusterProducer::buildClusters ( const GEMPadDigiCollection pads,
GEMPadDigiClusterContainer out_clusters 
) const
private

Light Cluster Packing Algorithm **

Based on: https://github.com/cms-gem-daq-project/OptoHybridv3/raw/master/doc/OH_modules.docx (Andrew Peck, Thomas Lenzi, Evaldas Juska)

In the current version of the algorithm, cluster finding is segmented into two separate halves of the GE1/1 chambers. Thus, each one of the trigger fibers can transmit clusters only from the half of the chamber that it corresponds to. For GE2/1, there are four separate quarts of the GE2/1 chamber.

This has the downside of being unable to transmit more than 4 clusters when they occur within that side of the chamber, so there will be a slightly higher rate of cluster overflow. For GE2/1 each OH can transmit up to 5 clusters.

The benefit, however, is in terms of (1) latency and (2) resource usage.

The burden of finding clusters on of the chamber is significantly less, and allows the cluster packer to operate in a simple, pipelined architecture which returns up to 4 (or 5) clusters per half-chamber per bunch crossing.

This faster architecture allows the mechanism to operate with only a single copy of the cluster finding priority encoder and cluster truncator (instead of two multiplexed copies), so the total resource usage of these stages is approximately half.

Further, a second step of cluster merging that is required in the full algorithm is avoided, which reduces latency by an additional bunch crossing and significantly reduces resource usage as well.

The sorting of the clusters favors lower eta partitions and lower pad numbers

Definition at line 183 of file GEMPadDigiClusterProducer.cc.

References checkValid(), haddnano::cl, ztail::d, GEMGeometry::etaPartitions(), geometry_, maxClusterSize_, and nPart().

Referenced by produce().

184  {
185  // clear the container
186  proto_clusters.clear();
187 
188  // construct clusters
189  for (const auto& part : geometry_->etaPartitions()) {
190  // clusters are not build for ME0
191  // -> ignore hits from station 0
192  if (part->isME0())
193  continue;
194 
195  GEMPadDigiClusters all_pad_clusters;
196 
197  auto pads = det_pads.get(part->id());
198  std::vector<uint16_t> cl;
199  int startBX = 99;
200 
201  for (auto d = pads.first; d != pads.second; ++d) {
202  // check if the input pad is valid
203  checkValid(*d, part->id());
204 
205  // number of eta partitions
206  unsigned nPart = d->nPartitions();
207 
208  if (cl.empty()) {
209  cl.push_back((*d).pad());
210  } else {
211  if ((*d).bx() == startBX and // same bunch crossing
212  (*d).pad() == cl.back() + 1 // pad difference is 1
213  and cl.size() < maxClusterSize_) { // max 8 in cluster
214  cl.push_back((*d).pad());
215  } else {
216  // put the current cluster in the proto collection
217  GEMPadDigiCluster pad_cluster(cl, startBX, part->subsystem(), nPart);
218 
219  // check if the output cluster is valid
220  checkValid(pad_cluster, part->id());
221 
222  all_pad_clusters.emplace_back(pad_cluster);
223 
224  // start a new cluster
225  cl.clear();
226  cl.push_back((*d).pad());
227  }
228  }
229  startBX = (*d).bx();
230  }
231 
232  // put the last cluster in the proto collection
233  if (pads.first != pads.second) {
234  // number of eta partitions
235  unsigned nPart = (pads.first)->nPartitions();
236 
237  GEMPadDigiCluster pad_cluster(cl, startBX, part->subsystem(), nPart);
238 
239  // check if the output cluster is valid
240  checkValid(pad_cluster, part->id());
241 
242  all_pad_clusters.emplace_back(pad_cluster);
243  }
244  proto_clusters.emplace(part->id(), all_pad_clusters);
245 
246  } // end of partition loop
247 }
tuple cl
Definition: haddnano.py:49
tuple d
Definition: ztail.py:151
const std::vector< const GEMEtaPartition * > & etaPartitions() const
Return a vector of all GEM eta partitions.
Definition: GEMGeometry.cc:40
TString nPart(Int_t part, TString string, TString delimit=";", Bool_t removerest=true)
part
Definition: HCALResponse.h:20
void checkValid(const T &cluster, const GEMDetId &id) const
std::vector< GEMPadDigiCluster > GEMPadDigiClusters
template<class T >
void GEMPadDigiClusterProducer::checkValid ( const T cluster,
const GEMDetId id 
) const
private

Definition at line 315 of file GEMPadDigiClusterProducer.cc.

References gpuClustering::id.

Referenced by buildClusters(), and selectClusters().

315  {
316  // check if the pad/cluster is valid
317  // in principle, invalid pads/clusters can appear in the CMS raw data
318  if (!tp.isValid()) {
319  edm::LogWarning("GEMPadDigiClusterProducer") << "Invalid " << tp << " in " << id;
320  }
321 }
uint16_t *__restrict__ id
Log< level::Warning, false > LogWarning
void GEMPadDigiClusterProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 143 of file GEMPadDigiClusterProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), submitPVResolutionJobs::desc, and HLT_FULL_cff::InputTag.

143  {
145  desc.add<edm::InputTag>("InputCollection", edm::InputTag("simMuonGEMPadDigis"));
146  desc.add<unsigned int>("maxClustersOHGE11", 4);
147  desc.add<unsigned int>("maxClustersOHGE21", 5);
148  desc.add<unsigned int>("nOHGE11", 2);
149  desc.add<unsigned int>("nOHGE21", 4);
150  desc.add<unsigned int>("maxClusterSize", 8);
151  desc.add<bool>("sendOverflowClusters", false);
152 
153  descriptions.add("simMuonGEMPadDigiClustersDef", desc);
154 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void GEMPadDigiClusterProducer::produce ( edm::Event e,
const edm::EventSetup eventSetup 
)
override

Definition at line 161 of file GEMPadDigiClusterProducer.cc.

References buildClusters(), edm::Event::getByToken(), eostools::move(), pad_token_, edm::Handle< T >::product(), edm::Event::put(), selectClusters(), and sortClusters().

161  {
163  e.getByToken(pad_token_, hpads);
164 
165  // Create empty output
166  std::unique_ptr<GEMPadDigiClusterCollection> pClusters(new GEMPadDigiClusterCollection());
167 
168  // build the proto clusters (per partition)
169  GEMPadDigiClusterContainer proto_clusters;
170  buildClusters(*(hpads.product()), proto_clusters);
171 
172  // // sort clusters per chamber, per OH, per partition number and per pad number
173  GEMPadDigiClusterSortedContainer sorted_clusters;
174  sortClusters(proto_clusters, sorted_clusters);
175 
176  // select the clusters from sorted clusters
177  selectClusters(sorted_clusters, *pClusters);
178 
179  // store them in the event
180  e.put(std::move(pClusters));
181 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
void sortClusters(const GEMPadDigiClusterContainer &in_clusters, GEMPadDigiClusterSortedContainer &out_clusters) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
std::map< GEMDetId, std::vector< std::vector< std::pair< GEMDetId, GEMPadDigiClusters > > > > GEMPadDigiClusterSortedContainer
MuonDigiCollection< GEMDetId, GEMPadDigiCluster > GEMPadDigiClusterCollection
std::vector< GEMPadDigiCluster > GEMPadDigiClusterContainer
def move
Definition: eostools.py:511
T const * product() const
Definition: Handle.h:70
void buildClusters(const GEMPadDigiCollection &pads, GEMPadDigiClusterContainer &out_clusters) const
void selectClusters(const GEMPadDigiClusterSortedContainer &in, GEMPadDigiClusterCollection &out) const
edm::EDGetTokenT< GEMPadDigiCollection > pad_token_
Name of input digi Collection.
void GEMPadDigiClusterProducer::selectClusters ( const GEMPadDigiClusterSortedContainer in,
GEMPadDigiClusterCollection out 
) const
private

Definition at line 283 of file GEMPadDigiClusterProducer.cc.

References GEMGeometry::chambers(), checkValid(), HLT_FULL_cff::clusters, geometry_, maxClustersOHGE11_, and maxClustersOHGE21_.

Referenced by produce().

284  {
285  // loop over chambers
286  for (const auto& ch : geometry_->chambers()) {
287  const unsigned maxClustersOH = ch->id().isGE11() ? maxClustersOHGE11_ : maxClustersOHGE21_;
288 
289  // loop over the optohybrids
290  for (const auto& optohybrid : sorted_clusters.at(ch->id())) {
291  // at most maxClustersOH per OH!
292  unsigned nClusters = 0;
293 
294  // loop over the eta partitions for this OH
295  for (const auto& etapart : optohybrid) {
296  const auto& detid(etapart.first);
297  const auto& clusters(etapart.second);
298 
299  // pick the clusters with lowest pad number
300  for (const auto& clus : clusters) {
301  if (nClusters < maxClustersOH) {
302  // check if the output cluster is valid
303  checkValid(clus, detid);
304 
305  out_clusters.insertDigi(detid, clus);
306  nClusters++;
307  }
308  } // end of cluster loop
309  } // end of eta partition loop
310  } // end of OH loop
311  } // end of chamber loop
312 }
const std::vector< const GEMChamber * > & chambers() const
Return a vector of all GEM chambers.
Definition: GEMGeometry.cc:38
void checkValid(const T &cluster, const GEMDetId &id) const
void GEMPadDigiClusterProducer::sortClusters ( const GEMPadDigiClusterContainer in_clusters,
GEMPadDigiClusterSortedContainer out_clusters 
) const
private

Definition at line 249 of file GEMPadDigiClusterProducer.cc.

References GEMGeometry::chambers(), geometry_, nOHGE11_, and nOHGE21_.

Referenced by produce().

250  {
251  // The sorting of the clusters favors lower eta partitions and lower pad numbers
252  // By default the eta partitions are sorted by Id
253 
254  sorted_clusters.clear();
255 
256  for (const auto& ch : geometry_->chambers()) {
257  // check the station number
258  const unsigned nOH = ch->id().isGE11() ? nOHGE11_ : nOHGE21_;
259  const unsigned nPartOH = ch->nEtaPartitions() / nOH;
260 
261  std::vector<std::vector<std::pair<GEMDetId, GEMPadDigiClusters> > > temp_clustersCH;
262 
263  for (unsigned int iOH = 0; iOH < nOH; iOH++) {
264  // all clusters for a set of eta partitions
265  std::vector<std::pair<GEMDetId, GEMPadDigiClusters> > temp_clustersOH;
266 
267  // loop over the 4 or 2 eta partitions for this optohybrid
268  for (unsigned iPart = 1; iPart <= nPartOH; iPart++) {
269  // get the clusters for this eta partition
270  const GEMDetId& partId = ch->etaPartition(iPart + iOH * nPartOH)->id();
271  if (proto_clusters.find(partId) != proto_clusters.end()) {
272  temp_clustersOH.emplace_back(partId, proto_clusters.at(partId));
273  }
274  } // end of eta partition loop
275 
276  temp_clustersCH.emplace_back(temp_clustersOH);
277  } // end of OH loop
278 
279  sorted_clusters.emplace(ch->id(), temp_clustersCH);
280  } // end of chamber loop
281 }
const std::vector< const GEMChamber * > & chambers() const
Return a vector of all GEM chambers.
Definition: GEMGeometry.cc:38

Member Data Documentation

edm::ESGetToken<GEMGeometry, MuonGeometryRecord> GEMPadDigiClusterProducer::geom_token_
private

Definition at line 107 of file GEMPadDigiClusterProducer.cc.

Referenced by beginRun(), and GEMPadDigiClusterProducer().

const GEMGeometry* GEMPadDigiClusterProducer::geometry_
private
unsigned int GEMPadDigiClusterProducer::maxClusterSize_
private

Definition at line 114 of file GEMPadDigiClusterProducer.cc.

Referenced by buildClusters(), and GEMPadDigiClusterProducer().

unsigned int GEMPadDigiClusterProducer::maxClustersOHGE11_
private

Definition at line 110 of file GEMPadDigiClusterProducer.cc.

Referenced by GEMPadDigiClusterProducer(), and selectClusters().

unsigned int GEMPadDigiClusterProducer::maxClustersOHGE21_
private

Definition at line 111 of file GEMPadDigiClusterProducer.cc.

Referenced by GEMPadDigiClusterProducer(), and selectClusters().

unsigned int GEMPadDigiClusterProducer::nOHGE11_
private

Definition at line 112 of file GEMPadDigiClusterProducer.cc.

Referenced by GEMPadDigiClusterProducer(), and sortClusters().

unsigned int GEMPadDigiClusterProducer::nOHGE21_
private

Definition at line 113 of file GEMPadDigiClusterProducer.cc.

Referenced by GEMPadDigiClusterProducer(), and sortClusters().

edm::EDGetTokenT<GEMPadDigiCollection> GEMPadDigiClusterProducer::pad_token_
private

Name of input digi Collection.

Definition at line 106 of file GEMPadDigiClusterProducer.cc.

Referenced by GEMPadDigiClusterProducer(), and produce().

edm::InputTag GEMPadDigiClusterProducer::pads_
private

Definition at line 108 of file GEMPadDigiClusterProducer.cc.

Referenced by GEMPadDigiClusterProducer().

bool GEMPadDigiClusterProducer::sendOverflowClusters_
private

Definition at line 115 of file GEMPadDigiClusterProducer.cc.

Referenced by GEMPadDigiClusterProducer().