Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
tdecex_main.cxx
Go to the documentation of this file.
1//-----------------------------------------------------------
2// Tests of Hall A Event Decoder and an example of usage
3// with a "detector class" THaGenDetTest.
4// To test for speed, compile THaGenDetTest.h with PRINTOUT=0.
5// To get lots of print output, put PRINTOUT=1. (say, 50 events)
6//
7// R. Michaels, rom@jlab.org, Mar, 2000
8
9#include <iostream>
10#include <cstdlib>
11#include "THaCodaFile.h"
12#include "CodaDecoder.h"
13#include "THaGenDetTest.h"
14#include "TString.h"
15//#include "evio.h"
16
17using namespace std;
18using namespace Decoder;
19
20int main(int argc, char* argv[])
21{
22
23 if (argc < 2) {
24 cout << "You made a mistake... " << endl << endl;
25 cout << "Usage: tdecex filename" << endl;
26 cout << " where 'filename' is the CODA file"<<endl;
27 cout << endl << "... exiting." << endl;
28 exit(1);
29 }
30 TString filename = argv[1];
31 THaCodaFile datafile;
32 if (datafile.codaOpen(filename) != CODA_OK) {
33 cout << "ERROR: Cannot open CODA data" << endl;
34 cout << "Perhaps you mistyped it" << endl;
35 cout << "... exiting." << endl;
36 exit(2);
37 }
38 auto *evdata = new CodaDecoder();
39 evdata->SetCodaVersion(datafile.getCodaVersion());
40 THaGenDetTest mydetector;
41 mydetector.init();
42
43// Loop over a finite number of events
44
45 unsigned NUMEVT=50000;
46 unsigned ievent = 0;
47 for (; ievent<NUMEVT; ievent++) {
48 if ( ievent > 0 && (
49 ( (ievent <= 1000) && ((ievent%100) == 0) ) ||
50 ( (ievent > 1000) && ((ievent%1000) == 0) ) ) )
51 cout << endl << " ---- Event " << ievent <<endl;
52 int status = datafile.codaRead();
53 if ( status != CODA_OK ) {
54 if ( status == EOF) {
55 cout << "This is end of file !" << endl;
56 cout << "... exiting " << endl;
57 goto Finish;
58 } else {
59 cout << hex << "ERROR: codaRread status = " << status << endl;
60 exit(3);
61 }
62 }
63 status = evdata->LoadEvent( datafile.getEvBuffer() );
64 if( status != CodaDecoder::HED_OK && status != CodaDecoder::HED_WARN ) {
65 cerr << "ERROR " << status << " while decoding event " << ievent
66 << ". Exiting." << endl;
67 exit(status);
68 }
69 mydetector.process_event(evdata);
70
71 } // end of event loop
72
73Finish:
74 cout << endl << " Finished processing " << ievent << " events " << endl;
75 datafile.codaClose();
76 return 0;
77}
78
79
80
81
82
83
84
85
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
#define CODA_OK
Definition THaCodaData.h:28
UInt_t * getEvBuffer()
Definition THaCodaData.h:76
virtual Int_t getCodaVersion()
virtual Int_t codaOpen(const char *filename, Int_t mode=1)
virtual Int_t codaClose()
virtual Int_t codaRead()
void process_event(THaEvData *evdata)
int main()
STL namespace.