Пример #1
0
int main(int argc, char* argv[])
{

   if (argc < 2) {
      cout << "You made a mistake... \n" << endl;
      cout << "Usage:   epicsd filename" << endl;
      cout << "  where 'filename' is the CODA file"<<endl;
      cout << "\n... exiting." << endl;
      exit(0);
   }
   TString filename = argv[1];
   THaCodaFile datafile;
   if (datafile.codaOpen(filename) != S_SUCCESS) {
        cout << "ERROR:  Cannot open CODA data" << endl;
        cout << "Perhaps you mistyped it" << endl;
        cout << "... exiting." << endl;
        exit(0);
   }
      
   THaEvData *evdata = new THaCodaDecoder();

// Loop over a finite number of events

   int NUMEVT=1000000;
   for (int i=0; i<NUMEVT; i++) {

     int status = datafile.codaRead();  
	                                            
     if ( status != S_SUCCESS ) {
        if ( status == EOF) {
           cout << "This is end of file !" << endl;
           cout << "... exiting " << endl;
           exit(1);
        } else {
  	   cout << hex << "ERROR: codaRread status = " << status << endl;
           exit(0);
        }
     }

     evdata->LoadEvent( datafile.getEvBuffer() );

     if(evdata->IsEpicsEvent()) {

       cout << "Some epics data --> "<<endl;
       cout << "hac_bcm_average "<<
	 evdata->GetEpicsData("hac_bcm_average")<<endl;
       cout << "IPM1H04A.XPOS  "<<
         evdata->GetEpicsData("IPM1H04A.XPOS")<<endl;
       cout << "IPM1H04A.YPOS  "<<
         evdata->GetEpicsData("IPM1H04A.YPOS")<<endl;

     }

   }  //  end of event loop


}
Пример #2
0
int main(int argc, char* argv[])
{

   if (argc < 2) {
      cout << "You made a mistake... \n" << endl;
      cout << "Usage:   tdecex filename" << endl;
      cout << "  where 'filename' is the CODA file"<<endl;
      cout << "\n... exiting." << endl;
      exit(0);
   }
   TString filename = argv[1];
   THaCodaFile datafile;
   if (datafile.codaOpen(filename) != S_SUCCESS) {
        cout << "ERROR:  Cannot open CODA data" << endl;
        cout << "Perhaps you mistyped it" << endl;
        cout << "... exiting." << endl;
        exit(0);
   }
   THaEvData *evdata = new THaCodaDecoder();
   THaGenDetTest mydetector;
   mydetector.init();

// Loop over a finite number of events

   int NUMEVT=50000;   
   int ievent;
   for (ievent=0; ievent<NUMEVT; ievent++) {
     if ( ievent > 0 && (
        ( (ievent <= 1000) && ((ievent%100) == 0) ) ||
        ( (ievent > 1000) && ((ievent%1000) == 0) ) ) )
              cout << "\n ---- Event " << ievent <<endl;
     int status = datafile.codaRead();  
     if ( status != S_SUCCESS ) {
        if ( status == EOF) {
           cout << "This is end of file !" << endl;
           cout << "... exiting " << endl;
           goto Finish;
        } else {
  	   cout << hex << "ERROR: codaRread status = " << status << endl;
           exit(0);
        }
     }
     evdata->LoadEvent( datafile.getEvBuffer() );   
     mydetector.process_event(evdata);

   }  //  end of event loop

Finish:
   cout << "\n Finished processing " << ievent << " events " << endl;
}
Пример #3
0
int main(int argc, char* argv[])
{

   int debug=0;
   if (argc > 1) debug=1;

// CODA file "snippet.dat" is a disk file of CODA data.  
   THaCodaFile datafile;   //     We could also open the data using a 
                        //     different constructor:                   
                        //     THaCodaFile datafile("snippet.dat");

   TString filename("snippet.dat");
   if (datafile.codaOpen(filename) != S_SUCCESS) {
        cout << "ERROR:  Cannot open CODA data" << endl;
        exit(0);
   }
      
   THaEvData *evdata = new THaCodaDecoder();

// Loop over events
 
   int NUMEVT=100;
   int ievent;
   for (ievent=0; ievent<NUMEVT; ievent++) {

     int status = datafile.codaRead();  
	                                            
     if ( status != S_SUCCESS ) {
        if ( status == EOF) {
           cout << "This is normal end of file.  Goodbye !" << endl;
        } else {
  	   cout << hex << "ERROR: codaRread status = " << status << endl;
        }
        goto Finish;
     }

// load_evbuffer() must be called each event before you access evdata contents.
// If you use the version of load_evbuffer() shown here, 
// evdata uses its private crate map (recommended).
// Alternatively you could use load_evbuffer(int* evbuffer, haCrateMap& map)
     
     evdata->LoadEvent( datafile.getEvBuffer() );   

     cout << "\nEvent type   " << dec << evdata->GetEvType() << endl;
     cout << "Event number " << evdata->GetEvNum()  << endl;
     cout << "Event length " << evdata->GetEvLength() << endl;
     if (evdata->IsPhysicsTrigger() ) { // triggers 1-14
        cout << "Physics trigger " << endl;
     }
     if(evdata->IsScalerEvent()) cout << "Scaler `event' " << endl;

// Now we want data from a particular crate and slot.
// E.g. crates are 1,2,3,13,14,15 (roc numbers), Slots are 1,2,3... 
// This is like what one might do in a detector decode() routine.

      int crate = 1;    // for example
      int slot = 24;

//  Here are raw 32-bit CODA words for this crate and slot
      cout << "Raw Data Dump for crate "<<dec<<crate<<" slot "<<slot<<endl; 
      int hit;
      for(hit=0; hit<evdata->GetNumRaw(crate,slot); hit++) {
        cout<<dec<<"raw["<<hit<<"] =   ";
        cout<<hex<<evdata->GetRawData(crate,slot,hit)<<endl;  
      }
// You can alternatively let evdata print out the contents of a crate and slot:
      evdata->PrintSlotData(crate,slot);

      if (evdata->IsPhysicsTrigger()) {
// Below are interpreted data, device types are ADC, TDC, or scaler.
// One needs to know the channel number within the device
        int channel = 7;    // for example
        cout << "Device type = ";
        cout << evdata->DevType(crate,slot) << endl;
        for (hit=0; hit<evdata->GetNumHits(crate,slot,channel); hit++) {
	   cout << "Channel " <<dec<<channel<<" hit # "<<hit<<"  ";
           cout << "data = " << evdata->GetData(crate,slot,channel,hit)<<endl;
        }
// Helicity data
        cout << "Helicity on left spectrometer "<<evdata->GetHelicity("left")<<endl;
        cout << "Helicity on right spectrometer "<<evdata->GetHelicity("right")<<endl;
        cout << "Helicity "<<evdata->GetHelicity()<<endl;
      }

// Scalers:  Although the getData methods works if you happen
// to know what crate & slot contain scaler data, here is
// another way to get scalers directly from evdata

      for (slot=0; slot<5; slot++) {
        cout << "\n scaler slot -> " << dec << slot << endl;; 
        for (int chan=0; chan<16; chan++) {
	  cout << "Scaler chan " <<  chan << "  ";
          cout << evdata->GetScaler("left",slot,chan);
          cout << "  "  << evdata->GetScaler(7,slot,chan) << endl;
	}
      }
 

   }  //  end of event loop

Finish:
   cout<<"\nAll done; processed "<<dec<<ievent<<" events"<<endl;
}
Пример #4
0
int main(int argc, char* argv[])
{

   if (argc < 2) {
      cout << "You made a mistake... \n" << endl;
      cout << "Usage:   prfact filename" << endl;
      cout << "  where 'filename' is the CODA file"<<endl;
      cout << "\n... exiting." << endl;
      exit(0);
   }
   TString filename = argv[1];
   THaCodaFile datafile;
   if (datafile.codaOpen(filename) != S_SUCCESS) {
        cout << "ERROR:  Cannot open CODA data" << endl;
        cout << "Perhaps you mistyped it" << endl;
        cout << "... exiting." << endl;
        exit(0);
   }
      
   THaEvData *evdata = new THaCodaDecoder();

   // Can tell evdata whether to use evtype 
   // 133 or 120 for prescale data.  Default is 120.
   evdata->SetOrigPS(133);   // args are 120 or 133
   cout << "Origin of PS data "<<evdata->GetOrigPS()<<endl;

// Loop over a finite number of events

   int NUMEVT=100000;
   for (int i=0; i<NUMEVT; i++) {

     int status = datafile.codaRead();  
	                                            
     if ( status != S_SUCCESS ) {
        if ( status == EOF) {
           cout << "This is end of file !" << endl;
           cout << "... exiting " << endl;
           exit(1);
        } else {
  	   cout << hex << "ERROR: codaRread status = " << status << endl;
           exit(0);
        }
     }

     evdata->LoadEvent( datafile.getEvBuffer() );   

     if(evdata->IsPrescaleEvent()) {
       cout <<"\n Prescale factors from CODA file = " << filename << endl;
       cout <<"\n Trigger      Prescale Factor"<< endl;
       for (int trig=1; trig<=8; trig++) {
	 cout <<"   "<<dec<<trig<<"             ";
         int ps = evdata->GetPrescaleFactor(trig);
         int psmax;
	 if (trig <= 4) psmax = 16777216;  // 2^24
         if (trig >= 5) psmax = 65536;     // 2^16
         ps = ps % psmax;
         if (ps == 0) ps = psmax;
         cout << ps << endl;
       }
       cout << "\nReminder: A 'zero' was interpreted as maximum."<<endl;
       cout << "Max for trig 1-4 = 2^24, for trig 5-8 = 2^16 \n"<<endl;
       exit(0);
     }

   }  //  end of event loop

   cout << "ERROR: prescale factors not found in the first "; 
   cout << dec << NUMEVT << " events " << endl;

}