Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
prfact_main.cxx
Go to the documentation of this file.
1//------------------------------------------------
2// prfact -- To print out the prescale factors found
3// in CODA file, then exit.
4//
5#include <iostream>
6#include <cstdlib>
7#include "THaCodaFile.h"
8#include "CodaDecoder.h"
9
10using namespace std;
11using namespace Decoder;
12
13int main(int argc, char* argv[])
14{
15 if (argc < 2) {
16 cout << "You made a mistake... \n" << endl;
17 cout << "Usage: prfact filename" << endl;
18 cout << " where 'filename' is the CODA file"<<endl;
19 cout << "\n... exiting." << endl;
20 exit(1);
21 }
22 const char* filename = argv[1];
23 THaCodaFile datafile;
24 if (datafile.codaOpen(filename) != CODA_OK) {
25 cout << "ERROR: Cannot open CODA data" << endl;
26 cout << "Perhaps you mistyped it" << endl;
27 cout << "... exiting." << endl;
28 exit(2);
29 }
30
31 auto* evdata = new CodaDecoder();
32 evdata->SetCodaVersion(datafile.getCodaVersion());
33
34 // Can tell evdata whether to use evtype
35 // 133 or 120 for prescale data. Default is 120.
36 evdata->SetOrigPS(133); // args are 120 or 133
37 cout << "Origin of PS data "<<evdata->GetOrigPS()<<endl;
38
39 // Loop over a finite number of events
40 UInt_t NUMEVT = 500;
41 bool found = false;
42 for (UInt_t i=0; i<NUMEVT; i++) {
43
44 int status = datafile.codaRead();
45
46 if ( status != CODA_OK ) {
47 if ( status == EOF) {
48 cout << "This is end of file !" << endl;
49 cout << "... exiting " << endl;
50 exit(1);
51 } else {
52 cout << hex << "ERROR: codaRead status = "
53 << status << dec << endl;
54 exit(2);
55 }
56 }
57
58 status = evdata->LoadEvent( datafile.getEvBuffer() );
59
60 if( status != CodaDecoder::HED_OK && status != CodaDecoder::HED_WARN ) {
61 cerr << "ERROR: LoadEvent status " << status << endl;
62 exit(3);
63 }
64
65 if(evdata->IsPrescaleEvent()) {
66 cout << endl << " Prescale factors from CODA file = "
67 << filename << endl;
68 cout << endl << " Trigger Prescale Factor" << endl;
69 for (UInt_t trig=1; trig<=8; trig++) {
70 cout <<" "<<dec<<trig<<" ";
71 UInt_t ps = evdata->GetPrescaleFactor(trig);
72 UInt_t psmax = (trig <= 4) ? 16777216 // 2^24
73 : 65536; // 2^16
74 ps = ps % psmax;
75 if (ps == 0) ps = psmax;
76 cout << ps << endl;
77 }
78 cout << endl;
79 cout << "Reminder: A 'zero' was interpreted as maximum." << endl;
80 cout << "Max for trig 1-4 = 2^24, for trig 5-8 = 2^16 \n"<< endl;
81 found = true;
82 break;
83 }
84 } // end of event loop
85
86 if( !found ) {
87 cout << "ERROR: prescale factors not found in the first ";
88 cout << dec << NUMEVT << " events " << endl;
89 exit(4);
90 }
91
92 datafile.codaClose();
93 exit(0);
94}
unsigned int UInt_t
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()
int main()
STL namespace.