Database

Now the FPD/FMS data base tables have been created including geometry, mapping and calibration tables. These pages describe the data structure and how to use the FPD/FMS database. Please note the online database browser is a nice tool to get intuitive informaton of the tables stored. StFmsDbMaker, which acts as the interface between end user makers and the database is developed and described in more details in the corresponding subsection.

Geometry & Mapping

 The following FMS database tables are defined for geometry and mapping.

 

 

  • Channel geometry

     $STAR/StDb/idl/fmsChannelGeometry.idl 

/* fmsGeometry.idl
*
* Table: fmsGeometry
*
* description: // FPD & FMS & FHC detector geometry
*/
/* Detector Name detectorId ew ns type nX nY */
/* FPD-North 0 0 0 0 7 7 */
/* FPD-South 1 0 1 0 7 7 */
/* FPD-North-Pres 2 0 0 1 7 1 */
/* FPD-South-Pres 3 0 1 1 7 1 */
/* FPD-North-SMDV 4 0 0 2 48 1 */
/* FPD-South-SMDV 5 0 1 2 48 1 */
/* FPD-North-SMDH 6 0 0 3 1 48 */
/* FPD-South-SMDH 7 0 1 3 1 48 */
/* FMS-North-Large 8 1 0 4 17 34 */
/* FMS-South-Large 9 1 1 4 17 34 */
/* FMS-North-Small 10 1 0 4 12 24 */
/* FMS-South-Small 11 1 1 4 12 24 */
/* FHC-North 12 1 0 5 9 12 */
/* FHC-South 13 1 1 5 9 12 */

struct fmsChannelGeometry {
octet detectorId; /* detector Id */
octet type; /* 0=SmallCell,1=Preshower,2=SMD-V,3=SMD-H,4=LargeCell,5=HadronCal */
octet ew; /* 0=east, 1=west */
octet ns; /* 0=north, 1=south */
octet nX; /* # of columns, max_channel is nX*nY */
octet nY; /* # of rows, max_channel is nX*nY */
};

  • Detector position

     $STAR/StDb/idl/fmsDetectorPosition.idl 

/* fmsPosition.idl
*
* Table: fmsPosition
*
* description: // FPD & FMS & FHC detector width and positions
*/

struct fmsDetectorPosition {
octet detectorId; /* detector Id */
float xwidth; /* x width */
float ywidth; /* y width */
float xoffset; /* xoffset from beam line to inner edge of detector */
float yoffset; /* yoffset from beam line to center of detector */
float zoffset; /* z position where we measure x,y */
};

  • Detector map

     $STAR/StDb/idl/fmsMap.idl 

/* fmsMap.idl
*
* Table: fmsMap
*
* description: // FMS & FPD detector map
*/

struct fmsMap {
octet detectorId; /* DetectorId */
unsigned short ch; /* Ch 1-578*/
octet qtCrate; /* QT crate# 1-4 & 7 */
octet qtSlot; /* QT slot# 1-16 */
octet qtChannel; /* QT channel# 0-31 */
};

  • PatchPanel to detector map

     $STAR/StDb/idl/fmsPatchPannelMap.idl 

/* fmsPatchPanelMap.idl
*
* Table: fmsPatchPanelMap
*
* description: // FMS detector to patch panel map
*/

/* module 1=North Large, 2=South Large, 3=North Small ,4=South Small => moduleIDs */

struct fmsPatchPanelMap {

/* channel# 1-548 for L and 1-288 for S*/
octet ppPanel[548]; /* panel# 1-2 */
octet ppRow[548]; /* row# 1-20 */
octet ppColumn[548]; /* column# 1-16 */
};

  • PatchPanel to QT map

     $STAR/StDb/idl/fmsQTMap.idl 

/* fmsQTMap.idl
*
* Table: fmsQTMap
*
* description: // FMS patch panel to QT map
*/

/* north=1/south=2 => sideIDs */

struct fmsQTMap {
/* panel# 1-2 */
/* row# 1-20 */
/* column# 1-16 */
octet qtCrate[2][20][16]; /* QT crate# 1-4 */
octet qtSlot[2][20][16]; /* QT slot# 1-16 */
octet qtChannel[2][20][16]; /* QT channel# 0-31 */
};

 

R/W DB

Below is mostly copied from Akio's page on how to read/write DB tables in a macro.

 FMS DB example

• Simple "how to Creating Offline DB Tables" from Dmitry 
    o Anyone in STAR should be able to read DB from RCAS machines
    o To write to DB, you need write permission to DB. Currently only Akio and Dmitry can write. Dmitry can add people as needed.
    o Only Dmitry can delete, or mark as de-activated DB entries.
    o For reading DB : unsetenv DB_ACCESS_MODE or setenv DB_ACCESS_MODE read
    o For writing DB : setenv DB_ACCESS_MODE write, and do not forget to unsetenv DB_ACCESS_MODE when done.

• STAR DB Broswer : Calibration DB , Geometry DB

• Look into other DB table definisions in $STAR/StDb/idl/*.idl 
    o Up to 3 dimensional array is supported 
    o Plus using one queue, DB can return array (ModuleID) of this table 
    o Thus 4 dimensional array (3 dim array in table + 1 module ID) used in fmsQTMap.idl (see below). 
    o Array is fixed length, but module ID can be variable length. 
    o For DB efficiencies, using big array block/blab is disfavored, and use small tables & moduleID is recomended.

• Edit Computing/Subsystem drupal page for documentation!

• To read/write into DB using macros 
       copy ~akio/dbServers.xml ~/
       unsetenv DB_SERVER_LOCAL_CONFIG

• For usual DB access through BFC/St_db_Maker 
      setenv DB_SERVER_LOCAL_CONFIG /afs/rhic.bnl.gov/star/packages/conf/dbLoadBalancerLocalConfig_BNL.xml

• Proposed tables and codes to read from and write into the database (examples are located at ~jgma/psudisk/fms/)
    o fmsPatchPanelMap.idl for FMS detector to patchpanel map
    Input file : qtmap2pp.txt
    Example root macro : fms_db_patchpanelmap.C 
       ** To read input file and write to DB
       root4star -q -b fms_db_patchpanelmap.C'("readtext writedb")'

      ** To read DB and write to text file
      root4star -q -b fms_db_patchpanelmap.C'("readdb writetext")'
      diff qtmap2pp.txt qtmap2pp.txt_dbout

    o fmsQTMap.idl for FMS patchpanel to QT map
    Input file for run8 : qtmap_run8.txt
    Input file for run9 : qtmap2009V1.txt
    Example root macro : fms_db_qtmap.C
       ** To read input file and write to DB for run8 (replace 2nd argument = 8 with 9 for run9)
       root4star -q -b fms_db_qtmap.C'("readtext writedb",8)'
       ** To read DB and write to text file for run8
       root4star -q -b fms_db_qtmap.C'("readdb writetext",8)'
       diff qtmap_run8.txt qtmap_run8.txt_dbout

    o fmsQTMap.idl for FPD,FMS,FHC detector to QT map
    For FMS, combine 2 DB tables (fmsPatchPanel & fmsQTMap) to create this table
    Root macro for FMS: fms_db_pp_qt_merge.C
       ** To read 2 maps from DB (fmsPatchPanel & fmsQTMap) and write fmsMap to DB for run8 (replace 2nd argument = 8 with 9 for run9)
       root4star -q -b fms_db_pp_qt_merge.C'("merge writedb",8)'
       ** To read fmsMap DB and write to text file for run8
       root4star -q -b fms_db_pp_qt_merge.C'("readdb writetext",8)'
       more fms_db_pp_qt_merge.txt

    Root macro For FPD : fpd_db_map.C

    o fmsChannelGeometry.idl for FPD,FMS,FHC detector basic numbers (id, type, Easr/West and North/south, # of row/column)
    Root macro : fms_db_ChannelGeometry.C

    o fmsDetectorPosition.idl for FPD,FMS,FHC detector position in STAR frame 
    Root macro : fms_db_detectorposition.C

    o fmsGain.idl/fmsGainCorrection.idl for FPD,FMS,FHC gain(detectorId, channel number, gain/gaincorr)
    Root macro : fms_db_fmsgain.C/fms_db_fmsgaincorr.C (they work in a similar way)        ** To read input gain file and write gain information to DB for run8 pp200 (the macro takes combined option of run8/run9 and dAu200/pp200)
       root4star -q -b fms_db_pp_fmsgain.C'("readtext writedb", "run8 pp200")'
       ** To read fmsGain DB and write to text file for run8 pp200
       root4star -q -b fms_db_fmsgain.C'("readdb writetext", "run8 pp200")'
 

StFmsDbMaker

StFmsDbMaker is the interface between the STAR FMS database and user makers. It provides access methods to all FPD/FMS related data in the STAR database such as mapping and calibration. (currently only at /star/u/jgma/psudisk/fms/StRoot/StFmsDbMaker) Small chain to test : root4star -q -b /star/u/jgma/psudisk/fms/mudst.C. The following is a list of functions provided by StFmsDbMaker. Please refer to the source code under CVS for details (will be checked in to CVS after peer review.).

List of functions

//! getting the whole table
fmsDetectorPosition_st* DetectorPosition();
fmsChannelGeometry_st* ChannelGeometry();
fmsMap_st* Map();
fmsPatchPanelMap_st* PatchPanelMap();
fmsQTMap_st* QTMap();
fmsGain_st* Gain();
fmsGainCorrection_st* GainCorrection();

//! utility functions related to FMS geometry and calibration
Int_t maxDetectorId(); //! maximum value of detector Id
Int_t detectorId(Int_t ew, Int_t ns, Int_t type); //! convert to detector Id
Int_t eastWest(Int_t detectorId); //! east or west to the STAR IP
Int_t northSouth(Int_t detectorId); //! north or south side
Int_t type(Int_t detectorId); //! type of the detector
Int_t nRow(Int_t detectorId); //! number of rows
Int_t nColumn(Int_t detectorId); //! number of column
Int_t maxChannel(Int_t detectorId); //! maximum number of channels
Int_t getRow(Int_t detectorId, Int_t ch); //! get the row number for the channel
Int_t getColumn(Int_t detectorId, Int_t ch); //! get the column number for the channel
Int_t getChannel(Int_t detectorId, Int_t row, Int_t column); //! get the channel number
StThreeVectorF detectorOffset(Int_t detectorId); //! get the offset of the detector
Float_t getXWidth(Int_t detectorId); //! get the X width of the cell
Float_t getYWidth(Int_t detectorId); //! get the Y width of the cell
Float_t getGain(Int_t detectorId, Int_t ch); //! get the gain for the channel
Float_t getGainCorrection(Int_t detectorId, Int_t ch); //! get the gain correction for the channel
StThreeVectorF getStarXYZ(Int_t detectorId,Float_t FmsX, Float_t FmsY); //! get the STAR frame coordinates
Float_t getPhi(Int_t detectorId,Float_t FmsX, Float_t FmsY); //! get the STAR frame phi angle
Float_t getEta(Int_t detectorId,Float_t FmsX, Float_t FmsY, Float_t Vertex); //! get the STAR frame pseudo rapidity

//! fmsMap related
Int_t maxMap();
void getMap(Int_t detectorId, Int_t ch, Int_t* qtCrate, Int_t* qtSlot, Int_t* qtChannel);

//! fmsPatchPanelMap related
Int_t maxModule();

//! fmsQTMap related
Int_t maxNS();

//! fmsGain/GainCorrection related
Int_t maxGain();
Int_t maxGainCorrection();

//! set time stamp
//void setDateTime(Int_t date, Int_t time);

//! text dump for debugging
void dumpFmsChannelGeometry(Char_t* filename="dumpFmsChannelGeometry.txt");
void dumpFmsDetectorPosition(Char_t* filename="dumpFmsDetectorPosition.txt");
void dumpFmsMap (Char_t* filename="dumpFmsMap.txt");
void dumpFmsPatchPanelMap (Char_t* filename="dumpFmsPatchPanelMap.txt");
void dumpFmsQTMap (Char_t* filename="dumpFmsQTMap.txt");
void dumpFmsGain (Char_t* filename="dumpFmsGain.txt");
void dumpFmsGainCorrection (Char_t* filename="dumpFmsGainCorrection.txt");

How to use it in user maker

#include "StFmsDbMaker/StFmsDbMaker.h"

Then use the global pointer to get access to all the FMS db table information by the methods above. For example to dump one table to a text file:

gStFmsDbMaker->dumpFmsChannelGeometry("ttest.txt");

To get a pointer to the channel geometry table:

fmsChannelGeometry_st *channelgeometry = gStFmsDbMaker->ChannelGeometry();

In your macro you'll need to load the .so files and create maker instances in the chain:

gSystem->Load("StDbBroker.so");
gSystem->Load("St_db_Maker.so");
gSystem->Load("StFmsDbMaker.so");

cout << "Setting up chain" << endl;
StChain* chain = new StChain;

cout << "Setting up St_db_Maker" << endl;
St_db_Maker* dbMaker = new St_db_Maker("db", "MySQL:StarDb", "$STAR/StarDb");
dbMaker->SetDEBUG();
dbMaker->SetDateTime(20090601, 0);

cout << "Setting up StFmsDbMaker" << endl;
StFmsDbMaker* fmsdb = new StFmsDbMaker("fmsdbmaker");
fmsdb->setDebug(1);

//Then your makers...

Please pay attention to the SetDateTime option, it sets the timestamp so the data extracted from the db will be corresponding to this time stamp. Please refer to Dmitry's page for more information about time stamp.

Timedep corrction for run 11 and tower masking

Since tower masking is  done with the same inputs in database by setting time dep. correction values negative  for bad towers, 1) how towers are masked 1) how time dep. correction files are written, 3) how they are loaded in datbase, and 4)  how the information can be fetched from database are explained below .

 

  • How towers are maseked

The xml file(Sub_L.xml) take run by run jobs and list towers for each run.

Channels are populated in different ADC & energy thresholds : 
/star/data01/pwg/mriganka/fms2015/jetData2011/new/hotCh/StRoot/StFmsHitMaker/StFmsHitMaker.cxx
SET-1
            h0->Fill(((d-8)*1000)+c);
            hh0->Fill(((d-8)*1000)+c,adc);
SET-2
            if(adc>10){
            h10->Fill(((d-8)*1000)+c);
            hh10->Fill(((d-8)*1000)+c,adc);
            }
SET-3
            if(adc>50){
            h50->Fill(((d-8)*1000)+c);
            hh50->Fill(((d-8)*1000)+c,adc);
            }
SET-4
            if(adc>100){
            h100->Fill(((d-8)*1000)+c);
            hh100->Fill(((d-8)*1000)+c,adc);
            }
SET-5
           he0->Fill(((d-8)*1000)+c);
            hhe0->Fill(((d-8)*1000)+c,e);
SET-6
           if(e>1){
            he1->Fill(((d-8)*1000)+c);
            hhe1->Fill(((d-8)*1000)+c,e);
            }
SET-7
           if(e>10){
            he10->Fill(((d-8)*1000)+c);
            hhe10->Fill(((d-8)*1000)+c,e);
            }
SET-8
            if(e>20){
            he20->Fill(((d-8)*1000)+c);
            hhe20->Fill(((d-8)*1000)+c,e);
            }

 
For each SET 4 top bincontent towers are being selected. A tower is being marked to be masked if belong in the 4*8 set. There are several common.
Generally the number is ,ess than 20.

Writes hot channels run by run  in "txt" directory with gif files in "gif"  : the inputs from the txt file will be used when writing in database. Each *.txt file for one run.
/star/data01/pwg/mriganka/fms2015/jetData2011/new/hotCh/test/run.C. The information from *.txt files will be used when database would be written run by run.

  • How time dependent files are prepared

Basic concept is to mark channels for which correction is significnat. It is such that with minum inputs in database, we can perfrom time dep. correction without overloading the database.
Some details are written  here : https://drupal.star.bnl.gov/STAR/blog/mriganka/fms-led-time

In starver SL14i from PSU TimeDepCorr.root was locally  generated.  We are listing the channels to be corrected for each time slot. Each time slot is a section of 10k data. Since the evnets nummber is unique in trigger file and microDst files there is one to one relation with time slots and MuDst event numbers.

/star/data01/pwg/mriganka/fms2015/jetData2011/old/led/test1

running the macro txt1/read.C lists : Run Number       #Events(fms_st)    time-slots    Entries in Database
taking f_runNumber.txt which is generated Sub_L.xml(RunFastJet.C)  take list(schedA96107FA7AD49F7008BAA3DE299BDEE7_$JOBINDEX.list) file which written for each run.

-- inputs in the file(f_runNumber.tx) written in  StRoot/StJetMaker/mudst/StjFMSMuDst.cxx
StjFMSMuDst::RCorrect(TMatrix* padc,TMatrix* pEmat,Int_t det,Int_t iEW,Int_t runnum,Int_t EvNum,Int_t SegNM)
/star/data02/pwg/mriganka/root12fms/fmstxt/RunDep.root (Steven Heppelmann run11 list)

fprintf(f,"%10d %6d  %6d\n", mCurrentRunNumber, nEnt, timeSlot);
fprintf(f," %hu %hu %lu  %f \n", detectorId, ch, 999000000, 1); -- for last time slot
fprintf(f," %hu %hu %lu  %f \n", detectorId, ch, endEvent, corr); -- for time slots where chages are required

 

  • Writing in database

 In couple with time dependent masked tower inputs are set into database (time dep. correction values are set to negative for mased towers).
/star/data01/pwg/mriganka/fms2015/jetData2011/old/led/test1/AKIO/writeFMSAll.C
Masked tower inputs : sprintf(fileTowers,"/star/data01/pwg/mriganka/fms2015/jetData2011/new/hotCh/test/txt/tower_rejected_%d.txt",iR);
Time dep. correction inputs : sprintf(fileTimeDep,"txt/f_%d.txt",iR);

  • Reading after implementation of time dep. and hot tower rejection in StFmsHitMaker

The macro is running for Jet recontruction with FMS towers using tower masking and tome dep. correction.
/star/data01/pwg/mriganka/fms2015/jetData2011/new/hotCh/t/mod/RunJetFinder2009pro.C
Two switches are set in StFmsHitMaker
fmshitMk->SetTimeDepCorr(1);   // does time dep, correction : default is "0"
fmshitMk->SetTowerRej (default = 1) // how tower rejection