BTOW map problem and solution

If you are not familiar with the map problem follow this discussion in the emc-list. Basically, bacause of swapped fiber optics or swapped signal cables some of the towers are not in the software_id position they are supposed to be. This corresponds to more or less 100 swaps (most in the west side) that corresponds to about 200 towers.

Some of the swapped towers could be fixed because they originated from swapped signal cables. When the swap happened at fiber optics level they were left as they are because the fibers are difficult to access and are frigile. In this case, and for previous runs, a software patch was made in order to recover the swapped towers.

The list of swapped towers can be found here:

The software patch is implemented in 3 libraries: StDaqLib (StEmcDecoder), StEmcRawMaker and StEmcADCtoEMaker and the idea is the following
  1. for 2006 (and future) data StEmcDecoder will have the correct map and all database and productions will be done correctly. In this case the patch is invisible for the user.
  2. for 2004/2005 data, because of the large amount of tables in database and because of the many productions that were done, the patch in StEmcDecoder, is turned OFF by default. This was done because changing the database and old productions is too much trouble at this point. In this case, the patch works in the following way:
    1. StEmcDecoder will use the non-corrected map by default, although it is possible to know the correction that should be applied for each tower using the method

      StEmcDecoder::GetTowerBugCorrectionShift(int id_old, int& shift)

      where id_old is the non-correct software id and shift is the shift that should be applied to the id. In this case:

       id_corrected = id_old + shift
    2. StBemcRaw (in StEmcRawMaker) was updated with a method


      That enables (true) or disables (false) the on-the-fly correction. The default options are:

      for StEmcRawMaker -> false (map correction IS NOT applied for PRODUCTION)
      for StEmcADCtoEMaker ->true (map correction IS applied for USER ANALYSIS)

      IMPORTANT: If you run your analysis with StEmcADCtoEMaker The StEmcRawHits in StEmcCollection will be automatically have the map FIXED!!!! This is not the case if you use StEmcRawMaker or StMuEmcCollection for analysis.

The consequences (only for 2004/2005 data):

  1. muDST data is saved with the non-corrected software id

    If you read muDST data directly, without running ADCtoEMaker you need to correct the ids by hand. The following code is an example how to do that correction. You need to use StEmcDecoder to get the correct id

    StEmcDecoder* decoder = new StEmcDecoder(date, time); // date and time correspond to the event timestamp
    StMuEmcCollection* emc = muMk->muDst()->muEmcCollection(); // get the MuEmcCollection from muDST

    //...................  B T O W   ....................
    for (int idOld = 1; idOld <= 4800 ; idOld++) 
        int rawAdc= emc->getTowerADC(idOld);
        int shift = 0;   
    idNew = idOld + shift;

    // user code starts here

  2. Database is saved with non-corrected software id
  3. StEmcCollection (StEvent format) after you run StEmcADCtoEMaker at analysis level is created with correct software id.
  4. StBemcTables. To enable the tower map bug, use the flag kTRUE in StBemcTables constructor. See examples bellow
    // This method returns values for NON-CORRECTED IDs (old ids, as the tables are saved in DB)
    tables = new StBemcTables();
    float pedestal, rms;
    tables->getPedestal(BTOW, idOld, 0, pedestal, rms);

    // This method returns values for CORRECTED IDs
    tables = new StBemcTables(kTRUE); // Use kTRUE to enable the BTOW map correction in StBemcTables. Default is kFALSE
    float pedestal, rms;
    tables->getPedestal(BTOW, idNew, 0, pedestal, rms);