CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GEMCSCPadDigiProducer.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  produces<GEMCSCPadDigiCollection>();
20  produces<GEMCSCPadDigiCollection>("Coincidence");
21 
22  input_ = ps.getParameter<edm::InputTag>("InputCollection");
23  maxDeltaBX_ = ps.getParameter<int>("maxDeltaBX");
24 }
25 
26 
28 {}
29 
30 
32 {
34  eventSetup.get<MuonGeometryRecord>().get( hGeom );
35  geometry_ = &*hGeom;
36 }
37 
38 
40 {
42  e.getByLabel(input_, hdigis);
43 
44  // Create empty output
45  std::auto_ptr<GEMCSCPadDigiCollection> pPads(new GEMCSCPadDigiCollection());
46  std::auto_ptr<GEMCSCPadDigiCollection> pCoPads(new GEMCSCPadDigiCollection());
47 
48  // build the pads
49  buildPads(*(hdigis.product()), *pPads, *pCoPads);
50 
51  // store them in the event
52  e.put(pPads);
53  e.put(pCoPads, "Coincidence");
54 }
55 
56 
58  GEMCSCPadDigiCollection &out_pads, GEMCSCPadDigiCollection &out_co_pads)
59 {
60  auto etaPartitions = geometry_->etaPartitions();
61  for(auto p: etaPartitions)
62  {
63  // set of <pad, bx> pairs, sorted first by pad then by bx
64  std::set<std::pair<int, int> > proto_pads;
65 
66  // walk over digis in this partition,
67  // and stuff them into a set of unique pads (equivalent of OR operation)
68  auto digis = det_digis.get(p->id());
69  for (auto d = digis.first; d != digis.second; ++d)
70  {
71  int pad_num = 1 + static_cast<int>( p->padOfStrip(d->strip()) );
72  auto pad = std::make_pair(pad_num, d->bx());
73  proto_pads.insert(pad);
74  }
75 
76  // in the future, do some dead-time handling
77  // emulateDeadTime(proto_pads)
78 
79  // fill the output collections
80  for (auto & d: proto_pads)
81  {
82  GEMCSCPadDigi pad_digi(d.first, d.second);
83  out_pads.insertDigi(p->id(), pad_digi);
84  }
85  }
86 
87  // build coincidences
88  for (auto det_range = out_pads.begin(); det_range != out_pads.end(); ++det_range)
89  {
90  const GEMDetId& id = (*det_range).first;
91 
92  // all coincidences detIDs will have layer=1
93  if (id.layer() != 1) continue;
94 
95  // find the corresponding id with layer=2
96  GEMDetId co_id(id.region(), id.ring(), id.station(), 2, id.chamber(), id.roll());
97 
98  auto co_pads_range = out_pads.get(co_id);
99  // empty range = no possible coincidence pads
100  if (co_pads_range.first == co_pads_range.second) continue;
101 
102  // now let's correlate the pads in two layers of this partition
103  const auto& pads_range = (*det_range).second;
104  for (auto p = pads_range.first; p != pads_range.second; ++p)
105  {
106  for (auto co_p = co_pads_range.first; co_p != co_pads_range.second; ++co_p)
107  {
108  // check the match!
109  if (p->pad() != co_p->pad() || std::abs(p->bx() - co_p->bx()) > maxDeltaBX_ ) continue;
110 
111  // always use layer1 pad's BX as a copad's BX
112  GEMCSCPadDigi co_pad_digi(p->pad(), p->bx());
113  out_co_pads.insertDigi(id, co_pad_digi);
114  }
115  }
116  }
117 }
T getParameter(std::string const &) const
#define nullptr
#define abs(x)
Definition: mlp_lapack.h:159
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
GEMCSCPadDigiProducer(const edm::ParameterSet &ps)
MuonDigiCollection< GEMDetId, GEMCSCPadDigi > GEMCSCPadDigiCollection
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
void buildPads(const GEMDigiCollection &digis, GEMCSCPadDigiCollection &out_pads, GEMCSCPadDigiCollection &out_co_pads)
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
const GEMGeometry * geometry_
edm::InputTag input_
Name of input digi Collection.
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: Handle.h:74
virtual void produce(edm::Event &e, const edm::EventSetup &c) override
Definition: Run.h:36
const std::vector< GEMEtaPartition * > & etaPartitions() const
Return a vector of all GEM chambers.
Definition: GEMGeometry.cc:57