CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CaloHitAnalyzer.cc
Go to the documentation of this file.
7 
8 #include <iostream>
9 
11  double hitEnergyThreshold,
12  const CaloVSimParameterMap *parameterMap,
13  const CaloVHitFilter *filter)
14  : hitEnergySumMap_(),
15  hitEnergyThreshold_(hitEnergyThreshold),
16  simParameterMap_(parameterMap),
17  hitFilter_(filter),
18  summary_(name, 1., 0.),
19  noiseHits_(0) {}
20 
23  hitEnergySumMap_.clear();
24  noiseHits_ = 0;
25  // store the energy of each hit in a map
26  MixCollection<PCaloHit>::MixItr hitItr = hits.begin();
28  for (; hitItr != last; ++hitItr) {
29  if (hitFilter_ == nullptr || hitFilter_->accepts(*hitItr)) {
30  int id = hitItr->id();
31  // double samplingFactor =
32  // simParameterMap_->simParameters(DetId(id)).samplingFactor();
33  double samplingFactor = 1.;
34  double energy = hitItr->energy() * samplingFactor;
35 
36  // add it to the map
37  std::map<int, double>::iterator mapItr = hitEnergySumMap_.find(id);
38  if (mapItr == hitEnergySumMap_.end()) {
40  } else {
41  mapItr->second += energy;
42  }
43  }
44  }
45 }
46 
47 void CaloHitAnalyzer::analyze(int id, double recEnergy) {
48  if (recEnergy > hitEnergyThreshold_) {
49  std::map<int, double>::iterator mapItr = hitEnergySumMap_.find(id);
50  if (mapItr == hitEnergySumMap_.end()) {
51  ++noiseHits_;
52  } else {
53  // keep statistics of the rec energy / sim energy
54  summary_.addEntry(recEnergy / mapItr->second);
55  }
56  }
57 }
double hitEnergyThreshold_
void analyze(int detId, double recEnergy)
to be called for each RecHit
CaloHitAnalyzer(const std::string &name, double hitEnergyThreshold, const CaloVSimParameterMap *parameterMap, const CaloVHitFilter *filter=nullptr)
CaloValidationStatistics summary_
uint16_t *__restrict__ id
const CaloVHitFilter * hitFilter_
void fillHits(MixCollection< PCaloHit > &hits)
should be called each event
iterator end() const
virtual bool accepts(const PCaloHit &hit) const =0
void addEntry(float value, float weight=1.)
std::map< int, double > hitEnergySumMap_
tuple last
Definition: dqmdumpme.py:56
iterator begin() const