Skip to content

Commit

Permalink
simplify corrections to use ROOT objects - remove old database code f…
Browse files Browse the repository at this point in the history
…rom MM
  • Loading branch information
kpedro88 committed Jan 13, 2015
1 parent 9ac1637 commit 9cf3803
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 567 deletions.
36 changes: 15 additions & 21 deletions Plotting/KCode/KBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
#include "TreeClass.h"

//custom headers for weighting
#include "../database/DataBaseManager.cc"
#include "../btag/GetBtagScale.C"

//ROOT headers
#include <TROOT.h>
#include <TFile.h>
#include <TH1.h>
#include <TH1F.h>
#include <TH2.h>
#include <TStyle.h>
#include <TLorentzVector.h>

Expand Down Expand Up @@ -983,20 +982,11 @@ void KBaseData::Build(){
class KBuilderMC : public KBuilder {
public:
//constructors
KBuilderMC() : KBuilder() { InitWeight(); }
KBuilderMC(KBase* MyBase_, TTree* tree_) : KBuilder(MyBase_,tree_) { InitWeight(); }
KBuilderMC() : KBuilder() { }
KBuilderMC(KBase* MyBase_, TTree* tree_) : KBuilder(MyBase_,tree_) { }
//destructor
virtual ~KBuilderMC() {}

//helper function
void InitWeight(){
TFile* pufile = new TFile("/data/users/pedrok/LQ2012/puWeightsLQ.root","READ"); //puWeights
puWeights = (TH1F*)pufile->Get("pileup");

dbm = new DataBaseManager(); //for muon efficiency corrections
dbm->loadDb("muID","muIDTight.db");
}

//functions for histo creation
bool Cut(){
bool goodEvent = KBuilder::Cut();
Expand All @@ -1018,9 +1008,17 @@ class KBuilderMC : public KBuilder {

//check option in case correction types are disabled globally
//(enabled by default)
if(option->Get("pucorr",true)) w *= puWeights->GetBinContent(puWeights->GetXaxis()->FindBin(trueNInteraction));

if(option->Get("mucorr",true)) w *= dbm->getDBValue("muID",fabs(MuonEta),MuonPt);
if(option->Get("pucorr",true)) {
TH1F* puWeights;
option->Get("puWeights",puWeights);
w *= puWeights->GetBinContent(puWeights->GetXaxis()->FindBin(trueNInteraction));
}

if(option->Get("mucorr",true)) {
TH2F* muIDTight;
option->Get("muIDTight",muIDTight);
w *= muIDTight->GetBinContent(muIDTight->FindBin(fabs(MuonEta),MuonPt));
}

if(option->Get("btagcorr",true)) {
int bSF = 0;
Expand All @@ -1044,11 +1042,7 @@ class KBuilderMC : public KBuilder {

return w;
}

private:
//member variables
TH1F* puWeights;
DataBaseManager* dbm;

};

void KBaseMC::Build(){
Expand Down
12 changes: 12 additions & 0 deletions Plotting/KCode/KParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,18 @@ KManager::KManager(string in, string dir) : input(in),treedir(dir),option(0),num
//final checks and initializations
MyRatio = new KSetRatio(option);
if(option->Get("calcfaketau",false)) FakeTauEstimationInit();
//store correction root files centrally
//todo: make file location and histo name configurable
if(option->Get("pucorr",true)) {
TFile* pufile = new TFile("corrections/puWeightsLQ.root","READ"); //puWeights
TH1F* puWeights = (TH1F*)pufile->Get("pileup");
option->Set("puWeights",puWeights);
}
if(option->Get("mucorr",true)) {
TFile* mufile = new TFile("corrections/muIDTight.root","READ"); //puWeights
TH1F* muIDTight = (TH1F*)mufile->Get("muIDTight");
option->Set("muIDTight",muIDTight);
}
}

#endif
Loading

0 comments on commit 9cf3803

Please sign in to comment.