00001 #include "NpotModule.h"
00002 #include "StripHist.h"
00003
00004 #include <JobControl/JobCModuleRegistry.h>
00005 #include <JobControl/JobCResult.h>
00006 #include <MessageService/MsgService.h>
00007
00008 #include <RawData/RawRecord.h>
00009 #include <RawData/RawBeamMonBlock.h>
00010 #include <RawData/RawBeamData.h>
00011
00012 #include <DataUtil/GetRecords.h>
00013 #include <HistMan/HistMan.h>
00014
00015 #include <Conventions/Munits.h>
00016
00017 #include <TGraph.h>
00018 #include <TCanvas.h>
00019 #include <TStyle.h>
00020
00021 #include <vector>
00022
00023
00024
00025 using namespace std;
00026
00027 CVSID("$Id: NpotModule.cxx,v 1.9 2005/06/01 17:01:47 thosieck Exp $");
00028 JOBMODULE(NpotModule,"MonNpot","Generate PoT related for Monitoring");
00029
00030 NpotModule::NpotModule()
00031 {
00032
00033 fStripHist = new StripHist("Protons Delivered Per Spill",
00034 "Number of Protons Delivered to NuMI per Spill",
00035 250,0,25);
00036 fStripHist->SetStripRange(1*Munits::day);
00037 }
00038
00039 NpotModule::~NpotModule()
00040 {
00041 }
00042
00043
00044 void NpotModule::BeginJob()
00045 {
00046 TCanvas* canvas = new TCanvas("Protons Delivered Per Spill",
00047 "Number of Protons Delivered to NuMI",
00048 500,400);
00049
00050 TH1D& hist = fStripHist->GetHist();
00051 hist.SetXTitle("Protons Delivered per Spill (1E12)");
00052
00053 canvas->cd();
00054 fStripHist->Draw("AB");
00055
00056 HistMan hm = this->GetHistMan();
00057 hm.Adopt("Protons",canvas);
00058 }
00059
00060
00061 void NpotModule::Fill(const RawBeamMonHeaderBlock& , const RawBeamMonBlock& block)
00062 {
00063 const RawBeamData* tortgt = block["E:TORTGT"];
00064 if (!tortgt) {
00065 MSG("BD",Msg::kWarning)
00066 << "No TORTGT in the data\n";
00067 return;
00068 }
00069 if (! tortgt->GetDataLength()) {
00070 MSG("BD",Msg::kWarning)
00071 << "TORTGT exists but w/out data\n";
00072 return;
00073 }
00074
00075 double npot = tortgt->GetData()[0];
00076 double dae = 1.0*tortgt->GetSeconds() + tortgt->GetMsecs()*0.001;
00077 MSG("BD",Msg::kDebug)
00078 << "npot = " << npot << ", dae = " << Form("%12u",dae) << endl;
00079
00080 fStripHist->Fill(dae,npot);
00081 }
00082