25 glob(wildcardString.Data(),
29 for(
unsigned int i = 0;
i < g.gl_pathc; ++
i)
30 fileList.push_back(g.gl_pathv[
i]);
41 TH2F*
hits = (TH2F*)f->Get((
"eff/hits"+suffix).c_str());
42 TH2F* miss = (TH2F*)f->Get((
"eff/miss"+suffix).c_str());
43 TH2F* known = (TH2F*)f->Get(
"eff/known");
45 if(!hits || !miss || !known)
return;
48 cut =
new TH2F(*hits);
58 TH1F
proj(
"",
"", 100, 0, 1);
62 const int X = frac.GetNbinsX()+1;
63 const int Y = frac.GetNbinsY()+1;
64 for(
int x = 1;
x <
X; ++
x){
65 for(
int y = 1;
y <
Y; ++
y){
66 const bool isBad = known->GetBinContent(
x,
y);
70 if(cut->GetBinContent(
x,
y))
continue;
73 if(tot.GetBinContent(
x,
y) < 20)
continue;
77 const double fr = frac.GetBinContent(
x,
y);
79 if(suffix ==
"XYTight"){
81 if(fr > .4) cut->SetBinContent(
x,
y, 1);
84 if(fr > .15) cut->SetBinContent(
x,
y, 1);
87 if(suffix ==
"XYTight"){
89 if(fr > .7) cut->SetBinContent(
x,
y, 1);
92 if(fr > .5) cut->SetBinContent(
x,
y, 1);
97 if(fr > .8) cut->SetBinContent(
x,
y, 1);
100 if(fr > .5) cut->SetBinContent(
x,
y, 1);
104 if(tot.GetBinContent(
x,
y)){
106 hVsRun->Fill(xpos, fr);
112 if(g && totCells > 1000){
115 int topbin = proj.GetXaxis()->FindBin(.95);
117 for(iy = topbin; iy >= 0; --iy){
118 if(proj.Integral(iy, topbin) > .01*totCells)
break;
120 g->SetPoint(g->GetN(), xpos, proj.GetXaxis()->GetBinCenter(iy));
129 std::set<std::pair<int, int> > goodRuns;
130 std::ifstream is(
"good_stats.txt");
140 TH2* hVsRun =
new TH2F(
"",
";Run;Fraction of times missed from track", fs.size(), 0, fs.size(), 101, 0, 1.01);
141 TH2* hVsRunXYTight =
new TH2F(
"",
";Run;Fraction of times missed from track", fs.size(), 0, fs.size(), 101, 0, 1.01);
142 TH2* hVsRunZTight =
new TH2F(
"",
";Run;Fraction of times missed from track", fs.size(), 0, fs.size(), 101, 0, 1.01);
143 TH2* hVsRunXYLoose =
new TH2F(
"",
";Run;Fraction of times missed from track", fs.size(), 0, fs.size(), 101, 0, 1.01);
144 TH2* hVsRunZLoose =
new TH2F(
"",
";Run;Fraction of times missed from track", fs.size(), 0, fs.size(), 101, 0, 1.01);
146 TGraph* gXYTight =
new TGraph;
147 TGraph* gXYLoose =
new TGraph;
148 TGraph* gPoint =
new TGraph;
150 TGraph* gPointHand =
new TGraph;
151 TGraph* gXYTightHand =
new TGraph;
152 TGraph* gXYLooseHand =
new TGraph;
154 gPointHand->SetPoint(0, 0, .8);
155 gXYTightHand->SetPoint(0, 0, .4);
156 gXYLooseHand->SetPoint(0, 0, .7);
158 for(
unsigned int n = 0;
n < fs.size(); ++
n){
159 TFile
f(fs[
n].c_str());
160 if(f.IsZombie())
continue;
162 const int p0 = fs[
n].find(
"eff_r")+5;
163 const int p1 = fs[
n].find(
"_s");
165 const int p3 = fs[
n].find(
"_t02");
166 const int run = atoi(fs[
n].substr(p0, p1-p0).c_str());
167 const int subrun = atoi(fs[
n].substr(p2, p3-p2).c_str());
174 if(run >
kThreshRun && gXYTightHand->GetN() == 1){
175 gXYTightHand->SetPoint(1,
n+.5, .4);
176 gXYTightHand->SetPoint(2,
n+.5, .15);
177 gXYLooseHand->SetPoint(1,
n+.5, .7);
178 gXYLooseHand->SetPoint(2,
n+.5, .5);
181 gPointHand->SetPoint(1,
n+.5, .8);
182 gPointHand->SetPoint(2,
n+.5, .5);
190 make_plots(&f, hVsRunXYTight, gXYTight, run,
"XYTight",
n+.5, cut);
191 make_plots(&f, hVsRunXYLoose, gXYLoose, run,
"XYLoose",
n+.5, cut);
192 make_plots(&f, hVsRun, gPoint, run,
"",
n+.5, cut);
194 make_plots(&f, hVsRunZTight, 0, run,
"ZTight",
n+.5, cut);
195 make_plots(&f, hVsRunZLoose, 0, run,
"ZLoose",
n+.5, cut);
197 if(run%50 == 0 && subrun == 0){
208 gXYTightHand->SetPoint(3, fs.size(), .15);
209 gXYLooseHand->SetPoint(3, fs.size(), .5);
210 gPointHand->SetPoint(3, fs.size(), .5);
212 hVsRun->GetXaxis()->SetTickLength(0);
213 hVsRun->Draw(
"colz");
214 gPad->SetLogz(
false);
215 gPad->Print(
"plots/proj_vs_run.eps");
217 gPad->Print(
"plots/proj_vs_run_log.eps");
218 gPoint->SetLineColor(
kRed);
220 gPointHand->SetLineColor(
kGreen);
221 gPointHand->Draw(
"l");
222 gPad->SetLogz(
false);
223 gPad->Print(
"plots/proj_vs_run_trace.eps");
225 gPad->Print(
"plots/proj_vs_run_trace_log.eps");
227 hVsRunXYTight->GetXaxis()->SetTickLength(0);
228 hVsRunXYTight->Draw(
"colz");
229 gPad->SetLogz(
false);
230 gPad->Print(
"plots/proj_vs_run_xytight.eps");
232 gPad->Print(
"plots/proj_vs_run_xytight_log.eps");
233 gXYTight->SetLineColor(
kRed);
235 gXYTightHand->SetLineColor(
kGreen);
236 gXYTightHand->Draw(
"l");
237 gPad->SetLogz(
false);
238 gPad->Print(
"plots/proj_vs_run_xytight_trace.eps");
240 gPad->Print(
"plots/proj_vs_run_xytight_trace_log.eps");
242 hVsRunZTight->GetXaxis()->SetTickLength(0);
243 hVsRunZTight->Draw(
"colz");
244 gPad->SetLogz(
false);
245 gPad->Print(
"plots/proj_vs_run_ztight.eps");
247 gPad->Print(
"plots/proj_vs_run_ztight_log.eps");
249 hVsRunXYLoose->GetXaxis()->SetTickLength(0);
250 hVsRunXYLoose->Draw(
"colz");
251 gPad->SetLogz(
false);
252 gPad->Print(
"plots/proj_vs_run_xyloose.eps");
254 gPad->Print(
"plots/proj_vs_run_xyloose_log.eps");
255 gXYLoose->SetLineColor(
kRed);
257 gXYLooseHand->SetLineColor(
kGreen);
258 gXYLooseHand->Draw(
"l");
259 gPad->SetLogz(
false);
260 gPad->Print(
"plots/proj_vs_run_xyloose_trace.eps");
262 gPad->Print(
"plots/proj_vs_run_xyloose_trace_log.eps");
264 hVsRunZLoose->GetXaxis()->SetTickLength(0);
265 hVsRunZLoose->Draw(
"colz");
266 gPad->SetLogz(
false);
267 gPad->Print(
"plots/proj_vs_run_zloose.eps");
269 gPad->Print(
"plots/proj_vs_run_zloose_log.eps");
271 TFile
fout(
"cosmic_eff.root",
"RECREATE");
272 hVsRun->Write(
"hVsRun");
273 hVsRunXYLoose->Write(
"hVsRunXYLoose");
274 hVsRunZLoose->Write(
"hVsRunZLoose");
275 hVsRunXYLoose->Write(
"hVsRunXYTight");
276 hVsRunZLoose->Write(
"hVsRunZTight");
std::vector< std::string > GetListOfFilesByWildcard(TString wildcardString)
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
double frac(double x)
Fractional part.
assert(nhit_max >=nhit_nbins)
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
void make_plots(TFile *f, TH2 *hVsRun, TGraph *g, int run, std::string suffix, double xpos, TH2 *&cut)