test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 {
21 }
22 
23 
26  hitEnergySumMap_.clear();
27  noiseHits_ = 0;
28  // store the energy of each hit in a map
29  MixCollection<PCaloHit>::MixItr hitItr = hits.begin();
31  for( ; hitItr != last; ++hitItr)
32  {
33  if(hitFilter_ == 0 || hitFilter_->accepts(*hitItr)) {
34  int id = hitItr->id();
35  //double samplingFactor = simParameterMap_->simParameters(DetId(id)).samplingFactor();
36  double samplingFactor = 1.;
37  double energy = hitItr->energy() * samplingFactor;
38 
39  // add it to the map
40  std::map<int, double>::iterator mapItr = hitEnergySumMap_.find(id);
41  if(mapItr == hitEnergySumMap_.end()) {
43  } else {
44  mapItr->second += energy;
45  }
46  }
47  }
48 }
49 
50 
51 void CaloHitAnalyzer::analyze(int id, double recEnergy) {
52  if(recEnergy > hitEnergyThreshold_) {
53  std::map<int, double>::iterator mapItr = hitEnergySumMap_.find(id);
54  if(mapItr == hitEnergySumMap_.end()) {
55  ++noiseHits_;
56  } else {
57  // keep statistics of the rec energy / sim energy
58  summary_.addEntry(recEnergy/mapItr->second);
59  }
60  }
61 }
62 
double hitEnergyThreshold_
CaloHitAnalyzer(const std::string &name, double hitEnergyThreshold, const CaloVSimParameterMap *parameterMap, const CaloVHitFilter *filter=0)
void analyze(int detId, double recEnergy)
to be called for each RecHit
CaloValidationStatistics summary_
const CaloVHitFilter * hitFilter_
iterator end()
void fillHits(MixCollection< PCaloHit > &hits)
should be called each event
virtual bool accepts(const PCaloHit &hit) const =0
iterator begin()
void addEntry(float value, float weight=1.)
std::map< int, double > hitEnergySumMap_