CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ClusterMultiplicityFilter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: ClusterMultiplicityFilter
4 // Class: ClusterMultiplicityFilter
5 //
6 
7 //
8 // Original Author: Carsten Noeding
9 // Created: Mon Mar 19 13:51:22 CDT 2007
10 // $Id: ClusterMultiplicityFilter.cc,v 1.5 2009/12/18 20:45:04 wmtan Exp $
11 //
12 //
13 
14 
15 // system include files
16 #include <memory>
17 
19 
21 
24 
26 
27 
29 {
30  maxNumberOfClusters_ = iConfig.getUntrackedParameter<unsigned int>("MaxNumberOfClusters");
31  clusterCollectionLabel_ = iConfig.getUntrackedParameter<std::string>("ClusterCollectionLabel");
32 }
33 
34 
36 }
37 
38 
39 // ------------ method called on each new Event ------------
41 
42  bool result = true;
43 
44  const edm::DetSetVector<SiStripCluster> *clusters = 0;
46  iEvent.getByLabel(clusterCollectionLabel_,clusterHandle);
47  if( !clusterHandle.isValid() ) {
48  throw cms::Exception("CorruptData")
49  << "ClusterMultiplicityFilter requires collection <edm::DetSetVector<SiStripCluster> with label " << clusterCollectionLabel_ << std::endl;
50  }
51 
52  clusters = clusterHandle.product();
53  const edm::DetSetVector<SiStripCluster>& input = *clusters;
54 
55  unsigned int totalClusters = 0;
56 
57  //loop over detectors
58  for (edm::DetSetVector<SiStripCluster>::const_iterator DSViter=input.begin(); DSViter!=input.end();DSViter++ ) {
59  totalClusters+=DSViter->data.size();
60  }
61 
62 
63  if (totalClusters>maxNumberOfClusters_) {
64  edm::LogInfo("ClusterMultiplicityFilter") << "Total number of clusters: " << totalClusters << " ==> exceeds allowed maximum of " << maxNumberOfClusters_ << " clusters";
65  result = false;
66  }
67 
68  return result;
69 }
70 
71 
73 }
74 
75 
76 // ------------ method called once each job just after ending the event loop ------------
78 }
79 
T getUntrackedParameter(std::string const &, T const &) const
ClusterMultiplicityFilter(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:243
tuple result
Definition: query.py:137
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:356
size_type size() const
Return the number of contained DetSets.
Definition: DetSetVector.h:278
virtual bool filter(edm::Event &, const edm::EventSetup &)
T const * product() const
Definition: Handle.h:74
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:341
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:106