Entry

Smearings

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
#ifndef CONDTOOLS_SISTRIP_SISTRIPMISCALIBRATEHELPER
#define CONDTOOLS_SISTRIP_SISTRIPMISCALIBRATEHELPER

#include <numeric>
#include "CommonTools/TrackerMap/interface/TrackerMap.h"
#include "CondFormats/SiStripObjects/interface/SiStripSummary.h"
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"

namespace SiStripMiscalibrate {

  /*-----------------
  / Auxilliary class to store averages and std. deviations
  /------------------*/
  class Entry {
  public:
    Entry() : entries(0), sum(0), sq_sum(0) {}

    double mean() { return sum / entries; }
    double std_dev() {
      double tmean = mean();
      return (sq_sum - entries * tmean * tmean) > 0 ? sqrt((sq_sum - entries * tmean * tmean) / (entries - 1)) : 0.;
    }
    double mean_rms() { return std_dev() / sqrt(entries); }

    void add(double val) {
      entries++;
      sum += val;
      sq_sum += val * val;
    }

    void reset() {
      entries = 0;
      sum = 0;
      sq_sum = 0;
    }

  private:
    long int entries;
    double sum, sq_sum;
  };

  /*-----------------
  / Auxilliary struct to store scale & smear factors
  /------------------*/
  struct Smearings {
    Smearings() {
      m_doScale = false;
      m_doSmear = false;
      m_scaleFactor = 1.;
      m_smearFactor = 0.;
    }
    ~Smearings() {}

    void setSmearing(bool doScale, bool doSmear, double the_scaleFactor, double the_smearFactor) {
      m_doScale = doScale;
      m_doSmear = doSmear;
      m_scaleFactor = the_scaleFactor;
      m_smearFactor = the_smearFactor;
    }

    bool m_doScale;
    bool m_doSmear;
    double m_scaleFactor;
    double m_smearFactor;
  };

  /*-----------------
  / Methods used in the miscalibration tools
  /------------------*/

  std::pair<float, float> getTruncatedRange(const TrackerMap* theMap);
  sistripsummary::TrackerRegion getRegionFromString(std::string region);
  std::vector<sistripsummary::TrackerRegion> getRegionsFromDetId(const TrackerTopology* m_trackerTopo, DetId detid);

};  // namespace SiStripMiscalibrate

#endif