-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding class to return FR weights in ZHtautau analysis #152
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef FRWEIGHTS_H | ||
#define FRWEIGHTS_H | ||
|
||
#include <string> | ||
#include "TFile.h" | ||
#include "TGraphErrors.h" | ||
|
||
class FRWeights | ||
{ | ||
public: | ||
FRWeights(); | ||
~FRWeights(); | ||
|
||
bool init(const std::string& WeightsFileName); | ||
double getWeight(const std::string& cat ,const std::string& bin, const std::string& var,const std::string& wrt ,const double& pT); | ||
|
||
private: | ||
TFile* WeightsFile; | ||
|
||
}; | ||
|
||
#endif | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include "UserCode/llvv_fwk/interface/FRWeights.h" | ||
#include <TFile.h> | ||
#include <TSystem.h> | ||
#include <math.h> | ||
#include <vector> | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
/*****************************************************************/ | ||
FRWeights::FRWeights() | ||
/*****************************************************************/ | ||
{ | ||
} | ||
|
||
/*****************************************************************/ | ||
FRWeights::~FRWeights() | ||
/*****************************************************************/ | ||
{ | ||
} | ||
|
||
/*****************************************************************/ | ||
bool FRWeights::init(const string& WeightsFileName) | ||
/*****************************************************************/ | ||
{ | ||
WeightsFile = TFile::Open(WeightsFileName.c_str()); | ||
if(!WeightsFile) { | ||
cout<<"ERROR: Cannot open weights file "<<WeightsFileName<<"\n"; | ||
return false; | ||
} else { | ||
return true; | ||
} | ||
} | ||
|
||
/*****************************************************************/ | ||
//double FRWeights::getWeight(string cat,string bin,string var,string wrt,double pT) | ||
double FRWeights::getWeight(const std::string& cat ,const std::string& bin, const std::string& var,const std::string& wrt ,const double& pT) | ||
/*****************************************************************/ | ||
{ | ||
TGraphErrors* graph = (TGraphErrors*)WeightsFile->Get((cat+"FRWeights"+var+bin+wrt).c_str()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be move to the constructor and cached There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi Loic yes, just testing... |
||
double result=-1.; | ||
if(graph){ | ||
result=(1 - graph->Eval(pT)); | ||
} else { | ||
result = 1; | ||
} | ||
|
||
return result; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cache everything and close the file when done
otherwise we will have huge trouble with file access