![]() |
![]() |
00001 // -*- C++ -*- 00002 // 00003 // Package: ClusterMultiplicityFilter 00004 // Class: ClusterMultiplicityFilter 00005 // 00006 00007 // 00008 // Original Author: Carsten Noeding 00009 // Created: Mon Mar 19 13:51:22 CDT 2007 00010 // $Id: ClusterMultiplicityFilter.cc,v 1.5 2009/12/18 20:45:04 wmtan Exp $ 00011 // 00012 // 00013 00014 00015 // system include files 00016 #include <memory> 00017 00018 #include "RecoLocalTracker/SubCollectionProducers/interface/ClusterMultiplicityFilter.h" 00019 00020 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00021 00022 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h" 00023 #include "DataFormats/Common/interface/DetSetVector.h" 00024 00025 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" 00026 00027 00028 ClusterMultiplicityFilter::ClusterMultiplicityFilter(const edm::ParameterSet& iConfig) 00029 { 00030 maxNumberOfClusters_ = iConfig.getUntrackedParameter<unsigned int>("MaxNumberOfClusters"); 00031 clusterCollectionLabel_ = iConfig.getUntrackedParameter<std::string>("ClusterCollectionLabel"); 00032 } 00033 00034 00035 ClusterMultiplicityFilter::~ClusterMultiplicityFilter() { 00036 } 00037 00038 00039 // ------------ method called on each new Event ------------ 00040 bool ClusterMultiplicityFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) { 00041 00042 bool result = true; 00043 00044 const edm::DetSetVector<SiStripCluster> *clusters = 0; 00045 edm::Handle<edm::DetSetVector<SiStripCluster> > clusterHandle; 00046 iEvent.getByLabel(clusterCollectionLabel_,clusterHandle); 00047 if( !clusterHandle.isValid() ) { 00048 throw cms::Exception("CorruptData") 00049 << "ClusterMultiplicityFilter requires collection <edm::DetSetVector<SiStripCluster> with label " << clusterCollectionLabel_ << std::endl; 00050 } 00051 00052 clusters = clusterHandle.product(); 00053 const edm::DetSetVector<SiStripCluster>& input = *clusters; 00054 00055 unsigned int totalClusters = 0; 00056 00057 //loop over detectors 00058 for (edm::DetSetVector<SiStripCluster>::const_iterator DSViter=input.begin(); DSViter!=input.end();DSViter++ ) { 00059 totalClusters+=DSViter->data.size(); 00060 } 00061 00062 00063 if (totalClusters>maxNumberOfClusters_) { 00064 edm::LogInfo("ClusterMultiplicityFilter") << "Total number of clusters: " << totalClusters << " ==> exceeds allowed maximum of " << maxNumberOfClusters_ << " clusters"; 00065 result = false; 00066 } 00067 00068 return result; 00069 } 00070 00071 00072 void ClusterMultiplicityFilter::beginJob() { 00073 } 00074 00075 00076 // ------------ method called once each job just after ending the event loop ------------ 00077 void ClusterMultiplicityFilter::endJob() { 00078 } 00079