-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New PU weight retrival; New weights with uncertainties
- Loading branch information
Showing
5 changed files
with
89 additions
and
5 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef PileUpWeight_h | ||
#define PileUpWeight_h | ||
|
||
/** \class PileUpWeight | ||
* | ||
* Implement PU reweighting. | ||
* | ||
*/ | ||
|
||
#include <TH1F.h> | ||
#include <TFile.h> | ||
#include <string> | ||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
#include "FWCore/ParameterSet/interface/FileInPath.h" | ||
|
||
class PileUpWeight { | ||
public: | ||
enum class PUvar : int {NOMINAL=0, VARUP=1, VARDOWN=2}; | ||
|
||
PileUpWeight(int MC, int target); | ||
|
||
float weight(float input, PUvar var = PUvar::NOMINAL); | ||
|
||
std::unique_ptr<TH1> h_nominal; | ||
std::unique_ptr<TH1> h_up; | ||
std::unique_ptr<TH1> h_down; | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "../interface/PileUpWeight.h" | ||
|
||
float PileUpWeight::weight(float input, PileUpWeight::PUvar var) { | ||
|
||
if (h_nominal != nullptr && var == PUvar::NOMINAL) { | ||
return h_nominal->GetBinContent(h_nominal->FindBin(input)); | ||
} else if (h_down != nullptr && var == PUvar::VARDOWN) { | ||
return h_down->GetBinContent(h_down->FindBin(input)); | ||
} else if (h_up != nullptr && var == PUvar::VARUP) { | ||
return h_up->GetBinContent(h_up->FindBin(input)); | ||
} else { | ||
edm::LogError("PU reweight") << "Did not find reweighting histogram to reweight variation=";// << var; | ||
return -99.; | ||
} | ||
} | ||
|
||
|
||
PileUpWeight::PileUpWeight(int MC, int target) { | ||
|
||
if (MC==2017&&target==2017) { | ||
edm::FileInPath fip("ZZAnalysis/AnalysisStep/data/PileUpWeights/puWeightsMoriond17_v2.root"); | ||
|
||
TFile *fPUWeight = TFile::Open(fip.fullPath().data(),"READ"); | ||
|
||
h_nominal.reset((TH1*)fPUWeight->Get("weights")->Clone()); | ||
h_up.reset((TH1*)fPUWeight->Get("weights_varUp")->Clone()); | ||
h_down.reset((TH1*)fPUWeight->Get("weights_varDn")->Clone()); | ||
|
||
fPUWeight->Close(); | ||
} | ||
if(h_nominal == nullptr) { | ||
edm::LogError("PU reweight") << "Did not find reweighting histogram to reweight MC=" << MC << " to data=" << target; | ||
edm::LogError("PU reweight") << "Legacy configurations are in PUReweight.cc"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters