Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:57:29

0001 #ifndef DQMOffline_Alignment_DiMuonMassBiasClient_h
0002 #define DQMOffline_Alignment_DiMuonMassBiasClient_h
0003 // -*- C++ -*-
0004 //
0005 // Package:    DQMOffline/Alignment
0006 // Class  :    DiMuonMassBiasClient
0007 //
0008 // DQM class to plot di-muon mass bias in different kinematics bins
0009 
0010 // system includes
0011 #include <string>
0012 
0013 // user includes
0014 #include "DQMServices/Core/interface/DQMEDHarvester.h"
0015 #include "DQMServices/Core/interface/DQMStore.h"
0016 #include "DataFormats/GeometryCommonDetAlgo/interface/Measurement1D.h"
0017 #include "FWCore/Framework/interface/ESHandle.h"
0018 #include "FWCore/Framework/interface/EventSetup.h"
0019 #include "FWCore/Framework/interface/LuminosityBlock.h"
0020 #include "FWCore/Framework/interface/MakerMacros.h"
0021 #include "FWCore/Framework/interface/Run.h"
0022 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0023 
0024 namespace diMuonMassBias {
0025 
0026   struct fitOutputs {
0027   public:
0028     fitOutputs(const Measurement1D& bias, const Measurement1D& width) : m_bias(bias), m_width(width) {}
0029 
0030     // getters
0031     const Measurement1D getBias() { return m_bias; }
0032     const Measurement1D getWidth() { return m_width; }
0033     const bool isInvalid() {
0034       return (m_bias.value() == 0.f && m_bias.error() == 0.f && m_width.value() == 0.f && m_width.error() == 0.f);
0035     }
0036 
0037   private:
0038     Measurement1D m_bias;
0039     Measurement1D m_width;
0040   };
0041 
0042   // helper functions to fill arrays from vectors
0043   inline void fillArrayF(float* x, const edm::ParameterSet& cfg, const char* name) {
0044     auto v = cfg.getParameter<std::vector<double>>(name);
0045     assert(v.size() == 3);
0046     std::copy(std::begin(v), std::end(v), x);
0047   }
0048 
0049   inline void fillArrayI(int* x, const edm::ParameterSet& cfg, const char* name) {
0050     auto v = cfg.getParameter<std::vector<int>>(name);
0051     assert(v.size() == 3);
0052     std::copy(std::begin(v), std::end(v), x);
0053   }
0054 
0055   static constexpr int minimumHits = 10;
0056 
0057 }  // namespace diMuonMassBias
0058 
0059 class DiMuonMassBiasClient : public DQMEDHarvester {
0060 public:
0061   /// Constructor
0062   DiMuonMassBiasClient(const edm::ParameterSet& ps);
0063 
0064   /// Destructor
0065   ~DiMuonMassBiasClient() override;
0066 
0067   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0068 
0069 protected:
0070   /// BeginJob
0071   void beginJob(void) override;
0072 
0073   /// BeginRun
0074   void beginRun(edm::Run const& run, edm::EventSetup const& eSetup) override;
0075 
0076   /// EndJob
0077   void dqmEndJob(DQMStore::IBooker& ibooker_, DQMStore::IGetter& igetter_) override;
0078 
0079 private:
0080   /// book MEs
0081   void bookMEs(DQMStore::IBooker& ibooker);
0082   void getMEsToHarvest(DQMStore::IGetter& igetter);
0083   diMuonMassBias::fitOutputs fitLineShape(TH1* hist, const bool& fitBackground = false) const;
0084 
0085   // data members
0086   const std::string TopFolder_;
0087   const bool fitBackground_;
0088   const bool useRooCBShape_;
0089   const bool useRooCMSShape_;
0090   const bool debugMode_;
0091 
0092   float meanConfig_[3];  /* parmaeters for the fit: mean */
0093   float widthConfig_[3]; /* parameters for the fit: width */
0094   float sigmaConfig_[3]; /* parameters for the fit: sigma */
0095 
0096   // list of histograms to harvest
0097   std::vector<std::string> MEtoHarvest_;
0098 
0099   // the histograms to be filled
0100   std::map<std::string, MonitorElement*> meanProfiles_;
0101   std::map<std::string, MonitorElement*> widthProfiles_;
0102 
0103   // the histograms than need to be fit and displays
0104   std::map<std::string, MonitorElement*> harvestTargets_;
0105 };
0106 #endif