/lem/pixie16/devel/scan_c++/src/pixie_std.cpp File Reference

pixie_std provides the interface between the HRIBF scan and the C++ analysis More...

#include <string>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <sys/time.h>
#include <malloc.h>
#include <vector>
#include <map>
#include <fstream>
#include <istream>
#include <iostream>
#include <sys/param.h>
#include <sys/times.h>
#include <sys/types.h>
#include <list>
#include "rawevent.h"
#include "event_structure.h"
#include "detector_driver.h"
#include "param.h"

Include dependency graph for pixie_std.cpp:


Defines

#define TOTALREAD   2000000

Functions

int Init_IDmap ()
int random_generate ()
void Scan_List ()
 Event by event analysis.
int Remove_List ()
void Histo_Stats (unsigned long &, double &, double &, int)
void hissub_sec (unsigned int *ibuf[], unsigned int *nhw)
 Extract channel information from the raw parameter array ibuf.
int ReadBuffData (unsigned int *ibuf[], unsigned short Begin, unsigned long *BufLen, vector< evt * > &, evt &)
 extract channel information from raw data
void pixie16_error (int errornum)
 pixie16 scan error handling.
void plot (const int &dammid, const double &val1, const double &val2=-1, const double val3=-1, char *name="h")
bool cmp (const evt *a, const evt *b)
 vector sort comparison function To use the sort function of a vector a method of comparing two elements in that vector must be defined.
void hissub_ (unsigned short *ibuf[], unsigned short *nhw)
 interface between scan and C++

Variables

vector< identifiermodchan
rawevent rawev
detector_driverddriver
detector_driver driver
string mode
int processcalls
int termit
vector< evt * > eventlist
vector< evt * >::iterator itereventlist
evt currentevt
float ran_num [MAXRAND]
int NumberofModules
struct tms t u
long r1
long r2
double firsttime
double time0old

Detailed Description

pixie_std provides the interface between the HRIBF scan and the C++ analysis

pixie16_std provides the interface between the HRIBF scan and the C++ analysis and as such is not a class in its own right. In this file the data received from scan is first reassembled into a pixie16 spill and the then channel objects are made. The list of channels is then sorted based on each channels event time and grouped into events (the variable is rawevent) based on how close in time the channels are. The rawevent is then passed to the detector_driver and all further processing is based on the rawevent.


Define Documentation

#define TOTALREAD   2000000


Function Documentation

bool cmp ( const evt a,
const evt b 
)

vector sort comparison function To use the sort function of a vector a method of comparing two elements in that vector must be defined.

"cmp" is the comparison function that will be used in the vector sorting routine. It will receive a pointer to two different objects of type evt. The "const" declaration is to ensure that the original objects are not inadvertently altered or damaged in this function. The function will return "true" if the time of the object a is less than the time of object b (otherwise return false). Currently time is taken from the pixie event time (two 32 bit words) with 10ns ticks.

void hissub_ ( unsigned short *  ibuf[],
unsigned short *  nhw 
)

interface between scan and C++

In a typical experiment Pixie16 reads data from all modules when one module has hit the maximum number of events which is programmed during experimental setup. This spill of data is then broken into smaller chuncks for transmitting across the network. The hissub_ function takes the chuncks and reconstructs the spill.

Summarizing the terminology:

  • Spill - a readout of all Pixie16 modules
  • Buffer - the data from a specific Pixie16 module
  • Chunk - the packet transferred from Pixie16 to the acquisition

The hissub_ function is passed a pointer to an array with data (ibuf) and the number of half words (nhw) contained in it. This function is used with the new Pixie16 readout (which is the default). If the old Pixie16 readout is used the code should be recompiled without the newredout flag in which case this particular function is not used.

void hissub_sec ( unsigned int *  ibuf[],
unsigned int *  nhw 
)

Extract channel information from the raw parameter array ibuf.

If the new Pixie16 readout is used (default) this routine processes the reconstructed buffer. Specifically, it retrieves channel information and places the channel information into a list of channels that triggered in this spill. The list of channels is sorted according to the event time assigned to each channel by Pixie16 and the sorted list is passed to the Scan_List function for rawevent creation.

If the old pixie readout is used then this function is redefined as hissub_.

void Histo_Stats ( unsigned long &  id,
double &  diff_t,
double &  clock,
int  event 
)

At various points in the processing of data in Scan_List() the Histo_Stats function is called to increment some low level pixie16 informational and diagnostic spectra. The list of spectra filled includes runtime in seconds and milliseconds the deadtime, time between events and time with of an event.

int Init_IDmap (  ) 

Initialize the analysis

Read in the map.txt file to determine what detector types are going to be used in this analysis. For each detector type used created an entry into the det_sum map of the rawevent. After this is completed proceed to the detector_driver initialization function (detector_driver::init()) to complete the initialization.

Initialize firstime to zero, need to think about this when running multiple files

Currently not used

void pixie16_error ( int  errornum  ) 

pixie16 scan error handling.

Print out an error message and terminate program depending on value of errornum. 1 - invalid module number in data stream (most likely due to not defining all modules in the map.txt file).

void plot ( const int &  dammid,
const double &  val1,
const double &  val2 = -1,
const double  val3 = -1,
char *  name = "h" 
)

Function for incrementing damm spectra. This function is defined in the detector_driver.cpp file. Using this interface function it will be possible to make a transparent switch between plotting functions in damm and ROOT.

int random_generate (  ) 

generate the random numbers, results of this function are currently unused.

int ReadBuffData ( unsigned int *  ibuf[],
unsigned short  Begin,
unsigned long *  BufLen,
vector< evt * > &  eventlist,
evt currentevt 
)

extract channel information from raw data

ReadBuffData extracts channel information from the raw data arrays and places it into a structure called evt. A pointer to each of the evt objects is placed in the eventlist vector for later time sorting.

int Remove_List (  ) 

Remove list from memory when not needed

void Scan_List (  ) 

Event by event analysis.

The Scan_List operates on the time sorted list of all channels that triggered in a given spill. Starting from the begining of the list and continuing to the end an individual channel event time is compared with the previous channel event time to determine if they occur within a time period defined by the diff_t variable (time is in units of 10 ns). Depending on the answer different actions are performed:

  • yes - the two channels are grouped together as belonging to the same event and the current channel is added to the list of channels in the rawevent variable.
  • no - the previous rawevent is sent for processing and once finished the rawevent variable is zeroed and the current channel placed inside it.


Variable Documentation

an object of type "evt" which is passed to ReadBuffData

a pointer of type detector_driver named ddriver used for rawevent filling and for passing to the detector_driver::process_events() function

a variable of type detector_driver named driver used to initialize the analysis and process rawevents

vector<evt*> eventlist

eventlist is a vector of pointers (the *) to different "evt" objects. The "evt" objects themselves are created in the function ReadBuffData (in file ReadBuffData.cpp) and a pointer to the object is stored in the vector eventlist.

double firsttime

The first time in a specific module (currently module 2) used for tracking run time.

vector<evt*>::iterator itereventlist

An iterator for the eventlist. The iterator is used to loop over the eventlist vector.

a vector which contains the description of each channel in the analysis. The description is read in from the map.txt file and includes the module and channel number, the detector type and subtype, the damm spectrum number, the detectors physical location and an integer that is currently not used

string mode

The variable mode is passed to the process_events function and defines the current operating mode of the file. For a scan and damm analysis this is set to "scan". For offline analysis only with root files (still to be implemented) the mode is set to "standaloneroot".

The number of modules used in the map.txt file. If during event processing a module is encountered with a number above this varaible the program terminates and exits.

The number of times an unpacked buffer is sorted

long r1

variables r1,r2 used to retrieve run time information to check speed of algorithms. The use of these variables and associated function calls are system dependent so are commented out until someone needs them

long r2

float ran_num[MAXRAND]

Array of random numbers used in other routines

rawev will contain event information, the information is filled in the function Scan_List (in this file) and is passed to the function process_events (in the detector_driver file)

int termit

Troubleshooting variable to stop program execution after a certain number of events, to be removed in a final version

double time0old

Current unused

struct tms t u

Structures and variables used to print the current running time of the analysis


Generated on Wed May 14 10:07:06 2008 for pixie16 by  doxygen 1.5.5