FGT Pedestal Maker, Reader, and Plotter

See Renee's instructions how to create and upload pedestals/status attached
-----------------

I had hoped to write this tutoral once all code was in CVS and I had automated all of the loading and writing scripts. Unfortunately these conditions are only partially fullfilled at this time, so this procedure describes how to make pedestal and status files needed to load to the database:

  • mkdir FgtPed
  • cd FgtPed
  • stardev
  • cvs co StRoot/StFgtPool/StFgtRawDaqReader
  • cvs co StRoot/StFgtPool/StFgtCosmicTestStandGeom
  • cvs co StRoot/StFgtPool/StFgtPedMaker
  • cvs co StRoot/StFgtPool/StFgtStatusMaker
  • cvs co StRoot/StFgtPool/StFgtQaMakers
  • cons
  • cvs co StRoot/StFgtPool/StFgtQaMakers/macro/makeFgtPedAndStat.C

You will need to open makeFgtPedAndStat.C and set the database time manually (next step is to automate this).  This timestamp is used to get the correct mapping:
  • dbMkr->SetDateTime(20121108,000000);
You also need to set the file and output file name fields at the top, but this is easily done dynamically if you wish.  Next simply run the macro :  root4star -b -q makeFgtPedAndStat.C.  Eight files will be part of the output:
  • Filename.FGT-ped-DB.dat
  • Filename.FGT-ped-stat-info.txt
  • Filename.FGT-ped-stat.pdf
  • Filename.FGT-ped-stat.ps
  • Filename.FGT-ped-stat.root
  • Filename.FGT-ped-stat.txt
  • Filename.FGT-stat-DB.dat
  • fgtMapDump.csv
The .dat files need to be loaded to the database using the macros
  • cvs co StRoot/StFgtUtil/database/macros/write_fgt_pedestal.C
  • cvs co StRoot/StFgtUtil/database/macros/write_fgt_status.C
  • cvs co StRoot/StFgtUtil/database/macros/fgtPedestal.h
  • cvs co StRoot/StFgtUtil/database/macros/fgtStatus.h
Now you need to open each of these macros and set the database time and file input correctly before running via the standard root4star -b -q write_fgt_pedestal.C.



Software for computing (making), reading (from file or DB) and plotting pedistals has been written.  The DB functionality is not fully implemented as of Jan 10, 2012.

 


Files

The current code for reading and writing pedistals is contained in the following files

$CVSROOT/offline/StFgtDevel/StRoot/StFgtPedMaker/StFgtPedMaker.h
$CVSROOT/offline/StFgtDevel/StRoot/StFgtPedMaker/StFgtPedMaker.cxx
$CVSROOT/offline/StFgtDevel/StRoot/StFgtPedMaker/StFgtPedReader.h
$CVSROOT/offline/StFgtDevel/StRoot/StFgtPedMaker/StFgtPedReader.cxx

An example of using the pedistal maker is in the file

$CVSROOT/offline/StFgtDevel/StRoot/StFgtPedMaker/macro/makeCosmicPeds.C

An example of using the pedistal reader is in the file

$CVSROOT/offline/StFgtDevel/StRoot/StFgtPool/StFgtPedPlotter/macro/plotPedsFromFile.C

An auxillary class to make a nice plot of pedistals is found in the files

$CVSROOT/offline/StFgtDevel/StRoot/StFgtPool/StFgtPedPlotter/StFgtPedPlotter.h
$CVSROOT/offline/StFgtDevel/StRoot/StFgtPool/StFgtPedPlotter/StFgtPedPlotter.cxx

After the software review, it is expected to move these files to StRoot instead of offline/StFgtDevel/StRoot


StFgtPedMaker

The StFgtPedMaker is designed to use the FGT online containers in StEvent.  The pedistals are the mean ADC value over all events processed by the chain, while the "RMS" is actually the standard deviation.  Running sums are computed in the StFgtPedMaker::Make function, and the final values are computed in ::Finish member function.  The values can then be written to a file, which contains four columns: (1) geoId of the strip (2) timebin (3) pedistal, i.e. mean ADC (4) RMS, i.e. st. dev.

The pedistal maker has the following user functions to modify the options:

   void setToSaveToFile( const Char_t* filename );
   void setToSaveToDb( Bool_t doIt = 1 );
   void setTimeBinMask( Short_t mask = 0xFF );

To save to file, one uses the "setToSaveToFile" function and passes the filename to which the information should be saved.  The "setToSaveToDb" function is not yet implemented.  It was decided not to allow this functionality in this class, but rather have a decidated macro to upload a text file generated by this class into the DB.  The time bin mask is set via the "setTimeBinMask" function.  All time bins which are flagged "false" in the mask will be ignored.  Note: time bin 0x01 is the 0th time bin, 0x10 is the 4th time bin, etc. 

The status of the strips (e.g. dead, broken, and/or hot strips) is not considered in making the pedistals.  All pedistals are computed for the time bins specified in the time bin mask.  As status of the strips is given by the StFgtStatusMaker/Reader, it is expected that the code querying the StFgtPedReader for a pedistal will also query the StFgtStatusReader for a status of the strip, and then choose to act accordingly.  In this manner, the status does not have to be computed before computing the pedistals, but instead should be computed before using the pedistal information.


StFgtPedReader

It was anticipated that all calls for pedistals, in all software, would use the StFgtPedReader.  The StFgtPedReader initially either loads the pedistals from file, or from the database, and holds them in an associative array, allowing both sparse data and for fast look ups.  In future versions, one could change the implimentation to a static array, if one desired faster processing but a larger memory imprint.  The code has the following accessor function, to read the time bine for a given geoId and time bin:

   // accessor: input is geoId and timebin, output is ped and
   // st. dev. (err).  Returns error if pedistal not found for given geoId and timebin
   Int_t getPed( Int_t geoId, Int_t timebin, Float_t& ped, Float_t& err ) const;

One can also set a time bin mask via

   void setTimeBinMask( Short_t mask = 0xFF );

Time bins with bits set to false will be ignored.  The fewer time bins loaded, the faster the initial load and the faster the look up time for each individual geoId afterwards.

The DB interface still needs to be programmed as of Jan 10, 2012.


StFgtPedPlotter

This produces a nice plot of the pedistals for a given quadrant (10 APVs).  The procedure is straight forward. See the macro and the code for an example of how this is done.  Note: the ped. plotter gives an example of how to use the ped. reader.


Comments

Usually 2,000 are used to compute pedistals.  The amount of time taken by the StFgtPedReader/Maker is significantly less than the amount of time used by the RawMaker to create the FGT containers in the StEvent and read the DAQ file from disk, and therefore can be considered negligible for the present.

An example pedistal file is attached.  This file is from the cosmic test stand, when quadrants 008, 018, 007 were on the top, middle, and bottom possition, respectively.  Plots of typical pedistal RMS can be found on page 1 of the QA plots produced during the cosmic test stand.  The base directory is http://www.star.bnl.gov/protected/spin/sgliske/fgtCosmicQA/, from which you can then select a quadrant, and then select a .pdf file.  The files are named via the quandrant and the time the data was taken.