Go to the documentation of this file.00001 #include "TBeamMonitorProc.h"
00002 #include "TGo4Version.h"
00003 #if __GO4BUILDVERSION__ > 40502
00004 #include "go4iostream.h"
00005 #else
00006 #include "Riostream.h"
00007 #endif
00008 #include "TTimeStamp.h"
00009 #include "TSystem.h"
00010 #include "TROOT.h"
00011 #include "TGo4Log.h"
00012
00013 #include "TGo4UserException.h"
00014 #include "TGo4MbsEvent.h"
00015 #include "roc/Message.h"
00016 #include "roc/Board.h"
00017
00018
00019 TBeamMonitorProc::TBeamMonitorProc(const char* name) :
00020 TCBMBeamtimeProc(name),
00021 fCrateInputEvent(0),
00022 fRocInputEvent(0),
00023 fEpicsInputEvent(0),
00024 fOutputEvent(0)
00025 {
00026 cout << "**** TBeamMonitorProc: Create instance " << name << endl;
00027 TString obname, obtitle;
00028
00029 fPar = (TBeamMonitorParam*) MakeParameter("BeamMonitorPar", "TBeamMonitorParam");
00030
00031 TString setupmacro = "set_BeamMonitorPar.C";
00032 if (!gSystem->AccessPathName(setupmacro.Data())) {
00033 TGo4Log::Info("Executing beam monitor condition setup script %s", setupmacro.Data());
00034 gROOT->ProcessLine(Form(".x %s", setupmacro.Data()));
00035
00036 } else {
00037 TGo4Log::Info("NO beam monitor setup script %s. Use previous values!", setupmacro.Data());
00038 }
00039
00040
00041
00042 fPmtDiff = MakeTH1('I', "BeamMonitor/PmtDiff", "Time difference between TDC[5][2] and TDC[5][3]", 4096, -2048, +2048, "time");
00043
00044
00045
00046
00047
00048
00049
00050 printf("TBeamMonitorProc Histograms created \n");
00051 fflush ( stdout);
00052 }
00053
00054
00055 TBeamMonitorProc::~TBeamMonitorProc()
00056 {
00057 }
00058
00059
00060
00061 void TBeamMonitorProc::InitEvent(TGo4EventElement* outevnt)
00062 {
00063
00064
00065
00066 if(fCrateInputEvent==0)
00067 {
00068 TCBMBeamtimeEvent* btevent=dynamic_cast<TCBMBeamtimeEvent*>(GetInputEvent());
00069 if(btevent)
00070 {
00071 fCrateInputEvent=dynamic_cast<TMbsCrateEvent*>(btevent->GetSubEvent("MBSCRATE"));
00072 fRocInputEvent=dynamic_cast<TRocEvent*>(btevent->GetSubEvent("ROC"));
00073 fEpicsInputEvent=dynamic_cast<TEpicsEvent*>(btevent->GetSubEvent("EPICS"));
00074 }
00075 else
00076 {
00077 fCrateInputEvent=dynamic_cast<TMbsCrateEvent*>(GetInputEvent());
00078
00079 }
00080 if(fCrateInputEvent==0) {
00081 GO4_STOP_ANALYSIS_MESSAGE("**** TBeamMonitorProc: Fatal error: no input event TMbsCrateEvent!!! STOP GO4");
00082 }
00083 if(fRocInputEvent==0) {
00084 GO4_STOP_ANALYSIS_MESSAGE("**** TBeamMonitorProc: Fatal error: no input event TRocEvent!!! STOP GO4");
00085 }
00086 if(fEpicsInputEvent==0) {
00087 Message(2,"**** TBeamMonitorProc: could not find TEpicsEvent!");
00088 }
00089
00090 }
00091
00092
00093
00094 if(fOutputEvent==0)
00095 {
00096 TCBMBeamtimeEvent* btevent=dynamic_cast<TCBMBeamtimeEvent*>(outevnt);
00097 if(btevent)
00098 {
00099 fOutputEvent=dynamic_cast<TBeamMonitorEvent*>(btevent->GetSubEvent("BEAM"));
00100 }
00101 else
00102 {
00103 fOutputEvent= dynamic_cast<TBeamMonitorEvent*>(outevnt);
00104 }
00105 if(fOutputEvent==0) {
00106 GO4_STOP_ANALYSIS_MESSAGE("**** TBeamMonitorProc: Fatal error: output event is not a TBeamMonitorEvent!!! STOP GO4");
00107 }
00108 }
00109 }
00110
00111
00112
00113 void TBeamMonitorProc::FinalizeEvent()
00114 {
00115 if(fCrateInputEvent && fCrateInputEvent->IsValid())
00116 {
00117 fPmtDiff->Fill(fCrateInputEvent->fMtdc[5].lead[2] - fCrateInputEvent->fMtdc[5].lead[3]);
00118
00119
00120
00121
00122 }
00123
00124 if( 0 && fEpicsInputEvent && fEpicsInputEvent->IsValid())
00125 {
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 }
00159 }