Slow fill tree function

Hey Good People!!
I am trying to fill a root tree while acquiring data from a drs4 board.
When i use many channels - so i have more data to save - my rate is going down because of the slowness of the tree->Fill function. How can I speed up?

// acquiring data for deltaT time
  while ((time(0) - t0) < cset.deltaT) {
        /* start board (activate domino wave) */
        while (b->IsBusy());

        /* read all waveforms */
        b->TransferWaves(0, 8);
        for (int ch = 0; ch < maxchan; ch++) {
            ev.eventID = totevents;
            b->GetTime(0, 2 * ch, b->GetTriggerCell(0), ev.time_array[ch]);
            /* decode waveform (Y) array of first channel in mV */
            b->GetWave(0, 2 * ch, ev.wave_array[ch]);

       tree->Fill();  //<< this is slowing down my rate

This is my tree definition:

     TTree * tree;
    tree = (TTree*) new TTree("t1", "title");

    TBranch * b_eventId = tree->Branch("eventID", &ev.eventID, "eventID/I");
    sprintf(branchDef, "time_array[%d][1024]/F", SANTA_MAX);
    TBranch * b_time_array = tree->Branch("time_array", &ev.time_array[0][0], branchDef);
    sprintf(branchDef, "wave_array[%d][1024]/F", SANTA_MAX);
    TBranch * b_wave_array = tree->Branch("wave_array", &ev.wave_array[0][0], branchDef);

If i don’t fill the tree i get about 50k events in 100 seconds, if i do fill the tree i get about 10k in same time. Thank you

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.