How to enter new TClonesArray into MuDst

I will use the example of adding a TClonesArray for the class StMuFgtAdc to show how to add a new TClonesArray for an existing detector.  Adapt the following for your particular case.

1) Make a new class StMuFgtAdc which inherits from TObject.

  • Name must start with StMu
  • It is good to make the number of bits used a multiple of 4, otherwise saving unused space due to packing issues

2) Be aware that 6 files are relevant

StRoot/StMuDSTMaker/COMMON/StMuArrays.cxx
StRoot/StMuDSTMaker/COMMON/StMuArrays.h
StRoot/StMuDSTMaker/COMMON/StMuDst.cxx
StRoot/StMuDSTMaker/COMMON/StMuDst.h
StRoot/StMuDSTMaker/COMMON/StMuDstMaker.cxx
StRoot/StMuDSTMaker/COMMON/StMuDstMaker.h

3) Modify StMuArrays.h

  • Add an enum for the new TClonesArray
    • Find the enum fgtTypes
    • Add a new enum value for the TClonesArray, based on the class name and starting with muFgt.
    • The enum name is also generally plural.
    • In this case, I add muFgtAdcs
  • Set the new total number of fgt TClonesArrays
    • Find __NFGTARRAYS__
    • Set it to the number of TClonesArrays, i.e. should be the same as the number of values in the enum.
    • In my case, I up the value from 3 to 4.


4) Modify StMuArrays.cxx

  • Identify a name with the TClonesArrays
    • Find the line with /*fgtArrayNames    [__NFGTARRAYS__    ]*/
    • Add the class name, without the leading StMu, in quotations, in the correct position (must match the enum), followed by a comma
    • I add "FgtAdc",
  • Identify the class type with the TClonesArray
    • Find the line with /*fgtArrayTypes   [__NFGTARRAYS__     ]*/
    • Add the class name, exactly, in quotations, in the correct position (must match the enum), followed by a comma
    • I add "StMuFgtAdc",
  • Set the initial value for the number of elements
    • Find the line with /*fgtArraySizes    [__NFGTARRAYS__    ]*/
    • Set an initial value for the size of the TClonesArray followed by a comma
    • I add 2000,
  • Initialize the counters
    • Find the line with  /*fgtArrayCounters    [__NFGTARRAYS__    ]*/
    • Add an extra zero-comma (i.e. "0,") so that the number of 0, matches __NFGTARRAYS__
    • I'm adding one new array, so I add 0,

5) Modify StRoot/StMuDSTMaker/COMMON/StMuDstMaker.cxx

  • Include the header
    • Add the include for the class, with the other StMuFgt* includes
    • I add '#include "StMuFgtAdc.h"' after the line for StMuFgtStripAssociation
  • Ignore the TObject streamer (i.e. don't save fields inherited from TObject parent)
    • Find the line with StMuFgtStrip::Class()->IgnoreTObjectStreamer();
    • After the last FGT related class line, and a new line for the new class
    • I add: StMuFgtAdc::Class()->IgnoreTObjectStreamer();
  • Fill the class
    • Find the function void StMuDstMaker::fillFgt(StEvent* ev)
    • There's a pointer to the fgtCollection in the StEvent
    • Figure out how to fill your new class based on the information in StEvent
    • To actually add the class to the TClonesArray, you must use StMuDstMaker::addType(...)

6) No need to modify other files: StMuDst.h, StMuDst.cxx, StMuDstMaker.h

  • Since we just added a new TClonesArray, no need to modify
  • Adding a new class rather than a new TClonesArray would be different

7) Compile and test...

  • To access the new array, just use StMuDst::fgtArray( type ) as usual, but use the enum value for the new class as the type.