File indexing completed on 2025-08-05 08:13:25
0001 int plot_rn_rawrate(int lo, int hi, int bit, float max)
0002 {
0003 gStyle->SetOptStat(0);
0004 int rn;
0005 double rawrate;
0006
0007 vector<int> rnv = {};
0008 vector<double> rrv = {};
0009
0010 ifstream ratefile;
0011 ratefile.open(("rn_rawrate_"+to_string(bit)+".txt").c_str());
0012
0013 while(true)
0014 {
0015 if(ratefile.eof()) break;
0016 ratefile >> rn >> rawrate;
0017 if(rn > hi || rn < lo) continue;
0018 rnv.push_back(rn);
0019 rrv.push_back(rawrate);
0020 }
0021
0022 TH1D* ratehist = new TH1D("ratehist","",hi-lo,lo,hi);
0023
0024
0025 for(int i=0; i<rnv.size(); ++i)
0026 {
0027 if(rrv.at(i) < max) ratehist->Fill(rnv.at(i),rrv.at(i));
0028 }
0029
0030 TCanvas* c1 = new TCanvas("","",2000,1000);
0031 float maxval=max;
0032 ratehist->SetMarkerStyle(20);
0033 ratehist->SetMarkerSize(1);
0034 ratehist->GetYaxis()->SetRangeUser(0,maxval);
0035 c1->cd();
0036
0037 TF1* flatfunc = new TF1("flat","[0]",lo,hi);
0038 flatfunc->SetParameter(0,200);
0039 flatfunc->SetParameter(1,0);
0040 ratehist->Fit(flatfunc,"W");
0041
0042 string trigger;
0043 if(bit==18) trigger = "Jet10&MBDNS>=1 ";
0044 else if(bit==10) trigger = "MBDNS>=1 ";
0045 else trigger = "";
0046
0047 ratehist->GetYaxis()->SetTitle((trigger+"Raw Rate [Hz]").c_str());
0048 ratehist->GetXaxis()->SetTitle("Run Number");
0049
0050 ratehist->Draw("HIST P");
0051 ratehist->GetFunction("flat")->Draw("SAME");
0052 vector<int> cosmics = {48795,49170,49782,49478,50572,51020,51020,52930,53321};
0053 vector<TLine*> lines = {};
0054 for(int i=0; i<cosmics.size(); ++i)
0055 {
0056 if(cosmics.at(i) > hi || cosmics.at(i) < lo) continue;
0057 TLine* mynewline = new TLine(cosmics.at(i),0,cosmics.at(i),maxval);
0058 mynewline->SetLineColor(kBlue);
0059 mynewline->SetLineWidth(1);
0060 lines.push_back(mynewline);
0061 lines.at(i)->Draw();
0062 }
0063
0064 c1->SaveAs(("ratehist"+to_string(bit)+".png").c_str());
0065
0066 return 0;
0067 };