Zeroes suppression while filling trees

I am saving data written to a data file by an ADC operating in “zeroes suppression mode” into a TTree . In this mode, only ADC channels which have non-zero values are written to the data file. There were 3 ADC’s of 32 channels each. So, I elected to save the values written by each ADC in arrays. (3 ADC’s, 32 channels each) <=> (3 arrrays, 32 elements each). Each array is saved in separate TBranches. The problem is the following. Since the ADC’s only write values that are non-zero, the corresponding arrays in the TBranches have only a few elements that are non-zero when the TBranches are filled. Thus I have many zeroes that are being saved into my TTree that eat up disk space and computer time. Is there any way to do a “zeroes suppression” when filling the TBranches? In other words, is there any way to fill the elements of the arrays in the TBranches only if it has a non-zero value?

Example of what I’m doing:

TTree *tree = new TTree(“tree”,“Run Tree”);
unsigned int vmeadc_l_1[32];
tree->Branch(“vmeadc_l_1”, &vmeadc_l_1, “vmeadc_l_1[32]/i”);

//The program loops over all conversion events in the data file
//
for(int k=0; k<NUM_CHAN; k++)
{
vmeadc_l_1[k] = 0;
}

//The program reads the adc values and saves them into the appropriate //elements of the array. The array might look something like this after
//this occurs:
//vmeadc_l_1[32] = {0, 0, 0, 0, 0, 174, 0, 0, 67, 0, 0, 0, 3007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
//In this case, the undesired result is that 29 zeroes have been filled, and only 3 non-zero values have been filled.
//I would like only the three non-zeroes filled and nothing else.

tree->Fill();

//After looping over all conversion events, it writes the TTree
tree->Write();

Any help would be appreciated.

Define your arrays as UShort_t instead of unsigned int.
Let the ROOT compression algorithm do its work. It will drop all zeros on the file.
Quantify what you mean by “eating space and computer time” and make sure you
to measure the space on disk and the computer time used.

Rene