CMS 3D CMS Logo

GEMPadDigiClusterProducer.cc
Go to the documentation of this file.
8 
9 #include <string>
10 #include <map>
11 #include <vector>
12 
13 
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 }
26 
27 
29 {}
30 
31 
33 {
35  eventSetup.get<MuonGeometryRecord>().get(hGeom);
36  geometry_ = &*hGeom;
37 }
38 
39 
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 }
54 
55 
57 {
58  for (auto ch: geometry_->chambers()) {
59  unsigned int nClusters = 0;
60  for (auto part: ch->etaPartitions()) {
61  auto pads = det_pads.get(part->id());
62  std::vector<uint16_t> cl;
63  int startBX = 99;
64  for (auto d = pads.first; d != pads.second; ++d) {
65  if (cl.size() == 0) {
66  cl.push_back((*d).pad());
67  }
68  else {
69  if ((*d).bx() == startBX and (*d).pad() == cl.back() + 1) {
70  cl.push_back((*d).pad());
71  }
72  else {
73  GEMPadDigiCluster pad_cluster(cl, startBX);
74  out_clusters.insertDigi(part->id(), pad_cluster);
75  cl.clear();
76  cl.push_back((*d).pad());
77  nClusters++;
78  }
79  }
80  startBX = (*d).bx();
81  }
82  if (pads.first != pads.second){
83  GEMPadDigiCluster pad_cluster(cl, startBX);
84  out_clusters.insertDigi(part->id(), pad_cluster);
85  nClusters++;
86  }
87  }
88  }
89 }
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
virtual void produce(edm::Event &, const edm::EventSetup &) override
#define nullptr
GEMPadDigiClusterProducer(const edm::ParameterSet &ps)
MuonDigiCollection< GEMDetId, GEMPadDigiCluster > GEMPadDigiClusterCollection
void buildClusters(const GEMPadDigiCollection &pads, GEMPadDigiClusterCollection &out_clusters)
T const * product() const
Definition: Handle.h:81
part
Definition: HCALResponse.h:20
const T & get() const
Definition: EventSetup.h:56
const std::vector< const GEMChamber * > & chambers() const
Return a vector of all GEM chambers.
Definition: GEMGeometry.cc:59
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
edm::EDGetTokenT< GEMPadDigiCollection > pad_token_
Name of input digi Collection.
def move(src, dest)
Definition: eostools.py:510
Definition: Run.h:42