Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaEpicsEvtHandler.cxx
Go to the documentation of this file.
1
2//
3// THaEpicsEvtHandler
4//
5// Event handler for Hall A EPICS data events
6// R. Michaels, April 2015
7//
8// This class does the following
9// For a particular set of event types (here, event type 131)
10// use the THaEpics class to decode the data. This class interacts
11// with THaOutput much the same way the old (now obsolete) THaCodaDecoder
12// did, providing EPICS data to the output.
13//
14// At the moment, I foresee this as a member of THaAnalyzer.
15// To use as a plugin with your own modifications, you can do this:
16// gHaEvtHandlers->Add (new THaEpicsEvtHandler("epics","HA EPICS event type 131"));
17//
19
20#include "THaEvtTypeHandler.h"
21#include "THaEpicsEvtHandler.h"
22#include "THaCodaData.h"
23#include "THaEvData.h"
24#include "THaEpics.h"
25#include "TTree.h"
26#include "TString.h"
27#include <iostream>
28#include "THaVarList.h"
29
30using namespace std;
31using namespace Decoder;
32
34 const char* description ) :
35 THaEvtTypeHandler(name, description),
36 fEpics{new Decoder::THaEpics()}
37{
38}
39
43
44Bool_t THaEpicsEvtHandler::IsLoaded(const char* tag) const {
45 if ( !fEpics ) return false;
46 return fEpics->IsLoaded(tag);
47}
48
50 assert( IsLoaded(tag) ); // Should never ask for non-existent data
51 if ( !fEpics ) return 0;
52 return fEpics->GetData(tag, event);
53}
54
55time_t THaEpicsEvtHandler::GetTime( const char* tag, UInt_t event ) const {
56 assert( IsLoaded(tag) );
57 if ( !fEpics ) return 0;
58 return fEpics->GetTimeStamp(tag, event);
59}
60
62 assert( IsLoaded(tag) );
63 if ( !fEpics ) return {"nothing"};
64 return {fEpics->GetString(tag, event).c_str()};
65}
66
68
69 if ( !IsMyEvent(evdata->GetEvType()) ) return -1;
70
71 UInt_t evbuffer[MAXDATA];
72 UInt_t recent_event = evdata->GetEvNum();
73
74 if (evdata->GetEvLength() >= MAXDATA)
75 cerr << "EpicsHandler: need a bigger buffer ! "<<endl;
76
77// Copy the buffer. EPICS events are infrequent, so no harm.
78 for( UInt_t i = 0; i < evdata->GetEvLength(); i++ )
79 evbuffer[i] = evdata->GetRawData(i);
80
81 if (fDebugFile) EvDump(evdata);
82
83 fEpics->LoadData(evbuffer, recent_event);
84
85 return 1;
86}
87
89
90 if( fDebug )
91 cout << "Howdy ! We are initializing THaEpicsEvtHandler !! "
92 "name = " << fName << endl;
93
94// Set the event type to the default unless the client has already defined it.
95 if( GetNumTypes() == 0 )
97
98 fStatus = kOK;
99 return kOK;
100}
101
int Int_t
unsigned int UInt_t
bool Bool_t
double Double_t
char name[80]
Bool_t IsLoaded(const char *tag) const
Definition THaEpics.cxx:96
Double_t GetData(const char *tag, UInt_t event=0) const
static const Int_t MAXDATA
THaEpicsEvtHandler(const char *name, const char *description)
TString GetString(const char *tag, UInt_t event=0) const
std::unique_ptr< Decoder::THaEpics > fEpics
time_t GetTime(const char *tag, UInt_t event=0) const
virtual Int_t End(THaRunBase *r=nullptr)
virtual Int_t Analyze(THaEvData *evdata)
Bool_t IsLoaded(const char *tag) const
UInt_t GetEvType() const
Definition THaEvData.h:53
UInt_t GetRawData(UInt_t crate, UInt_t slot, UInt_t hit) const
Definition THaEvData.h:288
UInt_t GetEvNum() const
Definition THaEvData.h:56
UInt_t GetEvLength() const
Definition THaEvData.h:54
virtual Bool_t IsMyEvent(UInt_t type) const
virtual void EvDump(THaEvData *evdata) const
virtual UInt_t GetNumTypes()
virtual void SetEvtType(UInt_t evtype)
std::ofstream * fDebugFile
TString fName
static const UInt_t EPICS_EVTYPE
Definition Decoder.h:46
STL namespace.
ClassImp(TPyArg)