File indexing completed on 2024-04-06 12:26:32
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <memory>
0015
0016 #include "RecoLocalTracker/SubCollectionProducers/interface/ClusterMultiplicityFilter.h"
0017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0018 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0019
0020 ClusterMultiplicityFilter::ClusterMultiplicityFilter(const edm::ParameterSet& iConfig)
0021 : maxNumberOfClusters_(iConfig.getParameter<unsigned int>("MaxNumberOfClusters")),
0022 clusterCollectionTag_(iConfig.getParameter<edm::InputTag>("ClusterCollection")),
0023 clusters_(consumes<edmNew::DetSetVector<SiStripCluster> >(clusterCollectionTag_)) {}
0024
0025 ClusterMultiplicityFilter::~ClusterMultiplicityFilter() {}
0026
0027
0028 bool ClusterMultiplicityFilter::filter(edm::StreamID iID, edm::Event& iEvent, edm::EventSetup const& iSetup) const {
0029 bool result = true;
0030
0031 const edmNew::DetSetVector<SiStripCluster>* clusters = nullptr;
0032 edm::Handle<edmNew::DetSetVector<SiStripCluster> > clusterHandle;
0033 iEvent.getByToken(clusters_, clusterHandle);
0034 if (!clusterHandle.isValid()) {
0035 throw cms::Exception("CorruptData")
0036 << "ClusterMultiplicityFilter requires collection <edm::DetSetVector<SiStripCluster> with label "
0037 << clusterCollectionTag_.label() << std::endl;
0038 }
0039
0040 clusters = clusterHandle.product();
0041 const edmNew::DetSetVector<SiStripCluster>& input = *clusters;
0042
0043 unsigned int totalClusters = 0;
0044
0045
0046 for (edmNew::DetSetVector<SiStripCluster>::const_iterator DSViter = input.begin(); DSViter != input.end();
0047 DSViter++) {
0048 totalClusters += DSViter->size();
0049 }
0050
0051 if (totalClusters > maxNumberOfClusters_) {
0052 edm::LogInfo("ClusterMultiplicityFilter")
0053 << "Total number of clusters: " << totalClusters << " ==> exceeds allowed maximum of " << maxNumberOfClusters_
0054 << " clusters";
0055 result = false;
0056 }
0057
0058 return result;
0059 }
0060
0061 #include "FWCore/PluginManager/interface/ModuleDef.h"
0062 #include "FWCore/Framework/interface/MakerMacros.h"
0063 DEFINE_FWK_MODULE(ClusterMultiplicityFilter);