Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

HornModule.cxx

Go to the documentation of this file.
00001 #include "HornModule.h"
00002 
00003 #include "StripHist.h"
00004 
00005 #include <JobControl/JobCModuleRegistry.h>
00006 #include <JobControl/JobCResult.h>
00007 #include <MessageService/MsgService.h>
00008 
00009 #include <RawData/RawRecord.h>
00010 #include <RawData/RawBeamMonBlock.h>
00011 #include <RawData/RawBeamData.h>
00012 
00013 #include <DataUtil/GetRecords.h>
00014 
00015 #include <Conventions/Munits.h>
00016 
00017 #include <TGraph.h>
00018 #include <TCanvas.h>
00019 #include <TH1F.h>
00020 #include <TStyle.h>
00021 
00022 #include <vector>
00023 
00024 //ClassImp(HornModule)
00025 
00026 using namespace std;
00027 
00028 CVSID("$Id: HornModule.cxx,v 1.5 2005/06/01 17:01:47 thosieck Exp $");
00029 JOBMODULE(HornModule,"MonHorn","Horn related histogramming for Monitoring");
00030 
00031 static const char* get_name(int ind)
00032 {
00033     const char* names[] = {
00034         "Total Horn Current",
00035         "Quadrant 1 Horn Current",
00036         "Quadrant 2 Horn Current",
00037         "Quadrant 3 Horn Current",
00038         "Quadrant 4 Horn Current",
00039         0
00040     };
00041     if (ind < 0 || ind > 4) return 0;
00042     return names[ind];
00043 }
00044 HornModule::HornModule()
00045 {
00046 
00047     for (int ind=0; ind <5; ++ind) {
00048 
00049         StripHist* sh = 0;
00050 
00051         int max = 50;
00052         if (!ind) max = 200;
00053         sh = new StripHist(get_name(ind), get_name(ind), 2*max,-1.0*max,1.0*max);
00054         fStripHist[get_name(ind)] = sh;
00055         sh->SetStripRange(1*Munits::day);
00056         sh->GetHist().SetXTitle("Current (kAmp)");
00057         //sh->GetStrip().GetHistogram()->SetYTitle("Current (kAmp)");
00058     }
00059 }
00060 HornModule::~HornModule()
00061 {
00062 }
00063 
00064 typedef std::map<std::string,StripHist*>  StripHistMap;
00065 void HornModule::BeginJob()
00066 {
00067     HistMan hm = this->GetHistMan();
00068     StripHistMap::iterator mit, done=fStripHist.end();
00069     for (mit=fStripHist.begin(); mit != done; ++mit) {
00070         StripHist* sh = mit->second;
00071         TCanvas* canvas = new TCanvas(mit->first.c_str(),sh->GetHist().GetTitle(),500,400);
00072         sh->Draw("AL");
00073         hm.Adopt("Horn",canvas);
00074     }
00075 }
00076 
00077 void HornModule::Fill(const RawBeamMonHeaderBlock& /*head*/, const RawBeamMonBlock& block)
00078 {
00079     char dev[16] = "E:NSLIN ";
00080     double dae = 0, total = 0;
00081     for (int ind=4; ind>0; --ind) {
00082         dev[7] = 'A' + ind -1;  // Assume ASCII
00083         const RawBeamData* hc = block[dev];
00084 
00085         if (!(hc && hc->GetDataLength())) {
00086             MSG("BD",Msg::kDebug)
00087                 << "No " << dev << " in the data\n";
00088             continue;
00089         }
00090 
00091         StripHist* sh = fStripHist[get_name(ind)];
00092 
00093         double val = hc->GetData()[0];
00094         dae = hc->GetSeconds() + 1.0e-6*hc->GetMsecs();
00095         sh->Fill(dae,val);
00096         total += val;
00097     }
00098     fStripHist[get_name(0)]->Fill(dae,total);
00099 }
00100 

Generated on Sat Nov 21 22:46:20 2009 for loon by  doxygen 1.3.9.1