CODA CLASSES   -   Layer on EVIO and ET Libraries

R. Michaels,   rom@jlab.org,   March 2001

Some classes that allow access to CODA data in Hall A have been written and will be a part of the new Hall A C++ analyzer.   These "CODA classes" are a layer on top of CODA software and can be run independently of the Hall A analyzer.   I keep the latest version of the code at www.jlab.org/~rom/codaclass.tar.     After untarring this file, see the README file.   Report problems or suggestions to me.   Below I explain the purposes and show a simple example of usage.

PURPOSES:



   int main(int argc, char* argv[]) {

        THaCodaData *coda;      // THaCodaData is abstract

        if (argc < 2) {
           explain_usage();
           return 1;
        }

        int choice1 = atoi(argv[1]);

        if (choice1 == 1) {  // CODA File

            // CODA file "e98108_1455.dat.0" is a disk file of CODA data.  
            TString filename("e98108_1455.dat.0"); 
            coda = new THaCodaFile();
            if (coda->codaOpen(filename) != 0) {
              cout << "ERROR:  Cannot open CODA data" << endl;
              return 1;
            }

        } else {         // Online ET connection

            int mymode = 1;     // 1=time-out mode (recommended)
            TString mycomputer("adaqcp");
            TString mysession("par1");

            coda = new THaEtClient();
            if (coda->codaOpen(mycomputer, mysession, mymode) != 0) {
              cout << "ERROR:  Cannot open ET connection" << endl;
              return 1;
            }
        }

        // Loop over events
        int NUMEVENTS_WANTED=20000;
        int *evbuffer;
        evbuffer = new int[coda->getBuffSize()];

        for (int ievent = 0; ievent < NUMEVENTS_WANTED; ievent++) {

           int status = coda->codaRead();  // read data

           if (status != 0) {
              if ( status == -1) {
                  cout << "Normal end of CODA data. Bye bye." << endl;
                  coda->codaClose();
                  return 0;
              } else {  // error will be printed.
                  return 1;
              }
 
           } else {

              // get one event buffer (raw data)
              evbuffer = coda->getEvBuffer();  
  
              do_something( evbuffer );        // analysis

           }
        }
        coda->codaClose();
        return 0;
   };