// PCAHists.cc // Contact person: Freija Descamps // See PCAHists.hh for more details //———————————————————————// // RAT stuff #include #include // ROOT stuff #include #include #include #include #include #include #include #include using namespace CLHEP; using namespace std; namespace RAT { PCAHists::PCAHists() { fIsInitialised=false; } PCAHists::~PCAHists() { } void PCAHists::InitialiseHists(const bool DoTWPCA, const bool DoGFPCA) { if( DoTWPCA==0 && DoGFPCA==0 ) return; // Get PCA user-defined intervals from PCA_GENERATION.ratdb DBLinkPtr PCAbank = DB::Get()->GetLink("PCA_GENERATION"); fMinComDiff=PCAbank->GetI("min_difference"); fMaxComDiff=PCAbank->GetI("max_difference"); // General summary histograms // Record 1D histogram of the total number of hits per PMT fPCAhitsPerPMT = new TH1I("fPCAhitPerPMT","",30000,0,30000); if( DoTWPCA ) { // Set up histogram RMS, TStep, FLate and Fout fRMSHist = new TH1F("fRMSHist","",100,0,7); fTStepHist = new TH1F("fTStepHist","",200,-10,10); fFlateHist = new TH1F("fFLateHist","",200,0,1); fFoutHist = new TH1F("fFoutHist","",200,0,1); } if( DoGFPCA ) { // Set up the comparison histograms 2D fPCAdiffPEAKQHS = new TH2D("fPCAdiffPEAKQHS","" ,9728,0,9728,100, fMinComDiff,fMaxComDiff); fPCAdiffTHRESHQHS = new TH2D("fPCAdiffTHRESHQHS","" ,9728,0,9728,100, fMinComDiff,fMaxComDiff); fPCAdiffHHPQHS = new TH2D("fPCAdiffHHPQHS","", 9728,0,9728,100, fMinComDiff,fMaxComDiff); fPCAdiffPEAKQHL = new TH2D("fPCAdiffPEAKQHL","", 9728,0,9728,100, fMinComDiff,fMaxComDiff); fPCAdiffTHRESHQHL = new TH2D("fPCAdiffTHRESHQHL","", 9728,0,9728,100, fMinComDiff,fMaxComDiff); fPCAdiffHHPQHL = new TH2D("fPCAdiffHHPQHL","", 9728,0,9728,100, fMinComDiff,fMaxComDiff); // Set up the comparison histograms 1D fPCAdiffPEAKQHS1d = new TH1F("fPCAdiffPEAKQHS1d","", 100, fMinComDiff,fMaxComDiff); fPCAdiffTHRESHQHS1d = new TH1F("fPCAdiffTHRESHQHS1d","", 100, fMinComDiff,fMaxComDiff); fPCAdiffHHPQHS1d = new TH1F("fPCAdiffHHPQHS1d","", 100, fMinComDiff,fMaxComDiff); fPCAdiffPEAKQHL1d = new TH1F("fPCAdiffPEAKQHL1d","", 100, fMinComDiff,fMaxComDiff); fPCAdiffTHRESHQHL1d = new TH1F("fPCAdiffTHRESHQHL1d","", 100, fMinComDiff,fMaxComDiff); fPCAdiffHHPQHL1d = new TH1F("fPCAdiffHHPQHL1d","", 100, fMinComDiff,fMaxComDiff); } fIsInitialised=true; } void PCAHists::WriteHists(const bool DoTWPCA, const bool DoGFPCA, TFile *rootfile) { if( DoTWPCA==0 && DoGFPCA==0 ) return; if( !fIsInitialised) return; rootfile->cd(); fPCAhitsPerPMT->Write(); if( DoTWPCA ) { fRMSHist->Write(); fTStepHist->Write(); fFlateHist->Write(); fFoutHist->Write(); } if( DoGFPCA ) { fPCAdiffPEAKQHS->Write(); fPCAdiffTHRESHQHS->Write(); fPCAdiffHHPQHS->Write(); fPCAdiffPEAKQHL->Write(); fPCAdiffTHRESHQHL->Write(); fPCAdiffHHPQHL->Write(); fPCAdiffPEAKQHS1d->Write(); fPCAdiffTHRESHQHS1d->Write(); fPCAdiffHHPQHS1d->Write(); fPCAdiffPEAKQHL1d->Write(); fPCAdiffTHRESHQHL1d->Write(); fPCAdiffHHPQHL1d->Write(); } // Clean up if( DoTWPCA ) { fRMSHist->Delete(); fTStepHist->Delete(); fFlateHist->Delete(); fFoutHist->Delete(); } if( DoGFPCA ) { fPCAdiffPEAKQHS->Delete(); fPCAdiffTHRESHQHS->Delete(); fPCAdiffHHPQHS->Delete(); fPCAdiffPEAKQHL->Delete(); fPCAdiffTHRESHQHL->Delete(); fPCAdiffHHPQHL->Delete(); fPCAdiffPEAKQHS1d->Delete(); fPCAdiffTHRESHQHS1d->Delete(); fPCAdiffHHPQHS1d->Delete(); fPCAdiffPEAKQHL1d->Delete(); fPCAdiffTHRESHQHL1d->Delete(); fPCAdiffHHPQHL1d->Delete(); } fPCAhitsPerPMT->Delete(); } void PCAHists::WriteSingleHist(TH1D *inhist, TFile *rootfile) { rootfile->cd(); inhist->Write(); } void PCAHists::WriteSingleHist(TH2D *inhist, TFile *rootfile) { rootfile->cd(); inhist->Write(); } void PCAHists::WriteSingleHist(TGraphErrors *ingraph, TFile *rootfile) { rootfile->cd(); ingraph->Write(); } void PCAHists::WriteSingleHist(TGraph2D *ingraph, TFile *rootfile) { rootfile->cd(); ingraph->Write(); } void PCAHists::SetAxes(const bool DoTWPCA, const bool DoGFPCA) { if( DoTWPCA==0 && DoGFPCA==0 ) return; if( !fIsInitialised) return; if( DoTWPCA ) { fRMSHist->GetXaxis()->SetTitle("Channel RMS [ns]"); fTStepHist->GetXaxis()->SetTitle("Channel TStep [ns]"); fFlateHist->GetXaxis()->SetTitle("Channel FLate [ns]"); fFoutHist->GetXaxis()->SetTitle("Channel Fout [ns]"); fRMSHist->GetYaxis()->SetTitle("Counts"); fTStepHist->GetYaxis()->SetTitle("Counts"); fFlateHist->GetYaxis()->SetTitle("Counts"); fFoutHist->GetYaxis()->SetTitle("Counts"); } if( DoGFPCA ) { // comparison graphs fPCAdiffPEAKQHS->GetXaxis()->SetTitle("PMT ID"); fPCAdiffTHRESHQHS->GetXaxis()->SetTitle("PMT ID"); fPCAdiffHHPQHS->GetXaxis()->SetTitle("PMT ID"); fPCAdiffPEAKQHL->GetXaxis()->SetTitle("PMT ID"); fPCAdiffTHRESHQHL->GetXaxis()->SetTitle("PMT ID"); fPCAdiffHHPQHL->GetXaxis()->SetTitle("PMT ID"); fPCAdiffPEAKQHS1d->GetXaxis() ->SetTitle("Difference (DB-data) in QHS peak (cap)"); fPCAdiffTHRESHQHS1d->GetXaxis() ->SetTitle("Difference (DB-data) in QHS threshold (cap)"); fPCAdiffHHPQHS1d->GetXaxis() ->SetTitle("Difference (DB-data) in QHS hhp (cap)"); fPCAdiffPEAKQHL1d->GetXaxis() ->SetTitle("Difference (DB-data) in QHL peak (cap)"); fPCAdiffTHRESHQHL1d->GetXaxis() ->SetTitle("Difference (DB-data) in QHL threshold (cap)"); fPCAdiffHHPQHL1d->GetXaxis() ->SetTitle("Difference (DB-data) in QHL hhp (cap)"); fPCAdiffPEAKQHS1d->GetYaxis()->SetTitle("Counts"); fPCAdiffTHRESHQHS1d->GetYaxis()->SetTitle("Counts"); fPCAdiffHHPQHS1d->GetYaxis()->SetTitle("Counts"); fPCAdiffPEAKQHL1d->GetYaxis()->SetTitle("Counts"); fPCAdiffTHRESHQHL1d->GetYaxis()->SetTitle("Counts"); fPCAdiffHHPQHL1d->GetYaxis()->SetTitle("Counts"); fPCAdiffPEAKQHS->GetYaxis() ->SetTitle("Difference in QHS peak (cap)"); fPCAdiffTHRESHQHS->GetYaxis() ->SetTitle("Difference in QHS threshold (cap)"); fPCAdiffHHPQHS->GetYaxis() ->SetTitle("Difference in QHS hhp (cap)"); fPCAdiffPEAKQHL->GetYaxis() ->SetTitle("Difference in QHL peak (cap)"); fPCAdiffTHRESHQHL->GetYaxis() ->SetTitle("Difference in QHL threshold (cap)"); fPCAdiffHHPQHL->GetYaxis() ->SetTitle("Difference in QHL hhp (cap)"); } } void PCAHists::Beautify() { // Set up some "pretty" Root style gStyle->SetOptStat(0); gStyle->SetStatColor(0); gStyle->SetTitleColor(1); gStyle->SetTitleBorderSize(0); gStyle->SetCanvasColor(0); gStyle->SetPadColor(0); gStyle->SetPadBorderMode(0); gStyle->SetCanvasBorderMode(0); gStyle->SetFrameBorderMode(0); gStyle->SetCanvasBorderMode(0); gStyle->SetPadBorderMode(0); } } // namespace RAT