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() : 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
SiStripMiscalibrate::Entry::sq_sum
double sq_sum
Definition: SiStripMiscalibrateHelper.h:39
SiStripMiscalibrate::Smearings::setSmearing
void setSmearing(bool doScale, bool doSmear, double the_scaleFactor, double the_smearFactor)
Definition: SiStripMiscalibrateHelper.h:54
TrackerTopology
Definition: TrackerTopology.h:16
SiStripMiscalibrate::Entry::mean_rms
double mean_rms()
Definition: SiStripMiscalibrateHelper.h:23
SiStripMiscalibrate::Smearings::~Smearings
~Smearings()
Definition: SiStripMiscalibrateHelper.h:52
SiStripMiscalibrate::Smearings
Definition: SiStripMiscalibrateHelper.h:45
SiStripMiscalibrate::Smearings::m_scaleFactor
double m_scaleFactor
Definition: SiStripMiscalibrateHelper.h:63
SiStripMiscalibrate::Entry::add
void add(double val)
Definition: SiStripMiscalibrateHelper.h:25
SiStripMiscalibrate::Smearings::Smearings
Smearings()
Definition: SiStripMiscalibrateHelper.h:46
DetId
Definition: DetId.h:17
TrackerTopology.h
sistripsummary::TrackerRegion
TrackerRegion
Definition: SiStripSummary.h:19
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
SiStripMiscalibrate::Smearings::m_doScale
bool m_doScale
Definition: SiStripMiscalibrateHelper.h:61
TrackerMap
Definition: TrackerMap.h:76
SiStripMiscalibrate::Entry::entries
long int entries
Definition: SiStripMiscalibrateHelper.h:38
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiStripMiscalibrate::getTruncatedRange
std::pair< float, float > getTruncatedRange(const TrackerMap *theMap)
Definition: SiStripMiscalibrateHelper.cc:87
SiStripSummary.h
SiStripMiscalibrate::Entry::reset
void reset()
Definition: SiStripMiscalibrateHelper.h:31
SiStripMiscalibrate::Entry::sum
double sum
Definition: SiStripMiscalibrateHelper.h:39
SiStripMiscalibrate::Entry::std_dev
double std_dev()
Definition: SiStripMiscalibrateHelper.h:19
SiStripMiscalibrate::Smearings::m_smearFactor
double m_smearFactor
Definition: SiStripMiscalibrateHelper.h:64
SiStripMiscalibrate
Definition: SiStripMiscalibrateHelper.h:9
TrackerMap.h
heppy_batch.val
val
Definition: heppy_batch.py:351
SiStripMiscalibrate::Smearings::m_doSmear
bool m_doSmear
Definition: SiStripMiscalibrateHelper.h:62
HLT_2018_cff.region
region
Definition: HLT_2018_cff.py:81479
SiStripMiscalibrate::Entry::Entry
Entry()
Definition: SiStripMiscalibrateHelper.h:16
SiStripMiscalibrate::getRegionFromString
sistripsummary::TrackerRegion getRegionFromString(std::string region)
Definition: SiStripMiscalibrateHelper.cc:8
SiStripMiscalibrate::Entry::mean
double mean()
Definition: SiStripMiscalibrateHelper.h:18
SiStripMiscalibrate::Entry
Definition: SiStripMiscalibrateHelper.h:14
SiStripMiscalibrate::getRegionsFromDetId
std::vector< sistripsummary::TrackerRegion > getRegionsFromDetId(const TrackerTopology *m_trackerTopo, DetId detid)
Definition: SiStripMiscalibrateHelper.cc:38