Skip to content
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

update JRA code from latest offline case to adapt online requirement #11

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# git will ignore these files:
*.pyc
*.txt
*_cc.d
*_cc.so
*.pcm
*.root
*.pdf
*.png
__init__.py

# git will not consider these directories:
*HLTBX25JEC*
*L1Calibration*
6 changes: 3 additions & 3 deletions JetAnalyzers/bin/jet_apply_jec_x.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ int main(int argc,char**argv)
string output = cl.getValue<string> ("output", "");
string jecpath = cl.getValue<string> ("jecpath", "");
vector<string> algs = cl.getVector<string> ("algs", "");
bool L1FastJet = cl.getValue<bool> ("L1FastJet", false);
bool L1FastJet = cl.getValue<bool> ("L1FastJet", true);
vector<string> postfix = cl.getVector<string> ("postfix", "");
bool useTags = cl.getValue<bool> ("useTags", true);
bool useTags = cl.getValue<bool> ("useTags", false);
bool saveitree = cl.getValue<bool> ("saveitree", true);
bool debug = cl.getValue<bool> ("debug", false);

Expand Down Expand Up @@ -183,7 +183,7 @@ int main(int argc,char**argv)
int nevt = (debug) ? 10000 : itree->GetEntries();
for (int ievt=0;ievt<nevt;ievt++) {
if (ievt % 100000 == 0)
cout<<ievt<<endl;
cout << "Loop on events: " << ievt << endl;
itree->GetEntry(ievt);
for (unsigned int ijt=0;ijt<JRAEvt->nref;ijt++) {
corrector->setJetPt(JRAEvt->jtpt->at(ijt));
Expand Down
2 changes: 1 addition & 1 deletion JetAnalyzers/bin/jet_l2_correction_x.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ int main(int argc,char**argv)
CommandLine cl;
if (!cl.parse(argc,argv)) return 0;

bool batch = cl.getValue<bool> ("batch", false);
bool batch = cl.getValue<bool> ("batch", true);

if (!cl.partialCheck()) return 0;
cl.print();
Expand Down
4 changes: 2 additions & 2 deletions JetAnalyzers/bin/jet_l3_correction_x.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ int main(int argc,char**argv)
string input = cl.getValue<string> ("input");
string era = cl.getValue<string> ("era");
string output = cl.getValue<string> ("output","l3.root");
vector<string> formats = cl.getVector<string>("formats", "");
vector<string> formats = cl.getVector<string>("formats", "png");
vector<string> algs = cl.getVector<string>("algs", "");
bool batch = cl.getValue<bool> ("batch", false);
bool batch = cl.getValue<bool> ("batch", true);
bool logx = cl.getValue<bool> ("logx", false);
bool logy = cl.getValue<bool> ("logy", false);
string flavor = cl.getValue<string> ("flavor", "");
Expand Down
98 changes: 94 additions & 4 deletions JetAnalyzers/bin/jet_response_analyzer_x.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ TString pdgid_to_flavor_name(int pdgid);
void fill_histo(float value,float weight,float x,
const vector<float>& binsx,const vector<TH1F**>& histos);

/// fill the appropriate histogram (histos), based on x and binsx
void fill_histo(float value,float weight,float x,
const vector<float>& binsx,const vector<TH1F*>& histos);

/// fill the appropriate histogram (histos), based on pdgid, x and binsx
void fill_histo(int pdgid,float value,float weight,float x,
const vector<float>& binsx,const vector<TH1F**>& histos,
Expand All @@ -72,6 +76,11 @@ void fill_histo(float value,float weight,float x,float y,
const vector<float>& binsx,const vector<float>& binsy,
const vector<TH1F***>& histos);

/// fill the appropriate histogram (histos), based on x, y, binsx, and binsy
void fill_histo(float value,float weight,float x,float y,
const vector<float>& binsx,const vector<float>& binsy,
const vector<TH1F**>& histos);

/// fill the appropriate histogram (histos), based on pdgid, x, y, binsx, and binsy
void fill_histo(int pdgid,float value,float weight,float x,float y,
const vector<float>& binsx,const vector<float>& binsy,
Expand Down Expand Up @@ -128,6 +137,7 @@ int main(int argc,char**argv)
vector<float> binseta = cl.getVector<float> ("binseta", "");
vector<float> binsphi = cl.getVector<float> ("binsphi", "");
vector<float> binsy = cl.getVector<float> ("binsy", "");
vector<float> binsTrueNPU = cl.getVector<float> ("binsTrueNPU", "");
vector<float> binsmu = cl.getVector<float> ("binsmu", "");
vector<float> binsrho = cl.getVector<float> ("binsrho", "");
string treename = cl.getValue<string> ("treename", "t");
Expand All @@ -151,7 +161,7 @@ int main(int argc,char**argv)
bool doflavor = cl.getValue<bool> ("doflavor", false);
TString flavorDefinition = cl.getValue<TString>("flavorDefinition", "phys");
bool noabsflavors = cl.getValue<bool> ("noabsflavors", false);
float drmax = cl.getValue<float> ("drmax", 0.3);
float drmax = cl.getValue<float> ("drmax", 0.25);
float dphimin = cl.getValue<float> ("dphimin", 2.7);
bool dojetpt = cl.getValue<bool> ("dojetpt", false);
bool dorefpt = cl.getValue<bool> ("dorefpt", true);
Expand Down Expand Up @@ -394,7 +404,12 @@ int main(int argc,char**argv)
vector<TH1F****> relRspVsJetEtaRhoRefPt;
vector<TH1F***> relRspVsJetYJetPt;
vector<TH1F***> relRspVsJetYRefPt;


/// add for HLT usage: true pileup will be treated as variable
vector<TH1F*> relRspVsTrueNPU;
vector<TH1F**> relRspVsTrueNPUJetPt;
vector<TH1F**> relRspVsTrueNPURefPt;

vector<TH1F**> absRspVsJetPt;
vector<TH1F**> absRspVsRefPt;
vector<TH1F**> absRspVsRefPtBarrel;
Expand All @@ -419,7 +434,19 @@ int main(int argc,char**argv)
vector<TH1F**> phiRspVsJetPhi;
vector<TH1F***> phiRspVsJetEtaJetPt;
vector<TH1F***> phiRspVsJetEtaRefPt;


// book TrueNPU histograms
if (binsTrueNPU.size()>=2){
string hname;
if (dorelrsp&&dorefpt) {
for(unsigned int iTPU=0;iTPU<binsTrueNPU.size()-1;++iTPU){
hname = "RelRsp_"+get_suffix("TrueNPU",iTPU,binsTrueNPU);
relRspVsTrueNPU.push_back(new TH1F(hname.c_str(),";p_{T}/p_{T}^{ref}",
nbinsrelrsp,relrspmin,relrspmax));
}
}
}

// book pT histograms
if (binspt.size()>=2) {
for (unsigned int ipt=0;ipt<binspt.size()-1;++ipt) {
Expand Down Expand Up @@ -784,6 +811,46 @@ int main(int argc,char**argv)
}
}

// book TrueNPU/pT histograms
if (binsTrueNPU.size()>=2 && binspt.size()>=2){
for (unsigned int iTPU=0;iTPU<binsTrueNPU.size()-1;++iTPU){
TH1F** relRspJetPt(0);
TH1F** relRspRefPt(0);

if (dorelrsp && dojetpt) {
relRspJetPt=new TH1F*[binspt.size()-1];
}

if (dorelrsp && dorefpt) {
relRspRefPt=new TH1F*[binspt.size()-1];
}

string jetTrueNPUSuffix=get_suffix("TrueNPU",iTPU,binsTrueNPU);

for (unsigned int ipt=0;ipt<binspt.size()-1;ipt++){
string hname;

string jetPtSuffix=get_suffix("JetPt",ipt,binspt);
string refPtSuffix=get_suffix("RefPt",ipt,binspt);

if (dorelrsp && dojetpt) {
hname="RelRsp_"+jetTrueNPUSuffix+"_"+jetPtSuffix;
relRspJetPt[ipt]=new TH1F(hname.c_str(),";p_{T}/p_{T}^{ref}",
nbinsrelrsp,relrspmin,relrspmax);
}

if (dorelrsp && dorefpt) {
hname="RelRsp_"+jetTrueNPUSuffix+"_"+refPtSuffix;
relRspRefPt[ipt]=new TH1F(hname.c_str(),";p_{T}/p_{T}^{ref}",
nbinsrelrsp,relrspmin,relrspmax);
}
}

if (dorelrsp && dojetpt) relRspVsTrueNPUJetPt.push_back(relRspJetPt);
if (dorelrsp && dorefpt) relRspVsTrueNPURefPt.push_back(relRspRefPt);
}
}

// book eta/pT histograms
if (binspt.size()>=2&&binseta.size()>=2) {

Expand Down Expand Up @@ -1312,6 +1379,7 @@ int main(int argc,char**argv)
tree->GetEntry(ientry);

float mu = JRAEvt->tnpus->at(itInd);
float TrueNPU = JRAEvt->tnpus->at(0);

if (nrefmax>0) JRAEvt->nref = std::min((int)JRAEvt->nref,nrefmax);
for (unsigned char iref=0;iref<JRAEvt->nref;iref++) {
Expand Down Expand Up @@ -1569,6 +1637,7 @@ int main(int argc,char**argv)
}
if (dorefpt) {
fill_histo(relrsp,weight,refpt,binspt,relRspVsRefPt);
fill_histo(relrsp,weight,TrueNPU,binsTrueNPU,relRspVsTrueNPU); //Fill TrueNPU hist!!!
if (doflavor) fill_histo(pdgid,relrsp,flavorWeight,
refpt,binspt,relRspVsRefPt,
noabsflavors);
Expand All @@ -1591,6 +1660,7 @@ int main(int argc,char**argv)

if (dojetpt) {
fill_histo(relrsp,weight,eta,pt,binseta,binspt,relRspVsJetEtaJetPt);
fill_histo(relrsp,weight,TrueNPU,pt,binsTrueNPU,binspt,relRspVsTrueNPUJetPt);
if (domu) fill_histo(relrsp, weight, eta, mu, pt, binseta, binsmu, binspt, relRspVsJetEtaMuJetPt);
if (dorho) fill_histo(relrsp, weight, eta, JRAEvt->rho, pt, binseta, binsrho, binspt, relRspVsJetEtaRhoJetPt);

Expand All @@ -1608,6 +1678,7 @@ int main(int argc,char**argv)
}
if (dorefpt) {
fill_histo(relrsp,weight,eta,refpt,binseta,binspt,relRspVsJetEtaRefPt);
fill_histo(relrsp,weight,TrueNPU,refpt,binsTrueNPU,binspt,relRspVsTrueNPURefPt);
if (domu) fill_histo(relrsp, weight, eta, mu, refpt, binseta, binsmu, binspt, relRspVsJetEtaMuRefPt);
if (dorho) fill_histo(relrsp, weight, eta, JRAEvt->rho, refpt, binseta, binsrho, binspt, relRspVsJetEtaRhoRefPt);

Expand Down Expand Up @@ -1809,7 +1880,6 @@ int get_index(float x,const vector<float>& binsx)
return -1;
}


//______________________________________________________________________________
vector<string> get_flavors(bool noabsflavors)
{
Expand Down Expand Up @@ -1883,6 +1953,14 @@ void fill_histo(float value,float weight,float x,
if (ix>=0) histos[ix][0]->Fill(value,weight);
}

//______________________________________________________________________________
void fill_histo(float value,float weight,float x,
const vector<float>& binsx, const vector<TH1F*>& histos)
{
if (binsx.size()==0) return;
int ix=get_index(x,binsx);
if (ix>=0) histos[ix]->Fill(value,weight);
}

//______________________________________________________________________________
void fill_histo(int pdgid,float value,float weight,float x,const vector<float>& binsx,
Expand Down Expand Up @@ -1948,6 +2026,18 @@ void fill_histo(float value,float weight,float x,float y,
}


//______________________________________________________________________________
void fill_histo(float value,float weight,float x,float y,
const vector<float>& binsx,const vector<float>& binsy,
const vector<TH1F**>& histos)
{
if (binsx.size()==0||binsy.size()==0) return;
int ix=get_index(x,binsx);
int iy=get_index(y,binsy);
if (ix>=0&&iy>=0) histos[ix][iy]->Fill(value,weight);
}


//______________________________________________________________________________
void fill_histo(int pdgid,float value,float weight,float x,float y,
const vector<float>& binsx,const vector<float>& binsy,
Expand Down
9 changes: 6 additions & 3 deletions JetAnalyzers/bin/jet_response_and_resolution_x.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int main(int argc,char**argv)
bool dorho = cl.getValue<bool> ("dorho", false);
vector<string> flavors = cl.getVector<string>("flavors", "");
vector<string> algs = cl.getVector<string>("algs", "");
bool fitres = cl.getValue<bool> ("fitres", true);
bool fitres = cl.getValue<bool> ("fitres", false);
bool unweighted = cl.getValue<bool> ("unweighted", false);
bool verbose = cl.getValue<bool> ("verbose", false);
bool forcefit = cl.getValue<bool> ("forcefit", false);
Expand All @@ -76,9 +76,9 @@ int main(int argc,char**argv)
float fracRMSjpt = cl.getValue<float> ("fracRMSjpt", 1.);
float fracRMScalo = cl.getValue<float> ("fracRMScalo", 1.);

float calomin = cl.getValue<float> ("calomin", -1.);
float calomin = cl.getValue<float> ("calomin", -5.);
float jptmin = cl.getValue<float> ("jptmin", -1.);
float pfmin = cl.getValue<float> ("pfmin", -1.);
float pfmin = cl.getValue<float> ("pfmin", -5.);
float puppimin = cl.getValue<float> ("puppimin", -1.);

float calofitmin = cl.getValue<float> ("calofitmin", -1.);
Expand Down Expand Up @@ -133,6 +133,9 @@ int main(int argc,char**argv)
//variables.push_back("RelRsp:JetY");
variables.push_back("RelRsp:JetEta:RefPt");
variables.push_back("RelRsp:JetEta#1:RefPt"); //fitmin and min options affect JetEta#1 (vs. JetEta), seems to try to fit res but not rsp
variables.push_back("RelRsp:TrueNPU");
variables.push_back("RelRsp:TrueNPU:RefPt");
variables.push_back("RelRsp:TrueNPU#1:RefPt");
//variables.push_back("RelRsp:JetY:RefPt");
//variables.push_back("RelRsp:JetY#1:RefPt");
//variables.push_back("RelRsp_Barrel:RefPt");
Expand Down
2 changes: 1 addition & 1 deletion JetAnalyzers/bin/jet_response_fitter_x.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ int main(int argc,char**argv)
string output = cl.getValue<string> ("output", "");
double nsigma = cl.getValue<double> ("nsigma", 1.5);
float jtptmin = cl.getValue<float> ("jtptmin", 1.0);
int niter = cl.getValue<int> ("niter", 3);
int niter = cl.getValue<int> ("niter", 30);
int ndfmin = cl.getValue<int> ("ndfmin", 5);
vector<string> algs = cl.getVector<string>("algs", "");
int verbose = cl.getValue<int> ("verbose", 0);
Expand Down
4 changes: 2 additions & 2 deletions JetAnalyzers/bin/jet_synchfit_x.cc
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ int main(int argc,char**argv){

CommandLine cl;
if (!cl.parse(argc,argv)) return 0;
string aalgo1 = cl.getValue<string> ("algo1", "ak5pf");
string aalgo2 = cl.getValue<string> ("algo2", "ak5pf");
string aalgo1 = cl.getValue<string> ("algo1", "ak4pfHLT");
string aalgo2 = cl.getValue<string> ("algo2", "ak4pfHLT");
bool highPU = cl.getValue<bool> ("highPU", false);
bool logPol = cl.getValue<bool> ("logPol", true);
bool useNPU = cl.getValue<bool> ("useNPU", false);
Expand Down
Loading