CMS 3D CMS Logo

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():
17  entries(0),
18  sum(0),
19  sq_sum(0){}
20 
21  double mean() {return sum / entries;}
22  double std_dev() {
23  double tmean = mean();
24  return (sq_sum - entries*tmean*tmean)>0 ? sqrt((sq_sum - entries*tmean*tmean)/(entries-1)) : 0.;
25  }
26  double mean_rms() { return std_dev()/sqrt(entries); }
27 
28  void add(double val){
29  entries++;
30  sum += val;
31  sq_sum += val*val;
32  }
33 
34  void reset() {
35  entries = 0;
36  sum = 0;
37  sq_sum = 0;
38  }
39  private:
40  long int entries;
41  double sum, sq_sum;
42  };
43 
44  /*-----------------
45  / Auxilliary struct to store scale & smear factors
46  /------------------*/
47  struct Smearings{
49  m_doScale = false;
50  m_doSmear = false;
51  m_scaleFactor = 1.;
52  m_smearFactor = 0.;
53  }
55 
56  void setSmearing(bool doScale,bool doSmear,double the_scaleFactor,double the_smearFactor){
57  m_doScale = doScale;
58  m_doSmear = doSmear;
59  m_scaleFactor = the_scaleFactor;
60  m_smearFactor = the_smearFactor;
61  }
62 
63  bool m_doScale;
64  bool m_doSmear;
65  double m_scaleFactor;
66  double m_smearFactor;
67  };
68 
69  /*-----------------
70  / Methods used in the miscalibration tools
71  /------------------*/
72 
73  std::pair<float,float> getTruncatedRange(const TrackerMap* theMap);
75  std::vector<sistripsummary::TrackerRegion> getRegionsFromDetId(const TrackerTopology* m_trackerTopo,DetId detid);
76 
77 };
78 
79 #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:18
Definition: DetId.h:18
void setSmearing(bool doScale, bool doSmear, double the_scaleFactor, double the_smearFactor)
std::pair< float, float > getTruncatedRange(const TrackerMap *theMap)