Some Basic rules that should be followed for the DAQ settings


Inside the DAQ, the detectors (i.e. flash ADC channels) are defined by one four character label and one number. Please USE ALWAYS THE SAME LABEL for a SPECIFIC DETECTOR TYPE. Why? Because the DST-creation routines (i..e pulse shape analysis) need to identify which pulse shape analysis routine has to be applied in each case, and this is done only on the basis of the LABELS (1 LABEL = 1 ANALYSIS ROUTINE).

One example of what should not be done: if there are four silicons, avoid using labels SIL1, SIL2, SIL3, SIL4. Instead, use the same type SILI and choose a different detector number for each SILI. PLEASE AVOID ALSO USING DETECTOR NUMBERS BIGGER THAN 100.

List of LABELS (please in capitals) for the different detectors that have been used until now:
 

  • C6D6 = Bicron C6D6 detectors
  • K6D6 = Carbon fibre C6D6 detectors
  • L6D6 = C6D6 detector with a different pulse shape
  • SILI = silicon detectors
  • PPAC = PPAC cathode
  • PPAN = PPAC anode
  • BF3_ = Boron trifluoride monitors
  • MUM_ = Micreomegas
  • BICR = Bicron 702 plastic detector
  • N213 = NE213 liquid scintillator
  • BAF2 = Barium Fluoride
  • CEF3 = Cerium Fluoride
  • HPGE = Hyper Pure Germanium detectors

  • If there is a new detector to be plugged to the DAQ, please inform about it (daniel.cano@ciemat.es) so that it can be included also in the DST-creation software.

    Event Building HOWTO

    I. Introduction

    The event building software is aimed to combine the full information of all (the selected) detectors + beam information in one single structure so that it is accessible for the analysis. Users should not care in which particular streams the specific detectors are found.
    The analysis can be done on an event by event basis.

    The directory where the different files are located is

    /afs/cern.ch/user/n/ntofuser/public/last_soft

    You will find there the following files

    1. dblock_last.h  (global definitions header block)
    2. event_build_last.h (event building definitions block)
    3. rf_libr_last.o (main library for the software to read the DSTs from CASTOR)
    4. rf_libr_local_last.o (main library for the software to read the DSTs from a local directory)
    5. pw_libr_last.o (addtional library)
    6. dstbeam_v2.c (a very simple event building program EXAMPLE).
    7. doto_beam (a macro for compiling the whole software for reading the DSTs+BEAM info from CASTOR)
    8. doto_beam_local (a macro for compiling the whole software for reading the DSTs from a local directory and the BEAM info from CASTOR)
    Copy to your local directory only the last two (or three if you don't have yet your own event building program) files.



    WARNING: The software will only run from the lxplus machines at CERN, from where the files are visible
    You MUST set the following ENVIRONMENT VARIABLES in your .login (or equivalent private definitions file)

    setenv STAGE_POOL ntof_stage
    setenv STAGE_HOST ntof001d
    setenv RFIO_READOPT 0


    II. Structure of one event

    The event structure which contains (hopefully) the complete information necessary for the analysis is defined as follows:

    #include "dblock.h"
    /* ============================ */

    #define NUM_DETECTOR_TYPES 20
    #define NUM_DETECTOR_CHANS 60
    #define MAX_DET_CHAN_NUM   300
    #define DETTYPE_NOT_FOUND  -1
    #define DETNUM_NOT_FOUND   -1
    #define NOT_ENOUGH_SPACE   -1

    /* The detectors in the DAQ software are defined by one LABEL (for example SILI) and one nuimber (if there are many of them) */
    /* For every particular LABEL (detectorType) and NUMBER (detectorNumber)  there is a certain structure which contains all its settings. */
    /* Most of the variables should be self explanatory, but if not, please do not hesitate to ask */

    typedef struct
    {
      nu_int       detectorType;   /* C6D6, PPAC, BAF2, ... */
      nu_int       detectorNumber; /* Number if there are many of the same type */
      char         channelNumber, moduleNumber, chassisNumber, streamNumber; /* DAQ info */
      /* ADC settings */
      nu_int       sampleRate, /* Sampling Rate */
                   sampleSize,      /* Sample Size */
                   fullScale;       /* Full Scale 0-6: [0.05V,0.1V,0.2V,0.5V,1V,2V,5V] */
      nu_int       delayTime; /* In samples */
      nu_int       threshold; /* in ADC units */
      nu_int       thresholdSign;   /* negative or positive crossing */
      n_float      offsetVoltage;   /* offset voltage in mV */
      nu_int       preSamples, /* number of presamples */
                   postSamples; /* number of postsamples */
      /* DST parameters */
      nu_int       RevisionNumber;  /* Revision number of the analysis routine */
      nu_int       noOfRealPar;   /* Number of real parameters per signal */
      nu_int       noOfIntPar;        /* Number of integer parameters per signal */
      nu_int       noOfMovies;   /* Number of ADC frames (pulses in Erich's notation) */
      nu_int       noOfCounts;        /* Number of real pulses detected */
      n_float*     ParReal;     /* float parameters for all signals */
      n_int*       ParInt;    /* integer parameters for all signals */
      /* Flags */
      n_int        BufferPresent; /* Check if the ACQC buffer for the detector was present 1=yes, 0=no */
    } ACEvBuild; /* This is the detector + detector number structure */
     

    typedef struct
    {
      nu_int runNumber;
      nu_int event_number;
      nu_int n_detectors;                         /* number of different types of detectors selected */
      nu_int npos_detector[NUM_DETECTOR_TYPES];   /* number of detectors of each type selected */
      n_float beamIntensity;             /* Beam intensity */
      nu_int  date,                      /* date for event */
              time;                               /* time for event */
      ACEvBuild detector[NUM_DETECTOR_TYPES][NUM_DETECTOR_CHANS];
    } FULL_EVENT_TYPE;/* This is the array containing the different (selected) detector + detector number structures plus some additional information such as the run number, the event number, the numper of detectors... beam intensity...etc*/

    The information of a complete event is stored in a variable of the FULL_EVENT_TYPE type. Lets describe a little bit more in detail what is inside the structure.

    Imagine you have selected the type C6D6 and SILI with the necessary routine

    dettype = SelectDetectorType("C6D6",&n_types_chosen);
    dettype = SelectDetectorType("SILI",&n_types_chosen);
    where dettype is just the output and n_types_chosen is a variable that is incremented after every different selection.

    Imagine also that there are 2 C6D6 detectors and 4 Silicon detectors.

    Now you can declare your structure as follows:

    FULL_EVENT_TYPE full_event;
    After some steps inside the program (you will see later which ones), the structure will be filled and contain the full information storred in the DSTs for all the detectors (C6D6 and SILI in our case)

    event_full.runNumber will contain the value of the run number you are currently analysing and event_full.event_number the corresponding event number you are processing. A bit more interesting is event_full.n_detectors, which corresponds to the number of different detector types chosen (2 in our example).

    You can see which (PROGRAM given) type number has been assigned to a certain detector type (i.e. LABEL) by using the subroutine

    success = FindTypeASCII(&event_full,"C6D6", &idet_type);
    /* Check if the detector is really in the data */
    if( success == DETECTOR_NOT_FOUND )
        { printf("C6D6 detector type not present in the run. Exiting\n" );
        exit(0); }
    else
       { printf("C6D6 detector type %d found\n",idet_type); }
    The routine returns the idet_type value which is the INDEX you will need to keep to select the variables associated to a given detector type (C6D6 in this case). For safety, you can verify that the detector was really found since to select it does not mean that it is really present in the run you are analysing.

    The INDEX idet_type can be immediately used to know HOW MANY detector of a given type you have read.

    event_full.npos_detector[idet_type]
    is exactly that value (should be 2 for the C6D6 and 4 for the Silicons).

    Now you can already make SAFE loops over your structure without subscript out of range errors (i.e. core dumped)

    for (i_type = 0; i_type < event_full.n_detectors; i_type++)
        {
         for(i_pos = 0; i_pos < event_full.npos_detector[i_type]; i_pos++)
            {
             /* This loop is running over the DETECTOR TYPES and for each TYPE over the number of detectors found*/
            }
         }
    The last but most important part missing is, of course, the access to the parameters (reals and floats) contained in the DSTs. This can be done as follows:
    event_full.[i_type][i_pos]
    contains everything for a particular detector (LABEL + NUMBER).

    event_full.detector[i_type][i_pos].noOfRealPar and event_full.detector[i_type][i_pos].noOfIntPar are the number of REAL (float) and INTEGER parameters respectively returned by a specific routine (the one that was used for analysing the detector i_type). All the real and integer parameters for one event are stored in two arrays:
    event_full.detector[i_type][i_pos].ParReal[i_real+i_count*n_real_par] and event_full.detector[i_type][i_pos].ParInt[i_int+i_count*n_int_par]
    The last to know in order to extract the values from the vector is how many counts (individual pulses) have been found in one event. That value corresponds to event_full.detector[i_type][i_pos].noOfCounts.

    With all this information it is possible to make a loop over the individual counts and extract the necessary values. In the next example it is shown how they are printed on screen:

    /* Loop over the total counts (i.e. signals found) */
    for(i_count = 0; i_count < event_full.detector[i_type][i_pos].noOfCounts; i_count++)
    {
    n_real_par = event_full.detector[i_type][i_pos].noOfRealPar;
    n_int_par = event_full.detector[i_type][i_pos].noOfIntPar;

    /* exit in case one of the both numbers is zero (should never occur in normal conditions, but it happens for some old run files) */
    if(n_real_par == 0 || n_int_par == 0){ break; };

    /* Loop over the REAL parameters. The index for the vector containing ALL reals for one event is also calculated as i_real+i_count*n_real_par */
        for(i_real = 0; i_real < n_real_par; i_real++)
            {
              printf("%f ",event_full.detector[i_type][i_pos].ParReal[i_real+i_count*n_real_par]);
            }
    /* Loop over the INTEGER parameters. The index for the vector containing ALL integers for one event is also calculated as i_real+i_count*n_int_par */
        for(i_int = 0; i_int < n_int_par; i_int++)
            {
           printf("%d ",event_full.detector[i_type][i_pos].ParInt[i_int+i_count*n_int_par]);
            }
    }

    A different number from event_full.detector[i_type][i_pos].noOfCounts is event_full.detector[i_type][i_pos].noOfMovies, which represent the number of flash ADC pulses (which in fact may contain many individual signals, pileups...) registered.

    III. A dummy Event Building program

    Now lets have a look at one example of a dummy event building program

    /************************************************
    C main program for event building based on DSTs.
    ------------------------------------
    D. Cano-Ott, CIEMAT, 27/3/2001
    daniel.cano@ciemat.es
    ------------------------------
    C. Domingo Pardo, IFIC
    cesar.domingo@ific.uv.es
    ------------------------------
    T. Papaevangelou, CERN
    thomas@pctof01.cern.ch
    ------------------------------
    ************************************************/

    #include "dblock.h"
    #include "event_build.h"
    #include <stdio.h>
    #include <fcntl.h>
    #include <shift.h>
    #include <sys/types.h>

    int FindTypePos(FULL_EVENT_TYPE* , char*, int , int*, int*);
    int SelectDetectorType(char*, int*);
    void AnalysisRoutine(FULL_EVENT_TYPE, int, int*, int*);
    static FILE* outfile;

    main(int argc, char **argv)
    {
      int deblev = -1;
      int nrunr,nrung,nrunst, nsegm;
      int nacq_stat,nmovies;
      int i,j;
      int in=0;
      int inf=0;
      int inm=0;
      int wr_size=0;
      int endOfString=0;

      int nstream=0;
      int rctrhsize=0;
      int modhsize=0;
      int acqchsize=0;
      int chanhsize=0;
      int evenhsize=0;
      int totchan=0;

      char filename[120];
      char dst_dir[120];
      char indx_dir[120];
      char path2[120];

      /* Several BOS headers */
      BOS_HEADER* bosh_rctr;
      BOS_HEADER* bosh_modh;
      BOS_HEADER* bosh_even;
      BOS_HEADER* bosh_acqc;
      BOS_HEADER* bosh_evendst;
      BOS_HEADER* bosh_acqcdst;
     

      /* The run control header */
      RCTR_HEADER* rctrhp;
      /* The module header */
      MOD_HEADER* modhp;
      /* The channel header (check that the number is large enough)*/
      CHAN_HEADER* chanhp[MAX_DET_CHAN_NUM];
      /* The event header */
      EVENT_HEADER* evenhp;
      /* The ACQC header */
      DST_HEADER* acqchp;
      /* Real parameters vector */
      float* chsigs_real;
      /* Integer parameters vector */
      int* chsigs_int;
      /* The ACQC DST header */
      ACQC_HEADER* acqcdsthp;
      /* DST EXTENSION header */
      DST_HEADER adsth;

      /* threshold initially set as 0 */
      int thresh=255;
      int i_segm;
      int n_event;
      int init_res;

      int is = 0;

      int type_of_file = INDX; /* RAW = 0 = raw data, INDX = 1 = index file, DST = 2 = dst */

      int ntrgr,ntrgg;
      int lsegm,usegm,ktrg,kstream;
      int mstage=0;

      /* ---- Definitions for the event building ---- */
      int id_det = 0;
      int id_pos = 0;
      int success = 0;
      int n_types_chosen = 0;
      int dettype = 0;
      char detname[5];
      FULL_EVENT_TYPE full_event;
      /* ---------------------------------------------- */

      /* Definitions for the output file */
      int events_read = 0;
      int events_written = 0;
      char ofilename[100];
      /* ------------------------------- */

      nrunr = 0;
      lsegm = 0;
      usegm = 0;
      ktrg = 0;
      deblev = NO_DEB;

      /* Reads the arguments of the subroutine. It is made so that it works as a standard UNIX command with several inputs to be given */
      sprintf(filename,"HSM_file");
      sprintf(dst_dir,"DST_directory");
      sprintf(indx_dir,"INDX_directory");
      if(argc>=2)
        {
        for(i=1;i<argc;i++)
          if(*argv[i]=='-')
     {
     switch (argv[i][1])
       {
       case 'r' : sscanf(argv[i+1],"%d",&nrunr); break;
       case 'l' : sscanf(argv[i+1],"%d",&lsegm); break;
       case 'u' : sscanf(argv[i+1],"%d",&usegm); break;
       case 'e' : sscanf(argv[i+1],"%d",&ktrg); break;
       case 'd' : sscanf(argv[i+1],"%d",&deblev); break;
       case 'i' : strcpy(dst_dir,argv[i+1]); break;
       case 'x' : strcpy(indx_dir,argv[i+1]); break;
         /*   case 'D' : strcpy(detname,argv[i+1]); break;*/
       case 'h':
         printf("You should use one of the following options\n");
         printf("\n");
         printf("-r run number\n");
         printf("-l lowest segment number (default 0) \n");
         printf("-u highest segment number (default 0) \n");
             printf("-e first event to be processed (skip the previous ones)\n");
         printf("-d debug option 0, 1, 2, 3, 4\n");
         printf("-i Input directory for the DSTs\n");
         printf("   Output ASCII file will be created there also\n");
         printf("-x Input directory for the INDEX files\n");
         printf("   Example of usage:\n");
         printf("   dstbeam -r 1525 -l 0 -u 1 -i /tmp/mumegas -x test\n");
         printf("   Opens the run 1525 streams necessary to analyse the detector\n");
         printf("   selected inside the program. Segments 0 to 1 will be open.\n");
         printf("   The DST files are searched in the CASTOR directory specified\n");
         printf("   by option -i: /castor/cern.ch/ntof/dst\n");
         printf("   The index file (proton beam information) is searched in the CASTOR\n");
         printf("   directory specified by option -x: /castor/cern.ch/ntof/test/stream0\n");
         printf("\n");
         printf("   MAKE SHURE the directory where the output files are created exists!!!\n");
         printf("   The directory path has to be changed inside the program source\n");
         printf("   dstbeam_v2.c\n");
         printf("   To create a new exe file run the script doto_beam\n");
         return;
       default: printf("dstbeam -h for help\n");return;
       }
          }
      }
      else
        {
          printf("dstbeam -h for help argc %d\n",argc);
          return;
        }

      /* Message at the start of the process */

      printf("Request: RUN %d SEGMENTS from %d to %d FILE %s\n",nrunr,lsegm,usegm,filename);

      /*
        Call the debug level
        If deblev > NO_DEB (defined as 1) debugging is active
        and messages are going to be printed. Otherwise no debugging
        is assumed
      */
      ntof_debug(deblev);

      ntrgr = ktrg;
      nstream = kstream;

      /* Some checks */
      if ( lsegm > usegm )
        {
          printf(" Lower segment %d bigger than highest segment value %d. Looking only for segment %d\n",
          lsegm,usegm,lsegm);
          usegm = lsegm;
        }
     

      if( strcmp(dst_dir,"DST_directory") == 0 || strcmp(dst_dir,"") == 0 )
        {
          printf("Please specify an input directory for the DST files (option -i)\n");
          exit(1);
        }
      printf("DST directory chosen is %s\n\n",dst_dir);

      if( strcmp(dst_dir,"INDX_directory") == 0 || strcmp(dst_dir,"") == 0 )
        {
          printf("Please specify an input directory for the INDX file (option -x)\n");
          exit(1);
        }
      printf("Index file directory chosen is %s\n\n",indx_dir);

      /* REAL START OF THE PROGRAM */

      /* Select different detector types by calling SelectDetectorType and the */
      /* corresponding label */
      /* In this example, only 3 detectors have been selected */

      dettype = SelectDetectorType("C6D6",&n_types_chosen);
      dettype = SelectDetectorType("K6D6",&n_types_chosen);
      dettype = SelectDetectorType("L6D6",&n_types_chosen);
     

      /* Opens an output filename to write down all the parameters as an ASCII file*/
      sprintf(ofilename,"/tmp/c6d6/run%d_nt.dat",nrunr);
      outfile = fopen(ofilename,"w+");

    /* For a given run, do it from segment file i_segm up to usegm */
      for (i_segm = lsegm; i_segm <= usegm; i_segm ++)
        {
          printf("Calling the open run routine\n");

    /* ESSENTIAL PART Initialise variables and look which modules are in the run */
          init_res = OpenRun(deblev,nrunr, i_segm, dst_dir, indx_dir, &full_event); /* OpenRun is the start!!! */
          if(init_res != INIT_OK)
     {
       printf("Problems in Open Run.");
       fclose(outfile);
       exit(1);
     }

          printf("\n");
          printf("-----------------------Segment number %d ----------------------------------\n",i_segm);
          printf("\n");

          while( (n_event = ReadEvent(deblev, ntrgr, i_segm, &full_event)) >= 0 )
             {

               /* This part has to be changed by the user. The rest should remain as it is. Here the particular Analysis routine is called event by event */
               AnalysisRoutine(full_event, i_segm,  &events_read, &events_written );
               /* ------------------------------------------------------------------------ */

              /* Once the structure has been used, DO NOT forget to free the memory it required. Otherwise you will consum the whole memory of the system and get finally a  segementation fault error. Recall also that the events can be extremely large (several hundred Mbytes!!!) */
               FreeMem(&full_event);

               ntrgr = 0;
               printf("Events read %d, Events written %d\n",events_read,events_written);
             }
          printf("End of Segment %d\n",i_segm);
        }
    /* Termination of the run */
      if( ntrgg != EVSTNOMORE)
        {
          printf("Error %d getting Event %d of Run %d\n",ntrgg,ntrgr,nrung);
         }
       fclose(outfile);

      exit(1);
    }
     

    /* The DUMMY analysis ROUTINE */
    void AnalysisRoutine(FULL_EVENT_TYPE event_full, int isegm, int* ev_read, int* ev_written)
    {
      int i_type;
      int idet_type;
      int i_pos;
      int i_count = 0;
      int i_real = 0;
      int i_int = 0;
      int n_real_par = 0;
      int n_int_par = 0;
      int success = 0;
      static float sum_intensity = 0;

      printf("------------- Analysis Routine----------- \n");
      printf("Event number %d, Beam Intensity %e\n",event_full.event_number,event_full.beamIntensity);

      /* Dummy loop for printing the information contained in one particular element of the array */
      /*  for (i_type = 0; i_type < event_full.n_detectors; i_type++)
        {
            for(i_pos = 0; i_pos < event_full.npos_detector[i_type]; i_pos++)
         {
           printf("            ---------------- \n");
           printf("Detector type %d found in place %d\n",event_full.detector[i_type][i_pos].detectorType, i_type);
           printf("Detector number %d found in position %d\n",event_full.detector[i_type][i_pos].detectorNumber, i_pos);
           printf("Channel %d, Module %d, Chassis %d, Stream %d\n",event_full.detector[i_type][i_pos].channelNumber,
           event_full.detector[i_type][i_pos].moduleNumber, event_full.detector[i_type][i_pos].chassisNumber,
           event_full.detector[i_type][i_pos].streamNumber);
           printf("Sampling rate %d \n",event_full.detector[i_type][i_pos].sampleRate);
           printf("Sample size %d \n",event_full.detector[i_type][i_pos].sampleSize);
           printf("Full scale 0-6 [0.05V,0.1V,0.2V,0.5V,1V,2V,5V]: %d \n",event_full.detector[i_type][i_pos].fullScale);
           printf("Delay time %d \n",event_full.detector[i_type][i_pos].delayTime);
           printf("Threshold %d \n",event_full.detector[i_type][i_pos].threshold);
          printf("Threshold sign  %d \n",event_full.detector[i_type][i_pos].thresholdSign);
           printf("Ofsset voltage (mV) %f \n",event_full.detector[i_type][i_pos].offsetVoltage);
           printf("Presamples %d \n",event_full.detector[i_type][i_pos].preSamples);
           printf("Postsamples %d \n",event_full.detector[i_type][i_pos].postSamples);
           printf("Number of real parameters %d \n",event_full.detector[i_type][i_pos].noOfRealPar);
           printf("Number of integer parameters %d \n",event_full.detector[i_type][i_pos].noOfIntPar);
           printf("Number of movies %d \n",event_full.detector[i_type][i_pos].noOfMovies);
           printf("Number of counts %d \n",event_full.detector[i_type][i_pos].noOfCounts);
           printf("Buffer present 1=Yes, 0=No %d\n",event_full.detector[i_type][i_pos].BufferPresent);
         }

         }
      */

    /* Checks if the detector types requested are present in the run. If one is missing, it exits. */
    success = FindTypeASCII(&event_full,"C6D6", &idet_type);
    if( success == DETECTOR_NOT_FOUND )
    { printf("C6D6 detector type not present in the run. Exiting\n" ); exit(0); }
    else
    { printf("C6D6 detector type %d found\n",idet_type); }

    success = FindTypeASCII(&event_full,"K6D6", &idet_type);
    if( success == DETECTOR_NOT_FOUND )
    { printf("K6D6 detector type not present in the run. Exiting\n" ); exit(0); }
    else
    { printf("K6D6 detector type %d found\n",idet_type); }

    success = FindTypeASCII(&event_full,"L6D6", &idet_type);
    if( success == DETECTOR_NOT_FOUND )
    { printf("L6D6 detector type not present in the run. Exiting\n" ); exit(0); }
    else
    { printf("L6D6 detector %d type found\n",idet_type); }
     

    /* Increases the number of events read */
    *ev_read += 1;

    /* Checks if the proton beam intensity is zero or not */
    /* If not, it does not write the event in the ASCII file */
    /* Uncomment the line for real events, comment it for calibration sources */
    /*  if( event_full.beamIntensity > 0. )
          { */

    sum_intensity += event_full.beamIntensity;
    /* Loop over detetctor types */
    for (i_type = 0; i_type < event_full.n_detectors; i_type++)
    {
    /* Loop over the number of detectors of a given type */
    for(i_pos = 0; i_pos < event_full.npos_detector[i_type]; i_pos++)
        {
    /* IMPORTANT CHECK. Some older run files do not have empty buffers when a detector did not fire. Thus, even if the detector is present, it is not found for one particular event, which produces a segmentation fault if it is not skipped */
        if( event_full.detector[i_type][i_pos].BufferPresent == 1 )
            {
            /* printf("Revision Number %d\n",event_full.detector[i_type][i_pos].RevisionNumber); */
            /* Loop over the number of counts */
            for(i_count = 0; i_count < event_full.detector[i_type][i_pos].noOfCounts; i_count++)
                {
                    n_real_par = event_full.detector[i_type][i_pos].noOfRealPar;
                    n_int_par = event_full.detector[i_type][i_pos].noOfIntPar;
                    if(n_real_par == 0 || n_int_par == 0){ break; };
                    fprintf(outfile,"%d %d %d %e %e ",event_full.detector[i_type][i_pos].detectorNumber, isegm, event_full.event_number,event_full.beamIntensity, sum_intensity);
                    /* Loop over the real parameters */
                    for(i_real = 0; i_real < n_real_par; i_real++)
                        { fprintf(outfile,"%f ",event_full.detector[i_type][i_pos].ParReal[i_real+i_count*n_real_par]);}
                    /* Loop over the integer parameters */
                    for(i_int = 0; i_int < n_int_par; i_int++)
                        { fprintf(outfile,"%d ",event_full.detector[i_type][i_pos].ParInt[i_int+i_count*n_int_par]);}
                        fprintf(outfile,"\n");
                 }
            }
       else
            { printf(" Data buffer for detector %d number %d is not present in event %d \n",
               event_full.detector[i_type][i_pos].detectorType,
               event_full.detector[i_type][i_pos].detectorNumber,
               event_full.event_number); }
        }
    }
    /* Increases the number of events written */
    *ev_written += 1;
     /*    } */
    }

    Description of the parameters provided in the DSTs

    detp segn ev be sbe amp bl blrms fch tch start peak end npeak pileup longp thr


    IV. Usage of dstbeam

    type dstbeam -h for help. You will find the following message:

    You should use the following options

    -r run number
    -l lowest segment number (default 0) OPTIONAL
    -u highest segment number (default 0) OPTIONAL
    -e first event to be processed (skip the previous ones) OPTIONAL
    -d debug option 0, 1, 2, 3, 4
    -i Input directory for the DSTs
       If you read the DSTs from a local directory (running dstbeam_local),
       the output ASCII file will be created there also.
       Otherwise, you have to specify the directory inside the program.
    -x Input directory for the INDEX files

       Example of usage:
       dstbeam -r 1525 -l 0 -u 1 -i P123/dst -x P123
       Opens the run 1525 streams necessary to analyse the detector
       selected inside the program. Segments 0 to 1 will be open.
       The DST files are searched in the CASTOR directory specified
       by option -i: /castor/cern.ch/ntof/P123/dst
       The index file (proton beam information) is searched in the CASTOR
       directory specified by option -x: /castor/cern.ch/ntof/P123/stream0

       MAKE SURE the directory where the output files are created exists!!!
       The directory path has to be changed inside the program source
       dstbeam_v#.c
       To create a new exe file run the script doto_beam (or doto_beam_local).
     

    V. Short manual about CASTOR

    CASTOR is the system that stores the n_TOF data. You can find some valuable documentation at the following Web address go to CASTOR's web page. It is strongly recommended to read its introduction.

    However, there is a simple list of commands and information on it.  All the n_TOF data are stored under /castor/cern.ch/ntof, which is not really a hard disk but a complex system of hard disk and tape pools. Type the following command on any lxplus machine

    lxplus> nsls -l /castor/cern.ch/ntof
    and you will find the following result
    drwxr-xr-x   6 ntofdaq  za                        0 Apr 23  2001 P123
    drwxr-xr-x   6 ntofdaq  za                        0 Apr 23  2001 P124
    drwxr-xr-x   6 ntofdaq  za                        0 Apr 23  2001 P125
    drwxr-xr-x 2451 ntofdaq  za                        0 Jan 25 13:28 dst
    drwxr-xr-x   5 ntofdaq  za                        0 Apr 11  2001 test
    By the 24th of May 2002, the n_TOF pool is structured as described above. There is a test "directory" containing the raw data files of the 2001 measuring campaign. The corresponding DATA summary tapes are in the dst directory. The more recent files (above run number 2160 for DSTs and above run number 2297 for the raw data files) will be be found in the P123, P124, P125 and so on directories.
    P123 is the name of the first campaign (also known as TOF02) and the corresponding files will be found there.

    Let's have a look of the structure of the P123 directory. After typing lxplus> nsls -l /castor/cern.ch/ntof/P123 the following result will be obtained:

    drwxr-xr-x 274 ntofdaq  za                        0 May 24 13:56 dst
    drwxr-xr-x  34 ntofdaq  za                        0 May 24 17:36 stream0
    drwxr-xr-x  34 ntofdaq  za                        0 May 24 17:37 stream1
    drwxr-xr-x  34 ntofdaq  za                        0 May 24 17:39 stream2
    drwxr-xr-x  34 ntofdaq  za                        0 May 24 17:41 stream3
    drwxr-xr-x   0 ntofdaq  za                        0 Apr 23  2001 stream4
    There are six directories found inside:
    Last revision 29/05/2002 daniel.cano@ciemat.es
    Comments, suggestions and bug reports are welcome