35 const char* fBank =
"OMCM" ;
40 int found =
event.FindBank(fBank, &bankLength, &bankType, &pdata);
44 printf(
"Dumping bank %s in hex\n",fBank);
45 for (
int j = 0; j < bankLength; j++)
46 printf(
"0x%08x%c", ((uint32_t*)pdata)[j], (j%10==9)?
'\n':
' ');
48 printf(
"Dumping bank %s in dec\n",fBank);
49 for (
int j = 0; j < bankLength; j++)
50 printf(
" %8d%c", ((uint32_t*)pdata)[j], (j%10==9)?
'\n':
' ');
74 int eventNum = ((uint32_t*)pdata)[1];
75 int spillNum = ((uint32_t*)pdata)[2] & 0xFFFF;
76 int trigBits = (((uint32_t*)pdata)[2] >> 16) & 0xFFFF;
77 const char* trigType =
"";
82 trigType =
"Beam spill";
85 if (trigBits == trigBeam) {
87 printf(
" eventNum %d, spillNum %d, trigBits 0x%04x, %s\n",eventNum,spillNum,trigBits,trigType);
90 printf(
"Can't find bank %s\n",fBank);
102 printf(
"Cannot open input file \"%s\"\n",fname);
115 printf(
"Have an event of type %d\n",eventId);
117 if ((eventId & 0xFFFF) == 0x8000)
122 else if ((eventId & 0xFFFF) == 0x8001)
135 printf(
"Processing event %d\n",i);
141 printf(
"Reached event %d, exiting loop.\n", i);
163 printf(
"\nUsage:\n");
164 printf(
"\n./event_skim.exe [-h] [-eMaxEvents] [file1 file2 ...]\n");
166 printf(
"\t-h: print this help message\n");
167 printf(
"\t-e: Number of events to read from input data files\n");
168 printf(
"\t-o: Generate output file \n");
170 printf(
"Example1: print events from file: ./event_skim.exe /data/alpha/current/run00500.mid.gz\n");
171 printf(
"Example2: output selected events: ./event_skim.exe -o skim_00500.mid.gz /data/alpha/current/run00500.mid.gz\n");
177 int main(
int argc,
char *argv[])
182 signal(SIGILL, SIG_DFL);
183 signal(SIGBUS, SIG_DFL);
184 signal(SIGSEGV, SIG_DFL);
185 signal(SIGPIPE, SIG_DFL);
187 std::vector<std::string> args;
188 for (
int i=0; i<argc; i++)
190 if (strcmp(argv[i],
"-h")==0)
192 args.push_back(argv[i]);
195 const char* outname = NULL;
197 for (
unsigned int i=1; i<args.size(); i++)
199 const char* arg = args[i].c_str();
202 if (strncmp(arg,
"-e",2)==0)
204 else if (strncmp(arg,
"-o",2)==0) {
205 outname = args[i+1].c_str();
208 else if (strcmp(arg,
"-h")==0)
210 else if (arg[0] ==
'-')
220 printf(
"Cannot open file \"%s\" for writing!\n", outname);
225 for (
unsigned int i=1; i<args.size(); i++)
227 const char* arg = args[i].c_str();
uint16_t GetEventId() const
return the event id
void HandleMidasEvent(TMidasEvent &event)
int main(int argc, char *argv[])
int ProcessMidasFile(const char *fname, TMWriterInterface *writer)
void TMWriteEvent(TMWriterInterface *writer, const TMEvent *event)
TMReaderInterface * TMNewReader(const char *source)
TMWriterInterface * TMNewWriter(const char *destination)
TMEvent * TMReadEvent(TMReaderInterface *reader)