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 
6 
8 
11  ClusterChecker(conf, iC)
12 {}
13 
16  doACheck_(conf.getParameter<bool>("doClusterCheck")),
17  selector_(conf.getParameter<bool>("doClusterCheck") && conf.existsAs<std::string>("cut") ?
18  conf.getParameter<std::string>("cut") :
19  "")
20 {
21  if (doACheck_){
22  clusterCollectionInputTag_ = conf.getParameter<edm::InputTag>("ClusterCollectionLabel");
23  pixelClusterCollectionInputTag_ = conf.getParameter<edm::InputTag>("PixelClusterCollectionLabel");
26  maxNrOfCosmicClusters_ = conf.getParameter<unsigned int>("MaxNumberOfCosmicClusters");
27  maxNrOfPixelClusters_ = conf.getParameter<unsigned int>("MaxNumberOfPixelClusters");
28  if (conf.existsAs<uint32_t>("DontCountDetsAboveNClusters")) {
29  ignoreDetsAboveNClusters_ = conf.getParameter<uint32_t>("DontCountDetsAboveNClusters");
30  } else {
32  }
33  }
34 }
35 
36 
38 {
39 }
40 
42 {
43  if (!doACheck_) return 0;
44 
45  // get special input for cosmic cluster multiplicity filter
47  e.getByToken(token_sc, clusterDSV);
49  if (!clusterDSV.failedToGet()) {
50  const edmNew::DetSetVector<SiStripCluster> & input = *clusterDSV;
51 
52  if (ignoreDetsAboveNClusters_ == 0) {
53  totals.strip = input.dataSize();
54  totals.stripdets = input.size();
55  } else {
56  //loop over detectors
57  totals.strip = 0;
58  totals.stripdets = 0;
59  edmNew::DetSetVector<SiStripCluster>::const_iterator DSViter=input.begin(), DSViter_end=input.end();
60  for (; DSViter!=DSViter_end; DSViter++ ) {
61  size_t siz = DSViter->size();
62  if (siz > ignoreDetsAboveNClusters_) continue;
63  totals.strip += siz;
64  totals.stripdets++;
65  }
66  }
67  }
68  else{
70  e.getByToken(token_sc, lazyGH);
71  totals.stripdets = 0; // don't know how to count this online
72  if (!lazyGH.failedToGet()){
73  totals.strip = lazyGH->size();
74  }else{
75  //say something's wrong.
76  edm::LogError("ClusterChecker")<<"could not get any SiStrip cluster collections of type edm::DetSetVector<SiStripCluster> or edm::LazyGetter<SiStripCluster, with label: "<<clusterCollectionInputTag_;
77  totals.strip = 999999;
78  }
79  }
80  if (totals.strip > int(maxNrOfCosmicClusters_)) return totals.strip;
81 
82  // get special input for pixel cluster multiplicity filter
84  e.getByToken(token_pc, pixelClusterDSV);
85  if (!pixelClusterDSV.failedToGet()) {
86  const edmNew::DetSetVector<SiPixelCluster> & input = *pixelClusterDSV;
87 
88  if (ignoreDetsAboveNClusters_ == 0) {
89  totals.pixel = input.dataSize();
90  totals.pixeldets = input.size();
91  } else {
92  //loop over detectors
93  totals.pixel = 0;
94  totals.pixeldets = 0;
95  edmNew::DetSetVector<SiPixelCluster>::const_iterator DSViter=input.begin(), DSViter_end=input.end();
96  for (; DSViter!=DSViter_end; DSViter++ ) {
97  size_t siz = DSViter->size();
98  if (siz > ignoreDetsAboveNClusters_) continue;
99  totals.pixel += siz;
100  totals.pixeldets++;
101  }
102  }
103  }
104  else{
105  //say something's wrong.
106  edm::LogError("ClusterChecker")<<"could not get any SiPixel cluster collections of type edm::DetSetVector<SiPixelCluster> with label: "<<pixelClusterCollectionInputTag_;
107  totals.pixel = 999999;
108  }
109  if (totals.pixel > int(maxNrOfPixelClusters_)) return totals.pixel;
110 
111  if (!selector_(totals)) return totals.strip;
112  return 0;
113 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
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
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:184
edm::InputTag clusterCollectionInputTag_
StringCutObjectSelector< reco::utils::ClusterTotals > selector_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
unsigned int maxNrOfPixelClusters_
static std::string const input
Definition: EdmProvDump.cc:44
int pixel
number of strip clusters
unsigned int maxNrOfCosmicClusters_
size_t tooManyClusters(const edm::Event &e) const
unsigned int ignoreDetsAboveNClusters_
tuple conf
Definition: dbtoconf.py:185
bool failedToGet() const
Definition: HandleBase.h:80
edm::InputTag pixelClusterCollectionInputTag_
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > token_pc
size_type size() const
const_iterator end(bool update=true) const
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > token_sc
const_iterator begin(bool update=true) const