Home CMS Production Clean room MedAustron HEPHY testbeams old
testbeam-DESY-Oct2017 testbeam-DESY-April2017 testbeam-SPS2015 testbeam-SPS2014 testbeam-DESY14 testbeam-SPS12 testbeam-SPS11 testbeam-SPS10 testbeam-SPS09 testbeam-SPS08 LP-TPC
  HEPHY logbook for testbeam at SPS June 2008  Not logged in ELOG logo
Message ID: 4     Entry time: Fri May 9 11:46:36 2008
Author: Markus Friedl 
Project: SiLC 
Subject: Data file format 
Run Number: (work in progress) 
Events:  
StartTime:  
EndTime:  
APVDAQ Data Analysis
====================

The Vienna APVDAQ system has its origin in the late 1990s, and has grown and been improved since then.
Along with the hardware, also the software has grown and hence now consists of several steps rather
than a single piece of software.


DAQ and Analysis Chain
----------------------

Step 0: APVDAQ Software (=online) - CVI/LabWindows under Windows
        * controls and reads hardware, provides quick online analysis for online data quality check
        * can record software (pedestal), hardware (normal) or calibration runs
        * saves raw data (default) or hardware-zero-suppressed data

Step 1: APVDAQ_Analysis - CVI/Labwindows under Windows
        * essentially an improved version of step 0, reads step 0 data from file and performs pedestal 
          subtraction, common-mode correction, hit finding and clump finding (=2D-clustering; we record
          typically 6 samples along the shaped waveform for each event for later peak time reconstruction;
          thus clustering is not only done along strip axis, but also in time -> we search for contiguous
          hit clouds within the two-dimensional x-t-domain and sum up the cluster for each time point)
        * saves clustered waveform hit data (typically 6 sampled values per hit)

Step 2: hitfitgui - ROOT under Linux
        * reads the clustered waveform hit data from step 1 and performs a waveform fit for each hit with the
          reference waveform created from calibration data, resulting in peak amplitude and peak time for each
          hit which is compared to a reference time obtained with a TDC (included in the APVDAQ hardware)
        * saves peak amplitude and time information per hit

Step 3: anarun.C - ROOT under Linux
        * reads the hit properties file from the previous step and fills the data into several histograms like
          Signal, SNR, Noise, Cluster Width, Eta distribution etc. for subsequent graphical display, including
          Landau*Gauss fits and p-n side correlations
        * saves several plot canvasses as PS files


What we don't have
------------------

Tracking, alignment and such things. I think that the best starting point for these functions is the step 2
output data, as this is the most compact form of data and almost directly represents spatial hit points.


General things to consider
--------------------------

* All counting starts from zero
* Strip numbers are counted by hybrids and can span over up to 4 APV chips (=strip numbers 0..511)
* The first 600 events are always software-triggered and used for pedestal and noise evaluation. Thus, event
  numbers 0..599 will never appear in the zero-suppressed data
* The TLU event number is stored separately and does not correspond to the APVDAQ internal event number
* Zones were introduced to label detector regions of different properties, such as the 16 (!) geometrically
  different regions of the SiLC test structures, each comprising only 16 strips
         

Step 1 (APVDAQ_Analysis) output data format
-------------------------------------------

The first step of offline analysis produces a zero-suppressed data file stream out
of the raw data file, thus reducing the file size considerably. 
The zero-suppressed file (file name ends with "_cluster.hit") uses the following structure.


#define MAX_SUBEVENTS       6             // maximum number of samples in one readout buffer
#define MAX_HITS_PER_EVENT  200           // maximum number of hits per event
#define MAX_CLUSTERWIDTH 20               // maximum cluster width

#define P_SIDE	0                         // p-side of the sensor
#define N_SIDE	1                         // n-side of the sensor 

typedef struct {
   unsigned long event;                   // APVDAQ event number
   unsigned char numberofsubevents;	  // number of samples in this event
   unsigned short numberhits;		  // total number of hits (clumps) in this event

   unsigned char hitbegin;  	          // sample number of the begin of the hit
   unsigned char hitlength;     	  // number of samples of this hit
   unsigned short first_strip;		  // first strip of the cluster
   unsigned char clwidth;		  // cluster width
   double center_strip;  		  // center-of-gravity of the cluster (counted in strip units)
   double center_coord;  		  // coordinate of the center strip
   unsigned char side;           	  // sensor side, P_SIDE = 0, N_SIDE = 1
   unsigned char module;                  // module number (internal=0,1,...)
   unsigned char zone;			  // zone number (internal=0,1,...)
   unsigned short tlueventnumber;	  // TLU event number (was previously reserved2)

   double eta;				  // eta of cluster peak
   double clnoise;			  // calibrated cluster noise
   double reserved;			  // used for calibration constant

   double clsigcal[MAX_SUBEVENTS];	  // calibrated cluster signal of all subevents

   double tdc;                            // time of digital conversion
   
   double strsigcal[MAX_CLUSTERWIDTH][MAX_SUBEVENTS];	// calibrated strip signal of all samples
   double strnoise [MAX_CLUSTERWIDTH];			// calibrated strip noise

} Clusterhit_t;

Clusterhit_t clhits[MAX_HITS_PER_EVENT];  // cluster hits of the current event


Each structure array element describes a single clump (2D cluster) found in one sensor plane
in one particular event.
The APV25 chips read out 6 consecutive samples for each strip, spaced by 25ns (MAX_SUBEVENTS).
Hence, the term "cluster" is extended into 2D, with strip number and time sample as coordinates,
leading to a "clump".
A clump is a cluster built from one or more strips and spanning over several time samples.
The total number of clumps per event is stored in the "numberofhits" field, so the procedure
to read the complete event data is to read one element first, then numberofhits-1 more elements.


Step 2 (hitfitgui) output data format
-------------------------------------

The data structure looks very similar to the previous one, except that the (typically) 6 samples values along
the shaped waveform are replaced by a single value pair: peak amplitude and time. Well, actually, there are 3
pairs obtained in different ways, where the last one (i.e. sigcal[2] and tpeak[2]) are most accurate.
The output file (file name ends with "_cluster.hit.fit") uses the following structure.


typedef struct {
   unsigned long event;                 // master event number
   unsigned char numberofsubevents;     // number of subevents in this master event
   unsigned short numberhits;           // total number of hits (clumps) in this event
   unsigned short numfithits;           // total number of fitted hits (clumps) in this event

   unsigned char hitbegin;              // subevent number of the begin of the hit
   unsigned char hitlength;             // number of subevents of this hit
   unsigned short first_strip;          // first strip of the cluster
   unsigned char clwidth;               // cluster width
   double center_strip;                 // center strip of the cluster
   double center_coord;                 // u or v coordinate of the center strip

   unsigned char side;                  // sensor side, N_SIDE, P_SIDE
   unsigned char module;                // module number (internal=0,1,...)
   unsigned char zone;                  // zone number (internal=0,1,...)

   double tdc;                          // time of digital conversion

   double eta;                          // eta of cluster peak
   double clnoise;                      // calibrated cluster noise

// OLD:
//   double reserved;                     // reserved for future use
//
// NEW:
   unsigned short tlueventnumber;	  // TLU event number
   unsigned short reserved2;
   unsigned long reserved3;

   double sigcal[3];                    // fitted hit amplitude {raw data max / expfit / calfit}
   double tpeak[3];                     // fitted peak time {raw data max / expfit / calfit}
   
   double strsigcal[MAX_CLUSTERWIDTH][MAX_SUBEVENTS];	// calibrated strip signal of all samples
   double strnoise [MAX_CLUSTERWIDTH];			// calibrated strip noise

} FittedHit_t;

FittedHit_t fithits[MAX_HITS_PER_EVENT];


Each structure array element describes a single clump (2D cluster) found in one sensor plane
in one particular event.
The total number of clumps per event is stored in the "numberofhits" field, so the procedure
to read the complete event data is to read one element first, then numberofhits-1 more elements.





To be continued...
ELOG V3.1.4-966e3dd