Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
tstcoda_main.cxx
Go to the documentation of this file.
1// Test of THaCodaData abstract class
2// THaCodaFile and THaEtClient both inherit from THaCodaData.
3// R. Michaels, March 2001.
4
5#include "THaCodaFile.h"
6#include "THaEtClient.h"
7#include "TString.h"
8#include <iostream>
9
10using namespace std;
11using namespace Decoder;
12
13void usage();
14void do_something(UInt_t* data);
15
16int main(int argc, char* argv[])
17{
18
19 if (argc < 3) {
20 usage();
21 return 1;
22 }
23
24 int choice1 = atoi(argv[1]);
25 int choice2 = atoi(argv[2]);
26
27 THaCodaData *coda; // THaCodaData is abstract
28
29 if (choice1 == 1) { // CODA File
30
31// CODA file "snippet.dat" is a disk file of CODA data.
32 TString filename("snippet.dat");
33
34 if (choice2 == 1) { // Two types of THaCodaFile constructors
35 coda = new THaCodaFile();
36 if (coda->codaOpen(filename) != 0) {
37 cout << "ERROR: Cannot open CODA data" << endl;
38 return 1;
39 }
40 } else { // 2nd type of c'tor
41 coda = new THaCodaFile(filename);
42 }
43
44 } else { // Online ET connection
45
46 int mymode = 1;
47 TString mycomputer("129.57.32.30");
48 TString mysession("eel1");
49
50 if (choice2 == 1) { // Three different types of constructor
51 coda = new THaEtClient();
52 if (coda->codaOpen(mycomputer, mysession, mymode) != 0) {
53 cout << "ERROR: Cannot open ET connection" << endl;
54 return 1;
55 }
56 } else if (choice2 == 2) {
57 coda = new THaEtClient(mycomputer, mymode);
58 } else {
59 coda = new THaEtClient(mycomputer, mysession, mymode);
60 }
61
62 }
63
64// Loop over events
65 unsigned NUMEVT=20000;
66
67 for (unsigned iev = 0; iev < NUMEVT; iev++) {
68
69 int status = coda->codaRead();
70
71 if (status != 0) {
72 if ( status == -1) {
73 if (choice1 == 1) cout << "End of CODA file. Bye bye." << endl;
74 if (choice1 == 2) cout << "CODA/ET not running. Bye bye." << endl;
75 } else {
76 cout << "ERROR: codaRread status = " << hex << status << endl;
77 }
78 coda->codaClose();
79 return 0;
80
81 } else {
82
83 do_something( coda->getEvBuffer() );
84
85 }
86 }
87
88 coda->codaClose();
89 return 0;
90}
91
92
93void usage() {
94 cout << "Usage: 'tstcoda choice1 choice2' " << endl;
95 cout << "\n where choice1 = " << endl;
96 cout << " 1. open a CODA file and print data" << endl;
97 cout << " 2. open an ET connection and print data "<<endl;
98 cout << "\n and choice2 = " << endl;
99 cout << "1 - 3 are different ways to open connection "<<endl;
100 cout << "If CODA file, you have 2 choices "<<endl;
101 cout << "If ET connection, you have 3 choices "<<endl;
102}
103
104void do_something (UInt_t* data) {
105 unsigned len = data[0] + 1;
106 unsigned evtype = data[1]>>16;
107 unsigned evnum = data[4];
108 // Crude event dump
109 cout << "\n\n Event number " << dec << evnum;
110 cout << " length " << len << " type " << evtype << endl;
111 unsigned ipt = 0;
112 for (unsigned j = 0; j < (len/5); j++) {
113 cout << dec << "\n evbuffer[" << ipt << "] = ";
114 for (unsigned k=j; k<j+5; k++) {
115 cout << hex << data[ipt++] << " ";
116 }
117 cout << endl;
118 }
119 if (ipt < len) {
120 cout << dec << "\n evbuffer[" << ipt << "] = ";
121 for (unsigned k=ipt; k<len; k++) {
122 cout << hex << data[ipt++] << " ";
123 }
124 cout << endl;
125 }
126}
127
128
129
130
131
unsigned int UInt_t
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
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
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 Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
UInt_t * getEvBuffer()
Definition THaCodaData.h:76
virtual Int_t codaRead()=0
virtual Int_t codaClose()=0
virtual Int_t codaOpen(const char *file_name, Int_t mode=1)=0
int main()
STL namespace.
void usage()
void do_something(UInt_t *data)