CMS 3D CMS Logo

GEMPadDigiClusterProducer.cc
Go to the documentation of this file.
1 
21 
26 
29 
33 
34 #include <string>
35 #include <map>
36 #include <vector>
37 
39 public:
40  // all clusters per eta partition
41  typedef std::vector<GEMPadDigiCluster> GEMPadDigiClusters;
42  typedef std::map<GEMDetId, GEMPadDigiClusters> GEMPadDigiClusterContainer;
43 
44  // all clusters sorted by chamber, by opthohybrid and by eta partition
45  typedef std::map<GEMDetId, std::vector<std::vector<std::pair<GEMDetId, GEMPadDigiClusters> > > >
47 
48  explicit GEMPadDigiClusterProducer(const edm::ParameterSet& ps);
49 
50  ~GEMPadDigiClusterProducer() override;
51 
52  void beginRun(const edm::Run&, const edm::EventSetup&) override;
53 
54  void produce(edm::Event&, const edm::EventSetup&) override;
55 
56  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
57 
58 private:
97  void buildClusters(const GEMPadDigiCollection& pads, GEMPadDigiClusterContainer& out_clusters) const;
98  void sortClusters(const GEMPadDigiClusterContainer& in_clusters,
99  GEMPadDigiClusterSortedContainer& out_clusters) const;
101 
105 
106  unsigned int maxClustersOHGE11_;
107  unsigned int maxClustersOHGE21_;
108  unsigned int nOHGE11_;
109  unsigned int nOHGE21_;
110  unsigned int maxClusterSize_;
111 
113 };
114 
116  pads_ = ps.getParameter<edm::InputTag>("InputCollection");
117  maxClustersOHGE11_ = ps.getParameter<unsigned int>("maxClustersOHGE11");
118  maxClustersOHGE21_ = ps.getParameter<unsigned int>("maxClustersOHGE21");
119  nOHGE11_ = ps.getParameter<unsigned int>("nOHGE11");
120  nOHGE21_ = ps.getParameter<unsigned int>("nOHGE21");
121  maxClusterSize_ = ps.getParameter<unsigned int>("maxClusterSize");
122 
123  pad_token_ = consumes<GEMPadDigiCollection>(pads_);
124 
125  produces<GEMPadDigiClusterCollection>();
126  consumes<GEMPadDigiCollection>(pads_);
127 }
128 
130 
133  desc.add<edm::InputTag>("InputCollection", edm::InputTag("simMuonGEMPadDigis"));
134  desc.add<unsigned int>("maxClustersOHGE11", 4);
135  desc.add<unsigned int>("maxClustersOHGE21", 5);
136  desc.add<unsigned int>("nOHGE11", 2);
137  desc.add<unsigned int>("nOHGE21", 4);
138  desc.add<unsigned int>("maxClusterSize", 8);
139 
140  descriptions.add("simMuonGEMPadDigiClustersDef", desc);
141 }
142 
145  eventSetup.get<MuonGeometryRecord>().get(hGeom);
146  geometry_ = &*hGeom;
147 }
148 
151  e.getByToken(pad_token_, hpads);
152 
153  // Create empty output
154  std::unique_ptr<GEMPadDigiClusterCollection> pClusters(new GEMPadDigiClusterCollection());
155 
156  // build the proto clusters (per partition)
157  GEMPadDigiClusterContainer proto_clusters;
158  buildClusters(*(hpads.product()), proto_clusters);
159 
160  // // sort clusters per chamber, per OH, per partition number and per pad number
161  GEMPadDigiClusterSortedContainer sorted_clusters;
162  sortClusters(proto_clusters, sorted_clusters);
163 
164  // select the clusters from sorted clusters
165  selectClusters(sorted_clusters, *pClusters);
166 
167  // store them in the event
168  e.put(std::move(pClusters));
169 }
170 
172  GEMPadDigiClusterContainer& proto_clusters) const {
173  // clear the container
174  proto_clusters.clear();
175 
176  // construct clusters
177  for (const auto& part : geometry_->etaPartitions()) {
178  // clusters are not build for ME0
179  // -> ignore hits from station 0
180  if (part->id().station() == 0)
181  continue;
182 
183  GEMPadDigiClusters all_pad_clusters;
184 
185  auto pads = det_pads.get(part->id());
186  std::vector<uint16_t> cl;
187  int startBX = 99;
188 
189  for (auto d = pads.first; d != pads.second; ++d) {
190  if (cl.empty()) {
191  cl.push_back((*d).pad());
192  } else {
193  if ((*d).bx() == startBX and // same bunch crossing
194  (*d).pad() == cl.back() + 1 // pad difference is 1
195  and cl.size() < maxClusterSize_) { // max 8 in cluster
196  cl.push_back((*d).pad());
197  } else {
198  // put the current cluster in the proto collection
199  GEMPadDigiCluster pad_cluster(cl, startBX);
200 
201  all_pad_clusters.emplace_back(pad_cluster);
202 
203  // start a new cluster
204  cl.clear();
205  cl.push_back((*d).pad());
206  }
207  }
208  startBX = (*d).bx();
209  }
210 
211  // put the last cluster in the proto collection
212  if (pads.first != pads.second) {
213  GEMPadDigiCluster pad_cluster(cl, startBX);
214  all_pad_clusters.emplace_back(pad_cluster);
215  }
216  proto_clusters.emplace(part->id(), all_pad_clusters);
217 
218  } // end of partition loop
219 }
220 
222  GEMPadDigiClusterSortedContainer& sorted_clusters) const {
223  // The sorting of the clusters favors lower eta partitions and lower pad numbers
224  // By default the eta partitions are sorted by Id
225 
226  sorted_clusters.clear();
227 
228  for (const auto& ch : geometry_->chambers()) {
229  // check the station number
230  const int station = ch->id().station();
231  const bool isGE11 = (station == 1);
232  const unsigned nOH = isGE11 ? nOHGE11_ : nOHGE21_;
233  const unsigned nPartOH = ch->nEtaPartitions() / nOH;
234 
235  std::vector<std::vector<std::pair<GEMDetId, GEMPadDigiClusters> > > temp_clustersCH;
236 
237  for (unsigned int iOH = 0; iOH < nOH; iOH++) {
238  // all clusters for a set of eta partitions
239  std::vector<std::pair<GEMDetId, GEMPadDigiClusters> > temp_clustersOH;
240 
241  // loop over the 4 or 2 eta partitions for this optohybrid
242  for (unsigned iPart = 1; iPart <= nPartOH; iPart++) {
243  // get the clusters for this eta partition
244  const GEMDetId& partId = ch->etaPartition(iPart + iOH * nPartOH)->id();
245  if (proto_clusters.find(partId) != proto_clusters.end()) {
246  temp_clustersOH.emplace_back(partId, proto_clusters.at(partId));
247  }
248  } // end of eta partition loop
249 
250  temp_clustersCH.emplace_back(temp_clustersOH);
251  } // end of OH loop
252 
253  sorted_clusters.emplace(ch->id(), temp_clustersCH);
254  } // end of chamber loop
255 }
256 
258  GEMPadDigiClusterCollection& out_clusters) const {
259  // loop over chambers
260  for (const auto& ch : geometry_->chambers()) {
261  const int station = ch->id().station();
262  const bool isGE11 = (station == 1);
263  const unsigned maxClustersOH = isGE11 ? maxClustersOHGE11_ : maxClustersOHGE21_;
264 
265  // loop over the optohybrids
266  for (const auto& optohybrid : sorted_clusters.at(ch->id())) {
267  // at most maxClustersOH per OH!
268  unsigned nClusters = 0;
269 
270  // loop over the eta partitions for this OH
271  for (const auto& etapart : optohybrid) {
272  const auto& detid(etapart.first);
273  const auto& clusters(etapart.second);
274 
275  // pick the clusters with lowest pad number
276  for (const auto& clus : clusters) {
277  if (nClusters < maxClustersOH) {
278  out_clusters.insertDigi(detid, clus);
279  nClusters++;
280  }
281  } // end of cluster loop
282  } // end of eta partition loop
283  } // end of OH loop
284  } // end of chamber loop
285 }
286 
GEMPadDigiClusterProducer::GEMPadDigiClusterProducer
GEMPadDigiClusterProducer(const edm::ParameterSet &ps)
Definition: GEMPadDigiClusterProducer.cc:115
heavyionUCCDQM_cfi.nClusters
nClusters
Definition: heavyionUCCDQM_cfi.py:9
GEMPadDigiClusterProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: GEMPadDigiClusterProducer.cc:131
Handle.h
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
MessageLogger.h
GEMPadDigiClusterProducer::GEMPadDigiClusters
std::vector< GEMPadDigiCluster > GEMPadDigiClusters
Definition: GEMPadDigiClusterProducer.cc:41
edm::Handle::product
T const * product() const
Definition: Handle.h:70
ESHandle.h
GEMPadDigiClusterProducer::geometry_
const GEMGeometry * geometry_
Definition: GEMPadDigiClusterProducer.cc:112
GEMPadDigiClusterProducer::pads_
edm::InputTag pads_
Definition: GEMPadDigiClusterProducer.cc:104
edm::Run
Definition: Run.h:45
edm::EDGetTokenT< GEMPadDigiCollection >
relativeConstraints.station
station
Definition: relativeConstraints.py:67
GEMPadDigiCluster
Definition: GEMPadDigiCluster.h:17
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
GEMPadDigiClusterProducer::nOHGE11_
unsigned int nOHGE11_
Definition: GEMPadDigiClusterProducer.cc:108
EDProducer.h
edm::Handle< GEMPadDigiCollection >
GEMPadDigiClusterProducer::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: GEMPadDigiClusterProducer.cc:143
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
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
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:106
GEMPadDigiClusterProducer::GEMPadDigiClusterContainer
std::map< GEMDetId, GEMPadDigiClusters > GEMPadDigiClusterContainer
Definition: GEMPadDigiClusterProducer.cc:42
GEMPadDigiClusterCollection
GEMPadDigiClusterProducer::sortClusters
void sortClusters(const GEMPadDigiClusterContainer &in_clusters, GEMPadDigiClusterSortedContainer &out_clusters) const
Definition: GEMPadDigiClusterProducer.cc:221
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
bsc_activity_cfg.clusters
clusters
Definition: bsc_activity_cfg.py:36
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
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:107
GEMPadDigiClusterProducer::GEMPadDigiClusterSortedContainer
std::map< GEMDetId, std::vector< std::vector< std::pair< GEMDetId, GEMPadDigiClusters > > > > GEMPadDigiClusterSortedContainer
Definition: GEMPadDigiClusterProducer.cc:46
recoMuon::in
Definition: RecoMuonEnumerators.h:6
GEMDetId
Definition: GEMDetId.h:17
ModuleDef.h
edm::stream::EDProducer
Definition: EDProducer.h:38
GEMPadDigiClusterProducer::~GEMPadDigiClusterProducer
~GEMPadDigiClusterProducer() override
Definition: GEMPadDigiClusterProducer.cc:129
GEMPadDigiClusterProducer
Definition: GEMPadDigiClusterProducer.cc:38
edm::EventSetup
Definition: EventSetup.h:57
GEMPadDigiClusterProducer::selectClusters
void selectClusters(const GEMPadDigiClusterSortedContainer &in, GEMPadDigiClusterCollection &out) const
Definition: GEMPadDigiClusterProducer.cc:257
get
#define get
InputTag.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
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:109
GEMPadDigiCollection.h
EventSetup.h
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:110
MuonGeometryRecord.h
edm::Event
Definition: Event.h:73
GEMPadDigiClusterProducer::pad_token_
edm::EDGetTokenT< GEMPadDigiCollection > pad_token_
Name of input digi Collection.
Definition: GEMPadDigiClusterProducer.cc:103
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
edm::InputTag
Definition: InputTag.h:15
GEMPadDigiClusterProducer::buildClusters
void buildClusters(const GEMPadDigiCollection &pads, GEMPadDigiClusterContainer &out_clusters) const
Definition: GEMPadDigiClusterProducer.cc:171
GEMPadDigiClusterProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: GEMPadDigiClusterProducer.cc:149
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37