AlcapDAQ  1
Macros | Functions | Variables
show_pulses.cxx File Reference
#include <stdio.h>
#include <stdlib.h>
#include "midas.h"
#include "../analyzer/compress/mucap_compress.h"
#include "TH1.h"
#include "TCanvas.h"

Go to the source code of this file.

Macros

#define _FILE_OFFSET_BITS   64
 
#define PRINT_SAMPLES   1
 

Functions

void process_file (char *input_filename, int addr, int fadc)
 
int process_event (void *pevent, int addr, int fadc)
 
bool get_input_event (FILE *fp, char *pevent, int event_number)
 
int processIsland (int t0, int nsamples, int *samples, int channel)
 

Variables

TCanvas * c = 0
 

Macro Definition Documentation

#define _FILE_OFFSET_BITS   64

Definition at line 1 of file show_pulses.cxx.

#define PRINT_SAMPLES   1

Definition at line 22 of file show_pulses.cxx.

Function Documentation

bool get_input_event ( FILE *  fp,
char *  pevent,
int  event_number 
)

Definition at line 29 of file show_pulses.cxx.

References printf(), and SUCCESS.

30 {
31  int event_size, size_read;
32  EVENT_HEADER *header;
33 
34  size_read = fread(pevent, 1, sizeof(EVENT_HEADER), fp);
35  if (size_read != sizeof(EVENT_HEADER))
36  return !SUCCESS;
37 
38  header = (EVENT_HEADER *) pevent;
39  printf("block# %d\n", header->serial_number);
40 
41  if (event_number == 0 && header->trigger_mask != MIDAS_MAGIC) {
42  fprintf(stderr, "Input is not a valid MIDAS file\n");
43  exit(1);
44  }
45 
46  event_size = header->data_size;
47 
48  if ((unsigned int) event_size >= MAX_EVENT_SIZE - sizeof(EVENT_HEADER)) {
49  fprintf(stderr, "Invalid event size %d\n", event_size);
50  exit(1);
51  }
52 
53  size_read = fread(pevent + sizeof(EVENT_HEADER), 1, event_size, fp);
54  if (size_read != event_size)
55  return !SUCCESS;
56 
57  return SUCCESS;
58 }
int process_event ( void *  pevent,
int  addr,
int  fadc 
)
void process_file ( char *  input_filename,
int  addr,
int  fadc 
)
int processIsland ( int  t0,
int  nsamples,
int *  samples,
int  channel 
)

Definition at line 104 of file show_pulses.cxx.

References c, i, nsamples, printf(), sprintf(), and title.

105 {
106 
107  c->Clear();
108  char title[80];
109  sprintf(title, "Waveform: channel %d, t0=%d", channel, t0);
110 
111  double sum = 0;
112  int min = 4097;
113  int max = -1;
114 
115  double binWidth = 100./100.00;
116  TH1D *waveform = new TH1D("waveform", title, nsamples, -0.5*binWidth, (nsamples-0.5)*binWidth);
117  for(int i = 0; i < nsamples; i++) {
118  waveform->SetBinContent(i+1, samples[i]);
119  sum += samples[i];
120 
121  if(samples[i] < min) min = samples[i];
122  if(samples[i] > max) max = samples[i];
123  }
124  waveform->Draw();
125 
126  double mean = sum/nsamples;
127  double sumSqrDeviations = 0;
128 
129  for(int i = 0; i < nsamples; i++) {
130  double deviation = samples[i] - mean;
131  sumSqrDeviations += deviation*deviation;
132  }
133  double rms = sqrt(sumSqrDeviations/(nsamples-1));
134 
135  printf("Number of samples = %d, Min = %d, Max = %d, Mean = %lf, RMS = %lf\n", nsamples, min, max, mean, rms);
136 
137  // if(max > 3500) {
138  c->Update();
139  c->Modified();
140 
141  char dummy[80];
142  fgets(dummy, sizeof(dummy), stdin);
143  if(dummy[0] == 'q') {
144  return 1;
145  }
146 //}
147 
148  delete waveform;
149  //delete c;
150 
151 return 0;
152 }

Variable Documentation

TCanvas* c = 0

Definition at line 24 of file show_pulses.cxx.