Skip to content

Commit

Permalink
Merge pull request cms-sw#24 from jozzez1/Run2HSCP_v9_ANEdits2
Browse files Browse the repository at this point in the history
Run2 hscp v9 an edits2
  • Loading branch information
quertenmont committed Dec 4, 2015
2 parents 238d8f3 + b3d654b commit 3fe4027
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 29 deletions.
40 changes: 20 additions & 20 deletions SUSYBSMAnalysis/HSCP/test/AnalysisCode/Analysis_PlotStructure.h
Original file line number Diff line number Diff line change
Expand Up @@ -1311,41 +1311,41 @@ void stPlots_Draw(stPlots& st, std::string SavePath, std::string LegendTitle, un
Histos1D[7] = (TH1*)st.AS_Eta_RegionH->ProjectionY((st.Name+"H").c_str(),CutIndex+1,CutIndex+1); legend.push_back("H");
if(Histos1D[7]->Integral()>0) Histos1D[7]->Scale(1.0/Histos1D[7]->Integral());
DrawSuperposedHistos((TH1**)Histos1D, legend, "E1", "#eta", "arbitrary units", 0, 0, 0, 0.1);
DrawLegend((TObject**)Histos1D,legend,"","P", 0.93, 0.88, 0.38, 0.045);
DrawLegend((TObject**)Histos1D,legend,"","P", 0.63, 0.88, 0.38, 0.045);
c1->SetLogy(false);
DrawPreliminary(LegendTitle, SQRTS, IntegratedLuminosityFromE(SQRTS));
SaveCanvas(c1,SavePath,std::string("EtaRegions_AS")+CutIndexStr);
for(unsigned int i=0;i<8;i++){delete Histos1D[i];}
delete c1;

c1 = new TCanvas("c1","c1,",600,600); legend.clear();
Histos1D[0] = (TH1*)st.AS_Eta_RegionA->ProjectionY((st.Name+"A").c_str(),CutIndex+1,CutIndex+1); legend.push_back("pT<"+string(PtCutStr)+" & dE/dx<"+string(ICutStr));
Histos1D[0] = (TH1*)st.AS_Eta_RegionA->ProjectionY((st.Name+"A").c_str(),CutIndex+1,CutIndex+1); legend.push_back("p_{T}<"+string(PtCutStr)+" & I_{as}<"+string(ICutStr));
if(Histos1D[0]->Integral()>0) Histos1D[0]->Scale(1.0/Histos1D[0]->Integral());
Histos1D[1] = (TH1*)st.AS_Eta_RegionB->ProjectionY((st.Name+"B").c_str(),CutIndex+1,CutIndex+1); legend.push_back("pT<"+string(PtCutStr)+" & dE/dx<"+string(ICutStr));
Histos1D[1] = (TH1*)st.AS_Eta_RegionB->ProjectionY((st.Name+"B").c_str(),CutIndex+1,CutIndex+1); legend.push_back("p_{T}<"+string(PtCutStr)+" & I_{as}>"+string(ICutStr));
if(Histos1D[1]->Integral()>0) Histos1D[1]->Scale(1.0/Histos1D[1]->Integral());
Histos1D[2] = (TH1*)st.AS_Eta_RegionC->ProjectionY((st.Name+"C").c_str(),CutIndex+1,CutIndex+1); legend.push_back("pT<"+string(PtCutStr)+" & dE/dx<"+string(ICutStr));
Histos1D[2] = (TH1*)st.AS_Eta_RegionC->ProjectionY((st.Name+"C").c_str(),CutIndex+1,CutIndex+1); legend.push_back("p_{T}>"+string(PtCutStr)+" & I_{as}<"+string(ICutStr));
if(Histos1D[2]->Integral()>0) Histos1D[2]->Scale(1.0/Histos1D[2]->Integral());
Histos1D[3] = (TH1*)st.AS_Eta_RegionD->ProjectionY((st.Name+"D").c_str(),CutIndex+1,CutIndex+1); legend.push_back("pT<"+string(PtCutStr)+" & dE/dx<"+string(ICutStr));
Histos1D[3] = (TH1*)st.AS_Eta_RegionD->ProjectionY((st.Name+"D").c_str(),CutIndex+1,CutIndex+1); legend.push_back("p_{T}>"+string(PtCutStr)+" & I_{as}>"+string(ICutStr));
if(Histos1D[3]->Integral()>0) Histos1D[3]->Scale(1.0/Histos1D[3]->Integral());
DrawSuperposedHistos((TH1**)Histos1D, legend, "E1", "#eta", "arbitrary units", 0, 0, 0, 0.1);
DrawLegend((TObject**)Histos1D,legend,"","P", 0.93, 0.88, 0.30, 0.045);
DrawLegend((TObject**)Histos1D,legend,"","P", 0.80, 0.88, 0.38, 0.045);
c1->SetLogy(false);
DrawPreliminary(LegendTitle, SQRTS, IntegratedLuminosityFromE(SQRTS));
SaveCanvas(c1,SavePath,std::string("EtaRegions_ABCD_AS")+CutIndexStr);
for(unsigned int i=0;i<4;i++){delete Histos1D[i];}
delete c1;

c1 = new TCanvas("c1","c1,",600,600); legend.clear();
Histos1D[0] = (TH1*)st.AS_Eta_RegionA->ProjectionY((st.Name+"A").c_str(),CutIndex+1,CutIndex+1); legend.push_back("pT<"+string(PtCutStr)+" & 1/#beta<"+string(TOFCutStr));
Histos1D[0] = (TH1*)st.AS_Eta_RegionA->ProjectionY((st.Name+"A").c_str(),CutIndex+1,CutIndex+1); legend.push_back("p_{T}<"+string(PtCutStr)+" & 1/#beta<"+string(TOFCutStr));
if(Histos1D[0]->Integral()>0) Histos1D[0]->Scale(1.0/Histos1D[0]->Integral());
Histos1D[1] = (TH1*)st.AS_Eta_RegionE->ProjectionY((st.Name+"E").c_str(),CutIndex+1,CutIndex+1); legend.push_back("pT<"+string(PtCutStr)+" & 1/#beta>"+string(TOFCutStr));
Histos1D[1] = (TH1*)st.AS_Eta_RegionE->ProjectionY((st.Name+"E").c_str(),CutIndex+1,CutIndex+1); legend.push_back("p_{T}<"+string(PtCutStr)+" & 1/#beta>"+string(TOFCutStr));
if(Histos1D[1]->Integral()>0) Histos1D[1]->Scale(1.0/Histos1D[1]->Integral());
Histos1D[2] = (TH1*)st.AS_Eta_RegionC->ProjectionY((st.Name+"C").c_str(),CutIndex+1,CutIndex+1); legend.push_back("pT>"+string(PtCutStr)+" & 1/#beta<"+string(TOFCutStr));
Histos1D[2] = (TH1*)st.AS_Eta_RegionC->ProjectionY((st.Name+"C").c_str(),CutIndex+1,CutIndex+1); legend.push_back("p_{T}>"+string(PtCutStr)+" & 1/#beta<"+string(TOFCutStr));
if(Histos1D[2]->Integral()>0) Histos1D[2]->Scale(1.0/Histos1D[2]->Integral());
Histos1D[3] = (TH1*)st.AS_Eta_RegionG->ProjectionY((st.Name+"G").c_str(),CutIndex+1,CutIndex+1); legend.push_back("pT>"+string(PtCutStr)+" & 1/#beta>"+string(TOFCutStr));
Histos1D[3] = (TH1*)st.AS_Eta_RegionG->ProjectionY((st.Name+"G").c_str(),CutIndex+1,CutIndex+1); legend.push_back("p_{T}>"+string(PtCutStr)+" & 1/#beta>"+string(TOFCutStr));
if(Histos1D[3]->Integral()>0) Histos1D[3]->Scale(1.0/Histos1D[3]->Integral());
DrawSuperposedHistos((TH1**)Histos1D, legend, "E1", "#eta", "arbitrary units", 0, 0, 0, 0.1);
DrawLegend((TObject**)Histos1D,legend,"","P", 0.93, 0.88, 0.30, 0.045);
DrawLegend((TObject**)Histos1D,legend,"","P", 0.80, 0.88, 0.30, 0.045);
c1->SetLogy(false);
DrawPreliminary(LegendTitle, SQRTS, IntegratedLuminosityFromE(SQRTS));
SaveCanvas(c1,SavePath,std::string("EtaRegions_ACEG_AS")+CutIndexStr);
Expand Down Expand Up @@ -2181,9 +2181,9 @@ void stPlots_DrawComparison(std::string SavePath, std::string LegendTitle, unsig
for(unsigned int i=0;i<st.size();i++){
Histos[i] = (TH1*)st[i]->BS_Is; legend.push_back(lg[i]); if(Histos[i]->Integral()>0) Histos[i]->Scale(1.0/Histos[i]->Integral()); }
sprintf(YAxisTitle,"Fraction of tracks/%0.2f",Histos[0]->GetBinWidth(1));
DrawSuperposedHistos((TH1**)Histos, legend, "E1", dEdxS_Legend.c_str(), YAxisTitle, 0,0, 1E-6,3);
DrawLegend((TObject**)Histos,legend,"","P", 0.93, 0.88, 0.45, 0.045);
DrawSuperposedHistos((TH1**)Histos, legend, "E1", dEdxS_Legend.c_str(), YAxisTitle, 0,1, 1E-6,3, false, true);
DrawSuperposedHistos((TH1**)Histos, legend, "E1", dEdxS_Legend.c_str(), YAxisTitle, 0,0, 1E-6,15);
DrawLegend((TObject**)Histos,legend,"","P", 0.93, 0.92, 0.45, 0.045);
DrawSuperposedHistos((TH1**)Histos, legend, "E1", dEdxS_Legend.c_str(), YAxisTitle, 0,1, 1E-6,15, false, true);
c1->SetLogy(true);
DrawPreliminary(LegendTitle, SQRTS, IntegratedLuminosityFromE(SQRTS));
SaveCanvas(c1,SavePath,"Is_BS");
Expand All @@ -2192,8 +2192,8 @@ void stPlots_DrawComparison(std::string SavePath, std::string LegendTitle, unsig
c1 = new TCanvas("c1","c1,",600,600); legend.clear();
for(unsigned int i=0;i<st.size();i++){
Histos[i] = (TH1*)st[i]->BS_Im; legend.push_back(lg[i]); if(Histos[i]->Integral()>0) Histos[i]->Scale(1.0/Histos[i]->Integral()); }
DrawSuperposedHistos((TH1**)Histos, legend, "E1", dEdxM_Legend.c_str(), "Fraction of tracks", 0,20, 1E-6,3);
DrawLegend((TObject**)Histos,legend,"","P", 0.93, 0.88, 0.45, 0.045);
DrawSuperposedHistos((TH1**)Histos, legend, "E1", dEdxM_Legend.c_str(), "Fraction of tracks", 0,20, 1E-6,15);
DrawLegend((TObject**)Histos,legend,"","P", 0.93, 0.92, 0.45, 0.045);
c1->SetLogy(true);
DrawPreliminary(LegendTitle, SQRTS, IntegratedLuminosityFromE(SQRTS));
SaveCanvas(c1,SavePath,"Im_BS");
Expand Down Expand Up @@ -2226,10 +2226,10 @@ void stPlots_DrawComparison(std::string SavePath, std::string LegendTitle, unsig
Histos[i] = (TH1*)st[i]->BS_Pt; legend.push_back(lg[i]); if(Histos[i]->Integral()>0) Histos[i]->Scale(1.0/Histos[i]->Integral()); }
sprintf(YAxisTitle,"Fraction of tracks/%2.0f GeV",Histos[0]->GetBinWidth(1));
//DrawSuperposedHistos((TH1**)Histos, legend, "E1", "p_{T} (GeV)", YAxisTitle, 0,1250, 0.000000001, 1.2);
DrawSuperposedHistos((TH1**)Histos, legend, "E1", "p_{T} (GeV)", YAxisTitle, 0,1250, 1E-6, 3);
DrawSuperposedHistos((TH1**)Histos, legend, "E1", "p_{T} (GeV)", YAxisTitle, 0,1250, 1E-6, 15);
//if(IsTkOnly) DrawLegend((TObject**)Histos,legend,"","P", 0.45, 0.42, 0.26, 0.05);
//else DrawLegend((TObject**)Histos,legend,"","P", 0.51, 0.39, 0.33, 0.05);
DrawLegend((TObject**)Histos,legend,"","P", 0.93, 0.88, 0.45, 0.045);
DrawLegend((TObject**)Histos,legend,"","P", 0.93, 0.92, 0.45, 0.045);
//DrawSuperposedHistos((TH1**)Histos, legend, "E1", "p_{T} (GeV)", YAxisTitle, 0,1250, 0.000000001, 1.2, false, true);

c1->SetLogy(true);
Expand Down Expand Up @@ -2263,8 +2263,8 @@ void stPlots_DrawComparison(std::string SavePath, std::string LegendTitle, unsig
for(unsigned int i=0;i<st.size();i++){
Histos[i] = (TH1*)st[i]->BS_TOF; legend.push_back(lg[i]); if(Histos[i]->Integral()>0) Histos[i]->Scale(1.0/Histos[i]->Integral()); }
sprintf(YAxisTitle,"Fraction of tracks/%0.2f",Histos[0]->GetBinWidth(1));
DrawSuperposedHistos((TH1**)Histos, legend, "E1", "1/#beta", YAxisTitle, 0, 4, 1E-6, 3);
DrawLegend((TObject**)Histos,legend,"","P", 0.93, 0.88, 0.45, 0.045);//,0.35);
DrawSuperposedHistos((TH1**)Histos, legend, "E1", "1/#beta", YAxisTitle, 0, 4, 1E-6, 15);
DrawLegend((TObject**)Histos,legend,"","P", 0.93, 0.92, 0.45, 0.045);//,0.35);
c1->SetLogy(true);
DrawPreliminary(LegendTitle, SQRTS, IntegratedLuminosityFromE(SQRTS));
SaveCanvas(c1,SavePath,"TOF_BS");
Expand Down
27 changes: 18 additions & 9 deletions SUSYBSMAnalysis/HSCP/test/AnalysisCode/Analysis_Step3_MakePlots.C
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "TGraphAsymmErrors.h"
#include "TPaletteAxis.h"
#include "TColor.h"
#include "TLatex.h"

using namespace std;

Expand Down Expand Up @@ -1383,6 +1384,13 @@ void CutFlowPlot(string InputPattern, unsigned int CutIndex, double ylow, double
TFile* InputFile = new TFile((InputPattern + "Histos.root").c_str());
if (!InputFile) std::cerr << "File could not be opened!" << std::endl;

TH1D* HCuts_Pt = (TH1D*) GetObjectFromPath (InputFile, "HCuts_Pt");
TH1D* HCuts_Is = (TH1D*) GetObjectFromPath (InputFile, "HCuts_I");
TH1D* HCuts_TOF = (TH1D*) GetObjectFromPath (InputFile, "HCuts_TOF");
char PtCutStr [1024]; sprintf (PtCutStr, "p_{T}>%.0f GeV", HCuts_Pt ->GetBinContent(CutIndex+1));
char ICutStr [1024]; sprintf (ICutStr, "I_{as}>%.2f", HCuts_Is ->GetBinContent(CutIndex+1));
char TOFCutStr[1024]; sprintf (TOFCutStr,"1/#beta>%.3f", HCuts_TOF->GetBinContent(CutIndex+1));

vector < pair<stSample, Color_t> > SamplesToDraw;
SamplesToDraw.push_back (make_pair(samples [JobIdToIndex("Data13TeV" , samples)], kBlack ));
SamplesToDraw.push_back (make_pair(samples [JobIdToIndex("MC_13TeV_DYToMuMu" , samples)], kBlue - 3 ));
Expand All @@ -1394,12 +1402,13 @@ void CutFlowPlot(string InputPattern, unsigned int CutIndex, double ylow, double
// const char * AxisLabels [16] = {"Initial", "#hit #geq 8", "dE/dx #hit #geq 6", "nDof #geq 8", "high purity track", "#chi^{2}/nDof < 5",
// "pT > 55", "#beta^{-1}>1", "d_{xy}<5mm", "tracker iso < 50", "E/p iso < 0.3", "pT_{err} < 25%", "d_{z}<5mm",
// "pT", "I_{as}", "#beta^{-1}"};
const char * AxisLabels [16] = {"Triggered", "#hit>7", "#dEdxHit>5", "nDof>7", "Track Qual.", "X²/nDof<5",
"pT>55", "iBeta>1", "dXY<5mm", "TkIso<50", "E/p<0.3", "pTerr<25%", "dZ<5mm",
"pT", "Ias", "iBeta"};
const char * AxisLabels [16] = {"Triggered", "#hit>7", "#dEdxHit>5", "nDof>7", "Track Qual.", "#chi^{2}/nDof<5",
"p_{T}>55 GeV", "1/#beta>1", "dXY<5 mm", "TkIso<50", "E/p<0.3", "#sigma_{p_{T}}/p_{T}<25 %", "dZ<5 mm", PtCutStr, ICutStr, TOFCutStr};

unsigned int NumberOfCuts = sizeof(AxisLabels)/sizeof(const char *);
TypeMode = TypeFromPattern(InputPattern);
if(CutIndex==0)NumberOfCuts-=3;
else if (TypeMode==0)NumberOfCuts-=1; //TkOnly does not have TOF cut

// initialize histograms and fill them
for (unsigned int sample_i = 0; sample_i < SamplesToDraw.size(); sample_i++){
Expand Down Expand Up @@ -1474,7 +1483,7 @@ void CutFlowPlot(string InputPattern, unsigned int CutIndex, double ylow, double
// draw the preselection/selection division line
SelectionLine.SetLineWidth(4);
SelectionLine.SetLineStyle(7);
SelectionLine.DrawLine (NumberOfCuts - 3 - 0.08, ylow, NumberOfCuts - 3 - 0.08, yhigh);
// SelectionLine.DrawLine (NumberOfCuts - 3 - 0.08, ylow, NumberOfCuts - 3 - 0.08, yhigh); Don't draw the line -- JOZE
// draw preselection/selection text
// TText SelectionText;
// SelectionText.SetTextAngle(0);
Expand All @@ -1494,14 +1503,14 @@ void CutFlowPlot(string InputPattern, unsigned int CutIndex, double ylow, double
histos[sample_i].first->Draw("same");
}
// now put the axis labels -- each cut at each respective bin
TText T;
TLatex T;
T.SetTextAngle(35);
T.SetTextAlign(33);
T.SetTextSize (0.03);

double Y = histos[0].first->GetYaxis()->GetBinLowEdge(1);
for (unsigned int cut_i = 0; cut_i < NumberOfCuts; cut_i++)
T.DrawText (histos[0].first->GetXaxis()->GetBinCenter(cut_i+1), Y, AxisLabels[cut_i]);
T.DrawLatex (histos[0].first->GetXaxis()->GetBinCenter(cut_i+1), Y, AxisLabels[cut_i]);

leg->Draw();
SQRTS=13; string LegendTitle = LegendFromType(InputPattern);
Expand Down Expand Up @@ -1541,7 +1550,7 @@ void CutFlowPlot(string InputPattern, unsigned int CutIndex, double ylow, double
// draw the preselection/selection division line
SelectionLine.SetLineWidth(2);
SelectionLine.SetLineStyle(7);
SelectionLine.DrawLine (NumberOfCuts - 3 - 0.08, ylow, NumberOfCuts - 3 - 0.08, yhigh);
// SelectionLine.DrawLine (NumberOfCuts - 3 - 0.08, ylow, NumberOfCuts - 3 - 0.08, yhigh); Don't draw it! JOZE
// draw preselection/selection text
// SelectionText.SetTextAngle(0);
// SelectionText.SetTextAlign(22);
Expand All @@ -1565,7 +1574,7 @@ void CutFlowPlot(string InputPattern, unsigned int CutIndex, double ylow, double
T.SetTextSize (0.03);
Y = histos[0].second->GetYaxis()->GetBinLowEdge(1);
for (unsigned int cut_i = 0; cut_i < NumberOfCuts; cut_i++)
T.DrawText (histos[0].second->GetXaxis()->GetBinCenter(cut_i+1), Y, AxisLabels[cut_i]);
T.DrawLatex (histos[0].second->GetXaxis()->GetBinCenter(cut_i+1), Y, AxisLabels[cut_i]);

leg->Draw();
SQRTS=13; LegendTitle = LegendFromType(InputPattern);
Expand Down Expand Up @@ -2961,7 +2970,7 @@ void CheckPrediction(string InputPattern, string HistoSuffix, string DataType){
}
Histos[1]->Draw("E1 same");
char LegendWithCuts[1024];
if(ICut>-1 && PtCut>-1) sprintf(LegendWithCuts, "I_{as} > %.2f, p_{T} > %.0f GeV", ICut, PtCut);
if(ICut>-1 && PtCut>-1) sprintf(LegendWithCuts, "p_{T} > %.0f GeV & I_{as} > %.2f", PtCut, ICut);
else if(PtCut>-1) sprintf(LegendWithCuts, "p_{T} > %.0f GeV", PtCut);
else if(ICut>-1) sprintf(LegendWithCuts, "I_{as} > %.2f", ICut);
DrawLegend((TObject**)Histos,legend,LegendWithCuts,"P", 0.93, 0.88, 0.45, 0.045);
Expand Down

0 comments on commit 3fe4027

Please sign in to comment.