1 |
ahart |
1.1 |
#include "OSUT3Analysis/AnaTools/interface/PUWeight.h"
|
2 |
|
|
|
3 |
|
|
PUWeight::PUWeight (const string &puFile, const string &dataPU, const string &mcPU)
|
4 |
|
|
{
|
5 |
|
|
TFile *fin = TFile::Open (puFile.c_str ());
|
6 |
|
|
TH1D *mc = (TH1D *) fin->Get (mcPU.c_str ());
|
7 |
|
|
puWeight_ = (TH1D *) fin->Get (dataPU.c_str ());
|
8 |
|
|
mc->SetDirectory (0);
|
9 |
|
|
puWeight_->SetDirectory (0);
|
10 |
|
|
mc->Scale (puWeight_->Integral () / mc->Integral ());
|
11 |
ahart |
1.3 |
TH1D *trimmedMC = new TH1D ("bla", "bla", puWeight_->GetNbinsX(), 0, puWeight_->GetNbinsX());
|
12 |
|
|
for (int bin = 1; bin <= puWeight_->GetNbinsX(); bin++)
|
13 |
|
|
trimmedMC->SetBinContent (bin, mc->GetBinContent (bin));
|
14 |
lantonel |
1.2 |
puWeight_->Divide (trimmedMC);
|
15 |
ahart |
1.1 |
fin->Close ();
|
16 |
|
|
delete mc;
|
17 |
|
|
}
|
18 |
|
|
|
19 |
|
|
PUWeight::~PUWeight ()
|
20 |
|
|
{
|
21 |
|
|
delete puWeight_;
|
22 |
|
|
}
|