10 #include "TPaveText.h"
18 ofstream
output(
"/outputdir_path/table_output.txt");
27 TString mystring =
"";
28 double thisval =
abs(weird);
29 if( thisval>=0.05 && thisval<0.10) mystring =
"\\cellcolor{green!25}";
30 else if( thisval>=0.10 && thisval<0.15) mystring =
"\\cellcolor{yellow!25}";
31 else if( thisval>=0.15) mystring =
"\\cellcolor{red!25}";
37 std::vector<TString>
in = {
"#",
" ",
".",
"_"};
38 std::vector<TString> out = {
"",
"",
"",
"\\_"};
40 for(
unsigned int i=0;i<in.size();i++)
41 mystring.ReplaceAll(in[i],out[i]);
48 output <<
"\\begin{table}[H]\n";
50 output <<
"\\resizebox{\\textwidth}{!}{\n";
52 output <<
"\\begin{tabular}{|l||c|c|c|c|c||c|}\n";
56 output <<
"\\multicolumn{1}{|c||}{} & \\multicolumn{4}{c||}{Number of interactions (\\% total)} & \\multicolumn{2}{c|}{Integrated} \\\\ \\hline \n \
57 \\multicolumn{1}{|c||}{Cut} & $\\nu_{e}$ CC & $\\nu_{\\mu}$ CC & NC & Cosmic & Efficiency & Purity \\\\ \\hline \n";
61 output <<
"\\end{tabular}}\n";
67 void printEventsLine(std::string cutname,
float nue,
float numu,
float nc,
float cos,
float other,
float eff,
float pur){
68 float total = nue+numu+nc+cos+other;
69 float percnue = 100*nue/total;
70 float percnumu = 100*numu/total;
71 float percnc = 100*nc/total;
72 float perccos = 100*cos/total;
73 float percother = 100*other/total;
74 float perctotbkg = 100*(numu+nc+cos+other)/total;
76 output << std::fixed << std::setw(6) << std::setprecision(3) << cutname <<
"&" << nue <<
"("<<percnue<<
")"<<
"&" << numu<<
"("<<percnumu<<
")"<<
"&" << nc<<
"("<<percnc<<
")"<<
"&" << cos<<
"("<<perccos<<
")"<<
"&" << eff <<
"&" << pur <<
"\\\\ \\hline \n";
85 c1 =
new TCanvas(
"c1",
"",700,800);
88 pad1 =
new TPad(
"pad1",
"pad1",0,0,1,1);
89 pad1->SetTopMargin(0.1);
90 pad1->SetBottomMargin(0.4);
91 pad1->SetLeftMargin(0.12);
92 pad1->SetRightMargin(0.03);
93 pad1->SetFillStyle(0);
97 pad2 =
new TPad(
"pad2",
"pad2",0,0,1,1);
98 pad2->SetTopMargin(0.6);
99 pad2->SetBottomMargin(0.1);
100 pad2->SetLeftMargin(0.12);
101 pad2->SetRightMargin(0.03);
102 pad2->SetFillStyle(0);
111 for(
unsigned int hId=0; hId<histos.size(); hId++){
112 float thismax = histos[hId]->GetMaximum();
113 if(thismax>hmax) hmax=thismax;
119 void PimpHist(TH1* histo, Color_t color, Style_t linestyle,
int linewidth, Style_t markerstyle=8,
double markersize=8){
121 histo->SetLineColor(color);
122 histo->SetLineStyle(linestyle);
123 histo->SetLineWidth(linewidth);
124 histo->SetMarkerColor(color);
125 histo->SetMarkerStyle(markerstyle);
126 histo->SetMarkerSize(markersize);
133 h->SetFillColorAlpha(h->GetLineColor(),dim);
136 TColor *color = gROOT->GetColor(h->GetLineColor());
137 float R,G,B,hR,hG,hB,hHue,hSat,hVal;
138 color->GetRGB(hR,hG,hB);
139 color->RGB2HSV(hR,hG,hB,hHue,hSat,hVal);
140 color->HSV2RGB(hHue,dim*hSat,hVal,R,G,B);
141 h->SetFillColor(color->GetColor(R,G,B));
148 TLegend *l =
new TLegend(0.70, 0.70, 0.85, 0.85, NULL,
"brNDC");
150 l->SetTextSize(0.035);
158 l->AddEntry(hnue,
"#nu_{e} CC",
"l");
159 l->AddEntry(hnumu,
"#nu_{#mu} CC",
"l");
160 l->AddEntry(hnc,
"NC",
"l");
161 l->AddEntry(hcos,
"Cosmics",
"l");
162 l->AddEntry(hother,
"Other bkg",
"l");
168 TLegend *leg =
new TLegend(.60,.60,.8,.8);
169 leg->AddEntry(h1, name1,
"l");
170 leg->AddEntry(h2, name2,
"l");
171 leg->SetBorderSize(0);
172 leg->SetFillColor(0);
173 leg->SetFillStyle(0);
174 leg->SetTextSize(0.04);
184 TLegend *leg =
new TLegend(.60,.60,.8,.8);
185 leg->AddEntry(h1, name1,
"l");
186 leg->AddEntry(h1, TString::Format(
"%.2f",iSig),
"");
187 leg->AddEntry(h2, name2,
"l");
188 leg->AddEntry(h2, TString::Format(
"%.2f",iBkg),
"");
190 leg->SetBorderSize(0);
191 leg->SetFillColor(0);
192 leg->SetFillStyle(0);
193 leg->SetTextSize(0.04);
201 float int1 = g1->Integral();
202 float int2 = g2->Integral();
203 TLegend *leg =
new TLegend(.65,.2,.85,.3);
204 leg->AddEntry(g1, name1,
"l");
205 leg->AddEntry(g2, name2,
"l");
208 leg->SetBorderSize(0);
209 leg->SetFillColor(0);
210 leg->SetFillStyle(0);
211 leg->SetTextSize(0.03);
219 TLegend *leg =
new TLegend(.65,.25,.85,.35);
220 leg->AddEntry(g1, name1,
"l");
221 leg->SetBorderSize(0);
222 leg->SetFillColor(0);
223 leg->SetFillStyle(0);
224 leg->SetTextSize(0.03);
232 TLegend *leg =
new TLegend(.65,.2,.85,.3);
233 leg->AddEntry(g1, name1,
"l");
234 leg->AddEntry(g2, name2,
"l");
235 leg->SetBorderSize(0);
236 leg->SetFillColor(0);
237 leg->SetFillStyle(0);
238 leg->SetTextSize(0.03);
245 float isig = hsig->Integral();
246 float ibkg = hbkg->Integral();
247 float psig = 100. * isig / (isig + ibkg);
248 float pbkg = 100. * ibkg / (isig + ibkg);
250 TPaveText *pText1 =
new TPaveText(0.15, 0.84, 0.30, 0.89,
"brNDC");
251 TText *text1 = (pText1->AddText(
"6.6 #times 10^{20} POT"));
252 text1->SetTextSize(textsize);
253 pText1->SetBorderSize(0);
254 pText1->SetFillStyle(0);
256 TPaveText *pText2 =
new TPaveText(0.15, 0.72, 0.30, 0.80,
"brNDC");
257 TText *text2 = pText2->AddText(Form(
"Sig: %2.f = %2.f %%", isig, psig));
258 text2->SetTextAlign(11);
259 text2->SetTextSize(textsize);
260 TText *text3 = pText2->AddText(Form(
"Bkg: %2.f = %2.f %%", ibkg, pbkg));
261 text3->SetTextAlign(11);
262 text3->SetTextSize(textsize);
263 pText2->SetBorderSize(0);
264 pText2->SetFillStyle(0);
276 TH1D* hTotal = (TH1D*)hSelSignal->Clone();
277 hTotal->Add(hSelBack);
279 TH1D* hPurity = (TH1D*)hSelSignal->Clone();
280 hPurity->Divide(hTotal);
282 TH1D* hEfficiency = (TH1D*)hSelSignal->Clone();
283 hEfficiency->Divide(hSignal);
292 TGraph*
EffOrPurGraph(TH1* hSelSignal, TH1* hSelBack, TH1* hSignal,
bool geteff) {
294 const int NBins = hSignal->GetNbinsX();
296 TString xTitle = hSignal->GetXaxis()->GetTitle();
297 TString yTitle = hSignal->GetYaxis()->GetTitle();
299 double eff[NBins], pur[NBins], val[NBins];
300 double sb[NBins], ssb[NBins];
303 for(
unsigned int i = 1; i <= (
unsigned int)NBins; ++i) {
304 double allsig = hSignal ->GetBinContent(i);
305 double selsig = hSelSignal->GetBinContent(i);
306 double selbac = hSelBack ->GetBinContent(i);
308 val[i-1] = hSignal->GetBinCenter(i);
312 if ( (selsig + selbac) > 0 ){
313 if ( allsig > 0 ) EFF = EFF/allsig;
314 PUR = PUR / (selsig + selbac);
319 if ( PUR > 1 || EFF > 1 ){
320 std::cout <<
"\n\n\n" <<
" >>> EFF " << EFF <<
"\t PUR " << PUR << std::endl;
324 TString
n = hSignal->GetName();
325 TGraph *graphPur=
new TGraph(NBins,val,pur);
326 graphPur->SetName(
"SelPur_"+n);
327 graphPur->GetXaxis()->SetTitle(xTitle);
328 graphPur->GetYaxis()->SetTitle(
"Pur.");
329 TGraph *graphEff=
new TGraph(NBins,val,eff);
330 graphEff->SetName(
"SelEff_"+n);
331 graphEff->GetXaxis()->SetTitle(xTitle);
332 graphEff->GetYaxis()->SetTitle(
"Eff.");
void PimpHist(TH1 *histo, Color_t color, Style_t linestyle, int linewidth, Style_t markerstyle=8, double markersize=8)
TH1D * EffOrPurHistogram(TH1 *hSelSignal, TH1 *hSelBack, TH1 *hSignal, bool geteff)
void DrawSigBkgIntLegend(TH1 *h1, char *name1, double iSig, TH1 *h2, char *name2, double iBkg)
void DrawIntEffPurLegend(TH1D *g1, char *name1, TH1D *g2, char *name2)
void printEventsLine(std::string cutname, float nue, float numu, float nc, float cos, float other, float eff, float pur)
process_name opflashCryoW ana
void SplitCanvas2(TCanvas *&c1, TPad *&pad1, TPad *&pad2)
void DrawEffPurLegend(TH1D *g1, char *name1, TH1D *g2, char *name2)
void FillWithDimColor(TH1 *h, bool usealpha=false, float dim=0.8)
void DrawComponentsLegend(TH1 *hnue, TH1 *hnumu, TH1 *hnc, TH1 *hcos, TH1 *hother)
TString fixLatexName(TString mystring)
void DrawSigBkgIntText(TH1 *hsig, TH1 *hbkg, float textsize)
TGraph * EffOrPurGraph(TH1 *hSelSignal, TH1 *hSelBack, TH1 *hSignal, bool geteff)
void DrawPurLegend(TH1D *g1, char *name1)
if &&[-z"$BASH_VERSION"] then echo Attempting to switch to bash bash shellSwitch exit fi &&["$1"= 'shellSwitch'] shift declare a IncludeDirectives for Dir in
TString thisCellColor(double weird)
BEGIN_PROLOG sequence::SlidingWindowTriggerPatternsOppositeWindows END_PROLOG simSlidingORM6O6 effSlidingORW output
void DrawSigBkgLegend(TH1 *h1, char *name1, TH1 *h2, char *name2)
void printTableHeader(int quantId=0)
BEGIN_PROLOG could also be cout
float GetHistMax(std::vector< TH1 * > histos)