• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

onlinemonitor/trbmonitor/TTrbAnalysis.cxx (r4864/r4070)

Go to the documentation of this file.
00001 #include "TTrbAnalysis.h"
00002 
00003 #include <stdlib.h>
00004 
00005 #include "TCanvas.h"
00006 #include "TH1.h"
00007 #include "TFile.h"
00008 
00009 #include "Go4EventServer.h"
00010 #include "TGo4AnalysisStep.h"
00011 #include "TGo4Version.h"
00012 
00013 #include "TTrbEvent.h"
00014 #include "TTrbProc.h"
00015 #include "TGo4StepFactory.h"
00016 #include "TGo4MbsEvent.h"
00017 
00018 TTrbAnalysis::TTrbAnalysis() :
00019         TGo4Analysis(),
00020         fRawEvent(0),
00021         fUnpackEvent(0),
00022         fSize(0),
00023         fEvents(0)
00024 {
00025         TGo4Log::Error("Wrong constructor TTrbAnalysis()!");
00026 }
00027 
00029 TTrbAnalysis::TTrbAnalysis(int argc, char** argv) :
00030         TGo4Analysis(argc, argv),
00031         fRawEvent(0),
00032         fUnpackEvent(0),
00033         fSize(0),
00034         fEvents(0)
00035 {
00036         if (!TGo4Version::CheckVersion(__GO4BUILDVERSION__))
00037         {
00038            TGo4Log::Error("Go4 version mismatch");
00039                 exit(-1);
00040         }
00041 
00042         TGo4Log::Info("TTrbAnalysis: Create");
00043 
00047 
00048         TGo4StepFactory* factory1 = new TGo4StepFactory ("Unpack-factory");
00049 
00050         factory1->DefUserEventSource ("TTrbSource");                    
00051         factory1->DefInputEvent ("RawEvent","TGo4MbsEvent");    
00052         factory1->DefEventProcessor ("UnpackProc", "TTrbProc"); 
00053         factory1->DefOutputEvent ("UnpackEvent", "TTrbEvent");  
00054 
00055         TGo4UserSourceParameter* source1 = new TGo4UserSourceParameter ("test.hld");
00056         TGo4FileStoreParameter* store1 = new TGo4FileStoreParameter (Form("%sOutput", argv[0]));
00057         store1->SetOverwriteMode (kTRUE);
00058         TGo4AnalysisStep* step1 = new TGo4AnalysisStep ("Unpack",factory1,source1,store1,0);
00059 
00060         step1->SetSourceEnabled (kTRUE);
00061         step1->SetStoreEnabled (kFALSE);                
00062         step1->SetProcessEnabled (kTRUE);
00063         step1->SetErrorStopEnabled (kTRUE);
00064 
00065         AddAnalysisStep(step1);
00066 }
00067 
00068 TTrbAnalysis::~TTrbAnalysis()
00069 {
00070    TGo4Log::Info("TTrbAnalysis: Delete");
00071 }
00072 
00073 Int_t TTrbAnalysis::UserPreLoop()
00074 {
00075    TGo4Log::Info("TTrbAnalysis: PreLoop");
00076 
00078         fRawEvent = dynamic_cast<TGo4MbsEvent*> (GetInputEvent("Unpack"));              // of step "Unpack"
00079         fUnpackEvent = dynamic_cast<TTrbEvent*> (GetOutputEvent("Unpack"));
00080         fEvents = 0;
00081 
00084         fSize = (TH1D*)GetHistogram("Eventsize");
00085         if (fSize==0)
00086         {
00088                 fSize = new TH1D ("Eventsize", "Read columns", Trb_BUFSIZE/32, 0, Trb_BUFSIZE);
00089                 AddHistogram (fSize);
00090         }
00091 
00094 //      ClearObjects ("Histograms");
00095 
00096         return 0;
00097 }
00098 
00099 Int_t TTrbAnalysis::UserPostLoop()
00100 {
00101         TFile calibHistoFile("calibHistos.root", "recreate");
00102 
00103         calibHistoFile.Close();
00104 
00105         TGo4Log::Info("TTrbAnalysis: PostLoop");
00106         TGo4Log::Info("Total events: %d", fEvents);
00107         fUnpackEvent = 0;               
00108         fRawEvent = 0;
00109         fEvents = 0;
00110         return 0;
00111 }
00112 
00113 Int_t TTrbAnalysis::UserEventFunc()
00114 {
00116         Int_t value = 0;
00117         if (fRawEvent) value = fRawEvent->GetDlen();
00118         fSize->Fill(value);             
00119         fEvents++;
00120         return 0;
00121 }

Generated on Tue Dec 10 2013 04:52:23 for ROCsoft by  doxygen 1.7.1