CMS 3D CMS Logo

ME0PadDigiClusterProducer.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<ME0PadDigiCollection>(pads_);
22 
23  produces<ME0PadDigiClusterCollection>();
24  consumes<ME0PadDigiCollection>(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<ME0PadDigiClusterCollection> pClusters(new ME0PadDigiClusterCollection());
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 (const auto& ch: geometry_->chambers()) {
59  for (const auto& part: ch->etaPartitions()) {
60  auto pads = det_pads.get(part->id());
61  std::vector<uint16_t> cl;
62  int startBX = 99;
63  for (auto d = pads.first; d != pads.second; ++d) {
64  if (cl.empty()) {
65  cl.push_back((*d).pad());
66  }
67  else {
68  if ((*d).bx() == startBX and (*d).pad() == cl.back() + 1) {
69  cl.push_back((*d).pad());
70  }
71  else {
72  ME0PadDigiCluster pad_cluster(cl, startBX);
73  out_clusters.insertDigi(part->id(), pad_cluster);
74  cl.clear();
75  cl.push_back((*d).pad());
76  }
77  }
78  startBX = (*d).bx();
79  }
80  if (pads.first != pads.second){
81  ME0PadDigiCluster pad_cluster(cl, startBX);
82  out_clusters.insertDigi(part->id(), pad_cluster);
83  }
84  }
85  }
86 }
T getParameter(std::string const &) const
virtual void produce(edm::Event &, const edm::EventSetup &) override
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:460
#define nullptr
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
const std::vector< const ME0Chamber * > & chambers() const
Return a vector of all ME0 chambers.
Definition: ME0Geometry.cc:49
void buildClusters(const ME0PadDigiCollection &pads, ME0PadDigiClusterCollection &out_clusters)
T const * product() const
Definition: Handle.h:81
part
Definition: HCALResponse.h:20
const T & get() const
Definition: EventSetup.h:56
ME0PadDigiClusterProducer(const edm::ParameterSet &ps)
edm::EDGetTokenT< ME0PadDigiCollection > pad_token_
Name of input digi Collection.
MuonDigiCollection< ME0DetId, ME0PadDigiCluster > ME0PadDigiClusterCollection
def move(src, dest)
Definition: eostools.py:510
Definition: Run.h:42