how-to by Jan


offline DB upload (write)

 Loose notes helping Justin in uploading of the offline DB tables for Endcap


1) Monitoring current content of DB,


use web interface: 

The following query selects pedestal tables for sector 1 (element ID) for year 2007+ 

results with just 2 tables:

  • the official (just one) table for 2007 run (flavor 'ofl') valid since April 5, 4:40 pm  GMT   (note it is not EST)
  • test table ( flavor=online  ) for 2008 run, valid since February 22

If you click on 'Control' you will see the content of this table, but I rarely do that


2) Upload  new tables to DB

  • need special DB write privileges, only Jan Y Justin have such.
  •  setenv DB_ACCESS_MODE write
  • execute _working_ version of eemcDb with proper params
  • you do NOT need any more the dbServer.xml file pointing to robinson.db, so do NOT have it in your main directory

Note, the last successfully compiled and working eemcDb is located at:

/star/u/balewski/dbaseIO-2008-sc.starp/eemcDb - use it as long as it works.

The source code is at sc.starp , user=sysuser, directory: junk2/


Good luck,



offline DB usage (read)

DB usage : ped, gains, fail/stat flags for EEMC towers/pre/post/SMD

Wed Oct 27 13:09:10 EDT 2004
Key features:




  • EEMC DB consist of 4 basic components: map of hardware channels to logical elements, peds, gains and fail/stat bits. The content of all DB tables for all time stamps is described in eLog entry 605 .


  • An independent set of tables with the 'sim' flavor is stored with beginTime of Jan 1 1999. If selected, allows to run ~exactly the same code on the M-C or real events.
    Content of 'ideal' simulation tables:
    * channel map as of October 2004
    * tower gains : 4096 ADC=60 GeV transverse electromagnetic energy in the tower
    * pre/post/smd gains : 23,000 ADC = 1 GeV of energy deposit by a MIP in scint
    * all pedestals set at 0 ADC, but sigPed of 1.0 ADC for Towers and of 0.7 ADC for MAPMT
    * masks: fail=stat=0 , meaning all elements are good

    The above content of sim-tables is consistent with the actual fast EEMC simulator code and hits stored in StEvent & muDst.
    Note, in the M-C a sampling fraction of 5% is assumed while converting GEANT energy deposit in tower scint layers to tower ADC. In order to get ~right pi0 or gamma energy a fudge factor of ~4/5 is still needed.


  • Example of geometrical manipulations:
  • The definition of all possible stat/fail bits values is at $STAR/StRoot/StEEmcDbMaker/cstructs/eemcConstDB.hh.
    For 2004 data the following 'stat' bits are in use:
    #define EEMCSTAT_ONLPED   0x0001 // only pedestal visible
    #define EEMCSTAT_STKBT    0x0002 // sticky lower bits
    #define EEMCSTAT_HOTHT    0x0004 // masked for HT trigger
    #define EEMCSTAT_HOTJP    0x0008 // masked for JP trigger
    #define EEMCSTAT_HIGPED   0x0010 // ped is very high but channel seems to work
    #define EEMCSTAT_HOTSTR   0x0020 // hot esmd strip
    #define EEMCSTAT_JUMPED   0x0040 // jumpy  ped over several chan over days
    #define EEMCSTAT_WIDPED   0x0080 // wide ped over:2.5 ch  towers, 1.5 ch MAPMT's
    It is up to a user what 'stat' condition is fatal for his/her analysis.
    Potentaily good elements may have set the 'STKBT', meaning the lowest bit(s) did not worked and only the energy reolution is worse.
    'JUMPED' bit means ped jumped by 20-40 ADC counts during one run. It is fatal for calibration with MIP's but ~OK for reco of 20 GeV gammas.

    For the record the following 'fatal' bits are set and all users should reject all elements marked that way.

    #define EEMCFAIL_GARBG  0x0001  // exclude from any analysis
    #define EEMCFAIL_HVOFF  0x0002  // HV was off
    #define EEMCFAIL_NOFIB  0x0004  // signal fiber is broken
    #define EEMCFAIL_CPYCT  0x0008  // stuck in copyCat mode
  • To see all stat/fail tables for sector 5 type:
    ~/ezGames/dbase/src/eemcDb -p Ver2004d/sector05/eemcPMTstat -H -t 2001
    To see content of stat/fail table for a given time stamp type:
    ~/ezGames/dbase/src/eemcDb -p Ver2004d/sector05/eemcPMTstat -g -t 1080832032


    Use constants defined in


    Access to EEMC DB-maker within the chain
    In .h add
    class  StEEmcDbMaker;
    class StYourAnalysistMaker : public StMaker {
      StEEmcDbMaker *eeDb;
    In .cxx add
    #include "StEEmcDbMaker/StEEmcDbMaker.h"
    #include "StEEmcDbMaker/EEmcDbItem.h"
    #include "StEEmcDbMaker/cstructs/eemcConstDB.hh"
    #include "StEEmcUtil/EEfeeRaw/EEname2Index.h"
    StYourAnalysistMaker::Init() {
     // connect to eemcDB
      eeDb = (StEEmcDbMaker*)GetMaker("eemcDb"); // or "eeDb" in BFC
      assert(eeDb); // eemcDB must be in the chain, fix it


    Details of DB usage for muDst events , loop over hist for one event:
     // choose which 'stat' bits are fatal for you, e.g.
     uint killStat=EEMCSTAT_ONLPED  | ......... ;
       StMuEmcCollection* emc = mMuDstMaker- >muDst()- >muEmcCollection();
      //.........................  T O W E R S .....................
      for (i=0; i < emc->getNEndcapTowerADC(); i++) {
        int sec,eta,sub,rawAdc; //muDst  ranges:sec:1-12, sub:1-5, eta:1-12
        assert(sec>0 && sec< =MaxSectors);// total corruption of muDst
        //Db ranges: sec=1-12,sub=A-E,eta=1-12,type=T,P-R ; slow method
        const EEmcDbItem *x=eeDb->getTile(sec,'A'+sub-1,eta,'T');
        ...... this is the same also for pre/post/smd (except ene fudge factor!)................
        assert(x); // it should never happened for muDst
        if(x->fail ) continue;  // drop broken channels
        if(x->stat &  killStat) continue; // drop not working channels
        if(x->gain < =0) continue; // drop it, unless you work with ADC spectra
        if(rawAdc < x-> thr) continue; // drop raw ADC < ped+N*sigPed
        float adc=rawAdc-x->ped; // ped subtracted ADC
        float ene=adc/x->gain;   // energy in GeV
        if(MCflag) ene/=0.8; //fudge factor for TOWER sampling fraction,  to get pi0, gamma energy right
        .... do your stuff ..........
     } // end of towers
     //.........................  P R E - P O S T .....................  
      int pNh= emc->getNEndcapPrsHits();
      for (i=0; i < pNh; i++) {
        int pre, sec,eta,sub;
        //muDst  ranges: sec:1-12, sub:1-5, eta:1-12 ,pre:1-3==>pre1/pre2/post
        StMuEmcHit *hit=emc->getEndcapPrsHit(i,sec,sub,eta,pre);
        float rawAdc=hit->getAdc();
        //Db ranges: sec=1-12,sub=A-E,eta=1-12,type=T,P-R ; slow method
        const EEmcDbItem *x=eeDb-> getTile(sec,sub-1+'A', eta, pre-1+'P');
        if(x==0) continue;
        ..... etc, as for towers ....
       //.......................  S M D ................................
      char uv='U';
      for(uv='U'; uv < ='V'; uv++) {
        int sec,strip;
        int nh= emc->getNEndcapSmdHits(uv);
         for (i=0; i < nh; i++) {
          StMuEmcHit *hit=emc->getEndcapSmdHit(uv,i,sec,strip);
          float rawAdc=hit->getAdc();
          const EEmcDbItem *x=eeDb->getByStrip(sec,uv,strip);
          assert(x); // it should never happened for muDst
          ... etc, as for towers ....


    Details of DB usage for StEvent , loop over hist for one event - posted for the record.
    Remember, NEVER EVER access EEMC data from StEvent. It is so slow and clumsy. It is asking for a trouble. All EEMC analysis SHOULD work on muDst ONLY - Jan
     T O W E R S 
     // choose which 'stat' bits are fatal for you, e.g.
     uint killStat=EEMCSTAT_ONLPED  | .......;
     StEvent*  mEvent = (StEvent*) StMaker::GetChain()->GetInputDS("StEvent");  assert(mEvent);
     StEmcCollection* emcC =(StEmcCollection*)mEvent->emcCollection(); assert(emcC);
     StEmcDetector* etow = emcC->detector(kEndcapEmcTowerId);  assert(etow);
     for(uint mod=1;mod < =det->numberOfModules();mod++) {
        StEmcModule*     module=det->module(mod);
        StSPtrVecEmcRawHit&     hit=  module->hits();
        int  sec=mod ; // range 1-12
        for(uint ih=0;ih < hit.size();ih++){
          StEmcRawHit *h=hit[ih];
          char sub='A'+h- >sub()-1; // range 'A' - 'E'
          int  eta=h->eta(); // range 1-12
          int  rawAdc=h->adc(); // raw ADC
          //Db ranges: sec=1-12,sub=A-E,eta=1-12,type=T,P-R; slow method
          const EEmcDbItem *x=eeDb->getTile(sec,sub,eta,'T');
          if(x==0) continue;
          ....  now follow muDst example for towers ....
        } // end of sector

    PRE1,PRE2, and POST -all mixed together preL='P','Q','R' for pres1,pres2,post, respectively StEmcDetector* det=emcC- > detector(kEndcapEmcPreShowerId)//==(14) for(int imod=1;imod < =det- > numberOfModules();imod++) { StEmcModule* module=det- > module(imod); printf("EPRE sect=%d nHit=%d\n",imod, module- > numberOfHits()); StSPtrVecEmcRawHit& hit= module- > hits(); int ih; for(ih=0;ih < hit.size();ih++){ StEmcRawHit *x=hit[ih]; int sec=x- > module(); int ss=x- > sub()-1; char sub='A'+ss%5; char preL='P'+ss/5; int eta=x- > eta(); int adc=x- > adc(); printf("ih=%d %02d%c%c%02d ss=%d -->adc=%d ener=%f ss=%d\n",ih,sec,preL,sub,eta,ss,adc, x- > energy(),ss); }

    SMD U & V are stored in SEPARATE collections StEmcDetector* det=emcC- > detector(kEndcapSmdUStripId)// U=15, V=16 for(int imod=1;imod < =det->numberOfModules();imod++) { StEmcModule* module=det- > module(imod); printf("ESMD sector=%d nHit=%d\n",imod, module- > numberOfHits()); StSPtrVecEmcRawHit& hit= module- > hits(); int ih; for(ih=0;ih < hit.size();ih++){ StEmcRawHit *x=hit[ih]; int sec=x- > module(); int strip=x- > eta(); int adc=x- > adc(); printf("ih=%d %02dU%03d -->adc=%d ener=%f\n",ih,sec,strip,adc, x- > energy()); }

    Details of the DB- Maker(s) setup in the muSort.C script:


  • By default ADC threshold (x->thr) is set at 3*sigPed. You may change 3.0 to any other (float) factor :
    myDb=new StEEmcDbMaker("eemcDb");
  • To switch to (ideal) simulation DB tables you need to change DB flavor for the St_db_Maker (different from StEEmcDbMaker ):
      St_db_Maker *dbMk=new St_db_Maker("db", "MySQL:StarDb", "$STAR/StarDb");
        ? dbMk->SetDateTime(20031120,0);  (you may need to specify the DB time stamp)
    To verify the ideal DB tables were loaded you should find in the log-file the following message for every sector:
      EEDB  conf ADC map for sector=6
    StInfo:       EEDB chanMap=Ideal EEMC mapping, (October 2004), RF
    StInfo:       EEDB calTw=Ideal EEMC tower gains, E_T 60GeV=4096ch, RF
    StInfo:       EEDB tubeTw=Ideal EEMC P-names, (October 2004), RF
    StInfo:       EEDB calMAPMT=Ideal EEMC P,Q,R,U,V gains, 23000ch/GeV, RF
    StInfo:       EEDB ped=Ideal EEMC peds/ADC at 0.0, sig: Tow=1.0, Mapmt=0.7; RF
    StInfo:       EEDB stat=Ideal EEMC stat=fail=0 (all good), RF
    To use Barrel ideal DB do
      starDb->SetFlavor("sim", "bemcPed");
      starDb->SetFlavor("sim", "bemcStatus");
      starDb->SetFlavor("sim", "bemcCalib");
      starDb->SetFlavor("sim", "bemcGain");