source: tools/inspectrawfile/inspectrawfile.cpp@ 48

Last change on this file since 48 was 47, checked in by ogrimm, 15 years ago
Update to reflect change from NCMCBoards to NBoards
File size: 1.5 KB
Line 
1/********************************************************************\
2
3 inspectrawfile.cpp
4
5 Reads DAQ raw data file and prints run and event headers and data.
6 Main purpose is to demonstrate the procedure to read raw files.
7
8 Oliver Grimm
9
10\********************************************************************/
11
12#include <stdlib.h>
13#include <limits.h>
14#include "RawDataCTX.h"
15
16int main(int argc, char *argv[]) {
17
18 int NumEvents, NumBins, EventCount=0;
19
20 // Check command line syntax
21 if (argc<2 || argc>4) {
22 printf("Usage: %s <rawfile> [Number of events to display] [Number of data bins to display]\n", argv[0]);
23 exit(EXIT_SUCCESS);
24 }
25
26 NumEvents = argc>2 ? atoi(argv[2]) : INT_MAX;
27 RawDataCTX *RD = new RawDataCTX();
28
29 // Open data file, read and print run header, and loop through all events
30 if (RD->OpenDataFile(argv[1], stdout) != CTX_OK) {
31 printf("Error accessing file: %s\n", argv[1]);
32 }
33 else {
34 NumBins = argc==4 && atoi(argv[3])<RD->RHeader->Samples ? atoi(argv[3]) : RD->RHeader->Samples;
35
36 while (EventCount++ < NumEvents && RD->ReadEvent(0,stdout) == CTX_OK) {
37 for(int i=0; i<RD->RHeader->NBoards; i++)
38 for(int j=0; j<RD->RHeader->NChips*RD->RHeader->NChannels; j++) {
39 printf("\nBoard %d, channel %d\t", i,j);
40 for(int k=0; k<NumBins ; k++)
41 printf("%.1f ",RD->Data[i*RD->RHeader->NChips*RD->RHeader->NChannels*RD->RHeader->Samples+j*RD->RHeader->Samples+k]*RD->BStruct[i].ScaleFactor);
42 }
43 printf("\n\n");
44 }
45 }
46
47 delete RD;
48 return EXIT_SUCCESS;
49}
50
Note: See TracBrowser for help on using the repository browser.