TGraphErrors* PlotLightYieldGraph() { string filename; vector<double> x,y,ex,ey; while(1){ cout<<"\n\nEnter next file to process; <enter> to finish."<<endl; getline(cin, filename); if(filename=="") break; //load the tree TTree* Events = GetEventsTree(filename.c_str()); if(!Events) continue; gROOT->ProcessLine(".x analysis/Aliases.C"); double start = Events->GetMinimum("timestamp"); double end = Events->GetMaximum("timestamp"); double error = 0; TString title = TString("Na22 Spectrum, ") + TString(filename)(TRegexp("Run......")); TH1F* hist = new TH1F("Na22Spec",title,200,1000,2500); Events->Draw("sumspec >> Na22Spec","min > 0","e"); double yield = Fit511Photopeak(hist,&error); x.push_back((start+end)/2.); ex.push_back((end-start)/2.); y.push_back(yield); ey.push_back(error); } if(x.size() == 0){ cerr<<"No valid points found!"<<endl; return 0; } TGraphErrors* graph = new TGraphErrors(x.size(),&x[0],&y[0],&ex[0],&ey[0]); graph->Draw("ape"); TAxis* xax = graph->GetXaxis(); xax->SetTitle("Run Time"); xax->SetTimeDisplay(1); xax->SetTimeFormat("%Y/%m/%d"); xax->SetTimeOffset(1,"gmt"); TAxis* yax = graph->GetYaxis(); yax->SetTitle("511 keV Light Yield [pe/keV]"); graph->Draw("ape"); return graph; }