CMS 3D CMS Logo

GEMPadDigiProducer.cc
Go to the documentation of this file.
12 
16 
19 
20 #include <set>
21 
22 /*
23  \class GEMPadDigiProducer
24  producer for GEM trigger pads
25 
26  In GE1/1: trigger pads are made from neighboring strip digis
27  in the same eta partition
28 
29  In GE2/1: trigger pads are made from neighboring strip digis
30  in neighboring eta partitions
31 */
32 
34 public:
35  explicit GEMPadDigiProducer(const edm::ParameterSet& ps);
36 
37  ~GEMPadDigiProducer() override;
38 
39  void beginRun(const edm::Run&, const edm::EventSetup&) override;
40 
41  void produce(edm::Event&, const edm::EventSetup&) override;
42 
43  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
44 
45 private:
46  void buildPads(const GEMDigiCollection& digis, GEMPadDigiCollection& out_pads) const;
47  void buildPads16GE21(const GEMDigiCollection& digis, GEMPadDigiCollection& out_pads) const;
48  void checkValid(const GEMPadDigi& pad, const GEMDetId& id) const;
49  void checkGeometry() const;
50 
55  bool use16GE21_;
56 
58 };
59 
60 GEMPadDigiProducer::GEMPadDigiProducer(const edm::ParameterSet& ps) : use16GE21_(false), geometry_(nullptr) {
61  digis_ = ps.getParameter<edm::InputTag>("InputCollection");
62 
63  digi_token_ = consumes<GEMDigiCollection>(digis_);
64  geom_token_ = esConsumes<GEMGeometry, MuonGeometryRecord, edm::Transition::BeginRun>();
65 
66  produces<GEMPadDigiCollection>();
67  consumes<GEMDigiCollection>(digis_);
68 }
69 
71 
74  desc.add<edm::InputTag>("InputCollection", edm::InputTag("simMuonGEMDigis"));
75 
76  descriptions.add("simMuonGEMPadDigisDef", desc);
77 }
78 
81  geometry_ = &*hGeom;
82  // check the number of parititions
83  if (geometry_->hasGE21()) {
84  use16GE21_ = (geometry_->chamber(GEMDetId(1, 1, 2, 2, 16, 0))->nEtaPartitions() ==
85  GEMPadDigi::NumberPartitions::GE21SplitStrip);
86  }
87 
88  checkGeometry();
89 }
90 
93  e.getByToken(digi_token_, hdigis);
94 
95  // Create empty output
96  std::unique_ptr<GEMPadDigiCollection> pPads(new GEMPadDigiCollection());
97 
98  // build the pads
99  buildPads(*(hdigis.product()), *pPads);
100  if (use16GE21_)
101  buildPads16GE21(*(hdigis.product()), *pPads);
102 
103  // store them in the event
104  e.put(std::move(pPads));
105 }
106 
108  for (const auto& p : geometry_->etaPartitions()) {
109  // when using the GE2/1 geometry with 16 eta partitions
110  // ->ignore GE2/1
111  if (use16GE21_ and p->isGE21())
112  continue;
113 
114  // set of <pad, bx, part> pairs, sorted first by pad then by bx
115  std::set<std::tuple<int, int, unsigned> > proto_pads;
116 
117  // walk over digis in this partition,
118  // and stuff them into a set of unique pads (equivalent of OR operation)
119  auto digis = det_digis.get(p->id());
120  for (auto d = digis.first; d != digis.second; ++d) {
121  unsigned pad_num = static_cast<unsigned>(p->padOfStrip(d->strip()));
122 
123  auto nPart = GEMPadDigi::NumberPartitions::GE11;
124  if (p->isME0()) {
126  } else if (p->isGE21()) {
127  nPart = GEMPadDigi::NumberPartitions::GE21;
128  }
129  // check that the input digi is valid
130  if ((p->isGE11() and pad_num == GEMPadDigi::GE11InValid) or
131  (p->isGE21() and pad_num == GEMPadDigi::GE21InValid) or (p->isME0() and pad_num == GEMPadDigi::ME0InValid)) {
132  edm::LogWarning("GEMPadDigiProducer") << "Invalid " << pad_num << " from " << *d << " in " << p->id();
133  }
134  proto_pads.emplace(pad_num, d->bx(), nPart);
135  }
136 
137  // fill the output collections
138  for (const auto& d : proto_pads) {
139  GEMPadDigi pad_digi(std::get<0>(d), std::get<1>(d), p->subsystem(), std::get<2>(d));
140  checkValid(pad_digi, p->id());
141  out_pads.insertDigi(p->id(), pad_digi);
142  }
143  }
144 }
145 
147  for (const auto& p : geometry_->etaPartitions()) {
148  // when using the GE2/1 geometry with 16 eta partitions
149  // ->ignore GE1/1
150  if (!p->isGE21())
151  continue;
152 
153  // ignore eta partition with even numbers
154  // these are included in the odd numbered pads
155  if (p->id().roll() % 2 == 0)
156  continue;
157 
158  // set of <pad, bx> pairs, sorted first by pad then by bx
159  std::set<std::pair<int, int> > proto_pads;
160 
161  // walk over digis in the first partition,
162  // and stuff them into a set of unique pads (equivalent of OR operation)
163  auto digis = det_digis.get(p->id());
164 
165  // proto pads for the odd partitions
166  for (auto d = digis.first; d != digis.second; ++d) {
167  proto_pads.emplace(d->strip(), d->bx());
168  }
169 
170  GEMDetId gemId2(
171  p->id().region(), p->id().ring(), p->id().station(), p->id().layer(), p->id().chamber(), p->id().roll() + 1);
172  auto digis2 = det_digis.get(gemId2);
173 
174  // proto pads for the even partitions
175  for (auto d = digis2.first; d != digis2.second; ++d) {
176  proto_pads.emplace(d->strip(), d->bx());
177  }
178 
179  // fill the output collections
180  for (const auto& d : proto_pads) {
181  GEMPadDigi pad_digi(d.first, d.second, p->subsystem(), GEMPadDigi::NumberPartitions::GE21SplitStrip);
182  checkValid(pad_digi, p->id());
183  out_pads.insertDigi(p->id(), pad_digi);
184  }
185  }
186 }
187 
188 void GEMPadDigiProducer::checkValid(const GEMPadDigi& pad, const GEMDetId& id) const {
189  // check if the pad is valid
190  // in principle, invalid pads can appear in the CMS raw data
191  if (!pad.isValid()) {
192  edm::LogWarning("GEMPadDigiProducer") << "Invalid " << pad << " in " << id;
193  }
194 }
195 
197  // check that ME0 has 8-eta partitions
198  if (geometry_->hasME0()) {
200  edm::LogError("GEMPadDigiProducer") << "ME0 geometry appears corrupted";
201  }
202  }
203 
204  // check that GE1/1 has 8-eta partitions
205  if (geometry_->hasGE11()) {
206  if (geometry_->chamber(GEMDetId(1, 1, 1, 1, 1, 0))->nEtaPartitions() != GEMPadDigi::NumberPartitions::GE11) {
207  edm::LogError("GEMPadDigiProducer") << "GE1/1 geometry appears corrupted";
208  }
209  }
210 
211  if (geometry_->hasGE21()) {
212  if (!use16GE21_) {
213  // check that GE2/1 has 8-eta partitions
214  if (geometry_->chamber(GEMDetId(1, 1, 2, 2, 16, 0))->nEtaPartitions() != GEMPadDigi::NumberPartitions::GE21) {
215  edm::LogError("GEMPadDigiProducer") << "GE2/1 geometry (8 partition) appears corrupted";
216  }
217  } else {
218  // check that GE2/1 has 16-eta partitions
219  if (geometry_->chamber(GEMDetId(1, 1, 2, 2, 16, 0))->nEtaPartitions() !=
220  GEMPadDigi::NumberPartitions::GE21SplitStrip) {
221  edm::LogError("GEMPadDigiProducer") << "GE2/1 geometry (16 partition) appears corrupted";
222  }
223  }
224  }
225 }
226 
void produce(edm::Event &, const edm::EventSetup &) override
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void buildPads16GE21(const GEMDigiCollection &digis, GEMPadDigiCollection &out_pads) const
T const * product() const
Definition: Handle.h:70
const GEMGeometry * geometry_
int nEtaPartitions() const
Retunr numbers of eta partitions.
Definition: GEMChamber.cc:31
GEMPadDigiProducer(const edm::ParameterSet &ps)
Log< level::Error, false > LogError
bool hasME0() const
Definition: GEMGeometry.cc:111
bool isValid() const
Definition: GEMPadDigi.cc:26
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
bool hasGE11() const
Definition: GEMGeometry.cc:113
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
d
Definition: ztail.py:151
TString nPart(Int_t part, TString string, TString delimit=";", Bool_t removerest=true)
bool hasGE21() const
Definition: GEMGeometry.cc:115
MuonDigiCollection< GEMDetId, GEMPadDigi > GEMPadDigiCollection
void add(std::string const &label, ParameterSetDescription const &psetDescription)
ME0 Data Record : block->header().getID() = 6.
Definition: Block.h:23
~GEMPadDigiProducer() override
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > geom_token_
Log< level::Warning, false > LogWarning
void checkValid(const GEMPadDigi &pad, const GEMDetId &id) const
edm::EDGetTokenT< GEMDigiCollection > digi_token_
Name of input digi Collection.
const GEMChamber * chamber(GEMDetId id) const
Definition: GEMGeometry.cc:73
void beginRun(const edm::Run &, const edm::EventSetup &) override
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45
void buildPads(const GEMDigiCollection &digis, GEMPadDigiCollection &out_pads) const
const std::vector< const GEMEtaPartition * > & etaPartitions() const
Return a vector of all GEM eta partitions.
Definition: GEMGeometry.cc:40