#include namespace RAT { CrateGainMonitor::CrateGainMonitor() : Processor("CrateGainMonitor"){} void CrateGainMonitor::BeginOfRun(DS::Run&){ DBLinkPtr fDB = DB::Get()->GetLink("CRATE_GAIN_MONITOR"); fFileName = "Charge_Histograms"; fNHitThreshold = static_cast(fDB->GetI("nhits_threshold")); fSkipESUM = fDB->GetZ("skip_esum"); // 19 crates in the detector for(int crate = 0; crate < 19; crate++){ sprintf(HistogramName, "Crate%dQHS", crate); qhs_histograms[crate] = new TH1D(HistogramName, HistogramName, 120, -20, 100); sprintf(HistogramName, "Crate%dQHL", crate); qhl_histograms[crate] = new TH1D(HistogramName, HistogramName, 120, -20, 100); sprintf(HistogramName, "Crate%dQLX", crate); qlx_histograms[crate] = new TH1D(HistogramName, HistogramName, 120, -20, 100); } } Processor::Result CrateGainMonitor::DSEvent(DS::Run&, DS::Entry& ds){ for(size_t iEV = 0; iEV < ds.GetEVCount(); iEV++){ Event(ds, ds.GetEV(iEV)); } return OK; } Processor::Result CrateGainMonitor::Event(DS::Entry&, DS::EV& ev){ // Skip orphans if(ev.GetTrigType() == 0){ return OK; } // Skip the forced triggers if(ev.GetTrigType() & DU::TrigBits::GetMask("Pedestal") || ev.GetTrigType() & DU::TrigBits::GetMask("PulseGT")){ return OK; } // Only look at relatively high nhit events if(ev.GetUncalPMTs().GetCount() < fNHitThreshold){ return OK; } // Skip flashers and shark-fins if(fSkipESUM && ev.GetTrigType() & DU::TrigBits::GetMask("ESHigh")){ return OK; } const DU::PMTCalStatus& PMTCalStatus = DU::Utility::Get()->GetPMTCalStatus(); const RAT::DS::CalPMTs& CalPMTs = ev.GetCalPMTs(); for(size_t iPMT = 0; iPMT < CalPMTs.GetCount(); iPMT++){ const RAT::DS::PMTCal& pmt = CalPMTs.GetPMT(iPMT); if(PMTCalStatus.GetHitStatus(pmt) != 0){ continue; } int crate = pmt.GetCrate(); double qhs = pmt.GetQHS(); double qhl = pmt.GetQHL(); double qlx = pmt.GetQLX(); qhs_histograms[crate]->Fill(qhs); qhl_histograms[crate]->Fill(qhl); qlx_histograms[crate]->Fill(qlx); } return OK; } void CrateGainMonitor::EndOfRun(DS::Run& run){ sprintf(TFileName, "%s_%d.root", fFileName.c_str(), run.GetRunID()); TFile *f = TFile::Open(TFileName, "RECREATE"); f->cd(); for(size_t crate = 0; crate < 19; crate++){ qhs_histograms[crate]->Write(); qhl_histograms[crate]->Write(); qlx_histograms[crate]->Write(); } f->Close(); } }