CMS 3D CMS Logo

GEMPadDigiClusterProducer.cc
Go to the documentation of this file.
1 
21 
27 
30 
34 
35 #include <string>
36 #include <map>
37 #include <vector>
38 
40 public:
41  // all clusters per eta partition
42  typedef std::vector<GEMPadDigiCluster> GEMPadDigiClusters;
43  typedef std::map<GEMDetId, GEMPadDigiClusters> GEMPadDigiClusterContainer;
44 
45  // all clusters sorted by chamber, by opthohybrid and by eta partition
46  typedef std::map<GEMDetId, std::vector<std::vector<std::pair<GEMDetId, GEMPadDigiClusters> > > >
48 
49  explicit GEMPadDigiClusterProducer(const edm::ParameterSet& ps);
50 
51  ~GEMPadDigiClusterProducer() override;
52 
53  void beginRun(const edm::Run&, const edm::EventSetup&) override;
54 
55  void produce(edm::Event&, const edm::EventSetup&) override;
56 
57  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
58 
59 private:
98  void buildClusters(const GEMPadDigiCollection& pads, GEMPadDigiClusterContainer& out_clusters) const;
99  void sortClusters(const GEMPadDigiClusterContainer& in_clusters,
100  GEMPadDigiClusterSortedContainer& out_clusters) const;
102  template <class T>
103  void checkValid(const T& cluster, const GEMDetId& id) const;
104 
109 
110  unsigned int maxClustersOHGE11_;
111  unsigned int maxClustersOHGE21_;
112  unsigned int nOHGE11_;
113  unsigned int nOHGE21_;
114  unsigned int maxClusterSize_;
116 
118 };
119 
121  pads_ = ps.getParameter<edm::InputTag>("InputCollection");
122  maxClustersOHGE11_ = ps.getParameter<unsigned int>("maxClustersOHGE11");
123  maxClustersOHGE21_ = ps.getParameter<unsigned int>("maxClustersOHGE21");
124  nOHGE11_ = ps.getParameter<unsigned int>("nOHGE11");
125  nOHGE21_ = ps.getParameter<unsigned int>("nOHGE21");
126  maxClusterSize_ = ps.getParameter<unsigned int>("maxClusterSize");
127  sendOverflowClusters_ = ps.getParameter<bool>("sendOverflowClusters");
128 
129  if (sendOverflowClusters_) {
130  maxClustersOHGE11_ *= 2;
131  maxClustersOHGE21_ *= 2;
132  }
133 
134  pad_token_ = consumes<GEMPadDigiCollection>(pads_);
135  geom_token_ = esConsumes<GEMGeometry, MuonGeometryRecord, edm::Transition::BeginRun>();
136 
137  produces<GEMPadDigiClusterCollection>();
138  consumes<GEMPadDigiCollection>(pads_);
139 }
140 
142 
145  desc.add<edm::InputTag>("InputCollection", edm::InputTag("simMuonGEMPadDigis"));
146  desc.add<unsigned int>("maxClustersOHGE11", 4);
147  desc.add<unsigned int>("maxClustersOHGE21", 5);
148  desc.add<unsigned int>("nOHGE11", 2);
149  desc.add<unsigned int>("nOHGE21", 4);
150  desc.add<unsigned int>("maxClusterSize", 8);
151  desc.add<bool>("sendOverflowClusters", false);
152 
153  descriptions.add("simMuonGEMPadDigiClustersDef", desc);
154 }
155 
158  geometry_ = &*hGeom;
159 }
160 
163  e.getByToken(pad_token_, hpads);
164 
165  // Create empty output
166  std::unique_ptr<GEMPadDigiClusterCollection> pClusters(new GEMPadDigiClusterCollection());
167 
168  // build the proto clusters (per partition)
169  GEMPadDigiClusterContainer proto_clusters;
170  buildClusters(*(hpads.product()), proto_clusters);
171 
172  // // sort clusters per chamber, per OH, per partition number and per pad number
173  GEMPadDigiClusterSortedContainer sorted_clusters;
174  sortClusters(proto_clusters, sorted_clusters);
175 
176  // select the clusters from sorted clusters
177  selectClusters(sorted_clusters, *pClusters);
178 
179  // store them in the event
180  e.put(std::move(pClusters));
181 }
182 
184  GEMPadDigiClusterContainer& proto_clusters) const {
185  // clear the container
186  proto_clusters.clear();
187 
188  // construct clusters
189  for (const auto& part : geometry_->etaPartitions()) {
190  // clusters are not build for ME0
191  // -> ignore hits from station 0
192  if (part->isME0())
193  continue;
194 
195  GEMPadDigiClusters all_pad_clusters;
196 
197  auto pads = det_pads.get(part->id());
198  std::vector<uint16_t> cl;
199  int startBX = 99;
200 
201  for (auto d = pads.first; d != pads.second; ++d) {
202  // check if the input pad is valid
203  checkValid(*d, part->id());
204 
205  // number of eta partitions
206  unsigned nPart = d->nPartitions();
207 
208  if (cl.empty()) {
209  cl.push_back((*d).pad());
210  } else {
211  if ((*d).bx() == startBX and // same bunch crossing
212  (*d).pad() == cl.back() + 1 // pad difference is 1
213  and cl.size() < maxClusterSize_) { // max 8 in cluster
214  cl.push_back((*d).pad());
215  } else {
216  // put the current cluster in the proto collection
217  GEMPadDigiCluster pad_cluster(cl, startBX, part->subsystem(), nPart);
218 
219  // check if the output cluster is valid
220  checkValid(pad_cluster, part->id());
221 
222  all_pad_clusters.emplace_back(pad_cluster);
223 
224  // start a new cluster
225  cl.clear();
226  cl.push_back((*d).pad());
227  }
228  }
229  startBX = (*d).bx();
230  }
231 
232  // put the last cluster in the proto collection
233  if (pads.first != pads.second) {
234  // number of eta partitions
235  unsigned nPart = (pads.first)->nPartitions();
236 
237  GEMPadDigiCluster pad_cluster(cl, startBX, part->subsystem(), nPart);
238 
239  // check if the output cluster is valid
240  checkValid(pad_cluster, part->id());
241 
242  all_pad_clusters.emplace_back(pad_cluster);
243  }
244  proto_clusters.emplace(part->id(), all_pad_clusters);
245 
246  } // end of partition loop
247 }
248 
250  GEMPadDigiClusterSortedContainer& sorted_clusters) const {
251  // The sorting of the clusters favors lower eta partitions and lower pad numbers
252  // By default the eta partitions are sorted by Id
253 
254  sorted_clusters.clear();
255 
256  for (const auto& ch : geometry_->chambers()) {
257  // check the station number
258  const unsigned nOH = ch->id().isGE11() ? nOHGE11_ : nOHGE21_;
259  const unsigned nPartOH = ch->nEtaPartitions() / nOH;
260 
261  std::vector<std::vector<std::pair<GEMDetId, GEMPadDigiClusters> > > temp_clustersCH;
262 
263  for (unsigned int iOH = 0; iOH < nOH; iOH++) {
264  // all clusters for a set of eta partitions
265  std::vector<std::pair<GEMDetId, GEMPadDigiClusters> > temp_clustersOH;
266 
267  // loop over the 4 or 2 eta partitions for this optohybrid
268  for (unsigned iPart = 1; iPart <= nPartOH; iPart++) {
269  // get the clusters for this eta partition
270  const GEMDetId& partId = ch->etaPartition(iPart + iOH * nPartOH)->id();
271  if (proto_clusters.find(partId) != proto_clusters.end()) {
272  temp_clustersOH.emplace_back(partId, proto_clusters.at(partId));
273  }
274  } // end of eta partition loop
275 
276  temp_clustersCH.emplace_back(temp_clustersOH);
277  } // end of OH loop
278 
279  sorted_clusters.emplace(ch->id(), temp_clustersCH);
280  } // end of chamber loop
281 }
282 
284  GEMPadDigiClusterCollection& out_clusters) const {
285  // loop over chambers
286  for (const auto& ch : geometry_->chambers()) {
287  const unsigned maxClustersOH = ch->id().isGE11() ? maxClustersOHGE11_ : maxClustersOHGE21_;
288 
289  // loop over the optohybrids
290  for (const auto& optohybrid : sorted_clusters.at(ch->id())) {
291  // at most maxClustersOH per OH!
292  unsigned nClusters = 0;
293 
294  // loop over the eta partitions for this OH
295  for (const auto& etapart : optohybrid) {
296  const auto& detid(etapart.first);
297  const auto& clusters(etapart.second);
298 
299  // pick the clusters with lowest pad number
300  for (const auto& clus : clusters) {
301  if (nClusters < maxClustersOH) {
302  // check if the output cluster is valid
303  checkValid(clus, detid);
304 
305  out_clusters.insertDigi(detid, clus);
306  nClusters++;
307  }
308  } // end of cluster loop
309  } // end of eta partition loop
310  } // end of OH loop
311  } // end of chamber loop
312 }
313 
314 template <class T>
315 void GEMPadDigiClusterProducer::checkValid(const T& tp, const GEMDetId& id) const {
316  // check if the pad/cluster is valid
317  // in principle, invalid pads/clusters can appear in the CMS raw data
318  if (!tp.isValid()) {
319  edm::LogWarning("GEMPadDigiClusterProducer") << "Invalid " << tp << " in " << id;
320  }
321 }
322 
GEMPadDigiClusterProducer::GEMPadDigiClusterProducer
GEMPadDigiClusterProducer(const edm::ParameterSet &ps)
Definition: GEMPadDigiClusterProducer.cc:120
heavyionUCCDQM_cfi.nClusters
nClusters
Definition: heavyionUCCDQM_cfi.py:9
GEMPadDigiClusterProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: GEMPadDigiClusterProducer.cc:143
Handle.h
MessageLogger.h
GEMPadDigiClusterProducer::GEMPadDigiClusters
std::vector< GEMPadDigiCluster > GEMPadDigiClusters
Definition: GEMPadDigiClusterProducer.cc:42
edm::Handle::product
T const * product() const
Definition: Handle.h:70
ESHandle.h
GEMPadDigiClusterProducer::geometry_
const GEMGeometry * geometry_
Definition: GEMPadDigiClusterProducer.cc:117
GEMPadDigiClusterProducer::pads_
edm::InputTag pads_
Definition: GEMPadDigiClusterProducer.cc:108
edm::Run
Definition: Run.h:45
edm::EDGetTokenT< GEMPadDigiCollection >
GEMPadDigiClusterProducer::sendOverflowClusters_
bool sendOverflowClusters_
Definition: GEMPadDigiClusterProducer.cc:115
GEMPadDigiCluster
Definition: GEMPadDigiCluster.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:85964
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
GEMPadDigiClusterProducer::nOHGE11_
unsigned int nOHGE11_
Definition: GEMPadDigiClusterProducer.cc:112
EDProducer.h
edm::Handle< GEMPadDigiCollection >
ESGetToken.h
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
GEMPadDigiClusterProducer::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: GEMPadDigiClusterProducer.cc:156
GetRecoTauVFromDQM_MC_cff.cl
cl
Definition: GetRecoTauVFromDQM_MC_cff.py:38
GEMPadDigiClusterCollection.h
MakerMacros.h
part
part
Definition: HCALResponse.h:20
GEMPadDigiClusterCollection
MuonDigiCollection< GEMDetId, GEMPadDigiCluster > GEMPadDigiClusterCollection
Definition: GEMPadDigiClusterCollection.h:13
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
edm::ESHandle< GEMGeometry >
GEMPadDigiCollection
GEMPadDigiClusterProducer::maxClustersOHGE11_
unsigned int maxClustersOHGE11_
Definition: GEMPadDigiClusterProducer.cc:110
GEMPadDigiClusterProducer::GEMPadDigiClusterContainer
std::map< GEMDetId, GEMPadDigiClusters > GEMPadDigiClusterContainer
Definition: GEMPadDigiClusterProducer.cc:43
GEMPadDigiClusterCollection
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
GEMPadDigiClusterProducer::sortClusters
void sortClusters(const GEMPadDigiClusterContainer &in_clusters, GEMPadDigiClusterSortedContainer &out_clusters) const
Definition: GEMPadDigiClusterProducer.cc:249
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
nPart
TString nPart(Int_t part, TString string, TString delimit=";", Bool_t removerest=true)
bsc_activity_cfg.clusters
clusters
Definition: bsc_activity_cfg.py:36
edm::ParameterSet
Definition: ParameterSet.h:47
GEMGeometry::chambers
const std::vector< const GEMChamber * > & chambers() const
Return a vector of all GEM chambers.
Definition: GEMGeometry.cc:38
Event.h
GEMPadDigiClusterProducer::maxClustersOHGE21_
unsigned int maxClustersOHGE21_
Definition: GEMPadDigiClusterProducer.cc:111
GEMPadDigiClusterProducer::GEMPadDigiClusterSortedContainer
std::map< GEMDetId, std::vector< std::vector< std::pair< GEMDetId, GEMPadDigiClusters > > > > GEMPadDigiClusterSortedContainer
Definition: GEMPadDigiClusterProducer.cc:47
recoMuon::in
Definition: RecoMuonEnumerators.h:6
GEMDetId
Definition: GEMDetId.h:18
ModuleDef.h
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:148
edm::stream::EDProducer
Definition: EDProducer.h:38
GEMPadDigiClusterProducer::geom_token_
edm::ESGetToken< GEMGeometry, MuonGeometryRecord > geom_token_
Definition: GEMPadDigiClusterProducer.cc:107
GEMPadDigiClusterProducer::~GEMPadDigiClusterProducer
~GEMPadDigiClusterProducer() override
Definition: GEMPadDigiClusterProducer.cc:141
GEMPadDigiClusterProducer
Definition: GEMPadDigiClusterProducer.cc:39
edm::EventSetup
Definition: EventSetup.h:57
GEMPadDigiClusterProducer::selectClusters
void selectClusters(const GEMPadDigiClusterSortedContainer &in, GEMPadDigiClusterCollection &out) const
Definition: GEMPadDigiClusterProducer.cc:283
edm::ESGetToken< GEMGeometry, MuonGeometryRecord >
InputTag.h
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
GEMGeometry.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
writedatasetfile.run
run
Definition: writedatasetfile.py:27
GEMPadDigiClusterProducer::nOHGE21_
unsigned int nOHGE21_
Definition: GEMPadDigiClusterProducer.cc:113
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
T
long double T
Definition: Basic3DVectorLD.h:48
GEMPadDigiCollection.h
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Exception.h
GEMGeometry::etaPartitions
const std::vector< const GEMEtaPartition * > & etaPartitions() const
Return a vector of all GEM eta partitions.
Definition: GEMGeometry.cc:40
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
GEMGeometry
Definition: GEMGeometry.h:24
ztail.d
d
Definition: ztail.py:151
ConsumesCollector.h
ParameterSet.h
GEMPadDigiClusterProducer::maxClusterSize_
unsigned int maxClusterSize_
Definition: GEMPadDigiClusterProducer.cc:114
MuonGeometryRecord.h
edm::Event
Definition: Event.h:73
GEMPadDigiClusterProducer::pad_token_
edm::EDGetTokenT< GEMPadDigiCollection > pad_token_
Name of input digi Collection.
Definition: GEMPadDigiClusterProducer.cc:106
edm::InputTag
Definition: InputTag.h:15
GEMPadDigiClusterProducer::checkValid
void checkValid(const T &cluster, const GEMDetId &id) const
Definition: GEMPadDigiClusterProducer.cc:315
GEMPadDigiClusterProducer::buildClusters
void buildClusters(const GEMPadDigiCollection &pads, GEMPadDigiClusterContainer &out_clusters) const
Definition: GEMPadDigiClusterProducer.cc:183
GEMPadDigiClusterProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: GEMPadDigiClusterProducer.cc:161
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37