Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaCodaRun.cxx
Go to the documentation of this file.
1//*-- Author : Ole Hansen 13/05/00
2
4//
5// THaCodaRun
6//
7// Description of a run based on CODA data.
8//
10
11#include "THaCodaRun.h"
12#include "THaCodaData.h"
13#include "TClass.h"
14#include <cassert>
15
16using namespace std;
17using namespace Decoder;
18
19//_____________________________________________________________________________
20THaCodaRun::THaCodaRun( const char* description )
21 : THaRunBase(description), fCodaData(nullptr)
22{
23 // Normal & default constructor
24}
25
26//_____________________________________________________________________________
28 : THaRunBase(rhs), fCodaData(nullptr)
29{
30 // Normal & default constructor
31}
32
33//_____________________________________________________________________________
34// Destructor. The CODA data will be closed by the THaCodaData
35// destructor if necessary.
36THaCodaRun::~THaCodaRun() = default;
37
38//_____________________________________________________________________________
40{
41 // Assignment operator
42
43 if( this != &rhs ) {
45 fCodaData = nullptr;
46 }
47 return *this;
48}
49
50//_____________________________________________________________________________
52{
53 // Convert THaCodaData return codes to THaRunBase codes
54
55 switch( coda_retcode ) {
56 case CODA_OK:
57 return READ_OK;
58
59 case CODA_EOF:
60 return READ_EOF;
61
62 case CODA_ERROR:
63 return READ_ERROR;
64
65 case CODA_FATAL:
66 return READ_FATAL;
67
68 default:
69 return READ_ERROR;
70 }
71 // not reached
72}
73
74//_____________________________________________________________________________
76{
77 // Close the CODA run
78
79 fOpened = false;
80 if( !IsOpen() )
81 return READ_OK;
82
83 return ReturnCode( fCodaData->codaClose() );
84}
85
86//_____________________________________________________________________________
87Int_t THaCodaRun::GetCodaVersion() // NOLINT(misc-no-recursion)
88{
89 // Get CODA format version of current data source.
90 // Returns either 2 or 3, or -1 on error (file not open, etc.)
91
92 if( fDataVersion > 0 ) // Override with user-specified value
93 return fDataVersion;
94 //FIXME Workaround for this function not being virtual
95 if( !fCodaData && IsA() != THaCodaRun::Class() ) {
96 if( IsA()->GetMethodAllAny("GetDataVersion") ==
97 THaCodaRun::Class()->GetMethodAllAny("GetDataVersion") ) {
98 return -1;
99 }
100 return GetDataVersion();
101 }
102 assert(fCodaData);
103 return (fDataVersion = fCodaData->getCodaVersion());
104}
105
106//_____________________________________________________________________________
108{
109 const char* const here = "THaCodaRun::SetCodaVersion";
110
111 if (vers != 2 && vers != 3) {
112 Error( here, "Illegal CODA version = %d. Must be 2 or 3.", vers );
113 return -1;
114 }
115 if( IsOpen() ) {
116 Error( here, "CODA data source is open, cannot set version" );
117 return -1;
118 }
119 return (fDataVersion = vers);
120}
121
122//_____________________________________________________________________________
124{
125 // Return address of the event buffer allocated and filled
126 // by fCodaData->codaRead()
127
128 assert( fCodaData );
129 return fCodaData->getEvBuffer();
130}
131
132//_____________________________________________________________________________
134{
135 assert( fCodaData );
136 return fCodaData->isOpen();
137}
138
139//_____________________________________________________________________________
141{
142 // Read one event from CODA file.
143
144 assert( fCodaData );
145 return ReturnCode( fCodaData->codaRead() );
146}
147
148//_____________________________________________________________________________
int Int_t
unsigned int UInt_t
std::unique_ptr< Decoder::THaCodaData > fCodaData
bool Bool_t
#define CODA_ERROR
Definition THaCodaData.h:30
#define CODA_FATAL
Definition THaCodaData.h:31
#define CODA_EOF
Definition THaCodaData.h:29
#define CODA_OK
Definition THaCodaData.h:28
static const char *const here
Definition THaVar.cxx:64
virtual const UInt_t * GetEvBuffer() const
std::unique_ptr< Decoder::THaCodaData > fCodaData
Definition THaCodaRun.h:35
static Int_t ReturnCode(Int_t coda_retcode)
Int_t GetCodaVersion()
virtual Bool_t IsOpen() const
virtual THaCodaRun & operator=(const THaRunBase &)
virtual Int_t Close()
virtual ~THaCodaRun()
virtual Int_t GetDataVersion()
Definition THaCodaRun.h:41
virtual Int_t ReadEvent()
THaCodaRun(const char *description="")
Int_t SetCodaVersion(Int_t version)
Bool_t fOpened
Definition THaRunBase.h:99
virtual THaRunBase & operator=(const THaRunBase &rhs)
Int_t fDataVersion
Definition THaRunBase.h:106
static TClass * Class()
TClass * IsA() const override
virtual void Error(const char *method, const char *msgfmt,...) const
STL namespace.
ClassImp(TPyArg)