/**************************************** * Root 6 macro: tbcPlotResults.C * * Plot results of tbcFit * * M. Staric, September 2016 * ****************************************/ // function prototypes string toString(int n); bool wait(); void timeDiff(TFile* file); void dt(TFile* file); void tcor(TFile* file); void calPulse(TFile* file); void laser(TFile* file); void laserProy(TFile* file); void calPulseProy(TFile* file); // global variables TCanvas* canvas = 0; std::string canvasTitle; // -- code --------------------------------------------------------- /** * Plot the results of tbcFit.C saved in root files * @param fileName file name of a root file (ex.: tbc/tbcScrod103.root) */ void tbcPlotResults(std::string fileName) { TFile* file = TFile::Open(fileName.c_str()); if(!file) return; canvasTitle = fileName; canvas = new TCanvas("tbcPlots", canvasTitle.c_str(), 800, 800); canvas->Divide(4,4); canvas->Show(); timeDiff(file); if(!wait()) return; dt(file); if(!wait()) return; tcor(file); if(!wait()) return; calPulse(file); if(!wait()) return; calPulseProy(file); if(!wait()) return; laser(file); if(!wait()) return; laserProy(file); } void timeDiff(TFile* file) { canvas->Clear(); canvas->Divide(4,4); std::string title = canvasTitle + ": raw cal pulse time difference vs. sample"; canvas->SetTitle(title.c_str()); TH1F* success = (TH1F*) file->Get("success"); for(int i = 0; i < 16; i++) { canvas->cd(i + 1); int chan = i * 8 + 7; std::string name = "timeDiff_ch" + toString(chan); TProfile* prof = (TProfile*) file->Get(name.c_str()); if(!prof) continue; if(success) { if(success->GetBinContent(chan + 1) > 0) { prof->SetLineColor(1); } else { prof->SetLineColor(2); } } prof->SetMinimum(45); prof->SetMaximum(75); prof->Draw(); } canvas->Update(); } void dt(TFile* file) { canvas->Clear(); canvas->Divide(4,4); std::string title = canvasTitle + ": dt vs. sample"; canvas->SetTitle(title.c_str()); for(int i = 0; i < 16; i++) { canvas->cd(i + 1); int chan = i * 8 + 7; std::string name = "dt_ch" + toString(chan); TH1F* h = (TH1F*) file->Get(name.c_str()); if(!h) continue; h->Draw(); } canvas->Update(); } void tcor(TFile* file) { canvas->Clear(); canvas->Divide(4,4); std::string title = canvasTitle + ": tcor vs. sample"; canvas->SetTitle(title.c_str()); for(int i = 0; i < 16; i++) { canvas->cd(i + 1); int chan = i * 8 + 7; std::string name = "tcor_ch" + toString(chan); TH1F* h = (TH1F*) file->Get(name.c_str()); if(!h) continue; h->Draw(); } canvas->Update(); } void calPulse(TFile* file) { canvas->Clear(); canvas->Divide(4,4); std::string title = canvasTitle + ": corrected cal pulse time difference vs. sample"; canvas->SetTitle(title.c_str()); for(int i = 0; i < 16; i++) { canvas->cd(i + 1); int chan = i * 8 + 7; std::string name = "calPulse_ch" + toString(chan); TH2F* h = (TH2F*) file->Get(name.c_str()); if(!h) continue; h->Draw("colz"); } canvas->Update(); } void calPulseProy(TFile* file) { canvas->Clear(); canvas->Divide(4,4); std::string title = canvasTitle + ": corrected cal pulse time difference (projection)"; canvas->SetTitle(title.c_str()); for(int i = 0; i < 16; i++) { canvas->cd(i + 1); int chan = i * 8 + 7; std::string name = "calPulse_ch" + toString(chan); TH2F* h = (TH2F*) file->Get(name.c_str()); if(!h) continue; TH1D* py = h->ProjectionY(); py->Draw(); } canvas->Update(); } void laser(TFile* file) { canvas->Clear(); canvas->Divide(4,4); std::string title = canvasTitle + ": corrected laser time vs. sample"; canvas->SetTitle(title.c_str()); for(int i = 0; i < 16; i++) { canvas->cd(i + 1); int chan = i * 8 + 7; std::string name = "laser_ch" + toString(chan); TH2F* h = (TH2F*) file->Get(name.c_str()); if(!h) continue; h->Draw("colz"); } canvas->Update(); } void laserProy(TFile* file) { canvas->Clear(); canvas->Divide(4,4); std::string title = canvasTitle + ": corrected laser time (projection)"; canvas->SetTitle(title.c_str()); for(int i = 0; i < 16; i++) { canvas->cd(i + 1); int chan = i * 8 + 7; std::string name = "laser_ch" + toString(chan); TH2F* h = (TH2F*) file->Get(name.c_str()); if(!h) continue; TH1D* py = h->ProjectionY(); py->Draw(); } canvas->Update(); } string toString(int n) { stringstream ss; ss << n; string str; ss >> str; return str; } bool wait() { std::cout << "Type to continue or Q to quit "; char qq[10]; std::cin.getline(qq, 10); if (strcmp(qq, "q") == 0 || strcmp(qq, ".q") == 0 || strcmp(qq, "Q") == 0) return false; return true; }