Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:37:25

0001 #ifndef PhysicsTools_Utilities_interface_Lumi3DReWeighting_h
0002 #define PhysicsTools_Utilities_interface_Lumi3DReWeighting_h
0003 
0004 /**
0005   \class    Lumi3DReWeighting Lumi3DReWeighting.h "PhysicsTools/Utilities/interface/Lumi3DReWeighting.h"
0006   \brief    Class to provide lumi weighting for analyzers to weight "flat-to-N" MC samples to data
0007 
0008   This class will trivially take two histograms:
0009   1. The generated "flat-to-N" distributions from a given processing
0010   2. A histogram generated from the "estimatePileup" macro here:
0011 
0012   https://twiki.cern.ch/twiki/bin/view/CMS/LumiCalc#How_to_use_script_estimatePileup
0013 
0014   \author Mike Hildreth
0015 */
0016 
0017 #include "TH1.h"
0018 #include "TFile.h"
0019 #include <cmath>
0020 #include <string>
0021 
0022 #include <vector>
0023 
0024 namespace edm {
0025   class EventBase;
0026   class Lumi3DReWeighting {
0027   public:
0028     Lumi3DReWeighting(std::string generatedFile,
0029                       std::string dataFile,
0030                       std::string GenHistName,
0031                       std::string DataHistName,
0032                       std::string WeightOutputFile);
0033 
0034     Lumi3DReWeighting(const std::vector<float>& MC_distr,
0035                       const std::vector<float>& Lumi_distr,
0036                       std::string WeightOutputFile);
0037 
0038     Lumi3DReWeighting() {}
0039 
0040     double weight3D(const edm::EventBase& e);
0041 
0042     double weight3D(int, int, int);
0043 
0044     void weight3D_set(std::string generatedFile,
0045                       std::string dataFile,
0046                       std::string GenHistName,
0047                       std::string DataHistName,
0048                       std::string WeightOutputFile);
0049 
0050     void weight3D_init(float Scale);
0051 
0052     void weight3D_init(std::string WeightFileName);  // initialize from root file
0053 
0054     void weight3D_init(std::string MCFileName, std::string DataFileName);  // initialize from root files
0055 
0056   protected:
0057     std::string generatedFileName_;
0058     std::string dataFileName_;
0059     std::string GenHistName_;
0060     std::string DataHistName_;
0061     std::string weightFileName_;
0062     std::shared_ptr<TFile> generatedFile_;
0063     std::shared_ptr<TFile> dataFile_;
0064     std::shared_ptr<TH1> weights_;
0065 
0066     //keep copies of normalized distributions:
0067 
0068     std::shared_ptr<TH1> MC_distr_;
0069     std::shared_ptr<TH1> Data_distr_;
0070 
0071     double Weight3D_[50][50][50];
0072   };
0073 }  // namespace edm
0074 
0075 #endif