26 glob(wildcardString.Data(),
30 for(
unsigned int i = 0;
i < g.gl_pathc; ++
i)
31 fileList.push_back(g.gl_pathv[
i]);
47 if(plane == rhs.
plane)
return cell < rhs.
cell;
48 return plane < rhs.
plane;
57 void Write(std::ostream& os,
int plane,
int cell,
int endrun,
int endsubrun)
const 59 os <<
run <<
", " <<
subrun <<
", " << endrun <<
", " << endsubrun <<
", ndos, " << plane <<
", " << cell <<
", " <<
good <<
", " <<
kRelease <<
", dummy, dummy" <<
std::endl;
69 std::set<std::pair<int, int> > goodRuns;
70 std::ifstream is(
"good_stats.txt");
77 std::map<OfflineChan, State>
states;
79 std::ofstream
table(
"cosmic_eff_table.csv");
84 TH1* hCutFrac =
new TH1F(
"",
"", fs.size(), 0, fs.size());
85 TH1* hCutFracCosmic =
new TH1F(
"",
"", fs.size(), 0, fs.size());
86 TH1* hCutFracXYTight =
new TH1F(
"",
"", fs.size(), 0, fs.size());
87 TH1* hCutFracXYLoose =
new TH1F(
"",
"", fs.size(), 0, fs.size());
92 long int rowswritten = 0;
95 for(
unsigned int n = 0;
n < fs.size(); ++
n){
96 TFile
f(fs[
n].c_str());
97 if(f.IsZombie())
return;
99 const int p0 = fs[
n].find(
"eff_r")+5;
100 const int p1 = fs[
n].find(
"_s");
102 const int p3 = fs[
n].find(
"_t02");
103 const int run = atoi(fs[
n].substr(p0, p1-p0).c_str());
104 const int subrun = atoi(fs[
n].substr(p2, p3-p2).c_str());
115 TH2*
frac = (TH2*)f.Get(
"eff/frac");
116 TH2* htot = (TH2*)f.Get(
"eff/tot");
117 TH2* fracXYTight = (TH2*)f.Get(
"eff/fracXYTight");
118 TH2* fracXYLoose = (TH2*)f.Get(
"eff/fracXYLoose");
119 TH2* totXYTight = (TH2*)f.Get(
"eff/totXYTight");
120 TH2* totXYLoose = (TH2*)f.Get(
"eff/totXYLoose");
122 TH2* known = (TH2*)f.Get(
"eff/known");
124 if(!frac || !htot || !fracXYTight || !fracXYLoose || !totXYTight || !totXYLoose)
continue;
129 double totcutxyt = 0;
130 double totcutxyl = 0;
134 const int X = frac->GetNbinsX()+1;
135 const int Y = frac->GetNbinsY()+1;
136 for(
int x = 1;
x <
X; ++
x){
137 for(
int y = 1;
y <
Y; ++
y){
138 const double t = htot->GetBinContent(
x,
y);
139 const double txyt = totXYTight->GetBinContent(
x,
y);
140 const double txyl = totXYLoose->GetBinContent(
x,
y);
143 if(txyt < 20 && txyl < 20 && t < 20)
continue;
149 const int cell =
y-1;
154 const double frXY = fracXYTight->GetBinContent(
x,
y);
155 if((run <= kThreshRun && frXY > .4) || (run >
kThreshRun && frXY > .15)){
161 if(good && txyl >= 20){
162 const double frXY = fracXYLoose->GetBinContent(
x,
y);
163 if((run <= kThreshRun && frXY > .7) || (run >
kThreshRun && frXY > .5)){
170 const double fr = frac->GetBinContent(
x,
y);
171 if((run <= kMysteryRun && fr > .8) || (run >
kMysteryRun && fr > .5)){
177 if(known && !known->GetBinContent(
x,
y)){
186 std::map<OfflineChan, State>::iterator
it = states.find(chan);
187 if(it == states.end()){
192 const State oldstate = it->second;
193 if(oldstate.
good != good){
195 oldstate.
Write(table, plane, cell, prevrun, prevsubrun);
205 const double tot = totkept+totcut;
206 if(tot && totcells > 1000){
207 hCutFrac->SetBinContent(
n, 100*totcut/tot);
208 hCutFracCosmic->SetBinContent(
n, 100*totcutp/tot);
209 hCutFracXYTight->SetBinContent(
n, 100*totcutxyt/tot);
210 hCutFracXYLoose->SetBinContent(
n, 100*totcutxyl/tot);
213 if(run%50 == 0 && subrun == 0){
222 for(std::map<OfflineChan, State>::iterator
it = states.begin();
it != states.end(); ++
it){
223 it->second.Write(table,
it->first.plane,
it->first.cell, prevrun, prevsubrun);
226 std::cout <<
"Wrote " << rowswritten <<
"/" << totrows <<
" = " << (10000*rowswritten/totrows)/100. <<
"%" <<
std::endl;
229 hCutFrac->GetYaxis()->SetTitle(
"Percentage of channels cut");
230 hCutFrac->GetXaxis()->SetTickLength(0);
231 hCutFracCosmic->SetLineColor(
kBlue);
232 hCutFracCosmic->Draw(
"same");
233 hCutFracXYTight->SetLineColor(
kRed);
234 hCutFracXYTight->Draw(
"same");
235 hCutFracXYLoose->SetLineColor(
kGreen+2);
236 hCutFracXYLoose->Draw(
"same");
238 gPad->Print(
"plots/frac_cut.eps");
239 hCutFrac->GetYaxis()->SetRangeUser(0, 10);
240 gPad->Print(
"plots/frac_cut_zoom.eps");
bool operator<(const OfflineChan &rhs) const
void make_cosmic_eff_table()
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)
void Write(std::ostream &os, int plane, int cell, int endrun, int endsubrun) const
const std::string kRelease
double frac(double x)
Fractional part.
OfflineChan(int p, int c)
State(int r, int s, bool g)
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)