CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ClusterChecker.cc
Go to the documentation of this file.
2 
10 
12 
14  doACheck_(conf.getParameter<bool>("doClusterCheck")),
15  selector_(conf.getParameter<bool>("doClusterCheck") && conf.existsAs<std::string>("cut") ?
16  conf.getParameter<std::string>("cut") :
17  "")
18 {
19  if (doACheck_){
20  clusterCollectionInputTag_ = conf.getParameter<edm::InputTag>("ClusterCollectionLabel");
21  pixelClusterCollectionInputTag_ = conf.getParameter<edm::InputTag>("PixelClusterCollectionLabel");
22  maxNrOfCosmicClusters_ = conf.getParameter<unsigned int>("MaxNumberOfCosmicClusters");
23  maxNrOfPixelClusters_ = conf.getParameter<unsigned int>("MaxNumberOfPixelClusters");
24  if (conf.existsAs<uint32_t>("DontCountDetsAboveNClusters")) {
25  ignoreDetsAboveNClusters_ = conf.getParameter<uint32_t>("DontCountDetsAboveNClusters");
26  } else {
28  }
29  }
30 }
31 
32 
34 {
35 }
36 
38 {
39  if (!doACheck_) return 0;
40 
41  // get special input for cosmic cluster multiplicity filter
45  if (!clusterDSV.failedToGet()) {
46  const edmNew::DetSetVector<SiStripCluster> & input = *clusterDSV;
47 
48  if (ignoreDetsAboveNClusters_ == 0) {
49  totals.strip = input.dataSize();
50  totals.stripdets = input.size();
51  } else {
52  //loop over detectors
53  totals.strip = 0;
54  totals.stripdets = 0;
55  edmNew::DetSetVector<SiStripCluster>::const_iterator DSViter=input.begin(), DSViter_end=input.end();
56  for (; DSViter!=DSViter_end; DSViter++ ) {
57  size_t siz = DSViter->size();
58  if (siz > ignoreDetsAboveNClusters_) continue;
59  totals.strip += siz;
60  totals.stripdets++;
61  }
62  }
63  }
64  else{
67  totals.stripdets = 0; // don't know how to count this online
68  if (!lazyGH.failedToGet()){
69  totals.strip = lazyGH->size();
70  }else{
71  //say something's wrong.
72  edm::LogError("ClusterChecker")<<"could not get any SiStrip cluster collections of type edm::DetSetVector<SiStripCluster> or edm::LazyGetter<SiStripCluster, with label: "<<clusterCollectionInputTag_;
73  totals.strip = 999999;
74  }
75  }
76  if (totals.strip > int(maxNrOfCosmicClusters_)) return totals.strip;
77 
78  // get special input for pixel cluster multiplicity filter
80  e.getByLabel(pixelClusterCollectionInputTag_, pixelClusterDSV);
81  if (!pixelClusterDSV.failedToGet()) {
82  const edmNew::DetSetVector<SiPixelCluster> & input = *pixelClusterDSV;
83 
84  if (ignoreDetsAboveNClusters_ == 0) {
85  totals.pixel = input.dataSize();
86  totals.pixeldets = input.size();
87  } else {
88  //loop over detectors
89  totals.pixel = 0;
90  totals.pixeldets = 0;
91  edmNew::DetSetVector<SiPixelCluster>::const_iterator DSViter=input.begin(), DSViter_end=input.end();
92  for (; DSViter!=DSViter_end; DSViter++ ) {
93  size_t siz = DSViter->size();
94  if (siz > ignoreDetsAboveNClusters_) continue;
95  totals.pixel += siz;
96  totals.pixeldets++;
97  }
98  }
99  }
100  else{
101  //say something's wrong.
102  edm::LogError("ClusterChecker")<<"could not get any SiPixel cluster collections of type edm::DetSetVector<SiPixelCluster> with label: "<<pixelClusterCollectionInputTag_;
103  totals.pixel = 999999;
104  }
105  if (totals.pixel > int(maxNrOfPixelClusters_)) return totals.pixel;
106 
107  if (!selector_(totals)) return totals.strip;
108  return 0;
109 }
T getParameter(std::string const &) const
int stripdets
number of pixel clusters
int pixeldets
number of strip detectors with at least one cluster
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const_iterator begin() const
size_type dataSize() const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:187
edm::InputTag clusterCollectionInputTag_
StringCutObjectSelector< reco::utils::ClusterTotals > selector_
ClusterChecker(const edm::ParameterSet &conf)
unsigned int maxNrOfPixelClusters_
int pixel
number of strip clusters
unsigned int maxNrOfCosmicClusters_
size_t tooManyClusters(const edm::Event &e) const
unsigned int ignoreDetsAboveNClusters_
const_iterator end() const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
tuple conf
Definition: dbtoconf.py:185
bool failedToGet() const
Definition: HandleBase.h:80
edm::InputTag pixelClusterCollectionInputTag_
size_type size() const