Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:27

0001 #ifndef CONDTOOLS_SISTRIP_SISTRIPMISCALIBRATEHELPER
0002 #define CONDTOOLS_SISTRIP_SISTRIPMISCALIBRATEHELPER
0003 
0004 #include <numeric>
0005 #include "CommonTools/TrackerMap/interface/TrackerMap.h"
0006 #include "CondFormats/SiStripObjects/interface/SiStripSummary.h"
0007 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0008 
0009 namespace SiStripMiscalibrate {
0010 
0011   /*-----------------
0012   / Auxilliary class to store averages and std. deviations
0013   /------------------*/
0014   class Entry {
0015   public:
0016     Entry() : entries(0), sum(0), sq_sum(0) {}
0017 
0018     double mean() { return sum / entries; }
0019     double std_dev() {
0020       double tmean = mean();
0021       return (sq_sum - entries * tmean * tmean) > 0 ? sqrt((sq_sum - entries * tmean * tmean) / (entries - 1)) : 0.;
0022     }
0023     double mean_rms() { return std_dev() / sqrt(entries); }
0024 
0025     void add(double val) {
0026       entries++;
0027       sum += val;
0028       sq_sum += val * val;
0029     }
0030 
0031     void reset() {
0032       entries = 0;
0033       sum = 0;
0034       sq_sum = 0;
0035     }
0036 
0037   private:
0038     long int entries;
0039     double sum, sq_sum;
0040   };
0041 
0042   /*-----------------
0043   / Auxilliary struct to store scale & smear factors
0044   /------------------*/
0045   struct Smearings {
0046     Smearings() {
0047       m_doScale = false;
0048       m_doSmear = false;
0049       m_scaleFactor = 1.;
0050       m_smearFactor = 0.;
0051     }
0052     ~Smearings() {}
0053 
0054     void setSmearing(bool doScale, bool doSmear, double the_scaleFactor, double the_smearFactor) {
0055       m_doScale = doScale;
0056       m_doSmear = doSmear;
0057       m_scaleFactor = the_scaleFactor;
0058       m_smearFactor = the_smearFactor;
0059     }
0060 
0061     bool m_doScale;
0062     bool m_doSmear;
0063     double m_scaleFactor;
0064     double m_smearFactor;
0065   };
0066 
0067   /*-----------------
0068   / Methods used in the miscalibration tools
0069   /------------------*/
0070 
0071   std::pair<float, float> getTruncatedRange(const TrackerMap* theMap);
0072   sistripsummary::TrackerRegion getRegionFromString(std::string region);
0073   std::vector<sistripsummary::TrackerRegion> getRegionsFromDetId(const TrackerTopology* m_trackerTopo, DetId detid);
0074 
0075 };  // namespace SiStripMiscalibrate
0076 
0077 #endif