CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SiStripMiscalibrateHelper.h
Go to the documentation of this file.
1 #ifndef CONDTOOLS_SISTRIP_SISTRIPMISCALIBRATEHELPER
2 #define CONDTOOLS_SISTRIP_SISTRIPMISCALIBRATEHELPER
3 
4 #include <numeric>
8 
9 namespace SiStripMiscalibrate {
10 
11  /*-----------------
12  / Auxilliary class to store averages and std. deviations
13  /------------------*/
14  class Entry {
15  public:
16  Entry() : entries(0), sum(0), sq_sum(0) {}
17 
18  double mean() { return sum / entries; }
19  double std_dev() {
20  double tmean = mean();
21  return (sq_sum - entries * tmean * tmean) > 0 ? sqrt((sq_sum - entries * tmean * tmean) / (entries - 1)) : 0.;
22  }
23  double mean_rms() { return std_dev() / sqrt(entries); }
24 
25  void add(double val) {
26  entries++;
27  sum += val;
28  sq_sum += val * val;
29  }
30 
31  void reset() {
32  entries = 0;
33  sum = 0;
34  sq_sum = 0;
35  }
36 
37  private:
38  long int entries;
39  double sum, sq_sum;
40  };
41 
42  /*-----------------
43  / Auxilliary struct to store scale & smear factors
44  /------------------*/
45  struct Smearings {
47  m_doScale = false;
48  m_doSmear = false;
49  m_scaleFactor = 1.;
50  m_smearFactor = 0.;
51  }
53 
54  void setSmearing(bool doScale, bool doSmear, double the_scaleFactor, double the_smearFactor) {
55  m_doScale = doScale;
56  m_doSmear = doSmear;
57  m_scaleFactor = the_scaleFactor;
58  m_smearFactor = the_smearFactor;
59  }
60 
61  bool m_doScale;
62  bool m_doSmear;
63  double m_scaleFactor;
64  double m_smearFactor;
65  };
66 
67  /*-----------------
68  / Methods used in the miscalibration tools
69  /------------------*/
70 
71  std::pair<float, float> getTruncatedRange(const TrackerMap* theMap);
73  std::vector<sistripsummary::TrackerRegion> getRegionsFromDetId(const TrackerTopology* m_trackerTopo, DetId detid);
74 
75 }; // namespace SiStripMiscalibrate
76 
77 #endif
std::vector< sistripsummary::TrackerRegion > getRegionsFromDetId(const TrackerTopology *m_trackerTopo, DetId detid)
sistripsummary::TrackerRegion getRegionFromString(std::string region)
T sqrt(T t)
Definition: SSEVec.h:19
Definition: DetId.h:17
void setSmearing(bool doScale, bool doSmear, double the_scaleFactor, double the_smearFactor)
std::pair< float, float > getTruncatedRange(const TrackerMap *theMap)