CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
GEMPadDigiClusterProducer Class Reference

#include <GEMPadDigiClusterProducer.h>

Inheritance diagram for GEMPadDigiClusterProducer:
edm::stream::EDProducer<>

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
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Member Functions

void buildClusters (const GEMPadDigiCollection &pads, GEMPadDigiClusterCollection &out_clusters)
 

Private Attributes

const GEMGeometrygeometry_
 
unsigned int maxClusters_
 
unsigned int maxClusterSize_
 
edm::EDGetTokenT< GEMPadDigiCollectionpad_token_
 Name of input digi Collection. More...
 
edm::InputTag pads_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 26 of file GEMPadDigiClusterProducer.h.

Constructor & Destructor Documentation

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

Definition at line 14 of file GEMPadDigiClusterProducer.cc.

References edm::ParameterSet::getParameter(), maxClusters_, maxClusterSize_, pad_token_, and pads_.

15 : geometry_(nullptr)
16 {
17  pads_ = ps.getParameter<edm::InputTag>("InputCollection");
18  maxClusters_ = ps.getParameter<unsigned int>("maxClusters");
19  maxClusterSize_ = ps.getParameter<unsigned int>("maxClusterSize");
20 
21  pad_token_ = consumes<GEMPadDigiCollection>(pads_);
22 
23  produces<GEMPadDigiClusterCollection>();
24  consumes<GEMPadDigiCollection>(pads_);
25 }
T getParameter(std::string const &) const
edm::EDGetTokenT< GEMPadDigiCollection > pad_token_
Name of input digi Collection.
GEMPadDigiClusterProducer::~GEMPadDigiClusterProducer ( )
override

Definition at line 28 of file GEMPadDigiClusterProducer.cc.

29 {}

Member Function Documentation

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

Definition at line 32 of file GEMPadDigiClusterProducer.cc.

References geometry_, and edm::EventSetup::get().

33 {
35  eventSetup.get<MuonGeometryRecord>().get(hGeom);
36  geometry_ = &*hGeom;
37 }
T get() const
Definition: EventSetup.h:68
void GEMPadDigiClusterProducer::buildClusters ( const GEMPadDigiCollection pads,
GEMPadDigiClusterCollection out_clusters 
)
private

Definition at line 56 of file GEMPadDigiClusterProducer.cc.

References GEMGeometry::chambers(), GetRecoTauVFromDQM_MC_cff::cl, edmIntegrityCheck::d, plotBeamSpotDB::first, geometry_, mps_fire::i, maxClusters_, maxClusterSize_, min(), and edm::second().

Referenced by produce().

58 {
59  // construct clusters
60  for (const auto& ch: geometry_->chambers()) {
61 
62  // proto collection
63  std::vector<std::pair<GEMDetId, GEMPadDigiCluster> > proto_clusters;
64 
65  for (const auto& part: ch->etaPartitions()) {
66  auto pads = det_pads.get(part->id());
67  std::vector<uint16_t> cl;
68  int startBX = 99;
69  for (auto d = pads.first; d != pads.second; ++d) {
70  if (cl.empty()) {
71  cl.push_back((*d).pad());
72  }
73  else {
74  if ((*d).bx() == startBX and // same bunch crossing
75  (*d).pad() == cl.back() + 1 // pad difference is 1
76  and cl.size()<maxClusterSize_) { // max 8 in cluster
77  cl.push_back((*d).pad());
78  }
79  else {
80  // put the current cluster in the proto collection
81  GEMPadDigiCluster pad_cluster(cl, startBX);
82  proto_clusters.emplace_back(part->id(), pad_cluster);
83 
84  // start a new cluster
85  cl.clear();
86  cl.push_back((*d).pad());
87  }
88  }
89  startBX = (*d).bx();
90  }
91  // put the last cluster in the proto collection
92  if (pads.first != pads.second){
93  GEMPadDigiCluster pad_cluster(cl, startBX);
94  proto_clusters.emplace_back(part->id(), pad_cluster);
95  }
96  } // end of partition loop
97 
98  // cluster selection: pick first maxClusters_ for now
99  unsigned loopMax=std::min(maxClusters_,unsigned(proto_clusters.size()));
100  for ( unsigned int i=0; i<loopMax; i++) {
101  const auto& detid(proto_clusters[i].first);
102  const auto& cluster(proto_clusters[i].second);
103  out_clusters.insertDigi(detid, cluster);
104  }
105  } // end of chamber loop
106 }
U second(std::pair< T, U > const &p)
T min(T a, T b)
Definition: MathUtil.h:58
part
Definition: HCALResponse.h:20
const std::vector< const GEMChamber * > & chambers() const
Return a vector of all GEM chambers.
Definition: GEMGeometry.cc:59
void GEMPadDigiClusterProducer::produce ( edm::Event e,
const edm::EventSetup eventSetup 
)
override

Definition at line 40 of file GEMPadDigiClusterProducer.cc.

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

41 {
43  e.getByToken(pad_token_, hpads);
44 
45  // Create empty output
46  std::unique_ptr<GEMPadDigiClusterCollection> pClusters(new GEMPadDigiClusterCollection());
47 
48  // build the clusters
49  buildClusters(*(hpads.product()), *pClusters);
50 
51  // store them in the event
52  e.put(std::move(pClusters));
53 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
MuonDigiCollection< GEMDetId, GEMPadDigiCluster > GEMPadDigiClusterCollection
void buildClusters(const GEMPadDigiCollection &pads, GEMPadDigiClusterCollection &out_clusters)
T const * product() const
Definition: Handle.h:81
edm::EDGetTokenT< GEMPadDigiCollection > pad_token_
Name of input digi Collection.
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

const GEMGeometry* GEMPadDigiClusterProducer::geometry_
private

Definition at line 49 of file GEMPadDigiClusterProducer.h.

Referenced by beginRun(), and buildClusters().

unsigned int GEMPadDigiClusterProducer::maxClusters_
private

Definition at line 46 of file GEMPadDigiClusterProducer.h.

Referenced by buildClusters(), and GEMPadDigiClusterProducer().

unsigned int GEMPadDigiClusterProducer::maxClusterSize_
private

Definition at line 47 of file GEMPadDigiClusterProducer.h.

Referenced by buildClusters(), and GEMPadDigiClusterProducer().

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

Name of input digi Collection.

Definition at line 43 of file GEMPadDigiClusterProducer.h.

Referenced by GEMPadDigiClusterProducer(), and produce().

edm::InputTag GEMPadDigiClusterProducer::pads_
private

Definition at line 44 of file GEMPadDigiClusterProducer.h.

Referenced by GEMPadDigiClusterProducer().