// Structure for markers/lines style struct style_definition{ int style, color; float size; }; // Get shortname from filename (excluding path and extension) string get_shortname(string filename){ string shortname = filename.substr(filename.find_last_of('/')+1, filename.find_last_of('.')-filename.find_last_of('/')-1); //cout << "Filename is " << filename << " ->shortname is " << shortname << endl; return shortname; } // Get run number from filename string get_runnumber(string filename){ string runnumber = filename.substr(filename.find_first_of('2'),filename.find_last_of('.')-filename.find_first_of('2')); //cout << "Filename " << filename << " ->runnumber " << runnumber << endl; return runnumber; } double unc_noise = 0.000003548; // in volts double unc_signal = 0.002580; double unc_GeomRep = 0.03123; /**************************************/ // Read scan file into a graph /**************************************/ TGraphErrors* read_scan_file(const string & filename, string & runnumber){ const std::string cutoff_date = "2022091900"; TGraphErrors *graph = new TGraphErrors(); std::ifstream file(filename); double x, y, sn, dp; while (file.good()){ if (runnumber > cutoff_date){ file >> x >> y >> sn >> dp; } else { file >> x >> y >> sn; } if (!file.good()) break; if (runnumber > cutoff_date){ graph->SetPoint(graph->GetN(), x, sn*1000); graph->SetPointError(graph->GetN() - 1, 0, ((sqrt(pow(dp,2) + pow(unc_noise,2) + pow(sn*(unc_signal+unc_GeomRep),2)))*1000)); } else { graph->SetPoint(graph->GetN(), x, sn/1000); } } return graph; } /**************************************/ // Read noise file into a graph /**************************************/ TGraphErrors* read_noise_file(const string & noisename, string & runnumber){ if (noisename == "") { return 0; } const std::string cutoff_date = "2022091900"; if (runnumber > cutoff_date){ TGraphErrors *graph = new TGraphErrors(); std::ifstream file(noisename); double x, y, n, dp; while (file.good()){ file >> x >> y >> n >> dp; if (!file.good()) break; graph->SetPoint(graph->GetN(), x, n*1000); graph->SetPointError(graph->GetN() - 1, 0, dp*1000); } return graph; } else { cout << "No valid noise file in this period" << endl; } return 0; } /**************************************************/ // Read stability file into a graph and a histogram /**************************************************/ void read_stability_file(string filename, TGraphErrors * graph, TH1F * hist){ std::ifstream file(filename); double line, sn, x, y, t, dp, sqrdp; while (file.good()){ file >> line >> sn >> x >> y >> t >> dp >> sqrdp; if (!file.good()) break; graph->SetPoint(graph->GetN(), t, sn*1000); graph->SetPointError(graph->GetN() - 1, 0, dp*1000); hist->Fill(sn*1000); } }