CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GEMPadDigiProducer.cc
Go to the documentation of this file.
2 
10 
11 #include <string>
12 #include <map>
13 #include <vector>
14 
15 
17 : geometry_(nullptr)
18 {
19  digis_ = ps.getParameter<edm::InputTag>("InputCollection");
20 
21  digi_token_ = consumes<GEMDigiCollection>(digis_);
22 
23  produces<GEMPadDigiCollection>();
24  consumes<GEMDigiCollection>(digis_);
25 }
26 
27 
29 {}
30 
31 
33 {
35  eventSetup.get<MuonGeometryRecord>().get(hGeom);
36  geometry_ = &*hGeom;
37 }
38 
39 
41 {
43  e.getByToken(digi_token_, hdigis);
44 
45  // Create empty output
46  std::auto_ptr<GEMPadDigiCollection> pPads(new GEMPadDigiCollection());
47 
48  // build the pads
49  buildPads(*(hdigis.product()), *pPads);
50 
51  // store them in the event
52  e.put(pPads);
53 }
54 
55 
57 {
58  auto etaPartitions = geometry_->etaPartitions();
59  for(auto p: etaPartitions)
60  {
61  // set of <pad, bx> pairs, sorted first by pad then by bx
62  std::set<std::pair<int, int> > proto_pads;
63 
64  // walk over digis in this partition,
65  // and stuff them into a set of unique pads (equivalent of OR operation)
66  auto digis = det_digis.get(p->id());
67  for (auto d = digis.first; d != digis.second; ++d)
68  {
69  int pad_num = 1 + static_cast<int>( p->padOfStrip(d->strip()) );
70  auto pad = std::make_pair(pad_num, d->bx());
71  proto_pads.insert(pad);
72  }
73 
74  // in the future, do some dead-time handling
75  // emulateDeadTime(proto_pads)
76 
77  // fill the output collections
78  for (auto & d: proto_pads)
79  {
80  GEMPadDigi pad_digi(d.first, d.second);
81  out_pads.insertDigi(p->id(), pad_digi);
82  }
83  }
84 }
virtual void produce(edm::Event &, const edm::EventSetup &) override
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define nullptr
const GEMGeometry * geometry_
GEMPadDigiProducer(const edm::ParameterSet &ps)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
const std::vector< const GEMEtaPartition * > & etaPartitions() const
Return a vector of all GEM chambers.
Definition: GEMGeometry.cc:57
const T & get() const
Definition: EventSetup.h:55
MuonDigiCollection< GEMDetId, GEMPadDigi > GEMPadDigiCollection
void buildPads(const GEMDigiCollection &digis, GEMPadDigiCollection &out_pads)
T const * product() const
Definition: Handle.h:81
edm::EDGetTokenT< GEMDigiCollection > digi_token_
Name of input digi Collection.
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: Run.h:41